Mesa (master): microsoft/compiler: Support raw SRVs/UAVs through dxil_module_get_res_type

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


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

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Fri Apr  9 13:43:25 2021 -0700

microsoft/compiler: Support raw SRVs/UAVs through dxil_module_get_res_type

Switch the OpenCL "globals" array to use that helper

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

---

 src/microsoft/compiler/dxil_module.c | 8 ++++++++
 src/microsoft/compiler/nir_to_dxil.c | 8 ++------
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/microsoft/compiler/dxil_module.c b/src/microsoft/compiler/dxil_module.c
index 7f772c96f85..86cd9465d46 100644
--- a/src/microsoft/compiler/dxil_module.c
+++ b/src/microsoft/compiler/dxil_module.c
@@ -830,6 +830,14 @@ dxil_module_get_res_type(struct dxil_module *m, enum dxil_resource_kind kind,
       return dxil_module_get_struct_type(m, class_name, &vec_type, 1);
    }
 
+   case DXIL_RESOURCE_KIND_RAW_BUFFER:
+   {
+      const struct dxil_type *component_type = dxil_module_get_int_type(m, 32);
+      char class_name[64] = { 0 };
+      snprintf(class_name, 64, "struct.%sByteAddressBuffer", readwrite ? "RW" : "");
+      return dxil_module_get_struct_type(m, class_name, &component_type, 1);
+   }
+
    default:
       unreachable("resource type not supported");
    }
diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c
index e8b450648a2..b21c13a4856 100644
--- a/src/microsoft/compiler/nir_to_dxil.c
+++ b/src/microsoft/compiler/nir_to_dxil.c
@@ -795,12 +795,8 @@ emit_globals(struct ntd_context *ctx, nir_shader *s, unsigned size)
    if (!size)
       return true;
 
-   const struct dxil_type *type = dxil_module_get_int_type(&ctx->mod, 32);
-   if (!type)
-      return false;
-
-   const struct dxil_type *struct_type =
-      dxil_module_get_struct_type(&ctx->mod, NULL, &type, 1);
+   const struct dxil_type *struct_type = dxil_module_get_res_type(&ctx->mod,
+      DXIL_RESOURCE_KIND_RAW_BUFFER, DXIL_COMP_TYPE_INVALID, true /* readwrite */);
    if (!struct_type)
       return false;
 



More information about the mesa-commit mailing list