From: Nicolai Hähnle <nicolai.haeh...@amd.com>

Redundant with the recently added ac_llvm_context::chip_class.
---
 src/amd/common/ac_nir_to_llvm.c          | 21 ++++++++++-----------
 src/amd/common/ac_shader_abi.h           |  2 --
 src/gallium/drivers/radeonsi/si_shader.c |  2 --
 3 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c
index 217d1e67ae2..d7b6259fe8f 100644
--- a/src/amd/common/ac_nir_to_llvm.c
+++ b/src/amd/common/ac_nir_to_llvm.c
@@ -1926,21 +1926,21 @@ static LLVMValueRef cast_ptr(struct nir_to_llvm_context 
*ctx, LLVMValueRef ptr,
 }
 
 static LLVMValueRef
 get_buffer_size(struct ac_nir_context *ctx, LLVMValueRef descriptor, bool 
in_elements)
 {
        LLVMValueRef size =
                LLVMBuildExtractElement(ctx->ac.builder, descriptor,
                                        LLVMConstInt(ctx->ac.i32, 2, false), 
"");
 
        /* VI only */
-       if (ctx->abi->chip_class == VI && in_elements) {
+       if (ctx->ac.chip_class == VI && in_elements) {
                /* On VI, the descriptor contains the size in bytes,
                 * but TXQ must return the size in elements.
                 * The stride is always non-zero for resources using TXQ.
                 */
                LLVMValueRef stride =
                        LLVMBuildExtractElement(ctx->ac.builder, descriptor,
                                                LLVMConstInt(ctx->ac.i32, 1, 
false), "");
                stride = LLVMBuildLShr(ctx->ac.builder, stride,
                                       LLVMConstInt(ctx->ac.i32, 16, false), 
"");
                stride = LLVMBuildAnd(ctx->ac.builder, stride,
@@ -2132,21 +2132,21 @@ static LLVMValueRef build_tex_intrinsic(struct 
ac_nir_context *ctx,
                break;
        case nir_texop_lod:
                args->opcode = ac_image_get_lod;
                args->compare = false;
                args->offset = false;
                break;
        default:
                break;
        }
 
-       if (instr->op == nir_texop_tg4 && ctx->abi->chip_class <= VI) {
+       if (instr->op == nir_texop_tg4 && ctx->ac.chip_class <= VI) {
                enum glsl_base_type stype = 
glsl_get_sampler_result_type(instr->texture->var->type);
                if (stype == GLSL_TYPE_UINT || stype == GLSL_TYPE_INT) {
                        return radv_lower_gather4_integer(&ctx->ac, args, 
instr);
                }
        }
        return ac_build_image_opcode(&ctx->ac, args);
 }
 
 static LLVMValueRef visit_vulkan_resource_index(struct nir_to_llvm_context 
*ctx,
                                                 nir_intrinsic_instr *instr)
@@ -3259,21 +3259,21 @@ static LLVMValueRef get_image_coords(struct 
ac_nir_context *ctx,
        LLVMValueRef res;
        LLVMValueRef sample_index = llvm_extract_elem(&ctx->ac, get_src(ctx, 
instr->src[1]), 0);
 
        int count;
        enum glsl_sampler_dim dim = glsl_get_sampler_dim(type);
        bool is_array = glsl_sampler_type_is_array(type);
        bool add_frag_pos = (dim == GLSL_SAMPLER_DIM_SUBPASS ||
                             dim == GLSL_SAMPLER_DIM_SUBPASS_MS);
        bool is_ms = (dim == GLSL_SAMPLER_DIM_MS ||
                      dim == GLSL_SAMPLER_DIM_SUBPASS_MS);
-       bool gfx9_1d = ctx->abi->chip_class >= GFX9 && dim == 
GLSL_SAMPLER_DIM_1D;
+       bool gfx9_1d = ctx->ac.chip_class >= GFX9 && dim == GLSL_SAMPLER_DIM_1D;
        count = image_type_to_components_count(dim, is_array);
 
        if (is_ms) {
                LLVMValueRef fmask_load_address[3];
                int chan;
 
                fmask_load_address[0] = 
LLVMBuildExtractElement(ctx->ac.builder, src0, masks[0], "");
                fmask_load_address[1] = 
LLVMBuildExtractElement(ctx->ac.builder, src0, masks[1], "");
                if (is_array)
                        fmask_load_address[2] = 
LLVMBuildExtractElement(ctx->ac.builder, src0, masks[2], "");
@@ -3404,21 +3404,21 @@ static LLVMValueRef visit_image_load(struct 
ac_nir_context *ctx,
 static void visit_image_store(struct ac_nir_context *ctx,
                              nir_intrinsic_instr *instr)
 {
        LLVMValueRef params[8];
        char intrinsic_name[64];
        const nir_variable *var = instr->variables[0]->var;
        const struct glsl_type *type = glsl_without_array(var->type);
        LLVMValueRef i1false = LLVMConstInt(ctx->ac.i1, 0, false);
        LLVMValueRef i1true = LLVMConstInt(ctx->ac.i1, 1, false);
        LLVMValueRef glc = i1false;
-       bool force_glc = ctx->abi->chip_class == SI;
+       bool force_glc = ctx->ac.chip_class == SI;
        if (force_glc)
                glc = i1true;
 
        if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF) {
                params[0] = ac_to_float(&ctx->ac, get_src(ctx, instr->src[2])); 
/* data */
                params[1] = get_sampler_desc(ctx, instr->variables[0], 
AC_DESC_BUFFER, true, true);
                params[2] = LLVMBuildExtractElement(ctx->ac.builder, 
get_src(ctx, instr->src[0]),
                                                    ctx->ac.i32_0, ""); /* 
vindex */
                params[3] = ctx->ac.i32_0; /* voffset */
                params[4] = glc;  /* glc */
@@ -3569,21 +3569,21 @@ static LLVMValueRef visit_image_size(struct 
ac_nir_context *ctx,
 
        LLVMValueRef two = LLVMConstInt(ctx->ac.i32, 2, false);
 
        if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE &&
            glsl_sampler_type_is_array(type)) {
                LLVMValueRef six = LLVMConstInt(ctx->ac.i32, 6, false);
                LLVMValueRef z = LLVMBuildExtractElement(ctx->ac.builder, res, 
two, "");
                z = LLVMBuildSDiv(ctx->ac.builder, z, six, "");
                res = LLVMBuildInsertElement(ctx->ac.builder, res, z, two, "");
        }
-       if (ctx->abi->chip_class >= GFX9 &&
+       if (ctx->ac.chip_class >= GFX9 &&
            glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_1D &&
            glsl_sampler_type_is_array(type)) {
                LLVMValueRef layers = LLVMBuildExtractElement(ctx->ac.builder, 
res, two, "");
                res = LLVMBuildInsertElement(ctx->ac.builder, res, layers,
                                                ctx->ac.i32_1, "");
 
        }
        return res;
 }
 
@@ -4320,21 +4320,21 @@ static void set_tex_fetch_args(struct ac_llvm_context 
*ctx,
  *
  * VI:
  *   The ANISO_OVERRIDE sampler field enables this fix in TA.
  */
 static LLVMValueRef sici_fix_sampler_aniso(struct ac_nir_context *ctx,
                                            LLVMValueRef res, LLVMValueRef samp)
 {
        LLVMBuilderRef builder = ctx->ac.builder;
        LLVMValueRef img7, samp0;
 
-       if (ctx->abi->chip_class >= VI)
+       if (ctx->ac.chip_class >= VI)
                return samp;
 
        img7 = LLVMBuildExtractElement(builder, res,
                                       LLVMConstInt(ctx->ac.i32, 7, 0), "");
        samp0 = LLVMBuildExtractElement(builder, samp,
                                        LLVMConstInt(ctx->ac.i32, 0, 0), "");
        samp0 = LLVMBuildAnd(builder, samp0, img7, "");
        return LLVMBuildInsertElement(builder, samp, samp0,
                                      LLVMConstInt(ctx->ac.i32, 0, 0), "");
 }
@@ -4495,21 +4495,21 @@ static void visit_tex(struct ac_nir_context *ctx, 
nir_tex_instr *instr)
                LLVMValueRef z = ac_to_float(&ctx->ac,
                                             llvm_extract_elem(&ctx->ac, 
comparator, 0));
 
                /* TC-compatible HTILE promotes Z16 and Z24 to Z32_FLOAT,
                 * so the depth comparison value isn't clamped for Z16 and
                 * Z24 anymore. Do it manually here.
                 *
                 * It's unnecessary if the original texture format was
                 * Z32_FLOAT, but we don't know that here.
                 */
-               if (ctx->abi->chip_class == VI)
+               if (ctx->ac.chip_class == VI)
                        z = ac_build_clamp(&ctx->ac, z);
 
                address[count++] = z;
        }
 
        /* pack derivatives */
        if (ddx || ddy) {
                int num_src_deriv_channels, num_dest_deriv_channels;
                switch (instr->sampler_dim) {
                case GLSL_SAMPLER_DIM_3D:
@@ -4519,21 +4519,21 @@ static void visit_tex(struct ac_nir_context *ctx, 
nir_tex_instr *instr)
                        num_dest_deriv_channels = 3;
                        break;
                case GLSL_SAMPLER_DIM_2D:
                default:
                        num_src_deriv_channels = 2;
                        num_dest_deriv_channels = 2;
                        num_deriv_comp = 2;
                        break;
                case GLSL_SAMPLER_DIM_1D:
                        num_src_deriv_channels = 1;
-                       if (ctx->abi->chip_class >= GFX9) {
+                       if (ctx->ac.chip_class >= GFX9) {
                                num_dest_deriv_channels = 2;
                                num_deriv_comp = 2;
                        } else {
                                num_dest_deriv_channels = 1;
                                num_deriv_comp = 1;
                        }
                        break;
                }
 
                for (unsigned i = 0; i < num_src_deriv_channels; i++) {
@@ -4575,21 +4575,21 @@ static void visit_tex(struct ac_nir_context *ctx, 
nir_tex_instr *instr)
                if (instr->coord_components > 2) {
                        /* This seems like a bit of a hack - but it passes 
Vulkan CTS with it */
                        if (instr->sampler_dim != GLSL_SAMPLER_DIM_3D &&
                            instr->sampler_dim != GLSL_SAMPLER_DIM_CUBE &&
                            instr->op != nir_texop_txf) {
                                coords[2] = apply_round_slice(&ctx->ac, 
coords[2]);
                        }
                        address[count++] = coords[2];
                }
 
-               if (ctx->abi->chip_class >= GFX9) {
+               if (ctx->ac.chip_class >= GFX9) {
                        LLVMValueRef filler;
                        if (instr->op == nir_texop_txf)
                                filler = ctx->ac.i32_0;
                        else
                                filler = LLVMConstReal(ctx->ac.f32, 0.5);
 
                        if (instr->sampler_dim == GLSL_SAMPLER_DIM_1D) {
                                if (instr->is_array) {
                                        address[count] = address[count - 1];
                                        address[count - 1] = filler;
@@ -4687,21 +4687,21 @@ static void visit_tex(struct ac_nir_context *ctx, 
nir_tex_instr *instr)
                 instr->op != nir_texop_tg4)
                result = LLVMBuildExtractElement(ctx->ac.builder, result, 
ctx->ac.i32_0, "");
        else if (instr->op == nir_texop_txs &&
                 instr->sampler_dim == GLSL_SAMPLER_DIM_CUBE &&
                 instr->is_array) {
                LLVMValueRef two = LLVMConstInt(ctx->ac.i32, 2, false);
                LLVMValueRef six = LLVMConstInt(ctx->ac.i32, 6, false);
                LLVMValueRef z = LLVMBuildExtractElement(ctx->ac.builder, 
result, two, "");
                z = LLVMBuildSDiv(ctx->ac.builder, z, six, "");
                result = LLVMBuildInsertElement(ctx->ac.builder, result, z, 
two, "");
-       } else if (ctx->abi->chip_class >= GFX9 &&
+       } else if (ctx->ac.chip_class >= GFX9 &&
                   instr->op == nir_texop_txs &&
                   instr->sampler_dim == GLSL_SAMPLER_DIM_1D &&
                   instr->is_array) {
                LLVMValueRef two = LLVMConstInt(ctx->ac.i32, 2, false);
                LLVMValueRef layers = LLVMBuildExtractElement(ctx->ac.builder, 
result, two, "");
                result = LLVMBuildInsertElement(ctx->ac.builder, result, layers,
                                                ctx->ac.i32_1, "");
        } else if (instr->dest.ssa.num_components != 4)
                result = trim_vector(&ctx->ac, result, 
instr->dest.ssa.num_components);
 
@@ -6373,21 +6373,20 @@ LLVMModuleRef 
ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
        ac_setup_rings(&ctx);
 
        ctx.num_output_clips = nir->info.clip_distance_array_size;
        ctx.num_output_culls = nir->info.cull_distance_array_size;
 
        if (nir->stage == MESA_SHADER_FRAGMENT)
                handle_fs_inputs(&ctx, nir);
        else if(nir->stage == MESA_SHADER_VERTEX)
                handle_vs_inputs(&ctx, nir);
 
-       ctx.abi.chip_class = options->chip_class;
        ctx.abi.inputs = &ctx.inputs[0];
        ctx.abi.emit_outputs = handle_shader_outputs_post;
        ctx.abi.load_ssbo = radv_load_ssbo;
        ctx.abi.load_sampler_desc = radv_get_sampler_desc;
 
        nir_foreach_variable(variable, &nir->outputs)
                scan_shader_output_decl(&ctx, variable);
 
        ac_nir_translate(&ctx.ac, &ctx.abi, nir, &ctx);
 
diff --git a/src/amd/common/ac_shader_abi.h b/src/amd/common/ac_shader_abi.h
index c2dd1c3a806..5f296be0c1f 100644
--- a/src/amd/common/ac_shader_abi.h
+++ b/src/amd/common/ac_shader_abi.h
@@ -30,22 +30,20 @@ enum ac_descriptor_type {
        AC_DESC_IMAGE,
        AC_DESC_FMASK,
        AC_DESC_SAMPLER,
        AC_DESC_BUFFER,
 };
 
 /* Document the shader ABI during compilation. This is what allows radeonsi and
  * radv to share a compiler backend.
  */
 struct ac_shader_abi {
-       enum chip_class chip_class;
-
        LLVMValueRef base_vertex;
        LLVMValueRef start_instance;
        LLVMValueRef draw_id;
        LLVMValueRef vertex_id;
        LLVMValueRef instance_id;
        LLVMValueRef frag_pos[4];
        LLVMValueRef front_face;
        LLVMValueRef ancillary;
        LLVMValueRef sample_coverage;
 
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index aea199d3efd..8d7be16dc62 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -5548,22 +5548,20 @@ static void si_dump_shader_key(unsigned processor, 
const struct si_shader *shade
                fprintf(f, "  opt.clip_disable = %u\n", key->opt.clip_disable);
        }
 }
 
 static void si_init_shader_ctx(struct si_shader_context *ctx,
                               struct si_screen *sscreen,
                               LLVMTargetMachineRef tm)
 {
        struct lp_build_tgsi_context *bld_base;
 
-       ctx->abi.chip_class = sscreen->b.chip_class;
-
        si_llvm_context_init(ctx, sscreen, tm);
 
        bld_base = &ctx->bld_base;
        bld_base->emit_fetch_funcs[TGSI_FILE_CONSTANT] = fetch_constant;
 
        bld_base->op_actions[TGSI_OPCODE_INTERP_CENTROID] = interp_action;
        bld_base->op_actions[TGSI_OPCODE_INTERP_SAMPLE] = interp_action;
        bld_base->op_actions[TGSI_OPCODE_INTERP_OFFSET] = interp_action;
 
        bld_base->op_actions[TGSI_OPCODE_MEMBAR].emit = membar_emit;
-- 
2.11.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to