From: Roland Scheidegger <srol...@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: + 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@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev