ir3/nir: Fix 1d array readonly images

ncoords includes the array index, and the NIR source has the array index
as its last component, so we have to insert the extra y coordinate in
the middle in this case.

Fixes: 0bb0cac ("freedreno/ir3: handle image buffer")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15114>
This commit is contained in:
Connor Abbott 2022-02-22 11:35:55 +01:00 committed by Marge Bot
parent 21ac044c3e
commit 58d72f45e5
2 changed files with 14 additions and 7 deletions

View file

@ -239,8 +239,6 @@ spec@arb_texture_rg@texwrap formats-int bordercolor-swizzled@GL_RG32UI- swizzled
spec@arb_texture_rg@texwrap formats-int bordercolor-swizzled@GL_RG8I- swizzled- border color only,Fail
spec@arb_texture_rg@texwrap formats-int bordercolor-swizzled@GL_RG8UI- swizzled- border color only,Fail
spec@arb_texture_view@rendering-layers-image,Fail
spec@arb_texture_view@rendering-layers-image@layers rendering of image1DArray,Fail
spec@arb_timer_query@timestamp-get,Fail
# "Expected 1 primitives written, got 0"

View file

@ -1421,11 +1421,20 @@ emit_intrinsic_load_image(struct ir3_context *ctx, nir_intrinsic_instr *intr,
info.flags |= flags;
for (unsigned i = 0; i < ncoords; i++)
coords[i] = src0[i];
if (ncoords == 1)
coords[ncoords++] = create_immed(b, 0);
/* hw doesn't do 1d, so we treat it as 2d with height of 1, and patch up the
* y coord. Note that the array index must come after the fake y coord.
*/
enum glsl_sampler_dim dim = nir_intrinsic_image_dim(intr);
if (dim == GLSL_SAMPLER_DIM_1D || dim == GLSL_SAMPLER_DIM_BUF) {
coords[0] = src0[0];
coords[1] = create_immed(b, 0);
for (unsigned i = 1; i < ncoords; i++)
coords[i + 1] = src0[i];
ncoords++;
} else {
for (unsigned i = 0; i < ncoords; i++)
coords[i] = src0[i];
}
sam = emit_sam(ctx, OPC_ISAM, info, type, 0b1111,
ir3_create_collect(b, coords, ncoords), NULL);