summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-08-06 07:05:19 -0400
committerMarek Olšák <[email protected]>2019-04-01 12:37:52 -0400
commitc5c38e831ee8113cf97fb5308fbb687464ae2f0e (patch)
treec2002b59dd135f4cef33177d06bbe9fa0dda1c21
parent3ad2a9b3faa19e29fe1c2a28c712f265ee29423b (diff)
mesa: implement ARB/KHR_parallel_shader_compile
Tested by piglit.
-rw-r--r--docs/features.txt2
-rw-r--r--docs/relnotes/19.0.0.html2
-rw-r--r--src/mapi/glapi/gen/gl_API.xml15
-rw-r--r--src/mesa/main/dd.h7
-rw-r--r--src/mesa/main/extensions_table.h2
-rw-r--r--src/mesa/main/get_hash_params.py3
-rw-r--r--src/mesa/main/hint.c12
-rw-r--r--src/mesa/main/hint.h4
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/shaderapi.c10
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp5
11 files changed, 61 insertions, 2 deletions
diff --git a/docs/features.txt b/docs/features.txt
index 038bbfc45a6..201e600adff 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -302,7 +302,7 @@ Khronos, ARB, and OES extensions that are not part of any OpenGL or OpenGL ES ve
GL_ARB_ES3_2_compatibility DONE (i965/gen8+, radeonsi, virgl)
GL_ARB_fragment_shader_interlock DONE (i965)
GL_ARB_gpu_shader_int64 DONE (i965/gen8+, nvc0, radeonsi, softpipe, llvmpipe)
- GL_ARB_parallel_shader_compile not started, but Chia-I Wu did some related work in 2014
+ GL_ARB_parallel_shader_compile DONE (all drivers)
GL_ARB_post_depth_coverage DONE (i965, nvc0)
GL_ARB_robustness_isolation not started
GL_ARB_sample_locations DONE (nvc0)
diff --git a/docs/relnotes/19.0.0.html b/docs/relnotes/19.0.0.html
index ea22d660f37..b0a3cc6c29f 100644
--- a/docs/relnotes/19.0.0.html
+++ b/docs/relnotes/19.0.0.html
@@ -41,11 +41,13 @@ Compatibility contexts may report a lower version depending on each driver.
<ul>
<li>GL_AMD_texture_texture4 on all GL 4.0 drivers.</li>
+<li>GL_ARB_parallel_shader_compile on all drivers.</li>
<li>GL_EXT_shader_implicit_conversions on all drivers (ES extension).</li>
<li>GL_EXT_texture_compression_bptc on all GL 4.0 drivers (ES extension).</li>
<li>GL_EXT_texture_compression_rgtc on all GL 3.0 drivers (ES extension).</li>
<li>GL_EXT_render_snorm on gallium drivers (ES extension).</li>
<li>GL_EXT_texture_view on drivers supporting texture views (ES extension).</li>
+<li>GL_KHR_parallel_shader_compile on all drivers.</li>
<li>GL_OES_texture_view on drivers supporting texture views (ES extension).</li>
<li>GL_NV_shader_atomic_float on nvc0 (Fermi/Kepler only).</li>
<li>Shader-based software implementations of GL_ARB_gpu_shader_fp64, GL_ARB_gpu_shader_int64, GL_ARB_vertex_attrib_64bit, and GL_ARB_shader_ballot on i965.</li>
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 929e5f6b024..9b8998532d5 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8400,7 +8400,20 @@
<xi:include href="ARB_gpu_shader_int64.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
-<!-- ARB extension 179 - 189 -->
+<category name="ARB_parallel_shader_compile" number="179">
+ <enum name="MAX_SHADER_COMPILER_THREADS_ARB" value="0x91B0"/>
+ <enum name="COMPLETION_STATUS_ARB" value="0x91B1"/>
+
+ <function name="MaxShaderCompilerThreadsKHR" es2="2.0">
+ <param name="count" type="GLuint"/>
+ </function>
+
+ <function name="MaxShaderCompilerThreadsARB" alias="MaxShaderCompilerThreadsKHR">
+ <param name="count" type="GLuint"/>
+ </function>
+</category>
+
+<!-- ARB extension 180 - 189 -->
<xi:include href="ARB_gl_spirv.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 1214eeaa474..8251af3f667 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1298,6 +1298,13 @@ struct dd_function_table {
void (*ShaderCacheSerializeDriverBlob)(struct gl_context *ctx,
struct gl_program *prog);
/*@}*/
+
+ /**
+ * \name Set the number of compiler threads for ARB_parallel_shader_compile
+ */
+ void (*SetMaxShaderCompilerThreads)(struct gl_context *ctx, unsigned count);
+ bool (*GetShaderProgramCompletionStatus)(struct gl_context *ctx,
+ struct gl_shader_program *shprog);
};
diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h
index a9773f701b6..f7eb62108f2 100644
--- a/src/mesa/main/extensions_table.h
+++ b/src/mesa/main/extensions_table.h
@@ -99,6 +99,7 @@ EXT(ARB_multisample , dummy_true
EXT(ARB_multitexture , dummy_true , GLL, x , x , x , 1998)
EXT(ARB_occlusion_query , ARB_occlusion_query , GLL, x , x , x , 2001)
EXT(ARB_occlusion_query2 , ARB_occlusion_query2 , GLL, GLC, x , x , 2003)
+EXT(ARB_parallel_shader_compile , dummy_true , GLL, GLC, x , x , 2015)
EXT(ARB_pipeline_statistics_query , ARB_pipeline_statistics_query , GLL, GLC, x , x , 2014)
EXT(ARB_pixel_buffer_object , EXT_pixel_buffer_object , GLL, GLC, x , x , 2004)
EXT(ARB_point_parameters , EXT_point_parameters , GLL, x , x , x , 1997)
@@ -337,6 +338,7 @@ EXT(KHR_blend_equation_advanced_coherent , KHR_blend_equation_advanced_cohere
EXT(KHR_context_flush_control , dummy_true , GLL, GLC, x , ES2, 2014)
EXT(KHR_debug , dummy_true , GLL, GLC, 11, ES2, 2012)
EXT(KHR_no_error , dummy_true , GLL, GLC, ES1, ES2, 2015)
+EXT(KHR_parallel_shader_compile , dummy_true , GLL, GLC, x , ES2, 2017)
EXT(KHR_robust_buffer_access_behavior , ARB_robust_buffer_access_behavior , GLL, GLC, x , ES2, 2014)
EXT(KHR_robustness , KHR_robustness , GLL, GLC, x , ES2, 2012)
EXT(KHR_texture_compression_astc_hdr , KHR_texture_compression_astc_hdr , GLL, GLC, x , ES2, 2012)
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 8b351bcd2d2..60ec1a8598c 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -280,6 +280,9 @@ descriptor=[
# GL_ARB_draw_buffers
[ "MAX_DRAW_BUFFERS_ARB", "CONTEXT_INT(Const.MaxDrawBuffers), NO_EXTRA" ],
+# GL_ARB_parallel_shader_compile
+ [ "MAX_SHADER_COMPILER_THREADS_ARB", "CONTEXT_INT(Hint.MaxShaderCompilerThreads), NO_EXTRA" ],
+
# GL_EXT_framebuffer_object / GL_NV_fbo_color_attachments
[ "MAX_COLOR_ATTACHMENTS", "CONTEXT_INT(Const.MaxColorAttachments), NO_EXTRA" ],
diff --git a/src/mesa/main/hint.c b/src/mesa/main/hint.c
index 5d0c15d35ab..2bcaeebc4aa 100644
--- a/src/mesa/main/hint.c
+++ b/src/mesa/main/hint.c
@@ -130,6 +130,17 @@ invalid_target:
return;
}
+/* GL_ARB_parallel_shader_compile */
+void GLAPIENTRY
+_mesa_MaxShaderCompilerThreadsKHR(GLuint count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ ctx->Hint.MaxShaderCompilerThreads = count;
+
+ if (ctx->Driver.SetMaxShaderCompilerThreads)
+ ctx->Driver.SetMaxShaderCompilerThreads(ctx, count);
+}
/**********************************************************************/
/***** Initialization *****/
@@ -146,4 +157,5 @@ void _mesa_init_hint( struct gl_context * ctx )
ctx->Hint.TextureCompression = GL_DONT_CARE;
ctx->Hint.GenerateMipmap = GL_DONT_CARE;
ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE;
+ ctx->Hint.MaxShaderCompilerThreads = 0xffffffff;
}
diff --git a/src/mesa/main/hint.h b/src/mesa/main/hint.h
index 87febfeecc0..2d7c710af26 100644
--- a/src/mesa/main/hint.h
+++ b/src/mesa/main/hint.h
@@ -43,6 +43,10 @@ struct gl_context;
extern void GLAPIENTRY
_mesa_Hint( GLenum target, GLenum mode );
+/* GL_KHR_parallel_shader_compile */
+extern void GLAPIENTRY
+_mesa_MaxShaderCompilerThreadsKHR(GLuint count);
+
extern void
_mesa_init_hint( struct gl_context * ctx );
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 96f30d4a4d5..c1dc52b2ec4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -603,6 +603,7 @@ struct gl_hint_attrib
GLenum16 TextureCompression; /**< GL_ARB_texture_compression */
GLenum16 GenerateMipmap; /**< GL_SGIS_generate_mipmap */
GLenum16 FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
+ GLuint MaxShaderCompilerThreads; /**< GL_ARB_parallel_shader_compile */
};
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2ea8d965aba..01342c04e8f 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -689,6 +689,12 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
case GL_DELETE_STATUS:
*params = shProg->DeletePending;
return;
+ case GL_COMPLETION_STATUS_ARB:
+ if (ctx->Driver.GetShaderProgramCompletionStatus)
+ *params = ctx->Driver.GetShaderProgramCompletionStatus(ctx, shProg);
+ else
+ *params = GL_TRUE;
+ return;
case GL_LINK_STATUS:
*params = shProg->data->LinkStatus ? GL_TRUE : GL_FALSE;
return;
@@ -960,6 +966,10 @@ 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:
+ /* _mesa_glsl_compile_shader is not offloaded to other threads. */
+ *params = GL_TRUE;
+ return;
case GL_COMPILE_STATUS:
*params = shader->CompileStatus ? GL_TRUE : GL_FALSE;
break;
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 672e4ce892a..37edfee587d 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -1198,6 +1198,8 @@ const struct function common_desktop_functions_possible[] = {
{ "glRenderbufferStorageMultisampleAdvancedAMD", 11, -1 },
{ "glNamedRenderbufferStorageMultisampleAdvancedAMD", 11, -1 },
+ { "glMaxShaderCompilerThreadsKHR", 11, -1 },
+
{ NULL, 0, -1 }
};
@@ -2244,6 +2246,9 @@ const struct function gles2_functions_possible[] = {
{ "glRenderbufferStorageMultisampleEXT", 20, -1 },
{ "glFramebufferTexture2DMultisampleEXT", 20, -1 },
+ /* GL_KHR_parallel_shader_compile */
+ { "glMaxShaderCompilerThreadsKHR", 20, -1 },
+
{ NULL, 0, -1 }
};