gallium/d3d12: move d3d12_lower_bool_input to microsoft/compiler

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/13262>
This commit is contained in:
Michael Tang
2021-10-07 16:19:33 -07:00
committed by Marge Bot
parent 70f193ffcf
commit 36aa1a2959
5 changed files with 50 additions and 52 deletions
+1 -1
View File
@@ -160,7 +160,7 @@ compile_nir(struct d3d12_context *ctx, struct d3d12_shader_selector *sel,
NIR_PASS_V(nir, nir_lower_packed_ubo_loads);
NIR_PASS_V(nir, d3d12_lower_load_first_vertex);
NIR_PASS_V(nir, d3d12_lower_state_vars, shader);
NIR_PASS_V(nir, d3d12_lower_bool_input);
NIR_PASS_V(nir, dxil_nir_lower_bool_input);
struct nir_to_dxil_options opts = {};
opts.interpolate_at_vertex = screen->have_load_at_vertex;
@@ -542,54 +542,6 @@ d3d12_lower_state_vars(nir_shader *nir, struct d3d12_shader *shader)
return progress;
}
static bool
lower_bool_input_filter(const nir_instr *instr,
UNUSED const void *_options)
{
if (instr->type != nir_instr_type_intrinsic)
return false;
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if (intr->intrinsic == nir_intrinsic_load_front_face)
return true;
if (intr->intrinsic == nir_intrinsic_load_deref) {
nir_deref_instr *deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
nir_variable *var = nir_deref_instr_get_variable(deref);
return var->data.mode == nir_var_shader_in &&
glsl_get_base_type(var->type) == GLSL_TYPE_BOOL;
}
return false;
}
static nir_ssa_def *
lower_bool_input_impl(nir_builder *b, nir_instr *instr,
UNUSED void *_options)
{
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if (intr->intrinsic == nir_intrinsic_load_deref) {
nir_deref_instr *deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
nir_variable *var = nir_deref_instr_get_variable(deref);
/* rewrite var->type */
var->type = glsl_vector_type(GLSL_TYPE_UINT,
glsl_get_vector_elements(var->type));
deref->type = var->type;
}
intr->dest.ssa.bit_size = 32;
return nir_i2b1(b, &intr->dest.ssa);
}
bool
d3d12_lower_bool_input(struct nir_shader *s)
{
return nir_shader_lower_instructions(s, lower_bool_input_filter,
lower_bool_input_impl, NULL);
}
void
d3d12_add_missing_dual_src_target(struct nir_shader *s,
unsigned missing_mask)
@@ -54,9 +54,6 @@ d3d12_lower_depth_range(nir_shader *nir);
bool
d3d12_lower_load_first_vertex(nir_shader *nir);
bool
d3d12_lower_bool_input(struct nir_shader *s);
void
d3d12_lower_uint_cast(nir_shader *nir, bool is_signed);
+48
View File
@@ -1466,6 +1466,54 @@ dxil_nir_create_bare_samplers(nir_shader *nir)
}
static bool
lower_bool_input_filter(const nir_instr *instr,
UNUSED const void *_options)
{
if (instr->type != nir_instr_type_intrinsic)
return false;
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if (intr->intrinsic == nir_intrinsic_load_front_face)
return true;
if (intr->intrinsic == nir_intrinsic_load_deref) {
nir_deref_instr *deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
nir_variable *var = nir_deref_instr_get_variable(deref);
return var->data.mode == nir_var_shader_in &&
glsl_get_base_type(var->type) == GLSL_TYPE_BOOL;
}
return false;
}
static nir_ssa_def *
lower_bool_input_impl(nir_builder *b, nir_instr *instr,
UNUSED void *_options)
{
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if (intr->intrinsic == nir_intrinsic_load_deref) {
nir_deref_instr *deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
nir_variable *var = nir_deref_instr_get_variable(deref);
/* rewrite var->type */
var->type = glsl_vector_type(GLSL_TYPE_UINT,
glsl_get_vector_elements(var->type));
deref->type = var->type;
}
intr->dest.ssa.bit_size = 32;
return nir_i2b1(b, &intr->dest.ssa);
}
bool
dxil_nir_lower_bool_input(struct nir_shader *s)
{
return nir_shader_lower_instructions(s, lower_bool_input_filter,
lower_bool_input_impl, NULL);
}
/* Comparison function to sort io values so that first come normal varyings,
* then system values, and then system generated values.
*/
+1
View File
@@ -50,6 +50,7 @@ bool dxil_nir_lower_system_values_to_zero(nir_shader *shader,
gl_system_value* system_value,
uint32_t count);
bool dxil_nir_create_bare_samplers(nir_shader *shader);
bool dxil_nir_lower_bool_input(struct nir_shader *s);
nir_ssa_def *
build_load_ubo_dxil(nir_builder *b, nir_ssa_def *buffer,