summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/iris/iris_screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/iris/iris_screen.c')
-rw-r--r--src/gallium/drivers/iris/iris_screen.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
index 16c3f857b00..cacac162f5c 100644
--- a/src/gallium/drivers/iris/iris_screen.c
+++ b/src/gallium/drivers/iris/iris_screen.c
@@ -621,6 +621,7 @@ void
iris_screen_destroy(struct iris_screen *screen)
{
iris_destroy_screen_measure(screen);
+ util_queue_destroy(&screen->shader_compiler_queue);
glsl_type_singleton_decref();
iris_bo_unreference(screen->workaround_bo);
u_transfer_helper_destroy(screen->base.transfer_helper);
@@ -661,6 +662,38 @@ iris_get_disk_shader_cache(struct pipe_screen *pscreen)
return screen->disk_cache;
}
+static void
+iris_set_max_shader_compiler_threads(struct pipe_screen *pscreen,
+ unsigned max_threads)
+{
+ struct iris_screen *screen = (struct iris_screen *) pscreen;
+ util_queue_adjust_num_threads(&screen->shader_compiler_queue, max_threads);
+}
+
+static bool
+iris_is_parallel_shader_compilation_finished(struct pipe_screen *pscreen,
+ void *v_shader,
+ enum pipe_shader_type p_stage)
+{
+ struct iris_screen *screen = (struct iris_screen *) pscreen;
+
+ /* Threaded compilation is only used for the precompile. If precompile is
+ * disabled, threaded compilation is "done."
+ */
+ if (!screen->precompile)
+ return true;
+
+ struct iris_uncompiled_shader *ish = v_shader;
+
+ /* When precompile is enabled, the first entry is the precompile variant.
+ * Check the ready fence of the precompile variant.
+ */
+ struct iris_compiled_shader *first =
+ list_first_entry(&ish->variants, struct iris_compiled_shader, link);
+
+ return util_queue_fence_is_signalled(&first->ready);
+}
+
static int
iris_getparam(int fd, int param, int *value)
{
@@ -878,10 +911,31 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
pscreen->query_memory_info = iris_query_memory_info;
pscreen->get_driver_query_group_info = iris_get_monitor_group_info;
pscreen->get_driver_query_info = iris_get_monitor_info;
+ pscreen->is_parallel_shader_compilation_finished = iris_is_parallel_shader_compilation_finished;
+ pscreen->set_max_shader_compiler_threads = iris_set_max_shader_compiler_threads;
genX_call(&screen->devinfo, init_screen_state, screen);
glsl_type_singleton_init_or_ref();
+ unsigned compiler_threads = 1;
+ unsigned hw_threads = sysconf(_SC_NPROCESSORS_ONLN);
+
+ if (hw_threads >= 12) {
+ compiler_threads = hw_threads * 3 /4;
+ } else if (hw_threads >= 6) {
+ compiler_threads = hw_threads - 2;
+ } else if (hw_threads >= 2) {
+ compiler_threads = hw_threads - 1;
+ }
+
+ if (!util_queue_init(&screen->shader_compiler_queue,
+ "sh", 64, compiler_threads,
+ UTIL_QUEUE_INIT_RESIZE_IF_FULL |
+ UTIL_QUEUE_INIT_SET_FULL_THREAD_AFFINITY)) {
+ /* FINISHME: Release resources. */
+ return NULL;
+ }
+
return pscreen;
}