[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 19:03:08 PDT 2014


Am 15.09.2014 21:28, schrieb Roland Scheidegger:
> 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.

Actually sample_c is already handled alright. The target information
comes from the sampler view dcl, and there will never be shadow there -
TGSI_TEXTURE_xxx is sort of a misnomer here it really is more like
PIPE_TEXTURE_xxx but it needs to match what we do for tex opcodes. It
would be possible to convert sample type (if sample_c) + sampler view
dcl into a shadow target but I don't see any point in that, the purpose
of the function was just to figure out the type of the texture and if
it's indirect or not.

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
> 
> _______________________________________________
> 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=%2FgutzOG6UM8y%2FgvyWvRCfwKsJIsJRHVQWVewUdmq4UM%3D%0A&s=ec9f6f189e32a81581b6b08dd535d4ad1f78530442f413b79c87a34dec53fd67
> 



More information about the mesa-dev mailing list