Mesa (main): microsoft/compiler: make sampler-lowering optional
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 10 22:44:52 UTC 2022
Module: Mesa
Branch: main
Commit: 00837c6bef92e733ed5eb3eab4f51e70427cc7b1
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=00837c6bef92e733ed5eb3eab4f51e70427cc7b1
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Wed Jun 8 16:03:37 2022 +0200
microsoft/compiler: make sampler-lowering optional
We don't want this in DZN, so let's make it optional.
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 | 2 +-
src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c | 14 ++++++++------
src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h | 2 +-
3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index 94ff702d352..d5e677d03ee 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -1347,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, dxil_nir_lower_int_cubemaps);
+ NIR_PASS_V(nir, dxil_nir_lower_int_cubemaps, true);
/* Keep this initial shader as the blue print for possible variants */
sel->initial = nir;
diff --git a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c
index 38e7ecae720..be4a1d2b7ff 100644
--- a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c
+++ b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c
@@ -41,8 +41,9 @@ type_needs_lowering(const struct glsl_type *type)
static bool
lower_int_cubmap_to_array_filter(const nir_instr *instr,
- UNUSED const void *_options)
+ const void *options)
{
+ bool lower_samplers = *(bool *)options;
if (instr->type == nir_instr_type_intrinsic) {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
switch (intr->intrinsic) {
@@ -89,7 +90,7 @@ lower_int_cubmap_to_array_filter(const nir_instr *instr,
} else if (instr->type == nir_instr_type_deref) {
nir_deref_instr *deref = nir_instr_as_deref(instr);
return type_needs_lowering(deref->type);
- } else if (instr->type == nir_instr_type_tex) {
+ } else if (instr->type == nir_instr_type_tex && lower_samplers) {
nir_tex_instr *tex = nir_instr_as_tex(instr);
if (tex->sampler_dim != GLSL_SAMPLER_DIM_CUBE)
@@ -546,9 +547,10 @@ lower_cube_image_deref(nir_builder *b, nir_deref_instr *deref)
static nir_ssa_def *
lower_int_cubmap_to_array_impl(nir_builder *b, nir_instr *instr,
- UNUSED void *_options)
+ void *options)
{
- if (instr->type == nir_instr_type_tex)
+ bool lower_samplers = *(bool *)options;
+ if (instr->type == nir_instr_type_tex && lower_samplers)
return lower_int_cubemap_to_array_tex(b, nir_instr_as_tex(instr));
else if (instr->type == nir_instr_type_intrinsic)
return lower_cube_image_intrinsic(b, nir_instr_as_intrinsic(instr));
@@ -558,13 +560,13 @@ lower_int_cubmap_to_array_impl(nir_builder *b, nir_instr *instr,
}
bool
-dxil_nir_lower_int_cubemaps(nir_shader *s)
+dxil_nir_lower_int_cubemaps(nir_shader *s, bool lower_samplers)
{
bool result =
nir_shader_lower_instructions(s,
lower_int_cubmap_to_array_filter,
lower_int_cubmap_to_array_impl,
- NULL);
+ &lower_samplers);
if (result) {
nir_foreach_variable_with_modes_safe(var, s, nir_var_uniform | nir_var_image) {
diff --git a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h
index 28434228ab7..d130700d0d8 100644
--- a/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h
+++ b/src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h
@@ -31,7 +31,7 @@ extern "C" {
#endif
bool
-dxil_nir_lower_int_cubemaps(nir_shader *s);
+dxil_nir_lower_int_cubemaps(nir_shader *s, bool lower_samplers);
#ifdef __cplusplus
}
More information about the mesa-commit
mailing list