[Mesa-dev] [PATCH 1/5] st/mesa: also emit labels for TGSI_OPCODE_BGNSUB

Brian Paul brianp at vmware.com
Tue Apr 14 11:12:32 PDT 2015


On 04/14/2015 10:58 AM, Ilia Mirkin wrote:
> Nothing against this patch per se, but are there any actual users of
> BGNSUB/CAL/etc? Was it done in anticipation of ARB_shader_subroutines
> (and/or whatever corresponding feature in DirectX)?

I found a shader that becomes extremely large after all the function 
call inlining is done.  So I looked at returning 
PIPE_SHADER_CAP_SUBROUTINES=1 and seeing what it would take to be 
smarter about whether to inline all calls or not.  It's a non-trivial 
project and I've only scratched the surface of it so far.

This was some low-hanging fruit I found while looking at that.

-Brian



>
> On Tue, Apr 14, 2015 at 12:56 PM, Brian Paul <brianp at vmware.com> wrote:
>> Subroutines need labels so they can be identied by CAL instructions.
>> ---
>>   src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 19 +++++++++++++------
>>   1 file changed, 13 insertions(+), 6 deletions(-)
>>
>> diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> index 67a4da7..eb0ce07 100644
>> --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
>> @@ -4771,18 +4771,25 @@ compile_tgsi_instruction(struct st_translate *t,
>>      }
>>
>>      switch(inst->op) {
>> +   case TGSI_OPCODE_BGNSUB:
>>      case TGSI_OPCODE_BGNLOOP:
>>      case TGSI_OPCODE_CAL:
>>      case TGSI_OPCODE_ELSE:
>>      case TGSI_OPCODE_ENDLOOP:
>>      case TGSI_OPCODE_IF:
>>      case TGSI_OPCODE_UIF:
>> -      assert(num_dst == 0);
>> -      ureg_label_insn(ureg,
>> -                      inst->op,
>> -                      src, num_src,
>> -                      get_label(t,
>> -                                inst->op == TGSI_OPCODE_CAL ? inst->function->sig_id : 0));
>> +      {
>> +         int sig_id = 0;
>> +         if (inst->op == TGSI_OPCODE_CAL ||
>> +             inst->op == TGSI_OPCODE_BGNSUB) {
>> +            sig_id = inst->function->sig_id;
>> +         }
>> +         assert(num_dst == 0);
>> +         ureg_label_insn(ureg,
>> +                         inst->op,
>> +                         src, num_src,
>> +                         get_label(t, sig_id));
>> +      }
>>         return;
>>
>>      case TGSI_OPCODE_TEX:
>> --
>> 1.9.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=AwIBaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=8c_P2LPF2tJdXKRwpiUU8FHxNtyf_w1nFwKe-NUUtSM&s=sk-_7YlHjG01t5DnqRTxnXy_aKsewOAl65XO6V_nI4M&e=



More information about the mesa-dev mailing list