* less than 64, so that a 64-bit bitmask of used inputs or outputs can be
* calculated.
*/
-static unsigned get_unique_index(unsigned semantic_name, unsigned index)
+unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index)
{
switch (semantic_name) {
case TGSI_SEMANTIC_POSITION:
static int get_param_index(unsigned semantic_name, unsigned index,
uint64_t mask)
{
- unsigned unique_index = get_unique_index(semantic_name, index);
+ unsigned unique_index = si_shader_io_get_unique_index(semantic_name, index);
int i, param_index = 0;
/* If not present... */
struct si_shader *shader = si_shader_ctx->shader;
si_store_shader_io_attribs(shader, decl);
-
- if (decl->Semantic.Name != TGSI_SEMANTIC_PRIMID) {
- shader->gs_used_inputs |=
- 1llu << get_unique_index(decl->Semantic.Name,
- decl->Semantic.Index);
- shader->nparam++;
- }
}
static LLVMValueRef fetch_input_gs(
args[1] = vtx_offset;
args[2] = lp_build_const_int32(gallivm,
(get_param_index(input->name, input->sid,
- shader->gs_used_inputs) * 4 +
+ shader->selector->gs_used_inputs) * 4 +
swizzle) * 256);
args[3] = uint->zero;
args[4] = uint->one; /* OFFEN */
*/
can_emit = LLVMBuildICmp(gallivm->builder, LLVMIntULE, gs_next_vertex,
lp_build_const_int32(gallivm,
- shader->gs_max_out_vertices), "");
+ shader->selector->gs_max_out_vertices), "");
kill = lp_build_select(&bld_base->base, can_emit,
lp_build_const_float(gallivm, 1.0f),
lp_build_const_float(gallivm, -1.0f));
LLVMValueRef out_val = LLVMBuildLoad(gallivm->builder, out_ptr[chan], "");
LLVMValueRef voffset =
lp_build_const_int32(gallivm, (i * 4 + chan) *
- shader->gs_max_out_vertices);
+ shader->selector->gs_max_out_vertices);
voffset = lp_build_add(uint, voffset, gs_next_vertex);
voffset = lp_build_mul_imm(uint, voffset, 4);
for (chan = 0; chan < 4; chan++) {
args[2] = lp_build_const_int32(gallivm,
(i * 4 + chan) *
- gs->gs_max_out_vertices * 16 * 4);
+ gs->selector->gs_max_out_vertices * 16 * 4);
outputs[i].values[chan] =
LLVMBuildBitCast(gallivm->builder,
si_shader_ctx.radeon_bld.load_input = declare_input_gs;
bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
-
- shader->gs_output_prim =
- sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM][0];
- shader->gs_max_out_vertices =
- sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES][0];
break;
case TGSI_PROCESSOR_FRAGMENT:
si_shader_ctx.radeon_bld.load_input = declare_input_fs;
/* PIPE_SHADER_[VERTEX|FRAGMENT|...] */
unsigned type;
+
+ unsigned gs_output_prim;
+ unsigned gs_max_out_vertices;
+ uint64_t gs_used_inputs; /* mask of "get_unique_index" bits */
};
union si_shader_key {
unsigned noutput;
struct si_shader_output output[40];
- /* geometry shader properties */
- unsigned gs_output_prim;
- unsigned gs_max_out_vertices;
- uint64_t gs_used_inputs; /* mask of "get_unique_index" bits */
-
unsigned nparam;
bool uses_instanceid;
bool vs_out_misc_write;
int si_compile_llvm(struct si_screen *sscreen, struct si_shader *shader,
LLVMModuleRef mod);
void si_shader_destroy(struct pipe_context *ctx, struct si_shader *shader);
+unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
#endif
key->vs.instance_divisors[i] = sctx->vertex_elements->elements[i].instance_divisor;
if (sctx->gs_shader) {
- /* At this point, the GS should be selected and compiled. */
key->vs.as_es = 1;
- key->vs.gs_used_inputs = sctx->gs_shader->current->gs_used_inputs;
+ key->vs.gs_used_inputs = sctx->gs_shader->gs_used_inputs;
}
} else if (sel->type == PIPE_SHADER_FRAGMENT) {
if (sel->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS][0])
unsigned pipe_shader_type)
{
struct si_shader_selector *sel = CALLOC_STRUCT(si_shader_selector);
+ int i;
sel->type = pipe_shader_type;
sel->tokens = tgsi_dup_tokens(state->tokens);
sel->so = state->stream_output;
tgsi_scan_shader(state->tokens, &sel->info);
+ switch (pipe_shader_type) {
+ case PIPE_SHADER_GEOMETRY:
+ sel->gs_output_prim =
+ sel->info.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM][0];
+ sel->gs_max_out_vertices =
+ sel->info.properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES][0];
+
+ for (i = 0; i < sel->info.num_inputs; i++) {
+ unsigned name = sel->info.input_semantic_name[i];
+ unsigned index = sel->info.input_semantic_index[i];
+
+ switch (name) {
+ case TGSI_SEMANTIC_PRIMID:
+ break;
+ default:
+ sel->gs_used_inputs |=
+ 1llu << si_shader_io_get_unique_index(name, index);
+ }
+ }
+ }
+
return sel;
}
{
struct si_context *sctx = (struct si_context *)ctx;
unsigned gs_vert_itemsize = shader->noutput * (16 >> 2);
- unsigned gs_max_vert_out = shader->gs_max_out_vertices;
+ unsigned gs_max_vert_out = shader->selector->gs_max_out_vertices;
unsigned gsvs_itemsize = gs_vert_itemsize * gs_max_vert_out;
unsigned cut_mode;
struct si_pm4_state *pm4;
si_pm4_set_reg(pm4, R_028A68_VGT_GSVS_RING_OFFSET_3, gsvs_itemsize);
si_pm4_set_reg(pm4, R_028AAC_VGT_ESGS_RING_ITEMSIZE,
- shader->nparam * (16 >> 2));
+ util_bitcount64(shader->selector->gs_used_inputs) * (16 >> 2));
si_pm4_set_reg(pm4, R_028AB0_VGT_GSVS_RING_ITEMSIZE, gsvs_itemsize);
si_pm4_set_reg(pm4, R_028B38_VGT_GS_MAX_VERT_OUT, gs_max_vert_out);
unsigned prim = si_conv_pipe_prim(info->mode);
unsigned gs_out_prim =
si_conv_prim_to_gs_out(sctx->gs_shader ?
- sctx->gs_shader->current->gs_output_prim :
+ sctx->gs_shader->gs_output_prim :
info->mode);
unsigned ls_mask = 0;
unsigned ia_multi_vgt_param = si_get_ia_multi_vgt_param(sctx, info);
si_set_ring_buffer(ctx, PIPE_SHADER_GEOMETRY, SI_RING_GSVS,
sctx->gsvs_ring,
- sctx->gs_shader->current->gs_max_out_vertices *
+ sctx->gs_shader->gs_max_out_vertices *
sctx->gs_shader->current->noutput * 16,
64, true, true, 4, 16);