nir: Drop "SSA" from NIR language
Everything is SSA now.
sed -e 's/nir_ssa_def/nir_def/g' \
-e 's/nir_ssa_undef/nir_undef/g' \
-e 's/nir_ssa_scalar/nir_scalar/g' \
-e 's/nir_src_rewrite_ssa/nir_src_rewrite/g' \
-e 's/nir_gather_ssa_types/nir_gather_types/g' \
-i $(git grep -l nir | grep -v relnotes)
git mv src/compiler/nir/nir_gather_ssa_types.c \
src/compiler/nir/nir_gather_types.c
ninja -C build/ clang-format
cd src/compiler/nir && find *.c *.h -type f -exec clang-format -i \{} \;
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Acked-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24585>
This commit is contained in:
@@ -310,7 +310,7 @@ ntq_add_pending_tmu_flush(struct v3d_compile *c,
|
||||
|
||||
nir_intrinsic_instr *store = nir_store_reg_for_def(&dest->ssa);
|
||||
if (store != NULL) {
|
||||
nir_ssa_def *reg = store->src[1].ssa;
|
||||
nir_def *reg = store->src[1].ssa;
|
||||
_mesa_set_add(c->tmu.outstanding_regs, reg);
|
||||
}
|
||||
}
|
||||
@@ -716,7 +716,7 @@ ntq_emit_tmu_general(struct v3d_compile *c, nir_intrinsic_instr *instr,
|
||||
}
|
||||
|
||||
static struct qreg *
|
||||
ntq_init_ssa_def(struct v3d_compile *c, nir_ssa_def *def)
|
||||
ntq_init_ssa_def(struct v3d_compile *c, nir_def *def)
|
||||
{
|
||||
struct qreg *qregs = ralloc_array(c->def_ht, struct qreg,
|
||||
def->num_components);
|
||||
@@ -789,7 +789,7 @@ ntq_store_dest(struct v3d_compile *c, nir_dest *dest, int chan,
|
||||
|
||||
qregs[chan] = result;
|
||||
} else {
|
||||
nir_ssa_def *reg = store->src[1].ssa;
|
||||
nir_def *reg = store->src[1].ssa;
|
||||
ASSERTED nir_intrinsic_instr *decl = nir_reg_get_decl(reg);
|
||||
assert(nir_intrinsic_base(store) == 0);
|
||||
assert(nir_intrinsic_num_array_elems(decl) == 0);
|
||||
@@ -858,7 +858,7 @@ ntq_get_src(struct v3d_compile *c, nir_src src, int i)
|
||||
entry = _mesa_hash_table_search(c->def_ht, src.ssa);
|
||||
}
|
||||
} else {
|
||||
nir_ssa_def *reg = load->src[0].ssa;
|
||||
nir_def *reg = load->src[0].ssa;
|
||||
ASSERTED nir_intrinsic_instr *decl = nir_reg_get_decl(reg);
|
||||
assert(nir_intrinsic_base(load) == 0);
|
||||
assert(nir_intrinsic_num_array_elems(decl) == 0);
|
||||
@@ -2471,7 +2471,7 @@ ntq_setup_registers(struct v3d_compile *c, nir_function_impl *impl)
|
||||
struct qreg *qregs = ralloc_array(c->def_ht, struct qreg,
|
||||
array_len * num_components);
|
||||
|
||||
nir_ssa_def *nir_reg = &decl->dest.ssa;
|
||||
nir_def *nir_reg = &decl->dest.ssa;
|
||||
_mesa_hash_table_insert(c->def_ht, nir_reg, qregs);
|
||||
|
||||
for (int i = 0; i < array_len * num_components; i++)
|
||||
|
||||
@@ -135,7 +135,7 @@ v3d33_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr)
|
||||
* instruction writes and how many the instruction could produce.
|
||||
*/
|
||||
p1_unpacked.return_words_of_texture_data =
|
||||
nir_ssa_def_components_read(&instr->dest.ssa);
|
||||
nir_def_components_read(&instr->dest.ssa);
|
||||
|
||||
uint32_t p0_packed;
|
||||
V3D33_TEXTURE_UNIFORM_PARAMETER_0_CFG_MODE1_pack(NULL,
|
||||
|
||||
@@ -253,15 +253,15 @@ v3d40_vir_emit_tex(struct v3d_compile *c, nir_tex_instr *instr)
|
||||
nir_intrinsic_instr *store = nir_store_reg_for_def(&instr->dest.ssa);
|
||||
if (store == NULL) {
|
||||
p0_unpacked.return_words_of_texture_data =
|
||||
nir_ssa_def_components_read(&instr->dest.ssa);
|
||||
nir_def_components_read(&instr->dest.ssa);
|
||||
} else {
|
||||
nir_ssa_def *reg = store->src[1].ssa;
|
||||
nir_def *reg = store->src[1].ssa;
|
||||
nir_intrinsic_instr *decl = nir_reg_get_decl(reg);
|
||||
unsigned reg_num_components =
|
||||
nir_intrinsic_num_components(decl);
|
||||
|
||||
/* For the non-ssa case we don't have a full equivalent to
|
||||
* nir_ssa_def_components_read. This is a problem for the 16
|
||||
* nir_def_components_read. This is a problem for the 16
|
||||
* bit case. nir_lower_tex will not change the destination as
|
||||
* nir_tex_instr_dest_size will still return 4. The driver is
|
||||
* just expected to not store on other channels, so we
|
||||
|
||||
@@ -622,7 +622,7 @@ struct v3d_compile {
|
||||
void *debug_output_data;
|
||||
|
||||
/**
|
||||
* Mapping from nir_register * or nir_ssa_def * to array of struct
|
||||
* Mapping from nir_register * or nir_def * to array of struct
|
||||
* qreg for the values.
|
||||
*/
|
||||
struct hash_table *def_ht;
|
||||
|
||||
@@ -60,14 +60,14 @@ v3d_gl_format_is_return_32(enum pipe_format format)
|
||||
/* Packs a 32-bit vector of colors in the range [0, (1 << bits[i]) - 1] to a
|
||||
* 32-bit SSA value, with as many channels as necessary to store all the bits
|
||||
*/
|
||||
static nir_ssa_def *
|
||||
pack_bits(nir_builder *b, nir_ssa_def *color, const unsigned *bits,
|
||||
static nir_def *
|
||||
pack_bits(nir_builder *b, nir_def *color, const unsigned *bits,
|
||||
int num_components, bool mask)
|
||||
{
|
||||
nir_ssa_def *results[4];
|
||||
nir_def *results[4];
|
||||
int offset = 0;
|
||||
for (int i = 0; i < num_components; i++) {
|
||||
nir_ssa_def *chan = nir_channel(b, color, i);
|
||||
nir_def *chan = nir_channel(b, color, i);
|
||||
|
||||
/* Channels being stored shouldn't cross a 32-bit boundary. */
|
||||
assert((offset & ~31) == ((offset + bits[i] - 1) & ~31));
|
||||
@@ -103,10 +103,10 @@ v3d_nir_lower_image_store(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *color = nir_trim_vector(b,
|
||||
nir_def *color = nir_trim_vector(b,
|
||||
nir_ssa_for_src(b, instr->src[3], 4),
|
||||
num_components);
|
||||
nir_ssa_def *formatted = NULL;
|
||||
nir_def *formatted = NULL;
|
||||
|
||||
if (format == PIPE_FORMAT_R11G11B10_FLOAT) {
|
||||
formatted = nir_format_pack_11f11f10f(b, color);
|
||||
@@ -182,14 +182,14 @@ v3d_nir_lower_image_load(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
|
||||
b->cursor = nir_after_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *result = &instr->dest.ssa;
|
||||
nir_def *result = &instr->dest.ssa;
|
||||
if (util_format_is_pure_uint(format)) {
|
||||
result = nir_format_unpack_uint(b, result, bits16, 4);
|
||||
} else if (util_format_is_pure_sint(format)) {
|
||||
result = nir_format_unpack_sint(b, result, bits16, 4);
|
||||
} else {
|
||||
nir_ssa_def *rg = nir_channel(b, result, 0);
|
||||
nir_ssa_def *ba = nir_channel(b, result, 1);
|
||||
nir_def *rg = nir_channel(b, result, 0);
|
||||
nir_def *ba = nir_channel(b, result, 1);
|
||||
result = nir_vec4(b,
|
||||
nir_unpack_half_2x16_split_x(b, rg),
|
||||
nir_unpack_half_2x16_split_y(b, rg),
|
||||
@@ -197,7 +197,7 @@ v3d_nir_lower_image_load(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
nir_unpack_half_2x16_split_y(b, ba));
|
||||
}
|
||||
|
||||
nir_ssa_def_rewrite_uses_after(&instr->dest.ssa, result,
|
||||
nir_def_rewrite_uses_after(&instr->dest.ssa, result,
|
||||
result->parent_instr);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -62,7 +62,7 @@ struct v3d_nir_lower_io_state {
|
||||
|
||||
BITSET_WORD varyings_stored[BITSET_WORDS(V3D_MAX_ANY_STAGE_INPUTS)];
|
||||
|
||||
nir_ssa_def *pos[4];
|
||||
nir_def *pos[4];
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -70,8 +70,8 @@ v3d_nir_emit_ff_vpm_outputs(struct v3d_compile *c, nir_builder *b,
|
||||
struct v3d_nir_lower_io_state *state);
|
||||
|
||||
static void
|
||||
v3d_nir_store_output(nir_builder *b, int base, nir_ssa_def *offset,
|
||||
nir_ssa_def *chan)
|
||||
v3d_nir_store_output(nir_builder *b, int base, nir_def *offset,
|
||||
nir_def *chan)
|
||||
{
|
||||
if (offset) {
|
||||
/* When generating the VIR instruction, the base and the offset
|
||||
@@ -134,13 +134,13 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
|
||||
/* If this is a geometry shader we need to emit our outputs
|
||||
* to the current vertex offset in the VPM.
|
||||
*/
|
||||
nir_ssa_def *offset_reg =
|
||||
nir_def *offset_reg =
|
||||
c->s->info.stage == MESA_SHADER_GEOMETRY ?
|
||||
nir_load_var(b, state->gs.output_offset_var) : NULL;
|
||||
|
||||
int start_comp = nir_intrinsic_component(intr);
|
||||
unsigned location = nir_intrinsic_io_semantics(intr).location;
|
||||
nir_ssa_def *src = nir_ssa_for_src(b, intr->src[0],
|
||||
nir_def *src = nir_ssa_for_src(b, intr->src[0],
|
||||
intr->num_components);
|
||||
/* Save off the components of the position for the setup of VPM inputs
|
||||
* read by fixed function HW.
|
||||
@@ -159,7 +159,7 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
|
||||
|
||||
if (location == VARYING_SLOT_LAYER) {
|
||||
assert(c->s->info.stage == MESA_SHADER_GEOMETRY);
|
||||
nir_ssa_def *header = nir_load_var(b, state->gs.header_var);
|
||||
nir_def *header = nir_load_var(b, state->gs.header_var);
|
||||
header = nir_iand_imm(b, header, 0xff00ffff);
|
||||
|
||||
/* From the GLES 3.2 spec:
|
||||
@@ -180,9 +180,9 @@ v3d_nir_lower_vpm_output(struct v3d_compile *c, nir_builder *b,
|
||||
* to 0 in that case (we always allocate tile state for at
|
||||
* least one layer).
|
||||
*/
|
||||
nir_ssa_def *fb_layers = nir_load_fb_layers_v3d(b, 32);
|
||||
nir_ssa_def *cond = nir_ige(b, src, fb_layers);
|
||||
nir_ssa_def *layer_id =
|
||||
nir_def *fb_layers = nir_load_fb_layers_v3d(b, 32);
|
||||
nir_def *cond = nir_ige(b, src, fb_layers);
|
||||
nir_def *layer_id =
|
||||
nir_bcsel(b, cond,
|
||||
nir_imm_int(b, 0),
|
||||
nir_ishl_imm(b, src, 16));
|
||||
@@ -238,9 +238,9 @@ v3d_nir_lower_emit_vertex(struct v3d_compile *c, nir_builder *b,
|
||||
{
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *header = nir_load_var(b, state->gs.header_var);
|
||||
nir_ssa_def *header_offset = nir_load_var(b, state->gs.header_offset_var);
|
||||
nir_ssa_def *output_offset = nir_load_var(b, state->gs.output_offset_var);
|
||||
nir_def *header = nir_load_var(b, state->gs.header_var);
|
||||
nir_def *header_offset = nir_load_var(b, state->gs.header_offset_var);
|
||||
nir_def *output_offset = nir_load_var(b, state->gs.output_offset_var);
|
||||
|
||||
/* Emit fixed function outputs */
|
||||
v3d_nir_emit_ff_vpm_outputs(c, b, state);
|
||||
@@ -476,16 +476,16 @@ v3d_nir_emit_ff_vpm_outputs(struct v3d_compile *c, nir_builder *b,
|
||||
/* If this is a geometry shader we need to emit our fixed function
|
||||
* outputs to the current vertex offset in the VPM.
|
||||
*/
|
||||
nir_ssa_def *offset_reg =
|
||||
nir_def *offset_reg =
|
||||
c->s->info.stage == MESA_SHADER_GEOMETRY ?
|
||||
nir_load_var(b, state->gs.output_offset_var) : NULL;
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (!state->pos[i])
|
||||
state->pos[i] = nir_ssa_undef(b, 1, 32);
|
||||
state->pos[i] = nir_undef(b, 1, 32);
|
||||
}
|
||||
|
||||
nir_ssa_def *rcp_wc = nir_frcp(b, state->pos[3]);
|
||||
nir_def *rcp_wc = nir_frcp(b, state->pos[3]);
|
||||
|
||||
if (state->pos_vpm_offset != -1) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@@ -496,8 +496,8 @@ v3d_nir_emit_ff_vpm_outputs(struct v3d_compile *c, nir_builder *b,
|
||||
|
||||
if (state->vp_vpm_offset != -1) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
nir_ssa_def *pos;
|
||||
nir_ssa_def *scale;
|
||||
nir_def *pos;
|
||||
nir_def *scale;
|
||||
pos = state->pos[i];
|
||||
if (i == 0)
|
||||
scale = nir_load_viewport_x_scale(b);
|
||||
@@ -523,7 +523,7 @@ v3d_nir_emit_ff_vpm_outputs(struct v3d_compile *c, nir_builder *b,
|
||||
}
|
||||
|
||||
if (state->zs_vpm_offset != -1) {
|
||||
nir_ssa_def *z = state->pos[2];
|
||||
nir_def *z = state->pos[2];
|
||||
z = nir_fmul(b, z, nir_load_viewport_z_scale(b));
|
||||
z = nir_fmul(b, z, rcp_wc);
|
||||
z = nir_fadd(b, z, nir_load_viewport_z_offset(b));
|
||||
@@ -599,11 +599,11 @@ emit_gs_vpm_output_header_prolog(struct v3d_compile *c, nir_builder *b,
|
||||
* offset variable by removing the one generic header slot that always
|
||||
* goes at the beginning of out header.
|
||||
*/
|
||||
nir_ssa_def *header_offset =
|
||||
nir_def *header_offset =
|
||||
nir_load_var(b, state->gs.header_offset_var);
|
||||
nir_ssa_def *vertex_count =
|
||||
nir_def *vertex_count =
|
||||
nir_iadd_imm(b, header_offset, -1);
|
||||
nir_ssa_def *header =
|
||||
nir_def *header =
|
||||
nir_ior_imm(b,
|
||||
nir_ishl_imm(b, vertex_count,
|
||||
VERTEX_COUNT_OFFSET),
|
||||
|
||||
@@ -42,11 +42,11 @@ lower_line_smooth_intrinsic(struct lower_line_smooth_state *state,
|
||||
{
|
||||
b->cursor = nir_before_instr(&intr->instr);
|
||||
|
||||
nir_ssa_def *one = nir_imm_float(b, 1.0f);
|
||||
nir_def *one = nir_imm_float(b, 1.0f);
|
||||
|
||||
nir_ssa_def *coverage = nir_load_var(b, state->coverage);
|
||||
nir_def *coverage = nir_load_var(b, state->coverage);
|
||||
|
||||
nir_ssa_def *new_val = nir_fmul(b, nir_vec4(b, one, one, one, coverage),
|
||||
nir_def *new_val = nir_fmul(b, nir_vec4(b, one, one, one, coverage),
|
||||
intr->src[0].ssa);
|
||||
|
||||
nir_instr_rewrite_src(&intr->instr,
|
||||
@@ -89,21 +89,21 @@ initialise_coverage_var(struct lower_line_smooth_state *state,
|
||||
{
|
||||
nir_builder b = nir_builder_at(nir_before_block(nir_start_block(impl)));
|
||||
|
||||
nir_ssa_def *line_width = nir_load_line_width(&b);
|
||||
nir_def *line_width = nir_load_line_width(&b);
|
||||
|
||||
nir_ssa_def *real_line_width = nir_load_aa_line_width(&b);
|
||||
nir_def *real_line_width = nir_load_aa_line_width(&b);
|
||||
|
||||
/* The line coord varies from 0.0 to 1.0 across the width of the line */
|
||||
nir_ssa_def *line_coord = nir_load_line_coord(&b);
|
||||
nir_def *line_coord = nir_load_line_coord(&b);
|
||||
|
||||
/* fabs(line_coord - 0.5) * real_line_width */
|
||||
nir_ssa_def *pixels_from_center =
|
||||
nir_def *pixels_from_center =
|
||||
nir_fmul(&b, real_line_width,
|
||||
nir_fabs(&b, nir_fsub(&b, line_coord,
|
||||
nir_imm_float(&b, 0.5f))));
|
||||
|
||||
/* 0.5 - 1/√2 * (pixels_from_center - line_width * 0.5) */
|
||||
nir_ssa_def *coverage =
|
||||
nir_def *coverage =
|
||||
nir_fsub(&b,
|
||||
nir_imm_float(&b, 0.5f),
|
||||
nir_fmul(&b,
|
||||
@@ -114,14 +114,14 @@ initialise_coverage_var(struct lower_line_smooth_state *state,
|
||||
0.5f))));
|
||||
|
||||
/* Discard fragments that aren’t covered at all by the line */
|
||||
nir_ssa_def *outside = nir_fle_imm(&b, coverage, 0.0f);
|
||||
nir_def *outside = nir_fle_imm(&b, coverage, 0.0f);
|
||||
|
||||
nir_discard_if(&b, outside);
|
||||
|
||||
/* Clamp to at most 1.0. If it was less than 0.0 then the fragment will
|
||||
* be discarded so we don’t need to handle that.
|
||||
*/
|
||||
nir_ssa_def *clamped = nir_fmin(&b, coverage, nir_imm_float(&b, 1.0f));
|
||||
nir_def *clamped = nir_fmin(&b, coverage, nir_imm_float(&b, 1.0f));
|
||||
|
||||
nir_store_var(&b, state->coverage, clamped, 0x1 /* writemask */);
|
||||
}
|
||||
|
||||
@@ -71,9 +71,9 @@ static nir_intrinsic_instr *
|
||||
init_scalar_intrinsic(nir_builder *b,
|
||||
nir_intrinsic_instr *intr,
|
||||
uint32_t component,
|
||||
nir_ssa_def *offset,
|
||||
nir_def *offset,
|
||||
uint32_t bit_size,
|
||||
nir_ssa_def **scalar_offset)
|
||||
nir_def **scalar_offset)
|
||||
{
|
||||
|
||||
nir_intrinsic_instr *new_intr =
|
||||
@@ -129,20 +129,20 @@ lower_load_bitsize(nir_builder *b,
|
||||
|
||||
/* For global 2x32 we ignore Y component because it must be zero */
|
||||
unsigned offset_idx = offset_src(intr->intrinsic);
|
||||
nir_ssa_def *offset = nir_ssa_for_src(b, intr->src[offset_idx], 1);
|
||||
nir_def *offset = nir_ssa_for_src(b, intr->src[offset_idx], 1);
|
||||
|
||||
/* Split vector store to multiple scalar loads */
|
||||
nir_ssa_def *dest_components[4] = { NULL };
|
||||
nir_def *dest_components[4] = { NULL };
|
||||
const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic];
|
||||
for (int component = 0; component < num_comp; component++) {
|
||||
nir_ssa_def *scalar_offset;
|
||||
nir_def *scalar_offset;
|
||||
nir_intrinsic_instr *new_intr =
|
||||
init_scalar_intrinsic(b, intr, component, offset,
|
||||
bit_size, &scalar_offset);
|
||||
|
||||
for (unsigned i = 0; i < info->num_srcs; i++) {
|
||||
if (i == offset_idx) {
|
||||
nir_ssa_def *final_offset;
|
||||
nir_def *final_offset;
|
||||
final_offset = intr->intrinsic != nir_intrinsic_load_global_2x32 ?
|
||||
scalar_offset :
|
||||
nir_vec2(b, scalar_offset,
|
||||
@@ -160,8 +160,8 @@ lower_load_bitsize(nir_builder *b,
|
||||
nir_builder_instr_insert(b, &new_intr->instr);
|
||||
}
|
||||
|
||||
nir_ssa_def *new_dst = nir_vec(b, dest_components, num_comp);
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa, new_dst);
|
||||
nir_def *new_dst = nir_vec(b, dest_components, num_comp);
|
||||
nir_def_rewrite_uses(&intr->dest.ssa, new_dst);
|
||||
|
||||
nir_instr_remove(&intr->instr);
|
||||
return true;
|
||||
@@ -181,13 +181,13 @@ lower_store_bitsize(nir_builder *b,
|
||||
if (nir_src_bit_size(intr->src[value_idx]) == 32)
|
||||
return false;
|
||||
|
||||
nir_ssa_def *value = nir_ssa_for_src(b, intr->src[value_idx], num_comp);
|
||||
nir_def *value = nir_ssa_for_src(b, intr->src[value_idx], num_comp);
|
||||
|
||||
b->cursor = nir_before_instr(&intr->instr);
|
||||
|
||||
/* For global 2x32 we ignore Y component because it must be zero */
|
||||
unsigned offset_idx = offset_src(intr->intrinsic);
|
||||
nir_ssa_def *offset = nir_ssa_for_src(b, intr->src[offset_idx], 1);
|
||||
nir_def *offset = nir_ssa_for_src(b, intr->src[offset_idx], 1);
|
||||
|
||||
/* Split vector store to multiple scalar stores */
|
||||
const nir_intrinsic_info *info = &nir_intrinsic_infos[intr->intrinsic];
|
||||
@@ -195,7 +195,7 @@ lower_store_bitsize(nir_builder *b,
|
||||
while (wrmask) {
|
||||
unsigned component = ffs(wrmask) - 1;
|
||||
|
||||
nir_ssa_def *scalar_offset;
|
||||
nir_def *scalar_offset;
|
||||
nir_intrinsic_instr *new_intr =
|
||||
init_scalar_intrinsic(b, intr, component, offset,
|
||||
value->bit_size, &scalar_offset);
|
||||
@@ -204,11 +204,11 @@ lower_store_bitsize(nir_builder *b,
|
||||
|
||||
for (unsigned i = 0; i < info->num_srcs; i++) {
|
||||
if (i == value_idx) {
|
||||
nir_ssa_def *scalar_value =
|
||||
nir_def *scalar_value =
|
||||
nir_channels(b, value, 1 << component);
|
||||
new_intr->src[i] = nir_src_for_ssa(scalar_value);
|
||||
} else if (i == offset_idx) {
|
||||
nir_ssa_def *final_offset;
|
||||
nir_def *final_offset;
|
||||
final_offset = intr->intrinsic != nir_intrinsic_store_global_2x32 ?
|
||||
scalar_offset :
|
||||
nir_vec2(b, scalar_offset,
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
#include "v3d_compiler.h"
|
||||
|
||||
|
||||
typedef nir_ssa_def *(*nir_pack_func)(nir_builder *b, nir_ssa_def *c);
|
||||
typedef nir_ssa_def *(*nir_unpack_func)(nir_builder *b, nir_ssa_def *c);
|
||||
typedef nir_def *(*nir_pack_func)(nir_builder *b, nir_def *c);
|
||||
typedef nir_def *(*nir_unpack_func)(nir_builder *b, nir_def *c);
|
||||
|
||||
static bool
|
||||
logicop_depends_on_dst_color(int logicop_func)
|
||||
@@ -53,9 +53,9 @@ logicop_depends_on_dst_color(int logicop_func)
|
||||
}
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_logicop(nir_builder *b, int logicop_func,
|
||||
nir_ssa_def *src, nir_ssa_def *dst)
|
||||
nir_def *src, nir_def *dst)
|
||||
{
|
||||
switch (logicop_func) {
|
||||
case PIPE_LOGICOP_CLEAR:
|
||||
@@ -96,8 +96,8 @@ v3d_logicop(nir_builder *b, int logicop_func,
|
||||
}
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
v3d_nir_get_swizzled_channel(nir_builder *b, nir_ssa_def **srcs, int swiz)
|
||||
static nir_def *
|
||||
v3d_nir_get_swizzled_channel(nir_builder *b, nir_def **srcs, int swiz)
|
||||
{
|
||||
switch (swiz) {
|
||||
default:
|
||||
@@ -116,48 +116,48 @@ v3d_nir_get_swizzled_channel(nir_builder *b, nir_ssa_def **srcs, int swiz)
|
||||
}
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
v3d_nir_swizzle_and_pack(nir_builder *b, nir_ssa_def **chans,
|
||||
static nir_def *
|
||||
v3d_nir_swizzle_and_pack(nir_builder *b, nir_def **chans,
|
||||
const uint8_t *swiz, nir_pack_func pack_func)
|
||||
{
|
||||
nir_ssa_def *c[4];
|
||||
nir_def *c[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
c[i] = v3d_nir_get_swizzled_channel(b, chans, swiz[i]);
|
||||
|
||||
return pack_func(b, nir_vec4(b, c[0], c[1], c[2], c[3]));
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
v3d_nir_unpack_and_swizzle(nir_builder *b, nir_ssa_def *packed,
|
||||
static nir_def *
|
||||
v3d_nir_unpack_and_swizzle(nir_builder *b, nir_def *packed,
|
||||
const uint8_t *swiz, nir_unpack_func unpack_func)
|
||||
{
|
||||
nir_ssa_def *unpacked = unpack_func(b, packed);
|
||||
nir_def *unpacked = unpack_func(b, packed);
|
||||
|
||||
nir_ssa_def *unpacked_chans[4];
|
||||
nir_def *unpacked_chans[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
unpacked_chans[i] = nir_channel(b, unpacked, i);
|
||||
|
||||
nir_ssa_def *c[4];
|
||||
nir_def *c[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
c[i] = v3d_nir_get_swizzled_channel(b, unpacked_chans, swiz[i]);
|
||||
|
||||
return nir_vec4(b, c[0], c[1], c[2], c[3]);
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
pack_unorm_rgb10a2(nir_builder *b, nir_ssa_def *c)
|
||||
static nir_def *
|
||||
pack_unorm_rgb10a2(nir_builder *b, nir_def *c)
|
||||
{
|
||||
static const unsigned bits[4] = { 10, 10, 10, 2 };
|
||||
nir_ssa_def *unorm = nir_format_float_to_unorm(b, c, bits);
|
||||
nir_def *unorm = nir_format_float_to_unorm(b, c, bits);
|
||||
|
||||
nir_ssa_def *chans[4];
|
||||
nir_def *chans[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
chans[i] = nir_channel(b, unorm, i);
|
||||
|
||||
nir_ssa_def *result = nir_mov(b, chans[0]);
|
||||
nir_def *result = nir_mov(b, chans[0]);
|
||||
int offset = bits[0];
|
||||
for (int i = 1; i < 4; i++) {
|
||||
nir_ssa_def *shifted_chan =
|
||||
nir_def *shifted_chan =
|
||||
nir_ishl_imm(b, chans[i], offset);
|
||||
result = nir_ior(b, result, shifted_chan);
|
||||
offset += bits[i];
|
||||
@@ -165,8 +165,8 @@ pack_unorm_rgb10a2(nir_builder *b, nir_ssa_def *c)
|
||||
return result;
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
unpack_unorm_rgb10a2(nir_builder *b, nir_ssa_def *c)
|
||||
static nir_def *
|
||||
unpack_unorm_rgb10a2(nir_builder *b, nir_def *c)
|
||||
{
|
||||
static const unsigned bits[4] = { 10, 10, 10, 2 };
|
||||
const unsigned masks[4] = { BITFIELD_MASK(bits[0]),
|
||||
@@ -174,9 +174,9 @@ unpack_unorm_rgb10a2(nir_builder *b, nir_ssa_def *c)
|
||||
BITFIELD_MASK(bits[2]),
|
||||
BITFIELD_MASK(bits[3]) };
|
||||
|
||||
nir_ssa_def *chans[4];
|
||||
nir_def *chans[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
nir_ssa_def *unorm = nir_iand_imm(b, c, masks[i]);
|
||||
nir_def *unorm = nir_iand_imm(b, c, masks[i]);
|
||||
chans[i] = nir_format_unorm_to_float(b, unorm, &bits[i]);
|
||||
c = nir_ushr_imm(b, c, bits[i]);
|
||||
}
|
||||
@@ -201,13 +201,13 @@ v3d_get_format_swizzle_for_rt(struct v3d_compile *c, int rt)
|
||||
}
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_nir_get_tlb_color(nir_builder *b, struct v3d_compile *c, int rt, int sample)
|
||||
{
|
||||
uint32_t num_components =
|
||||
util_format_get_nr_components(c->fs_key->color_fmt[rt].format);
|
||||
|
||||
nir_ssa_def *color[4];
|
||||
nir_def *color[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < num_components) {
|
||||
color[i] =
|
||||
@@ -222,17 +222,17 @@ v3d_nir_get_tlb_color(nir_builder *b, struct v3d_compile *c, int rt, int sample)
|
||||
return nir_vec4(b, color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_emit_logic_op_raw(struct v3d_compile *c, nir_builder *b,
|
||||
nir_ssa_def **src_chans, nir_ssa_def **dst_chans,
|
||||
nir_def **src_chans, nir_def **dst_chans,
|
||||
int rt, int sample)
|
||||
{
|
||||
const uint8_t *fmt_swz = v3d_get_format_swizzle_for_rt(c, rt);
|
||||
|
||||
nir_ssa_def *op_res[4];
|
||||
nir_def *op_res[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
nir_ssa_def *src = src_chans[i];
|
||||
nir_ssa_def *dst =
|
||||
nir_def *src = src_chans[i];
|
||||
nir_def *dst =
|
||||
v3d_nir_get_swizzled_channel(b, dst_chans, fmt_swz[i]);
|
||||
op_res[i] = v3d_logicop(b, c->fs_key->logicop_func, src, dst);
|
||||
|
||||
@@ -250,40 +250,40 @@ v3d_emit_logic_op_raw(struct v3d_compile *c, nir_builder *b,
|
||||
}
|
||||
}
|
||||
|
||||
nir_ssa_def *r[4];
|
||||
nir_def *r[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
r[i] = v3d_nir_get_swizzled_channel(b, op_res, fmt_swz[i]);
|
||||
|
||||
return nir_vec4(b, r[0], r[1], r[2], r[3]);
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_emit_logic_op_unorm(struct v3d_compile *c, nir_builder *b,
|
||||
nir_ssa_def **src_chans, nir_ssa_def **dst_chans,
|
||||
nir_def **src_chans, nir_def **dst_chans,
|
||||
int rt, int sample,
|
||||
nir_pack_func pack_func, nir_unpack_func unpack_func)
|
||||
{
|
||||
static const uint8_t src_swz[4] = { 0, 1, 2, 3 };
|
||||
nir_ssa_def *packed_src =
|
||||
nir_def *packed_src =
|
||||
v3d_nir_swizzle_and_pack(b, src_chans, src_swz, pack_func);
|
||||
|
||||
const uint8_t *fmt_swz = v3d_get_format_swizzle_for_rt(c, rt);
|
||||
nir_ssa_def *packed_dst =
|
||||
nir_def *packed_dst =
|
||||
v3d_nir_swizzle_and_pack(b, dst_chans, fmt_swz, pack_func);
|
||||
|
||||
nir_ssa_def *packed_result =
|
||||
nir_def *packed_result =
|
||||
v3d_logicop(b, c->fs_key->logicop_func, packed_src, packed_dst);
|
||||
|
||||
return v3d_nir_unpack_and_swizzle(b, packed_result, fmt_swz, unpack_func);
|
||||
}
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_nir_emit_logic_op(struct v3d_compile *c, nir_builder *b,
|
||||
nir_ssa_def *src, int rt, int sample)
|
||||
nir_def *src, int rt, int sample)
|
||||
{
|
||||
nir_ssa_def *dst = v3d_nir_get_tlb_color(b, c, rt, sample);
|
||||
nir_def *dst = v3d_nir_get_tlb_color(b, c, rt, sample);
|
||||
|
||||
nir_ssa_def *src_chans[4], *dst_chans[4];
|
||||
nir_def *src_chans[4], *dst_chans[4];
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
src_chans[i] = nir_channel(b, src, i);
|
||||
dst_chans[i] = nir_channel(b, dst, i);
|
||||
@@ -306,7 +306,7 @@ v3d_nir_emit_logic_op(struct v3d_compile *c, nir_builder *b,
|
||||
|
||||
static void
|
||||
v3d_emit_ms_output(nir_builder *b,
|
||||
nir_ssa_def *color, nir_src *offset,
|
||||
nir_def *color, nir_src *offset,
|
||||
nir_alu_type type, int rt, int sample)
|
||||
{
|
||||
nir_store_tlb_sample_color_v3d(b, color, nir_imm_int(b, rt), .base = sample, .component = 0, .src_type = type);
|
||||
@@ -318,7 +318,7 @@ v3d_nir_lower_logic_op_instr(struct v3d_compile *c,
|
||||
nir_intrinsic_instr *intr,
|
||||
int rt)
|
||||
{
|
||||
nir_ssa_def *frag_color = intr->src[0].ssa;
|
||||
nir_def *frag_color = intr->src[0].ssa;
|
||||
|
||||
|
||||
const int logic_op = c->fs_key->logicop_func;
|
||||
@@ -328,7 +328,7 @@ v3d_nir_lower_logic_op_instr(struct v3d_compile *c,
|
||||
nir_src *offset = &intr->src[1];
|
||||
nir_alu_type type = nir_intrinsic_src_type(intr);
|
||||
for (int i = 0; i < V3D_MAX_SAMPLES; i++) {
|
||||
nir_ssa_def *sample =
|
||||
nir_def *sample =
|
||||
v3d_nir_emit_logic_op(c, b, frag_color, rt, i);
|
||||
|
||||
v3d_emit_ms_output(b, sample, offset, type, rt, i);
|
||||
@@ -336,7 +336,7 @@ v3d_nir_lower_logic_op_instr(struct v3d_compile *c,
|
||||
|
||||
nir_instr_remove(&intr->instr);
|
||||
} else {
|
||||
nir_ssa_def *result =
|
||||
nir_def *result =
|
||||
v3d_nir_emit_logic_op(c, b, frag_color, rt, 0);
|
||||
|
||||
nir_instr_rewrite_src(&intr->instr, &intr->src[0],
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
* writemasks in the process.
|
||||
*/
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_nir_scratch_offset(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
{
|
||||
bool is_store = instr->intrinsic == nir_intrinsic_store_scratch;
|
||||
nir_ssa_def *offset = nir_ssa_for_src(b, instr->src[is_store ? 1 : 0], 1);
|
||||
nir_def *offset = nir_ssa_for_src(b, instr->src[is_store ? 1 : 0], 1);
|
||||
|
||||
assert(nir_intrinsic_align_mul(instr) >= 4);
|
||||
assert(nir_intrinsic_align_offset(instr) == 0);
|
||||
@@ -55,11 +55,11 @@ v3d_nir_lower_load_scratch(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
{
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *offset = v3d_nir_scratch_offset(b,instr);
|
||||
nir_def *offset = v3d_nir_scratch_offset(b,instr);
|
||||
|
||||
nir_ssa_def *chans[NIR_MAX_VEC_COMPONENTS];
|
||||
nir_def *chans[NIR_MAX_VEC_COMPONENTS];
|
||||
for (int i = 0; i < instr->num_components; i++) {
|
||||
nir_ssa_def *chan_offset =
|
||||
nir_def *chan_offset =
|
||||
nir_iadd_imm(b, offset, V3D_CHANNELS * i * 4);
|
||||
|
||||
nir_intrinsic_instr *chan_instr =
|
||||
@@ -77,8 +77,8 @@ v3d_nir_lower_load_scratch(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
chans[i] = &chan_instr->dest.ssa;
|
||||
}
|
||||
|
||||
nir_ssa_def *result = nir_vec(b, chans, instr->num_components);
|
||||
nir_ssa_def_rewrite_uses(&instr->dest.ssa, result);
|
||||
nir_def *result = nir_vec(b, chans, instr->num_components);
|
||||
nir_def_rewrite_uses(&instr->dest.ssa, result);
|
||||
nir_instr_remove(&instr->instr);
|
||||
}
|
||||
|
||||
@@ -87,15 +87,15 @@ v3d_nir_lower_store_scratch(nir_builder *b, nir_intrinsic_instr *instr)
|
||||
{
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *offset = v3d_nir_scratch_offset(b, instr);
|
||||
nir_ssa_def *value = nir_ssa_for_src(b, instr->src[0],
|
||||
nir_def *offset = v3d_nir_scratch_offset(b, instr);
|
||||
nir_def *value = nir_ssa_for_src(b, instr->src[0],
|
||||
instr->num_components);
|
||||
|
||||
for (int i = 0; i < instr->num_components; i++) {
|
||||
if (!(nir_intrinsic_write_mask(instr) & (1 << i)))
|
||||
continue;
|
||||
|
||||
nir_ssa_def *chan_offset =
|
||||
nir_def *chan_offset =
|
||||
nir_iadd_imm(b, offset, V3D_CHANNELS * i * 4);
|
||||
|
||||
nir_intrinsic_instr *chan_instr =
|
||||
|
||||
@@ -32,21 +32,21 @@
|
||||
* 2x2 quad.
|
||||
*/
|
||||
|
||||
static nir_ssa_def *
|
||||
static nir_def *
|
||||
v3d_nir_lower_txf_ms_instr(nir_builder *b, nir_instr *in_instr, void *data)
|
||||
{
|
||||
nir_tex_instr *instr = nir_instr_as_tex(in_instr);
|
||||
|
||||
b->cursor = nir_before_instr(&instr->instr);
|
||||
|
||||
nir_ssa_def *coord = nir_steal_tex_src(instr, nir_tex_src_coord);
|
||||
nir_ssa_def *sample = nir_steal_tex_src(instr, nir_tex_src_ms_index);
|
||||
nir_def *coord = nir_steal_tex_src(instr, nir_tex_src_coord);
|
||||
nir_def *sample = nir_steal_tex_src(instr, nir_tex_src_ms_index);
|
||||
|
||||
nir_ssa_def *one = nir_imm_int(b, 1);
|
||||
nir_ssa_def *x = nir_iadd(b,
|
||||
nir_def *one = nir_imm_int(b, 1);
|
||||
nir_def *x = nir_iadd(b,
|
||||
nir_ishl(b, nir_channel(b, coord, 0), one),
|
||||
nir_iand(b, sample, one));
|
||||
nir_ssa_def *y = nir_iadd(b,
|
||||
nir_def *y = nir_iadd(b,
|
||||
nir_ishl(b, nir_channel(b, coord, 1), one),
|
||||
nir_iand(b, nir_ushr(b, sample, one), one));
|
||||
if (instr->is_array)
|
||||
|
||||
@@ -1481,8 +1481,8 @@ lower_load_num_subgroups(struct v3d_compile *c,
|
||||
DIV_ROUND_UP(c->s->info.workgroup_size[0] *
|
||||
c->s->info.workgroup_size[1] *
|
||||
c->s->info.workgroup_size[2], V3D_CHANNELS);
|
||||
nir_ssa_def *result = nir_imm_int(b, num_subgroups);
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa, result);
|
||||
nir_def *result = nir_imm_int(b, num_subgroups);
|
||||
nir_def_rewrite_uses(&intr->dest.ssa, result);
|
||||
nir_instr_remove(&intr->instr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user