summaryrefslogtreecommitdiffstats
path: root/src/panfrost/midgard
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-08-15 16:41:53 -0700
committerAlyssa Rosenzweig <[email protected]>2019-08-19 08:32:17 -0700
commitedc8e41566ed7c4e9f8931db57328cea7a7104b3 (patch)
tree5754b9891d7b81d4347cc2f89ac329c80c7b3814 /src/panfrost/midgard
parent2bcb3d922600b86818dc03110538460a92fbab6f (diff)
pan/midgard: Use type-appropriate swizzle for texture coordinate
The texture coordinate for a 2D texture could be a vec2 or a vec3, depending if it's an array texture or not. If it's vec2 (non-array texture), we should not reference the z component; otherwise, liveness analysis will get very confused when z is never written. v2: Fix typo (Ilia). Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost/midgard')
-rw-r--r--src/panfrost/midgard/midgard_compile.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 67c5c848214..2b454a92260 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -1753,6 +1753,7 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
for (unsigned i = 0; i < instr->num_srcs; ++i) {
int index = nir_src_index(ctx, &instr->src[i].src);
midgard_vector_alu_src alu_src = blank_alu_src;
+ unsigned nr_components = nir_src_num_components(instr->src[i].src);
switch (instr->src[i].src_type) {
case nir_tex_src_coord: {
@@ -1804,7 +1805,12 @@ emit_texop_native(compiler_context *ctx, nir_tex_instr *instr,
if (instr->sampler_dim == GLSL_SAMPLER_DIM_2D) {
/* Array component in w but NIR wants it in z */
- ins.texture.in_reg_swizzle = SWIZZLE_XYZZ;
+ if (nr_components == 3)
+ ins.texture.in_reg_swizzle = SWIZZLE_XYZZ;
+ else if (nr_components == 2)
+ ins.texture.in_reg_swizzle = SWIZZLE_XYXX;
+ else
+ unreachable("Invalid texture 2D components");
}
break;