Mesa (main): microsoft/compiler: Delete non-sysval deref load/store code
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Dec 20 16:44:24 UTC 2021
Module: Mesa
Branch: main
Commit: 8d5b7450a4fc250cf7be185e0ed1023584ce397a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d5b7450a4fc250cf7be185e0ed1023584ce397a
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Sat Dec 11 09:57:36 2021 -0800
microsoft/compiler: Delete non-sysval deref load/store code
Reviewed-by: Enrico Galli <enrico.galli at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14175>
---
src/microsoft/compiler/nir_to_dxil.c | 231 -----------------------------------
1 file changed, 231 deletions(-)
diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c
index e66bf26f189..319940a9409 100644
--- a/src/microsoft/compiler/nir_to_dxil.c
+++ b/src/microsoft/compiler/nir_to_dxil.c
@@ -2696,73 +2696,6 @@ emit_load_ubo_dxil(struct ntd_context *ctx, nir_intrinsic_instr *intr)
return true;
}
-static bool
-emit_store_output(struct ntd_context *ctx, nir_intrinsic_instr *intr,
- nir_variable *output)
-{
- nir_alu_type out_type = nir_get_nir_type_for_glsl_base_type(glsl_get_base_type(output->type));
- enum overload_type overload = DXIL_F32;
- if (output->data.compact)
- out_type = nir_type_float;
- else
- overload = get_overload(out_type, glsl_get_bit_size(output->type));
- const struct dxil_func *func = dxil_get_function(&ctx->mod, "dx.op.storeOutput", overload);
-
- if (!func)
- return false;
-
- const struct dxil_value *opcode = dxil_module_get_int32_const(&ctx->mod, DXIL_INTR_STORE_OUTPUT);
- const struct dxil_value *output_id = dxil_module_get_int32_const(&ctx->mod, (int)output->data.driver_location);
- const struct dxil_value *row = dxil_module_get_int32_const(&ctx->mod, 0);
-
- bool success = true;
- if (output->data.compact) {
- nir_deref_instr *array_deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
- unsigned array_index = nir_src_as_uint(array_deref->arr.index);
-
- const struct dxil_value *col = dxil_module_get_int8_const(&ctx->mod, array_index);
- const struct dxil_value *value = get_src(ctx, &intr->src[1], 0, out_type);
- if (!col || !value)
- return false;
-
- const struct dxil_value *args[] = {
- opcode, output_id, row, col, value
- };
- success = dxil_emit_call_void(&ctx->mod, func, args, ARRAY_SIZE(args));
- } else {
- uint32_t writemask = nir_intrinsic_write_mask(intr);
- for (unsigned i = 0; i < nir_src_num_components(intr->src[1]) && success; ++i) {
- if (writemask & (1 << i)) {
- const struct dxil_value *col = dxil_module_get_int8_const(&ctx->mod, i);
- const struct dxil_value *value = get_src(ctx, &intr->src[1], i, out_type);
- if (!col || !value)
- return false;
-
- const struct dxil_value *args[] = {
- opcode, output_id, row, col, value
- };
- success &= dxil_emit_call_void(&ctx->mod, func, args, ARRAY_SIZE(args));
- }
- }
- }
- return success;
-}
-
-static bool
-emit_store_deref(struct ntd_context *ctx, nir_intrinsic_instr *intr)
-{
- nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
- nir_variable *var = nir_deref_instr_get_variable(deref);
-
- switch (var->data.mode) {
- case nir_var_shader_out:
- return emit_store_output(ctx, intr, var);
-
- default:
- unreachable("unsupported nir_variable_mode");
- }
-}
-
static bool
emit_store_output_via_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
{
@@ -2795,100 +2728,6 @@ emit_store_output_via_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *in
return success;
}
-static bool
-emit_load_input_array(struct ntd_context *ctx, nir_intrinsic_instr *intr, nir_variable *var, nir_src *index)
-{
- assert(var);
- const struct dxil_value *opcode = dxil_module_get_int32_const(&ctx->mod, DXIL_INTR_LOAD_INPUT);
- const struct dxil_value *input_id = dxil_module_get_int32_const(&ctx->mod, var->data.driver_location);
- const struct dxil_value *vertex_id;
- const struct dxil_value *row;
-
- if (ctx->mod.shader_kind == DXIL_GEOMETRY_SHADER) {
- vertex_id = get_src(ctx, index, 0, nir_type_int);
- row = dxil_module_get_int32_const(&ctx->mod, 0);
- } else {
- const struct dxil_type *int32_type = dxil_module_get_int_type(&ctx->mod, 32);
- vertex_id = dxil_module_get_undef(&ctx->mod, int32_type);
- row = get_src(ctx, index, 0, nir_type_int);
- }
-
- if (!opcode || !input_id || !vertex_id || !row)
- return false;
-
- nir_alu_type out_type = nir_get_nir_type_for_glsl_base_type(glsl_get_base_type(glsl_get_array_element(var->type)));
- enum overload_type overload = get_overload(out_type, glsl_get_bit_size(glsl_get_array_element(var->type)));
-
- const struct dxil_func *func = dxil_get_function(&ctx->mod, "dx.op.loadInput", overload);
-
- if (!func)
- return false;
-
- for (unsigned i = 0; i < nir_dest_num_components(intr->dest); ++i) {
- const struct dxil_value *comp = dxil_module_get_int8_const(&ctx->mod, i);
- if (!comp)
- return false;
-
- const struct dxil_value *args[] = {
- opcode, input_id, row, comp, vertex_id
- };
-
- const struct dxil_value *retval = dxil_emit_call(&ctx->mod, func, args, ARRAY_SIZE(args));
- if (!retval)
- return false;
- store_dest(ctx, &intr->dest, i, retval, out_type);
- }
- return true;
-}
-
-static bool
-emit_load_compact_input_array(struct ntd_context *ctx, nir_intrinsic_instr *intr, nir_variable *var, nir_deref_instr *deref)
-{
- assert(var);
- const struct dxil_value *opcode = dxil_module_get_int32_const(&ctx->mod, DXIL_INTR_LOAD_INPUT);
- const struct dxil_value *input_id = dxil_module_get_int32_const(&ctx->mod, var->data.driver_location);
- const struct dxil_value *row = dxil_module_get_int32_const(&ctx->mod, 0);
- const struct dxil_value *vertex_id;
-
- nir_src *col = &deref->arr.index;
- nir_src_is_const(*col);
-
- if (ctx->mod.shader_kind == DXIL_GEOMETRY_SHADER) {
- nir_deref_instr *deref_parent = nir_deref_instr_parent(deref);
- assert(deref_parent->deref_type == nir_deref_type_array);
-
- vertex_id = get_src(ctx, &deref_parent->arr.index, 0, nir_type_int);
- } else {
- const struct dxil_type *int32_type = dxil_module_get_int_type(&ctx->mod, 32);
- vertex_id = dxil_module_get_undef(&ctx->mod, int32_type);
- }
-
- if (!opcode || !input_id || !row || !vertex_id)
- return false;
-
- nir_alu_type out_type = nir_type_float;
- enum overload_type overload = get_overload(out_type, 32);
-
- const struct dxil_func *func = dxil_get_function(&ctx->mod, "dx.op.loadInput", overload);
-
- if (!func)
- return false;
-
- const struct dxil_value *comp = dxil_module_get_int8_const(&ctx->mod, nir_src_as_int(*col));
- if (!comp)
- return false;
-
- const struct dxil_value *args[] = {
- opcode, input_id, row, comp, vertex_id
- };
-
- const struct dxil_value *retval = dxil_emit_call(&ctx->mod, func, args, ARRAY_SIZE(args));
- if (!retval)
- return false;
- store_dest(ctx, &intr->dest, 0, retval, out_type);
- return true;
-}
-
static bool
emit_load_input_interpolated(struct ntd_context *ctx, nir_intrinsic_instr *intr, nir_variable *var)
{
@@ -2925,50 +2764,6 @@ emit_load_input_interpolated(struct ntd_context *ctx, nir_intrinsic_instr *intr,
return true;
}
-static bool
-emit_load_input_flat(struct ntd_context *ctx, nir_intrinsic_instr *intr, nir_variable* var)
-{
- const struct dxil_value *opcode = dxil_module_get_int32_const(&ctx->mod, DXIL_INTR_ATTRIBUTE_AT_VERTEX);
- const struct dxil_value *input_id = dxil_module_get_int32_const(&ctx->mod, (int)var->data.driver_location);
- const struct dxil_value *row = dxil_module_get_int32_const(&ctx->mod, 0);
- const struct dxil_value *vertex_id = dxil_module_get_int8_const(&ctx->mod, ctx->opts->provoking_vertex);
-
- nir_alu_type out_type = nir_get_nir_type_for_glsl_base_type(glsl_get_base_type(var->type));
- enum overload_type overload = get_overload(out_type, glsl_get_bit_size(var->type));
-
- const struct dxil_func *func = dxil_get_function(&ctx->mod, "dx.op.attributeAtVertex", overload);
- if (!func)
- return false;
-
- for (unsigned i = 0; i < nir_dest_num_components(intr->dest); ++i) {
- const struct dxil_value *comp = dxil_module_get_int8_const(&ctx->mod, i);
- const struct dxil_value *args[] = {
- opcode, input_id, row, comp, vertex_id
- };
-
- const struct dxil_value *retval = dxil_emit_call(&ctx->mod, func, args, ARRAY_SIZE(args));
- if (!retval)
- return false;
-
- store_dest(ctx, &intr->dest, i, retval, out_type);
- }
- return true;
-}
-
-static bool
-emit_load_input(struct ntd_context *ctx, nir_intrinsic_instr *intr,
- nir_variable *input)
-{
- if (ctx->mod.shader_kind != DXIL_PIXEL_SHADER ||
- input->data.interpolation != INTERP_MODE_FLAT ||
- !ctx->opts->interpolate_at_vertex ||
- ctx->opts->provoking_vertex == 0 ||
- glsl_type_is_integer(input->type))
- return emit_load_input_interpolated(ctx, intr, input);
- else
- return emit_load_input_flat(ctx, intr, input);
-}
-
static bool
emit_load_input_via_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
{
@@ -3123,28 +2918,6 @@ emit_load_scratch(struct ntd_context *ctx, nir_intrinsic_instr *intr)
return true;
}
-static bool
-emit_load_deref(struct ntd_context *ctx, nir_intrinsic_instr *intr)
-{
- assert(intr->src[0].is_ssa);
- nir_deref_instr *deref = nir_instr_as_deref(intr->src[0].ssa->parent_instr);
- nir_variable *var = nir_deref_instr_get_variable(deref);
-
- switch (var->data.mode) {
- case nir_var_shader_in:
- if (glsl_type_is_array(var->type)) {
- if (var->data.compact)
- return emit_load_compact_input_array(ctx, intr, var, deref);
- else
- return emit_load_input_array(ctx, intr, var, &deref->arr.index);
- }
- return emit_load_input(ctx, intr, var);
-
- default:
- unreachable("unsupported nir_variable_mode");
- }
-}
-
static bool
emit_discard_if_with_value(struct ntd_context *ctx, const struct dxil_value *value)
{
@@ -3676,15 +3449,11 @@ emit_intrinsic(struct ntd_context *ctx, nir_intrinsic_instr *intr)
return emit_store_ssbo(ctx, intr);
case nir_intrinsic_store_ssbo_masked_dxil:
return emit_store_ssbo_masked(ctx, intr);
- case nir_intrinsic_store_deref:
- return emit_store_deref(ctx, intr);
case nir_intrinsic_store_shared_dxil:
case nir_intrinsic_store_shared_masked_dxil:
return emit_store_shared(ctx, intr);
case nir_intrinsic_store_scratch_dxil:
return emit_store_scratch(ctx, intr);
- case nir_intrinsic_load_deref:
- return emit_load_deref(ctx, intr);
case nir_intrinsic_load_ptr_dxil:
return emit_load_ptr(ctx, intr);
case nir_intrinsic_load_ubo:
More information about the mesa-commit
mailing list