Commit c5c38e83 authored by Marek Olšák's avatar Marek Olšák

mesa: implement ARB/KHR_parallel_shader_compile

Tested by piglit.
parent 3ad2a9b3
......@@ -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)
......
......@@ -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>
......
......@@ -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"/>
......
......@@ -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);
};
......
......@@ -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)
......
......@@ -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" ],
......
......@@ -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;
}
......@@ -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 );
......
......@@ -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 */
};
......
......@@ -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;
......
......@@ -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 }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment