185
185
if (location == VARYING_SLOT_LAYER) {
186
186
assert(c->s->info.stage == MESA_SHADER_GEOMETRY);
187
187
nir_ssa_def *header = nir_load_var(b, state->gs.header_var);
188
header = nir_iand(b, header, nir_imm_int(b, 0xff00ffff));
188
header = nir_iand_imm(b, header, 0xff00ffff);
190
190
/* From the GLES 3.2 spec:
210
210
nir_ssa_def *layer_id =
211
211
nir_bcsel(b, cond,
212
212
nir_imm_int(b, 0),
213
nir_ishl(b, src, nir_imm_int(b, 16)));
213
nir_ishl_imm(b, src, 16));
214
214
header = nir_ior(b, header, layer_id);
215
215
nir_store_var(b, state->gs.header_var, header, 0x1);
218
218
/* Scalarize outputs if it hasn't happened already, since we want to
219
* schedule each VPM write individually. We can skip any outut
219
* schedule each VPM write individually. We can skip any output
220
220
* components not read by the FS.
222
222
for (int i = 0; i < intr->num_components; i++) {
224
224
v3d_varying_slot_vpm_offset(c, location, start_comp + i);
226
if (!(nir_intrinsic_write_mask(intr) & (1 << i)))
227
229
if (vpm_offset == -1)
274
276
/* Update VPM offset for next vertex output data and header */
276
nir_iadd(b, output_offset,
277
nir_imm_int(b, state->gs.output_vertex_data_size));
278
nir_iadd_imm(b, output_offset,
279
state->gs.output_vertex_data_size);
279
header_offset = nir_iadd(b, header_offset, nir_imm_int(b, 1));
281
header_offset = nir_iadd_imm(b, header_offset, 1);
281
283
/* Reset the New Primitive bit */
282
header = nir_iand(b, header, nir_imm_int(b, 0xfffffffe));
284
header = nir_iand_imm(b, header, 0xfffffffe);
284
286
nir_store_var(b, state->gs.output_offset_var, output_offset, 0x1);
285
287
nir_store_var(b, state->gs.header_offset_var, header_offset, 0x1);
373
375
if (c->fs_key->point_coord_upper_left && comp == 1)
374
result = nir_fsub(b, nir_imm_float(b, 1.0), result);
376
result = nir_fsub_imm(b, 1.0, result);
375
377
if (result != &intr->dest.ssa) {
376
378
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa,
679
681
* have a variable just to keep track of the number of vertices we
680
682
* emitted and instead we can just compute it here from the header
681
683
* offset variable by removing the one generic header slot that always
682
* goes at the begining of out header.
684
* goes at the beginning of out header.
684
686
nir_ssa_def *header_offset =
685
687
nir_load_var(b, state->gs.header_offset_var);
686
688
nir_ssa_def *vertex_count =
687
nir_isub(b, header_offset, nir_imm_int(b, 1));
689
nir_iadd_imm(b, header_offset, -1);
688
690
nir_ssa_def *header =
689
nir_ior(b, nir_imm_int(b, state->gs.output_header_size),
690
nir_ishl(b, vertex_count,
691
nir_imm_int(b, VERTEX_COUNT_OFFSET)));
692
nir_ishl_imm(b, vertex_count,
693
VERTEX_COUNT_OFFSET),
694
state->gs.output_header_size);
693
696
v3d_nir_store_output(b, 0, NULL, header);
713
716
unreachable("Unsupported shader stage");
716
nir_foreach_function(function, s) {
717
if (function->impl) {
719
nir_builder_init(&b, function->impl);
721
if (c->s->info.stage == MESA_SHADER_GEOMETRY)
722
emit_gs_prolog(c, &b, function->impl, &state);
724
nir_foreach_block(block, function->impl) {
725
nir_foreach_instr_safe(instr, block)
726
v3d_nir_lower_io_instr(c, &b, instr,
730
nir_block *last = nir_impl_last_block(function->impl);
731
b.cursor = nir_after_block(last);
732
if (s->info.stage == MESA_SHADER_VERTEX) {
733
v3d_nir_emit_ff_vpm_outputs(c, &b, &state);
734
} else if (s->info.stage == MESA_SHADER_GEOMETRY) {
735
emit_gs_vpm_output_header_prolog(c, &b, &state);
738
nir_metadata_preserve(function->impl,
739
nir_metadata_block_index |
740
nir_metadata_dominance);
719
nir_foreach_function_impl(impl, s) {
720
nir_builder b = nir_builder_create(impl);
722
if (c->s->info.stage == MESA_SHADER_GEOMETRY)
723
emit_gs_prolog(c, &b, impl, &state);
725
nir_foreach_block(block, impl) {
726
nir_foreach_instr_safe(instr, block)
727
v3d_nir_lower_io_instr(c, &b, instr,
731
nir_block *last = nir_impl_last_block(impl);
732
b.cursor = nir_after_block(last);
733
if (s->info.stage == MESA_SHADER_VERTEX) {
734
v3d_nir_emit_ff_vpm_outputs(c, &b, &state);
735
} else if (s->info.stage == MESA_SHADER_GEOMETRY) {
736
emit_gs_vpm_output_header_prolog(c, &b, &state);
739
nir_metadata_preserve(impl,
740
nir_metadata_block_index |
741
nir_metadata_dominance);
744
744
if (s->info.stage == MESA_SHADER_VERTEX ||