Mesa (master): svga: round UBO constant buffer size up/ down to multiple of 16 bytes

Brian Paul brianp at kemper.freedesktop.org
Wed Oct 7 15:37:09 UTC 2015


Module: Mesa
Branch: master
Commit: 2bad030ac9c47c316f615db83c52cf0391f64f3f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2bad030ac9c47c316f615db83c52cf0391f64f3f

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Oct  6 16:55:39 2015 -0600

svga: round UBO constant buffer size up/down to multiple of 16 bytes

The svga3d device requires constant buffers to be a multiple of 16 bytes
in size.  OpenGL UBOs may not fit that restriction.  As a work-around,
round the size up if possible, else round down.

Note that this patch only effects UBO constant buffers (index 1 or higher),
not the 0th/default constant buffer.

Fixes the game Grim Fandango Remastered.  VMware bug 1510130.

Reviewed-by: Charmaine Lee <charmainel at vmware.com>
Reviewed-by: José Fonseca <jfonseca at vmware.com>

---

 src/gallium/drivers/svga/svga_state_constants.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index b6d6de0..75592d3 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -704,6 +704,24 @@ emit_consts_vgpu10(struct svga_context *svga, unsigned shader)
          assert(size == 0);
       }
 
+      if (size % 16 != 0) {
+         /* GL's buffer range sizes can be any number of bytes but the
+          * SVGA3D device requires a multiple of 16 bytes.
+          */
+         const unsigned total_size = buffer->b.b.width0;
+
+         if (offset + align(size, 16) <= total_size) {
+            /* round up size to multiple of 16 */
+            size = align(size, 16);
+         }
+         else {
+            /* round down to mulitple of 16 (this may cause rendering problems
+             * but should avoid a device error).
+             */
+            size &= ~16;
+         }
+      }
+
       assert(size % 16 == 0);
       ret = SVGA3D_vgpu10_SetSingleConstantBuffer(svga->swc,
                                                   index,




More information about the mesa-commit mailing list