<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 17, 2017 at 4:49 PM, 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"><span class=""><br>
<br>
On 04/18/2017 01:13 AM, Jason Ekstrand wrote:<br>
> I don't see anything in here that actually implements parallel shader<br>
> compilation. Does radeon already spawn back-end threads to compile<br>
</span>As far as I am aware that is exactly right.<span class=""><br></span></blockquote><div><br></div><div>If that's the case, then I didn't see anywhere that you actually hooked the maximum number of threads value to the radeon back-end. The extension does two things:<br><br></div><div> 1) Allow for asynchronous reading of compile status<br></div><div> 2) Allow the user to specify the maximum number of threads for the driver to use for shader compiles.<br><br></div><div>Your implementation does neither of these things.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> shaders or are we just lying about it? Even if it does, the front-end<br>
> tends to take significant quantities of time so it'd be nice to<br>
> parallelize that.<br>
</span>Indeed the frontend part I believe is where the remaining work is to be<br>
done.<span class=""><br></span></blockquote><div><br></div><div>Right. 90% of the work is left to be done.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
><br>
> On Mon, Apr 17, 2017 at 5:07 AM, Edward O'Callaghan<br>
</span><span class="">> <<a href="mailto:funfunctor@folklore1984.net">funfunctor@folklore1984.net</a> <mailto:<a href="mailto:funfunctor@folklore1984.net">funfunctor@<wbr>folklore1984.net</a>>> wrote:<br>
><br>
> Signed-off-by: Edward O'Callaghan <<a href="mailto:funfunctor@folklore1984.net">funfunctor@folklore1984.net</a><br>
</span>> <mailto:<a href="mailto:funfunctor@folklore1984.net">funfunctor@<wbr>folklore1984.net</a>>><br>
<div><div class="h5">> ---<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<br>
> 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>
><br>
><br>
> This seems to only be initialized by st/mesa. Shoule we initialize it<br>
> to 1 by default for everyone else?<br>
><br>
><br>
> };<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<br>
> 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<br>
> 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<br>
> 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<br>
> 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<br>
> maximum.<br>
> + */<br>
> + if (count == 0xFFFFFFFF || count ><br>
> ctx->Const.<wbr>MaxShaderCompilerThreads)<br>
> + count = ctx->Const.<wbr>MaxShaderCompilerThreads;<br>
><br>
><br>
> Give that it's a 32-bit unsigned integer, 0xFFFFFFFF ><br>
> ctx->Const.<wbr>MaxShaderCompilerThreads so we don't need the extra case.<br>
><br>
><br>
> +<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<br>
> gl_shader_program *src,<br>
> extern bool<br>
> _mesa_validate_shader_target(<wbr>const struct gl_context *ctx, GLenum<br>
> 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<br>
> 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 ?<br>
> 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>
> --<br>
> 2.9.3<br>
><br>
> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
</div></div>> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.<wbr>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>
> <<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.<wbr>org/mailman/listinfo/mesa-dev</a>><br>
><br>
><br>
<br>
</blockquote></div><br></div></div>