radeonsi: move PS LLVM code into si_shader_llvm_ps.c
This is an attempt to clean up si_shader.c. v2: don't move code that is not specific to LLVM Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> (v1)
This commit is contained in:
@@ -37,6 +37,7 @@ C_SOURCES := \
|
|||||||
si_shader_internal.h \
|
si_shader_internal.h \
|
||||||
si_shader_llvm.c \
|
si_shader_llvm.c \
|
||||||
si_shader_llvm_build.c \
|
si_shader_llvm_build.c \
|
||||||
|
si_shader_llvm_ps.c \
|
||||||
si_shader_nir.c \
|
si_shader_nir.c \
|
||||||
si_shaderlib_tgsi.c \
|
si_shaderlib_tgsi.c \
|
||||||
si_state.c \
|
si_state.c \
|
||||||
|
@@ -52,6 +52,7 @@ files_libradeonsi = files(
|
|||||||
'si_shader_internal.h',
|
'si_shader_internal.h',
|
||||||
'si_shader_llvm.c',
|
'si_shader_llvm.c',
|
||||||
'si_shader_llvm_build.c',
|
'si_shader_llvm_build.c',
|
||||||
|
'si_shader_llvm_ps.c',
|
||||||
'si_shader_nir.c',
|
'si_shader_nir.c',
|
||||||
'si_shaderlib_tgsi.c',
|
'si_shaderlib_tgsi.c',
|
||||||
'si_state.c',
|
'si_state.c',
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -35,6 +35,11 @@ struct pipe_debug_callback;
|
|||||||
|
|
||||||
#define RADEON_LLVM_MAX_INPUTS 32 * 4
|
#define RADEON_LLVM_MAX_INPUTS 32 * 4
|
||||||
|
|
||||||
|
/* Ideally pass the sample mask input to the PS epilog as v14, which
|
||||||
|
* is its usual location, so that the shader doesn't have to add v_mov.
|
||||||
|
*/
|
||||||
|
#define PS_EPILOG_SAMPLEMASK_MIN_LOC 14
|
||||||
|
|
||||||
struct si_shader_output_values {
|
struct si_shader_output_values {
|
||||||
LLVMValueRef values[4];
|
LLVMValueRef values[4];
|
||||||
unsigned semantic_name;
|
unsigned semantic_name;
|
||||||
@@ -235,9 +240,7 @@ LLVMValueRef si_nir_load_input_tes(struct ac_shader_abi *abi,
|
|||||||
bool is_patch,
|
bool is_patch,
|
||||||
bool is_compact,
|
bool is_compact,
|
||||||
bool load_input);
|
bool load_input);
|
||||||
LLVMValueRef si_nir_lookup_interp_param(struct ac_shader_abi *abi,
|
bool si_is_merged_shader(struct si_shader_context *ctx);
|
||||||
enum glsl_interp_mode interp,
|
|
||||||
unsigned location);
|
|
||||||
LLVMValueRef si_get_sample_id(struct si_shader_context *ctx);
|
LLVMValueRef si_get_sample_id(struct si_shader_context *ctx);
|
||||||
LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx,
|
LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx,
|
||||||
LLVMValueRef list, LLVMValueRef index,
|
LLVMValueRef list, LLVMValueRef index,
|
||||||
@@ -246,7 +249,10 @@ LLVMValueRef si_load_image_desc(struct si_shader_context *ctx,
|
|||||||
LLVMValueRef list, LLVMValueRef index,
|
LLVMValueRef list, LLVMValueRef index,
|
||||||
enum ac_descriptor_type desc_type,
|
enum ac_descriptor_type desc_type,
|
||||||
bool uses_store, bool bindless);
|
bool uses_store, bool bindless);
|
||||||
LLVMValueRef si_nir_emit_fbfetch(struct ac_shader_abi *abi);
|
LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx,
|
||||||
|
LLVMValueRef resource, LLVMValueRef offset);
|
||||||
|
void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret);
|
||||||
|
LLVMValueRef si_prolog_get_rw_buffers(struct si_shader_context *ctx);
|
||||||
void si_declare_compute_memory(struct si_shader_context *ctx);
|
void si_declare_compute_memory(struct si_shader_context *ctx);
|
||||||
LLVMValueRef si_get_primitive_id(struct si_shader_context *ctx,
|
LLVMValueRef si_get_primitive_id(struct si_shader_context *ctx,
|
||||||
unsigned swizzle);
|
unsigned swizzle);
|
||||||
@@ -258,6 +264,11 @@ void si_emit_streamout_output(struct si_shader_context *ctx,
|
|||||||
LLVMValueRef const *so_write_offsets,
|
LLVMValueRef const *so_write_offsets,
|
||||||
struct pipe_stream_output *stream_out,
|
struct pipe_stream_output *stream_out,
|
||||||
struct si_shader_output_values *shader_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(
|
void si_llvm_load_input_vs(
|
||||||
struct si_shader_context *ctx,
|
struct si_shader_context *ctx,
|
||||||
@@ -271,6 +282,15 @@ LLVMValueRef si_unpack_param(struct si_shader_context *ctx,
|
|||||||
unsigned bitwidth);
|
unsigned bitwidth);
|
||||||
LLVMValueRef si_is_es_thread(struct si_shader_context *ctx);
|
LLVMValueRef si_is_es_thread(struct si_shader_context *ctx);
|
||||||
LLVMValueRef si_is_gs_thread(struct si_shader_context *ctx);
|
LLVMValueRef si_is_gs_thread(struct si_shader_context *ctx);
|
||||||
|
void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *parts,
|
||||||
|
unsigned num_parts, unsigned main_part,
|
||||||
|
unsigned next_shader_first_part);
|
||||||
|
bool si_need_ps_prolog(const union si_shader_part_key *key);
|
||||||
|
void si_get_ps_prolog_key(struct si_shader *shader,
|
||||||
|
union si_shader_part_key *key,
|
||||||
|
bool separate_prolog);
|
||||||
|
void si_get_ps_epilog_key(struct si_shader *shader,
|
||||||
|
union si_shader_part_key *key);
|
||||||
|
|
||||||
void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi,
|
void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi,
|
||||||
unsigned max_outputs,
|
unsigned max_outputs,
|
||||||
@@ -282,4 +302,13 @@ void gfx10_ngg_gs_emit_prologue(struct si_shader_context *ctx);
|
|||||||
void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx);
|
void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx);
|
||||||
void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader);
|
void gfx10_ngg_calculate_subgroup_info(struct si_shader *shader);
|
||||||
|
|
||||||
|
/* si_shader_llvm_ps.c */
|
||||||
|
void si_llvm_build_ps_prolog(struct si_shader_context *ctx,
|
||||||
|
union si_shader_part_key *key);
|
||||||
|
void si_llvm_build_ps_epilog(struct si_shader_context *ctx,
|
||||||
|
union si_shader_part_key *key);
|
||||||
|
void si_llvm_build_monolithic_ps(struct si_shader_context *ctx,
|
||||||
|
struct si_shader *shader);
|
||||||
|
void si_llvm_init_ps_callbacks(struct si_shader_context *ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -159,61 +159,31 @@ LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx,
|
|||||||
return ac_build_load_to_sgpr(&ctx->ac, list, index);
|
return ac_build_load_to_sgpr(&ctx->ac, list, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef si_nir_emit_fbfetch(struct ac_shader_abi *abi)
|
/**
|
||||||
|
* Load a dword from a constant buffer.
|
||||||
|
*/
|
||||||
|
LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx,
|
||||||
|
LLVMValueRef resource, LLVMValueRef offset)
|
||||||
{
|
{
|
||||||
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
|
return ac_build_buffer_load(&ctx->ac, resource, 1, NULL, offset, NULL,
|
||||||
struct ac_image_args args = {};
|
0, 0, true, true);
|
||||||
LLVMValueRef ptr, image, fmask;
|
}
|
||||||
|
|
||||||
/* Ignore src0, because KHR_blend_func_extended disallows multiple render
|
void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret)
|
||||||
* targets.
|
{
|
||||||
*/
|
if (LLVMGetTypeKind(LLVMTypeOf(ret)) == LLVMVoidTypeKind)
|
||||||
|
LLVMBuildRetVoid(ctx->ac.builder);
|
||||||
/* Load the image descriptor. */
|
else
|
||||||
STATIC_ASSERT(SI_PS_IMAGE_COLORBUF0 % 2 == 0);
|
LLVMBuildRet(ctx->ac.builder, ret);
|
||||||
ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers);
|
}
|
||||||
ptr = LLVMBuildPointerCast(ctx->ac.builder, ptr,
|
|
||||||
ac_array_in_const32_addr_space(ctx->v8i32), "");
|
LLVMValueRef si_prolog_get_rw_buffers(struct si_shader_context *ctx)
|
||||||
image = ac_build_load_to_sgpr(&ctx->ac, ptr,
|
{
|
||||||
LLVMConstInt(ctx->i32, SI_PS_IMAGE_COLORBUF0 / 2, 0));
|
LLVMValueRef ptr[2], list;
|
||||||
|
bool merged_shader = si_is_merged_shader(ctx);
|
||||||
unsigned chan = 0;
|
|
||||||
|
ptr[0] = LLVMGetParam(ctx->main_fn, (merged_shader ? 8 : 0) + SI_SGPR_RW_BUFFERS);
|
||||||
args.coords[chan++] = si_unpack_param(ctx, ctx->pos_fixed_pt, 0, 16);
|
list = LLVMBuildIntToPtr(ctx->ac.builder, ptr[0],
|
||||||
|
ac_array_in_const32_addr_space(ctx->v4i32), "");
|
||||||
if (!ctx->shader->key.mono.u.ps.fbfetch_is_1D)
|
return list;
|
||||||
args.coords[chan++] = si_unpack_param(ctx, ctx->pos_fixed_pt, 16, 16);
|
|
||||||
|
|
||||||
/* Get the current render target layer index. */
|
|
||||||
if (ctx->shader->key.mono.u.ps.fbfetch_layered)
|
|
||||||
args.coords[chan++] = si_unpack_param(ctx, ctx->args.ancillary, 16, 11);
|
|
||||||
|
|
||||||
if (ctx->shader->key.mono.u.ps.fbfetch_msaa)
|
|
||||||
args.coords[chan++] = si_get_sample_id(ctx);
|
|
||||||
|
|
||||||
if (ctx->shader->key.mono.u.ps.fbfetch_msaa &&
|
|
||||||
!(ctx->screen->debug_flags & DBG(NO_FMASK))) {
|
|
||||||
fmask = ac_build_load_to_sgpr(&ctx->ac, ptr,
|
|
||||||
LLVMConstInt(ctx->i32, SI_PS_IMAGE_COLORBUF0_FMASK / 2, 0));
|
|
||||||
|
|
||||||
ac_apply_fmask_to_sample(&ctx->ac, fmask, args.coords,
|
|
||||||
ctx->shader->key.mono.u.ps.fbfetch_layered);
|
|
||||||
}
|
|
||||||
|
|
||||||
args.opcode = ac_image_load;
|
|
||||||
args.resource = image;
|
|
||||||
args.dmask = 0xf;
|
|
||||||
args.attributes = AC_FUNC_ATTR_READNONE;
|
|
||||||
|
|
||||||
if (ctx->shader->key.mono.u.ps.fbfetch_msaa)
|
|
||||||
args.dim = ctx->shader->key.mono.u.ps.fbfetch_layered ?
|
|
||||||
ac_image_2darraymsaa : ac_image_2dmsaa;
|
|
||||||
else if (ctx->shader->key.mono.u.ps.fbfetch_is_1D)
|
|
||||||
args.dim = ctx->shader->key.mono.u.ps.fbfetch_layered ?
|
|
||||||
ac_image_1darray : ac_image_1d;
|
|
||||||
else
|
|
||||||
args.dim = ctx->shader->key.mono.u.ps.fbfetch_layered ?
|
|
||||||
ac_image_2darray : ac_image_2d;
|
|
||||||
|
|
||||||
return ac_build_image_opcode(&ctx->ac, &args);
|
|
||||||
}
|
}
|
||||||
|
1061
src/gallium/drivers/radeonsi/si_shader_llvm_ps.c
Normal file
1061
src/gallium/drivers/radeonsi/si_shader_llvm_ps.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1005,38 +1005,6 @@ static void declare_nir_input_vs(struct si_shader_context *ctx,
|
|||||||
si_llvm_load_input_vs(ctx, input_index, out);
|
si_llvm_load_input_vs(ctx, input_index, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef
|
|
||||||
si_nir_lookup_interp_param(struct ac_shader_abi *abi,
|
|
||||||
enum glsl_interp_mode interp, unsigned location)
|
|
||||||
{
|
|
||||||
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
|
|
||||||
|
|
||||||
switch (interp) {
|
|
||||||
case INTERP_MODE_FLAT:
|
|
||||||
return NULL;
|
|
||||||
case INTERP_MODE_SMOOTH:
|
|
||||||
case INTERP_MODE_NONE:
|
|
||||||
if (location == INTERP_CENTER)
|
|
||||||
return ac_get_arg(&ctx->ac, ctx->args.persp_center);
|
|
||||||
else if (location == INTERP_CENTROID)
|
|
||||||
return ctx->abi.persp_centroid;
|
|
||||||
else if (location == INTERP_SAMPLE)
|
|
||||||
return ac_get_arg(&ctx->ac, ctx->args.persp_sample);
|
|
||||||
break;
|
|
||||||
case INTERP_MODE_NOPERSPECTIVE:
|
|
||||||
if (location == INTERP_CENTER)
|
|
||||||
return ac_get_arg(&ctx->ac, ctx->args.linear_center);
|
|
||||||
else if (location == INTERP_CENTROID)
|
|
||||||
return ac_get_arg(&ctx->ac, ctx->args.linear_centroid);
|
|
||||||
else if (location == INTERP_SAMPLE)
|
|
||||||
return ac_get_arg(&ctx->ac, ctx->args.linear_sample);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(!"Unhandled interpolation mode.");
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static LLVMValueRef
|
static LLVMValueRef
|
||||||
si_nir_load_sampler_desc(struct ac_shader_abi *abi,
|
si_nir_load_sampler_desc(struct ac_shader_abi *abi,
|
||||||
unsigned descriptor_set, unsigned base_index,
|
unsigned descriptor_set, unsigned base_index,
|
||||||
|
Reference in New Issue
Block a user