<div dir="ltr">I don't see anything in here that actually implements parallel shader compilation. Does radeon already spawn back-end threads to compile shaders or are we just lying about it? Even if it does, the front-end tends to take significant quantities of time so it'd be nice to parallelize that.<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 17, 2017 at 5:07 AM, Edward O'Callaghan <span dir="ltr"><<a href="mailto:funfunctor@folklore1984.net" target="_blank">funfunctor@folklore1984.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Edward O'Callaghan <<a href="mailto:funfunctor@folklore1984.net">funfunctor@folklore1984.net</a>><br>
---<br>
src/mesa/main/get.c | 4 ++++<br>
src/mesa/main/mtypes.h | 6 ++++++<br>
src/mesa/main/shaderapi.c | 20 ++++++++++++++++++++<br>
src/mesa/main/shaderapi.h | 3 +++<br>
src/mesa/main/shared.c | 3 +++<br>
src/mesa/state_tracker/st_<wbr>extensions.c | 4 ++++<br>
6 files changed, 40 insertions(+)<br>
<br>
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c<br>
index cf3ee63..91f21ce 100644<br>
--- a/src/mesa/main/get.c<br>
+++ b/src/mesa/main/get.c<br>
@@ -2332,6 +2332,10 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)<br>
return TYPE_INT;<br>
}<br>
<br>
+ case GL_MAX_SHADER_COMPILER_<wbr>THREADS_ARB:<br>
+ v->value_int = ctx->Shared-><wbr>MaxCompileThreads;<br>
+ return TYPE_INT;<br>
+<br>
case GL_MAX_COMPUTE_WORK_GROUP_<wbr>COUNT:<br>
if (!_mesa_has_compute_shaders(<wbr>ctx))<br>
goto invalid_enum;<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index 4a76de5..33cf33d 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -3227,6 +3227,9 @@ struct gl_shared_state<br>
* Once this field becomes true, it is never reset to false.<br>
*/<br>
bool ShareGroupReset;<br>
+<br>
+ /* GL_ARB_parallel_shader_compile */<br>
+ int MaxCompileThreads;<br></blockquote><div><br></div><div>This seems to only be initialized by st/mesa. Shoule we initialize it to 1 by default for everyone else?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
};<br>
<br>
<br>
@@ -3880,6 +3883,9 @@ struct gl_constants<br>
GLuint MaxImageSamples;<br>
GLuint MaxCombinedImageUniforms;<br>
<br>
+ /** GL_ARB_parallel_shader_compile */<br>
+ GLuint MaxShaderCompilerThreads;<br>
+<br>
/** GL_ARB_compute_shader */<br>
GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */<br>
GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */<br>
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c<br>
index 187475f..051390a 100644<br>
--- a/src/mesa/main/shaderapi.c<br>
+++ b/src/mesa/main/shaderapi.c<br>
@@ -631,6 +631,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,<br>
case GL_DELETE_STATUS:<br>
*params = shProg->DeletePending;<br>
return;<br>
+ case GL_COMPLETION_STATUS_ARB:<br>
case GL_LINK_STATUS:<br>
*params = shProg->data->LinkStatus ? GL_TRUE : GL_FALSE;<br>
return;<br>
@@ -898,6 +899,7 @@ get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params)<br>
case GL_DELETE_STATUS:<br>
*params = shader->DeletePending;<br>
break;<br>
+ case GL_COMPLETION_STATUS_ARB:<br>
case GL_COMPILE_STATUS:<br>
*params = shader->CompileStatus ? GL_TRUE : GL_FALSE;<br>
break;<br>
@@ -2234,6 +2236,24 @@ _mesa_copy_linked_program_<wbr>data(const struct gl_shader_program *src,<br>
}<br>
<br>
/**<br>
+ * ARB_parallel_shader_compile<br>
+ */<br>
+GLvoid GLAPIENTRY<br>
+_mesa_<wbr>MaxShaderCompilerThreadsARB(<wbr>GLuint count)<br>
+{<br>
+ GET_CURRENT_CONTEXT(ctx);<br>
+<br>
+ /**<br>
+ * Additions to Chapter 7 "Programs and Shaders":<br>
+ * a <count> of 0xFFFFFFFF requests an implementation-specific maximum.<br>
+ */<br>
+ if (count == 0xFFFFFFFF || count > ctx->Const.<wbr>MaxShaderCompilerThreads)<br>
+ count = ctx->Const.<wbr>MaxShaderCompilerThreads;<br></blockquote><div><br></div><div>Give that it's a 32-bit unsigned integer, 0xFFFFFFFF > ctx->Const.MaxShaderCompilerThreads so we don't need the extra case.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ ctx->Shared->MaxCompileThreads = count;<br>
+}<br>
+<br>
+/**<br>
* ARB_separate_shader_objects: Compile & Link Program<br>
*/<br>
GLuint GLAPIENTRY<br>
diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h<br>
index 99b4fe8..1ec287a 100644<br>
--- a/src/mesa/main/shaderapi.h<br>
+++ b/src/mesa/main/shaderapi.h<br>
@@ -225,6 +225,9 @@ _mesa_copy_linked_program_<wbr>data(const struct gl_shader_program *src,<br>
extern bool<br>
_mesa_validate_shader_target(<wbr>const struct gl_context *ctx, GLenum type);<br>
<br>
+/* ARB_parallel_shader_compile */<br>
+extern GLvoid GLAPIENTRY<br>
+_mesa_<wbr>MaxShaderCompilerThreadsARB(<wbr>GLuint count);<br>
<br>
/* GL_ARB_separate_shader_objects */<br>
extern GLuint GLAPIENTRY<br>
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c<br>
index 5344812..586502e 100644<br>
--- a/src/mesa/main/shared.c<br>
+++ b/src/mesa/main/shared.c<br>
@@ -126,6 +126,9 @@ _mesa_alloc_shared_state(<wbr>struct gl_context *ctx)<br>
shared->SyncObjects = _mesa_set_create(NULL, _mesa_hash_pointer,<br>
_mesa_key_pointer_equal);<br>
<br>
+ /* GL_ARB_parallel_shader_compile */<br>
+ shared->MaxCompileThreads = 0xFFFFFFFF;<br>
+<br>
return shared;<br>
}<br>
<br>
diff --git a/src/mesa/state_tracker/st_<wbr>extensions.c b/src/mesa/state_tracker/st_<wbr>extensions.c<br>
index 1df2ba7..61391f8 100644<br>
--- a/src/mesa/state_tracker/st_<wbr>extensions.c<br>
+++ b/src/mesa/state_tracker/st_<wbr>extensions.c<br>
@@ -35,6 +35,7 @@<br>
#include "pipe/p_defines.h"<br>
#include "pipe/p_screen.h"<br>
#include "util/u_math.h"<br>
+#include "util/u_cpu_detect.h"<br>
<br>
#include "st_context.h"<br>
#include "st_debug.h"<br>
@@ -897,6 +898,9 @@ void st_init_extensions(struct pipe_screen *screen,<br>
if (consts->GLSLVersion >= 410)<br>
extensions->ARB_shader_<wbr>precision = GL_TRUE;<br>
<br>
+ /* GL_ARB_parallel_shader_compile */<br>
+ consts-><wbr>MaxShaderCompilerThreads = util_cpu_caps.nr_cpus > 1 ? util_cpu_caps.nr_cpus : 0;<br>
+<br>
/* This extension needs full OpenGL 3.2, but we don't know if that's<br>
* supported at this point. Only check the GLSL version. */<br>
if (consts->GLSLVersion >= 150 &&<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>