[Mesa-dev] [PATCH 01/40] st/mesa/i965: create link status enum
Anuj Phogat
anuj.phogat at gmail.com
Wed Feb 8 23:37:09 UTC 2017
On Mon, Feb 6, 2017 at 7:42 PM, Timothy Arceri <tarceri at itsqueeze.com> wrote:
> 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.
> ---
> src/compiler/glsl/linker.cpp | 6 +++---
> src/compiler/glsl/standalone.cpp | 2 +-
> src/mesa/drivers/dri/i965/brw_cs.c | 4 ++--
> src/mesa/drivers/dri/i965/brw_tcs.c | 2 +-
> src/mesa/drivers/dri/i965/brw_tes.c | 2 +-
> src/mesa/drivers/dri/i965/brw_vs.c | 2 +-
> src/mesa/drivers/dri/i965/brw_wm.c | 2 +-
> src/mesa/main/mtypes.h | 13 ++++++++++++-
> src/mesa/main/program_resource.c | 2 +-
> src/mesa/main/shaderapi.c | 8 ++++----
> src/mesa/main/uniforms.c | 2 +-
> src/mesa/program/ir_to_mesa.cpp | 4 ++--
> src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 +-
> 13 files changed, 31 insertions(+), 20 deletions(-)
>
> diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
> index b768a6e..720c22b 100644
> --- a/src/compiler/glsl/linker.cpp
> +++ b/src/compiler/glsl/linker.cpp
> @@ -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:
> diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
> index 44f2c0f..7a2d3d2 100644
> --- a/src/compiler/glsl/standalone.cpp
> +++ b/src/compiler/glsl/standalone.cpp
> @@ -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,
> diff --git a/src/mesa/drivers/dri/i965/brw_cs.c b/src/mesa/drivers/dri/i965/brw_cs.c
> index 0f8d4eb..16b7945 100644
> --- a/src/mesa/drivers/dri/i965/brw_cs.c
> +++ b/src/mesa/drivers/dri/i965/brw_cs.c
> @@ -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);
>
> diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
> index 858ecf9..64bfc40 100644
> --- a/src/mesa/drivers/dri/i965/brw_tcs.c
> +++ b/src/mesa/drivers/dri/i965/brw_tcs.c
> @@ -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);
> }
>
> diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
> index cb12b9c..3da5357 100644
> --- a/src/mesa/drivers/dri/i965/brw_tes.c
> +++ b/src/mesa/drivers/dri/i965/brw_tes.c
> @@ -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: "
> diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
> index a822580..3f11a76 100644
> --- a/src/mesa/drivers/dri/i965/brw_vs.c
> +++ b/src/mesa/drivers/dri/i965/brw_vs.c
> @@ -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);
> }
>
> diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
> index a774720..4a07c14 100644
> --- a/src/mesa/drivers/dri/i965/brw_wm.c
> +++ b/src/mesa/drivers/dri/i965/brw_wm.c
> @@ -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);
> }
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index a2280e2..a845a39 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -2647,6 +2647,17 @@ struct gl_program_resource
> };
>
> /**
> + * 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.
> */
> struct gl_shader_program_data
> @@ -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;
>
> diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
> index 4b5be6f..4eacdfb 100644
> --- a/src/mesa/main/program_resource.c
> +++ b/src/mesa/main/program_resource.c
> @@ -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;
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 4667866..da450f2 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -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
> }
> diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
> index a954055..8376a95 100644
> --- a/src/mesa/main/uniforms.c
> +++ b/src/mesa/main/uniforms.c
> @@ -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;
> diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
> index dc5f801..ce58fbb 100644
> --- a/src/mesa/program/ir_to_mesa.cpp
> +++ b/src/mesa/program/ir_to_mesa.cpp
> @@ -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;
> }
> }
>
> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> index 77a51d5..5a65f32 100644
> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
> @@ -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
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Patches 1-4 are:
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
More information about the mesa-dev
mailing list