mesa: align constant/uniform uploads to driver expected alignment

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 <marek.olsak@amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14674>
This commit is contained in:
Charles Baker 2021-11-30 07:25:03 +13:00 committed by Marge Bot
parent 418c77640b
commit 1895e17591
1 changed files with 6 additions and 2 deletions

View File

@ -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)