summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2022-06-08 16:03:37 +0200
committerMarge Bot <emma+marge@anholt.net>2022-06-10 22:14:14 +0000
commit00837c6bef92e733ed5eb3eab4f51e70427cc7b1 (patch)
tree05ea69977c6cb4f1e350d6e787d9cc92caea143b
parentfff03d2bd3452d0472886b72b5cc7c7770796e80 (diff)
microsoft/compiler: make sampler-lowering optional
We don't want this in DZN, so let's make it optional. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16904>
-rw-r--r--src/gallium/drivers/d3d12/d3d12_compiler.cpp2
-rw-r--r--src/microsoft/compiler/dxil_nir_lower_int_cubemaps.c14
-rw-r--r--src/microsoft/compiler/dxil_nir_lower_int_cubemaps.h2
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
}