panfrost: Clamp uniform buffer size
authorIcecream95 <ixn@keemail.me>
Sun, 20 Sep 2020 03:30:45 +0000 (15:30 +1200)
committerMarge Bot <eric+marge@anholt.net>
Thu, 24 Sep 2020 12:43:19 +0000 (12:43 +0000)
Issue (57) for the ARB_uniform_buffer_object spec states:
    "The uniform buffer could be larger than the amount of uniform
    block(s) data inside it."

This means we need to clamp the uniform buffer size in case it is
bigger than what hardware supports.

Fixes the OpenGL 3.3 renderer of GZDoom.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6835>

src/gallium/drivers/panfrost/pan_cmdstream.c

index b15e6b8..45ce989 100644 (file)
@@ -905,8 +905,12 @@ panfrost_emit_const_buf(struct panfrost_batch *batch,
                         continue;
                 }
 
+                /* Issue (57) for the ARB_uniform_buffer_object spec says that
+                 * the buffer can be larger than the uniform data inside it,
+                 * so clamp ubo size to what hardware supports. */
+
                 pan_pack(ubo_ptr + ubo, UNIFORM_BUFFER, cfg) {
-                        cfg.entries = DIV_ROUND_UP(usz, 16);
+                        cfg.entries = MIN2(DIV_ROUND_UP(usz, 16), 1 << 12);
                         cfg.pointer = panfrost_map_constant_buffer_gpu(batch,
                                         stage, buf, ubo);
                 }