Mesa (main): microsoft/spirv_to_dxil: Fix the push_constant UBO size calculation

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 3 10:54:46 UTC 2022


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

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Wed May 25 10:18:32 2022 +0200

microsoft/spirv_to_dxil: Fix the push_constant UBO size calculation

Right now, we just consider the size of the accessed portion of the
push constant array, but it doesn't necessarily reflect the size
of the UBO we should declare.

Fixes: de1e941c5909 ("microsoft/spirv_to_dxil: Lower push constant loads to UBO loads")
Reviewed-by: Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16703>

---

 src/microsoft/spirv_to_dxil/spirv_to_dxil.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c
index 4b5bd8a636a..ea643979002 100644
--- a/src/microsoft/spirv_to_dxil/spirv_to_dxil.c
+++ b/src/microsoft/spirv_to_dxil/spirv_to_dxil.c
@@ -177,8 +177,7 @@ struct lower_load_push_constant_data {
    nir_address_format ubo_format;
    unsigned desc_set;
    unsigned binding;
-   uint32_t min;
-   uint32_t max;
+   unsigned size;
 };
 
 static bool
@@ -199,8 +198,8 @@ lower_load_push_constant(struct nir_builder *builder, nir_instr *instr,
 
    uint32_t base = nir_intrinsic_base(intrin);
    uint32_t range = nir_intrinsic_range(intrin);
-   data->min = MIN2(data->min, base);
-   data->max = MAX2(data->max, base + range);
+
+   data->size = MAX2(base + range, data->size);
 
    builder->cursor = nir_after_instr(instr);
    nir_address_format ubo_format = data->ubo_format;
@@ -239,8 +238,6 @@ dxil_spirv_nir_lower_load_push_constant(nir_shader *shader,
       .ubo_format = ubo_format,
       .desc_set = desc_set,
       .binding = binding,
-      .min = UINT32_MAX,
-      .max = 0,
    };
    ret = nir_shader_instructions_pass(shader, lower_load_push_constant,
                                       nir_metadata_block_index |
@@ -248,10 +245,7 @@ dxil_spirv_nir_lower_load_push_constant(nir_shader *shader,
                                          nir_metadata_loop_analysis,
                                       &data);
 
-   if (data.min >= data.max)
-      *size = 0;
-   else
-      *size = (data.max - data.min);
+   *size = data.size;
 
    assert(ret == (*size > 0));
 



More information about the mesa-commit mailing list