On 12/13/2011 01:12 PM, Eric Anholt wrote: > On Thu, 8 Dec 2011 17:07:58 -0800, Kenneth Graunke <kenn...@whitecape.org> > wrote: >> This translates the GLSL compiler's IR into vec4_instruction IR, >> generating code to load coordinates, LOD info, shadow comparitors, and >> so on into the appropriate message registers. >> >> It turns out that the SIMD4x2 parameters are identical on Gen 5-7, and >> the Gen4 code is similar enough that, unlike in the FS, it's easy enough >> to support all generations in a single function. >> >> Signed-off-by: Kenneth Graunke <kenn...@whitecape.org> >> --- >> src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 114 >> ++++++++++++++++++++++-- >> 1 files changed, 107 insertions(+), 7 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp >> b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp >> index 853c3ee..85490bb 100644 >> --- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp >> +++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp > >> + vec4_instruction *inst; >> + switch (ir->op) { >> + case ir_tex: > > Isn't this one invalid for vertex shaders, too?
Nope. From the GLSL 1.30 spec, page 80 (86 in the PDF): "The implicit level of detail is selected as follows: For a texture that is not mip-mapped, the texture is used directly. If it is mip-mapped and running in a fragment shader, the LOD computed by the implementation is used to do the texture lookup. If it is mip-mapped and running on the vertex shader, then the base texture is used." So ir_tex is equivalent to ir_txl with lod 0. >> + case ir_txl: >> + inst = new(mem_ctx) vec4_instruction(this, SHADER_OPCODE_TXL); >> + break; >> + case ir_txd: >> + inst = new(mem_ctx) vec4_instruction(this, SHADER_OPCODE_TXD); >> + break; >> + case ir_txf: >> + inst = new(mem_ctx) vec4_instruction(this, SHADER_OPCODE_TXF); >> + break; >> + case ir_txs: >> + inst = new(mem_ctx) vec4_instruction(this, SHADER_OPCODE_TXS); >> + break; >> + case ir_txb: >> + assert(!"TXB is not valid for vertex shaders."); >> + } > >> + /* Load the LOD info */ >> + if (ir->op == ir_txl) { >> + ir->lod_info.lod->accept(this); >> + int mrf, writemask; >> + if (intel->gen >= 5) { >> + mrf = param_base + 1; >> + writemask = ir->shadow_comparitor ? WRITEMASK_Y : WRITEMASK_X; >> + inst->mlen++; >> + } else /* intel->gen == 4 */ { >> + mrf = param_base; >> + writemask = WRITEMASK_Z; >> + } >> + emit(MOV(dst_reg(MRF, mrf, ir->lod_info.lod->type, writemask), >> + this->result)); > > I'd move the accept down next to the MOV. I'm always afraid of the > hidden return data from accept getting trashed before it gets consumed. > I wish the visitor stuff let us do the sensible thing and produce a > return value. I totally agree - they used to be right next to each other before I added the Gen4 code. I'll move it. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev