X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fi965%2Fbrw_vs_constval.c;h=5b26c7a6db46bd9eb86d313fa322d2e7344ce60d;hb=8dd3e341b337ca2d22bcc0e7548a78a6c36ca77d;hp=528e164db8c6f5df51eb49f8ff31a6e51b032645;hpb=5363e3331ba016c9b1b9d5167473d69f32be3dac;p=mesa.git diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c b/src/mesa/drivers/dri/i965/brw_vs_constval.c index 528e164db8c..5b26c7a6db4 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_constval.c +++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c @@ -30,19 +30,17 @@ */ +#include "main/macros.h" #include "brw_context.h" -#include "program.h" -#include "program_instruction.h" -#include "macros.h" #include "brw_vs.h" /* Component is active if it may diverge from [0,0,0,1]. Undef values * are promoted to [0,0,0,1] for the purposes of this analysis. */ struct tracker { - GLboolean twoside; - GLubyte active[PROGRAM_OUTPUT+1][128]; - GLuint size_masks[4]; + bool twoside; + GLubyte active[PROGRAM_OUTPUT+1][MAX_PROGRAM_TEMPS]; + GLbitfield size_masks[4]; /**< one bit per fragment program input attrib */ }; @@ -55,8 +53,10 @@ static void set_active_component( struct tracker *t, case PROGRAM_TEMPORARY: case PROGRAM_INPUT: case PROGRAM_OUTPUT: + assert(file < PROGRAM_OUTPUT + 1); + assert(index < Elements(t->active[0])); t->active[file][index] |= active; - + break; default: break; } @@ -98,7 +98,7 @@ static GLubyte get_active( struct tracker *t, struct prog_src_register src ) { GLuint i; - GLubyte active = src.NegateBase; /* NOTE! */ + GLubyte active = src.Negate; /* NOTE! */ if (src.RelAddr) return 0xf; @@ -110,10 +110,15 @@ static GLubyte get_active( struct tracker *t, return active; } +/** + * Return the size (1,2,3 or 4) of the output/result for VERT_RESULT_idx. + */ static GLubyte get_output_size( struct tracker *t, GLuint idx ) { - GLubyte active = t->active[PROGRAM_OUTPUT][idx]; + GLubyte active; + assert(idx < VERT_RESULT_MAX); + active = t->active[PROGRAM_OUTPUT][idx]; if (active & (1<<3)) return 4; if (active & (1<<2)) return 3; if (active & (1<<1)) return 2; @@ -125,7 +130,7 @@ static GLubyte get_output_size( struct tracker *t, */ static void calc_sizes( struct tracker *t ) { - GLuint i; + GLint vertRes; if (t->twoside) { t->active[PROGRAM_OUTPUT][VERT_RESULT_COL0] |= @@ -135,12 +140,23 @@ static void calc_sizes( struct tracker *t ) t->active[PROGRAM_OUTPUT][VERT_RESULT_BFC1]; } - for (i = 0; i < FRAG_ATTRIB_MAX; i++) { - switch (get_output_size(t, i)) { - case 4: t->size_masks[4-1] |= 1<size_masks[3-1] |= 1<size_masks[2-1] |= 1<size_masks[1-1] |= 1<= FRAG_ATTRIB_TEX0); + assert(fragAttrib <= FRAG_ATTRIB_MAX); + + switch (get_output_size(t, vertRes)) { + case 4: t->size_masks[4-1] |= 1 << fragAttrib; + case 3: t->size_masks[3-1] |= 1 << fragAttrib; + case 2: t->size_masks[2-1] |= 1 << fragAttrib; + case 1: t->size_masks[1-1] |= 1 << fragAttrib; break; } } @@ -170,22 +186,38 @@ static GLuint get_input_size(struct brw_context *brw, */ static void calc_wm_input_sizes( struct brw_context *brw ) { + struct gl_context *ctx = &brw->intel.ctx; /* BRW_NEW_VERTEX_PROGRAM */ - struct brw_vertex_program *vp = - (struct brw_vertex_program *)brw->vertex_program; + const struct brw_vertex_program *vp = + brw_vertex_program_const(brw->vertex_program); /* BRW_NEW_INPUT_DIMENSIONS */ struct tracker t; GLuint insn; GLuint i; + /* Mesa IR is not generated for GLSL vertex shaders. If there's no Mesa + * IR, the code below cannot determine which output components are + * written. So, skip it and assume everything is written. This + * circumvents some optimizations in the fragment shader, but it guarantees + * that correct code is generated. + */ + if (vp->program.Base.NumInstructions == 0) { + brw->wm.input_size_masks[0] = ~0; + brw->wm.input_size_masks[1] = ~0; + brw->wm.input_size_masks[2] = ~0; + brw->wm.input_size_masks[3] = ~0; + return; + } + + memset(&t, 0, sizeof(t)); - /* _NEW_LIGHT */ - if (brw->attribs.Light->Model.TwoSide) + /* _NEW_LIGHT | _NEW_PROGRAM */ + if (ctx->VertexProgram._TwoSideEnabled) t.twoside = 1; for (i = 0; i < VERT_ATTRIB_MAX; i++) - if (vp->program.Base.InputsRead & (1<program.Base.InputsRead & BITFIELD64_BIT(i)) set_active_component(&t, PROGRAM_INPUT, i, szflag[get_input_size(brw, i)]); @@ -216,10 +248,10 @@ static void calc_wm_input_sizes( struct brw_context *brw ) const struct brw_tracked_state brw_wm_input_sizes = { .dirty = { - .mesa = _NEW_LIGHT, + .mesa = _NEW_LIGHT | _NEW_PROGRAM, .brw = BRW_NEW_VERTEX_PROGRAM | BRW_NEW_INPUT_DIMENSIONS, .cache = 0 }, - .update = calc_wm_input_sizes + .emit = calc_wm_input_sizes };