mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-30 20:50:09 +01:00
v3d: use intrinsic builders
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8295>
This commit is contained in:
parent
c0fe111d64
commit
66d51965af
3 changed files with 8 additions and 50 deletions
|
|
@ -73,31 +73,19 @@ static void
|
|||
v3d_nir_store_output(nir_builder *b, int base, nir_ssa_def *offset,
|
||||
nir_ssa_def *chan)
|
||||
{
|
||||
nir_intrinsic_instr *intr =
|
||||
nir_intrinsic_instr_create(b->shader,
|
||||
nir_intrinsic_store_output);
|
||||
nir_ssa_dest_init(&intr->instr, &intr->dest,
|
||||
1, intr->dest.ssa.bit_size, NULL);
|
||||
intr->num_components = 1;
|
||||
|
||||
intr->src[0] = nir_src_for_ssa(chan);
|
||||
if (offset) {
|
||||
/* When generating the VIR instruction, the base and the offset
|
||||
* are just going to get added together with an ADD instruction
|
||||
* so we might as well do the add here at the NIR level instead
|
||||
* and let the constant folding do its magic.
|
||||
*/
|
||||
intr->src[1] = nir_src_for_ssa(nir_iadd_imm(b, offset, base));
|
||||
offset = nir_iadd_imm(b, offset, base);
|
||||
base = 0;
|
||||
} else {
|
||||
intr->src[1] = nir_src_for_ssa(nir_imm_int(b, 0));
|
||||
offset = nir_imm_int(b, 0);
|
||||
}
|
||||
|
||||
nir_intrinsic_set_base(intr, base);
|
||||
nir_intrinsic_set_write_mask(intr, 0x1);
|
||||
nir_intrinsic_set_component(intr, 0);
|
||||
|
||||
nir_builder_instr_insert(b, &intr->instr);
|
||||
nir_store_output(b, chan, offset, .base = base, .write_mask = 0x1, .component = 0);
|
||||
}
|
||||
|
||||
/* Convert the uniform offset to bytes. If it happens to be a constant,
|
||||
|
|
@ -215,13 +203,7 @@ 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_intrinsic_instr *load =
|
||||
nir_intrinsic_instr_create(b->shader,
|
||||
nir_intrinsic_load_fb_layers_v3d);
|
||||
nir_ssa_dest_init(&load->instr, &load->dest, 1, 32, NULL);
|
||||
nir_builder_instr_insert(b, &load->instr);
|
||||
nir_ssa_def *fb_layers = &load->dest.ssa;
|
||||
|
||||
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_bcsel(b, cond,
|
||||
|
|
|
|||
|
|
@ -118,11 +118,7 @@ initialise_coverage_var(struct lower_line_smooth_state *state,
|
|||
/* Discard fragments that aren’t covered at all by the line */
|
||||
nir_ssa_def *outside = nir_fge(&b, nir_imm_float(&b, 0.0f), coverage);
|
||||
|
||||
nir_intrinsic_instr *discard =
|
||||
nir_intrinsic_instr_create(state->shader,
|
||||
nir_intrinsic_discard_if);
|
||||
discard->src[0] = nir_src_for_ssa(outside);
|
||||
nir_builder_instr_insert(&b, &discard->instr);
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -205,18 +205,8 @@ static nir_ssa_def *
|
|||
v3d_nir_get_tlb_color(nir_builder *b, int rt, int sample)
|
||||
{
|
||||
nir_ssa_def *color[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
nir_intrinsic_instr *load =
|
||||
nir_intrinsic_instr_create(b->shader,
|
||||
nir_intrinsic_load_tlb_color_v3d);
|
||||
load->num_components = 1;
|
||||
nir_intrinsic_set_base(load, sample);
|
||||
nir_intrinsic_set_component(load, i);
|
||||
load->src[0] = nir_src_for_ssa(nir_imm_int(b, rt));
|
||||
nir_ssa_dest_init(&load->instr, &load->dest, 1, 32, NULL);
|
||||
nir_builder_instr_insert(b, &load->instr);
|
||||
color[i] = &load->dest.ssa;
|
||||
}
|
||||
for (int i = 0; i < 4; i++)
|
||||
color[i] = nir_load_tlb_color_v3d(b, 1, 32, nir_imm_int(b, rt), .base = sample, .component = i);
|
||||
|
||||
return nir_vec4(b, color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
|
@ -295,17 +285,7 @@ v3d_emit_ms_output(struct v3d_compile *c, nir_builder *b,
|
|||
nir_ssa_def *color, nir_src *offset,
|
||||
nir_alu_type type, int rt, int sample)
|
||||
{
|
||||
|
||||
nir_intrinsic_instr *store =
|
||||
nir_intrinsic_instr_create(b->shader,
|
||||
nir_intrinsic_store_tlb_sample_color_v3d);
|
||||
store->num_components = 4;
|
||||
nir_intrinsic_set_base(store, sample);
|
||||
nir_intrinsic_set_component(store, 0);
|
||||
nir_intrinsic_set_src_type(store, type);
|
||||
store->src[0] = nir_src_for_ssa(color);
|
||||
store->src[1] = nir_src_for_ssa(nir_imm_int(b, rt));
|
||||
nir_builder_instr_insert(b, &store->instr);
|
||||
nir_store_tlb_sample_color_v3d(b, color, nir_imm_int(b, rt), .base = sample, .component = 0, .src_type = type);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue