zink: adjust swizzled deref loads by the variable component offset
this code is intended to transform a block like:
```
32 %306 = @load_interpolated_input (%34, %0 (0x0)) (base=3, component=2, dest_type=float32, io location=VARYING_SLOT_VAR3 slots=1)
32x2 %307 = fsub %305, %306.xx
```
into derefs. the existing code generates this:
```
decl_var shader_in INTERP_MODE_NONE none vec2 #7 (VARYING_SLOT_VAR3.zw, 0, 0)
32 %516 = deref_var  (shader_in vec2)
32x2 %517 = @load_deref (%516) (access=none)
32 %518 = mov %517.z
error: src->swizzle[i] < num_components (../src/compiler/nir/nir_validate.c:216)
```
the problem is attempting to reapply the component offset to a variable which is
already at an offset
fixes #10567
Fixes: 17a35412dc
("zink: re-rework i/o variable handling to make having variables entirely optional")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27522>
This commit is contained in:

committed by
Marge Bot

parent
fab5c706fe
commit
0a243a7241
@@ -3777,7 +3777,7 @@ add_derefs_instr(nir_builder *b, nir_intrinsic_instr *intr, void *data)
|
|||||||
}
|
}
|
||||||
/* filter needed components */
|
/* filter needed components */
|
||||||
if (intr->num_components < load->num_components)
|
if (intr->num_components < load->num_components)
|
||||||
load = nir_channels(b, load, BITFIELD_MASK(intr->num_components) << c);
|
load = nir_channels(b, load, BITFIELD_MASK(intr->num_components) << (c - var->data.location_frac));
|
||||||
nir_def_rewrite_uses(&intr->def, load);
|
nir_def_rewrite_uses(&intr->def, load);
|
||||||
} else {
|
} else {
|
||||||
nir_def *store = intr->src[0].ssa;
|
nir_def *store = intr->src[0].ssa;
|
||||||
|
Reference in New Issue
Block a user