mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
radeonsi: merge and simplify tbuffer_store functions
Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
b46e412c2e
commit
27439dfdae
4 changed files with 77 additions and 114 deletions
|
|
@ -543,21 +543,25 @@ ac_build_indexed_load_const(struct ac_llvm_context *ctx,
|
||||||
* or v4i32 (num_channels=3,4).
|
* or v4i32 (num_channels=3,4).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ac_build_tbuffer_store(struct ac_llvm_context *ctx,
|
ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
|
||||||
LLVMValueRef rsrc,
|
LLVMValueRef rsrc,
|
||||||
LLVMValueRef vdata,
|
LLVMValueRef vdata,
|
||||||
unsigned num_channels,
|
unsigned num_channels,
|
||||||
LLVMValueRef vaddr,
|
LLVMValueRef vaddr,
|
||||||
LLVMValueRef soffset,
|
LLVMValueRef soffset,
|
||||||
unsigned inst_offset,
|
unsigned inst_offset,
|
||||||
unsigned dfmt,
|
bool offen,
|
||||||
unsigned nfmt,
|
bool glc,
|
||||||
unsigned offen,
|
bool slc)
|
||||||
unsigned idxen,
|
|
||||||
unsigned glc,
|
|
||||||
unsigned slc,
|
|
||||||
unsigned tfe)
|
|
||||||
{
|
{
|
||||||
|
static unsigned dfmt[] = {
|
||||||
|
V_008F0C_BUF_DATA_FORMAT_32,
|
||||||
|
V_008F0C_BUF_DATA_FORMAT_32_32,
|
||||||
|
V_008F0C_BUF_DATA_FORMAT_32_32_32,
|
||||||
|
V_008F0C_BUF_DATA_FORMAT_32_32_32_32
|
||||||
|
};
|
||||||
|
assert(num_channels >= 1 && num_channels <= 4);
|
||||||
|
|
||||||
LLVMValueRef args[] = {
|
LLVMValueRef args[] = {
|
||||||
rsrc,
|
rsrc,
|
||||||
vdata,
|
vdata,
|
||||||
|
|
@ -565,13 +569,13 @@ ac_build_tbuffer_store(struct ac_llvm_context *ctx,
|
||||||
vaddr,
|
vaddr,
|
||||||
soffset,
|
soffset,
|
||||||
LLVMConstInt(ctx->i32, inst_offset, 0),
|
LLVMConstInt(ctx->i32, inst_offset, 0),
|
||||||
LLVMConstInt(ctx->i32, dfmt, 0),
|
LLVMConstInt(ctx->i32, dfmt[num_channels - 1], 0),
|
||||||
LLVMConstInt(ctx->i32, nfmt, 0),
|
LLVMConstInt(ctx->i32, V_008F0C_BUF_NUM_FORMAT_UINT, 0),
|
||||||
LLVMConstInt(ctx->i32, offen, 0),
|
LLVMConstInt(ctx->i32, offen, 0),
|
||||||
LLVMConstInt(ctx->i32, idxen, 0),
|
LLVMConstInt(ctx->i32, 0, 0), /* idxen */
|
||||||
LLVMConstInt(ctx->i32, glc, 0),
|
LLVMConstInt(ctx->i32, glc, 0),
|
||||||
LLVMConstInt(ctx->i32, slc, 0),
|
LLVMConstInt(ctx->i32, slc, 0),
|
||||||
LLVMConstInt(ctx->i32, tfe, 0)
|
LLVMConstInt(ctx->i32, 0, 0), /* tfe*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The instruction offset field has 12 bits */
|
/* The instruction offset field has 12 bits */
|
||||||
|
|
@ -588,28 +592,6 @@ ac_build_tbuffer_store(struct ac_llvm_context *ctx,
|
||||||
AC_FUNC_ATTR_LEGACY);
|
AC_FUNC_ATTR_LEGACY);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ac_build_tbuffer_store_dwords(struct ac_llvm_context *ctx,
|
|
||||||
LLVMValueRef rsrc,
|
|
||||||
LLVMValueRef vdata,
|
|
||||||
unsigned num_channels,
|
|
||||||
LLVMValueRef vaddr,
|
|
||||||
LLVMValueRef soffset,
|
|
||||||
unsigned inst_offset)
|
|
||||||
{
|
|
||||||
static unsigned dfmt[] = {
|
|
||||||
V_008F0C_BUF_DATA_FORMAT_32,
|
|
||||||
V_008F0C_BUF_DATA_FORMAT_32_32,
|
|
||||||
V_008F0C_BUF_DATA_FORMAT_32_32_32,
|
|
||||||
V_008F0C_BUF_DATA_FORMAT_32_32_32_32
|
|
||||||
};
|
|
||||||
assert(num_channels >= 1 && num_channels <= 4);
|
|
||||||
|
|
||||||
ac_build_tbuffer_store(ctx, rsrc, vdata, num_channels, vaddr, soffset,
|
|
||||||
inst_offset, dfmt[num_channels - 1],
|
|
||||||
V_008F0C_BUF_NUM_FORMAT_UINT, 1, 0, 1, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
LLVMValueRef
|
LLVMValueRef
|
||||||
ac_build_buffer_load(struct ac_llvm_context *ctx,
|
ac_build_buffer_load(struct ac_llvm_context *ctx,
|
||||||
LLVMValueRef rsrc,
|
LLVMValueRef rsrc,
|
||||||
|
|
|
||||||
|
|
@ -122,30 +122,16 @@ ac_build_indexed_load_const(struct ac_llvm_context *ctx,
|
||||||
LLVMValueRef base_ptr, LLVMValueRef index);
|
LLVMValueRef base_ptr, LLVMValueRef index);
|
||||||
|
|
||||||
void
|
void
|
||||||
ac_build_tbuffer_store_dwords(struct ac_llvm_context *ctx,
|
ac_build_buffer_store_dword(struct ac_llvm_context *ctx,
|
||||||
LLVMValueRef rsrc,
|
LLVMValueRef rsrc,
|
||||||
LLVMValueRef vdata,
|
LLVMValueRef vdata,
|
||||||
unsigned num_channels,
|
unsigned num_channels,
|
||||||
LLVMValueRef vaddr,
|
LLVMValueRef vaddr,
|
||||||
LLVMValueRef soffset,
|
LLVMValueRef soffset,
|
||||||
unsigned inst_offset);
|
unsigned inst_offset,
|
||||||
|
bool offen,
|
||||||
void
|
bool glc,
|
||||||
ac_build_tbuffer_store(struct ac_llvm_context *ctx,
|
bool slc);
|
||||||
LLVMValueRef rsrc,
|
|
||||||
LLVMValueRef vdata,
|
|
||||||
unsigned num_channels,
|
|
||||||
LLVMValueRef vaddr,
|
|
||||||
LLVMValueRef soffset,
|
|
||||||
unsigned inst_offset,
|
|
||||||
unsigned dfmt,
|
|
||||||
unsigned nfmt,
|
|
||||||
unsigned offen,
|
|
||||||
unsigned idxen,
|
|
||||||
unsigned glc,
|
|
||||||
unsigned slc,
|
|
||||||
unsigned tfe);
|
|
||||||
|
|
||||||
LLVMValueRef
|
LLVMValueRef
|
||||||
ac_build_buffer_load(struct ac_llvm_context *ctx,
|
ac_build_buffer_load(struct ac_llvm_context *ctx,
|
||||||
LLVMValueRef rsrc,
|
LLVMValueRef rsrc,
|
||||||
|
|
|
||||||
|
|
@ -3156,12 +3156,10 @@ visit_emit_vertex(struct nir_to_llvm_context *ctx,
|
||||||
|
|
||||||
out_val = LLVMBuildBitCast(ctx->builder, out_val, ctx->i32, "");
|
out_val = LLVMBuildBitCast(ctx->builder, out_val, ctx->i32, "");
|
||||||
|
|
||||||
ac_build_tbuffer_store(&ctx->ac, ctx->gsvs_ring,
|
ac_build_buffer_store_dword(&ctx->ac, ctx->gsvs_ring,
|
||||||
out_val, 1,
|
out_val, 1,
|
||||||
voffset, ctx->gs2vs_offset, 0,
|
voffset, ctx->gs2vs_offset, 0,
|
||||||
V_008F0C_BUF_DATA_FORMAT_32,
|
1, 1, 1);
|
||||||
V_008F0C_BUF_NUM_FORMAT_UINT,
|
|
||||||
1, 0, 1, 1, 0);
|
|
||||||
}
|
}
|
||||||
idx += slot_inc;
|
idx += slot_inc;
|
||||||
}
|
}
|
||||||
|
|
@ -4672,14 +4670,12 @@ handle_es_outputs_post(struct nir_to_llvm_context *ctx)
|
||||||
LLVMValueRef out_val = LLVMBuildLoad(ctx->builder, out_ptr[j], "");
|
LLVMValueRef out_val = LLVMBuildLoad(ctx->builder, out_ptr[j], "");
|
||||||
out_val = LLVMBuildBitCast(ctx->builder, out_val, ctx->i32, "");
|
out_val = LLVMBuildBitCast(ctx->builder, out_val, ctx->i32, "");
|
||||||
|
|
||||||
ac_build_tbuffer_store(&ctx->ac,
|
ac_build_buffer_store_dword(&ctx->ac,
|
||||||
ctx->esgs_ring,
|
ctx->esgs_ring,
|
||||||
out_val, 1,
|
out_val, 1,
|
||||||
LLVMGetUndef(ctx->i32), ctx->es2gs_offset,
|
LLVMGetUndef(ctx->i32), ctx->es2gs_offset,
|
||||||
(4 * param_index + j + start) * 4,
|
(4 * param_index + j + start) * 4,
|
||||||
V_008F0C_BUF_DATA_FORMAT_32,
|
0, 1, 1);
|
||||||
V_008F0C_BUF_NUM_FORMAT_UINT,
|
|
||||||
0, 0, 1, 1, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx->shader_info->vs.esgs_itemsize = (max_output_written + 1) * 16;
|
ctx->shader_info->vs.esgs_itemsize = (max_output_written + 1) * 16;
|
||||||
|
|
|
||||||
|
|
@ -1047,17 +1047,17 @@ static void store_output_tcs(struct lp_build_tgsi_context *bld_base,
|
||||||
values[chan_index] = value;
|
values[chan_index] = value;
|
||||||
|
|
||||||
if (inst->Dst[0].Register.WriteMask != 0xF && !is_tess_factor) {
|
if (inst->Dst[0].Register.WriteMask != 0xF && !is_tess_factor) {
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buffer, value, 1,
|
ac_build_buffer_store_dword(&ctx->ac, buffer, value, 1,
|
||||||
buf_addr, base,
|
buf_addr, base,
|
||||||
4 * chan_index);
|
4 * chan_index, 1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inst->Dst[0].Register.WriteMask == 0xF && !is_tess_factor) {
|
if (inst->Dst[0].Register.WriteMask == 0xF && !is_tess_factor) {
|
||||||
LLVMValueRef value = lp_build_gather_values(bld_base->base.gallivm,
|
LLVMValueRef value = lp_build_gather_values(bld_base->base.gallivm,
|
||||||
values, 4);
|
values, 4);
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buffer, value, 4, buf_addr,
|
ac_build_buffer_store_dword(&ctx->ac, buffer, value, 4, buf_addr,
|
||||||
base, 0);
|
base, 0, 1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2083,11 +2083,11 @@ static void emit_streamout_output(struct si_shader_context *ctx,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, so_buffers[buf_idx],
|
ac_build_buffer_store_dword(&ctx->ac, so_buffers[buf_idx],
|
||||||
vdata, num_comps,
|
vdata, num_comps,
|
||||||
so_write_offsets[buf_idx],
|
so_write_offsets[buf_idx],
|
||||||
LLVMConstInt(ctx->i32, 0, 0),
|
LLVMConstInt(ctx->i32, 0, 0),
|
||||||
stream_out->dst_offset * 4);
|
stream_out->dst_offset * 4, 1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2411,8 +2411,8 @@ static void si_copy_tcs_inputs(struct lp_build_tgsi_context *bld_base)
|
||||||
LLVMValueRef value = lds_load(bld_base, TGSI_TYPE_SIGNED, ~0,
|
LLVMValueRef value = lds_load(bld_base, TGSI_TYPE_SIGNED, ~0,
|
||||||
lds_ptr);
|
lds_ptr);
|
||||||
|
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buffer, value, 4, buffer_addr,
|
ac_build_buffer_store_dword(&ctx->ac, buffer, value, 4, buffer_addr,
|
||||||
buffer_offset, 0);
|
buffer_offset, 0, 1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2524,18 +2524,21 @@ static void si_write_tess_factors(struct lp_build_tgsi_context *bld_base,
|
||||||
rel_patch_id, bld_base->uint_bld.zero, ""));
|
rel_patch_id, bld_base->uint_bld.zero, ""));
|
||||||
|
|
||||||
/* Store the dynamic HS control word. */
|
/* Store the dynamic HS control word. */
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buffer,
|
ac_build_buffer_store_dword(&ctx->ac, buffer,
|
||||||
lp_build_const_int32(gallivm, 0x80000000),
|
lp_build_const_int32(gallivm, 0x80000000),
|
||||||
1, lp_build_const_int32(gallivm, 0), tf_base, 0);
|
1, lp_build_const_int32(gallivm, 0), tf_base,
|
||||||
|
0, 1, 1, 1);
|
||||||
|
|
||||||
lp_build_endif(&inner_if_ctx);
|
lp_build_endif(&inner_if_ctx);
|
||||||
|
|
||||||
/* Store the tessellation factors. */
|
/* Store the tessellation factors. */
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buffer, vec0,
|
ac_build_buffer_store_dword(&ctx->ac, buffer, vec0,
|
||||||
MIN2(stride, 4), byteoffset, tf_base, 4);
|
MIN2(stride, 4), byteoffset, tf_base,
|
||||||
|
4, 1, 1, 1);
|
||||||
if (vec1)
|
if (vec1)
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buffer, vec1,
|
ac_build_buffer_store_dword(&ctx->ac, buffer, vec1,
|
||||||
stride - 4, byteoffset, tf_base, 20);
|
stride - 4, byteoffset, tf_base,
|
||||||
|
20, 1, 1, 1);
|
||||||
|
|
||||||
/* Store the tess factors into the offchip buffer if TES reads them. */
|
/* Store the tess factors into the offchip buffer if TES reads them. */
|
||||||
if (shader->key.part.tcs.epilog.tes_reads_tess_factors) {
|
if (shader->key.part.tcs.epilog.tes_reads_tess_factors) {
|
||||||
|
|
@ -2555,9 +2558,9 @@ static void si_write_tess_factors(struct lp_build_tgsi_context *bld_base,
|
||||||
outer_vec = lp_build_gather_values(gallivm, outer,
|
outer_vec = lp_build_gather_values(gallivm, outer,
|
||||||
util_next_power_of_two(outer_comps));
|
util_next_power_of_two(outer_comps));
|
||||||
|
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buf, outer_vec,
|
ac_build_buffer_store_dword(&ctx->ac, buf, outer_vec,
|
||||||
outer_comps, tf_outer_offset,
|
outer_comps, tf_outer_offset,
|
||||||
base, 0);
|
base, 0, 1, 1, 1);
|
||||||
if (inner_comps) {
|
if (inner_comps) {
|
||||||
param_inner = si_shader_io_get_unique_index(
|
param_inner = si_shader_io_get_unique_index(
|
||||||
TGSI_SEMANTIC_TESSINNER, 0);
|
TGSI_SEMANTIC_TESSINNER, 0);
|
||||||
|
|
@ -2566,9 +2569,9 @@ static void si_write_tess_factors(struct lp_build_tgsi_context *bld_base,
|
||||||
|
|
||||||
inner_vec = inner_comps == 1 ? inner[0] :
|
inner_vec = inner_comps == 1 ? inner[0] :
|
||||||
lp_build_gather_values(gallivm, inner, inner_comps);
|
lp_build_gather_values(gallivm, inner, inner_comps);
|
||||||
ac_build_tbuffer_store_dwords(&ctx->ac, buf, inner_vec,
|
ac_build_buffer_store_dword(&ctx->ac, buf, inner_vec,
|
||||||
inner_comps, tf_inner_offset,
|
inner_comps, tf_inner_offset,
|
||||||
base, 0);
|
base, 0, 1, 1, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2688,14 +2691,12 @@ static void si_llvm_emit_es_epilogue(struct lp_build_tgsi_context *bld_base)
|
||||||
LLVMValueRef out_val = LLVMBuildLoad(gallivm->builder, out_ptr[chan], "");
|
LLVMValueRef out_val = LLVMBuildLoad(gallivm->builder, out_ptr[chan], "");
|
||||||
out_val = LLVMBuildBitCast(gallivm->builder, out_val, ctx->i32, "");
|
out_val = LLVMBuildBitCast(gallivm->builder, out_val, ctx->i32, "");
|
||||||
|
|
||||||
ac_build_tbuffer_store(&ctx->ac,
|
ac_build_buffer_store_dword(&ctx->ac,
|
||||||
ctx->esgs_ring,
|
ctx->esgs_ring,
|
||||||
out_val, 1,
|
out_val, 1,
|
||||||
LLVMGetUndef(ctx->i32), soffset,
|
LLVMGetUndef(ctx->i32), soffset,
|
||||||
(4 * param_index + chan) * 4,
|
(4 * param_index + chan) * 4,
|
||||||
V_008F0C_BUF_DATA_FORMAT_32,
|
0, 1, 1);
|
||||||
V_008F0C_BUF_NUM_FORMAT_UINT,
|
|
||||||
0, 0, 1, 1, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -5056,13 +5057,11 @@ static void si_llvm_emit_vertex(
|
||||||
|
|
||||||
out_val = LLVMBuildBitCast(gallivm->builder, out_val, ctx->i32, "");
|
out_val = LLVMBuildBitCast(gallivm->builder, out_val, ctx->i32, "");
|
||||||
|
|
||||||
ac_build_tbuffer_store(&ctx->ac,
|
ac_build_buffer_store_dword(&ctx->ac,
|
||||||
ctx->gsvs_ring[stream],
|
ctx->gsvs_ring[stream],
|
||||||
out_val, 1,
|
out_val, 1,
|
||||||
voffset, soffset, 0,
|
voffset, soffset, 0,
|
||||||
V_008F0C_BUF_DATA_FORMAT_32,
|
1, 1, 1);
|
||||||
V_008F0C_BUF_NUM_FORMAT_UINT,
|
|
||||||
1, 0, 1, 1, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue