summaryrefslogtreecommitdiff
path: root/src/threads.h
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-04-22 08:04:21 -0700
committerVito Caputo <vcaputo@pengaru.com>2017-04-22 12:25:53 -0700
commit90ad3469f3772218ce1842cf79cbc8235368bba2 (patch)
tree13e2dd4fdf987e9e47797580578ea911d3020571 /src/threads.h
parent5ba408fd9ce88a3635f745930cf09cb47a1400a2 (diff)
rototiller: add threaded rendering
This is a simple worker thread implementation derived from the ray_threads code in the ray module. The ray_threads code should be discarded in a future commit now that rototiller can render fragments using threads. If a module supplies a prepare_frame() method, then it is called per-frame to prepare a rototiller_frame_t which specifies how to divvy up the page into fragments. Those fragments are then dispatched to a thread per CPU which call the module's rendering function in parallel. There is no coupling of the number of fragments in a frame to the number of threads/CPUs. Some modules may benefit from the locality of tile-based rendering, so the fragments are simply dispatched across the available CPUs in a striped fashion. Helpers will be added later to the fb interface for tiling fragments, which modules desiring tiled rendering may utilize in their prepare_frame() methods. This commit does not modify any modules to become threaded, it only adds the scaffolding.
Diffstat (limited to 'src/threads.h')
-rw-r--r--src/threads.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/threads.h b/src/threads.h
new file mode 100644
index 0000000..5926328
--- /dev/null
+++ b/src/threads.h
@@ -0,0 +1,18 @@
+#ifndef _THREADS_H
+#define _THREADS_H
+
+#include <pthread.h>
+
+typedef struct fb_fragment_t fb_fragment_t;
+typedef struct rototiller_frame_t rototiller_frame_t;
+typedef struct thread_t thread_t;
+typedef struct threads_t threads_t;
+
+threads_t * threads_create();
+void threads_destroy(threads_t *threads);
+
+void threads_frame_submit(threads_t *threads, rototiller_frame_t *frame, void (*render_fragment_func)(fb_fragment_t *fragment));
+void threads_wait_idle(threads_t *threads);
+unsigned threads_num_threads(threads_t *threads);
+
+#endif
© All Rights Reserved