st/mesa/i965: create link status enum
For the on-disk shader cache we want to be able to differentiate between a program that was linked and one that was loaded from cache. V2: - don't return the new enum directly to the application when queried, instead return GL_TRUE or GL_FALSE as required. Fixes google-chrome corruptions when using cache. Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
parent
ac5845453c
commit
a3fd8bb8c5
|
@ -421,7 +421,7 @@ linker_error(gl_shader_program *prog, const char *fmt, ...)
|
|||
ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
prog->data->LinkStatus = false;
|
||||
prog->data->LinkStatus = linking_failure;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2190,7 +2190,7 @@ link_intrastage_shaders(void *mem_ctx,
|
|||
_mesa_shader_stage_to_program(shader_list[0]->Stage),
|
||||
prog->Name, false);
|
||||
if (!gl_prog) {
|
||||
prog->data->LinkStatus = false;
|
||||
prog->data->LinkStatus = linking_failure;
|
||||
_mesa_delete_linked_shader(ctx, linked);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4629,7 +4629,7 @@ linker_optimisation_loop(struct gl_context *ctx, exec_list *ir,
|
|||
void
|
||||
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||
{
|
||||
prog->data->LinkStatus = true; /* All error paths will set this to false */
|
||||
prog->data->LinkStatus = linking_success; /* All error paths will set this to false */
|
||||
prog->data->Validated = false;
|
||||
|
||||
/* Section 7.3 (Program Objects) of the OpenGL 4.5 Core Profile spec says:
|
||||
|
|
|
@ -509,7 +509,7 @@ standalone_compile_shader(const struct standalone_options *_options,
|
|||
} else {
|
||||
const gl_shader_stage stage = whole_program->Shaders[0]->Stage;
|
||||
|
||||
whole_program->data->LinkStatus = GL_TRUE;
|
||||
whole_program->data->LinkStatus = linking_success;
|
||||
whole_program->_LinkedShaders[stage] =
|
||||
link_intrastage_shaders(whole_program /* mem_ctx */,
|
||||
ctx,
|
||||
|
|
|
@ -66,7 +66,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
|
|||
memset(&prog_data, 0, sizeof(prog_data));
|
||||
|
||||
if (cp->program.info.cs.shared_size > 64 * 1024) {
|
||||
cp->program.sh.data->LinkStatus = false;
|
||||
cp->program.sh.data->LinkStatus = linking_failure;
|
||||
const char *error_str =
|
||||
"Compute shader used more than 64KB of shared variables";
|
||||
ralloc_strcat(&cp->program.sh.data->InfoLog, error_str);
|
||||
|
@ -119,7 +119,7 @@ brw_codegen_cs_prog(struct brw_context *brw,
|
|||
&prog_data, cp->program.nir, st_index,
|
||||
&program_size, &error_str);
|
||||
if (program == NULL) {
|
||||
cp->program.sh.data->LinkStatus = false;
|
||||
cp->program.sh.data->LinkStatus = linking_failure;
|
||||
ralloc_strcat(&cp->program.sh.data->InfoLog, error_str);
|
||||
_mesa_problem(NULL, "Failed to compile compute shader: %s\n", error_str);
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ brw_codegen_tcs_prog(struct brw_context *brw, struct brw_program *tcp,
|
|||
&program_size, &error_str);
|
||||
if (program == NULL) {
|
||||
if (tep) {
|
||||
tep->program.sh.data->LinkStatus = false;
|
||||
tep->program.sh.data->LinkStatus = linking_failure;
|
||||
ralloc_strcat(&tep->program.sh.data->InfoLog, error_str);
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ brw_codegen_tes_prog(struct brw_context *brw,
|
|||
brw_compile_tes(compiler, brw, mem_ctx, key, &input_vue_map, &prog_data,
|
||||
nir, &tep->program, st_index, &program_size, &error_str);
|
||||
if (program == NULL) {
|
||||
tep->program.sh.data->LinkStatus = false;
|
||||
tep->program.sh.data->LinkStatus = linking_failure;
|
||||
ralloc_strcat(&tep->program.sh.data->InfoLog, error_str);
|
||||
|
||||
_mesa_problem(NULL, "Failed to compile tessellation evaluation shader: "
|
||||
|
|
|
@ -226,7 +226,7 @@ brw_codegen_vs_prog(struct brw_context *brw,
|
|||
st_index, &program_size, &error_str);
|
||||
if (program == NULL) {
|
||||
if (!vp->program.is_arb_asm) {
|
||||
vp->program.sh.data->LinkStatus = false;
|
||||
vp->program.sh.data->LinkStatus = linking_failure;
|
||||
ralloc_strcat(&vp->program.sh.data->InfoLog, error_str);
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ brw_codegen_wm_prog(struct brw_context *brw,
|
|||
|
||||
if (program == NULL) {
|
||||
if (!fp->program.is_arb_asm) {
|
||||
fp->program.sh.data->LinkStatus = false;
|
||||
fp->program.sh.data->LinkStatus = linking_failure;
|
||||
ralloc_strcat(&fp->program.sh.data->InfoLog, error_str);
|
||||
}
|
||||
|
||||
|
|
|
@ -2646,6 +2646,17 @@ struct gl_program_resource
|
|||
uint8_t StageReferences; /** Bitmask of shader stage references. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Link status enum. linking_skipped is used to indicate linking
|
||||
* was skipped due to the shader being loaded from the on-disk cache.
|
||||
*/
|
||||
enum gl_link_status
|
||||
{
|
||||
linking_failure = 0,
|
||||
linking_success,
|
||||
linking_skipped
|
||||
};
|
||||
|
||||
/**
|
||||
* A data structure to be shared by gl_shader_program and gl_program.
|
||||
*/
|
||||
|
@ -2677,7 +2688,7 @@ struct gl_shader_program_data
|
|||
struct gl_program_resource *ProgramResourceList;
|
||||
unsigned NumProgramResourceList;
|
||||
|
||||
GLboolean LinkStatus; /**< GL_LINK_STATUS */
|
||||
enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
|
||||
GLboolean Validated;
|
||||
GLchar *InfoLog;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ lookup_linked_program(GLuint program, const char *caller)
|
|||
if (!prog)
|
||||
return NULL;
|
||||
|
||||
if (prog->data->LinkStatus == GL_FALSE) {
|
||||
if (prog->data->LinkStatus == linking_failure) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(program not linked)",
|
||||
caller);
|
||||
return NULL;
|
||||
|
|
|
@ -636,7 +636,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
|
|||
*params = shProg->DeletePending;
|
||||
return;
|
||||
case GL_LINK_STATUS:
|
||||
*params = shProg->data->LinkStatus;
|
||||
*params = shProg->data->LinkStatus ? GL_TRUE : GL_FALSE;
|
||||
return;
|
||||
case GL_VALIDATE_STATUS:
|
||||
*params = shProg->data->Validated;
|
||||
|
@ -815,7 +815,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
|
|||
}
|
||||
case GL_PROGRAM_SEPARABLE:
|
||||
/* If the program has not been linked, return initial value 0. */
|
||||
*params = (shProg->data->LinkStatus == GL_FALSE) ? 0 : shProg->SeparateShader;
|
||||
*params = (shProg->data->LinkStatus == linking_failure) ? 0 : shProg->SeparateShader;
|
||||
return;
|
||||
|
||||
/* ARB_tessellation_shader */
|
||||
|
@ -1160,7 +1160,7 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
|
|||
ralloc_free(filename);
|
||||
}
|
||||
|
||||
if (shProg->data->LinkStatus == GL_FALSE &&
|
||||
if (shProg->data->LinkStatus == linking_failure &&
|
||||
(ctx->_Shader->Flags & GLSL_REPORT_ERRORS)) {
|
||||
_mesa_debug(ctx, "Error linking program %u:\n%s\n",
|
||||
shProg->Name, shProg->data->InfoLog);
|
||||
|
@ -2095,7 +2095,7 @@ _mesa_ProgramBinary(GLuint program, GLenum binaryFormat,
|
|||
* Since any value of binaryFormat passed "is not one of those specified as
|
||||
* allowable for [this] command, an INVALID_ENUM error is generated."
|
||||
*/
|
||||
shProg->data->LinkStatus = GL_FALSE;
|
||||
shProg->data->LinkStatus = linking_failure;
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glProgramBinary");
|
||||
}
|
||||
|
||||
|
@ -2270,7 +2270,7 @@ _mesa_CreateShaderProgramv(GLenum type, GLsizei count,
|
|||
/* Possibly... */
|
||||
if (active-user-defined-varyings-in-linked-program) {
|
||||
append-error-to-info-log;
|
||||
shProg->data->LinkStatus = GL_FALSE;
|
||||
shProg->data->LinkStatus = linking_failure;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -941,7 +941,7 @@ _mesa_GetUniformLocation(GLuint programObj, const GLcharARB *name)
|
|||
* "If program has not been successfully linked, the error
|
||||
* INVALID_OPERATION is generated."
|
||||
*/
|
||||
if (shProg->data->LinkStatus == GL_FALSE) {
|
||||
if (shProg->data->LinkStatus == linking_failure) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glGetUniformLocation(program not linked)");
|
||||
return -1;
|
||||
|
|
|
@ -3096,7 +3096,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
|
||||
_mesa_clear_shader_program_data(ctx, prog);
|
||||
|
||||
prog->data->LinkStatus = GL_TRUE;
|
||||
prog->data->LinkStatus = linking_success;
|
||||
|
||||
for (i = 0; i < prog->NumShaders; i++) {
|
||||
if (!prog->Shaders[i]->CompileStatus) {
|
||||
|
@ -3110,7 +3110,7 @@ _mesa_glsl_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
|
||||
if (prog->data->LinkStatus) {
|
||||
if (!ctx->Driver.LinkShader(ctx, prog)) {
|
||||
prog->data->LinkStatus = GL_FALSE;
|
||||
prog->data->LinkStatus = linking_failure;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -588,7 +588,7 @@ fail_link(struct gl_shader_program *prog, const char *fmt, ...)
|
|||
ralloc_vasprintf_append(&prog->data->InfoLog, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
prog->data->LinkStatus = GL_FALSE;
|
||||
prog->data->LinkStatus = linking_failure;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
Loading…
Reference in New Issue