[Mesa-dev] [PATCH 17/27] i965: don't recreate program struct on cache fallback
Jordan Justen
jordan.l.justen at intel.com
Sat Aug 19 07:44:33 UTC 2017
From: Timothy Arceri <timothy.arceri at collabora.com>
We already have the struct and paramlist we don't want to recreate
them as this is unnecessary and would mean we would need to remap
anything using the old paramlist to the addresses of the new one.
---
src/compiler/glsl/linker.cpp | 13 +++++++++----
src/mesa/drivers/dri/i965/brw_link.cpp | 25 +++++++++++++------------
src/mesa/main/mtypes.h | 2 ++
3 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 9af7d8033a..306051f1f0 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -2260,10 +2260,15 @@ link_intrastage_shaders(void *mem_ctx,
linked->Stage = shader_list[0]->Stage;
/* Create program and attach it to the linked shader */
- struct gl_program *gl_prog =
- ctx->Driver.NewProgram(ctx,
- _mesa_shader_stage_to_program(shader_list[0]->Stage),
- prog->Name, false);
+ struct gl_program *gl_prog;
+ if (!prog->data->cache_fallback) {
+ gl_prog = ctx->Driver.NewProgram(ctx,
+ _mesa_shader_stage_to_program(shader_list[0]->Stage), prog->Name,
+ false);
+ } else {
+ gl_prog = prog->cache_progs[shader_list[0]->Stage];
+ }
+
if (!gl_prog) {
prog->data->LinkStatus = linking_failure;
_mesa_delete_linked_shader(ctx, linked);
diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index f14b87fd56..8f46728e74 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -229,23 +229,24 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
if (!shProg->data->cache_fallback) {
prog->Parameters = _mesa_new_parameter_list();
- }
- _mesa_copy_linked_program_data(shProg, shader);
+ _mesa_copy_linked_program_data(shProg, shader);
- prog->ShadowSamplers = shader->shadow_samplers;
- _mesa_update_shader_textures_used(shProg, prog);
+ prog->ShadowSamplers = shader->shadow_samplers;
+ _mesa_update_shader_textures_used(shProg, prog);
- update_xfb_info(prog->sh.LinkedTransformFeedback);
+ update_xfb_info(prog->sh.LinkedTransformFeedback);
- bool debug_enabled =
- (INTEL_DEBUG & intel_debug_flag_for_shader_stage(shader->Stage));
+ bool debug_enabled =
+ (INTEL_DEBUG & intel_debug_flag_for_shader_stage(shader->Stage));
- if (debug_enabled && shader->ir) {
- fprintf(stderr, "GLSL IR for native %s shader %d:\n",
- _mesa_shader_stage_to_string(shader->Stage), shProg->Name);
- _mesa_print_ir(stderr, shader->ir, NULL);
- fprintf(stderr, "\n\n");
+ if (debug_enabled && shader->ir) {
+ fprintf(stderr, "GLSL IR for native %s shader %d:\n",
+ _mesa_shader_stage_to_string(shader->Stage),
+ shProg->Name);
+ _mesa_print_ir(stderr, shader->ir, NULL);
+ fprintf(stderr, "\n\n");
+ }
}
prog->nir = brw_create_nir(brw, shProg, prog, (gl_shader_stage) stage,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index cb69d39d98..5e227e3dfb 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3038,6 +3038,8 @@ struct gl_shader_program
* #extension ARB_fragment_coord_conventions: enable
*/
GLboolean ARB_fragment_coord_conventions_enable;
+
+ struct gl_program *cache_progs[MESA_SHADER_STAGES];
};
--
2.14.0
More information about the mesa-dev
mailing list