diff options
author | Timothy Arceri <[email protected]> | 2017-03-09 22:58:37 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-03-12 17:24:40 +1100 |
commit | bfa95997c4ecf74a329a047359d5e8d1217da49b (patch) | |
tree | 49f64331b9c2af6e09d443aae92d1e667320bfa4 /src/mesa | |
parent | 3d253d330a47eb06bd4745c3ee41c4aa9d6143be (diff) |
mesa/glsl: introduce new gl_compile_status enum
This will allow us to tell if a shader really has been compiled or
if the shader cache has just seen it before.
Acked-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 2 | ||||
-rw-r--r-- | src/mesa/main/ff_fragment_shader.cpp | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 14 | ||||
-rw-r--r-- | src/mesa/main/shaderapi.c | 6 |
4 files changed, 18 insertions, 6 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 2db4668ef7d..d8deaaf3713 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -131,7 +131,7 @@ meta_compile_shader_with_debug(struct gl_context *ctx, gl_shader_stage stage, sh = _mesa_new_shader(name, stage); sh->Source = strdup(source); - sh->CompileStatus = false; + sh->CompileStatus = compile_failure; _mesa_compile_shader(ctx, sh); if (!sh->CompileStatus) { diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index b2942f1aada..be382fa3ae9 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -1273,7 +1273,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key) reparent_ir(p.shader->ir, p.shader->ir); - p.shader->CompileStatus = true; + p.shader->CompileStatus = compile_success; p.shader->Version = state->language_version; p.shader_program->Shaders = (gl_shader **)malloc(sizeof(*p.shader_program->Shaders)); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d07391debbb..e53d5762f98 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2400,6 +2400,18 @@ static inline GLbitfield gl_external_samplers(struct gl_program *prog) } /** + * Compile status enum. compile_skipped is used to indicate the compile + * was skipped due to the shader matching one that's been seen before by + * the on-disk cache. + */ +enum gl_compile_status +{ + compile_failure = 0, + compile_success, + compile_skipped +}; + +/** * A GLSL shader object. */ struct gl_shader @@ -2415,7 +2427,7 @@ struct gl_shader GLchar *Label; /**< GL_KHR_debug */ unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */ GLboolean DeletePending; - GLboolean CompileStatus; + enum gl_compile_status CompileStatus; bool IsES; /**< True if this shader uses GLSL ES */ #ifdef DEBUG diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 0c38cea2555..ba69ede0e84 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -903,7 +903,7 @@ get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params) *params = shader->DeletePending; break; case GL_COMPILE_STATUS: - *params = shader->CompileStatus; + *params = shader->CompileStatus ? GL_TRUE : GL_FALSE; break; case GL_INFO_LOG_LENGTH: *params = (shader->InfoLog && shader->InfoLog[0] != '\0') ? @@ -1003,7 +1003,7 @@ shader_source(struct gl_shader *sh, const GLchar *source) { assert(sh); - if (sh->CompileStatus == GL_TRUE && !sh->FallbackSource) { + if (sh->CompileStatus == compile_skipped && !sh->FallbackSource) { /* If shader was previously compiled back-up the source in case of cache * fallback. */ @@ -1034,7 +1034,7 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh) /* If the user called glCompileShader without first calling * glShaderSource, we should fail to compile, but not raise a GL_ERROR. */ - sh->CompileStatus = GL_FALSE; + sh->CompileStatus = compile_failure; } else { if (ctx->_Shader->Flags & GLSL_DUMP) { _mesa_log("GLSL source for %s shader %d:\n", |