[Mesa-dev] [PATCH 2/3] mesa: implement ARB_parallel_shader_compile
Jason Ekstrand
jason at jlekstrand.net
Mon Apr 17 15:13:10 UTC 2017
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.
On Mon, Apr 17, 2017 at 5:07 AM, Edward O'Callaghan <
funfunctor at folklore1984.net> wrote:
> Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
> ---
> src/mesa/main/get.c | 4 ++++
> src/mesa/main/mtypes.h | 6 ++++++
> src/mesa/main/shaderapi.c | 20 ++++++++++++++++++++
> src/mesa/main/shaderapi.h | 3 +++
> src/mesa/main/shared.c | 3 +++
> src/mesa/state_tracker/st_extensions.c | 4 ++++
> 6 files changed, 40 insertions(+)
>
> diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
> index cf3ee63..91f21ce 100644
> --- a/src/mesa/main/get.c
> +++ b/src/mesa/main/get.c
> @@ -2332,6 +2332,10 @@ find_value_indexed(const char *func, GLenum pname,
> GLuint index, union value *v)
> return TYPE_INT;
> }
>
> + case GL_MAX_SHADER_COMPILER_THREADS_ARB:
> + v->value_int = ctx->Shared->MaxCompileThreads;
> + return TYPE_INT;
> +
> case GL_MAX_COMPUTE_WORK_GROUP_COUNT:
> if (!_mesa_has_compute_shaders(ctx))
> goto invalid_enum;
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 4a76de5..33cf33d 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3227,6 +3227,9 @@ struct gl_shared_state
> * Once this field becomes true, it is never reset to false.
> */
> bool ShareGroupReset;
> +
> + /* GL_ARB_parallel_shader_compile */
> + int MaxCompileThreads;
>
This seems to only be initialized by st/mesa. Shoule we initialize it to 1
by default for everyone else?
> };
>
>
> @@ -3880,6 +3883,9 @@ struct gl_constants
> GLuint MaxImageSamples;
> GLuint MaxCombinedImageUniforms;
>
> + /** GL_ARB_parallel_shader_compile */
> + GLuint MaxShaderCompilerThreads;
> +
> /** GL_ARB_compute_shader */
> GLuint MaxComputeWorkGroupCount[3]; /* Array of x, y, z dimensions */
> GLuint MaxComputeWorkGroupSize[3]; /* Array of x, y, z dimensions */
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 187475f..051390a 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -631,6 +631,7 @@ get_programiv(struct gl_context *ctx, GLuint program,
> GLenum pname,
> case GL_DELETE_STATUS:
> *params = shProg->DeletePending;
> return;
> + case GL_COMPLETION_STATUS_ARB:
> case GL_LINK_STATUS:
> *params = shProg->data->LinkStatus ? GL_TRUE : GL_FALSE;
> return;
> @@ -898,6 +899,7 @@ get_shaderiv(struct gl_context *ctx, GLuint name,
> GLenum pname, GLint *params)
> case GL_DELETE_STATUS:
> *params = shader->DeletePending;
> break;
> + case GL_COMPLETION_STATUS_ARB:
> case GL_COMPILE_STATUS:
> *params = shader->CompileStatus ? GL_TRUE : GL_FALSE;
> break;
> @@ -2234,6 +2236,24 @@ _mesa_copy_linked_program_data(const struct
> gl_shader_program *src,
> }
>
> /**
> + * ARB_parallel_shader_compile
> + */
> +GLvoid GLAPIENTRY
> +_mesa_MaxShaderCompilerThreadsARB(GLuint count)
> +{
> + GET_CURRENT_CONTEXT(ctx);
> +
> + /**
> + * Additions to Chapter 7 "Programs and Shaders":
> + * a <count> of 0xFFFFFFFF requests an implementation-specific maximum.
> + */
> + if (count == 0xFFFFFFFF || count > ctx->Const.
> MaxShaderCompilerThreads)
> + count = ctx->Const.MaxShaderCompilerThreads;
>
Give that it's a 32-bit unsigned integer, 0xFFFFFFFF >
ctx->Const.MaxShaderCompilerThreads so we don't need the extra case.
> +
> + ctx->Shared->MaxCompileThreads = count;
> +}
> +
> +/**
> * ARB_separate_shader_objects: Compile & Link Program
> */
> GLuint GLAPIENTRY
> diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h
> index 99b4fe8..1ec287a 100644
> --- a/src/mesa/main/shaderapi.h
> +++ b/src/mesa/main/shaderapi.h
> @@ -225,6 +225,9 @@ _mesa_copy_linked_program_data(const struct
> gl_shader_program *src,
> extern bool
> _mesa_validate_shader_target(const struct gl_context *ctx, GLenum type);
>
> +/* ARB_parallel_shader_compile */
> +extern GLvoid GLAPIENTRY
> +_mesa_MaxShaderCompilerThreadsARB(GLuint count);
>
> /* GL_ARB_separate_shader_objects */
> extern GLuint GLAPIENTRY
> diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
> index 5344812..586502e 100644
> --- a/src/mesa/main/shared.c
> +++ b/src/mesa/main/shared.c
> @@ -126,6 +126,9 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
> shared->SyncObjects = _mesa_set_create(NULL, _mesa_hash_pointer,
> _mesa_key_pointer_equal);
>
> + /* GL_ARB_parallel_shader_compile */
> + shared->MaxCompileThreads = 0xFFFFFFFF;
> +
> return shared;
> }
>
> diff --git a/src/mesa/state_tracker/st_extensions.c
> b/src/mesa/state_tracker/st_extensions.c
> index 1df2ba7..61391f8 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -35,6 +35,7 @@
> #include "pipe/p_defines.h"
> #include "pipe/p_screen.h"
> #include "util/u_math.h"
> +#include "util/u_cpu_detect.h"
>
> #include "st_context.h"
> #include "st_debug.h"
> @@ -897,6 +898,9 @@ void st_init_extensions(struct pipe_screen *screen,
> if (consts->GLSLVersion >= 410)
> extensions->ARB_shader_precision = GL_TRUE;
>
> + /* GL_ARB_parallel_shader_compile */
> + consts->MaxShaderCompilerThreads = util_cpu_caps.nr_cpus > 1 ?
> util_cpu_caps.nr_cpus : 0;
> +
> /* This extension needs full OpenGL 3.2, but we don't know if that's
> * supported at this point. Only check the GLSL version. */
> if (consts->GLSLVersion >= 150 &&
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170417/750b342d/attachment-0001.html>
More information about the mesa-dev
mailing list