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 <marek.olsak@amd.com>
This commit is contained in:
Timothy Arceri
2017-03-09 22:58:37 +11:00
parent 3d253d330a
commit bfa95997c4
5 changed files with 20 additions and 8 deletions

View File

@@ -1946,7 +1946,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
fprintf(stderr, "deferring compile of shader: %s\n", fprintf(stderr, "deferring compile of shader: %s\n",
_mesa_sha1_format(buf, shader->sha1)); _mesa_sha1_format(buf, shader->sha1));
} }
shader->CompileStatus = true; shader->CompileStatus = compile_skipped;
free((void *)shader->FallbackSource); free((void *)shader->FallbackSource);
shader->FallbackSource = NULL; shader->FallbackSource = NULL;
@@ -2034,7 +2034,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
set_shader_inout_layout(shader, state); set_shader_inout_layout(shader, state);
shader->symbols = new(shader->ir) glsl_symbol_table; shader->symbols = new(shader->ir) glsl_symbol_table;
shader->CompileStatus = !state->error; shader->CompileStatus = state->error ? compile_failure : compile_success;
shader->InfoLog = state->info_log; shader->InfoLog = state->info_log;
shader->Version = state->language_version; shader->Version = state->language_version;
shader->IsES = state->es_shader; shader->IsES = state->es_shader;

View File

@@ -131,7 +131,7 @@ meta_compile_shader_with_debug(struct gl_context *ctx, gl_shader_stage stage,
sh = _mesa_new_shader(name, stage); sh = _mesa_new_shader(name, stage);
sh->Source = strdup(source); sh->Source = strdup(source);
sh->CompileStatus = false; sh->CompileStatus = compile_failure;
_mesa_compile_shader(ctx, sh); _mesa_compile_shader(ctx, sh);
if (!sh->CompileStatus) { if (!sh->CompileStatus) {

View File

@@ -1273,7 +1273,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
reparent_ir(p.shader->ir, p.shader->ir); 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->Version = state->language_version;
p.shader_program->Shaders = p.shader_program->Shaders =
(gl_shader **)malloc(sizeof(*p.shader_program->Shaders)); (gl_shader **)malloc(sizeof(*p.shader_program->Shaders));

View File

@@ -2399,6 +2399,18 @@ static inline GLbitfield gl_external_samplers(struct gl_program *prog)
return external_samplers; return external_samplers;
} }
/**
* 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. * A GLSL shader object.
*/ */
@@ -2415,7 +2427,7 @@ struct gl_shader
GLchar *Label; /**< GL_KHR_debug */ GLchar *Label; /**< GL_KHR_debug */
unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */ unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
GLboolean DeletePending; GLboolean DeletePending;
GLboolean CompileStatus; enum gl_compile_status CompileStatus;
bool IsES; /**< True if this shader uses GLSL ES */ bool IsES; /**< True if this shader uses GLSL ES */
#ifdef DEBUG #ifdef DEBUG

View File

@@ -903,7 +903,7 @@ get_shaderiv(struct gl_context *ctx, GLuint name, GLenum pname, GLint *params)
*params = shader->DeletePending; *params = shader->DeletePending;
break; break;
case GL_COMPILE_STATUS: case GL_COMPILE_STATUS:
*params = shader->CompileStatus; *params = shader->CompileStatus ? GL_TRUE : GL_FALSE;
break; break;
case GL_INFO_LOG_LENGTH: case GL_INFO_LOG_LENGTH:
*params = (shader->InfoLog && shader->InfoLog[0] != '\0') ? *params = (shader->InfoLog && shader->InfoLog[0] != '\0') ?
@@ -1003,7 +1003,7 @@ shader_source(struct gl_shader *sh, const GLchar *source)
{ {
assert(sh); 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 /* If shader was previously compiled back-up the source in case of cache
* fallback. * fallback.
*/ */
@@ -1034,7 +1034,7 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
/* If the user called glCompileShader without first calling /* If the user called glCompileShader without first calling
* glShaderSource, we should fail to compile, but not raise a GL_ERROR. * glShaderSource, we should fail to compile, but not raise a GL_ERROR.
*/ */
sh->CompileStatus = GL_FALSE; sh->CompileStatus = compile_failure;
} else { } else {
if (ctx->_Shader->Flags & GLSL_DUMP) { if (ctx->_Shader->Flags & GLSL_DUMP) {
_mesa_log("GLSL source for %s shader %d:\n", _mesa_log("GLSL source for %s shader %d:\n",