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 <kenneth@whitecape.org>
This commit is contained in:
Paul Berry 2014-01-22 11:45:39 -08:00
parent 00c672086c
commit 9cee3ff562
7 changed files with 8 additions and 18 deletions

View file

@ -617,7 +617,6 @@ private:
struct brw_wm_compile *c; struct brw_wm_compile *c;
struct gl_shader_program *prog; struct gl_shader_program *prog;
struct gl_shader *shader;
const struct gl_fragment_program *fp; const struct gl_fragment_program *fp;
unsigned dispatch_width; /**< 8 or 16 */ unsigned dispatch_width; /**< 8 or 16 */

View file

@ -46,8 +46,6 @@ fs_generator::fs_generator(struct brw_context *brw,
{ {
ctx = &brw->ctx; ctx = &brw->ctx;
shader = prog ? prog->_LinkedShaders[MESA_SHADER_FRAGMENT] : NULL;
mem_ctx = c; mem_ctx = c;
p = rzalloc(mem_ctx, struct brw_compile); 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; const void *last_annotation_ir = NULL;
if (unlikely(INTEL_DEBUG & DEBUG_WM)) { if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
if (shader) { if (prog) {
printf("Native code for fragment shader %d (SIMD%d dispatch):\n", printf("Native code for fragment shader %d (SIMD%d dispatch):\n",
prog->Name, dispatch_width); prog->Name, dispatch_width);
} else if (fp) { } else if (fp) {
@ -1373,7 +1371,7 @@ fs_generator::generate_code(exec_list *instructions, FILE *dump_file)
last_annotation_ir = inst->ir; last_annotation_ir = inst->ir;
if (last_annotation_ir) { if (last_annotation_ir) {
printf(" "); printf(" ");
if (shader) if (prog)
((ir_instruction *)inst->ir)->print(); ((ir_instruction *)inst->ir)->print();
else { else {
const prog_instruction *fpi; const prog_instruction *fpi;

View file

@ -652,7 +652,6 @@ private:
struct brw_compile *p; struct brw_compile *p;
struct gl_shader_program *shader_prog; struct gl_shader_program *shader_prog;
struct gl_shader *shader;
const struct gl_program *prog; const struct gl_program *prog;
struct brw_vec4_prog_data *prog_data; struct brw_vec4_prog_data *prog_data;

View file

@ -142,8 +142,6 @@ vec4_generator::vec4_generator(struct brw_context *brw,
: brw(brw), shader_prog(shader_prog), prog(prog), prog_data(prog_data), : brw(brw), shader_prog(shader_prog), prog(prog), prog_data(prog_data),
mem_ctx(mem_ctx), debug_flag(debug_flag) 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); p = rzalloc(mem_ctx, struct brw_compile);
brw_init_compile(brw, p, mem_ctx); brw_init_compile(brw, p, mem_ctx);
} }
@ -1257,7 +1255,7 @@ vec4_generator::generate_code(exec_list *instructions)
const void *last_annotation_ir = NULL; const void *last_annotation_ir = NULL;
if (unlikely(debug_flag)) { if (unlikely(debug_flag)) {
if (shader) { if (prog) {
printf("Native code for vertex shader %d:\n", shader_prog->Name); printf("Native code for vertex shader %d:\n", shader_prog->Name);
} else { } else {
printf("Native code for vertex program %d:\n", prog->Id); 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; last_annotation_ir = inst->ir;
if (last_annotation_ir) { if (last_annotation_ir) {
printf(" "); printf(" ");
if (shader) { if (prog) {
((ir_instruction *) last_annotation_ir)->print(); ((ir_instruction *) last_annotation_ir)->print();
} else { } else {
const prog_instruction *vpi; const prog_instruction *vpi;

View file

@ -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), : gen8_generator(brw, shader_prog, fp ? &fp->Base : NULL, c), c(c), fp(fp),
dual_source_output(dual_source_output) dual_source_output(dual_source_output)
{ {
shader =
shader_prog ? shader_prog->_LinkedShaders[MESA_SHADER_FRAGMENT] : NULL;
} }
gen8_fs_generator::~gen8_fs_generator() gen8_fs_generator::~gen8_fs_generator()
@ -570,7 +568,7 @@ gen8_fs_generator::generate_code(exec_list *instructions)
const void *last_annotation_ir = NULL; const void *last_annotation_ir = NULL;
if (unlikely(INTEL_DEBUG & DEBUG_WM)) { if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
if (shader) { if (prog) {
printf("Native code for fragment shader %d (SIMD%d dispatch):\n", printf("Native code for fragment shader %d (SIMD%d dispatch):\n",
shader_prog->Name, dispatch_width); shader_prog->Name, dispatch_width);
} else if (fp) { } else if (fp) {
@ -611,7 +609,7 @@ gen8_fs_generator::generate_code(exec_list *instructions)
last_annotation_ir = ir->ir; last_annotation_ir = ir->ir;
if (last_annotation_ir) { if (last_annotation_ir) {
printf(" "); printf(" ");
if (shader) { if (prog) {
((ir_instruction *) ir->ir)->print(); ((ir_instruction *) ir->ir)->print();
} else if (prog) { } else if (prog) {
const prog_instruction *fpi; const prog_instruction *fpi;

View file

@ -133,7 +133,6 @@ protected:
gen8_instruction *next_inst(unsigned opcode); gen8_instruction *next_inst(unsigned opcode);
struct gl_shader_program *shader_prog; struct gl_shader_program *shader_prog;
struct gl_shader *shader;
struct gl_program *prog; struct gl_program *prog;
struct brw_context *brw; struct brw_context *brw;

View file

@ -42,7 +42,6 @@ gen8_vec4_generator::gen8_vec4_generator(struct brw_context *brw,
prog_data(prog_data), prog_data(prog_data),
debug_flag(debug_flag) debug_flag(debug_flag)
{ {
shader = shader_prog ? shader_prog->_LinkedShaders[MESA_SHADER_VERTEX] : NULL;
} }
gen8_vec4_generator::~gen8_vec4_generator() gen8_vec4_generator::~gen8_vec4_generator()
@ -783,7 +782,7 @@ gen8_vec4_generator::generate_code(exec_list *instructions)
const void *last_annotation_ir = NULL; const void *last_annotation_ir = NULL;
if (unlikely(debug_flag)) { if (unlikely(debug_flag)) {
if (shader) { if (prog) {
printf("Native code for vertex shader %d:\n", shader_prog->Name); printf("Native code for vertex shader %d:\n", shader_prog->Name);
} else { } else {
printf("Native code for vertex program %d:\n", prog->Id); 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; last_annotation_ir = ir->ir;
if (last_annotation_ir) { if (last_annotation_ir) {
printf(" "); printf(" ");
if (shader) { if (prog) {
((ir_instruction *) last_annotation_ir)->print(); ((ir_instruction *) last_annotation_ir)->print();
} else { } else {
const prog_instruction *vpi; const prog_instruction *vpi;