diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 7d72fe924a7..f875d290800 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6449,6 +6449,7 @@ typedef struct nir_input_attachment_options { bool use_fragcoord_sysval; bool use_layer_id_sysval; bool use_view_id_for_layer; + bool unscaled_depth_stencil_ir3; uint32_t unscaled_input_attachment_ir3; } nir_input_attachment_options; diff --git a/src/compiler/nir/nir_lower_input_attachments.c b/src/compiler/nir/nir_lower_input_attachments.c index 44b02a75646..ab072d9e12d 100644 --- a/src/compiler/nir/nir_lower_input_attachments.c +++ b/src/compiler/nir/nir_lower_input_attachments.c @@ -30,18 +30,22 @@ load_frag_coord(nir_builder *b, nir_deref_instr *deref, { if (options->use_fragcoord_sysval) { nir_def *frag_coord = nir_load_frag_coord(b); - if (options->unscaled_input_attachment_ir3) { + if (options->unscaled_input_attachment_ir3 || + options->unscaled_depth_stencil_ir3) { nir_variable *var = nir_deref_instr_get_variable(deref); unsigned base = var->data.index; nir_def *unscaled_frag_coord = nir_load_frag_coord_unscaled_ir3(b); - if (deref->deref_type == nir_deref_type_array) { + if (deref->deref_type == nir_deref_type_array && + options->unscaled_input_attachment_ir3) { nir_def *unscaled = nir_i2b(b, nir_iand(b, nir_ishr(b, nir_imm_int(b, options->unscaled_input_attachment_ir3 >> base), deref->arr.index.ssa), nir_imm_int(b, 1))); frag_coord = nir_bcsel(b, unscaled, unscaled_frag_coord, frag_coord); } else { assert(deref->deref_type == nir_deref_type_var); - bool unscaled = (options->unscaled_input_attachment_ir3 >> base) & 1; + bool unscaled = base == NIR_VARIABLE_NO_INDEX ? + options->unscaled_depth_stencil_ir3 : + ((options->unscaled_input_attachment_ir3 >> base) & 1); frag_coord = unscaled ? unscaled_frag_coord : frag_coord; } }