diff options
author | Timothy Arceri <[email protected]> | 2017-05-03 16:40:39 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-05-17 10:12:03 +1000 |
commit | 70aa66f1819bb7edae12e053577284c2ba050ce8 (patch) | |
tree | 5fb3431ad4644c15333f8980f8b212a872c6155a | |
parent | 35a9b9a70c90436105d702e0da0b8e99a27c4b8b (diff) |
mesa: add KHR_no_error support for glUseProgram
V3: use always_inline attribute (Suggested by Nicolai)
Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r-- | src/mapi/glapi/gen/gl_API.xml | 2 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.c | 65 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.h | 2 |
3 files changed, 48 insertions, 21 deletions
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index a304ac0e4d9..50d60f53da6 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -5500,7 +5500,7 @@ <glx ignore="true"/> </function> - <function name="UseProgram" es2="2.0"> + <function name="UseProgram" es2="2.0" no_error="true"> <param name="program" type="GLuint"/> <glx ignore="true"/> </function> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index f63215a07be..68fb3faf0c6 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1803,8 +1803,8 @@ _mesa_ShaderSource(GLuint shaderObj, GLsizei count, } -void GLAPIENTRY -_mesa_UseProgram(GLuint program) +static ALWAYS_INLINE void +use_program(GLuint program, bool no_error) { GET_CURRENT_CONTEXT(ctx); struct gl_shader_program *shProg = NULL; @@ -1812,26 +1812,33 @@ _mesa_UseProgram(GLuint program) if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glUseProgram %u\n", program); - if (_mesa_is_xfb_active_and_unpaused(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(transform feedback active)"); - return; - } - - if (program) { - shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); - if (!shProg) { - return; + if (no_error) { + if (program) { + shProg = _mesa_lookup_shader_program(ctx, program); } - if (!shProg->data->LinkStatus) { + } else { + if (_mesa_is_xfb_active_and_unpaused(ctx)) { _mesa_error(ctx, GL_INVALID_OPERATION, - "glUseProgram(program %u not linked)", program); + "glUseProgram(transform feedback active)"); return; } - /* debug code */ - if (ctx->_Shader->Flags & GLSL_USE_PROG) { - print_shader_info(shProg); + if (program) { + shProg = + _mesa_lookup_shader_program_err(ctx, program, "glUseProgram"); + if (!shProg) + return; + + if (!shProg->data->LinkStatus) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glUseProgram(program %u not linked)", program); + return; + } + + /* debug code */ + if (ctx->_Shader->Flags & GLSL_USE_PROG) { + print_shader_info(shProg); + } } } @@ -1844,7 +1851,7 @@ _mesa_UseProgram(GLuint program) * object (section 2.14.PPO), the program bound to the appropriate * stage of the pipeline object is considered current." */ - if (program) { + if (shProg) { /* Attach shader state to the binding point */ _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader); /* Update the program */ @@ -1853,16 +1860,34 @@ _mesa_UseProgram(GLuint program) /* Must be done first: detach the progam */ _mesa_use_shader_program(ctx, shProg); /* Unattach shader_state binding point */ - _mesa_reference_pipeline_object(ctx, &ctx->_Shader, ctx->Pipeline.Default); + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, + ctx->Pipeline.Default); /* If a pipeline was bound, rebind it */ if (ctx->Pipeline.Current) { - _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name); + if (no_error) + _mesa_BindProgramPipeline_no_error(ctx->Pipeline.Current->Name); + else + _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name); } } } void GLAPIENTRY +_mesa_UseProgram_no_error(GLuint program) +{ + use_program(program, true); +} + + +void GLAPIENTRY +_mesa_UseProgram(GLuint program) +{ + use_program(program, false); +} + + +void GLAPIENTRY _mesa_ValidateProgram(GLuint program) { GET_CURRENT_CONTEXT(ctx); diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h index 99b4fe84d82..0a28185177d 100644 --- a/src/mesa/main/shaderapi.h +++ b/src/mesa/main/shaderapi.h @@ -127,6 +127,8 @@ _mesa_LinkProgram(GLuint programObj); extern void GLAPIENTRY _mesa_ShaderSource(GLuint, GLsizei, const GLchar* const *, const GLint *); +void GLAPIENTRY +_mesa_UseProgram_no_error(GLuint); extern void GLAPIENTRY _mesa_UseProgram(GLuint); |