From 1895e17591439ca876da1b1a1c9669cbb5c70f0a Mon Sep 17 00:00:00 2001 From: Charles Baker Date: Tue, 30 Nov 2021 07:25:03 +1300 Subject: [PATCH] mesa: align constant/uniform uploads to driver expected alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixed a problem for Zink where uniform buffer alignment varies by GPU, e.g. 64 bytes for an RTX 2070 SUPER but 256 bytes for a GTX 1070 Ti. Tested running Superposition on Windows 10 with Nvidia 1070 Ti with 496.13 driver. Without the fix Superposition soft locks on its splash screen. With the fix Superposition runs through its benchmark. Reviewed-by: Marek Olšák Reviewed-By: Mike Blumenkrantz Part-of: --- src/mesa/state_tracker/st_atom_constbuf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index f23dacbbc60..9f337d4f957 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -122,12 +122,16 @@ st_upload_constants(struct st_context *st, struct gl_program *prog, gl_shader_st if (st->prefer_real_buffer_in_constbuf0) { struct pipe_context *pipe = st->pipe; uint32_t *ptr; + + const unsigned alignment = MAX2( + st->ctx->Const.UniformBufferOffsetAlignment, 64); + /* fetch_state always stores 4 components (16 bytes) per matrix row, * but matrix rows are sometimes allocated partially, so add 12 * to compensate for the fetch_state defect. */ - u_upload_alloc(pipe->const_uploader, 0, paramBytes + 12, 64, - &cb.buffer_offset, &cb.buffer, (void**)&ptr); + u_upload_alloc(pipe->const_uploader, 0, paramBytes + 12, + alignment, &cb.buffer_offset, &cb.buffer, (void**)&ptr); int uniform_bytes = params->UniformBytes; if (uniform_bytes)