Mesa (master): microsoft/compiler: Emit CBVs via variables for Vulkan

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 16 17:16:32 UTC 2021


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

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Fri Apr  9 14:39:44 2021 -0700

microsoft/compiler: Emit CBVs via variables for Vulkan

The resources need to be emitted in a particular order, so CBVs
have to be emitted first and can't be emitted as we iterate through
instructions.

Reviewed-by: Enrico Galli <enrico.galli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10149>

---

 src/microsoft/compiler/nir_to_dxil.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c
index 53467e5d76a..792aa834ea5 100644
--- a/src/microsoft/compiler/nir_to_dxil.c
+++ b/src/microsoft/compiler/nir_to_dxil.c
@@ -3209,12 +3209,6 @@ emit_load_vulkan_descriptor(struct ntd_context *ctx, nir_intrinsic_instr *intr)
 
    switch (nir_intrinsic_desc_type(intr)) {
    case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: {
-      if (ctx->cbv_handles[binding])
-         break;
-      char name[64];
-      snprintf(name, sizeof(name), "__ubo%d", binding);
-      if (!emit_cbv(ctx, binding, 16384 /*4096 vec4's*/, 1, name))
-         return false;
       break;
    }
    default:
@@ -4008,7 +4002,7 @@ prepare_phi_values(struct ntd_context *ctx, nir_shader *shader)
 static bool
 emit_cbvs(struct ntd_context *ctx, nir_shader *s)
 {
-   if (s->info.stage == MESA_SHADER_KERNEL) {
+   if (s->info.stage == MESA_SHADER_KERNEL || ctx->opts->vulkan_environment) {
       nir_foreach_variable_with_modes(var, s, nir_var_mem_ubo) {
          if (!emit_ubo_var(ctx, var))
             return false;
@@ -4099,9 +4093,8 @@ emit_module(struct ntd_context *ctx, nir_shader *s, const struct nir_to_dxil_opt
    sort_uniforms_by_binding_and_remove_structs(s);
 
    /* CBVs */
-   if(!opts->vulkan_environment)
-      if (!emit_cbvs(ctx, s))
-         return false;
+   if (!emit_cbvs(ctx, s, opts))
+      return false;
 
    /* Samplers */
    binding = 0;



More information about the mesa-commit mailing list