llvmpipe/draw: handle UBOs that are < 16 bytes.
authorDave Airlie <airlied@redhat.com>
Wed, 9 Oct 2019 05:11:14 +0000 (15:11 +1000)
committerDave Airlie <airlied@linux.ie>
Thu, 10 Oct 2019 21:52:20 +0000 (21:52 +0000)
Not sure if this is a bug in the user or not, but some CTS
tests fail due to using an 8 byte constant buffer.

Fixes: KHR-GLES31.core.layout_binding.block_layout_binding_block_VertexShader
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
src/gallium/drivers/llvmpipe/lp_setup.c

index b96a5c9931594c0d5bd1343169e0d99c854c9a04..0eeaf780af053ce356b819b0ef7dcf693f399a9d 100644 (file)
@@ -289,8 +289,13 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
    unsigned i;
 
    for (i = 0; i < ARRAY_SIZE(llvm->jit_context.vs_constants); ++i) {
+      /*
+       * There could be a potential issue with rounding this up, as the
+       * shader expects 16-byte allocations, the fix is likely to move
+       * to LOAD intrinsic in the future and remove the vec4 constraint.
+       */
       int num_consts =
-         draw->pt.user.vs_constants_size[i] / (sizeof(float) * 4);
+         DIV_ROUND_UP(draw->pt.user.vs_constants_size[i], (sizeof(float) * 4));
       llvm->jit_context.vs_constants[i] = draw->pt.user.vs_constants[i];
       llvm->jit_context.num_vs_constants[i] = num_consts;
       if (num_consts == 0) {
@@ -308,7 +313,7 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
 
    for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) {
       int num_consts =
-         draw->pt.user.gs_constants_size[i] / (sizeof(float) * 4);
+         DIV_ROUND_UP(draw->pt.user.gs_constants_size[i], (sizeof(float) * 4));
       llvm->gs_jit_context.constants[i] = draw->pt.user.gs_constants[i];
       llvm->gs_jit_context.num_constants[i] = num_consts;
       if (num_consts == 0) {
index e6fa082f4f005007acf67fa70503d67fa78e3658..002c8b8a25b6347ca02a004e302c33f2face2cb0 100644 (file)
@@ -1230,7 +1230,7 @@ try_update_scene_state( struct lp_setup_context *setup )
          }
 
          num_constants =
-            setup->constants[i].stored_size / (sizeof(float) * 4);
+            DIV_ROUND_UP(setup->constants[i].stored_size, (sizeof(float) * 4));
          setup->fs.current.jit_context.num_constants[i] = num_constants;
          setup->dirty |= LP_SETUP_NEW_FS;
       }