ac,radeonsi: load VS inputs at the call site of nir_intrinsic_load_input

to match ACO

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12570>
This commit is contained in:
Marek Olšák 2021-08-20 23:59:05 -04:00 committed by Marge Bot
parent bce7c7f3fc
commit 3fb229e010
4 changed files with 22 additions and 23 deletions

View file

@ -3344,22 +3344,22 @@ static LLVMValueRef visit_load(struct ac_nir_context *ctx, nir_intrinsic_instr *
nir_intrinsic_io_semantics(instr).fb_fetch_output)
return ctx->abi->emit_fbfetch(ctx->abi);
/* Other non-fragment cases have inputs and outputs in temporaries. */
if (ctx->stage != MESA_SHADER_FRAGMENT) {
for (unsigned chan = component; chan < count + component; chan++) {
if (is_output) {
values[chan] = LLVMBuildLoad(ctx->ac.builder, ctx->abi->outputs[base * 4 + chan], "");
} else {
values[chan] = ctx->abi->inputs[base * 4 + chan];
if (!values[chan])
values[chan] = LLVMGetUndef(ctx->ac.i32);
}
}
if (ctx->stage == MESA_SHADER_VERTEX && !is_output)
return ctx->abi->load_inputs(ctx->abi, base, component, count, 0, component_type);
/* Other non-fragment cases have outputs in temporaries. */
if (is_output && (ctx->stage == MESA_SHADER_VERTEX || ctx->stage == MESA_SHADER_TESS_EVAL)) {
assert(is_output);
for (unsigned chan = component; chan < count + component; chan++)
values[chan] = LLVMBuildLoad(ctx->ac.builder, ctx->abi->outputs[base * 4 + chan], "");
LLVMValueRef result = ac_build_varying_gather_values(&ctx->ac, values, count, component);
return LLVMBuildBitCast(ctx->ac.builder, result, dest_type, "");
}
/* Fragment shader inputs. */
assert(ctx->stage == MESA_SHADER_FRAGMENT);
unsigned vertex_id = 2; /* P0 */
if (instr->intrinsic == nir_intrinsic_load_input_vertex) {

View file

@ -257,7 +257,6 @@ void si_llvm_init_ps_callbacks(struct si_shader_context *ctx);
void si_llvm_init_resource_callbacks(struct si_shader_context *ctx);
/* si_shader_llvm_vs.c */
void si_llvm_load_vs_inputs(struct si_shader_context *ctx, struct nir_shader *nir);
void si_llvm_streamout_store_output(struct si_shader_context *ctx, LLVMValueRef const *so_buffers,
LLVMValueRef const *so_write_offsets,
struct pipe_stream_output *stream_out,

View file

@ -441,9 +441,7 @@ static void si_llvm_declare_compute_memory(struct si_shader_context *ctx)
static bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
{
if (nir->info.stage == MESA_SHADER_VERTEX) {
si_llvm_load_vs_inputs(ctx, nir);
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
unsigned colors_read = ctx->shader->selector->info.colors_read;
LLVMValueRef main_fn = ctx->main_fn;

View file

@ -252,18 +252,19 @@ static void load_input_vs(struct si_shader_context *ctx, unsigned input_index, L
out[i] = ac_to_float(&ctx->ac, fetches[i]);
}
void si_llvm_load_vs_inputs(struct si_shader_context *ctx, struct nir_shader *nir)
static LLVMValueRef si_load_vs_input(struct ac_shader_abi *abi, unsigned driver_location,
unsigned component, unsigned num_components,
unsigned vertex_index, LLVMTypeRef type)
{
const struct si_shader_info *info = &ctx->shader->selector->info;
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
LLVMValueRef values[4];
for (unsigned i = 0; i < info->num_inputs; i++) {
LLVMValueRef values[4];
load_input_vs(ctx, driver_location, values);
load_input_vs(ctx, i, values);
for (unsigned i = 0; i < 4; i++)
values[i] = LLVMBuildBitCast(ctx->ac.builder, values[i], type, "");
for (unsigned chan = 0; chan < 4; chan++)
ctx->abi.inputs[i * 4 + chan] = ac_to_integer(&ctx->ac, values[chan]);
}
return ac_build_varying_gather_values(&ctx->ac, values, num_components, component);
}
void si_llvm_streamout_store_output(struct si_shader_context *ctx, LLVMValueRef const *so_buffers,
@ -1130,4 +1131,5 @@ void si_llvm_init_vs_callbacks(struct si_shader_context *ctx, bool ngg_cull_shad
ctx->abi.emit_outputs = si_llvm_emit_vs_epilogue;
ctx->abi.load_base_vertex = get_base_vertex;
ctx->abi.load_inputs = si_load_vs_input;
}