Mesa (main): d3d12: move cubemap-lowering to common-code

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 10 22:44:51 UTC 2022


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

Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date:   Wed Jun  8 15:53:44 2022 +0200

d3d12: move cubemap-lowering to common-code

We're going to want to do part of this in DZN as well.

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16904>

---

 src/gallium/drivers/d3d12/d3d12_compiler.cpp       |  3 +-
 src/gallium/drivers/d3d12/d3d12_nir_passes.h       |  3 --
 src/gallium/drivers/d3d12/meson.build              |  1 -
 .../compiler/dxil_nir_lower_int_cubemaps.c}        |  4 +--
 .../compiler/dxil_nir_lower_int_cubemaps.h         | 40 ++++++++++++++++++++++
 src/microsoft/compiler/meson.build                 |  1 +
 6 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index f48c94f41ba..94ff702d352 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -28,6 +28,7 @@
 #include "d3d12_nir_passes.h"
 #include "nir_to_dxil.h"
 #include "dxil_nir.h"
+#include "dxil_nir_lower_int_cubemaps.h"
 
 #include "pipe/p_state.h"
 
@@ -1346,7 +1347,7 @@ d3d12_create_shader_impl(struct d3d12_context *ctx,
    /* Integer cube maps are not supported in DirectX because sampling is not supported
     * on integer textures and TextureLoad is not supported for cube maps, so we have to
     * lower integer cube maps to be handled like 2D textures arrays*/
-   NIR_PASS_V(nir, d3d12_lower_int_cubmap_to_array);
+   NIR_PASS_V(nir, dxil_nir_lower_int_cubemaps);
 
    /* Keep this initial shader as the blue print for possible variants */
    sel->initial = nir;
diff --git a/src/gallium/drivers/d3d12/d3d12_nir_passes.h b/src/gallium/drivers/d3d12/d3d12_nir_passes.h
index dca85e4ff95..920be9be559 100644
--- a/src/gallium/drivers/d3d12/d3d12_nir_passes.h
+++ b/src/gallium/drivers/d3d12/d3d12_nir_passes.h
@@ -90,9 +90,6 @@ d3d12_fix_io_uint_type(struct nir_shader *s, uint64_t in_mask, uint64_t out_mask
 void
 d3d12_nir_invert_depth(nir_shader *s, unsigned viewport_mask);
 
-bool
-d3d12_lower_int_cubmap_to_array(nir_shader *s);
-
 bool
 nir_lower_packed_ubo_loads(struct nir_shader *nir);
 
diff --git a/src/gallium/drivers/d3d12/meson.build b/src/gallium/drivers/d3d12/meson.build
index 72f8ae2cd31..cfe33bcadc3 100644
--- a/src/gallium/drivers/d3d12/meson.build
+++ b/src/gallium/drivers/d3d12/meson.build
@@ -34,7 +34,6 @@ files_libd3d12 = files(
   'd3d12_format.c',
   'd3d12_gs_variant.cpp',
   'd3d12_lower_image_casts.c',
-  'd3d12_lower_int_cubemap_to_array.c',
   'd3d12_lower_point_sprite.c',
   'd3d12_nir_lower_vs_vertex_conversion.c',
   'd3d12_nir_passes.c',
diff --git a/src/gallium/drivers/d3d12/d3d12_lower_int_cubemap_to_array.c b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c
similarity index 99%
rename from src/gallium/drivers/d3d12/d3d12_lower_int_cubemap_to_array.c
rename to src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c
index 819dc51388b..1eab15af8d2 100644
--- a/src/gallium/drivers/d3d12/d3d12_lower_int_cubemap_to_array.c
+++ b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c
@@ -21,7 +21,7 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "d3d12_nir_passes.h"
+#include "dxil_nir_lower_int_cubemaps.h"
 
 #include "nir_builder.h"
 #include "nir_builtin_builder.h"
@@ -558,7 +558,7 @@ lower_int_cubmap_to_array_impl(nir_builder *b, nir_instr *instr,
 }
 
 bool
-d3d12_lower_int_cubmap_to_array(nir_shader *s)
+dxil_nir_lower_int_cubemaps(nir_shader *s)
 {
    bool result =
          nir_shader_lower_instructions(s,
diff --git a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h
new file mode 100644
index 00000000000..28434228ab7
--- /dev/null
+++ b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright © Microsoft Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef DXIL_NIR_LOWER_INT_CUBEMAPS_H
+#define DXIL_NIR_LOWER_INT_CUBEMAPS_H
+
+#include "nir.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool
+dxil_nir_lower_int_cubemaps(nir_shader *s);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // DXIL_NIR_LOWER_INT_CUBEMAPS_H
diff --git a/src/microsoft/compiler/meson.build b/src/microsoft/compiler/meson.build
index e8953c7c693..f96b47562c0 100644
--- a/src/microsoft/compiler/meson.build
+++ b/src/microsoft/compiler/meson.build
@@ -27,6 +27,7 @@ files_libdxil_compiler = files(
   'dxil_function.c',
   'dxil_module.c',
   'dxil_nir.c',
+  'dxil_nir_lower_int_cubemaps.c',
   'dxil_nir_lower_int_samplers.c',
   'dxil_signature.c',
   'dxil_nir_tess.c',



More information about the mesa-commit mailing list