ac: add build_alloca with an initializer
combining alloca_undef + BuildStore. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7542>
This commit is contained in:
@@ -3222,6 +3222,13 @@ LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMValueRef ac_build_alloca_init(struct ac_llvm_context *ac, LLVMValueRef val, const char *name)
|
||||||
|
{
|
||||||
|
LLVMValueRef ptr = ac_build_alloca_undef(ac, LLVMTypeOf(val), name);
|
||||||
|
LLVMBuildStore(ac->builder, val, ptr);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type)
|
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type)
|
||||||
{
|
{
|
||||||
int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
|
int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
|
||||||
|
@@ -470,6 +470,7 @@ void ac_build_ifcc(struct ac_llvm_context *ctx, LLVMValueRef cond, int label_id)
|
|||||||
|
|
||||||
LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
|
LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
|
||||||
LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
|
LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name);
|
||||||
|
LLVMValueRef ac_build_alloca_init(struct ac_llvm_context *ac, LLVMValueRef val, const char *name);
|
||||||
|
|
||||||
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type);
|
LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type);
|
||||||
|
|
||||||
|
@@ -132,8 +132,7 @@ static LLVMValueRef cull_bbox(struct ac_llvm_context *ctx, LLVMValueRef pos[3][4
|
|||||||
* W is negative.
|
* W is negative.
|
||||||
*/
|
*/
|
||||||
LLVMValueRef cond = LLVMBuildAnd(builder, initially_accepted, w->all_w_positive, "");
|
LLVMValueRef cond = LLVMBuildAnd(builder, initially_accepted, w->all_w_positive, "");
|
||||||
LLVMValueRef accepted_var = ac_build_alloca_undef(ctx, ctx->i1, "");
|
LLVMValueRef accepted_var = ac_build_alloca_init(ctx, initially_accepted, "");
|
||||||
LLVMBuildStore(builder, initially_accepted, accepted_var);
|
|
||||||
|
|
||||||
ac_build_ifcc(ctx, cond, 10000000 /* does this matter? */);
|
ac_build_ifcc(ctx, cond, 10000000 /* does this matter? */);
|
||||||
{
|
{
|
||||||
|
@@ -4877,9 +4877,8 @@ void ac_nir_translate(struct ac_llvm_context *ac, struct ac_shader_abi *abi,
|
|||||||
setup_shared(&ctx, nir);
|
setup_shared(&ctx, nir);
|
||||||
|
|
||||||
if (nir->info.stage == MESA_SHADER_FRAGMENT && nir->info.fs.uses_demote) {
|
if (nir->info.stage == MESA_SHADER_FRAGMENT && nir->info.fs.uses_demote) {
|
||||||
ctx.ac.postponed_kill = ac_build_alloca_undef(&ctx.ac, ac->i1, "");
|
|
||||||
/* true = don't kill. */
|
/* true = don't kill. */
|
||||||
LLVMBuildStore(ctx.ac.builder, ctx.ac.i1true, ctx.ac.postponed_kill);
|
ctx.ac.postponed_kill = ac_build_alloca_init(&ctx.ac, ctx.ac.i1true, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_cf_list(&ctx, &func->impl->body);
|
visit_cf_list(&ctx, &func->impl->body);
|
||||||
|
@@ -1055,13 +1055,13 @@ void gfx10_emit_ngg_culling_epilogue(struct ac_shader_abi *abi, unsigned max_out
|
|||||||
update_thread_counts(ctx, &new_num_es_threads, &new_gs_tg_info, 9, 12, &new_merged_wave_info, 8,
|
update_thread_counts(ctx, &new_num_es_threads, &new_gs_tg_info, 9, 12, &new_merged_wave_info, 8,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
/* Update vertex indices in VGPR0 (same format as NGG passthrough). */
|
/* Update vertex indices in VGPR0 (same format as NGG passthrough).
|
||||||
LLVMValueRef new_vgpr0 = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, "");
|
*
|
||||||
|
* Set the null flag at the beginning (culled), and then
|
||||||
/* Set the null flag at the beginning (culled), and then
|
|
||||||
* overwrite it for accepted primitives.
|
* overwrite it for accepted primitives.
|
||||||
*/
|
*/
|
||||||
LLVMBuildStore(builder, LLVMConstInt(ctx->ac.i32, 1u << 31, 0), new_vgpr0);
|
LLVMValueRef new_vgpr0 =
|
||||||
|
ac_build_alloca_init(&ctx->ac, LLVMConstInt(ctx->ac.i32, 1u << 31, 0), "");
|
||||||
|
|
||||||
/* Get vertex indices after vertex compaction. */
|
/* Get vertex indices after vertex compaction. */
|
||||||
ac_build_ifcc(&ctx->ac, LLVMBuildTrunc(builder, gs_accepted, ctx->ac.i1, ""), 16011);
|
ac_build_ifcc(&ctx->ac, LLVMBuildTrunc(builder, gs_accepted, ctx->ac.i1, ""), 16011);
|
||||||
@@ -1315,8 +1315,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, unsigned max_outputs, LL
|
|||||||
tmp = LLVMBuildLoad(builder, tmp, "");
|
tmp = LLVMBuildLoad(builder, tmp, "");
|
||||||
tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, "");
|
tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, "");
|
||||||
|
|
||||||
user_edgeflags[i] = ac_build_alloca_undef(&ctx->ac, ctx->ac.i1, "");
|
user_edgeflags[i] = ac_build_alloca_init(&ctx->ac, tmp, "");
|
||||||
LLVMBuildStore(builder, tmp, user_edgeflags[i]);
|
|
||||||
}
|
}
|
||||||
ac_build_endif(&ctx->ac, 5400);
|
ac_build_endif(&ctx->ac, 5400);
|
||||||
}
|
}
|
||||||
|
@@ -495,10 +495,9 @@ static void si_vertex_color_clamping(struct si_shader_context *ctx,
|
|||||||
outputs[i].semantic != VARYING_SLOT_BFC1)
|
outputs[i].semantic != VARYING_SLOT_BFC1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (unsigned j = 0; j < 4; j++) {
|
for (unsigned j = 0; j < 4; j++)
|
||||||
addr[i][j] = ac_build_alloca_undef(&ctx->ac, ctx->ac.f32, "");
|
addr[i][j] = ac_build_alloca_init(&ctx->ac, outputs[i].values[j], "");
|
||||||
LLVMBuildStore(ctx->ac.builder, outputs[i].values[j], addr[i][j]);
|
|
||||||
}
|
|
||||||
has_colors = true;
|
has_colors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user