summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-08-06 07:09:28 -0400
committerMarek Olšák <[email protected]>2019-04-01 12:37:52 -0400
commite871cbd625953c3767d53a858ab6478cd5ebc24d (patch)
treee4f2262d2e2f6be00981e500233596932b9796e6
parentc5c38e831ee8113cf97fb5308fbb687464ae2f0e (diff)
gallium: implement ARB/KHR_parallel_shader_compile
-rw-r--r--src/gallium/include/pipe/p_screen.h13
-rw-r--r--src/mesa/state_tracker/st_cb_program.c59
2 files changed, 71 insertions, 1 deletions
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index c4d6e1cc94f..d4e2d9f63ac 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -442,6 +442,19 @@ struct pipe_screen {
* \param uuid pointer to a memory region of PIPE_UUID_SIZE bytes
*/
void (*get_device_uuid)(struct pipe_screen *screen, char *uuid);
+
+ /**
+ * Set the maximum number of parallel shader compiler threads.
+ */
+ void (*set_max_shader_compiler_threads)(struct pipe_screen *screen,
+ unsigned max_threads);
+
+ /**
+ * Return whether parallel shader compilation has finished.
+ */
+ bool (*is_parallel_shader_compilation_finished)(struct pipe_screen *screen,
+ void *shader,
+ unsigned shader_type);
};
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 349ed7fa3f8..f1c62187a95 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -267,6 +267,61 @@ st_new_ati_fs(struct gl_context *ctx, struct ati_fragment_shader *curProg)
return prog;
}
+static void
+st_max_shader_compiler_threads(struct gl_context *ctx, unsigned count)
+{
+ struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+
+ if (screen->set_max_shader_compiler_threads)
+ screen->set_max_shader_compiler_threads(screen, count);
+}
+
+static bool
+st_get_shader_program_completion_status(struct gl_context *ctx,
+ struct gl_shader_program *shprog)
+{
+ struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+
+ if (!screen->is_parallel_shader_compilation_finished)
+ return true;
+
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *linked = shprog->_LinkedShaders[i];
+ void *sh = NULL;
+
+ if (!linked || !linked->Program)
+ continue;
+
+ switch (i) {
+ case MESA_SHADER_VERTEX:
+ if (st_vertex_program(linked->Program)->variants)
+ sh = st_vertex_program(linked->Program)->variants->driver_shader;
+ break;
+ case MESA_SHADER_FRAGMENT:
+ if (st_fragment_program(linked->Program)->variants)
+ sh = st_fragment_program(linked->Program)->variants->driver_shader;
+ break;
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
+ case MESA_SHADER_GEOMETRY:
+ if (st_common_program(linked->Program)->variants)
+ sh = st_common_program(linked->Program)->variants->driver_shader;
+ break;
+ case MESA_SHADER_COMPUTE:
+ if (st_compute_program(linked->Program)->variants)
+ sh = st_compute_program(linked->Program)->variants->driver_shader;
+ break;
+ }
+
+ unsigned type = pipe_shader_type_from_mesa(i);
+
+ if (sh &&
+ !screen->is_parallel_shader_compilation_finished(screen, sh, type))
+ return false;
+ }
+ return true;
+}
+
/**
* Plug in the program and shader-related device driver functions.
*/
@@ -277,6 +332,8 @@ st_init_program_functions(struct dd_function_table *functions)
functions->DeleteProgram = st_delete_program;
functions->ProgramStringNotify = st_program_string_notify;
functions->NewATIfs = st_new_ati_fs;
-
functions->LinkShader = st_link_shader;
+ functions->SetMaxShaderCompilerThreads = st_max_shader_compiler_threads;
+ functions->GetShaderProgramCompletionStatus =
+ st_get_shader_program_completion_status;
}