ac: add emit_vertex to the abi
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
@@ -3934,14 +3934,13 @@ static LLVMValueRef visit_interp(struct nir_to_llvm_context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
visit_emit_vertex(struct nir_to_llvm_context *ctx,
|
visit_emit_vertex(struct ac_shader_abi *abi, unsigned stream, LLVMValueRef *addrs)
|
||||||
const nir_intrinsic_instr *instr)
|
|
||||||
{
|
{
|
||||||
LLVMValueRef gs_next_vertex;
|
LLVMValueRef gs_next_vertex;
|
||||||
LLVMValueRef can_emit;
|
LLVMValueRef can_emit;
|
||||||
int idx;
|
int idx;
|
||||||
|
struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
|
||||||
|
|
||||||
assert(instr->const_index[0] == 0);
|
|
||||||
/* Write vertex attribute values to GSVS ring */
|
/* Write vertex attribute values to GSVS ring */
|
||||||
gs_next_vertex = LLVMBuildLoad(ctx->builder,
|
gs_next_vertex = LLVMBuildLoad(ctx->builder,
|
||||||
ctx->gs_next_vertex,
|
ctx->gs_next_vertex,
|
||||||
@@ -3959,7 +3958,7 @@ visit_emit_vertex(struct nir_to_llvm_context *ctx,
|
|||||||
/* loop num outputs */
|
/* loop num outputs */
|
||||||
idx = 0;
|
idx = 0;
|
||||||
for (unsigned i = 0; i < RADEON_LLVM_MAX_OUTPUTS; ++i) {
|
for (unsigned i = 0; i < RADEON_LLVM_MAX_OUTPUTS; ++i) {
|
||||||
LLVMValueRef *out_ptr = &ctx->nir->outputs[i * 4];
|
LLVMValueRef *out_ptr = &addrs[i * 4];
|
||||||
int length = 4;
|
int length = 4;
|
||||||
int slot = idx;
|
int slot = idx;
|
||||||
int slot_inc = 1;
|
int slot_inc = 1;
|
||||||
@@ -4197,7 +4196,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
|
|||||||
result = visit_interp(ctx->nctx, instr);
|
result = visit_interp(ctx->nctx, instr);
|
||||||
break;
|
break;
|
||||||
case nir_intrinsic_emit_vertex:
|
case nir_intrinsic_emit_vertex:
|
||||||
visit_emit_vertex(ctx->nctx, instr);
|
assert(instr->const_index[0] == 0);
|
||||||
|
ctx->abi->emit_vertex(ctx->abi, 0, ctx->outputs);
|
||||||
break;
|
break;
|
||||||
case nir_intrinsic_end_primitive:
|
case nir_intrinsic_end_primitive:
|
||||||
visit_end_primitive(ctx->nctx, instr);
|
visit_end_primitive(ctx->nctx, instr);
|
||||||
@@ -6527,6 +6527,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
|
|||||||
|
|
||||||
ctx.abi.inputs = &ctx.inputs[0];
|
ctx.abi.inputs = &ctx.inputs[0];
|
||||||
ctx.abi.emit_outputs = handle_shader_outputs_post;
|
ctx.abi.emit_outputs = handle_shader_outputs_post;
|
||||||
|
ctx.abi.emit_vertex = visit_emit_vertex;
|
||||||
ctx.abi.load_ssbo = radv_load_ssbo;
|
ctx.abi.load_ssbo = radv_load_ssbo;
|
||||||
ctx.abi.load_sampler_desc = radv_get_sampler_desc;
|
ctx.abi.load_sampler_desc = radv_get_sampler_desc;
|
||||||
ctx.abi.clamp_shadow_reference = false;
|
ctx.abi.clamp_shadow_reference = false;
|
||||||
|
@@ -58,6 +58,10 @@ struct ac_shader_abi {
|
|||||||
unsigned max_outputs,
|
unsigned max_outputs,
|
||||||
LLVMValueRef *addrs);
|
LLVMValueRef *addrs);
|
||||||
|
|
||||||
|
void (*emit_vertex)(struct ac_shader_abi *abi,
|
||||||
|
unsigned stream,
|
||||||
|
LLVMValueRef *addrs);
|
||||||
|
|
||||||
LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
|
LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -4038,15 +4038,14 @@ static unsigned si_llvm_get_stream(struct lp_build_tgsi_context *bld_base,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Emit one vertex from the geometry shader */
|
/* Emit one vertex from the geometry shader */
|
||||||
static void si_llvm_emit_vertex(
|
static void si_llvm_emit_vertex(struct ac_shader_abi *abi,
|
||||||
const struct lp_build_tgsi_action *action,
|
unsigned stream,
|
||||||
struct lp_build_tgsi_context *bld_base,
|
LLVMValueRef *addrs)
|
||||||
struct lp_build_emit_data *emit_data)
|
|
||||||
{
|
{
|
||||||
struct si_shader_context *ctx = si_shader_context(bld_base);
|
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
|
||||||
struct lp_build_context *uint = &bld_base->uint_bld;
|
struct tgsi_shader_info *info = &ctx->shader->selector->info;
|
||||||
|
struct lp_build_context *uint = &ctx->bld_base.uint_bld;
|
||||||
struct si_shader *shader = ctx->shader;
|
struct si_shader *shader = ctx->shader;
|
||||||
struct tgsi_shader_info *info = &shader->selector->info;
|
|
||||||
struct lp_build_if_state if_state;
|
struct lp_build_if_state if_state;
|
||||||
LLVMValueRef soffset = LLVMGetParam(ctx->main_fn,
|
LLVMValueRef soffset = LLVMGetParam(ctx->main_fn,
|
||||||
ctx->param_gs2vs_offset);
|
ctx->param_gs2vs_offset);
|
||||||
@@ -4054,9 +4053,6 @@ static void si_llvm_emit_vertex(
|
|||||||
LLVMValueRef can_emit;
|
LLVMValueRef can_emit;
|
||||||
unsigned chan, offset;
|
unsigned chan, offset;
|
||||||
int i;
|
int i;
|
||||||
unsigned stream;
|
|
||||||
|
|
||||||
stream = si_llvm_get_stream(bld_base, emit_data);
|
|
||||||
|
|
||||||
/* Write vertex attribute values to GSVS ring */
|
/* Write vertex attribute values to GSVS ring */
|
||||||
gs_next_vertex = LLVMBuildLoad(ctx->ac.builder,
|
gs_next_vertex = LLVMBuildLoad(ctx->ac.builder,
|
||||||
@@ -4084,14 +4080,12 @@ static void si_llvm_emit_vertex(
|
|||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
for (i = 0; i < info->num_outputs; i++) {
|
for (i = 0; i < info->num_outputs; i++) {
|
||||||
LLVMValueRef *out_ptr = ctx->outputs[i];
|
|
||||||
|
|
||||||
for (chan = 0; chan < 4; chan++) {
|
for (chan = 0; chan < 4; chan++) {
|
||||||
if (!(info->output_usagemask[i] & (1 << chan)) ||
|
if (!(info->output_usagemask[i] & (1 << chan)) ||
|
||||||
((info->output_streams[i] >> (2 * chan)) & 3) != stream)
|
((info->output_streams[i] >> (2 * chan)) & 3) != stream)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
LLVMValueRef out_val = LLVMBuildLoad(ctx->ac.builder, out_ptr[chan], "");
|
LLVMValueRef out_val = LLVMBuildLoad(ctx->ac.builder, addrs[4 * i + chan], "");
|
||||||
LLVMValueRef voffset =
|
LLVMValueRef voffset =
|
||||||
LLVMConstInt(ctx->i32, offset *
|
LLVMConstInt(ctx->i32, offset *
|
||||||
shader->selector->gs_max_out_vertices, 0);
|
shader->selector->gs_max_out_vertices, 0);
|
||||||
@@ -4122,6 +4116,18 @@ static void si_llvm_emit_vertex(
|
|||||||
lp_build_endif(&if_state);
|
lp_build_endif(&if_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Emit one vertex from the geometry shader */
|
||||||
|
static void si_tgsi_emit_vertex(
|
||||||
|
const struct lp_build_tgsi_action *action,
|
||||||
|
struct lp_build_tgsi_context *bld_base,
|
||||||
|
struct lp_build_emit_data *emit_data)
|
||||||
|
{
|
||||||
|
struct si_shader_context *ctx = si_shader_context(bld_base);
|
||||||
|
unsigned stream = si_llvm_get_stream(bld_base, emit_data);
|
||||||
|
|
||||||
|
si_llvm_emit_vertex(&ctx->abi, stream, ctx->outputs[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/* Cut one primitive from the geometry shader */
|
/* Cut one primitive from the geometry shader */
|
||||||
static void si_llvm_emit_primitive(
|
static void si_llvm_emit_primitive(
|
||||||
const struct lp_build_tgsi_action *action,
|
const struct lp_build_tgsi_action *action,
|
||||||
@@ -5644,7 +5650,7 @@ static void si_init_shader_ctx(struct si_shader_context *ctx,
|
|||||||
bld_base->op_actions[TGSI_OPCODE_READ_INVOC].fetch_args = read_invoc_fetch_args;
|
bld_base->op_actions[TGSI_OPCODE_READ_INVOC].fetch_args = read_invoc_fetch_args;
|
||||||
bld_base->op_actions[TGSI_OPCODE_READ_INVOC].emit = read_lane_emit;
|
bld_base->op_actions[TGSI_OPCODE_READ_INVOC].emit = read_lane_emit;
|
||||||
|
|
||||||
bld_base->op_actions[TGSI_OPCODE_EMIT].emit = si_llvm_emit_vertex;
|
bld_base->op_actions[TGSI_OPCODE_EMIT].emit = si_tgsi_emit_vertex;
|
||||||
bld_base->op_actions[TGSI_OPCODE_ENDPRIM].emit = si_llvm_emit_primitive;
|
bld_base->op_actions[TGSI_OPCODE_ENDPRIM].emit = si_llvm_emit_primitive;
|
||||||
bld_base->op_actions[TGSI_OPCODE_BARRIER].emit = si_llvm_emit_barrier;
|
bld_base->op_actions[TGSI_OPCODE_BARRIER].emit = si_llvm_emit_barrier;
|
||||||
}
|
}
|
||||||
@@ -5758,6 +5764,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
|
|||||||
break;
|
break;
|
||||||
case PIPE_SHADER_GEOMETRY:
|
case PIPE_SHADER_GEOMETRY:
|
||||||
bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
|
bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_gs;
|
||||||
|
ctx->abi.emit_vertex = si_llvm_emit_vertex;
|
||||||
bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
|
bld_base->emit_epilogue = si_llvm_emit_gs_epilogue;
|
||||||
break;
|
break;
|
||||||
case PIPE_SHADER_FRAGMENT:
|
case PIPE_SHADER_FRAGMENT:
|
||||||
|
Reference in New Issue
Block a user