radeonsi: move VS shader code into si_shader_llvm_vs.c
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3421>
This commit is contained in:
parent
d1c42e2c6a
commit
cd5b99c541
|
@ -41,6 +41,7 @@ C_SOURCES := \
|
|||
si_shader_llvm_ps.c \
|
||||
si_shader_llvm_resources.c \
|
||||
si_shader_llvm_tess.c \
|
||||
si_shader_llvm_vs.c \
|
||||
si_shader_nir.c \
|
||||
si_shaderlib_tgsi.c \
|
||||
si_state.c \
|
||||
|
|
|
@ -252,7 +252,7 @@ static void build_streamout_vertex(struct si_shader_context *ctx,
|
|||
(info->output_streams[reg] >> (2 * comp)) & 3;
|
||||
}
|
||||
|
||||
si_emit_streamout_output(ctx, so_buffer, offset, &so->output[i], &out);
|
||||
si_llvm_streamout_store_output(ctx, so_buffer, offset, &so->output[i], &out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1486,7 +1486,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi,
|
|||
i++;
|
||||
}
|
||||
|
||||
si_llvm_export_vs(ctx, outputs, i);
|
||||
si_llvm_build_vs_exports(ctx, outputs, i);
|
||||
}
|
||||
ac_build_endif(&ctx->ac, 6002);
|
||||
}
|
||||
|
@ -1970,7 +1970,7 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx)
|
|||
}
|
||||
}
|
||||
|
||||
si_llvm_export_vs(ctx, outputs, info->num_outputs);
|
||||
si_llvm_build_vs_exports(ctx, outputs, info->num_outputs);
|
||||
}
|
||||
ac_build_endif(&ctx->ac, 5145);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ files_libradeonsi = files(
|
|||
'si_shader_llvm_ps.c',
|
||||
'si_shader_llvm_resources.c',
|
||||
'si_shader_llvm_tess.c',
|
||||
'si_shader_llvm_vs.c',
|
||||
'si_shader_nir.c',
|
||||
'si_shaderlib_tgsi.c',
|
||||
'si_state.c',
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -231,28 +231,16 @@ LLVMValueRef si_build_gather_64bit(struct si_shader_context *ctx,
|
|||
LLVMValueRef val2);
|
||||
void si_llvm_emit_barrier(struct si_shader_context *ctx);
|
||||
void si_llvm_declare_esgs_ring(struct si_shader_context *ctx);
|
||||
void si_init_exec_from_input(struct si_shader_context *ctx, struct ac_arg param,
|
||||
unsigned bitoffset);
|
||||
void si_declare_compute_memory(struct si_shader_context *ctx);
|
||||
LLVMValueRef si_get_primitive_id(struct si_shader_context *ctx,
|
||||
unsigned swizzle);
|
||||
void si_llvm_export_vs(struct si_shader_context *ctx,
|
||||
struct si_shader_output_values *outputs,
|
||||
unsigned noutput);
|
||||
void si_emit_streamout_output(struct si_shader_context *ctx,
|
||||
LLVMValueRef const *so_buffers,
|
||||
LLVMValueRef const *so_write_offsets,
|
||||
struct pipe_stream_output *stream_out,
|
||||
struct si_shader_output_values *shader_out);
|
||||
void si_add_arg_checked(struct ac_shader_args *args,
|
||||
enum ac_arg_regfile file,
|
||||
unsigned registers, enum ac_arg_type type,
|
||||
struct ac_arg *arg,
|
||||
unsigned idx);
|
||||
|
||||
void si_llvm_load_input_vs(
|
||||
struct si_shader_context *ctx,
|
||||
unsigned input_index,
|
||||
LLVMValueRef out[4]);
|
||||
|
||||
bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir);
|
||||
|
||||
LLVMValueRef si_unpack_param(struct si_shader_context *ctx,
|
||||
|
@ -283,9 +271,6 @@ int si_compile_llvm(struct si_screen *sscreen,
|
|||
const char *name,
|
||||
bool less_optimized);
|
||||
void si_fix_resource_usage(struct si_screen *sscreen, struct si_shader *shader);
|
||||
void si_llvm_emit_streamout(struct si_shader_context *ctx,
|
||||
struct si_shader_output_values *outputs,
|
||||
unsigned noutput, unsigned stream);
|
||||
void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader);
|
||||
|
||||
bool gfx10_ngg_export_prim_early(struct si_shader *shader);
|
||||
|
@ -324,7 +309,7 @@ void si_llvm_emit_ls_epilogue(struct ac_shader_abi *abi, unsigned max_outputs,
|
|||
void si_llvm_build_tcs_epilog(struct si_shader_context *ctx,
|
||||
union si_shader_part_key *key);
|
||||
void si_llvm_init_tcs_callbacks(struct si_shader_context *ctx);
|
||||
void si_llvm_init_tes_callbacks(struct si_shader_context *ctx);
|
||||
void si_llvm_init_tes_callbacks(struct si_shader_context *ctx, bool ngg_cull_shader);
|
||||
|
||||
/* si_shader_llvm_ps.c */
|
||||
void si_llvm_build_ps_prolog(struct si_shader_context *ctx,
|
||||
|
@ -338,4 +323,23 @@ void si_llvm_init_ps_callbacks(struct si_shader_context *ctx);
|
|||
/* si_shader_llvm_resources.c */
|
||||
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,
|
||||
struct si_shader_output_values *shader_out);
|
||||
void si_llvm_emit_streamout(struct si_shader_context *ctx,
|
||||
struct si_shader_output_values *outputs,
|
||||
unsigned noutput, unsigned stream);
|
||||
void si_llvm_build_vs_exports(struct si_shader_context *ctx,
|
||||
struct si_shader_output_values *outputs,
|
||||
unsigned noutput);
|
||||
void si_llvm_emit_vs_epilogue(struct ac_shader_abi *abi, unsigned max_outputs,
|
||||
LLVMValueRef *addrs);
|
||||
void si_llvm_build_vs_prolog(struct si_shader_context *ctx,
|
||||
union si_shader_part_key *key);
|
||||
void si_llvm_init_vs_callbacks(struct si_shader_context *ctx, bool ngg_cull_shader);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -129,3 +129,15 @@ void si_llvm_declare_esgs_ring(struct si_shader_context *ctx)
|
|||
LLVMSetLinkage(ctx->esgs_ring, LLVMExternalLinkage);
|
||||
LLVMSetAlignment(ctx->esgs_ring, 64 * 1024);
|
||||
}
|
||||
|
||||
void si_init_exec_from_input(struct si_shader_context *ctx, struct ac_arg param,
|
||||
unsigned bitoffset)
|
||||
{
|
||||
LLVMValueRef args[] = {
|
||||
ac_get_arg(&ctx->ac, param),
|
||||
LLVMConstInt(ctx->ac.i32, bitoffset, 0),
|
||||
};
|
||||
ac_build_intrinsic(&ctx->ac,
|
||||
"llvm.amdgcn.init.exec.from.input",
|
||||
ctx->ac.voidt, args, 2, AC_FUNC_ATTR_CONVERGENT);
|
||||
}
|
||||
|
|
|
@ -609,7 +609,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
|
|||
}
|
||||
|
||||
if (stream == 0)
|
||||
si_llvm_export_vs(&ctx, outputs, gsinfo->num_outputs);
|
||||
si_llvm_build_vs_exports(&ctx, outputs, gsinfo->num_outputs);
|
||||
|
||||
LLVMBuildBr(builder, end_bb);
|
||||
}
|
||||
|
|
|
@ -1277,10 +1277,19 @@ void si_llvm_init_tcs_callbacks(struct si_shader_context *ctx)
|
|||
ctx->abi.load_patch_vertices_in = si_load_patch_vertices_in;
|
||||
}
|
||||
|
||||
void si_llvm_init_tes_callbacks(struct si_shader_context *ctx)
|
||||
void si_llvm_init_tes_callbacks(struct si_shader_context *ctx, bool ngg_cull_shader)
|
||||
{
|
||||
ctx->abi.load_tess_varyings = si_nir_load_input_tes;
|
||||
ctx->abi.load_tess_coord = si_load_tess_coord;
|
||||
ctx->abi.load_tess_level = si_load_tess_level;
|
||||
ctx->abi.load_patch_vertices_in = si_load_patch_vertices_in;
|
||||
|
||||
if (ctx->shader->key.as_es)
|
||||
ctx->abi.emit_outputs = si_llvm_emit_es_epilogue;
|
||||
else if (ngg_cull_shader)
|
||||
ctx->abi.emit_outputs = gfx10_emit_ngg_culling_epilogue_4x_wave32;
|
||||
else if (ctx->shader->key.as_ngg)
|
||||
ctx->abi.emit_outputs = gfx10_emit_ngg_epilogue;
|
||||
else
|
||||
ctx->abi.emit_outputs = si_llvm_emit_vs_epilogue;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -997,59 +997,10 @@ void si_finalize_nir(struct pipe_screen *screen, void *nirptr, bool optimize)
|
|||
si_lower_nir(sscreen, nir);
|
||||
}
|
||||
|
||||
static void declare_nir_input_vs(struct si_shader_context *ctx,
|
||||
struct nir_variable *variable,
|
||||
unsigned input_index,
|
||||
LLVMValueRef out[4])
|
||||
{
|
||||
si_llvm_load_input_vs(ctx, input_index, out);
|
||||
}
|
||||
|
||||
static void bitcast_inputs(struct si_shader_context *ctx,
|
||||
LLVMValueRef data[4],
|
||||
unsigned input_idx)
|
||||
{
|
||||
for (unsigned chan = 0; chan < 4; chan++) {
|
||||
ctx->inputs[input_idx + chan] =
|
||||
LLVMBuildBitCast(ctx->ac.builder, data[chan], ctx->ac.i32, "");
|
||||
}
|
||||
}
|
||||
|
||||
bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir)
|
||||
{
|
||||
struct si_shader_info *info = &ctx->shader->selector->info;
|
||||
|
||||
if (nir->info.stage == MESA_SHADER_VERTEX) {
|
||||
uint64_t processed_inputs = 0;
|
||||
nir_foreach_variable(variable, &nir->inputs) {
|
||||
unsigned attrib_count = glsl_count_attribute_slots(variable->type,
|
||||
true);
|
||||
unsigned input_idx = variable->data.driver_location;
|
||||
|
||||
LLVMValueRef data[4];
|
||||
unsigned loc = variable->data.location;
|
||||
|
||||
for (unsigned i = 0; i < attrib_count; i++) {
|
||||
/* Packed components share the same location so skip
|
||||
* them if we have already processed the location.
|
||||
*/
|
||||
if (processed_inputs & ((uint64_t)1 << (loc + i))) {
|
||||
input_idx += 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
declare_nir_input_vs(ctx, variable, input_idx / 4, data);
|
||||
bitcast_inputs(ctx, data, input_idx);
|
||||
if (glsl_type_is_dual_slot(variable->type)) {
|
||||
input_idx += 4;
|
||||
declare_nir_input_vs(ctx, variable, input_idx / 4, data);
|
||||
bitcast_inputs(ctx, data, input_idx);
|
||||
}
|
||||
|
||||
processed_inputs |= ((uint64_t)1 << (loc + i));
|
||||
input_idx += 4;
|
||||
}
|
||||
}
|
||||
si_llvm_load_vs_inputs(ctx, nir);
|
||||
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
|
||||
unsigned colors_read =
|
||||
ctx->shader->selector->info.colors_read;
|
||||
|
|
Loading…
Reference in New Issue