From 524341f1092e4c8cfa594d1c4d291ea5ed9267eb Mon Sep 17 00:00:00 2001 From: Charmaine Lee Date: Tue, 25 May 2021 11:11:36 -0700 Subject: [PATCH] svga: fix texture rectangle sampling when no sampler view declaration is defined It is valid to not have a sampler view declaration for the corresponding sampler in a TGSI shader, and hence we should not rely on the sampler view declaration to determine if we need to adjust the unnormalized coordinates for texture rectangle sampling. This patch is to prep for tgsi shaders that are translated from nir which in many cases do not issue sampler view declarations. Fixes: 584b1070372a0e ("st/mesa: Drop the TGSI paths for drawpixels and use nir-to-tgsi") Reviewed-by: Neha Bhende (cherry picked from commit fda4eaf5c43dc05b1218a394a7e418054347a6d5) --- .pick_status.json | 2 +- src/gallium/drivers/svga/svga_tgsi_vgpu10.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index cd821559ae4..fe19e7f0a7e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -769,7 +769,7 @@ "description": "svga: fix texture rectangle sampling when no sampler view declaration is defined", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "584b1070372a0e010a0e9a221493e5042575abb1" }, diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c index 2d991d16952..b58b90575e2 100644 --- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c +++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c @@ -4662,6 +4662,7 @@ emit_vgpu10_declaration(struct svga_shader_emitter_v10 *emit, unsigned unit = decl->Range.First; assert(decl->Range.First == decl->Range.Last); emit->sampler_target[unit] = decl->SamplerView.Resource; + /* Note: we can ignore YZW return types for now */ emit->sampler_return_type[unit] = decl->SamplerView.ReturnTypeX; emit->sampler_view[unit] = TRUE; @@ -5605,15 +5606,14 @@ emit_constant_declaration(struct svga_shader_emitter_v10 *emit) for (i = 0; i < emit->num_samplers; i++) { - if (emit->sampler_view[i]) { - + if (emit->key.tex[i].sampler_view) { /* Texcoord scale factors for RECT textures */ if (emit->key.tex[i].unnormalized) { emit->texcoord_scale_index[i] = total_consts++; } /* Texture buffer sizes */ - if (emit->sampler_target[i] == TGSI_TEXTURE_BUFFER) { + if (emit->key.tex[i].target == PIPE_BUFFER) { emit->texture_buffer_size_index[i] = total_consts++; } } @@ -7721,7 +7721,7 @@ setup_texcoord(struct svga_shader_emitter_v10 *emit, unsigned unit, const struct tgsi_full_src_register *coord) { - if (emit->sampler_view[unit] && emit->key.tex[unit].unnormalized) { + if (emit->key.tex[unit].sampler_view && emit->key.tex[unit].unnormalized) { unsigned scale_index = emit->texcoord_scale_index[unit]; unsigned tmp = get_temp_index(emit); struct tgsi_full_src_register tmp_src = make_src_temp_reg(tmp); @@ -8561,7 +8561,7 @@ emit_txq(struct svga_shader_emitter_v10 *emit, { const uint unit = inst->Src[1].Register.Index; - if (emit->sampler_target[unit] == TGSI_TEXTURE_BUFFER) { + if (emit->key.tex[unit].target == PIPE_BUFFER) { /* RESINFO does not support querying texture buffers, so we instead * store texture buffer sizes in shader constants, then copy them to * implement TXQ instead of emitting RESINFO. @@ -10890,6 +10890,7 @@ transform_fs_pstipple(struct svga_shader_emitter_v10 *emit, emit->key.tex[unit].swizzle_g = TGSI_SWIZZLE_Y; emit->key.tex[unit].swizzle_b = TGSI_SWIZZLE_Z; emit->key.tex[unit].swizzle_a = TGSI_SWIZZLE_W; + emit->key.tex[unit].target = PIPE_TEXTURE_2D; if (0) { debug_printf("After pstipple ------------------\n");