X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fshaderapi.c;h=9f0122ad704ba5ae8678128b3909f81195fd5849;hb=cb1d5f46395598c56818a04aadc5353ff1971a02;hp=681b7306d13135b07df81aed4324148dddce2489;hpb=bdaff25c2041a2399ee4d4b08764baa890531e22;p=mesa.git diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 681b7306d13..9f0122ad704 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -77,6 +77,8 @@ _mesa_get_shader_flags(void) flags |= GLSL_DUMP; if (strstr(env, "log")) flags |= GLSL_LOG; + if (strstr(env, "cache_fb")) + flags |= GLSL_CACHE_FALLBACK; if (strstr(env, "cache_info")) flags |= GLSL_CACHE_INFO; if (strstr(env, "nopvert")) @@ -155,7 +157,6 @@ _mesa_free_shader_state(struct gl_context *ctx) for (int i = 0; i < MESA_SHADER_STAGES; i++) { _mesa_reference_program(ctx, &ctx->Shader.CurrentProgram[i], NULL); } - _mesa_reference_program(ctx, &ctx->Shader._CurrentFragmentProgram, NULL); _mesa_reference_shader_program(ctx, &ctx->Shader.ActiveProgram, NULL); /* Extended for ARB_separate_shader_objects */ @@ -1243,54 +1244,6 @@ _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, } -static void -use_program(struct gl_context *ctx, gl_shader_stage stage, - struct gl_shader_program *shProg, struct gl_program *new_prog, - struct gl_pipeline_object *shTarget) -{ - struct gl_program **target; - - target = &shTarget->CurrentProgram[stage]; - if (new_prog) { - _mesa_program_init_subroutine_defaults(ctx, new_prog); - } - - if (*target != new_prog) { - /* Program is current, flush it */ - if (shTarget == ctx->_Shader) { - FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); - } - - /* If the shader is also bound as the current rendering shader, unbind - * it from that binding point as well. This ensures that the correct - * semantics of glDeleteProgram are maintained. - */ - switch (stage) { - case MESA_SHADER_VERTEX: - case MESA_SHADER_TESS_CTRL: - case MESA_SHADER_TESS_EVAL: - case MESA_SHADER_GEOMETRY: - case MESA_SHADER_COMPUTE: - /* Empty for now. */ - break; - case MESA_SHADER_FRAGMENT: - if (*target == ctx->_Shader->_CurrentFragmentProgram) { - _mesa_reference_program(ctx, - &ctx->_Shader->_CurrentFragmentProgram, - NULL); - } - break; - } - - _mesa_reference_shader_program(ctx, - &shTarget->ReferencedPrograms[stage], - shProg); - _mesa_reference_program(ctx, target, new_prog); - return; - } -} - - /** * Use the named shader program for subsequent rendering. */ @@ -1302,7 +1255,7 @@ _mesa_use_shader_program(struct gl_context *ctx, struct gl_program *new_prog = NULL; if (shProg && shProg->_LinkedShaders[i]) new_prog = shProg->_LinkedShaders[i]->Program; - use_program(ctx, i, shProg, new_prog, &ctx->Shader); + _mesa_use_program(ctx, i, shProg, new_prog, &ctx->Shader); } _mesa_active_program(ctx, shProg, "glUseProgram"); } @@ -1852,8 +1805,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; @@ -1861,26 +1814,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); + } } } @@ -1893,7 +1853,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 */ @@ -1902,15 +1862,33 @@ _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) { @@ -2186,7 +2164,26 @@ _mesa_use_program(struct gl_context *ctx, gl_shader_stage stage, struct gl_shader_program *shProg, struct gl_program *prog, struct gl_pipeline_object *shTarget) { - use_program(ctx, stage, shProg, prog, shTarget); + struct gl_program **target; + + target = &shTarget->CurrentProgram[stage]; + if (prog) { + _mesa_program_init_subroutine_defaults(ctx, prog); + } + + if (*target != prog) { + /* Program is current, flush it */ + if (shTarget == ctx->_Shader) { + FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS); + } + + _mesa_reference_shader_program(ctx, + &shTarget->ReferencedPrograms[stage], + shProg); + _mesa_reference_program(ctx, target, prog); + return; + } + } @@ -2357,11 +2354,6 @@ _mesa_GetSubroutineUniformLocation(GLuint program, GLenum shadertype, GLenum resource_type; gl_shader_stage stage; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return -1; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return -1; @@ -2392,11 +2384,6 @@ _mesa_GetSubroutineIndex(GLuint program, GLenum shadertype, GLenum resource_type; gl_shader_stage stage; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return -1; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return -1; @@ -2436,11 +2423,6 @@ _mesa_GetActiveSubroutineUniformiv(GLuint program, GLenum shadertype, GLenum resource_type; int count, i, j; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return; @@ -2523,11 +2505,6 @@ _mesa_GetActiveSubroutineUniformName(GLuint program, GLenum shadertype, GLenum resource_type; gl_shader_stage stage; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return; @@ -2562,11 +2539,6 @@ _mesa_GetActiveSubroutineName(GLuint program, GLenum shadertype, GLenum resource_type; gl_shader_stage stage; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return; @@ -2596,11 +2568,6 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count, gl_shader_stage stage; int i; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return; @@ -2671,11 +2638,6 @@ _mesa_GetUniformSubroutineuiv(GLenum shadertype, GLint location, const char *api_name = "glGetUniformSubroutineuiv"; gl_shader_stage stage; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return; @@ -2707,11 +2669,6 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype, struct gl_linked_shader *sh; gl_shader_stage stage; - if (!_mesa_has_ARB_shader_subroutine(ctx)) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); - return; - } - if (!_mesa_validate_shader_target(ctx, shadertype)) { _mesa_error(ctx, GL_INVALID_OPERATION, "%s", api_name); return;