nir_foreach_instr(instr, block) {
if (instr->type == nir_instr_type_intrinsic) {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
- if (intr->intrinsic == nir_intrinsic_load_deref) {
- nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
- if (deref->mode != nir_var_shader_in)
- continue;
-
- nir_variable *var = nir_deref_instr_get_variable(deref);
-
- if (var->data.location == VARYING_SLOT_POS) {
- /* gl_FragCoord should not have array/struct derefs: */
- assert(deref->deref_type == nir_deref_type_var);
- update_fragcoord(b, intr, for_sample_shading);
- progress = true;
- }
+ if (intr->intrinsic == nir_intrinsic_load_frag_coord) {
+ update_fragcoord(b, intr, for_sample_shading);
+ progress = true;
}
}
}
case PIPE_CAP_LOAD_CONSTBUF:
case PIPE_CAP_NIR_COMPACT_ARRAYS:
case PIPE_CAP_DRAW_PARAMETERS:
+ case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
case PIPE_CAP_COMPUTE_SHADER_DERIVATIVES:
case PIPE_CAP_INVALIDATE_BUFFER:
nir_variable *v_dst_offset;
nir_variable *v_src_inv_size;
- /* gl_FragCoord */
- nir_variable *frag_coord;
-
/* gl_FragColor */
nir_variable *color_out;
};
#undef LOAD_INPUT
- v->frag_coord = nir_variable_create(b->shader, nir_var_shader_in,
- glsl_vec4_type(), "gl_FragCoord");
- v->frag_coord->data.location = VARYING_SLOT_POS;
-
v->color_out = nir_variable_create(b->shader, nir_var_shader_out,
glsl_vec4_type(), "gl_FragColor");
v->color_out->data.location = FRAG_RESULT_COLOR;
const struct brw_blorp_blit_prog_key *key,
struct brw_blorp_blit_vars *v)
{
- nir_ssa_def *coord = nir_f2i32(b, nir_load_var(b, v->frag_coord));
+ nir_ssa_def *coord = nir_f2i32(b, nir_load_frag_coord(b));
/* Account for destination surface intratile offset
*
nir_ssa_def *color = nir_load_var(&b, v_color);
if (clear_rgb_as_red) {
- nir_variable *frag_coord =
- nir_variable_create(b.shader, nir_var_shader_in,
- glsl_vec4_type(), "gl_FragCoord");
- frag_coord->data.location = VARYING_SLOT_POS;
-
- nir_ssa_def *pos = nir_f2i32(&b, nir_load_var(&b, frag_coord));
+ nir_ssa_def *pos = nir_f2i32(&b, nir_load_frag_coord(&b));
nir_ssa_def *comp = nir_umod(&b, nir_channel(&b, pos, 0),
nir_imm_int(&b, 3));
nir_ssa_def *color_component =
/* Do an MCS fetch and check if it is equal to the magic clear value */
nir_ssa_def *mcs =
- blorp_nir_txf_ms_mcs(&b, nir_f2i32(&b, blorp_nir_frag_coord(&b)),
+ blorp_nir_txf_ms_mcs(&b, nir_f2i32(&b, nir_load_frag_coord(&b)),
nir_load_layer_id(&b));
nir_ssa_def *is_clear =
blorp_nir_mcs_is_clear_color(&b, mcs, blorp_key.num_samples);
b->shader->info.fs.origin_upper_left = true;
}
-static inline nir_ssa_def *
-blorp_nir_frag_coord(nir_builder *b)
-{
- nir_variable *frag_coord =
- nir_variable_create(b->shader, nir_var_shader_in,
- glsl_vec4_type(), "gl_FragCoord");
-
- frag_coord->data.location = VARYING_SLOT_POS;
-
- return nir_load_var(b, frag_coord);
-}
-
static inline nir_ssa_def *
blorp_nir_txf_ms_mcs(nir_builder *b, nir_ssa_def *xy_pos, nir_ssa_def *layer)
{
assert(devinfo->gen >= 6);
prog_data->uses_src_depth = prog_data->uses_src_w =
- (nir->info.inputs_read & (1 << VARYING_SLOT_POS)) != 0;
+ (nir->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD)) != 0;
prog_data->uses_sample_mask =
(nir->info.system_values_read & SYSTEM_BIT_SAMPLE_MASK_IN) != 0;
emit_shader_time_begin();
if (nir->info.inputs_read > 0 ||
+ (nir->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD)) ||
(nir->info.outputs_read > 0 && !wm_key->coherent_fb_fetch)) {
if (devinfo->gen < 6)
emit_interpolation_setup_gen4();
return true;
nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(src->parent_instr);
- if (intrin->intrinsic != nir_intrinsic_load_interpolated_input)
- return true;
-
- if (nir_intrinsic_base(intrin) != VARYING_SLOT_POS)
+ if (intrin->intrinsic != nir_intrinsic_load_frag_coord)
return true;
}
break;
}
- case nir_intrinsic_load_interpolated_input: {
- if (nir_intrinsic_base(instr) == VARYING_SLOT_POS) {
- emit_fragcoord_interpolation(dest);
- break;
- }
+ case nir_intrinsic_load_frag_coord:
+ emit_fragcoord_interpolation(dest);
+ break;
+ case nir_intrinsic_load_interpolated_input: {
assert(instr->src[0].ssa &&
instr->src[0].ssa->parent_instr->type == nir_instr_type_intrinsic);
nir_intrinsic_instr *bary_intrinsic =
payload.subspan_coord_reg[0] = reg++;
prog_data->uses_src_depth =
- (nir->info.inputs_read & (1 << VARYING_SLOT_POS)) != 0;
+ (nir->info.system_values_read & (1ull << SYSTEM_VALUE_FRAG_COORD)) != 0;
if (wm_iz_table[lookup].sd_present || prog_data->uses_src_depth ||
kill_stats_promoted_workaround) {
payload.source_depth_reg[0] = reg;
};
struct spirv_to_nir_options spirv_options = {
.lower_workgroup_access_to_offsets = true,
+ .frag_coord_is_sysval = true,
.caps = {
.demote_to_helper_invocation = true,
.derivative_group = true,
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
NIR_PASS_V(nir, nir_lower_wpos_center, pipeline->sample_shading_enable);
- NIR_PASS_V(nir, nir_lower_input_attachments, false);
+ NIR_PASS_V(nir, nir_lower_input_attachments, true);
}
NIR_PASS_V(nir, anv_nir_lower_ycbcr_textures, layout);
if (devinfo->gen >= 5 || devinfo->is_g4x)
ctx->Const.MaxClipPlanes = 8;
+ ctx->Const.GLSLFragCoordIsSysVal = true;
ctx->Const.GLSLTessLevelsAsInputs = true;
ctx->Const.PrimitiveRestartForPatches = true;
if (newFP == curFP)
brw->ctx.NewDriverState |= BRW_NEW_FRAGMENT_PROGRAM;
+ _mesa_program_fragment_position_to_sysval(&newFP->program);
newFP->id = get_new_program_id(brw->screen);
prog->nir = brw_create_nir(brw, NULL, prog, MESA_SHADER_FRAGMENT, true);