ac: use new LLVM 8 intrinsic when storing 16-bit values
vindex is always 0. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
parent
2a9d331898
commit
9d960c17a8
|
@ -1741,6 +1741,26 @@ ac_build_raw_tbuffer_store(struct ac_llvm_context *ctx,
|
||||||
writeonly_memory, false);
|
writeonly_memory, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ac_build_tbuffer_store_short(struct ac_llvm_context *ctx,
|
||||||
|
LLVMValueRef rsrc,
|
||||||
|
LLVMValueRef vdata,
|
||||||
|
LLVMValueRef voffset,
|
||||||
|
LLVMValueRef soffset,
|
||||||
|
bool glc,
|
||||||
|
bool writeonly_memory)
|
||||||
|
{
|
||||||
|
unsigned dfmt = V_008F0C_BUF_DATA_FORMAT_16;
|
||||||
|
unsigned nfmt = V_008F0C_BUF_NUM_FORMAT_UINT;
|
||||||
|
|
||||||
|
vdata = LLVMBuildBitCast(ctx->builder, vdata, ctx->i16, "");
|
||||||
|
vdata = LLVMBuildZExt(ctx->builder, vdata, ctx->i32, "");
|
||||||
|
|
||||||
|
ac_build_raw_tbuffer_store(ctx, rsrc, vdata, voffset, soffset,
|
||||||
|
ctx->i32_0, 1, dfmt, nfmt, glc, false,
|
||||||
|
writeonly_memory);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set range metadata on an instruction. This can only be used on load and
|
* Set range metadata on an instruction. This can only be used on load and
|
||||||
* call instructions. If you know an instruction can only produce the values
|
* call instructions. If you know an instruction can only produce the values
|
||||||
|
|
|
@ -343,6 +343,15 @@ ac_build_raw_tbuffer_load(struct ac_llvm_context *ctx,
|
||||||
bool slc,
|
bool slc,
|
||||||
bool can_speculate);
|
bool can_speculate);
|
||||||
|
|
||||||
|
void
|
||||||
|
ac_build_tbuffer_store_short(struct ac_llvm_context *ctx,
|
||||||
|
LLVMValueRef rsrc,
|
||||||
|
LLVMValueRef vdata,
|
||||||
|
LLVMValueRef voffset,
|
||||||
|
LLVMValueRef soffset,
|
||||||
|
bool glc,
|
||||||
|
bool writeonly_memory);
|
||||||
|
|
||||||
void
|
void
|
||||||
ac_build_struct_tbuffer_store(struct ac_llvm_context *ctx,
|
ac_build_struct_tbuffer_store(struct ac_llvm_context *ctx,
|
||||||
LLVMValueRef rsrc,
|
LLVMValueRef rsrc,
|
||||||
|
|
|
@ -1523,14 +1523,12 @@ static unsigned get_cache_policy(struct ac_nir_context *ctx,
|
||||||
static void visit_store_ssbo(struct ac_nir_context *ctx,
|
static void visit_store_ssbo(struct ac_nir_context *ctx,
|
||||||
nir_intrinsic_instr *instr)
|
nir_intrinsic_instr *instr)
|
||||||
{
|
{
|
||||||
const char *store_name;
|
|
||||||
LLVMValueRef src_data = get_src(ctx, instr->src[0]);
|
LLVMValueRef src_data = get_src(ctx, instr->src[0]);
|
||||||
int elem_size_bytes = ac_get_elem_bits(&ctx->ac, LLVMTypeOf(src_data)) / 8;
|
int elem_size_bytes = ac_get_elem_bits(&ctx->ac, LLVMTypeOf(src_data)) / 8;
|
||||||
unsigned writemask = nir_intrinsic_write_mask(instr);
|
unsigned writemask = nir_intrinsic_write_mask(instr);
|
||||||
enum gl_access_qualifier access = nir_intrinsic_access(instr);
|
enum gl_access_qualifier access = nir_intrinsic_access(instr);
|
||||||
bool writeonly_memory = access & ACCESS_NON_READABLE;
|
bool writeonly_memory = access & ACCESS_NON_READABLE;
|
||||||
unsigned cache_policy = get_cache_policy(ctx, access, false, writeonly_memory);
|
unsigned cache_policy = get_cache_policy(ctx, access, false, writeonly_memory);
|
||||||
LLVMValueRef glc = (cache_policy & ac_glc) ? ctx->ac.i1true : ctx->ac.i1false;
|
|
||||||
|
|
||||||
LLVMValueRef rsrc = ctx->abi->load_ssbo(ctx->abi,
|
LLVMValueRef rsrc = ctx->abi->load_ssbo(ctx->abi,
|
||||||
get_src(ctx, instr->src[1]), true);
|
get_src(ctx, instr->src[1]), true);
|
||||||
|
@ -1573,25 +1571,10 @@ static void visit_store_ssbo(struct ac_nir_context *ctx,
|
||||||
LLVMConstInt(ctx->ac.i32, start * elem_size_bytes, false), "");
|
LLVMConstInt(ctx->ac.i32, start * elem_size_bytes, false), "");
|
||||||
|
|
||||||
if (num_bytes == 2) {
|
if (num_bytes == 2) {
|
||||||
store_name = "llvm.amdgcn.tbuffer.store.i32";
|
ac_build_tbuffer_store_short(&ctx->ac, rsrc, data,
|
||||||
data_type = ctx->ac.i32;
|
offset, ctx->ac.i32_0,
|
||||||
data = LLVMBuildBitCast(ctx->ac.builder, data, ctx->ac.i16, "");
|
cache_policy & ac_glc,
|
||||||
data = LLVMBuildZExt(ctx->ac.builder, data, data_type, "");
|
writeonly_memory);
|
||||||
LLVMValueRef tbuffer_params[] = {
|
|
||||||
data,
|
|
||||||
rsrc,
|
|
||||||
ctx->ac.i32_0, /* vindex */
|
|
||||||
offset, /* voffset */
|
|
||||||
ctx->ac.i32_0,
|
|
||||||
ctx->ac.i32_0,
|
|
||||||
LLVMConstInt(ctx->ac.i32, 2, false), // dfmt (= 16bit)
|
|
||||||
LLVMConstInt(ctx->ac.i32, 4, false), // nfmt (= uint)
|
|
||||||
glc,
|
|
||||||
ctx->ac.i1false,
|
|
||||||
};
|
|
||||||
ac_build_intrinsic(&ctx->ac, store_name,
|
|
||||||
ctx->ac.voidt, tbuffer_params, 10,
|
|
||||||
ac_get_store_intr_attribs(writeonly_memory));
|
|
||||||
} else {
|
} else {
|
||||||
int num_channels = num_bytes / 4;
|
int num_channels = num_bytes / 4;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue