pan/bi: Handle images in vertex shaders

We need to offset by the number of attributes, since the primary
attribute table is shared for images and vertex attributes.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11123>
This commit is contained in:
Alyssa Rosenzweig 2021-06-01 18:50:30 -04:00 committed by Marge Bot
parent 071165e082
commit 5c0e5d4d2d
2 changed files with 21 additions and 10 deletions

View file

@ -12,16 +12,8 @@ dEQP-GLES31.functional.draw_buffers_indexed.random.max_implementation_draw_buffe
dEQP-GLES31.functional.draw_buffers_indexed.random.max_required_draw_buffers.10,Fail
dEQP-GLES31.functional.draw_indirect.draw_elements_indirect.line_strip.instanced_attributes,Fail
dEQP-GLES31.functional.draw_indirect.random.31,Fail
dEQP-GLES31.functional.layout_binding.image.image2d.vertex_binding_array,Fail
dEQP-GLES31.functional.layout_binding.image.image2d.vertex_binding_max_array,Fail
dEQP-GLES31.functional.layout_binding.image.image2d.vertex_binding_max,Fail
dEQP-GLES31.functional.layout_binding.image.image2d.vertex_binding_multiple,Fail
dEQP-GLES31.functional.layout_binding.image.image2d.vertex_binding_single,Fail
dEQP-GLES31.functional.layout_binding.image.image3d.vertex_binding_array,Fail
dEQP-GLES31.functional.layout_binding.image.image3d.vertex_binding_max_array,Fail
dEQP-GLES31.functional.layout_binding.image.image3d.vertex_binding_max,Fail
dEQP-GLES31.functional.layout_binding.image.image3d.vertex_binding_multiple,Fail
dEQP-GLES31.functional.layout_binding.image.image3d.vertex_binding_single,Fail
dEQP-GLES31.functional.separate_shader.random.23,Fail
dEQP-GLES31.functional.separate_shader.random.35,Fail
dEQP-GLES31.functional.separate_shader.random.49,Fail

View file

@ -809,6 +809,25 @@ bi_emit_image_coord(bi_builder *b, bi_index coord)
bi_half(bi_word(coord, 1), false));
}
static bi_index
bi_emit_image_index(bi_builder *b, nir_intrinsic_instr *instr)
{
nir_src src = instr->src[0];
bi_index index = bi_src_index(&src);
bi_context *ctx = b->shader;
/* Images come after vertex attributes, so handle an explicit offset */
unsigned offset = (ctx->stage == MESA_SHADER_VERTEX) ?
util_bitcount64(ctx->nir->info.inputs_read) : 0;
if (offset == 0)
return index;
else if (nir_src_is_const(src))
return bi_imm_u32(nir_src_as_uint(src) + offset);
else
return bi_iadd_u32(b, index, bi_imm_u32(offset), false);
}
static void
bi_emit_image_load(bi_builder *b, nir_intrinsic_instr *instr)
{
@ -822,7 +841,7 @@ bi_emit_image_load(bi_builder *b, nir_intrinsic_instr *instr)
bi_ld_attr_tex_to(b, bi_dest_index(&instr->dest),
bi_emit_image_coord(b, coords),
bi_emit_image_coord(b, bi_word(coords, 2)),
bi_src_index(&instr->src[0]),
bi_emit_image_index(b, instr),
bi_reg_fmt_for_nir(nir_intrinsic_dest_type(instr)),
instr->num_components - 1);
}
@ -845,7 +864,7 @@ bi_emit_lea_image(bi_builder *b, nir_intrinsic_instr *instr)
bi_index zw = bi_emit_image_coord(b, bi_word(coords, 2));
bi_instr *I = bi_lea_attr_tex_to(b, bi_temp(b->shader), xy, zw,
bi_src_index(&instr->src[0]), type);
bi_emit_image_index(b, instr), type);
/* LEA_ATTR_TEX defaults to the secondary attribute table, but our ABI
* has all images in the primary attribute table */