On 24 August 2012 03:05, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The number we're passing around is actually the ID of the texture unit,<br>
as opposed to the numerical value our of sampler uniforms.  Calling it<br>
"texunit" clarifies this slightly.<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 28 ++++++++++++++--------------<br>
 1 file changed, 14 insertions(+), 14 deletions(-)<br>
<br>
The first of the "real" patches.<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
index b844009..601f83c 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp<br>
@@ -1166,7 +1166,7 @@ fs_visitor::emit_texture_gen7(ir_texture *ir, fs_reg dst, fs_reg coordinate,<br>
  * setting this->result).<br>
  */<br>
 fs_reg<br>
-fs_visitor::emit_texcoord(ir_texture *ir, int sampler)<br>
+fs_visitor::emit_texcoord(ir_texture *ir, int texunit)<br>
 {<br>
    fs_inst *inst = NULL;<br>
<br>
@@ -1186,13 +1186,13 @@ fs_visitor::emit_texcoord(ir_texture *ir, int sampler)<br>
     */<br>
    if (ir->sampler->type->sampler_dimensionality == GLSL_SAMPLER_DIM_RECT &&<br>
        (intel->gen < 6 ||<br>
-       (intel->gen >= 6 && (c->key.tex.gl_clamp_mask[0] & (1 << sampler) ||<br>
-                            c->key.tex.gl_clamp_mask[1] & (1 << sampler))))) {<br>
+       (intel->gen >= 6 && (c->key.tex.gl_clamp_mask[0] & (1 << texunit) ||<br>
+                            c->key.tex.gl_clamp_mask[1] & (1 << texunit))))) {<br>
       struct gl_program_parameter_list *params = c->fp->program.Base.Parameters;<br>
       int tokens[STATE_LENGTH] = {<br>
         STATE_INTERNAL,<br>
         STATE_TEXRECT_SCALE,<br>
-        sampler,<br>
+        texunit,<br>
         0,<br>
         0<br>
       };<br>
@@ -1239,7 +1239,7 @@ fs_visitor::emit_texcoord(ir_texture *ir, int sampler)<br>
       needs_gl_clamp = false;<br>
<br>
       for (int i = 0; i < 2; i++) {<br>
-        if (c->key.tex.gl_clamp_mask[i] & (1 << sampler)) {<br>
+        if (c->key.tex.gl_clamp_mask[i] & (1 << texunit)) {<br>
            fs_reg chan = coordinate;<br>
            chan.reg_offset += i;<br>
<br>
@@ -1265,7 +1265,7 @@ fs_visitor::emit_texcoord(ir_texture *ir, int sampler)<br>
    if (ir->coordinate && needs_gl_clamp) {<br>
       for (unsigned int i = 0;<br>
           i < MIN2(ir->coordinate->type->vector_elements, 3); i++) {<br>
-        if (c->key.tex.gl_clamp_mask[i] & (1 << sampler)) {<br>
+        if (c->key.tex.gl_clamp_mask[i] & (1 << texunit)) {<br>
            fs_reg chan = coordinate;<br>
            chan.reg_offset += i;<br>
<br>
@@ -1283,7 +1283,7 @@ fs_visitor::visit(ir_texture *ir)<br>
    fs_inst *inst = NULL;<br>
<br>
    int sampler = _mesa_get_sampler_uniform_value(ir->sampler, prog, &fp->Base);<br>
-   sampler = fp->Base.SamplerUnits[sampler];<br>
+   int texunit = fp->Base.SamplerUnits[sampler];<br></blockquote><div><br>Oh, wow, this particular line is *much* better now.  Thank you for clarifying this code.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
    /* Should be lowered by do_lower_texture_projection */<br>
    assert(!ir->projector);<br>
@@ -1292,7 +1292,7 @@ fs_visitor::visit(ir_texture *ir)<br>
     * done before loading any values into MRFs for the sampler message since<br>
     * generating these values may involve SEND messages that need the MRFs.<br>
     */<br>
-   fs_reg coordinate = emit_texcoord(ir, sampler);<br>
+   fs_reg coordinate = emit_texcoord(ir, texunit);<br>
<br>
    fs_reg shadow_comparitor;<br>
    if (ir->shadow_comparitor) {<br>
@@ -1345,12 +1345,12 @@ fs_visitor::visit(ir_texture *ir)<br>
    if (ir->offset != NULL && ir->op != ir_txf)<br>
       inst->texture_offset = brw_texture_offset(ir->offset->as_constant());<br>
<br>
-   inst->sampler = sampler;<br>
+   inst->sampler = texunit;<br></blockquote><div><br>BTW, you might want to include a sentence in the commit message to explain why you're not renaming inst->sampler to inst->texunit.  I had to look ahead to patch 9/10 to understand that in the long run, inst->sampler actually will be the sampler number, not the texture unit (so renaming it here would just be pointless churn).<br>
<br>Either way, the patch is:<br><br>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> <br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
    if (ir->shadow_comparitor)<br>
       inst->shadow_compare = true;<br>
<br>
-   swizzle_result(ir, dst, sampler);<br>
+   swizzle_result(ir, dst, texunit);<br>
 }<br>
<br>
 /**<br>
@@ -1358,7 +1358,7 @@ fs_visitor::visit(ir_texture *ir)<br>
  * EXT_texture_swizzle as well as DEPTH_TEXTURE_MODE for shadow comparisons.<br>
  */<br>
 void<br>
-fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)<br>
+fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int texunit)<br>
 {<br>
    this->result = orig_val;<br>
<br>
@@ -1368,11 +1368,11 @@ fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)<br>
    if (ir->type == glsl_type::float_type) {<br>
       /* Ignore DEPTH_TEXTURE_MODE swizzling. */<br>
       assert(ir->sampler->type->sampler_shadow);<br>
-   } else if (c->key.tex.swizzles[sampler] != SWIZZLE_NOOP) {<br>
+   } else if (c->key.tex.swizzles[texunit] != SWIZZLE_NOOP) {<br>
       fs_reg swizzled_result = fs_reg(this, glsl_type::vec4_type);<br>
<br>
       for (int i = 0; i < 4; i++) {<br>
-        int swiz = GET_SWZ(c->key.tex.swizzles[sampler], i);<br>
+        int swiz = GET_SWZ(c->key.tex.swizzles[texunit], i);<br>
         fs_reg l = swizzled_result;<br>
         l.reg_offset += i;<br>
<br>
@@ -1382,7 +1382,7 @@ fs_visitor::swizzle_result(ir_texture *ir, fs_reg orig_val, int sampler)<br>
            emit(BRW_OPCODE_MOV, l, fs_reg(1.0f));<br>
         } else {<br>
            fs_reg r = orig_val;<br>
-           r.reg_offset += GET_SWZ(c->key.tex.swizzles[sampler], i);<br>
+           r.reg_offset += GET_SWZ(c->key.tex.swizzles[texunit], i);<br>
            emit(BRW_OPCODE_MOV, l, r);<br>
         }<br>
       }<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.11.4<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br>