[Mesa-dev] [PATCH 10/12] i965/fs: Reimplement emit_texture() in terms of logical send messages.

Francisco Jerez currojerez at riseup.net
Wed Jul 22 00:41:59 PDT 2015


Jason Ekstrand <jason at jlekstrand.net> writes:

> On Sat, Jul 18, 2015 at 7:34 AM, Francisco Jerez <currojerez at riseup.net> wrote:
>> ---
>>  src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 66 +++++++++++++++++++++-------
>>  1 file changed, 49 insertions(+), 17 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
>> index 89fcc49..4011639 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
>> @@ -861,6 +861,14 @@ fs_visitor::emit_texture(ir_texture_opcode op,
>>        }
>>     }
>>
>> +   if (op == ir_query_levels) {
>> +      /* textureQueryLevels() is implemented in terms of TXS so we need to
>> +       * pass a valid LOD argument.
>> +       */
>> +      assert(lod.file == BAD_FILE);
>> +      lod = fs_reg(0u);
>
> Why can't this go as part of the switch below?  It seems kind of odd
> to split the logic up like this.
>
What I had in mind originally was to factor out the switch statement
below into a separate function -- Later on I noticed that you wanted to
rework emit_texture() and friends to stop using ir_texture_opcode as
representation for the texturing operation, so you would likely want to
get rid of the whole switch-case statement below or replace it with
something else, so I didn't bother.  What are your current plans for
emit_texture()?

>> +   }
>> +
>>     if (coordinate.file != BAD_FILE) {
>>        /* FINISHME: Texture coordinate rescaling doesn't work with non-constant
>>         * samplers.  This should only be a problem with GL_CLAMP on Gen7.
>> @@ -873,26 +881,50 @@ fs_visitor::emit_texture(ir_texture_opcode op,
>>      * samples, so don't worry about them.
>>      */
>>     fs_reg dst = vgrf(glsl_type::get_instance(dest_type->base_type, 4, 1));
>> +   const fs_reg srcs[] = {
>> +      coordinate, shadow_c, lod, lod2,
>> +      sample_index, mcs, sampler_reg, offset_value,
>> +      fs_reg(coord_components), fs_reg(grad_components)
>> +   };
>> +   enum opcode opcode;
>>
>> -   if (devinfo->gen >= 7) {
>> -      inst = emit_texture_gen7(op, dst, coordinate, coord_components,
>> -                               shadow_c, lod, lod2, grad_components,
>> -                               sample_index, mcs, sampler_reg,
>> -                               offset_value);
>> -   } else if (devinfo->gen >= 5) {
>> -      inst = emit_texture_gen5(op, dst, coordinate, coord_components,
>> -                               shadow_c, lod, lod2, grad_components,
>> -                               sample_index, sampler,
>> -                               offset_value.file != BAD_FILE);
>> -   } else if (dispatch_width == 16) {
>> -      inst = emit_texture_gen4_simd16(op, dst, coordinate, coord_components,
>> -                                      shadow_c, lod, sampler);
>> -   } else {
>> -      inst = emit_texture_gen4(op, dst, coordinate, coord_components,
>> -                               shadow_c, lod, lod2, grad_components,
>> -                               sampler);
>> +   switch (op) {
>> +   case ir_tex:
>> +      opcode = SHADER_OPCODE_TEX_LOGICAL;
>> +      break;
>> +   case ir_txb:
>> +      opcode = FS_OPCODE_TXB_LOGICAL;
>> +      break;
>> +   case ir_txl:
>> +      opcode = SHADER_OPCODE_TXL_LOGICAL;
>> +      break;
>> +   case ir_txd:
>> +      opcode = SHADER_OPCODE_TXD_LOGICAL;
>> +      break;
>> +   case ir_txf:
>> +      opcode = SHADER_OPCODE_TXF_LOGICAL;
>> +      break;
>> +   case ir_txf_ms:
>> +      opcode = SHADER_OPCODE_TXF_CMS_LOGICAL;
>> +      break;
>> +   case ir_txs:
>> +   case ir_query_levels:
>> +      opcode = SHADER_OPCODE_TXS_LOGICAL;
>> +      break;
>> +   case ir_lod:
>> +      opcode = SHADER_OPCODE_LOD_LOGICAL;
>> +      break;
>> +   case ir_tg4:
>> +      opcode = (offset_value.file != BAD_FILE && offset_value.file != IMM ?
>> +                SHADER_OPCODE_TG4_OFFSET_LOGICAL : SHADER_OPCODE_TG4_LOGICAL);
>> +      break;
>> +   default:
>> +      unreachable("not reached");
>
> Please choose something more descriptive than "not reached".  How
> about "invalid texture opcode"

Sure, I'll fix that, thanks.

>
>>     }
>>
>> +   inst = bld.emit(opcode, dst, srcs, ARRAY_SIZE(srcs));
>> +   inst->regs_written = 4 * dispatch_width / 8;
>> +
>>     if (shadow_c.file != BAD_FILE)
>>        inst->shadow_compare = true;
>>
>> --
>> 2.4.3
>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150722/20451eb2/attachment.sig>


More information about the mesa-dev mailing list