mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 04:38:03 +02:00
aco: use new common helpers for building buffer descriptors
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29268>
This commit is contained in:
parent
074f3cfe73
commit
3d6957268b
2 changed files with 37 additions and 47 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "aco_interface.h"
|
||||
#include "aco_ir.h"
|
||||
|
||||
#include "common/ac_descriptors.h"
|
||||
#include "common/ac_nir.h"
|
||||
#include "common/sid.h"
|
||||
|
||||
|
|
@ -4674,14 +4675,14 @@ const EmitLoadParameters scratch_flat_load_params{scratch_load_callback, false,
|
|||
Temp
|
||||
get_gfx6_global_rsrc(Builder& bld, Temp addr)
|
||||
{
|
||||
uint32_t rsrc_conf = S_008F0C_NUM_FORMAT(V_008F0C_BUF_NUM_FORMAT_FLOAT) |
|
||||
S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32);
|
||||
uint32_t desc[4];
|
||||
ac_build_raw_buffer_descriptor(bld.program->gfx_level, 0, 0xffffffff, desc);
|
||||
|
||||
if (addr.type() == RegType::vgpr)
|
||||
return bld.pseudo(aco_opcode::p_create_vector, bld.def(s4), Operand::zero(), Operand::zero(),
|
||||
Operand::c32(-1u), Operand::c32(rsrc_conf));
|
||||
return bld.pseudo(aco_opcode::p_create_vector, bld.def(s4), addr, Operand::c32(-1u),
|
||||
Operand::c32(rsrc_conf));
|
||||
Operand::c32(desc[2]), Operand::c32(desc[3]));
|
||||
return bld.pseudo(aco_opcode::p_create_vector, bld.def(s4), addr, Operand::c32(desc[2]),
|
||||
Operand::c32(desc[3]));
|
||||
}
|
||||
|
||||
Temp
|
||||
|
|
@ -5980,17 +5981,8 @@ visit_load_constant(isel_context* ctx, nir_intrinsic_instr* instr)
|
|||
|
||||
Builder bld(ctx->program, ctx->block);
|
||||
|
||||
uint32_t desc_type =
|
||||
S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) | S_008F0C_DST_SEL_Y(V_008F0C_SQ_SEL_Y) |
|
||||
S_008F0C_DST_SEL_Z(V_008F0C_SQ_SEL_Z) | S_008F0C_DST_SEL_W(V_008F0C_SQ_SEL_W);
|
||||
if (ctx->options->gfx_level >= GFX10) {
|
||||
desc_type |= S_008F0C_FORMAT_GFX10(V_008F0C_GFX10_FORMAT_32_FLOAT) |
|
||||
S_008F0C_OOB_SELECT(V_008F0C_OOB_SELECT_RAW) |
|
||||
S_008F0C_RESOURCE_LEVEL(ctx->options->gfx_level < GFX11);
|
||||
} else {
|
||||
desc_type |= S_008F0C_NUM_FORMAT(V_008F0C_BUF_NUM_FORMAT_FLOAT) |
|
||||
S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32);
|
||||
}
|
||||
uint32_t desc[4];
|
||||
ac_build_raw_buffer_descriptor(ctx->options->gfx_level, 0, 0, desc);
|
||||
|
||||
unsigned base = nir_intrinsic_base(instr);
|
||||
unsigned range = nir_intrinsic_range(instr);
|
||||
|
|
@ -6006,7 +5998,7 @@ visit_load_constant(isel_context* ctx, nir_intrinsic_instr* instr)
|
|||
bld.pseudo(aco_opcode::p_constaddr, bld.def(s2), bld.def(s1, scc),
|
||||
Operand::c32(ctx->constant_data_offset)),
|
||||
Operand::c32(MIN2(base + range, ctx->shader->constant_data_size)),
|
||||
Operand::c32(desc_type));
|
||||
Operand::c32(desc[3]));
|
||||
unsigned size = instr->def.bit_size / 8;
|
||||
// TODO: get alignment information for subdword constants
|
||||
load_buffer(ctx, instr->num_components, size, dst, rsrc, offset, size, 0);
|
||||
|
|
@ -7589,25 +7581,23 @@ get_scratch_resource(isel_context* ctx)
|
|||
bld.smem(aco_opcode::s_load_dwordx2, bld.def(s2), scratch_addr, Operand::zero());
|
||||
}
|
||||
|
||||
uint32_t rsrc_conf =
|
||||
S_008F0C_ADD_TID_ENABLE(1) | S_008F0C_INDEX_STRIDE(ctx->program->wave_size == 64 ? 3 : 2);
|
||||
|
||||
if (ctx->program->gfx_level >= GFX10) {
|
||||
rsrc_conf |= S_008F0C_FORMAT_GFX10(V_008F0C_GFX10_FORMAT_32_FLOAT) |
|
||||
S_008F0C_OOB_SELECT(V_008F0C_OOB_SELECT_RAW) |
|
||||
S_008F0C_RESOURCE_LEVEL(ctx->program->gfx_level < GFX11);
|
||||
} else if (ctx->program->gfx_level <=
|
||||
GFX7) { /* dfmt modifies stride on GFX8/GFX9 when ADD_TID_EN=1 */
|
||||
rsrc_conf |= S_008F0C_NUM_FORMAT(V_008F0C_BUF_NUM_FORMAT_FLOAT) |
|
||||
S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32);
|
||||
}
|
||||
struct ac_buffer_state ac_state = {0};
|
||||
uint32_t desc[4];
|
||||
|
||||
ac_state.size = 0xffffffff;
|
||||
ac_state.format = PIPE_FORMAT_R32_FLOAT;
|
||||
for (int i = 0; i < 4; i++)
|
||||
ac_state.swizzle[i] = PIPE_SWIZZLE_0;
|
||||
/* older generations need element size = 4 bytes. element size removed in GFX9 */
|
||||
if (ctx->program->gfx_level <= GFX8)
|
||||
rsrc_conf |= S_008F0C_ELEMENT_SIZE(1);
|
||||
ac_state.element_size = ctx->program->gfx_level <= GFX8 ? 1u : 0u;
|
||||
ac_state.index_stride = ctx->program->wave_size == 64 ? 3u : 2u;
|
||||
ac_state.add_tid = true;
|
||||
ac_state.gfx10_oob_select = V_008F0C_OOB_SELECT_RAW;
|
||||
|
||||
return bld.pseudo(aco_opcode::p_create_vector, bld.def(s4), scratch_addr, Operand::c32(-1u),
|
||||
Operand::c32(rsrc_conf));
|
||||
ac_build_buffer_descriptor(ctx->program->gfx_level, &ac_state, desc);
|
||||
|
||||
return bld.pseudo(aco_opcode::p_create_vector, bld.def(s4), scratch_addr, Operand::c32(desc[2]),
|
||||
Operand::c32(desc[3]));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "aco_ir.h"
|
||||
#include "aco_util.h"
|
||||
|
||||
#include "common/ac_descriptors.h"
|
||||
#include "common/sid.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
|
@ -1199,24 +1200,23 @@ load_scratch_resource(spill_ctx& ctx, Builder& bld, bool apply_scratch_offset)
|
|||
bld.pseudo(aco_opcode::p_create_vector, bld.def(s2), addr_lo, addr_hi);
|
||||
}
|
||||
|
||||
uint32_t rsrc_conf =
|
||||
S_008F0C_ADD_TID_ENABLE(1) | S_008F0C_INDEX_STRIDE(ctx.program->wave_size == 64 ? 3 : 2);
|
||||
struct ac_buffer_state ac_state = {0};
|
||||
uint32_t desc[4];
|
||||
|
||||
if (ctx.program->gfx_level >= GFX10) {
|
||||
rsrc_conf |= S_008F0C_FORMAT_GFX10(V_008F0C_GFX10_FORMAT_32_FLOAT) |
|
||||
S_008F0C_OOB_SELECT(V_008F0C_OOB_SELECT_RAW) |
|
||||
S_008F0C_RESOURCE_LEVEL(ctx.program->gfx_level < GFX11);
|
||||
} else if (ctx.program->gfx_level <= GFX7) {
|
||||
/* dfmt modifies stride on GFX8/GFX9 when ADD_TID_EN=1 */
|
||||
rsrc_conf |= S_008F0C_NUM_FORMAT(V_008F0C_BUF_NUM_FORMAT_FLOAT) |
|
||||
S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32);
|
||||
}
|
||||
ac_state.size = 0xffffffff;
|
||||
ac_state.format = PIPE_FORMAT_R32_FLOAT;
|
||||
for (int i = 0; i < 4; i++)
|
||||
ac_state.swizzle[i] = PIPE_SWIZZLE_0;
|
||||
/* older generations need element size = 4 bytes. element size removed in GFX9 */
|
||||
if (ctx.program->gfx_level <= GFX8)
|
||||
rsrc_conf |= S_008F0C_ELEMENT_SIZE(1);
|
||||
ac_state.element_size = ctx.program->gfx_level <= GFX8 ? 1u : 0u;
|
||||
ac_state.index_stride = ctx.program->wave_size == 64 ? 3u : 2u;
|
||||
ac_state.add_tid = true;
|
||||
ac_state.gfx10_oob_select = V_008F0C_OOB_SELECT_RAW;
|
||||
|
||||
ac_build_buffer_descriptor(ctx.program->gfx_level, &ac_state, desc);
|
||||
|
||||
return bld.pseudo(aco_opcode::p_create_vector, bld.def(s4), private_segment_buffer,
|
||||
Operand::c32(-1u), Operand::c32(rsrc_conf));
|
||||
Operand::c32(desc[2]), Operand::c32(desc[3]));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue