Mesa (main): mesa: align constant/uniform uploads to driver expected alignment

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Feb 8 15:52:55 UTC 2022


Module: Mesa
Branch: main
Commit: 1895e17591439ca876da1b1a1c9669cbb5c70f0a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1895e17591439ca876da1b1a1c9669cbb5c70f0a

Author: Charles Baker <charles at juicelabs.co>
Date:   Tue Nov 30 07:25:03 2021 +1300

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 at amd.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14674>

---

 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)



More information about the mesa-commit mailing list