etnaviv: fix rendering without vertex buffers/attributes

The hardware doesn't allow to disable all vertex attribute streams,
so we end up with random FE state when a draw without vertex
attributes is encountered. Plug in a dummy attribute and vertex
buffer to avoid this.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32947>
This commit is contained in:
Lucas Stach
2025-01-07 23:15:26 +01:00
committed by Marge Bot
parent bca5ef70a4
commit 5ca8feb28b

View File

@@ -547,6 +547,13 @@ etna_set_vertex_buffers(struct pipe_context *pctx, unsigned num_buffers,
true);
so->count = util_last_bit(so->enabled_mask);
if (!num_buffers) {
so->count = 1;
so->cvb[0].FE_VERTEX_STREAM_BASE_ADDR.bo = ctx->screen->dummy_bo;
so->cvb[0].FE_VERTEX_STREAM_BASE_ADDR.offset = 0;
so->cvb[0].FE_VERTEX_STREAM_BASE_ADDR.flags = ETNA_RELOC_READ;
}
for (unsigned idx = 0; idx < num_buffers; ++idx) {
struct compiled_set_vertex_buffer *cs = &so->cvb[idx];
struct pipe_vertex_buffer *vbi = &so->vb[idx];
@@ -635,6 +642,18 @@ etna_vertex_elements_state_create(struct pipe_context *pctx,
/* XXX could minimize number of consecutive stretches here by sorting, and
* permuting the inputs in shader or does Mesa do this already? */
if (!num_elements) {
/* There's no way to disable all elements on the hardware, so we need to
* plug in a dummy element and vertex buffer (stride = 0, so only fetches
* first location). */
static const struct pipe_vertex_element dummy_element = {
.src_format = PIPE_FORMAT_R8G8B8A8_UNORM,
};
elements = &dummy_element;
num_elements = 1;
}
cs->num_elements = num_elements;
unsigned start_offset = 0; /* start of current consecutive stretch */