[Mesa-dev] [PATCH 4/5] gallivm: add texture target information for sample opcodes to tgsi info

Roland Scheidegger sroland at vmware.com
Mon Sep 15 12:28:53 PDT 2014


Am 15.09.2014 21:00, schrieb Ilia Mirkin:
> On Mon, Sep 15, 2014 at 2:51 PM,  <sroland at vmware.com> wrote:
>> From: Roland Scheidegger <sroland at vmware.com>
>>
>> sample opcodes don't have valid texture target information (and I don't think
>> this should be changed), however it would be nice if we had that information
>> ready elsewhere, so stuff that information into the tgsi info when analyzing
>> a shader.
>> ---
>>  src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c | 41 ++++++++++++++++++++----
>>  1 file changed, 34 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c
>> index 3bbf260..7da76fc 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_info.c
>> @@ -48,6 +48,7 @@ struct analysis_context
>>
>>     unsigned num_imms;
>>     float imm[LP_MAX_TGSI_IMMEDIATES][4];
>> +   unsigned sample_target[PIPE_MAX_SHADER_SAMPLER_VIEWS];
>>
>>     struct lp_tgsi_channel_info temp[32][4];
>>  };
>> @@ -207,17 +208,36 @@ analyse_sample(struct analysis_context *ctx,
>>
>>     if (info->num_texs < Elements(info->tex)) {
>>        struct lp_tgsi_texture_info *tex_info = &info->tex[info->num_texs];
>> +      unsigned target = ctx->sample_target[inst->Src[1].Register.Index];
>>        boolean indirect = FALSE;
>>        boolean shadow = FALSE;
>>        unsigned readmask;
>>
>> -      /*
>> -       * We don't really get much information here, in particular not
>> -       * the target info, hence no useful writemask neither. Maybe should just
>> -       * forget the whole function.
>> -       */
>> -      readmask = TGSI_WRITEMASK_XYZW;
>> +      switch (target) {
>> +      /* note no shadow targets here */
>> +      case TGSI_TEXTURE_BUFFER:
>> +      case TGSI_TEXTURE_1D:
>> +         readmask = TGSI_WRITEMASK_X;
>> +         break;
>> +      case TGSI_TEXTURE_1D_ARRAY:
>> +      case TGSI_TEXTURE_2D:
>> +      case TGSI_TEXTURE_RECT:
>> +         readmask = TGSI_WRITEMASK_XY;
>> +         break;
>> +      case TGSI_TEXTURE_2D_ARRAY:
>> +      case TGSI_TEXTURE_3D:
>> +      case TGSI_TEXTURE_CUBE:
>> +         readmask = TGSI_WRITEMASK_XYZ;
>> +         break;
>> +      case TGSI_TEXTURE_CUBE_ARRAY:
>> +         readmask = TGSI_WRITEMASK_XYZW;
>> +         break;
>> +      default:
> 
> There are sample variants for 2d_ms/2d_ms_array (SAMPLE_I_MS) as well
> as shadow (SAMPLE_C). Perhaps you don't need to handle them here, but
> thought I'd point it out.

You are quite right they should be handled here too. It's because the
same code for tex opcodes forgot to handle it too, so copy/paste/cut
failed ;-). I'll fix that.

Roland

> 
>> +         assert(0);
>> +         return;
>> +      }
>>
>> +      tex_info->target = target;
>>        tex_info->texture_unit = inst->Src[1].Register.Index;
>>        tex_info->sampler_unit = inst->Src[2].Register.Index;
>>
>> @@ -524,7 +544,14 @@ lp_build_tgsi_info(const struct tgsi_token *tokens,
>>        tgsi_parse_token(&parse);
>>
>>        switch (parse.FullToken.Token.Type) {
>> -      case TGSI_TOKEN_TYPE_DECLARATION:
>> +      case TGSI_TOKEN_TYPE_DECLARATION: {
>> +         struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
>> +         if (decl->Declaration.File == TGSI_FILE_SAMPLER_VIEW) {
>> +            for (index = decl->Range.First; index <= decl->Range.Last; index++) {
>> +               ctx->sample_target[index] = decl->SamplerView.Resource;
>> +            }
>> +         }
>> +      }
>>           break;
>>
>>        case TGSI_TOKEN_TYPE_INSTRUCTION:
>> --
>> 1.9.1
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=yySEHQGQ6yte%2BFplrckZekkXjQZ%2FVUzcSKxQO1burfg%3D%0A&s=81e1e911f034aa8b1717477e11e980caad125c36942543c69e12aee74b385705



More information about the mesa-dev mailing list