From 9cee3ff562f3e4b51bfd30338fd1ba7716ac5737 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Wed, 22 Jan 2014 11:45:39 -0800 Subject: [PATCH] i965: Remove *_generator::shader field; use prog field instead. The "shader" field in fs_generator, vec4_generator, and gen8_generator was only used for one purpose; to figure out if we were compiling an assembly program or a GLSL shader (shader is NULL for assembly programs). And it wasn't being used properly: in vec4 shaders we were always initializing it based on prog->_LinkedShaders[MESA_SHADER_FRAGMENT], regardless of whether we were compiling a geometry shader or a vertex shader. This patch simplifies things by using the "prog" field instead; this is also NULL for assembly programs. Reviewed-by: Kenneth Graunke --- src/mesa/drivers/dri/i965/brw_fs.h | 1 - src/mesa/drivers/dri/i965/brw_fs_generator.cpp | 6 ++---- src/mesa/drivers/dri/i965/brw_vec4.h | 1 - src/mesa/drivers/dri/i965/brw_vec4_generator.cpp | 6 ++---- src/mesa/drivers/dri/i965/gen8_fs_generator.cpp | 6 ++---- src/mesa/drivers/dri/i965/gen8_generator.h | 1 - src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp | 5 ++--- 7 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 9bc69829798..2ccb8c4585d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -617,7 +617,6 @@ private: struct brw_wm_compile *c; struct gl_shader_program *prog; - struct gl_shader *shader; const struct gl_fragment_program *fp; unsigned dispatch_width; /**< 8 or 16 */ diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 121f73343cf..6d211e11412 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -46,8 +46,6 @@ fs_generator::fs_generator(struct brw_context *brw, { ctx = &brw->ctx; - shader = prog ? prog->_LinkedShaders[MESA_SHADER_FRAGMENT] : NULL; - mem_ctx = c; p = rzalloc(mem_ctx, struct brw_compile); @@ -1332,7 +1330,7 @@ fs_generator::generate_code(exec_list *instructions, FILE *dump_file) const void *last_annotation_ir = NULL; if (unlikely(INTEL_DEBUG & DEBUG_WM)) { - if (shader) { + if (prog) { printf("Native code for fragment shader %d (SIMD%d dispatch):\n", prog->Name, dispatch_width); } else if (fp) { @@ -1373,7 +1371,7 @@ fs_generator::generate_code(exec_list *instructions, FILE *dump_file) last_annotation_ir = inst->ir; if (last_annotation_ir) { printf(" "); - if (shader) + if (prog) ((ir_instruction *)inst->ir)->print(); else { const prog_instruction *fpi; diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 4a5b57775c3..e17b5cd3f37 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -652,7 +652,6 @@ private: struct brw_compile *p; struct gl_shader_program *shader_prog; - struct gl_shader *shader; const struct gl_program *prog; struct brw_vec4_prog_data *prog_data; diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 1e6520dbabe..94d1e791689 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -142,8 +142,6 @@ vec4_generator::vec4_generator(struct brw_context *brw, : brw(brw), shader_prog(shader_prog), prog(prog), prog_data(prog_data), mem_ctx(mem_ctx), debug_flag(debug_flag) { - shader = shader_prog ? shader_prog->_LinkedShaders[MESA_SHADER_VERTEX] : NULL; - p = rzalloc(mem_ctx, struct brw_compile); brw_init_compile(brw, p, mem_ctx); } @@ -1257,7 +1255,7 @@ vec4_generator::generate_code(exec_list *instructions) const void *last_annotation_ir = NULL; if (unlikely(debug_flag)) { - if (shader) { + if (prog) { printf("Native code for vertex shader %d:\n", shader_prog->Name); } else { printf("Native code for vertex program %d:\n", prog->Id); @@ -1273,7 +1271,7 @@ vec4_generator::generate_code(exec_list *instructions) last_annotation_ir = inst->ir; if (last_annotation_ir) { printf(" "); - if (shader) { + if (prog) { ((ir_instruction *) last_annotation_ir)->print(); } else { const prog_instruction *vpi; diff --git a/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp b/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp index 6c710bc8a0c..e0b52126705 100644 --- a/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/gen8_fs_generator.cpp @@ -43,8 +43,6 @@ gen8_fs_generator::gen8_fs_generator(struct brw_context *brw, : gen8_generator(brw, shader_prog, fp ? &fp->Base : NULL, c), c(c), fp(fp), dual_source_output(dual_source_output) { - shader = - shader_prog ? shader_prog->_LinkedShaders[MESA_SHADER_FRAGMENT] : NULL; } gen8_fs_generator::~gen8_fs_generator() @@ -570,7 +568,7 @@ gen8_fs_generator::generate_code(exec_list *instructions) const void *last_annotation_ir = NULL; if (unlikely(INTEL_DEBUG & DEBUG_WM)) { - if (shader) { + if (prog) { printf("Native code for fragment shader %d (SIMD%d dispatch):\n", shader_prog->Name, dispatch_width); } else if (fp) { @@ -611,7 +609,7 @@ gen8_fs_generator::generate_code(exec_list *instructions) last_annotation_ir = ir->ir; if (last_annotation_ir) { printf(" "); - if (shader) { + if (prog) { ((ir_instruction *) ir->ir)->print(); } else if (prog) { const prog_instruction *fpi; diff --git a/src/mesa/drivers/dri/i965/gen8_generator.h b/src/mesa/drivers/dri/i965/gen8_generator.h index 7d74267bcf1..1f4b7f8823e 100644 --- a/src/mesa/drivers/dri/i965/gen8_generator.h +++ b/src/mesa/drivers/dri/i965/gen8_generator.h @@ -133,7 +133,6 @@ protected: gen8_instruction *next_inst(unsigned opcode); struct gl_shader_program *shader_prog; - struct gl_shader *shader; struct gl_program *prog; struct brw_context *brw; diff --git a/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp b/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp index f1fc188eca3..5a348580b9a 100644 --- a/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/gen8_vec4_generator.cpp @@ -42,7 +42,6 @@ gen8_vec4_generator::gen8_vec4_generator(struct brw_context *brw, prog_data(prog_data), debug_flag(debug_flag) { - shader = shader_prog ? shader_prog->_LinkedShaders[MESA_SHADER_VERTEX] : NULL; } gen8_vec4_generator::~gen8_vec4_generator() @@ -783,7 +782,7 @@ gen8_vec4_generator::generate_code(exec_list *instructions) const void *last_annotation_ir = NULL; if (unlikely(debug_flag)) { - if (shader) { + if (prog) { printf("Native code for vertex shader %d:\n", shader_prog->Name); } else { printf("Native code for vertex program %d:\n", prog->Id); @@ -799,7 +798,7 @@ gen8_vec4_generator::generate_code(exec_list *instructions) last_annotation_ir = ir->ir; if (last_annotation_ir) { printf(" "); - if (shader) { + if (prog) { ((ir_instruction *) last_annotation_ir)->print(); } else { const prog_instruction *vpi; -- 2.30.2