mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 07:08:04 +02:00
nak: Turn nak_const_offsets into a function.
Reviewed-by: Mary Guillemard <mary@mary.zone> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40639>
This commit is contained in:
parent
7fc8fdbdaf
commit
017bb885db
5 changed files with 33 additions and 20 deletions
|
|
@ -91,7 +91,7 @@ struct nak_constant_offset_info {
|
|||
*/
|
||||
uint32_t printf_buffer_offset;
|
||||
};
|
||||
const extern struct nak_constant_offset_info nak_const_offsets;
|
||||
const extern struct nak_constant_offset_info nak_const_offsets_base;
|
||||
|
||||
#define NAK_PRINTF_BUFFER_SIZE 0x40000
|
||||
|
||||
|
|
|
|||
|
|
@ -829,12 +829,13 @@ static bool
|
|||
nak_nir_lower_printf_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
|
||||
void *data)
|
||||
{
|
||||
const struct nak_compiler* nak = data;
|
||||
b->cursor = nir_before_instr(&intrin->instr);
|
||||
if (intrin->intrinsic == nir_intrinsic_load_printf_buffer_address) {
|
||||
nir_def *buffer_addr = nir_ldc_nv(
|
||||
b, 1, 64,
|
||||
nir_imm_int(b, 0),
|
||||
nir_imm_int(b, nak_const_offsets.printf_buffer_offset));
|
||||
nir_imm_int(b, nak_const_offsets(nak)->printf_buffer_offset));
|
||||
nir_def_replace(&intrin->def, buffer_addr);
|
||||
return true;
|
||||
} else if (intrin->intrinsic == nir_intrinsic_load_printf_buffer_size) {
|
||||
|
|
@ -847,10 +848,10 @@ nak_nir_lower_printf_intrin(nir_builder *b, nir_intrinsic_instr *intrin,
|
|||
}
|
||||
|
||||
static bool
|
||||
nak_nir_lower_printf(nir_shader *nir)
|
||||
nak_nir_lower_printf(nir_shader *nir, const struct nak_compiler* nak)
|
||||
{
|
||||
return nir_shader_intrinsics_pass(nir, nak_nir_lower_printf_intrin,
|
||||
nir_metadata_none, NULL);
|
||||
nir_metadata_none, (void*)nak);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -1378,7 +1379,7 @@ nak_postprocess_nir(nir_shader *nir,
|
|||
OPT(nir, nak_nir_remove_barriers);
|
||||
|
||||
if (NAK_CAN_PRINTF)
|
||||
OPT(nir, nak_nir_lower_printf);
|
||||
OPT(nir, nak_nir_lower_printf, nak);
|
||||
|
||||
/* Call divergence analysis regardless of sm version. */
|
||||
nir_divergence_analysis(nir);
|
||||
|
|
|
|||
|
|
@ -96,12 +96,13 @@ interp_fs_input(nir_builder *b, unsigned num_components, uint32_t addr,
|
|||
}
|
||||
|
||||
static nir_def *
|
||||
load_sample_pos_u4_at(nir_builder *b, nir_def *sample_id)
|
||||
load_sample_pos_u4_at(nir_builder *b, nir_def *sample_id,
|
||||
const struct nak_compiler* nak)
|
||||
{
|
||||
nir_def *loc = nir_ldc_nv(b, 1, 8,
|
||||
nir_imm_int(b, nak_const_offsets.sample_info_cb),
|
||||
nir_imm_int(b, nak_const_offsets(nak)->sample_info_cb),
|
||||
nir_iadd_imm(b, sample_id,
|
||||
nak_const_offsets.sample_locations_offset),
|
||||
nak_const_offsets(nak)->sample_locations_offset),
|
||||
.align_mul = 1, .align_offset = 0);
|
||||
|
||||
/* The rest of these calculations are in 32-bit */
|
||||
|
|
@ -112,36 +113,41 @@ load_sample_pos_u4_at(nir_builder *b, nir_def *sample_id)
|
|||
}
|
||||
|
||||
static nir_def *
|
||||
load_pass_sample_mask_at(nir_builder *b, nir_def *sample_id)
|
||||
load_pass_sample_mask_at(nir_builder *b, nir_def *sample_id,
|
||||
const struct nak_compiler* nak)
|
||||
{
|
||||
nir_def *offset =
|
||||
nir_imul_imm(b, sample_id, sizeof(struct nak_sample_mask));
|
||||
offset = nir_iadd_imm(b, offset, nak_const_offsets.sample_masks_offset);
|
||||
offset = nir_iadd_imm(b, offset,
|
||||
nak_const_offsets(nak)->sample_masks_offset);
|
||||
|
||||
return nir_ldc_nv(b, 1, 8 * sizeof(struct nak_sample_mask),
|
||||
nir_imm_int(b, nak_const_offsets.sample_info_cb), offset,
|
||||
nir_imm_int(b, nak_const_offsets(nak)->sample_info_cb),
|
||||
offset,
|
||||
.align_mul = sizeof(struct nak_sample_mask),
|
||||
.align_offset = 0);
|
||||
}
|
||||
|
||||
static nir_def *
|
||||
load_sample_pos_at(nir_builder *b, nir_def *sample_id)
|
||||
load_sample_pos_at(nir_builder *b, nir_def *sample_id,
|
||||
const struct nak_compiler* nak)
|
||||
{
|
||||
nir_def *loc_u4 = load_sample_pos_u4_at(b, sample_id);
|
||||
nir_def *loc_u4 = load_sample_pos_u4_at(b, sample_id, nak);
|
||||
nir_def *result = nir_fmul_imm(b, nir_i2f32(b, loc_u4), 1.0 / 16.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static nir_def *
|
||||
load_barycentric_offset(nir_builder *b, nir_intrinsic_instr *bary)
|
||||
load_barycentric_offset(nir_builder *b, nir_intrinsic_instr *bary,
|
||||
const struct nak_compiler* nak)
|
||||
{
|
||||
nir_def *offset_s12;
|
||||
|
||||
if (bary->intrinsic == nir_intrinsic_load_barycentric_coord_at_sample ||
|
||||
bary->intrinsic == nir_intrinsic_load_barycentric_at_sample) {
|
||||
nir_def *sample_id = bary->src[0].ssa;
|
||||
nir_def *offset_u4 = load_sample_pos_u4_at(b, sample_id);
|
||||
nir_def *offset_u4 = load_sample_pos_u4_at(b, sample_id, nak);
|
||||
/* The sample position we loaded is a u4 from the upper-left and the
|
||||
* sample position wanted by ipa.offset is s12
|
||||
*/
|
||||
|
|
@ -250,7 +256,7 @@ lower_fs_input_intrin(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
|||
case nir_intrinsic_load_barycentric_coord_at_sample:
|
||||
case nir_intrinsic_load_barycentric_coord_at_offset:
|
||||
interp_loc = NAK_INTERP_LOC_OFFSET;
|
||||
offset = load_barycentric_offset(b, intrin);
|
||||
offset = load_barycentric_offset(b, intrin, nak);
|
||||
break;
|
||||
case nir_intrinsic_load_barycentric_coord_centroid:
|
||||
case nir_intrinsic_load_barycentric_coord_sample:
|
||||
|
|
@ -290,7 +296,7 @@ lower_fs_input_intrin(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
|||
case nir_intrinsic_load_barycentric_at_offset:
|
||||
case nir_intrinsic_load_barycentric_at_sample: {
|
||||
interp_loc = NAK_INTERP_LOC_OFFSET;
|
||||
offset = load_barycentric_offset(b, bary);
|
||||
offset = load_barycentric_offset(b, bary, nak);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -339,7 +345,7 @@ lower_fs_input_intrin(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
|||
* that with the coverage mask.
|
||||
*/
|
||||
nir_def *sample = nir_load_sample_id(b);
|
||||
nir_def *mask = load_pass_sample_mask_at(b, sample);
|
||||
nir_def *mask = load_pass_sample_mask_at(b, sample, nak);
|
||||
mask = nir_iand(b, &intrin->def, nir_u2u32(b, mask));
|
||||
nir_def_rewrite_uses_after(&intrin->def, mask);
|
||||
|
||||
|
|
@ -353,7 +359,7 @@ lower_fs_input_intrin(nir_builder *b, nir_intrinsic_instr *intrin, void *data)
|
|||
break;
|
||||
|
||||
case nir_intrinsic_load_sample_pos:
|
||||
res = load_sample_pos_at(b, nir_load_sample_id(b));
|
||||
res = load_sample_pos_at(b, nir_load_sample_id(b), nak);
|
||||
break;
|
||||
|
||||
case nir_intrinsic_load_input_vertex: {
|
||||
|
|
|
|||
|
|
@ -343,6 +343,12 @@ enum nak_fs_out {
|
|||
|
||||
#define NAK_FS_OUT_COLOR(n) (NAK_FS_OUT_COLOR0 + (n) * 16)
|
||||
|
||||
static inline const struct nak_constant_offset_info*
|
||||
nak_const_offsets(const struct nak_compiler* nak)
|
||||
{
|
||||
return &nak_const_offsets_base;
|
||||
}
|
||||
|
||||
bool nak_nir_rematerialize_load_const(nir_shader *nir);
|
||||
bool nak_nir_mark_lcssa_invariants(nir_shader *nir);
|
||||
bool nak_nir_lower_non_uniform_ldcx(nir_shader *nir, const struct nak_compiler *nak);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#include "nv_push_clc397.h"
|
||||
#include "nv_push_clc797.h"
|
||||
|
||||
const struct nak_constant_offset_info nak_const_offsets = {
|
||||
const struct nak_constant_offset_info nak_const_offsets_base = {
|
||||
.sample_info_cb = 0,
|
||||
.sample_locations_offset = nvk_root_descriptor_offset(draw.sample_locations),
|
||||
.sample_masks_offset = nvk_root_descriptor_offset(draw.sample_masks),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue