ac: add ac_build_{struct,raw}_tbuffer_load() helpers

The struct version sets IDXEN=1, while the raw version sets IDXEN=0.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Samuel Pitoiset
2019-03-13 14:04:13 +01:00
parent a66b186beb
commit 045fae0f73
3 changed files with 75 additions and 23 deletions

View File

@@ -1407,7 +1407,7 @@ ac_build_llvm8_tbuffer_load(struct ac_llvm_context *ctx,
ac_get_load_intr_attribs(can_speculate)); ac_get_load_intr_attribs(can_speculate));
} }
LLVMValueRef static LLVMValueRef
ac_build_tbuffer_load(struct ac_llvm_context *ctx, ac_build_tbuffer_load(struct ac_llvm_context *ctx,
LLVMValueRef rsrc, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef vindex,
@@ -1419,7 +1419,8 @@ ac_build_tbuffer_load(struct ac_llvm_context *ctx,
unsigned nfmt, unsigned nfmt,
bool glc, bool glc,
bool slc, bool slc,
bool can_speculate) bool can_speculate,
bool structurized) /* only matters for LLVM 8+ */
{ {
if (HAVE_LLVM >= 0x800) { if (HAVE_LLVM >= 0x800) {
voffset = LLVMBuildAdd(ctx->builder, voffset, immoffset, ""); voffset = LLVMBuildAdd(ctx->builder, voffset, immoffset, "");
@@ -1427,12 +1428,12 @@ ac_build_tbuffer_load(struct ac_llvm_context *ctx,
return ac_build_llvm8_tbuffer_load(ctx, rsrc, vindex, voffset, return ac_build_llvm8_tbuffer_load(ctx, rsrc, vindex, voffset,
soffset, num_channels, soffset, num_channels,
dfmt, nfmt, glc, slc, dfmt, nfmt, glc, slc,
can_speculate, true); can_speculate, structurized);
} }
LLVMValueRef args[] = { LLVMValueRef args[] = {
rsrc, rsrc,
vindex, vindex ? vindex : ctx->i32_0,
voffset, voffset,
soffset, soffset,
immoffset, immoffset,
@@ -1453,6 +1454,43 @@ ac_build_tbuffer_load(struct ac_llvm_context *ctx,
ac_get_load_intr_attribs(can_speculate)); ac_get_load_intr_attribs(can_speculate));
} }
LLVMValueRef
ac_build_struct_tbuffer_load(struct ac_llvm_context *ctx,
LLVMValueRef rsrc,
LLVMValueRef vindex,
LLVMValueRef voffset,
LLVMValueRef soffset,
LLVMValueRef immoffset,
unsigned num_channels,
unsigned dfmt,
unsigned nfmt,
bool glc,
bool slc,
bool can_speculate)
{
return ac_build_tbuffer_load(ctx, rsrc, vindex, voffset, soffset,
immoffset, num_channels, dfmt, nfmt, glc,
slc, can_speculate, true);
}
LLVMValueRef
ac_build_raw_tbuffer_load(struct ac_llvm_context *ctx,
LLVMValueRef rsrc,
LLVMValueRef voffset,
LLVMValueRef soffset,
LLVMValueRef immoffset,
unsigned num_channels,
unsigned dfmt,
unsigned nfmt,
bool glc,
bool slc,
bool can_speculate)
{
return ac_build_tbuffer_load(ctx, rsrc, NULL, voffset, soffset,
immoffset, num_channels, dfmt, nfmt, glc,
slc, can_speculate, false);
}
LLVMValueRef LLVMValueRef
ac_build_tbuffer_load_short(struct ac_llvm_context *ctx, ac_build_tbuffer_load_short(struct ac_llvm_context *ctx,
LLVMValueRef rsrc, LLVMValueRef rsrc,
@@ -1467,7 +1505,7 @@ ac_build_tbuffer_load_short(struct ac_llvm_context *ctx,
LLVMValueRef res; LLVMValueRef res;
res = ac_build_tbuffer_load(ctx, rsrc, vindex, voffset, soffset, res = ac_build_tbuffer_load(ctx, rsrc, vindex, voffset, soffset,
immoffset, 1, dfmt, nfmt, glc, false, false); immoffset, 1, dfmt, nfmt, glc, false, false, true);
return LLVMBuildTrunc(ctx->builder, res, ctx->i16, ""); return LLVMBuildTrunc(ctx->builder, res, ctx->i16, "");
} }

View File

@@ -307,7 +307,7 @@ ac_build_tbuffer_load_short(struct ac_llvm_context *ctx,
bool glc); bool glc);
LLVMValueRef LLVMValueRef
ac_build_tbuffer_load(struct ac_llvm_context *ctx, ac_build_struct_tbuffer_load(struct ac_llvm_context *ctx,
LLVMValueRef rsrc, LLVMValueRef rsrc,
LLVMValueRef vindex, LLVMValueRef vindex,
LLVMValueRef voffset, LLVMValueRef voffset,
@@ -320,6 +320,19 @@ ac_build_tbuffer_load(struct ac_llvm_context *ctx,
bool slc, bool slc,
bool can_speculate); bool can_speculate);
LLVMValueRef
ac_build_raw_tbuffer_load(struct ac_llvm_context *ctx,
LLVMValueRef rsrc,
LLVMValueRef voffset,
LLVMValueRef soffset,
LLVMValueRef immoffset,
unsigned num_channels,
unsigned dfmt,
unsigned nfmt,
bool glc,
bool slc,
bool can_speculate);
LLVMValueRef LLVMValueRef
ac_get_thread_id(struct ac_llvm_context *ctx); ac_get_thread_id(struct ac_llvm_context *ctx);

View File

@@ -2181,7 +2181,8 @@ handle_vs_input_decl(struct radv_shader_context *ctx,
t_offset = LLVMConstInt(ctx->ac.i32, attrib_binding, false); t_offset = LLVMConstInt(ctx->ac.i32, attrib_binding, false);
t_list = ac_build_load_to_sgpr(&ctx->ac, t_list_ptr, t_offset); t_list = ac_build_load_to_sgpr(&ctx->ac, t_list_ptr, t_offset);
input = ac_build_tbuffer_load(&ctx->ac, t_list, buffer_index, input = ac_build_struct_tbuffer_load(&ctx->ac, t_list,
buffer_index,
LLVMConstInt(ctx->ac.i32, attrib_offset, false), LLVMConstInt(ctx->ac.i32, attrib_offset, false),
ctx->ac.i32_0, ctx->ac.i32_0, ctx->ac.i32_0, ctx->ac.i32_0,
num_channels, num_channels,