From 594f085cfa46520e5590168fde1763439afee45a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 15 Jan 2020 17:25:06 -0500 Subject: [PATCH] radeonsi: use ctx->ac. for types and integer constants Reviewed-by: Timothy Arceri Part-of: --- .../drivers/radeonsi/gfx10_shader_ngg.c | 270 +++++++++--------- .../radeonsi/si_compute_prim_discard.c | 146 +++++----- src/gallium/drivers/radeonsi/si_shader.c | 184 ++++++------ .../drivers/radeonsi/si_shader_internal.h | 17 -- src/gallium/drivers/radeonsi/si_shader_llvm.c | 24 +- .../drivers/radeonsi/si_shader_llvm_build.c | 6 +- .../drivers/radeonsi/si_shader_llvm_gs.c | 76 ++--- .../drivers/radeonsi/si_shader_llvm_ps.c | 60 ++-- .../radeonsi/si_shader_llvm_resources.c | 54 ++-- .../drivers/radeonsi/si_shader_llvm_tess.c | 98 +++---- src/gallium/drivers/radeonsi/si_shader_nir.c | 2 +- 11 files changed, 449 insertions(+), 488 deletions(-) diff --git a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c index 02d51ec7d5b..852842d8059 100644 --- a/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c +++ b/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c @@ -69,7 +69,7 @@ static LLVMValueRef ngg_get_query_buf(struct si_shader_context *ctx) LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers); return ac_build_load_to_sgpr(&ctx->ac, buf_ptr, - LLVMConstInt(ctx->i32, GFX10_GS_QUERY_BUF, false)); + LLVMConstInt(ctx->ac.i32, GFX10_GS_QUERY_BUF, false)); } static LLVMValueRef ngg_get_initial_edgeflag(struct si_shader_context *ctx, unsigned index) @@ -81,7 +81,7 @@ static LLVMValueRef ngg_get_initial_edgeflag(struct si_shader_context *ctx, unsi LLVMConstInt(ctx->ac.i32, 8 + index, false), ""); return LLVMBuildTrunc(ctx->ac.builder, tmp, ctx->ac.i1, ""); } - return ctx->i1false; + return ctx->ac.i1false; } /** @@ -97,7 +97,7 @@ static LLVMValueRef ngg_get_vertices_per_prim(struct si_shader_context *ctx, if (info->properties[TGSI_PROPERTY_VS_BLIT_SGPRS_AMD]) { /* Blits always use axis-aligned rectangles with 3 vertices. */ *num_vertices = 3; - return LLVMConstInt(ctx->i32, 3, 0); + return LLVMConstInt(ctx->ac.i32, 3, 0); } else { /* We always build up all three indices for the prim export * independent of the primitive type. The additional garbage @@ -108,7 +108,7 @@ static LLVMValueRef ngg_get_vertices_per_prim(struct si_shader_context *ctx, /* Extract OUTPRIM field. */ LLVMValueRef num = si_unpack_param(ctx, ctx->vs_state_bits, 2, 2); - return LLVMBuildAdd(ctx->ac.builder, num, ctx->i32_1, ""); + return LLVMBuildAdd(ctx->ac.builder, num, ctx->ac.i32_1, ""); } } else { assert(ctx->type == PIPE_SHADER_TESS_EVAL); @@ -120,7 +120,7 @@ static LLVMValueRef ngg_get_vertices_per_prim(struct si_shader_context *ctx, else *num_vertices = 3; - return LLVMConstInt(ctx->i32, *num_vertices, false); + return LLVMConstInt(ctx->ac.i32, *num_vertices, false); } } @@ -163,7 +163,7 @@ void gfx10_ngg_build_export_prim(struct si_shader_context *ctx, */ if (ctx->shader->selector->info.writes_edgeflag) { unsigned all_bits_no_edgeflags = ~SI_NGG_PRIM_EDGE_FLAG_BITS; - LLVMValueRef edgeflags = LLVMConstInt(ctx->i32, all_bits_no_edgeflags, 0); + LLVMValueRef edgeflags = LLVMConstInt(ctx->ac.i32, all_bits_no_edgeflags, 0); unsigned num_vertices; ngg_get_vertices_per_prim(ctx, &num_vertices); @@ -173,8 +173,8 @@ void gfx10_ngg_build_export_prim(struct si_shader_context *ctx, LLVMValueRef edge; edge = LLVMBuildLoad(builder, user_edgeflags[i], ""); - edge = LLVMBuildZExt(builder, edge, ctx->i32, ""); - edge = LLVMBuildShl(builder, edge, LLVMConstInt(ctx->i32, shift, 0), ""); + edge = LLVMBuildZExt(builder, edge, ctx->ac.i32, ""); + edge = LLVMBuildShl(builder, edge, LLVMConstInt(ctx->ac.i32, shift, 0), ""); edgeflags = LLVMBuildOr(builder, edgeflags, edge, ""); } prim.passthrough = LLVMBuildAnd(builder, prim.passthrough, edgeflags, ""); @@ -230,9 +230,9 @@ static void build_streamout_vertex(struct si_shader_context *ctx, continue; tmp = LLVMBuildMul(builder, offset_vtx, - LLVMConstInt(ctx->i32, so->stride[buffer], false), ""); + LLVMConstInt(ctx->ac.i32, so->stride[buffer], false), ""); tmp = LLVMBuildAdd(builder, wg_offset_dw[buffer], tmp, ""); - offset[buffer] = LLVMBuildShl(builder, tmp, LLVMConstInt(ctx->i32, 2, false), ""); + offset[buffer] = LLVMBuildShl(builder, tmp, LLVMConstInt(ctx->ac.i32, 2, false), ""); } for (unsigned i = 0; i < so->num_outputs; ++i) { @@ -246,7 +246,7 @@ static void build_streamout_vertex(struct si_shader_context *ctx, for (unsigned comp = 0; comp < 4; comp++) { tmp = ac_build_gep0(&ctx->ac, vertexptr, - LLVMConstInt(ctx->i32, 4 * reg + comp, false)); + LLVMConstInt(ctx->ac.i32, 4 * reg + comp, false)); out.values[comp] = LLVMBuildLoad(builder, tmp, ""); out.vertex_stream[comp] = (info->output_streams[reg] >> (2 * comp)) & 3; @@ -285,19 +285,19 @@ static void build_streamout(struct si_shader_context *ctx, LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers); LLVMValueRef tid = get_thread_id_in_tg(ctx); LLVMValueRef tmp, tmp2; - LLVMValueRef i32_2 = LLVMConstInt(ctx->i32, 2, false); - LLVMValueRef i32_4 = LLVMConstInt(ctx->i32, 4, false); - LLVMValueRef i32_8 = LLVMConstInt(ctx->i32, 8, false); + LLVMValueRef i32_2 = LLVMConstInt(ctx->ac.i32, 2, false); + LLVMValueRef i32_4 = LLVMConstInt(ctx->ac.i32, 4, false); + LLVMValueRef i32_8 = LLVMConstInt(ctx->ac.i32, 8, false); LLVMValueRef so_buffer[4] = {}; unsigned max_num_vertices = 1 + (nggso->vertices[1] ? 1 : 0) + (nggso->vertices[2] ? 1 : 0); LLVMValueRef prim_stride_dw[4] = {}; - LLVMValueRef prim_stride_dw_vgpr = LLVMGetUndef(ctx->i32); + LLVMValueRef prim_stride_dw_vgpr = LLVMGetUndef(ctx->ac.i32); int stream_for_buffer[4] = { -1, -1, -1, -1 }; unsigned bufmask_for_stream[4] = {}; bool isgs = ctx->type == PIPE_SHADER_GEOMETRY; unsigned scratch_emit_base = isgs ? 4 : 0; - LLVMValueRef scratch_emit_basev = isgs ? i32_4 : ctx->i32_0; + LLVMValueRef scratch_emit_basev = isgs ? i32_4 : ctx->ac.i32_0; unsigned scratch_offset_base = isgs ? 8 : 4; LLVMValueRef scratch_offset_basev = isgs ? i32_8 : i32_4; @@ -318,26 +318,26 @@ static void build_streamout(struct si_shader_context *ctx, assert(so->stride[buffer]); - tmp = LLVMConstInt(ctx->i32, so->stride[buffer], false); + tmp = LLVMConstInt(ctx->ac.i32, so->stride[buffer], false); prim_stride_dw[buffer] = LLVMBuildMul(builder, tmp, nggso->num_vertices, ""); prim_stride_dw_vgpr = ac_build_writelane( &ctx->ac, prim_stride_dw_vgpr, prim_stride_dw[buffer], - LLVMConstInt(ctx->i32, buffer, false)); + LLVMConstInt(ctx->ac.i32, buffer, false)); so_buffer[buffer] = ac_build_load_to_sgpr( &ctx->ac, buf_ptr, - LLVMConstInt(ctx->i32, SI_VS_STREAMOUT_BUF0 + buffer, false)); + LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false)); } - tmp = LLVMBuildICmp(builder, LLVMIntEQ, get_wave_id_in_tg(ctx), ctx->i32_0, ""); + tmp = LLVMBuildICmp(builder, LLVMIntEQ, get_wave_id_in_tg(ctx), ctx->ac.i32_0, ""); ac_build_ifcc(&ctx->ac, tmp, 5200); { - LLVMTypeRef gdsptr = LLVMPointerType(ctx->i32, AC_ADDR_SPACE_GDS); - LLVMValueRef gdsbase = LLVMBuildIntToPtr(builder, ctx->i32_0, gdsptr, ""); + LLVMTypeRef gdsptr = LLVMPointerType(ctx->ac.i32, AC_ADDR_SPACE_GDS); + LLVMValueRef gdsbase = LLVMBuildIntToPtr(builder, ctx->ac.i32_0, gdsptr, ""); /* Advance the streamout offsets in GDS. */ - LLVMValueRef offsets_vgpr = ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); - LLVMValueRef generated_by_stream_vgpr = ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); + LLVMValueRef offsets_vgpr = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); + LLVMValueRef generated_by_stream_vgpr = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); tmp = LLVMBuildICmp(builder, LLVMIntULT, ac_get_thread_id(&ctx->ac), i32_4, ""); ac_build_ifcc(&ctx->ac, tmp, 5210); @@ -346,8 +346,8 @@ static void build_streamout(struct si_shader_context *ctx, tmp = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, tid); tmp = LLVMBuildLoad(builder, tmp, ""); } else { - tmp = ac_build_writelane(&ctx->ac, ctx->i32_0, - ngg_get_prim_cnt(ctx), ctx->i32_0); + tmp = ac_build_writelane(&ctx->ac, ctx->ac.i32_0, + ngg_get_prim_cnt(ctx), ctx->ac.i32_0); } LLVMBuildStore(builder, tmp, generated_by_stream_vgpr); @@ -375,15 +375,15 @@ static void build_streamout(struct si_shader_context *ctx, LLVMValueRef args[] = { LLVMBuildIntToPtr(builder, ngg_get_ordered_id(ctx), gdsptr, ""), tmp, - ctx->i32_0, // ordering - ctx->i32_0, // scope + ctx->ac.i32_0, // ordering + ctx->ac.i32_0, // scope ctx->ac.i1false, // isVolatile - LLVMConstInt(ctx->i32, 4 << 24, false), // OA index + LLVMConstInt(ctx->ac.i32, 4 << 24, false), // OA index ctx->ac.i1true, // wave release ctx->ac.i1true, // wave done }; tmp = ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.ds.ordered.add", - ctx->i32, args, ARRAY_SIZE(args), 0); + ctx->ac.i32, args, ARRAY_SIZE(args), 0); /* Keep offsets in a VGPR for quick retrieval via readlane by * the first wave for bounds checking, and also store in LDS @@ -414,13 +414,13 @@ static void build_streamout(struct si_shader_context *ctx, tmp = LLVMBuildLoad(builder, offsets_vgpr, ""); LLVMValueRef offset_dw = ac_build_readlane(&ctx->ac, tmp, - LLVMConstInt(ctx->i32, buffer, false)); + LLVMConstInt(ctx->ac.i32, buffer, false)); tmp = LLVMBuildSub(builder, bufsize_dw, offset_dw, ""); tmp = LLVMBuildUDiv(builder, tmp, prim_stride_dw[buffer], ""); tmp2 = LLVMBuildICmp(builder, LLVMIntULT, bufsize_dw, offset_dw, ""); - max_emit[buffer] = LLVMBuildSelect(builder, tmp2, ctx->i32_0, tmp, ""); + max_emit[buffer] = LLVMBuildSelect(builder, tmp2, ctx->ac.i32_0, tmp, ""); } /* Determine the number of emitted primitives per stream and fixup the @@ -429,7 +429,7 @@ static void build_streamout(struct si_shader_context *ctx, * This is complicated by the fact that a single stream can emit to * multiple buffers (but luckily not vice versa). */ - LLVMValueRef emit_vgpr = ctx->i32_0; + LLVMValueRef emit_vgpr = ctx->ac.i32_0; for (unsigned stream = 0; stream < 4; ++stream) { if (!info->num_stream_output_components[stream]) @@ -438,7 +438,7 @@ static void build_streamout(struct si_shader_context *ctx, tmp = LLVMBuildLoad(builder, generated_by_stream_vgpr, ""); LLVMValueRef generated = ac_build_readlane(&ctx->ac, tmp, - LLVMConstInt(ctx->i32, stream, false)); + LLVMConstInt(ctx->ac.i32, stream, false)); LLVMValueRef emit = generated; for (unsigned buffer = 0; buffer < 4; ++buffer) { @@ -447,15 +447,15 @@ static void build_streamout(struct si_shader_context *ctx, } emit_vgpr = ac_build_writelane(&ctx->ac, emit_vgpr, emit, - LLVMConstInt(ctx->i32, stream, false)); + LLVMConstInt(ctx->ac.i32, stream, false)); /* Fixup the offset using a plain GDS atomic if we overflowed. */ tmp = LLVMBuildICmp(builder, LLVMIntULT, emit, generated, ""); ac_build_ifcc(&ctx->ac, tmp, 5221); /* scalar branch */ tmp = LLVMBuildLShr(builder, - LLVMConstInt(ctx->i32, bufmask_for_stream[stream], false), + LLVMConstInt(ctx->ac.i32, bufmask_for_stream[stream], false), ac_get_thread_id(&ctx->ac), ""); - tmp = LLVMBuildTrunc(builder, tmp, ctx->i1, ""); + tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, ""); ac_build_ifcc(&ctx->ac, tmp, 5222); { tmp = LLVMBuildSub(builder, generated, emit, ""); @@ -494,7 +494,7 @@ static void build_streamout(struct si_shader_context *ctx, primemit_scan[stream].src = nggso->prim_enable[stream]; primemit_scan[stream].scratch = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, - LLVMConstInt(ctx->i32, 12 + 8 * stream, false)); + LLVMConstInt(ctx->ac.i32, 12 + 8 * stream, false)); primemit_scan[stream].waveidx = get_wave_id_in_tg(ctx); primemit_scan[stream].numwaves = get_tgsize(ctx); primemit_scan[stream].maxwaves = 8; @@ -517,7 +517,7 @@ static void build_streamout(struct si_shader_context *ctx, if (stream_for_buffer[buffer] >= 0) { wgoffset_dw[buffer] = ac_build_readlane( &ctx->ac, scratch_vgpr, - LLVMConstInt(ctx->i32, scratch_offset_base + buffer, false)); + LLVMConstInt(ctx->ac.i32, scratch_offset_base + buffer, false)); } } @@ -525,7 +525,7 @@ static void build_streamout(struct si_shader_context *ctx, if (info->num_stream_output_components[stream]) { nggso->emit[stream] = ac_build_readlane( &ctx->ac, scratch_vgpr, - LLVMConstInt(ctx->i32, scratch_emit_base + stream, false)); + LLVMConstInt(ctx->ac.i32, scratch_emit_base + stream, false)); } } } @@ -553,13 +553,13 @@ static void build_streamout(struct si_shader_context *ctx, for (unsigned i = 0; i < max_num_vertices; ++i) { tmp = LLVMBuildICmp(builder, LLVMIntULT, - LLVMConstInt(ctx->i32, i, false), + LLVMConstInt(ctx->ac.i32, i, false), nggso->num_vertices, ""); ac_build_ifcc(&ctx->ac, tmp, 5241); build_streamout_vertex(ctx, so_buffer, wgoffset_dw, stream, offset_vtx, nggso->vertices[i]); ac_build_endif(&ctx->ac, 5241); - offset_vtx = LLVMBuildAdd(builder, offset_vtx, ctx->i32_1, ""); + offset_vtx = LLVMBuildAdd(builder, offset_vtx, ctx->ac.i32_1, ""); } } ac_build_endif(&ctx->ac, 5240); @@ -603,8 +603,8 @@ static LLVMValueRef si_build_gep_i8(struct si_shader_context *ctx, LLVMValueRef ptr, unsigned byte_index) { assert(byte_index < 4); - LLVMTypeRef pi8 = LLVMPointerType(ctx->i8, AC_ADDR_SPACE_LDS); - LLVMValueRef index = LLVMConstInt(ctx->i32, byte_index, 0); + LLVMTypeRef pi8 = LLVMPointerType(ctx->ac.i8, AC_ADDR_SPACE_LDS); + LLVMValueRef index = LLVMConstInt(ctx->ac.i32, byte_index, 0); return LLVMBuildGEP(ctx->ac.builder, LLVMBuildPointerCast(ctx->ac.builder, ptr, pi8, ""), @@ -661,7 +661,7 @@ static LLVMValueRef ngg_nogs_vertex_ptr(struct si_shader_context *ctx, { /* The extra dword is used to avoid LDS bank conflicts. */ unsigned vertex_size = ngg_nogs_vertex_size(ctx->shader); - LLVMTypeRef ai32 = LLVMArrayType(ctx->i32, vertex_size); + LLVMTypeRef ai32 = LLVMArrayType(ctx->ac.i32, vertex_size); LLVMTypeRef pai32 = LLVMPointerType(ai32, AC_ADDR_SPACE_LDS); LLVMValueRef tmp = LLVMBuildBitCast(ctx->ac.builder, ctx->esgs_ring, pai32, ""); return LLVMBuildGEP(ctx->ac.builder, tmp, &vtxid, 1, ""); @@ -687,10 +687,10 @@ static void load_bitmasks_2x64(struct si_shader_context *ctx, { LLVMBuilderRef builder = ctx->ac.builder; LLVMValueRef ptr64 = LLVMBuildPointerCast(builder, lds_ptr, - LLVMPointerType(LLVMArrayType(ctx->i64, 2), + LLVMPointerType(LLVMArrayType(ctx->ac.i64, 2), AC_ADDR_SPACE_LDS), ""); for (unsigned i = 0; i < 2; i++) { - LLVMValueRef index = LLVMConstInt(ctx->i32, dw_offset / 2 + i, 0); + LLVMValueRef index = LLVMConstInt(ctx->ac.i32, dw_offset / 2 + i, 0); mask[i] = LLVMBuildLoad(builder, ac_build_gep0(&ctx->ac, ptr64, index), ""); } @@ -725,24 +725,24 @@ static void update_thread_counts(struct si_shader_context *ctx, /* Update the total thread count. */ unsigned tg_info_mask = ~(u_bit_consecutive(0, tg_info_num_bits) << tg_info_shift); *tg_info = LLVMBuildAnd(builder, *tg_info, - LLVMConstInt(ctx->i32, tg_info_mask, 0), ""); + LLVMConstInt(ctx->ac.i32, tg_info_mask, 0), ""); *tg_info = LLVMBuildOr(builder, *tg_info, LLVMBuildShl(builder, *new_num_threads, - LLVMConstInt(ctx->i32, tg_info_shift, 0), ""), ""); + LLVMConstInt(ctx->ac.i32, tg_info_shift, 0), ""), ""); /* Update the per-wave thread count. */ LLVMValueRef prev_threads = LLVMBuildMul(builder, get_wave_id_in_tg(ctx), - LLVMConstInt(ctx->i32, ctx->ac.wave_size, 0), ""); + LLVMConstInt(ctx->ac.i32, ctx->ac.wave_size, 0), ""); *new_num_threads = LLVMBuildSub(builder, *new_num_threads, prev_threads, ""); - *new_num_threads = ac_build_imax(&ctx->ac, *new_num_threads, ctx->i32_0); + *new_num_threads = ac_build_imax(&ctx->ac, *new_num_threads, ctx->ac.i32_0); *new_num_threads = ac_build_imin(&ctx->ac, *new_num_threads, - LLVMConstInt(ctx->i32, ctx->ac.wave_size, 0)); + LLVMConstInt(ctx->ac.i32, ctx->ac.wave_size, 0)); unsigned wave_info_mask = ~(u_bit_consecutive(0, wave_info_num_bits) << wave_info_shift); *wave_info = LLVMBuildAnd(builder, *wave_info, - LLVMConstInt(ctx->i32, wave_info_mask, 0), ""); + LLVMConstInt(ctx->ac.i32, wave_info_mask, 0), ""); *wave_info = LLVMBuildOr(builder, *wave_info, LLVMBuildShl(builder, *new_num_threads, - LLVMConstInt(ctx->i32, wave_info_shift, 0), ""), ""); + LLVMConstInt(ctx->ac.i32, wave_info_shift, 0), ""), ""); } /** @@ -784,14 +784,14 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, for (unsigned chan = 0; chan < 4; chan++) { LLVMBuildStore(builder, ac_to_integer(&ctx->ac, position[chan]), ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_pos_x + chan, 0))); + LLVMConstInt(ctx->ac.i32, lds_pos_x + chan, 0))); } /* Store Position.XY / W into LDS. */ for (unsigned chan = 0; chan < 2; chan++) { LLVMValueRef val = ac_build_fdiv(&ctx->ac, position[chan], position[3]); LLVMBuildStore(builder, ac_to_integer(&ctx->ac, val), ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_pos_x_div_w + chan, 0))); + LLVMConstInt(ctx->ac.i32, lds_pos_x_div_w + chan, 0))); } /* Store VertexID and InstanceID. ES threads will have to load them @@ -800,7 +800,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, */ bool uses_instance_id = false; bool uses_tes_prim_id = false; - LLVMValueRef packed_data = ctx->i32_0; + LLVMValueRef packed_data = ctx->ac.i32_0; if (ctx->type == PIPE_SHADER_VERTEX) { uses_instance_id = sel->info.uses_instanceid || @@ -809,11 +809,11 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, LLVMBuildStore(builder, ctx->abi.vertex_id, ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_vertex_id, 0))); + LLVMConstInt(ctx->ac.i32, lds_vertex_id, 0))); if (uses_instance_id) { LLVMBuildStore(builder, ctx->abi.instance_id, ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_instance_id, 0))); + LLVMConstInt(ctx->ac.i32, lds_instance_id, 0))); } } else { uses_tes_prim_id = sel->info.uses_primid || @@ -822,22 +822,22 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, assert(ctx->type == PIPE_SHADER_TESS_EVAL); LLVMBuildStore(builder, ac_to_integer(&ctx->ac, ac_get_arg(&ctx->ac, ctx->tes_u)), ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_tes_u, 0))); + LLVMConstInt(ctx->ac.i32, lds_tes_u, 0))); LLVMBuildStore(builder, ac_to_integer(&ctx->ac, ac_get_arg(&ctx->ac, ctx->tes_v)), ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_tes_v, 0))); + LLVMConstInt(ctx->ac.i32, lds_tes_v, 0))); packed_data = LLVMBuildShl(builder, ac_get_arg(&ctx->ac, ctx->tes_rel_patch_id), - LLVMConstInt(ctx->i32, lds_byte2_tes_rel_patch_id * 8, 0), ""); + LLVMConstInt(ctx->ac.i32, lds_byte2_tes_rel_patch_id * 8, 0), ""); if (uses_tes_prim_id) { LLVMBuildStore(builder, ac_get_arg(&ctx->ac, ctx->args.tes_patch_id), ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_tes_patch_id, 0))); + LLVMConstInt(ctx->ac.i32, lds_tes_patch_id, 0))); } } /* Initialize the packed data. */ LLVMBuildStore(builder, packed_data, ac_build_gep0(&ctx->ac, es_vtxptr, - LLVMConstInt(ctx->i32, lds_packed_data, 0))); + LLVMConstInt(ctx->ac.i32, lds_packed_data, 0))); ac_build_endif(&ctx->ac, ctx->merged_wrap_if_label); LLVMValueRef tid = ac_get_thread_id(&ctx->ac); @@ -850,10 +850,10 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, */ ac_build_ifcc(&ctx->ac, LLVMBuildICmp(builder, LLVMIntULT, get_thread_id_in_tg(ctx), - LLVMConstInt(ctx->i32, 3, 0), ""), 16101); + LLVMConstInt(ctx->ac.i32, 3, 0), ""), 16101); { - LLVMValueRef index = LLVMBuildAdd(builder, tid, ctx->i32_1, ""); - LLVMBuildStore(builder, ctx->i32_0, + LLVMValueRef index = LLVMBuildAdd(builder, tid, ctx->ac.i32_1, ""); + LLVMBuildStore(builder, ctx->ac.i32_0, ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, index)); } ac_build_endif(&ctx->ac, 16101); @@ -908,7 +908,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, }; es_vtxptr = ngg_nogs_vertex_ptr(ctx, get_thread_id_in_tg(ctx)); - LLVMValueRef gs_accepted = ac_build_alloca(&ctx->ac, ctx->i32, ""); + LLVMValueRef gs_accepted = ac_build_alloca(&ctx->ac, ctx->ac.i32, ""); /* Do culling in GS threads. */ ac_build_ifcc(&ctx->ac, si_is_gs_thread(ctx), 16002); @@ -926,7 +926,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, continue; LLVMValueRef addr = ac_build_gep0(&ctx->ac, gs_vtxptr[vtx], - LLVMConstInt(ctx->i32, index, 0)); + LLVMConstInt(ctx->ac.i32, index, 0)); pos[vtx][chan] = LLVMBuildLoad(builder, addr, ""); pos[vtx][chan] = ac_to_float(&ctx->ac, pos[vtx][chan]); } @@ -935,8 +935,8 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, /* Load the viewport state for small prim culling. */ LLVMValueRef vp = ac_build_load_invariant(&ctx->ac, ac_get_arg(&ctx->ac, ctx->small_prim_cull_info), - ctx->i32_0); - vp = LLVMBuildBitCast(builder, vp, ctx->v4f32, ""); + ctx->ac.i32_0); + vp = LLVMBuildBitCast(builder, vp, ctx->ac.v4f32, ""); LLVMValueRef vp_scale[2], vp_translate[2]; vp_scale[0] = ac_llvm_extract_elem(&ctx->ac, vp, 0); vp_scale[1] = ac_llvm_extract_elem(&ctx->ac, vp, 1); @@ -946,10 +946,10 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, /* Get the small prim filter precision. */ LLVMValueRef small_prim_precision = si_unpack_param(ctx, ctx->vs_state_bits, 7, 4); small_prim_precision = LLVMBuildOr(builder, small_prim_precision, - LLVMConstInt(ctx->i32, 0x70, 0), ""); + LLVMConstInt(ctx->ac.i32, 0x70, 0), ""); small_prim_precision = LLVMBuildShl(builder, small_prim_precision, - LLVMConstInt(ctx->i32, 23, 0), ""); - small_prim_precision = LLVMBuildBitCast(builder, small_prim_precision, ctx->f32, ""); + LLVMConstInt(ctx->ac.i32, 23, 0), ""); + small_prim_precision = LLVMBuildBitCast(builder, small_prim_precision, ctx->ac.f32, ""); /* Execute culling code. */ struct ac_cull_options options = {}; @@ -961,7 +961,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, options.cull_w = true; /* Tell ES threads whether their vertex survived. */ - ac_build_ifcc(&ctx->ac, ac_cull_triangle(&ctx->ac, pos, ctx->i1true, + ac_build_ifcc(&ctx->ac, ac_cull_triangle(&ctx->ac, pos, ctx->ac.i1true, vp_scale, vp_translate, small_prim_precision, &options), 16003); { @@ -978,7 +978,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, gs_accepted = LLVMBuildLoad(builder, gs_accepted, ""); - LLVMValueRef es_accepted = ac_build_alloca(&ctx->ac, ctx->i1, ""); + LLVMValueRef es_accepted = ac_build_alloca(&ctx->ac, ctx->ac.i1, ""); /* Convert the per-vertex flag to a thread bitmask in ES threads and store it in LDS. */ ac_build_ifcc(&ctx->ac, si_is_es_thread(ctx), 16007); @@ -994,7 +994,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, LLVMBuildStore(builder, es_accepted_bool, es_accepted); ac_build_ifcc(&ctx->ac, LLVMBuildICmp(builder, LLVMIntEQ, - tid, ctx->i32_0, ""), 16008); + tid, ctx->ac.i32_0, ""), 16008); { LLVMBuildStore(builder, es_mask, ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, @@ -1020,10 +1020,10 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, LLVMValueRef old_id = get_thread_id_in_tg(ctx); LLVMValueRef new_id = ac_prefix_bitcount_2x64(&ctx->ac, es_mask, old_id); - LLVMBuildStore(builder, LLVMBuildTrunc(builder, old_id, ctx->i8, ""), + LLVMBuildStore(builder, LLVMBuildTrunc(builder, old_id, ctx->ac.i8, ""), si_build_gep_i8(ctx, ngg_nogs_vertex_ptr(ctx, new_id), lds_byte0_old_thread_id)); - LLVMBuildStore(builder, LLVMBuildTrunc(builder, new_id, ctx->i8, ""), + LLVMBuildStore(builder, LLVMBuildTrunc(builder, new_id, ctx->ac.i8, ""), si_build_gep_i8(ctx, es_vtxptr, lds_byte1_new_thread_id)); } ac_build_endif(&ctx->ac, 16009); @@ -1032,14 +1032,14 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, kill_wave = LLVMBuildICmp(builder, LLVMIntULE, ac_build_imax(&ctx->ac, new_num_es_threads, ngg_get_prim_cnt(ctx)), LLVMBuildMul(builder, get_wave_id_in_tg(ctx), - LLVMConstInt(ctx->i32, ctx->ac.wave_size, 0), ""), ""); + LLVMConstInt(ctx->ac.i32, ctx->ac.wave_size, 0), ""), ""); ac_build_ifcc(&ctx->ac, kill_wave, 19202); { /* If we are killing wave 0, send that there are no primitives * in this threadgroup. */ ac_build_sendmsg_gs_alloc_req(&ctx->ac, get_wave_id_in_tg(ctx), - ctx->i32_0, ctx->i32_0); + ctx->ac.i32_0, ctx->ac.i32_0); ac_build_s_endpgm(&ctx->ac); } ac_build_endif(&ctx->ac, 19202); @@ -1058,26 +1058,26 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, &new_merged_wave_info, 8, 0); /* Update vertex indices in VGPR0 (same format as NGG passthrough). */ - LLVMValueRef new_vgpr0 = ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); + LLVMValueRef new_vgpr0 = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); /* Set the null flag at the beginning (culled), and then * overwrite it for accepted primitives. */ - LLVMBuildStore(builder, LLVMConstInt(ctx->i32, 1u << 31, 0), new_vgpr0); + LLVMBuildStore(builder, LLVMConstInt(ctx->ac.i32, 1u << 31, 0), new_vgpr0); /* Get vertex indices after vertex compaction. */ - ac_build_ifcc(&ctx->ac, LLVMBuildTrunc(builder, gs_accepted, ctx->i1, ""), 16011); + ac_build_ifcc(&ctx->ac, LLVMBuildTrunc(builder, gs_accepted, ctx->ac.i1, ""), 16011); { struct ac_ngg_prim prim = {}; prim.num_vertices = 3; - prim.isnull = ctx->i1false; + prim.isnull = ctx->ac.i1false; for (unsigned vtx = 0; vtx < 3; vtx++) { prim.index[vtx] = LLVMBuildLoad(builder, si_build_gep_i8(ctx, gs_vtxptr[vtx], lds_byte1_new_thread_id), ""); - prim.index[vtx] = LLVMBuildZExt(builder, prim.index[vtx], ctx->i32, ""); + prim.index[vtx] = LLVMBuildZExt(builder, prim.index[vtx], ctx->ac.i32, ""); prim.edgeflag[vtx] = ngg_get_initial_edgeflag(ctx, vtx); } @@ -1091,10 +1091,10 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, /* Set the new ES input VGPRs. */ LLVMValueRef es_data[4]; - LLVMValueRef old_thread_id = ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); + LLVMValueRef old_thread_id = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); for (unsigned i = 0; i < 4; i++) - es_data[i] = ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); + es_data[i] = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); ac_build_ifcc(&ctx->ac, LLVMBuildICmp(ctx->ac.builder, LLVMIntULT, tid, new_num_es_threads, ""), 16012); @@ -1104,7 +1104,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, /* Load ES input VGPRs from the ES thread before compaction. */ old_id = LLVMBuildLoad(builder, si_build_gep_i8(ctx, es_vtxptr, lds_byte0_old_thread_id), ""); - old_id = LLVMBuildZExt(builder, old_id, ctx->i32, ""); + old_id = LLVMBuildZExt(builder, old_id, ctx->ac.i32, ""); LLVMBuildStore(builder, old_id, old_thread_id); old_es_vtxptr = ngg_nogs_vertex_ptr(ctx, old_id); @@ -1112,7 +1112,7 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, for (unsigned i = 0; i < 2; i++) { tmp = LLVMBuildLoad(builder, ac_build_gep0(&ctx->ac, old_es_vtxptr, - LLVMConstInt(ctx->i32, lds_vertex_id + i, 0)), ""); + LLVMConstInt(ctx->ac.i32, lds_vertex_id + i, 0)), ""); LLVMBuildStore(builder, tmp, es_data[i]); } @@ -1120,13 +1120,13 @@ void gfx10_emit_ngg_culling_epilogue_4x_wave32(struct ac_shader_abi *abi, tmp = LLVMBuildLoad(builder, si_build_gep_i8(ctx, old_es_vtxptr, lds_byte2_tes_rel_patch_id), ""); - tmp = LLVMBuildZExt(builder, tmp, ctx->i32, ""); + tmp = LLVMBuildZExt(builder, tmp, ctx->ac.i32, ""); LLVMBuildStore(builder, tmp, es_data[2]); if (uses_tes_prim_id) { tmp = LLVMBuildLoad(builder, ac_build_gep0(&ctx->ac, old_es_vtxptr, - LLVMConstInt(ctx->i32, lds_tes_patch_id, 0)), ""); + LLVMConstInt(ctx->ac.i32, lds_tes_patch_id, 0)), ""); LLVMBuildStore(builder, tmp, es_data[3]); } } @@ -1269,7 +1269,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, */ if (sel->so.num_outputs) { tmp = ac_build_gep0(&ctx->ac, vertex_ptr, - LLVMConstInt(ctx->i32, 4 * i + j, false)); + LLVMConstInt(ctx->ac.i32, 4 * i + j, false)); tmp2 = LLVMBuildLoad(builder, addrs[4 * i + j], ""); tmp2 = ac_to_integer(&ctx->ac, tmp2); LLVMBuildStore(builder, tmp2, tmp); @@ -1281,10 +1281,10 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, sel->info.writes_edgeflag) { LLVMValueRef edgeflag = LLVMBuildLoad(builder, addrs[4 * i], ""); /* The output is a float, but the hw expects a 1-bit integer. */ - edgeflag = LLVMBuildFPToUI(ctx->ac.builder, edgeflag, ctx->i32, ""); - edgeflag = ac_build_umin(&ctx->ac, edgeflag, ctx->i32_1); + edgeflag = LLVMBuildFPToUI(ctx->ac.builder, edgeflag, ctx->ac.i32, ""); + edgeflag = ac_build_umin(&ctx->ac, edgeflag, ctx->ac.i32_1); - tmp = LLVMConstInt(ctx->i32, ngg_nogs_vertex_size(ctx->shader) - 1, 0); + tmp = LLVMConstInt(ctx->ac.i32, ngg_nogs_vertex_size(ctx->shader) - 1, 0); tmp = ac_build_gep0(&ctx->ac, vertex_ptr, tmp); LLVMBuildStore(builder, edgeflag, tmp); } @@ -1348,12 +1348,12 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, /* Load edge flags from ES threads and store them into VGPRs in GS threads. */ for (unsigned i = 0; i < num_vertices; i++) { tmp = ngg_nogs_vertex_ptr(ctx, vtxindex[i]); - tmp2 = LLVMConstInt(ctx->i32, ngg_nogs_vertex_size(ctx->shader) - 1, 0); + tmp2 = LLVMConstInt(ctx->ac.i32, ngg_nogs_vertex_size(ctx->shader) - 1, 0); tmp = ac_build_gep0(&ctx->ac, tmp, tmp2); tmp = LLVMBuildLoad(builder, tmp, ""); - tmp = LLVMBuildTrunc(builder, tmp, ctx->i1, ""); + tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, ""); - user_edgeflags[i] = ac_build_alloca_undef(&ctx->ac, ctx->i1, ""); + user_edgeflags[i] = ac_build_alloca_undef(&ctx->ac, ctx->ac.i1, ""); LLVMBuildStore(builder, tmp, user_edgeflags[i]); } ac_build_endif(&ctx->ac, 5400); @@ -1382,7 +1382,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, LLVMValueRef vertex_ptr = ngg_nogs_vertex_ptr(ctx, provoking_vtx_index); LLVMBuildStore(builder, ac_get_arg(&ctx->ac, ctx->args.gs_prim_id), - ac_build_gep0(&ctx->ac, vertex_ptr, ctx->i32_0)); + ac_build_gep0(&ctx->ac, vertex_ptr, ctx->ac.i32_0)); ac_build_endif(&ctx->ac, 5400); } @@ -1392,7 +1392,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, assert(!unterminated_es_if_block); tmp = si_unpack_param(ctx, ctx->vs_state_bits, 6, 1); - tmp = LLVMBuildTrunc(builder, tmp, ctx->i1, ""); + tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, ""); ac_build_ifcc(&ctx->ac, tmp, 5029); /* if (STREAMOUT_QUERY_ENABLED) */ tmp = LLVMBuildICmp(builder, LLVMIntEQ, get_wave_id_in_tg(ctx), ctx->ac.i32_0, ""); ac_build_ifcc(&ctx->ac, tmp, 5030); @@ -1403,20 +1403,20 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, LLVMValueRef args[] = { ngg_get_prim_cnt(ctx), ngg_get_query_buf(ctx), - LLVMConstInt(ctx->i32, 16, false), /* offset of stream[0].generated_primitives */ - ctx->i32_0, /* soffset */ - ctx->i32_0, /* cachepolicy */ + LLVMConstInt(ctx->ac.i32, 16, false), /* offset of stream[0].generated_primitives */ + ctx->ac.i32_0, /* soffset */ + ctx->ac.i32_0, /* cachepolicy */ }; if (sel->so.num_outputs) { - args[0] = ac_build_writelane(&ctx->ac, args[0], emitted_prims, ctx->i32_1); + args[0] = ac_build_writelane(&ctx->ac, args[0], emitted_prims, ctx->ac.i32_1); args[2] = ac_build_writelane(&ctx->ac, args[2], - LLVMConstInt(ctx->i32, 24, false), ctx->i32_1); + LLVMConstInt(ctx->ac.i32, 24, false), ctx->ac.i32_1); } /* TODO: should this be 64-bit atomics? */ ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.raw.buffer.atomic.add.i32", - ctx->i32, args, 5, 0); + ctx->ac.i32, args, 5, 0); } ac_build_endif(&ctx->ac, 5031); ac_build_endif(&ctx->ac, 5030); @@ -1447,7 +1447,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, ac_get_arg(&ctx->ac, ctx->ngg_old_thread_id)); for (unsigned j = 0; j < 4; j++) { - tmp = LLVMConstInt(ctx->i32, lds_pos_x + j, 0); + tmp = LLVMConstInt(ctx->ac.i32, lds_pos_x + j, 0); tmp = ac_build_gep0(&ctx->ac, vertex_ptr, tmp); tmp = LLVMBuildLoad(builder, tmp, ""); outputs[i].values[j] = ac_to_float(&ctx->ac, tmp); @@ -1470,7 +1470,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, ac_build_s_barrier(&ctx->ac); tmp = ngg_nogs_vertex_ptr(ctx, get_thread_id_in_tg(ctx)); - tmp = ac_build_gep0(&ctx->ac, tmp, ctx->i32_0); + tmp = ac_build_gep0(&ctx->ac, tmp, ctx->ac.i32_0); outputs[i].values[0] = LLVMBuildLoad(builder, tmp, ""); } else { assert(ctx->type == PIPE_SHADER_TESS_EVAL); @@ -1479,7 +1479,7 @@ void gfx10_emit_ngg_epilogue(struct ac_shader_abi *abi, outputs[i].values[0] = ac_to_float(&ctx->ac, outputs[i].values[0]); for (unsigned j = 1; j < 4; j++) - outputs[i].values[j] = LLVMGetUndef(ctx->f32); + outputs[i].values[j] = LLVMGetUndef(ctx->ac.f32); memset(outputs[i].vertex_stream, 0, sizeof(outputs[i].vertex_stream)); @@ -1614,7 +1614,7 @@ void gfx10_ngg_gs_emit_vertex(struct si_shader_context *ctx, */ const LLVMValueRef can_emit = LLVMBuildICmp(builder, LLVMIntULT, vertexidx, - LLVMConstInt(ctx->i32, sel->gs_max_out_vertices, false), ""); + LLVMConstInt(ctx->ac.i32, sel->gs_max_out_vertices, false), ""); tmp = LLVMBuildAdd(builder, vertexidx, ctx->ac.i32_1, ""); tmp = LLVMBuildSelect(builder, can_emit, tmp, vertexidx, ""); @@ -1650,10 +1650,10 @@ void gfx10_ngg_gs_emit_vertex(struct si_shader_context *ctx, * track which primitive is odd and swap vertex indices to get * the correct vertex order. */ - LLVMValueRef is_odd = ctx->i1false; + LLVMValueRef is_odd = ctx->ac.i1false; if (stream == 0 && u_vertices_per_prim(sel->gs_output_prim) == 3) { - tmp = LLVMBuildAnd(builder, curverts, ctx->i32_1, ""); - is_odd = LLVMBuildICmp(builder, LLVMIntEQ, tmp, ctx->i32_1, ""); + tmp = LLVMBuildAnd(builder, curverts, ctx->ac.i32_1, ""); + is_odd = LLVMBuildICmp(builder, LLVMIntEQ, tmp, ctx->ac.i32_1, ""); } tmp = LLVMBuildAdd(builder, curverts, ctx->ac.i32_1, ""); @@ -1687,11 +1687,11 @@ void gfx10_ngg_gs_emit_prologue(struct si_shader_context *ctx) LLVMValueRef tid = get_thread_id_in_tg(ctx); LLVMValueRef tmp; - tmp = LLVMBuildICmp(builder, LLVMIntULT, tid, LLVMConstInt(ctx->i32, 4, false), ""); + tmp = LLVMBuildICmp(builder, LLVMIntULT, tid, LLVMConstInt(ctx->ac.i32, 4, false), ""); ac_build_ifcc(&ctx->ac, tmp, 5090); { LLVMValueRef ptr = ac_build_gep0(&ctx->ac, scratchptr, tid); - LLVMBuildStore(builder, ctx->i32_0, ptr); + LLVMBuildStore(builder, ctx->ac.i32_0, ptr); } ac_build_endif(&ctx->ac, 5090); @@ -1748,12 +1748,12 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) LLVMBuildLoad(builder, ctx->gs_generated_prims[stream], ""); numprims = ac_build_reduce(&ctx->ac, numprims, nir_op_iadd, ctx->ac.wave_size); - tmp = LLVMBuildICmp(builder, LLVMIntEQ, ac_get_thread_id(&ctx->ac), ctx->i32_0, ""); + tmp = LLVMBuildICmp(builder, LLVMIntEQ, ac_get_thread_id(&ctx->ac), ctx->ac.i32_0, ""); ac_build_ifcc(&ctx->ac, tmp, 5105); { LLVMBuildAtomicRMW(builder, LLVMAtomicRMWBinOpAdd, ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, - LLVMConstInt(ctx->i32, stream, false)), + LLVMConstInt(ctx->ac.i32, stream, false)), numprims, LLVMAtomicOrderingMonotonic, false); } ac_build_endif(&ctx->ac, 5105); @@ -1770,7 +1770,7 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) if (sel->so.num_outputs) { struct ngg_streamout nggso = {}; - nggso.num_vertices = LLVMConstInt(ctx->i32, verts_per_prim, false); + nggso.num_vertices = LLVMConstInt(ctx->ac.i32, verts_per_prim, false); LLVMValueRef vertexptr = ngg_gs_vertex_ptr(ctx, tid); for (unsigned stream = 0; stream < 4; ++stream) { @@ -1778,16 +1778,16 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) continue; tmp = LLVMBuildLoad(builder, ngg_gs_get_emit_primflag_ptr(ctx, vertexptr, stream), ""); - tmp = LLVMBuildTrunc(builder, tmp, ctx->i1, ""); + tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, ""); tmp2 = LLVMBuildICmp(builder, LLVMIntULT, tid, num_emit_threads, ""); nggso.prim_enable[stream] = LLVMBuildAnd(builder, tmp, tmp2, ""); } for (unsigned i = 0; i < verts_per_prim; ++i) { tmp = LLVMBuildSub(builder, tid, - LLVMConstInt(ctx->i32, verts_per_prim - i - 1, false), ""); + LLVMConstInt(ctx->ac.i32, verts_per_prim - i - 1, false), ""); tmp = ngg_gs_vertex_ptr(ctx, tmp); - nggso.vertices[i] = ac_build_gep0(&ctx->ac, tmp, ctx->i32_0); + nggso.vertices[i] = ac_build_gep0(&ctx->ac, tmp, ctx->ac.i32_0); } build_streamout(ctx, &nggso); @@ -1796,21 +1796,21 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) /* Write shader query data. */ if (ctx->screen->use_ngg_streamout) { tmp = si_unpack_param(ctx, ctx->vs_state_bits, 6, 1); - tmp = LLVMBuildTrunc(builder, tmp, ctx->i1, ""); + tmp = LLVMBuildTrunc(builder, tmp, ctx->ac.i1, ""); ac_build_ifcc(&ctx->ac, tmp, 5109); /* if (STREAMOUT_QUERY_ENABLED) */ unsigned num_query_comps = sel->so.num_outputs ? 8 : 4; tmp = LLVMBuildICmp(builder, LLVMIntULT, tid, - LLVMConstInt(ctx->i32, num_query_comps, false), ""); + LLVMConstInt(ctx->ac.i32, num_query_comps, false), ""); ac_build_ifcc(&ctx->ac, tmp, 5110); { LLVMValueRef offset; tmp = tid; if (sel->so.num_outputs) - tmp = LLVMBuildAnd(builder, tmp, LLVMConstInt(ctx->i32, 3, false), ""); - offset = LLVMBuildNUWMul(builder, tmp, LLVMConstInt(ctx->i32, 32, false), ""); + tmp = LLVMBuildAnd(builder, tmp, LLVMConstInt(ctx->ac.i32, 3, false), ""); + offset = LLVMBuildNUWMul(builder, tmp, LLVMConstInt(ctx->ac.i32, 32, false), ""); if (sel->so.num_outputs) { - tmp = LLVMBuildLShr(builder, tid, LLVMConstInt(ctx->i32, 2, false), ""); - tmp = LLVMBuildNUWMul(builder, tmp, LLVMConstInt(ctx->i32, 8, false), ""); + tmp = LLVMBuildLShr(builder, tid, LLVMConstInt(ctx->ac.i32, 2, false), ""); + tmp = LLVMBuildNUWMul(builder, tmp, LLVMConstInt(ctx->ac.i32, 8, false), ""); offset = LLVMBuildAdd(builder, offset, tmp, ""); } @@ -1819,11 +1819,11 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) tmp, ngg_get_query_buf(ctx), offset, - LLVMConstInt(ctx->i32, 16, false), /* soffset */ - ctx->i32_0, /* cachepolicy */ + LLVMConstInt(ctx->ac.i32, 16, false), /* soffset */ + ctx->ac.i32_0, /* cachepolicy */ }; ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.raw.buffer.atomic.add.i32", - ctx->i32, args, 5, 0); + ctx->ac.i32, args, 5, 0); } ac_build_endif(&ctx->ac, 5110); ac_build_endif(&ctx->ac, 5109); @@ -1868,7 +1868,7 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) vertlive_scan.enable_reduce = true; vertlive_scan.enable_exclusive = true; vertlive_scan.src = vertlive; - vertlive_scan.scratch = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, ctx->i32_0); + vertlive_scan.scratch = ac_build_gep0(&ctx->ac, ctx->gs_ngg_scratch, ctx->ac.i32_0); vertlive_scan.waveidx = get_wave_id_in_tg(ctx); vertlive_scan.numwaves = get_tgsize(ctx); vertlive_scan.maxwaves = 8; @@ -1919,7 +1919,7 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) tmp = ngg_gs_vertex_ptr(ctx, tid); flags = LLVMBuildLoad(builder, ngg_gs_get_emit_primflag_ptr(ctx, tmp, 0), ""); - prim.isnull = LLVMBuildNot(builder, LLVMBuildTrunc(builder, flags, ctx->i1, ""), ""); + prim.isnull = LLVMBuildNot(builder, LLVMBuildTrunc(builder, flags, ctx->ac.i1, ""), ""); for (unsigned i = 0; i < verts_per_prim; ++i) { prim.index[i] = LLVMBuildSub(builder, vertlive_scan.result_exclusive, @@ -1930,11 +1930,11 @@ void gfx10_ngg_gs_emit_epilogue(struct si_shader_context *ctx) /* Geometry shaders output triangle strips, but NGG expects triangles. */ if (verts_per_prim == 3) { LLVMValueRef is_odd = LLVMBuildLShr(builder, flags, ctx->ac.i8_1, ""); - is_odd = LLVMBuildTrunc(builder, is_odd, ctx->i1, ""); + is_odd = LLVMBuildTrunc(builder, is_odd, ctx->ac.i1, ""); LLVMValueRef flatshade_first = LLVMBuildICmp(builder, LLVMIntEQ, si_unpack_param(ctx, ctx->vs_state_bits, 4, 2), - ctx->i32_0, ""); + ctx->ac.i32_0, ""); ac_build_triangle_strip_indices_to_triangle(&ctx->ac, is_odd, flatshade_first, diff --git a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c index 57c73e33a97..9b59570bf3f 100644 --- a/src/gallium/drivers/radeonsi/si_compute_prim_discard.c +++ b/src/gallium/drivers/radeonsi/si_compute_prim_discard.c @@ -243,28 +243,28 @@ si_build_ds_ordered_op(struct si_shader_context *ctx, const char *opcode, { LLVMValueRef args[] = { LLVMBuildIntToPtr(ctx->ac.builder, m0, - LLVMPointerType(ctx->i32, AC_ADDR_SPACE_GDS), ""), + LLVMPointerType(ctx->ac.i32, AC_ADDR_SPACE_GDS), ""), value, - LLVMConstInt(ctx->i32, LLVMAtomicOrderingMonotonic, 0), /* ordering */ - ctx->i32_0, /* scope */ - ctx->i1false, /* volatile */ - LLVMConstInt(ctx->i32, ordered_count_index, 0), - LLVMConstInt(ctx->i1, release, 0), - LLVMConstInt(ctx->i1, done, 0), + LLVMConstInt(ctx->ac.i32, LLVMAtomicOrderingMonotonic, 0), /* ordering */ + ctx->ac.i32_0, /* scope */ + ctx->ac.i1false, /* volatile */ + LLVMConstInt(ctx->ac.i32, ordered_count_index, 0), + LLVMConstInt(ctx->ac.i1, release, 0), + LLVMConstInt(ctx->ac.i1, done, 0), }; char intrinsic[64]; snprintf(intrinsic, sizeof(intrinsic), "llvm.amdgcn.ds.ordered.%s", opcode); - return ac_build_intrinsic(&ctx->ac, intrinsic, ctx->i32, args, ARRAY_SIZE(args), 0); + return ac_build_intrinsic(&ctx->ac, intrinsic, ctx->ac.i32, args, ARRAY_SIZE(args), 0); } static LLVMValueRef si_expand_32bit_pointer(struct si_shader_context *ctx, LLVMValueRef ptr) { uint64_t hi = (uint64_t)ctx->screen->info.address32_hi << 32; - ptr = LLVMBuildZExt(ctx->ac.builder, ptr, ctx->i64, ""); - ptr = LLVMBuildOr(ctx->ac.builder, ptr, LLVMConstInt(ctx->i64, hi, 0), ""); + ptr = LLVMBuildZExt(ctx->ac.builder, ptr, ctx->ac.i64, ""); + ptr = LLVMBuildOr(ctx->ac.builder, ptr, LLVMConstInt(ctx->ac.i64, hi, 0), ""); return LLVMBuildIntToPtr(ctx->ac.builder, ptr, - LLVMPointerType(ctx->i32, AC_ADDR_SPACE_GLOBAL), ""); + LLVMPointerType(ctx->ac.i32, AC_ADDR_SPACE_GLOBAL), ""); } struct si_thread0_section { @@ -279,7 +279,7 @@ static void si_enter_thread0_section(struct si_shader_context *ctx, LLVMValueRef thread_id) { section->ctx = ctx; - section->vgpr_result = ac_build_alloca_undef(&ctx->ac, ctx->i32, "result0"); + section->vgpr_result = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, "result0"); /* This IF has 4 instructions: * v_and_b32_e32 v, 63, v ; get the thread ID @@ -291,7 +291,7 @@ static void si_enter_thread0_section(struct si_shader_context *ctx, */ ac_build_ifcc(&ctx->ac, LLVMBuildICmp(ctx->ac.builder, LLVMIntEQ, thread_id, - ctx->i32_0, ""), 12601); + ctx->ac.i32_0, ""), 12601); } /* Exit a section that only executes on thread 0 and broadcast the result @@ -381,17 +381,17 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) vs_params[num_vs_params++] = LLVMGetUndef(LLVMTypeOf(LLVMGetParam(vs, 1))); /* BINDLESS */ vs_params[num_vs_params++] = ac_get_arg(&ctx->ac, param_const_desc); vs_params[num_vs_params++] = ac_get_arg(&ctx->ac, param_sampler_desc); - vs_params[num_vs_params++] = LLVMConstInt(ctx->i32, + vs_params[num_vs_params++] = LLVMConstInt(ctx->ac.i32, S_VS_STATE_INDEXED(key->opt.cs_indexed), 0); vs_params[num_vs_params++] = ac_get_arg(&ctx->ac, param_base_vertex); vs_params[num_vs_params++] = ac_get_arg(&ctx->ac, param_start_instance); - vs_params[num_vs_params++] = ctx->i32_0; /* DrawID */ + vs_params[num_vs_params++] = ctx->ac.i32_0; /* DrawID */ vs_params[num_vs_params++] = ac_get_arg(&ctx->ac, param_vb_desc); vs_params[(param_vertex_id = num_vs_params++)] = NULL; /* VertexID */ vs_params[(param_instance_id = num_vs_params++)] = NULL; /* InstanceID */ - vs_params[num_vs_params++] = ctx->i32_0; /* unused (PrimID) */ - vs_params[num_vs_params++] = ctx->i32_0; /* unused */ + vs_params[num_vs_params++] = ctx->ac.i32_0; /* unused (PrimID) */ + vs_params[num_vs_params++] = ctx->ac.i32_0; /* unused */ assert(num_vs_params <= ARRAY_SIZE(vs_params)); assert(num_vs_params == LLVMCountParamTypes(LLVMGetElementType(LLVMTypeOf(vs)))); @@ -401,8 +401,8 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) LLVMValueRef index_buffers_and_constants = ac_get_arg(&ctx->ac, param_index_buffers_and_constants); tmp = LLVMBuildPointerCast(builder, index_buffers_and_constants, - ac_array_in_const32_addr_space(ctx->v8i32), ""); - tmp = ac_build_load_to_sgpr(&ctx->ac, tmp, ctx->i32_0); + ac_array_in_const32_addr_space(ctx->ac.v8i32), ""); + tmp = ac_build_load_to_sgpr(&ctx->ac, tmp, ctx->ac.i32_0); for (unsigned i = 0; i < 8; i++) desc[i] = ac_llvm_extract_elem(&ctx->ac, tmp, i); @@ -413,10 +413,10 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* Compute PrimID and InstanceID. */ LLVMValueRef global_thread_id = ac_build_imad(&ctx->ac, ac_get_arg(&ctx->ac, param_block_id), - LLVMConstInt(ctx->i32, THREADGROUP_SIZE, 0), + LLVMConstInt(ctx->ac.i32, THREADGROUP_SIZE, 0), ac_get_arg(&ctx->ac, param_local_id)); LLVMValueRef prim_id = global_thread_id; /* PrimID within an instance */ - LLVMValueRef instance_id = ctx->i32_0; + LLVMValueRef instance_id = ctx->ac.i32_0; if (key->opt.cs_instancing) { LLVMValueRef num_prims_udiv_terms = @@ -425,9 +425,9 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) ac_get_arg(&ctx->ac, param_num_prims_udiv_multiplier); /* Unpack num_prims_udiv_terms. */ LLVMValueRef post_shift = LLVMBuildAnd(builder, num_prims_udiv_terms, - LLVMConstInt(ctx->i32, 0x1f, 0), ""); + LLVMConstInt(ctx->ac.i32, 0x1f, 0), ""); LLVMValueRef prims_per_instance = LLVMBuildLShr(builder, num_prims_udiv_terms, - LLVMConstInt(ctx->i32, 5, 0), ""); + LLVMConstInt(ctx->ac.i32, 5, 0), ""); /* Divide the total prim_id by the number of prims per instance. */ instance_id = ac_build_fast_udiv_u31_d_not_one(&ctx->ac, prim_id, num_prims_udiv_multiplier, @@ -439,21 +439,21 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) } /* Generate indices (like a non-indexed draw call). */ - LLVMValueRef index[4] = {NULL, NULL, NULL, LLVMGetUndef(ctx->i32)}; + LLVMValueRef index[4] = {NULL, NULL, NULL, LLVMGetUndef(ctx->ac.i32)}; unsigned vertices_per_prim = 3; switch (key->opt.cs_prim_type) { case PIPE_PRIM_TRIANGLES: for (unsigned i = 0; i < 3; i++) { index[i] = ac_build_imad(&ctx->ac, prim_id, - LLVMConstInt(ctx->i32, 3, 0), - LLVMConstInt(ctx->i32, i, 0)); + LLVMConstInt(ctx->ac.i32, 3, 0), + LLVMConstInt(ctx->ac.i32, i, 0)); } break; case PIPE_PRIM_TRIANGLE_STRIP: for (unsigned i = 0; i < 3; i++) { index[i] = LLVMBuildAdd(builder, prim_id, - LLVMConstInt(ctx->i32, i, 0), ""); + LLVMConstInt(ctx->ac.i32, i, 0), ""); } break; case PIPE_PRIM_TRIANGLE_FAN: @@ -463,13 +463,13 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) * gl_VertexID is preserved, because it's equal to the index. */ if (key->opt.cs_provoking_vertex_first) { - index[0] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->i32, 1, 0), ""); - index[1] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->i32, 2, 0), ""); - index[2] = ctx->i32_0; + index[0] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->ac.i32, 1, 0), ""); + index[1] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->ac.i32, 2, 0), ""); + index[2] = ctx->ac.i32_0; } else { - index[0] = ctx->i32_0; - index[1] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->i32, 1, 0), ""); - index[2] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->i32, 2, 0), ""); + index[0] = ctx->ac.i32_0; + index[1] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->ac.i32, 1, 0), ""); + index[2] = LLVMBuildAdd(builder, prim_id, LLVMConstInt(ctx->ac.i32, 2, 0), ""); } break; default: @@ -480,7 +480,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) if (key->opt.cs_indexed) { for (unsigned i = 0; i < 3; i++) { index[i] = ac_build_buffer_load_format(&ctx->ac, input_indexbuf, - index[i], ctx->i32_0, 1, + index[i], ctx->ac.i32_0, 1, 0, true); index[i] = ac_to_integer(&ctx->ac, index[i]); } @@ -491,20 +491,20 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* Extract the ordered wave ID. */ if (VERTEX_COUNTER_GDS_MODE == 2) { ordered_wave_id = LLVMBuildLShr(builder, ordered_wave_id, - LLVMConstInt(ctx->i32, 6, 0), ""); + LLVMConstInt(ctx->ac.i32, 6, 0), ""); ordered_wave_id = LLVMBuildAnd(builder, ordered_wave_id, - LLVMConstInt(ctx->i32, 0xfff, 0), ""); + LLVMConstInt(ctx->ac.i32, 0xfff, 0), ""); } LLVMValueRef thread_id = LLVMBuildAnd(builder, ac_get_arg(&ctx->ac, param_local_id), - LLVMConstInt(ctx->i32, 63, 0), ""); + LLVMConstInt(ctx->ac.i32, 63, 0), ""); /* Every other triangle in a strip has a reversed vertex order, so we * need to swap vertices of odd primitives to get the correct primitive * orientation when converting triangle strips to triangles. Primitive * restart complicates it, because a strip can start anywhere. */ - LLVMValueRef prim_restart_accepted = ctx->i1true; + LLVMValueRef prim_restart_accepted = ctx->ac.i1true; LLVMValueRef vertex_counter = ac_get_arg(&ctx->ac, param_vertex_counter); if (key->opt.cs_prim_type == PIPE_PRIM_TRIANGLE_STRIP) { @@ -512,7 +512,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) * Only primitive restart can flip it with respect to the first vertex * of the draw call. */ - LLVMValueRef first_is_odd = ctx->i1false; + LLVMValueRef first_is_odd = ctx->ac.i1false; /* Handle primitive restart. */ if (key->opt.cs_primitive_restart) { @@ -523,11 +523,11 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) */ LLVMValueRef gds_prim_restart_continue = LLVMBuildLShr(builder, vertex_counter, - LLVMConstInt(ctx->i32, 31, 0), ""); + LLVMConstInt(ctx->ac.i32, 31, 0), ""); gds_prim_restart_continue = - LLVMBuildTrunc(builder, gds_prim_restart_continue, ctx->i1, ""); + LLVMBuildTrunc(builder, gds_prim_restart_continue, ctx->ac.i1, ""); vertex_counter = LLVMBuildAnd(builder, vertex_counter, - LLVMConstInt(ctx->i32, 0x7fffffff, 0), ""); + LLVMConstInt(ctx->ac.i32, 0x7fffffff, 0), ""); LLVMValueRef index0_is_reset; @@ -554,7 +554,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) LLVMValueRef preceding_threads_mask = LLVMBuildSub(builder, LLVMBuildShl(builder, ctx->ac.i64_1, - LLVMBuildZExt(builder, thread_id, ctx->i64, ""), ""), + LLVMBuildZExt(builder, thread_id, ctx->ac.i64, ""), ""), ctx->ac.i64_1, ""); LLVMValueRef reset_threadmask = ac_get_i1_sgpr_mask(&ctx->ac, index0_is_reset); @@ -562,10 +562,10 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) LLVMBuildAnd(builder, reset_threadmask, preceding_threads_mask, ""); LLVMValueRef strip_start = ac_build_umsb(&ctx->ac, preceding_reset_threadmask, NULL); - strip_start = LLVMBuildAdd(builder, strip_start, ctx->i32_1, ""); + strip_start = LLVMBuildAdd(builder, strip_start, ctx->ac.i32_1, ""); /* This flips the orientatino based on reset indices within this wave only. */ - first_is_odd = LLVMBuildTrunc(builder, strip_start, ctx->i1, ""); + first_is_odd = LLVMBuildTrunc(builder, strip_start, ctx->ac.i1, ""); LLVMValueRef last_strip_start, prev_wave_state, ret, tmp; LLVMValueRef is_first_wave, current_wave_resets_index; @@ -579,7 +579,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) * be 64. */ last_strip_start = ac_build_umsb(&ctx->ac, reset_threadmask, NULL); - last_strip_start = LLVMBuildAdd(builder, last_strip_start, ctx->i32_1, ""); + last_strip_start = LLVMBuildAdd(builder, last_strip_start, ctx->ac.i32_1, ""); struct si_thread0_section section; si_enter_thread0_section(ctx, §ion, thread_id); @@ -591,14 +591,14 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) * NOTE: This will need to be different if we wanna support * instancing with primitive restart. */ - is_first_wave = LLVMBuildICmp(builder, LLVMIntEQ, prim_id, ctx->i32_0, ""); + is_first_wave = LLVMBuildICmp(builder, LLVMIntEQ, prim_id, ctx->ac.i32_0, ""); is_first_wave = LLVMBuildAnd(builder, is_first_wave, LLVMBuildNot(builder, gds_prim_restart_continue, ""), ""); current_wave_resets_index = LLVMBuildICmp(builder, LLVMIntNE, - last_strip_start, ctx->i32_0, ""); + last_strip_start, ctx->ac.i32_0, ""); - ret = ac_build_alloca_undef(&ctx->ac, ctx->i32, "prev_state"); + ret = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, "prev_state"); /* Save the last strip start primitive index in GDS and read * the value that previous waves stored. @@ -624,7 +624,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) { /* Just read the value from GDS. */ tmp = si_build_ds_ordered_op(ctx, "add", - ordered_wave_id, ctx->i32_0, + ordered_wave_id, ctx->ac.i32_0, 1, true, false); LLVMBuildStore(builder, tmp, ret); } @@ -633,9 +633,9 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) prev_wave_state = LLVMBuildLoad(builder, ret, ""); /* Ignore the return value if this is the first wave. */ prev_wave_state = LLVMBuildSelect(builder, is_first_wave, - ctx->i32_0, prev_wave_state, ""); + ctx->ac.i32_0, prev_wave_state, ""); si_exit_thread0_section(§ion, &prev_wave_state); - prev_wave_state = LLVMBuildTrunc(builder, prev_wave_state, ctx->i1, ""); + prev_wave_state = LLVMBuildTrunc(builder, prev_wave_state, ctx->ac.i1, ""); /* If the strip start appears to be on thread 0 for the current primitive * (meaning the reset index is not present in this wave and might have @@ -646,7 +646,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) * the value from the current wave to determine primitive orientation. */ LLVMValueRef strip_start_is0 = LLVMBuildICmp(builder, LLVMIntEQ, - strip_start, ctx->i32_0, ""); + strip_start, ctx->ac.i32_0, ""); first_is_odd = LLVMBuildSelect(builder, strip_start_is0, prev_wave_state, first_is_odd, ""); } @@ -654,11 +654,11 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* prim_is_odd = (first_is_odd + current_is_odd) % 2. */ LLVMValueRef prim_is_odd = LLVMBuildXor(builder, first_is_odd, - LLVMBuildTrunc(builder, thread_id, ctx->i1, ""), ""); + LLVMBuildTrunc(builder, thread_id, ctx->ac.i1, ""), ""); /* Convert triangle strip indices to triangle indices. */ ac_build_triangle_strip_indices_to_triangle(&ctx->ac, prim_is_odd, - LLVMConstInt(ctx->i1, key->opt.cs_provoking_vertex_first, 0), + LLVMConstInt(ctx->ac.i1, key->opt.cs_provoking_vertex_first, 0), index); } @@ -681,8 +681,8 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* Load the viewport state. */ LLVMValueRef vp = ac_build_load_invariant(&ctx->ac, index_buffers_and_constants, - LLVMConstInt(ctx->i32, 2, 0)); - vp = LLVMBuildBitCast(builder, vp, ctx->v4f32, ""); + LLVMConstInt(ctx->ac.i32, 2, 0)); + vp = LLVMBuildBitCast(builder, vp, ctx->ac.v4f32, ""); LLVMValueRef vp_scale[2], vp_translate[2]; vp_scale[0] = ac_llvm_extract_elem(&ctx->ac, vp, 0); vp_scale[1] = ac_llvm_extract_elem(&ctx->ac, vp, 1); @@ -712,9 +712,9 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* Count the number of active threads by doing bitcount(accepted). */ LLVMValueRef num_prims_accepted = - ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i64", ctx->i64, + ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i64", ctx->ac.i64, &accepted_threadmask, 1, AC_FUNC_ATTR_READNONE); - num_prims_accepted = LLVMBuildTrunc(builder, num_prims_accepted, ctx->i32, ""); + num_prims_accepted = LLVMBuildTrunc(builder, num_prims_accepted, ctx->ac.i32, ""); LLVMValueRef start; @@ -724,21 +724,21 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) { if (VERTEX_COUNTER_GDS_MODE == 0) { LLVMValueRef num_indices = LLVMBuildMul(builder, num_prims_accepted, - LLVMConstInt(ctx->i32, vertices_per_prim, 0), ""); + LLVMConstInt(ctx->ac.i32, vertices_per_prim, 0), ""); vertex_counter = si_expand_32bit_pointer(ctx, vertex_counter); start = LLVMBuildAtomicRMW(builder, LLVMAtomicRMWBinOpAdd, vertex_counter, num_indices, LLVMAtomicOrderingMonotonic, false); } else if (VERTEX_COUNTER_GDS_MODE == 1) { LLVMValueRef num_indices = LLVMBuildMul(builder, num_prims_accepted, - LLVMConstInt(ctx->i32, vertices_per_prim, 0), ""); + LLVMConstInt(ctx->ac.i32, vertices_per_prim, 0), ""); vertex_counter = LLVMBuildIntToPtr(builder, vertex_counter, - LLVMPointerType(ctx->i32, AC_ADDR_SPACE_GDS), ""); + LLVMPointerType(ctx->ac.i32, AC_ADDR_SPACE_GDS), ""); start = LLVMBuildAtomicRMW(builder, LLVMAtomicRMWBinOpAdd, vertex_counter, num_indices, LLVMAtomicOrderingMonotonic, false); } else if (VERTEX_COUNTER_GDS_MODE == 2) { - LLVMValueRef tmp_store = ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); + LLVMValueRef tmp_store = ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); /* If the draw call was split into multiple subdraws, each using * a separate draw packet, we need to start counting from 0 for @@ -769,7 +769,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* The GDS address is always 0 with ordered append. */ si_build_ds_ordered_op(ctx, "swap", ordered_wave_id, num_prims_accepted, 0, true, true); - LLVMBuildStore(builder, ctx->i32_0, tmp_store); + LLVMBuildStore(builder, ctx->ac.i32_0, tmp_store); } ac_build_else(&ctx->ac, 12605); { @@ -798,7 +798,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) 12606); LLVMValueRef count = LLVMBuildAdd(builder, start, num_prims_accepted, ""); count = LLVMBuildMul(builder, count, - LLVMConstInt(ctx->i32, vertices_per_prim, 0), ""); + LLVMConstInt(ctx->ac.i32, vertices_per_prim, 0), ""); /* GFX8 needs to disable caching, so that the CP can see the stored value. * MTYPE=3 bypasses TC L2. @@ -806,15 +806,15 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) if (ctx->screen->info.chip_class <= GFX8) { LLVMValueRef desc[] = { ac_get_arg(&ctx->ac, param_vertex_count_addr), - LLVMConstInt(ctx->i32, + LLVMConstInt(ctx->ac.i32, S_008F04_BASE_ADDRESS_HI(ctx->screen->info.address32_hi), 0), - LLVMConstInt(ctx->i32, 4, 0), - LLVMConstInt(ctx->i32, S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32) | + LLVMConstInt(ctx->ac.i32, 4, 0), + LLVMConstInt(ctx->ac.i32, S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32) | S_008F0C_MTYPE(3 /* uncached */), 0), }; LLVMValueRef rsrc = ac_build_gather_values(&ctx->ac, desc, 4); - ac_build_buffer_store_dword(&ctx->ac, rsrc, count, 1, ctx->i32_0, - ctx->i32_0, 0, ac_glc | ac_slc); + ac_build_buffer_store_dword(&ctx->ac, rsrc, count, 1, ctx->ac.i32_0, + ctx->ac.i32_0, 0, ac_glc | ac_slc); } else { LLVMBuildStore(builder, count, si_expand_32bit_pointer(ctx, @@ -827,7 +827,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) * primitive count, convert it into the primitive index. */ start = LLVMBuildUDiv(builder, start, - LLVMConstInt(ctx->i32, vertices_per_prim, 0), ""); + LLVMConstInt(ctx->ac.i32, vertices_per_prim, 0), ""); } /* Now we need to store the indices of accepted primitives into @@ -841,7 +841,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) /* We have lowered instancing. Pack the instance ID into vertex ID. */ if (key->opt.cs_instancing) { instance_id = LLVMBuildShl(builder, instance_id, - LLVMConstInt(ctx->i32, 16, 0), ""); + LLVMConstInt(ctx->ac.i32, 16, 0), ""); for (unsigned i = 0; i < vertices_per_prim; i++) index[i] = LLVMBuildOr(builder, index[i], instance_id, ""); @@ -867,7 +867,7 @@ void si_build_prim_discard_compute_shader(struct si_shader_context *ctx) vdata = ac_build_expand_to_vec4(&ctx->ac, vdata, 3); ac_build_buffer_store_format(&ctx->ac, output_indexbuf, vdata, - vindex, ctx->i32_0, 3, + vindex, ctx->ac.i32_0, 3, ac_glc | (INDEX_STORES_USE_SLC ? ac_slc : 0)); } ac_build_endif(&ctx->ac, 16607); diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index daaf7722942..65daaa5dc0b 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -160,12 +160,12 @@ static LLVMValueRef unpack_llvm_param(struct si_shader_context *ctx, if (rshift) value = LLVMBuildLShr(ctx->ac.builder, value, - LLVMConstInt(ctx->i32, rshift, 0), ""); + LLVMConstInt(ctx->ac.i32, rshift, 0), ""); if (rshift + bitwidth < 32) { unsigned mask = (1 << bitwidth) - 1; value = LLVMBuildAnd(ctx->ac.builder, value, - LLVMConstInt(ctx->i32, mask, 0), ""); + LLVMConstInt(ctx->ac.i32, mask, 0), ""); } return value; @@ -187,12 +187,12 @@ static LLVMValueRef unpack_sint16(struct si_shader_context *ctx, if (index == 1) return LLVMBuildAShr(ctx->ac.builder, i32, - LLVMConstInt(ctx->i32, 16, 0), ""); + LLVMConstInt(ctx->ac.i32, 16, 0), ""); return LLVMBuildSExt(ctx->ac.builder, LLVMBuildTrunc(ctx->ac.builder, i32, ctx->ac.i16, ""), - ctx->i32, ""); + ctx->ac.i32, ""); } void si_llvm_load_input_vs( @@ -207,13 +207,13 @@ void si_llvm_load_input_vs( LLVMValueRef vertex_id = ctx->abi.vertex_id; LLVMValueRef sel_x1 = LLVMBuildICmp(ctx->ac.builder, LLVMIntULE, vertex_id, - ctx->i32_1, ""); + ctx->ac.i32_1, ""); /* Use LLVMIntNE, because we have 3 vertices and only * the middle one should use y2. */ LLVMValueRef sel_y1 = LLVMBuildICmp(ctx->ac.builder, LLVMIntNE, vertex_id, - ctx->i32_1, ""); + ctx->ac.i32_1, ""); unsigned param_vs_blit_inputs = ctx->vs_blit_inputs.arg_index; if (input_index == 0) { @@ -233,8 +233,8 @@ void si_llvm_load_input_vs( LLVMValueRef y = LLVMBuildSelect(ctx->ac.builder, sel_y1, y1, y2, ""); - out[0] = LLVMBuildSIToFP(ctx->ac.builder, x, ctx->f32, ""); - out[1] = LLVMBuildSIToFP(ctx->ac.builder, y, ctx->f32, ""); + out[0] = LLVMBuildSIToFP(ctx->ac.builder, x, ctx->ac.f32, ""); + out[1] = LLVMBuildSIToFP(ctx->ac.builder, y, ctx->ac.f32, ""); out[2] = LLVMGetParam(ctx->main_fn, param_vs_blit_inputs + 2); out[3] = ctx->ac.f32_1; @@ -284,7 +284,7 @@ void si_llvm_load_input_vs( unsigned index= input_index - num_vbos_in_user_sgprs; vb_desc = ac_build_load_to_sgpr(&ctx->ac, ac_get_arg(&ctx->ac, ctx->vertex_buffers), - LLVMConstInt(ctx->i32, index, 0)); + LLVMConstInt(ctx->ac.i32, index, 0)); } vertex_index = LLVMGetParam(ctx->main_fn, @@ -308,7 +308,7 @@ void si_llvm_load_input_vs( fix_fetch.u.format, fix_fetch.u.reverse, !opencode, vb_desc, vertex_index, ctx->ac.i32_0, ctx->ac.i32_0, 0, true); for (unsigned i = 0; i < 4; ++i) - out[i] = LLVMBuildExtractElement(ctx->ac.builder, tmp, LLVMConstInt(ctx->i32, i, false), ""); + out[i] = LLVMBuildExtractElement(ctx->ac.builder, tmp, LLVMConstInt(ctx->ac.i32, i, false), ""); return; } @@ -330,7 +330,7 @@ void si_llvm_load_input_vs( } for (unsigned i = 0; i < num_fetches; ++i) { - LLVMValueRef voffset = LLVMConstInt(ctx->i32, fetch_stride * i, 0); + LLVMValueRef voffset = LLVMConstInt(ctx->ac.i32, fetch_stride * i, 0); fetches[i] = ac_build_buffer_load_format(&ctx->ac, vb_desc, vertex_index, voffset, channels_per_fetch, 0, true); } @@ -338,7 +338,7 @@ void si_llvm_load_input_vs( if (num_fetches == 1 && channels_per_fetch > 1) { LLVMValueRef fetch = fetches[0]; for (unsigned i = 0; i < channels_per_fetch; ++i) { - tmp = LLVMConstInt(ctx->i32, i, false); + tmp = LLVMConstInt(ctx->ac.i32, i, false); fetches[i] = LLVMBuildExtractElement( ctx->ac.builder, fetch, tmp, ""); } @@ -347,7 +347,7 @@ void si_llvm_load_input_vs( } for (unsigned i = num_fetches; i < 4; ++i) - fetches[i] = LLVMGetUndef(ctx->f32); + fetches[i] = LLVMGetUndef(ctx->ac.f32); if (fix_fetch.u.log_size <= 1 && fix_fetch.u.num_channels_m1 == 2 && required_channels == 4) { @@ -364,11 +364,11 @@ void si_llvm_load_input_vs( * convert it to a signed one. */ LLVMValueRef tmp = fetches[3]; - LLVMValueRef c30 = LLVMConstInt(ctx->i32, 30, 0); + LLVMValueRef c30 = LLVMConstInt(ctx->ac.i32, 30, 0); /* First, recover the sign-extended signed integer value. */ if (fix_fetch.u.format == AC_FETCH_FORMAT_SSCALED) - tmp = LLVMBuildFPToUI(ctx->ac.builder, tmp, ctx->i32, ""); + tmp = LLVMBuildFPToUI(ctx->ac.builder, tmp, ctx->ac.i32, ""); else tmp = ac_to_integer(&ctx->ac, tmp); @@ -380,18 +380,18 @@ void si_llvm_load_input_vs( */ tmp = LLVMBuildShl(ctx->ac.builder, tmp, fix_fetch.u.format == AC_FETCH_FORMAT_SNORM ? - LLVMConstInt(ctx->i32, 7, 0) : c30, ""); + LLVMConstInt(ctx->ac.i32, 7, 0) : c30, ""); tmp = LLVMBuildAShr(ctx->ac.builder, tmp, c30, ""); /* Convert back to the right type. */ if (fix_fetch.u.format == AC_FETCH_FORMAT_SNORM) { LLVMValueRef clamp; - LLVMValueRef neg_one = LLVMConstReal(ctx->f32, -1.0); - tmp = LLVMBuildSIToFP(ctx->ac.builder, tmp, ctx->f32, ""); + LLVMValueRef neg_one = LLVMConstReal(ctx->ac.f32, -1.0); + tmp = LLVMBuildSIToFP(ctx->ac.builder, tmp, ctx->ac.f32, ""); clamp = LLVMBuildFCmp(ctx->ac.builder, LLVMRealULT, tmp, neg_one, ""); tmp = LLVMBuildSelect(ctx->ac.builder, clamp, neg_one, tmp, ""); } else if (fix_fetch.u.format == AC_FETCH_FORMAT_SSCALED) { - tmp = LLVMBuildSIToFP(ctx->ac.builder, tmp, ctx->f32, ""); + tmp = LLVMBuildSIToFP(ctx->ac.builder, tmp, ctx->ac.f32, ""); } fetches[3] = tmp; @@ -405,7 +405,7 @@ LLVMValueRef si_get_primitive_id(struct si_shader_context *ctx, unsigned swizzle) { if (swizzle > 0) - return ctx->i32_0; + return ctx->ac.i32_0; switch (ctx->type) { case PIPE_SHADER_VERTEX: @@ -418,7 +418,7 @@ LLVMValueRef si_get_primitive_id(struct si_shader_context *ctx, return ac_get_arg(&ctx->ac, ctx->args.gs_prim_id); default: assert(0); - return ctx->i32_0; + return ctx->ac.i32_0; } } @@ -434,12 +434,12 @@ static LLVMValueRef get_base_vertex(struct ac_shader_abi *abi) ctx->vs_state_bits); LLVMValueRef indexed; - indexed = LLVMBuildLShr(ctx->ac.builder, vs_state, ctx->i32_1, ""); - indexed = LLVMBuildTrunc(ctx->ac.builder, indexed, ctx->i1, ""); + indexed = LLVMBuildLShr(ctx->ac.builder, vs_state, ctx->ac.i32_1, ""); + indexed = LLVMBuildTrunc(ctx->ac.builder, indexed, ctx->ac.i1, ""); return LLVMBuildSelect(ctx->ac.builder, indexed, ac_get_arg(&ctx->ac, ctx->args.base_vertex), - ctx->i32_0, ""); + ctx->ac.i32_0, ""); } static LLVMValueRef get_block_size(struct ac_shader_abi *abi) @@ -459,7 +459,7 @@ static LLVMValueRef get_block_size(struct ac_shader_abi *abi) }; for (i = 0; i < 3; ++i) - values[i] = LLVMConstInt(ctx->i32, sizes[i], 0); + values[i] = LLVMConstInt(ctx->ac.i32, sizes[i], 0); result = ac_build_gather_values(&ctx->ac, values, 3); } else { @@ -474,13 +474,13 @@ void si_declare_compute_memory(struct si_shader_context *ctx) struct si_shader_selector *sel = ctx->shader->selector; unsigned lds_size = sel->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE]; - LLVMTypeRef i8p = LLVMPointerType(ctx->i8, AC_ADDR_SPACE_LDS); + LLVMTypeRef i8p = LLVMPointerType(ctx->ac.i8, AC_ADDR_SPACE_LDS); LLVMValueRef var; assert(!ctx->ac.lds); var = LLVMAddGlobalInAddressSpace(ctx->ac.module, - LLVMArrayType(ctx->i8, lds_size), + LLVMArrayType(ctx->ac.i8, lds_size), "compute_lds", AC_ADDR_SPACE_LDS); LLVMSetAlignment(var, 64 * 1024); @@ -511,7 +511,7 @@ static void si_llvm_emit_clipvertex(struct si_shader_context *ctx, unsigned const_chan; LLVMValueRef base_elt; LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers); - LLVMValueRef constbuf_index = LLVMConstInt(ctx->i32, + LLVMValueRef constbuf_index = LLVMConstInt(ctx->ac.i32, SI_VS_CONST_CLIP_PLANES, 0); LLVMValueRef const_resource = ac_build_load_to_sgpr(&ctx->ac, ptr, constbuf_index); @@ -521,13 +521,13 @@ static void si_llvm_emit_clipvertex(struct si_shader_context *ctx, args->out[0] = args->out[1] = args->out[2] = - args->out[3] = LLVMConstReal(ctx->f32, 0.0f); + args->out[3] = LLVMConstReal(ctx->ac.f32, 0.0f); /* Compute dot products of position and user clip plane vectors */ for (chan = 0; chan < 4; chan++) { for (const_chan = 0; const_chan < 4; const_chan++) { LLVMValueRef addr = - LLVMConstInt(ctx->i32, ((reg_index * 4 + chan) * 4 + + LLVMConstInt(ctx->ac.i32, ((reg_index * 4 + chan) * 4 + const_chan) * 4, 0); base_elt = si_buffer_load_const(ctx, const_resource, addr); @@ -601,7 +601,7 @@ void si_emit_streamout_output(struct si_shader_context *ctx, break; } /* as v4i32 (aligned to 4) */ - out[3] = LLVMGetUndef(ctx->i32); + out[3] = LLVMGetUndef(ctx->ac.i32); /* fall through */ case 4: /* as v4i32 */ vdata = ac_build_gather_values(&ctx->ac, out, util_next_power_of_two(num_comps)); @@ -611,7 +611,7 @@ void si_emit_streamout_output(struct si_shader_context *ctx, ac_build_buffer_store_dword(&ctx->ac, so_buffers[buf_idx], vdata, num_comps, so_write_offsets[buf_idx], - ctx->i32_0, + ctx->ac.i32_0, stream_out->dst_offset * 4, ac_glc | ac_slc); } @@ -667,17 +667,17 @@ void si_llvm_emit_streamout(struct si_shader_context *ctx, if (!so->stride[i]) continue; - LLVMValueRef offset = LLVMConstInt(ctx->i32, + LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + i, 0); so_buffers[i] = ac_build_load_to_sgpr(&ctx->ac, buf_ptr, offset); LLVMValueRef so_offset = ac_get_arg(&ctx->ac, ctx->streamout_offset[i]); - so_offset = LLVMBuildMul(builder, so_offset, LLVMConstInt(ctx->i32, 4, 0), ""); + so_offset = LLVMBuildMul(builder, so_offset, LLVMConstInt(ctx->ac.i32, 4, 0), ""); so_write_offset[i] = ac_build_imad(&ctx->ac, so_write_index, - LLVMConstInt(ctx->i32, so->stride[i]*4, 0), + LLVMConstInt(ctx->ac.i32, so->stride[i]*4, 0), so_offset); } @@ -777,7 +777,7 @@ static void si_vertex_color_clamping(struct si_shader_context *ctx, continue; for (unsigned j = 0; j < 4; j++) { - addr[i][j] = ac_build_alloca_undef(&ctx->ac, ctx->f32, ""); + addr[i][j] = ac_build_alloca_undef(&ctx->ac, ctx->ac.f32, ""); LLVMBuildStore(ctx->ac.builder, outputs[i].values[j], addr[i][j]); } has_colors = true; @@ -788,7 +788,7 @@ static void si_vertex_color_clamping(struct si_shader_context *ctx, /* The state is in the first bit of the user SGPR. */ LLVMValueRef cond = ac_get_arg(&ctx->ac, ctx->vs_state_bits); - cond = LLVMBuildTrunc(ctx->ac.builder, cond, ctx->i1, ""); + cond = LLVMBuildTrunc(ctx->ac.builder, cond, ctx->ac.i1, ""); ac_build_ifcc(&ctx->ac, cond, 6502); @@ -912,10 +912,10 @@ void si_llvm_export_vs(struct si_shader_context *ctx, * with the first bit containing the edge flag. */ edgeflag_value = LLVMBuildFPToUI(ctx->ac.builder, edgeflag_value, - ctx->i32, ""); + ctx->ac.i32, ""); edgeflag_value = ac_build_umin(&ctx->ac, edgeflag_value, - ctx->i32_1); + ctx->ac.i32_1); /* The LLVM intrinsic expects a float. */ pos_args[1].out[1] = ac_to_float(&ctx->ac, edgeflag_value); @@ -933,7 +933,7 @@ void si_llvm_export_vs(struct si_shader_context *ctx, v = ac_to_integer(&ctx->ac, v); v = LLVMBuildShl(ctx->ac.builder, v, - LLVMConstInt(ctx->i32, 16, 0), ""); + LLVMConstInt(ctx->ac.i32, 16, 0), ""); v = LLVMBuildOr(ctx->ac.builder, v, ac_to_integer(&ctx->ac, pos_args[1].out[2]), ""); pos_args[1].out[2] = ac_to_float(&ctx->ac, v); @@ -1019,7 +1019,7 @@ static void si_llvm_emit_vs_epilogue(struct ac_shader_abi *abi, outputs[i].semantic_index = 0; outputs[i].values[0] = ac_to_float(&ctx->ac, si_get_primitive_id(ctx, 0)); for (j = 1; j < 4; j++) - outputs[i].values[j] = LLVMConstReal(ctx->f32, 0); + outputs[i].values[j] = LLVMConstReal(ctx->ac.f32, 0); memset(outputs[i].vertex_stream, 0, sizeof(outputs[i].vertex_stream)); @@ -1341,7 +1341,7 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) /* Return values */ if (shader->key.opt.vs_as_prim_discard_cs) { for (i = 0; i < 4; i++) - returns[num_returns++] = ctx->f32; /* VGPRs */ + returns[num_returns++] = ctx->ac.f32; /* VGPRs */ } break; @@ -1363,9 +1363,9 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) * placed after the user SGPRs. */ for (i = 0; i < GFX6_TCS_NUM_USER_SGPR + 2; i++) - returns[num_returns++] = ctx->i32; /* SGPRs */ + returns[num_returns++] = ctx->ac.i32; /* SGPRs */ for (i = 0; i < 11; i++) - returns[num_returns++] = ctx->f32; /* VGPRs */ + returns[num_returns++] = ctx->ac.f32; /* VGPRs */ break; case SI_SHADER_MERGED_VERTEX_TESSCTRL: @@ -1399,9 +1399,9 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) /* LS return values are inputs to the TCS main shader part. */ for (i = 0; i < 8 + GFX9_TCS_NUM_USER_SGPR; i++) - returns[num_returns++] = ctx->i32; /* SGPRs */ + returns[num_returns++] = ctx->ac.i32; /* SGPRs */ for (i = 0; i < 2; i++) - returns[num_returns++] = ctx->f32; /* VGPRs */ + returns[num_returns++] = ctx->ac.f32; /* VGPRs */ } else { /* TCS return values are inputs to the TCS epilog. * @@ -1410,9 +1410,9 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) * should be passed to the epilog. */ for (i = 0; i <= 8 + GFX9_SGPR_TCS_OUT_LAYOUT; i++) - returns[num_returns++] = ctx->i32; /* SGPRs */ + returns[num_returns++] = ctx->ac.i32; /* SGPRs */ for (i = 0; i < 11; i++) - returns[num_returns++] = ctx->f32; /* VGPRs */ + returns[num_returns++] = ctx->ac.f32; /* VGPRs */ } break; @@ -1498,9 +1498,9 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) /* ES return values are inputs to GS. */ for (i = 0; i < 8 + num_user_sgprs; i++) - returns[num_returns++] = ctx->i32; /* SGPRs */ + returns[num_returns++] = ctx->ac.i32; /* SGPRs */ for (i = 0; i < num_vgprs; i++) - returns[num_returns++] = ctx->f32; /* VGPRs */ + returns[num_returns++] = ctx->ac.f32; /* VGPRs */ } break; @@ -1610,9 +1610,9 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) PS_EPILOG_SAMPLEMASK_MIN_LOC + 1); for (i = 0; i < num_return_sgprs; i++) - returns[i] = ctx->i32; + returns[i] = ctx->ac.i32; for (; i < num_returns; i++) - returns[i] = ctx->f32; + returns[i] = ctx->ac.f32; break; case PIPE_SHADER_COMPUTE: @@ -1683,7 +1683,7 @@ void si_create_function(struct si_shader_context *ctx, bool ngg_cull_shader) * own LDS-based lowering). */ ctx->ac.lds = LLVMAddGlobalInAddressSpace( - ctx->ac.module, LLVMArrayType(ctx->i32, 0), + ctx->ac.module, LLVMArrayType(ctx->ac.i32, 0), "__lds_end", AC_ADDR_SPACE_LDS); LLVMSetAlignment(ctx->ac.lds, 256); } else { @@ -2279,11 +2279,11 @@ static void si_init_exec_from_input(struct si_shader_context *ctx, { LLVMValueRef args[] = { ac_get_arg(&ctx->ac, param), - LLVMConstInt(ctx->i32, bitoffset, 0), + LLVMConstInt(ctx->ac.i32, bitoffset, 0), }; ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.init.exec.from.input", - ctx->voidt, args, 2, AC_FUNC_ATTR_CONVERGENT); + ctx->ac.voidt, args, 2, AC_FUNC_ATTR_CONVERGENT); } static bool si_vs_needs_prolog(const struct si_shader_selector *sel, @@ -2367,14 +2367,14 @@ static bool si_build_main_function(struct si_shader_context *ctx, sel->info.tessfactors_are_def_in_all_invocs) { for (unsigned i = 0; i < 6; i++) { ctx->invoc0_tess_factors[i] = - ac_build_alloca_undef(&ctx->ac, ctx->i32, ""); + ac_build_alloca_undef(&ctx->ac, ctx->ac.i32, ""); } } if (ctx->type == PIPE_SHADER_GEOMETRY) { for (unsigned i = 0; i < 4; i++) { ctx->gs_next_vertex[i] = - ac_build_alloca(&ctx->ac, ctx->i32, ""); + ac_build_alloca(&ctx->ac, ctx->ac.i32, ""); } if (shader->key.as_ngg) { for (unsigned i = 0; i < 4; ++i) { @@ -2389,14 +2389,14 @@ static bool si_build_main_function(struct si_shader_context *ctx, scratch_size = 44; assert(!ctx->gs_ngg_scratch); - LLVMTypeRef ai32 = LLVMArrayType(ctx->i32, scratch_size); + LLVMTypeRef ai32 = LLVMArrayType(ctx->ac.i32, scratch_size); ctx->gs_ngg_scratch = LLVMAddGlobalInAddressSpace(ctx->ac.module, ai32, "ngg_scratch", AC_ADDR_SPACE_LDS); LLVMSetInitializer(ctx->gs_ngg_scratch, LLVMGetUndef(ai32)); LLVMSetAlignment(ctx->gs_ngg_scratch, 4); ctx->gs_ngg_emit = LLVMAddGlobalInAddressSpace(ctx->ac.module, - LLVMArrayType(ctx->i32, 0), "ngg_emit", AC_ADDR_SPACE_LDS); + LLVMArrayType(ctx->ac.i32, 0), "ngg_emit", AC_ADDR_SPACE_LDS); LLVMSetLinkage(ctx->gs_ngg_emit, LLVMExternalLinkage); LLVMSetAlignment(ctx->gs_ngg_emit, 4); } @@ -2419,7 +2419,7 @@ static bool si_build_main_function(struct si_shader_context *ctx, */ if (!ctx->gs_ngg_scratch && (sel->so.num_outputs || shader->key.opt.ngg_culling)) { - LLVMTypeRef asi32 = LLVMArrayType(ctx->i32, 8); + LLVMTypeRef asi32 = LLVMArrayType(ctx->ac.i32, 8); ctx->gs_ngg_scratch = LLVMAddGlobalInAddressSpace(ctx->ac.module, asi32, "ngg_scratch", AC_ADDR_SPACE_LDS); LLVMSetInitializer(ctx->gs_ngg_scratch, LLVMGetUndef(asi32)); @@ -2520,9 +2520,9 @@ static bool si_build_main_function(struct si_shader_context *ctx, } if (sel->force_correct_derivs_after_kill) { - ctx->postponed_kill = ac_build_alloca_undef(&ctx->ac, ctx->i1, ""); + ctx->postponed_kill = ac_build_alloca_undef(&ctx->ac, ctx->ac.i1, ""); /* true = don't kill. */ - LLVMBuildStore(ctx->ac.builder, ctx->i1true, + LLVMBuildStore(ctx->ac.builder, ctx->ac.i1true, ctx->postponed_kill); } @@ -2663,7 +2663,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part arg_type = AC_ARG_CONST_IMAGE_PTR; else assert(0); - } else if (type == ctx->f32) { + } else if (type == ctx->ac.f32) { arg_type = AC_ARG_CONST_FLOAT_PTR; } else { assert(0); @@ -2714,13 +2714,13 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part for (unsigned i = 0; i < ctx->args.arg_count; ++i) { LLVMValueRef param = LLVMGetParam(ctx->main_fn, i); LLVMTypeRef param_type = LLVMTypeOf(param); - LLVMTypeRef out_type = ctx->args.args[i].file == AC_ARG_SGPR ? ctx->i32 : ctx->f32; + LLVMTypeRef out_type = ctx->args.args[i].file == AC_ARG_SGPR ? ctx->ac.i32 : ctx->ac.f32; unsigned size = ac_get_type_size(param_type) / 4; if (size == 1) { if (LLVMGetTypeKind(param_type) == LLVMPointerTypeKind) { - param = LLVMBuildPtrToInt(builder, param, ctx->i32, ""); - param_type = ctx->i32; + param = LLVMBuildPtrToInt(builder, param, ctx->ac.i32, ""); + param_type = ctx->ac.i32; } if (param_type != out_type) @@ -2730,8 +2730,8 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part LLVMTypeRef vector_type = LLVMVectorType(out_type, size); if (LLVMGetTypeKind(param_type) == LLVMPointerTypeKind) { - param = LLVMBuildPtrToInt(builder, param, ctx->i64, ""); - param_type = ctx->i64; + param = LLVMBuildPtrToInt(builder, param, ctx->ac.i64, ""); + param_type = ctx->ac.i64; } if (param_type != vector_type) @@ -2739,7 +2739,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part for (unsigned j = 0; j < size; ++j) out[num_out++] = LLVMBuildExtractElement( - builder, param, LLVMConstInt(ctx->i32, j, 0), ""); + builder, param, LLVMConstInt(ctx->ac.i32, j, 0), ""); } if (ctx->args.args[i].file == AC_ARG_SGPR) @@ -2764,7 +2764,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part LLVMValueRef ena, count = initial[3]; count = LLVMBuildAnd(builder, count, - LLVMConstInt(ctx->i32, 0x7f, 0), ""); + LLVMConstInt(ctx->ac.i32, 0x7f, 0), ""); ena = LLVMBuildICmp(builder, LLVMIntULT, ac_get_thread_id(&ctx->ac), count, ""); ac_build_ifcc(&ctx->ac, ena, 6506); @@ -2805,10 +2805,10 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part if (LLVMGetTypeKind(param_type) == LLVMPointerTypeKind) { if (LLVMGetPointerAddressSpace(param_type) == AC_ADDR_SPACE_CONST_32BIT) { - arg = LLVMBuildBitCast(builder, arg, ctx->i32, ""); + arg = LLVMBuildBitCast(builder, arg, ctx->ac.i32, ""); arg = LLVMBuildIntToPtr(builder, arg, param_type, ""); } else { - arg = LLVMBuildBitCast(builder, arg, ctx->i64, ""); + arg = LLVMBuildBitCast(builder, arg, ctx->ac.i64, ""); arg = LLVMBuildIntToPtr(builder, arg, param_type, ""); } } else { @@ -2857,7 +2857,7 @@ void si_build_wrapper_function(struct si_shader_context *ctx, LLVMValueRef *part assert(num_out < ARRAY_SIZE(out)); out[num_out++] = val; - if (LLVMTypeOf(val) == ctx->i32) { + if (LLVMTypeOf(val) == ctx->ac.i32) { assert(num_out_sgpr + 1 == num_out); num_out_sgpr = num_out; } @@ -3369,7 +3369,7 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, for (i = 0; i < key->vs_prolog.num_input_sgprs; i++) { ac_add_arg(&ctx->args, AC_ARG_SGPR, 1, AC_ARG_INT, &input_sgpr_param[i]); - returns[num_returns++] = ctx->i32; + returns[num_returns++] = ctx->ac.i32; } struct ac_arg merged_wave_info = input_sgpr_param[3]; @@ -3377,12 +3377,12 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, /* Preloaded VGPRs (outputs must be floats) */ for (i = 0; i < num_input_vgprs; i++) { ac_add_arg(&ctx->args, AC_ARG_VGPR, 1, AC_ARG_INT, &input_vgpr_param[i]); - returns[num_returns++] = ctx->f32; + returns[num_returns++] = ctx->ac.f32; } /* Vertex load indices. */ for (i = 0; i < key->vs_prolog.num_inputs; i++) - returns[num_returns++] = ctx->f32; + returns[num_returns++] = ctx->ac.f32; /* Create the function. */ si_llvm_create_func(ctx, "vs_prolog", returns, num_returns, 0); @@ -3405,7 +3405,7 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, LLVMValueRef has_hs_threads = LLVMBuildICmp(ctx->ac.builder, LLVMIntNE, si_unpack_param(ctx, input_sgpr_param[3], 8, 8), - ctx->i32_0, ""); + ctx->ac.i32_0, ""); for (i = 4; i > 0; --i) { input_vgprs[i + 1] = @@ -3439,14 +3439,14 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, */ if (key->vs_prolog.gs_fast_launch_tri_list) { input_vgprs[0] = ac_build_imad(&ctx->ac, thread_id_in_tg, /* gs_vtx01_offset */ - LLVMConstInt(ctx->i32, 3, 0), /* Vertex 0 */ - LLVMConstInt(ctx->i32, 0, 0)); + LLVMConstInt(ctx->ac.i32, 3, 0), /* Vertex 0 */ + LLVMConstInt(ctx->ac.i32, 0, 0)); input_vgprs[1] = ac_build_imad(&ctx->ac, thread_id_in_tg, /* gs_vtx23_offset */ - LLVMConstInt(ctx->i32, 3, 0), /* Vertex 1 */ - LLVMConstInt(ctx->i32, 1, 0)); + LLVMConstInt(ctx->ac.i32, 3, 0), /* Vertex 1 */ + LLVMConstInt(ctx->ac.i32, 1, 0)); input_vgprs[4] = ac_build_imad(&ctx->ac, thread_id_in_tg, /* gs_vtx45_offset */ - LLVMConstInt(ctx->i32, 3, 0), /* Vertex 2 */ - LLVMConstInt(ctx->i32, 2, 0)); + LLVMConstInt(ctx->ac.i32, 3, 0), /* Vertex 2 */ + LLVMConstInt(ctx->ac.i32, 2, 0)); } else { assert(key->vs_prolog.gs_fast_launch_tri_strip); LLVMBuilderRef builder = ctx->ac.builder; @@ -3454,16 +3454,16 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, LLVMValueRef index[3] = { thread_id_in_tg, LLVMBuildAdd(builder, thread_id_in_tg, - LLVMConstInt(ctx->i32, 1, 0), ""), + LLVMConstInt(ctx->ac.i32, 1, 0), ""), LLVMBuildAdd(builder, thread_id_in_tg, - LLVMConstInt(ctx->i32, 2, 0), ""), + LLVMConstInt(ctx->ac.i32, 2, 0), ""), }; LLVMValueRef is_odd = LLVMBuildTrunc(ctx->ac.builder, - thread_id_in_tg, ctx->i1, ""); + thread_id_in_tg, ctx->ac.i1, ""); LLVMValueRef flatshade_first = LLVMBuildICmp(builder, LLVMIntEQ, si_unpack_param(ctx, ctx->vs_state_bits, 4, 2), - ctx->i32_0, ""); + ctx->ac.i32_0, ""); ac_build_triangle_strip_indices_to_triangle(&ctx->ac, is_odd, flatshade_first, index); @@ -3473,7 +3473,7 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, } /* Triangles always have all edge flags set initially. */ - input_vgprs[3] = LLVMConstInt(ctx->i32, 0x7 << 8, 0); + input_vgprs[3] = LLVMConstInt(ctx->ac.i32, 0x7 << 8, 0); input_vgprs[2] = LLVMBuildAdd(ctx->ac.builder, input_vgprs[2], thread_id_in_tg, ""); /* PrimID */ @@ -3496,9 +3496,9 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, */ if (key->vs_prolog.states.unpack_instance_id_from_vertex_id) { ctx->abi.instance_id = LLVMBuildLShr(ctx->ac.builder, ctx->abi.vertex_id, - LLVMConstInt(ctx->i32, 16, 0), ""); + LLVMConstInt(ctx->ac.i32, 16, 0), ""); ctx->abi.vertex_id = LLVMBuildAnd(ctx->ac.builder, ctx->abi.vertex_id, - LLVMConstInt(ctx->i32, 0xffff, 0), ""); + LLVMConstInt(ctx->ac.i32, 0xffff, 0), ""); } /* Copy inputs to outputs. This should be no-op, as the registers match, @@ -3528,7 +3528,7 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, if (key->vs_prolog.states.instance_divisor_is_fetched) { LLVMValueRef list = si_prolog_get_rw_buffers(ctx); LLVMValueRef buf_index = - LLVMConstInt(ctx->i32, SI_VS_CONST_INSTANCE_DIVISORS, 0); + LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0); instance_divisor_constbuf = ac_build_load_to_sgpr(&ctx->ac, list, buf_index); } @@ -3548,7 +3548,7 @@ static void si_build_vs_prolog_function(struct si_shader_context *ctx, for (unsigned j = 0; j < 4; j++) { udiv_factors[j] = si_buffer_load_const(ctx, instance_divisor_constbuf, - LLVMConstInt(ctx->i32, i*16 + j*4, 0)); + LLVMConstInt(ctx->ac.i32, i*16 + j*4, 0)); udiv_factors[j] = ac_to_integer(&ctx->ac, udiv_factors[j]); } /* The faster NUW version doesn't work when InstanceID == UINT_MAX. diff --git a/src/gallium/drivers/radeonsi/si_shader_internal.h b/src/gallium/drivers/radeonsi/si_shader_internal.h index 492ebaa744b..a3f43358e39 100644 --- a/src/gallium/drivers/radeonsi/si_shader_internal.h +++ b/src/gallium/drivers/radeonsi/si_shader_internal.h @@ -187,23 +187,6 @@ struct si_shader_context { LLVMValueRef gs_ngg_scratch; LLVMValueRef postponed_kill; LLVMValueRef return_value; - - LLVMTypeRef voidt; - LLVMTypeRef i1; - LLVMTypeRef i8; - LLVMTypeRef i32; - LLVMTypeRef i64; - LLVMTypeRef i128; - LLVMTypeRef f32; - LLVMTypeRef v2i32; - LLVMTypeRef v4i32; - LLVMTypeRef v4f32; - LLVMTypeRef v8i32; - - LLVMValueRef i32_0; - LLVMValueRef i32_1; - LLVMValueRef i1false; - LLVMValueRef i1true; }; static inline struct si_shader_context * diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c index 539b2531ab7..7fa067f5e44 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c @@ -163,11 +163,6 @@ void si_llvm_context_init(struct si_shader_context *ctx, struct ac_llvm_compiler *compiler, unsigned wave_size) { - /* Initialize the gallivm object: - * We are only using the module, context, and builder fields of this struct. - * This should be enough for us to be able to pass our gallivm struct to the - * helper functions in the gallivm module. - */ memset(ctx, 0, sizeof(*ctx)); ctx->screen = sscreen; ctx->compiler = compiler; @@ -176,23 +171,6 @@ void si_llvm_context_init(struct si_shader_context *ctx, sscreen->info.family, AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH, wave_size, 64); - - ctx->voidt = LLVMVoidTypeInContext(ctx->ac.context); - ctx->i1 = LLVMInt1TypeInContext(ctx->ac.context); - ctx->i8 = LLVMInt8TypeInContext(ctx->ac.context); - ctx->i32 = LLVMInt32TypeInContext(ctx->ac.context); - ctx->i64 = LLVMInt64TypeInContext(ctx->ac.context); - ctx->i128 = LLVMIntTypeInContext(ctx->ac.context, 128); - ctx->f32 = LLVMFloatTypeInContext(ctx->ac.context); - ctx->v2i32 = LLVMVectorType(ctx->i32, 2); - ctx->v4i32 = LLVMVectorType(ctx->i32, 4); - ctx->v4f32 = LLVMVectorType(ctx->f32, 4); - ctx->v8i32 = LLVMVectorType(ctx->i32, 8); - - ctx->i32_0 = LLVMConstInt(ctx->i32, 0, 0); - ctx->i32_1 = LLVMConstInt(ctx->i32, 1, 0); - ctx->i1false = LLVMConstInt(ctx->i1, 0, 0); - ctx->i1true = LLVMConstInt(ctx->i1, 1, 0); } /* Set the context to a certain shader. Can be called repeatedly @@ -226,7 +204,7 @@ void si_llvm_create_func(struct si_shader_context *ctx, const char *name, return_types, num_return_elems, true); else - ret_type = ctx->voidt; + ret_type = ctx->ac.voidt; real_shader_type = ctx->type; diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_build.c b/src/gallium/drivers/radeonsi/si_shader_llvm_build.c index 7c159560cb6..ec7629514a7 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_build.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_build.c @@ -68,7 +68,7 @@ LLVMValueRef si_insert_input_ptr(struct si_shader_context *ctx, LLVMValueRef ret { LLVMBuilderRef builder = ctx->ac.builder; LLVMValueRef ptr = ac_get_arg(&ctx->ac, param); - ptr = LLVMBuildPtrToInt(builder, ptr, ctx->i32, ""); + ptr = LLVMBuildPtrToInt(builder, ptr, ctx->ac.i32, ""); return LLVMBuildInsertValue(builder, ret, ptr, return_index, ""); } @@ -79,7 +79,7 @@ LLVMValueRef si_prolog_get_rw_buffers(struct si_shader_context *ctx) ptr[0] = LLVMGetParam(ctx->main_fn, (merged_shader ? 8 : 0) + SI_SGPR_RW_BUFFERS); list = LLVMBuildIntToPtr(ctx->ac.builder, ptr[0], - ac_array_in_const32_addr_space(ctx->v4i32), ""); + ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); return list; } @@ -123,7 +123,7 @@ void si_llvm_declare_esgs_ring(struct si_shader_context *ctx) assert(!LLVMGetNamedGlobal(ctx->ac.module, "esgs_ring")); ctx->esgs_ring = LLVMAddGlobalInAddressSpace( - ctx->ac.module, LLVMArrayType(ctx->i32, 0), + ctx->ac.module, LLVMArrayType(ctx->ac.i32, 0), "esgs_ring", AC_ADDR_SPACE_LDS); LLVMSetLinkage(ctx->esgs_ring, LLVMExternalLinkage); diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c index 7f47f31bcdf..f88bde7a019 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c @@ -84,7 +84,7 @@ static LLVMValueRef si_llvm_load_input_gs(struct ac_shader_abi *abi, unsigned offset = param * 4 + swizzle; vtx_offset = LLVMBuildAdd(ctx->ac.builder, vtx_offset, - LLVMConstInt(ctx->i32, offset, false), ""); + LLVMConstInt(ctx->ac.i32, offset, false), ""); LLVMValueRef ptr = ac_build_gep0(&ctx->ac, ctx->esgs_ring, vtx_offset); LLVMValueRef value = LLVMBuildLoad(ctx->ac.builder, ptr, ""); @@ -116,18 +116,18 @@ static LLVMValueRef si_llvm_load_input_gs(struct ac_shader_abi *abi, ctx->gs_vtx_offset[vtx_offset_param]); vtx_offset = LLVMBuildMul(ctx->ac.builder, gs_vtx_offset, - LLVMConstInt(ctx->i32, 4, 0), ""); + LLVMConstInt(ctx->ac.i32, 4, 0), ""); - soffset = LLVMConstInt(ctx->i32, (param * 4 + swizzle) * 256, 0); + soffset = LLVMConstInt(ctx->ac.i32, (param * 4 + swizzle) * 256, 0); - value = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, ctx->i32_0, + value = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, ctx->ac.i32_0, vtx_offset, soffset, 0, ac_glc, true, false); if (ac_get_type_size(type) == 8) { LLVMValueRef value2; - soffset = LLVMConstInt(ctx->i32, (param * 4 + swizzle + 1) * 256, 0); + soffset = LLVMConstInt(ctx->ac.i32, (param * 4 + swizzle + 1) * 256, 0); value2 = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, - ctx->i32_0, vtx_offset, soffset, + ctx->ac.i32_0, vtx_offset, soffset, 0, ac_glc, true, false); return si_build_gather_64bit(ctx, type, value, value2); } @@ -213,9 +213,9 @@ void si_llvm_emit_es_epilogue(struct ac_shader_abi *abi, unsigned max_outputs, LLVMValueRef wave_idx = si_unpack_param(ctx, ctx->merged_wave_info, 24, 4); vertex_idx = LLVMBuildOr(ctx->ac.builder, vertex_idx, LLVMBuildMul(ctx->ac.builder, wave_idx, - LLVMConstInt(ctx->i32, ctx->ac.wave_size, false), ""), ""); + LLVMConstInt(ctx->ac.i32, ctx->ac.wave_size, false), ""), ""); lds_base = LLVMBuildMul(ctx->ac.builder, vertex_idx, - LLVMConstInt(ctx->i32, itemsize_dw, 0), ""); + LLVMConstInt(ctx->ac.i32, itemsize_dw, 0), ""); } for (i = 0; i < info->num_outputs; i++) { @@ -237,7 +237,7 @@ void si_llvm_emit_es_epilogue(struct ac_shader_abi *abi, unsigned max_outputs, /* GFX9 has the ESGS ring in LDS. */ if (ctx->screen->info.chip_class >= GFX9) { - LLVMValueRef idx = LLVMConstInt(ctx->i32, param * 4 + chan, false); + LLVMValueRef idx = LLVMConstInt(ctx->ac.i32, param * 4 + chan, false); idx = LLVMBuildAdd(ctx->ac.builder, lds_base, idx, ""); ac_build_indexed_store(&ctx->ac, ctx->esgs_ring, idx, out_val); continue; @@ -327,7 +327,7 @@ static void si_llvm_emit_vertex(struct ac_shader_abi *abi, * altogether. */ can_emit = LLVMBuildICmp(ctx->ac.builder, LLVMIntULT, gs_next_vertex, - LLVMConstInt(ctx->i32, + LLVMConstInt(ctx->ac.i32, shader->selector->gs_max_out_vertices, 0), ""); bool use_kill = !info->writes_memory; @@ -346,13 +346,13 @@ static void si_llvm_emit_vertex(struct ac_shader_abi *abi, LLVMValueRef out_val = LLVMBuildLoad(ctx->ac.builder, addrs[4 * i + chan], ""); LLVMValueRef voffset = - LLVMConstInt(ctx->i32, offset * + LLVMConstInt(ctx->ac.i32, offset * shader->selector->gs_max_out_vertices, 0); offset++; voffset = LLVMBuildAdd(ctx->ac.builder, voffset, gs_next_vertex, ""); voffset = LLVMBuildMul(ctx->ac.builder, voffset, - LLVMConstInt(ctx->i32, 4, 0), ""); + LLVMConstInt(ctx->ac.i32, 4, 0), ""); out_val = ac_to_integer(&ctx->ac, out_val); @@ -364,7 +364,7 @@ static void si_llvm_emit_vertex(struct ac_shader_abi *abi, } } - gs_next_vertex = LLVMBuildAdd(ctx->ac.builder, gs_next_vertex, ctx->i32_1, ""); + gs_next_vertex = LLVMBuildAdd(ctx->ac.builder, gs_next_vertex, ctx->ac.i32_1, ""); LLVMBuildStore(ctx->ac.builder, gs_next_vertex, ctx->gs_next_vertex[stream]); /* Signal vertex emission if vertex data was written. */ @@ -399,7 +399,7 @@ void si_preload_esgs_ring(struct si_shader_context *ctx) unsigned ring = ctx->type == PIPE_SHADER_GEOMETRY ? SI_GS_RING_ESGS : SI_ES_RING_ESGS; - LLVMValueRef offset = LLVMConstInt(ctx->i32, ring, 0); + LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, ring, 0); LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers); ctx->esgs_ring = @@ -419,7 +419,7 @@ void si_preload_gs_rings(struct si_shader_context *ctx) { const struct si_shader_selector *sel = ctx->shader->selector; LLVMBuilderRef builder = ctx->ac.builder; - LLVMValueRef offset = LLVMConstInt(ctx->i32, SI_RING_GSVS, 0); + LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, SI_RING_GSVS, 0); LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers); LLVMValueRef base_ring = ac_build_load_to_sgpr(&ctx->ac, buf_ptr, offset); @@ -431,7 +431,7 @@ void si_preload_gs_rings(struct si_shader_context *ctx) * t16v0c0 .. * Override the buffer descriptor accordingly. */ - LLVMTypeRef v2i64 = LLVMVectorType(ctx->i64, 2); + LLVMTypeRef v2i64 = LLVMVectorType(ctx->ac.i64, 2); uint64_t stream_offset = 0; for (unsigned stream = 0; stream < 4; ++stream) { @@ -452,23 +452,23 @@ void si_preload_gs_rings(struct si_shader_context *ctx) num_records = ctx->ac.wave_size; ring = LLVMBuildBitCast(builder, base_ring, v2i64, ""); - tmp = LLVMBuildExtractElement(builder, ring, ctx->i32_0, ""); + tmp = LLVMBuildExtractElement(builder, ring, ctx->ac.i32_0, ""); tmp = LLVMBuildAdd(builder, tmp, - LLVMConstInt(ctx->i64, + LLVMConstInt(ctx->ac.i64, stream_offset, 0), ""); stream_offset += stride * ctx->ac.wave_size; - ring = LLVMBuildInsertElement(builder, ring, tmp, ctx->i32_0, ""); - ring = LLVMBuildBitCast(builder, ring, ctx->v4i32, ""); - tmp = LLVMBuildExtractElement(builder, ring, ctx->i32_1, ""); + ring = LLVMBuildInsertElement(builder, ring, tmp, ctx->ac.i32_0, ""); + ring = LLVMBuildBitCast(builder, ring, ctx->ac.v4i32, ""); + tmp = LLVMBuildExtractElement(builder, ring, ctx->ac.i32_1, ""); tmp = LLVMBuildOr(builder, tmp, - LLVMConstInt(ctx->i32, + LLVMConstInt(ctx->ac.i32, S_008F04_STRIDE(stride) | S_008F04_SWIZZLE_ENABLE(1), 0), ""); - ring = LLVMBuildInsertElement(builder, ring, tmp, ctx->i32_1, ""); + ring = LLVMBuildInsertElement(builder, ring, tmp, ctx->ac.i32_1, ""); ring = LLVMBuildInsertElement(builder, ring, - LLVMConstInt(ctx->i32, num_records, 0), - LLVMConstInt(ctx->i32, 2, 0), ""); + LLVMConstInt(ctx->ac.i32, num_records, 0), + LLVMConstInt(ctx->ac.i32, 2, 0), ""); uint32_t rsrc3 = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) | @@ -489,8 +489,8 @@ void si_preload_gs_rings(struct si_shader_context *ctx) } ring = LLVMBuildInsertElement(builder, ring, - LLVMConstInt(ctx->i32, rsrc3, false), - LLVMConstInt(ctx->i32, 3, 0), ""); + LLVMConstInt(ctx->ac.i32, rsrc3, false), + LLVMConstInt(ctx->ac.i32, 3, 0), ""); ctx->gsvs_ring[stream] = ring; } @@ -533,11 +533,11 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, LLVMValueRef buf_ptr = ac_get_arg(&ctx.ac, ctx.rw_buffers); ctx.gsvs_ring[0] = ac_build_load_to_sgpr(&ctx.ac, buf_ptr, - LLVMConstInt(ctx.i32, SI_RING_GSVS, 0)); + LLVMConstInt(ctx.ac.i32, SI_RING_GSVS, 0)); LLVMValueRef voffset = LLVMBuildMul(ctx.ac.builder, ctx.abi.vertex_id, - LLVMConstInt(ctx.i32, 4, 0), ""); + LLVMConstInt(ctx.ac.i32, 4, 0), ""); /* Fetch the vertex stream ID.*/ LLVMValueRef stream_id; @@ -545,7 +545,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, if (!sscreen->use_ngg_streamout && gs_selector->so.num_outputs) stream_id = si_unpack_param(&ctx, ctx.streamout_config, 24, 2); else - stream_id = ctx.i32_0; + stream_id = ctx.ac.i32_0; /* Fill in output information. */ for (i = 0; i < gsinfo->num_outputs; ++i) { @@ -575,7 +575,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, continue; bb = LLVMInsertBasicBlockInContext(ctx.ac.context, end_bb, "out"); - LLVMAddCase(switch_inst, LLVMConstInt(ctx.i32, stream, 0), bb); + LLVMAddCase(switch_inst, LLVMConstInt(ctx.ac.i32, stream, 0), bb); LLVMPositionBuilderAtEnd(builder, bb); /* Fetch vertex data from GSVS ring */ @@ -584,18 +584,18 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, for (unsigned chan = 0; chan < 4; chan++) { if (!(gsinfo->output_usagemask[i] & (1 << chan)) || outputs[i].vertex_stream[chan] != stream) { - outputs[i].values[chan] = LLVMGetUndef(ctx.f32); + outputs[i].values[chan] = LLVMGetUndef(ctx.ac.f32); continue; } - LLVMValueRef soffset = LLVMConstInt(ctx.i32, + LLVMValueRef soffset = LLVMConstInt(ctx.ac.i32, offset * gs_selector->gs_max_out_vertices * 16 * 4, 0); offset++; outputs[i].values[chan] = ac_build_buffer_load(&ctx.ac, ctx.gsvs_ring[0], 1, - ctx.i32_0, voffset, + ctx.ac.i32_0, voffset, soffset, 0, ac_glc | ac_slc, true, false); } @@ -674,12 +674,12 @@ void si_llvm_build_gs_prolog(struct si_shader_context *ctx, for (unsigned i = 0; i < num_sgprs; ++i) { ac_add_arg(&ctx->args, AC_ARG_SGPR, 1, AC_ARG_INT, NULL); - returns[i] = ctx->i32; + returns[i] = ctx->ac.i32; } for (unsigned i = 0; i < num_vgprs; ++i) { ac_add_arg(&ctx->args, AC_ARG_VGPR, 1, AC_ARG_INT, NULL); - returns[num_sgprs + i] = ctx->f32; + returns[num_sgprs + i] = ctx->ac.f32; } /* Create the function. */ @@ -736,7 +736,7 @@ void si_llvm_build_gs_prolog(struct si_shader_context *ctx, } prim_id = LLVMGetParam(func, num_sgprs + 2); - rotate = LLVMBuildTrunc(builder, prim_id, ctx->i1, ""); + rotate = LLVMBuildTrunc(builder, prim_id, ctx->ac.i1, ""); for (unsigned i = 0; i < 6; ++i) { LLVMValueRef base, rotated; @@ -750,7 +750,7 @@ void si_llvm_build_gs_prolog(struct si_shader_context *ctx, LLVMValueRef hi, out; hi = LLVMBuildShl(builder, vtx_out[i*2+1], - LLVMConstInt(ctx->i32, 16, 0), ""); + LLVMConstInt(ctx->ac.i32, 16, 0), ""); out = LLVMBuildOr(builder, vtx_out[i*2], hi, ""); out = ac_to_float(&ctx->ac, out); ret = LLVMBuildInsertValue(builder, ret, out, diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c index 74ae6f7b96e..493eb2cf908 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_ps.c @@ -41,18 +41,18 @@ static LLVMValueRef load_sample_position(struct ac_shader_abi *abi, LLVMValueRef { struct si_shader_context *ctx = si_shader_context_from_abi(abi); LLVMValueRef desc = ac_get_arg(&ctx->ac, ctx->rw_buffers); - LLVMValueRef buf_index = LLVMConstInt(ctx->i32, SI_PS_CONST_SAMPLE_POSITIONS, 0); + LLVMValueRef buf_index = LLVMConstInt(ctx->ac.i32, SI_PS_CONST_SAMPLE_POSITIONS, 0); LLVMValueRef resource = ac_build_load_to_sgpr(&ctx->ac, desc, buf_index); /* offset = sample_id * 8 (8 = 2 floats containing samplepos.xy) */ - LLVMValueRef offset0 = LLVMBuildMul(ctx->ac.builder, sample_id, LLVMConstInt(ctx->i32, 8, 0), ""); - LLVMValueRef offset1 = LLVMBuildAdd(ctx->ac.builder, offset0, LLVMConstInt(ctx->i32, 4, 0), ""); + LLVMValueRef offset0 = LLVMBuildMul(ctx->ac.builder, sample_id, LLVMConstInt(ctx->ac.i32, 8, 0), ""); + LLVMValueRef offset1 = LLVMBuildAdd(ctx->ac.builder, offset0, LLVMConstInt(ctx->ac.i32, 4, 0), ""); LLVMValueRef pos[4] = { si_buffer_load_const(ctx, resource, offset0), si_buffer_load_const(ctx, resource, offset1), - LLVMConstReal(ctx->f32, 0), - LLVMConstReal(ctx->f32, 0) + LLVMConstReal(ctx->ac.f32, 0), + LLVMConstReal(ctx->ac.f32, 0) }; return ac_build_gather_values(&ctx->ac, pos, 4); @@ -72,9 +72,9 @@ static LLVMValueRef si_nir_emit_fbfetch(struct ac_shader_abi *abi) STATIC_ASSERT(SI_PS_IMAGE_COLORBUF0 % 2 == 0); ptr = ac_get_arg(&ctx->ac, ctx->rw_buffers); ptr = LLVMBuildPointerCast(ctx->ac.builder, ptr, - ac_array_in_const32_addr_space(ctx->v8i32), ""); + ac_array_in_const32_addr_space(ctx->ac.v8i32), ""); image = ac_build_load_to_sgpr(&ctx->ac, ptr, - LLVMConstInt(ctx->i32, SI_PS_IMAGE_COLORBUF0 / 2, 0)); + LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0 / 2, 0)); unsigned chan = 0; @@ -93,7 +93,7 @@ static LLVMValueRef si_nir_emit_fbfetch(struct ac_shader_abi *abi) 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)); + LLVMConstInt(ctx->ac.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); @@ -124,14 +124,14 @@ static LLVMValueRef si_build_fs_interp(struct si_shader_context *ctx, { if (i || j) { return ac_build_fs_interp(&ctx->ac, - LLVMConstInt(ctx->i32, chan, 0), - LLVMConstInt(ctx->i32, attr_index, 0), + LLVMConstInt(ctx->ac.i32, chan, 0), + LLVMConstInt(ctx->ac.i32, attr_index, 0), prim_mask, i, j); } return ac_build_fs_interp_mov(&ctx->ac, - LLVMConstInt(ctx->i32, 2, 0), /* P0 */ - LLVMConstInt(ctx->i32, chan, 0), - LLVMConstInt(ctx->i32, attr_index, 0), + LLVMConstInt(ctx->ac.i32, 2, 0), /* P0 */ + LLVMConstInt(ctx->ac.i32, chan, 0), + LLVMConstInt(ctx->ac.i32, attr_index, 0), prim_mask); } @@ -179,12 +179,12 @@ static void interp_fs_color(struct si_shader_context *ctx, if (interp) { interp_param = LLVMBuildBitCast(ctx->ac.builder, interp_param, - LLVMVectorType(ctx->f32, 2), ""); + LLVMVectorType(ctx->ac.f32, 2), ""); i = LLVMBuildExtractElement(ctx->ac.builder, interp_param, - ctx->i32_0, ""); + ctx->ac.i32_0, ""); j = LLVMBuildExtractElement(ctx->ac.builder, interp_param, - ctx->i32_1, ""); + ctx->ac.i32_1, ""); } if (ctx->shader->key.part.ps.prolog.color_two_side) { @@ -198,7 +198,7 @@ static void interp_fs_color(struct si_shader_context *ctx, back_attr_offset += 1; is_face_positive = LLVMBuildICmp(ctx->ac.builder, LLVMIntNE, - face, ctx->i32_0, ""); + face, ctx->ac.i32_0, ""); for (chan = 0; chan < 4; chan++) { LLVMValueRef front, back; @@ -245,7 +245,7 @@ static void si_alpha_test(struct si_shader_context *ctx, LLVMValueRef alpha) LLVMBuildFCmp(ctx->ac.builder, cond, alpha, alpha_ref, ""); ac_build_kill_if_false(&ctx->ac, alpha_pass); } else { - ac_build_kill_if_false(&ctx->ac, ctx->i1false); + ac_build_kill_if_false(&ctx->ac, ctx->ac.i1false); } } @@ -261,14 +261,14 @@ static LLVMValueRef si_scale_alpha_by_sample_mask(struct si_shader_context *ctx, coverage = ac_to_integer(&ctx->ac, coverage); coverage = ac_build_intrinsic(&ctx->ac, "llvm.ctpop.i32", - ctx->i32, + ctx->ac.i32, &coverage, 1, AC_FUNC_ATTR_READNONE); coverage = LLVMBuildUIToFP(ctx->ac.builder, coverage, - ctx->f32, ""); + ctx->ac.f32, ""); coverage = LLVMBuildFMul(ctx->ac.builder, coverage, - LLVMConstReal(ctx->f32, + LLVMConstReal(ctx->ac.f32, 1.0 / SI_NUM_SMOOTH_AA_SAMPLES), ""); return LLVMBuildFMul(ctx->ac.builder, alpha, coverage, ""); @@ -603,16 +603,16 @@ static void si_llvm_emit_polygon_stipple(struct si_shader_context *ctx, address[1] = si_unpack_param(ctx, param_pos_fixed_pt, 16, 5); /* Load the buffer descriptor. */ - slot = LLVMConstInt(ctx->i32, SI_PS_CONST_POLY_STIPPLE, 0); + slot = LLVMConstInt(ctx->ac.i32, SI_PS_CONST_POLY_STIPPLE, 0); desc = ac_build_load_to_sgpr(&ctx->ac, param_rw_buffers, slot); /* The stipple pattern is 32x32, each row has 32 bits. */ offset = LLVMBuildMul(builder, address[1], - LLVMConstInt(ctx->i32, 4, 0), ""); + LLVMConstInt(ctx->ac.i32, 4, 0), ""); row = si_buffer_load_const(ctx, desc, offset); row = ac_to_integer(&ctx->ac, row); bit = LLVMBuildLShr(builder, row, address[0], ""); - bit = LLVMBuildTrunc(builder, bit, ctx->i1, ""); + bit = LLVMBuildTrunc(builder, bit, ctx->ac.i1, ""); ac_build_kill_if_false(&ctx->ac, bit); } @@ -662,7 +662,7 @@ void si_llvm_build_ps_prolog(struct si_shader_context *ctx, num_color_channels <= AC_MAX_ARGS); for (i = 0; i < key->ps_prolog.num_input_sgprs; i++) { ac_add_arg(&ctx->args, AC_ARG_SGPR, 1, AC_ARG_INT, NULL); - return_types[num_returns++] = ctx->i32; + return_types[num_returns++] = ctx->ac.i32; } @@ -680,12 +680,12 @@ void si_llvm_build_ps_prolog(struct si_shader_context *ctx, arg = &pos_fixed_pt; } ac_add_arg(&ctx->args, AC_ARG_VGPR, 1, AC_ARG_FLOAT, arg); - return_types[num_returns++] = ctx->f32; + return_types[num_returns++] = ctx->ac.f32; } /* Declare outputs (same as inputs + add colors if needed) */ for (i = 0; i < num_color_channels; i++) - return_types[num_returns++] = ctx->f32; + return_types[num_returns++] = ctx->ac.f32; /* Create the function. */ si_llvm_create_func(ctx, "ps_prolog", return_types, num_returns, 0); @@ -720,9 +720,9 @@ void si_llvm_build_ps_prolog(struct si_shader_context *ctx, */ bc_optimize = LLVMGetParam(func, SI_PS_NUM_USER_SGPR); bc_optimize = LLVMBuildLShr(ctx->ac.builder, bc_optimize, - LLVMConstInt(ctx->i32, 31, 0), ""); + LLVMConstInt(ctx->ac.i32, 31, 0), ""); bc_optimize = LLVMBuildTrunc(ctx->ac.builder, bc_optimize, - ctx->i1, ""); + ctx->ac.i1, ""); if (key->ps_prolog.states.bc_optimize_for_persp) { /* Read PERSP_CENTER. */ @@ -907,7 +907,7 @@ void si_llvm_build_ps_prolog(struct si_shader_context *ctx, ctx->ac.builder, samplemask, LLVMBuildShl(ctx->ac.builder, - LLVMConstInt(ctx->i32, ps_iter_mask, false), + LLVMConstInt(ctx->ac.i32, ps_iter_mask, false), sampleid, ""), ""); samplemask = ac_to_float(&ctx->ac, samplemask); diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c index ba23ddb0aa7..cb06aa99ca7 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c @@ -35,7 +35,7 @@ static LLVMValueRef si_llvm_bound_index(struct si_shader_context *ctx, unsigned num) { LLVMBuilderRef builder = ctx->ac.builder; - LLVMValueRef c_max = LLVMConstInt(ctx->i32, num - 1, 0); + LLVMValueRef c_max = LLVMConstInt(ctx->ac.i32, num - 1, 0); LLVMValueRef cc; if (util_is_power_of_two_or_zero(num)) { @@ -69,7 +69,7 @@ static LLVMValueRef load_const_buffer_desc_fast_path(struct si_shader_context *c LLVMValueRef desc0, desc1; desc0 = ptr; - desc1 = LLVMConstInt(ctx->i32, + desc1 = LLVMConstInt(ctx->ac.i32, S_008F04_BASE_ADDRESS_HI(ctx->screen->info.address32_hi), 0); uint32_t rsrc3 = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) | @@ -88,8 +88,8 @@ static LLVMValueRef load_const_buffer_desc_fast_path(struct si_shader_context *c LLVMValueRef desc_elems[] = { desc0, desc1, - LLVMConstInt(ctx->i32, sel->info.constbuf0_num_slots * 16, 0), - LLVMConstInt(ctx->i32, rsrc3, false) + LLVMConstInt(ctx->ac.i32, sel->info.constbuf0_num_slots * 16, 0), + LLVMConstInt(ctx->ac.i32, rsrc3, false) }; return ac_build_gather_values(&ctx->ac, desc_elems, 4); @@ -109,7 +109,7 @@ static LLVMValueRef load_ubo(struct ac_shader_abi *abi, LLVMValueRef index) index = si_llvm_bound_index(ctx, index, ctx->num_const_buffers); index = LLVMBuildAdd(ctx->ac.builder, index, - LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS, 0), ""); + LLVMConstInt(ctx->ac.i32, SI_NUM_SHADER_BUFFERS, 0), ""); return ac_build_load_to_sgpr(&ctx->ac, ptr, index); } @@ -123,7 +123,7 @@ load_ssbo(struct ac_shader_abi *abi, LLVMValueRef index, bool write) index = si_llvm_bound_index(ctx, index, ctx->num_shader_buffers); index = LLVMBuildSub(ctx->ac.builder, - LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS - 1, 0), + LLVMConstInt(ctx->ac.i32, SI_NUM_SHADER_BUFFERS - 1, 0), index, ""); return ac_build_load_to_sgpr(&ctx->ac, rsrc_ptr, index); @@ -146,8 +146,8 @@ static LLVMValueRef force_dcc_off(struct si_shader_context *ctx, if (ctx->screen->info.chip_class <= GFX7) { return rsrc; } else { - LLVMValueRef i32_6 = LLVMConstInt(ctx->i32, 6, 0); - LLVMValueRef i32_C = LLVMConstInt(ctx->i32, C_008F28_COMPRESSION_EN, 0); + LLVMValueRef i32_6 = LLVMConstInt(ctx->ac.i32, 6, 0); + LLVMValueRef i32_C = LLVMConstInt(ctx->ac.i32, C_008F28_COMPRESSION_EN, 0); LLVMValueRef tmp; tmp = LLVMBuildExtractElement(ctx->ac.builder, rsrc, i32_6, ""); @@ -167,10 +167,10 @@ static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, LLVMValueRef rsrc; if (desc_type == AC_DESC_BUFFER) { - index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->i32, 2, 0), - ctx->i32_1); + index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 2, 0), + ctx->ac.i32_1); list = LLVMBuildPointerCast(builder, list, - ac_array_in_const32_addr_space(ctx->v4i32), ""); + ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); } else { assert(desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_FMASK); @@ -198,26 +198,26 @@ static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, switch (type) { case AC_DESC_IMAGE: /* The image is at [0:7]. */ - index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->i32, 2, 0), ""); + index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->ac.i32, 2, 0), ""); break; case AC_DESC_BUFFER: /* The buffer is in [4:7]. */ - index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->i32, 4, 0), - ctx->i32_1); + index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 4, 0), + ctx->ac.i32_1); list = LLVMBuildPointerCast(builder, list, - ac_array_in_const32_addr_space(ctx->v4i32), ""); + ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); break; case AC_DESC_FMASK: /* The FMASK is at [8:15]. */ - index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->i32, 2, 0), - ctx->i32_1); + index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 2, 0), + ctx->ac.i32_1); break; case AC_DESC_SAMPLER: /* The sampler state is at [12:15]. */ - index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->i32, 4, 0), - LLVMConstInt(ctx->i32, 3, 0)); + index = ac_build_imad(&ctx->ac, index, LLVMConstInt(ctx->ac.i32, 4, 0), + LLVMConstInt(ctx->ac.i32, 3, 0)); list = LLVMBuildPointerCast(builder, list, - ac_array_in_const32_addr_space(ctx->v4i32), ""); + ac_array_in_const32_addr_space(ctx->ac.v4i32), ""); break; case AC_DESC_PLANE_0: case AC_DESC_PLANE_1: @@ -252,11 +252,11 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi, if (image) { /* Bindless image descriptors use 16-dword slots. */ dynamic_index = LLVMBuildMul(ctx->ac.builder, dynamic_index, - LLVMConstInt(ctx->i64, 2, 0), ""); + LLVMConstInt(ctx->ac.i64, 2, 0), ""); /* FMASK is right after the image. */ if (desc_type == AC_DESC_FMASK) { dynamic_index = LLVMBuildAdd(ctx->ac.builder, dynamic_index, - ctx->i32_1, ""); + ctx->ac.i32_1, ""); } return si_load_image_desc(ctx, list, dynamic_index, desc_type, @@ -269,9 +269,9 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi, * to prevent incorrect code generation and hangs. */ dynamic_index = LLVMBuildMul(ctx->ac.builder, dynamic_index, - LLVMConstInt(ctx->i64, 2, 0), ""); + LLVMConstInt(ctx->ac.i64, 2, 0), ""); list = ac_build_pointer_add(&ctx->ac, list, dynamic_index); - return si_load_sampler_desc(ctx, list, ctx->i32_0, desc_type); + return si_load_sampler_desc(ctx, list, ctx->ac.i32_0, desc_type); } unsigned num_slots = image ? ctx->num_images : ctx->num_samplers; @@ -299,16 +299,16 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi, /* FMASKs are separate from images. */ if (desc_type == AC_DESC_FMASK) { index = LLVMBuildAdd(ctx->ac.builder, index, - LLVMConstInt(ctx->i32, SI_NUM_IMAGES, 0), ""); + LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGES, 0), ""); } index = LLVMBuildSub(ctx->ac.builder, - LLVMConstInt(ctx->i32, SI_NUM_IMAGE_SLOTS - 1, 0), + LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGE_SLOTS - 1, 0), index, ""); return si_load_image_desc(ctx, list, index, desc_type, write, false); } index = LLVMBuildAdd(ctx->ac.builder, index, - LLVMConstInt(ctx->i32, SI_NUM_IMAGE_SLOTS / 2, 0), ""); + LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGE_SLOTS / 2, 0), ""); return si_load_sampler_desc(ctx, list, index, desc_type); } diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c b/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c index cd0f136e952..b83e26fc582 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c @@ -82,7 +82,7 @@ static LLVMValueRef get_tcs_out_vertex_dw_stride(struct si_shader_context *ctx) { unsigned stride = get_tcs_out_vertex_dw_stride_constant(ctx); - return LLVMConstInt(ctx->i32, stride, 0); + return LLVMConstInt(ctx->ac.i32, stride, 0); } static LLVMValueRef get_tcs_out_patch_stride(struct si_shader_context *ctx) @@ -96,7 +96,7 @@ static LLVMValueRef get_tcs_out_patch_stride(struct si_shader_context *ctx) unsigned num_patch_outputs = util_last_bit64(ctx->shader->selector->patch_outputs_written); unsigned patch_dw_stride = tcs_out_vertices * vertex_dw_stride + num_patch_outputs * 4; - return LLVMConstInt(ctx->i32, patch_dw_stride, 0); + return LLVMConstInt(ctx->ac.i32, patch_dw_stride, 0); } static LLVMValueRef @@ -104,7 +104,7 @@ get_tcs_out_patch0_offset(struct si_shader_context *ctx) { return LLVMBuildMul(ctx->ac.builder, si_unpack_param(ctx, ctx->tcs_out_lds_offsets, 0, 16), - LLVMConstInt(ctx->i32, 4, 0), ""); + LLVMConstInt(ctx->ac.i32, 4, 0), ""); } static LLVMValueRef @@ -112,7 +112,7 @@ get_tcs_out_patch0_patch_data_offset(struct si_shader_context *ctx) { return LLVMBuildMul(ctx->ac.builder, si_unpack_param(ctx, ctx->tcs_out_lds_offsets, 16, 16), - LLVMConstInt(ctx->i32, 4, 0), ""); + LLVMConstInt(ctx->ac.i32, 4, 0), ""); } static LLVMValueRef @@ -153,7 +153,7 @@ static LLVMValueRef get_num_tcs_out_vertices(struct si_shader_context *ctx) /* If !tcs_out_vertices, it's either the fixed-func TCS or the TCS epilog. */ if (ctx->type == PIPE_SHADER_TESS_CTRL && tcs_out_vertices) - return LLVMConstInt(ctx->i32, tcs_out_vertices, 0); + return LLVMConstInt(ctx->ac.i32, tcs_out_vertices, 0); return si_unpack_param(ctx, ctx->tcs_offchip_layout, 6, 6); } @@ -165,13 +165,13 @@ static LLVMValueRef get_tcs_in_vertex_dw_stride(struct si_shader_context *ctx) switch (ctx->type) { case PIPE_SHADER_VERTEX: stride = ctx->shader->selector->lshs_vertex_stride / 4; - return LLVMConstInt(ctx->i32, stride, 0); + return LLVMConstInt(ctx->ac.i32, stride, 0); case PIPE_SHADER_TESS_CTRL: if (ctx->screen->info.chip_class >= GFX9 && ctx->shader->is_monolithic) { stride = ctx->shader->key.part.tcs.ls->lshs_vertex_stride / 4; - return LLVMConstInt(ctx->i32, stride, 0); + return LLVMConstInt(ctx->ac.i32, stride, 0); } return si_unpack_param(ctx, ctx->vs_state_bits, 24, 8); @@ -195,7 +195,7 @@ static LLVMValueRef get_dw_address_from_generic_indices(struct si_shader_context if (param_index) { base_addr = ac_build_imad(&ctx->ac, param_index, - LLVMConstInt(ctx->i32, 4, 0), base_addr); + LLVMConstInt(ctx->ac.i32, 4, 0), base_addr); } int param = name == TGSI_SEMANTIC_PATCH || @@ -206,7 +206,7 @@ static LLVMValueRef get_dw_address_from_generic_indices(struct si_shader_context /* Add the base address of the element. */ return LLVMBuildAdd(ctx->ac.builder, base_addr, - LLVMConstInt(ctx->i32, param * 4, 0), ""); + LLVMConstInt(ctx->ac.i32, param * 4, 0), ""); } /* The offchip buffer layout for TCS->TES is @@ -240,7 +240,7 @@ static LLVMValueRef get_tcs_tes_buffer_address(struct si_shader_context *ctx, total_vertices = LLVMBuildMul(ctx->ac.builder, vertices_per_patch, num_patches, ""); - constant16 = LLVMConstInt(ctx->i32, 16, 0); + constant16 = LLVMConstInt(ctx->ac.i32, 16, 0); if (vertex_index) { base_addr = ac_build_imad(&ctx->ac, rel_patch_id, vertices_per_patch, vertex_index); @@ -279,10 +279,10 @@ static LLVMValueRef get_tcs_tes_buffer_address_from_generic_indices( if (param_index) { param_index = LLVMBuildAdd(ctx->ac.builder, param_index, - LLVMConstInt(ctx->i32, param_index_base, 0), + LLVMConstInt(ctx->ac.i32, param_index_base, 0), ""); } else { - param_index = LLVMConstInt(ctx->i32, param_index_base, 0); + param_index = LLVMConstInt(ctx->ac.i32, param_index_base, 0); } return get_tcs_tes_buffer_address(ctx, get_rel_patch_id(ctx), @@ -310,7 +310,7 @@ static LLVMValueRef buffer_load(struct si_shader_context *ctx, value = LLVMBuildBitCast(ctx->ac.builder, value, vec_type, ""); return LLVMBuildExtractElement(ctx->ac.builder, value, - LLVMConstInt(ctx->i32, swizzle, 0), ""); + LLVMConstInt(ctx->ac.i32, swizzle, 0), ""); } value = ac_build_buffer_load(&ctx->ac, buffer, 1, NULL, base, offset, @@ -348,13 +348,13 @@ static LLVMValueRef lshs_lds_load(struct si_shader_context *ctx, if (ac_get_type_size(type) == 8) { LLVMValueRef lo, hi; - lo = lshs_lds_load(ctx, ctx->i32, swizzle, dw_addr); - hi = lshs_lds_load(ctx, ctx->i32, swizzle + 1, dw_addr); + lo = lshs_lds_load(ctx, ctx->ac.i32, swizzle, dw_addr); + hi = lshs_lds_load(ctx, ctx->ac.i32, swizzle + 1, dw_addr); return si_build_gather_64bit(ctx, type, lo, hi); } dw_addr = LLVMBuildAdd(ctx->ac.builder, dw_addr, - LLVMConstInt(ctx->i32, swizzle, 0), ""); + LLVMConstInt(ctx->ac.i32, swizzle, 0), ""); value = ac_lds_load(&ctx->ac, dw_addr); @@ -373,7 +373,7 @@ static void lshs_lds_store(struct si_shader_context *ctx, LLVMValueRef value) { dw_addr = LLVMBuildAdd(ctx->ac.builder, dw_addr, - LLVMConstInt(ctx->i32, dw_offset_imm, 0), ""); + LLVMConstInt(ctx->ac.i32, dw_offset_imm, 0), ""); ac_lds_store(&ctx->ac, dw_addr, value); } @@ -396,13 +396,13 @@ static LLVMValueRef get_tess_ring_descriptor(struct si_shader_context *ctx, /* TCS only receives high 13 bits of the address. */ if (ring == TESS_OFFCHIP_RING_TCS || ring == TCS_FACTOR_RING) { addr = LLVMBuildAnd(builder, addr, - LLVMConstInt(ctx->i32, 0xfff80000, 0), ""); + LLVMConstInt(ctx->ac.i32, 0xfff80000, 0), ""); } if (ring == TCS_FACTOR_RING) { unsigned tf_offset = ctx->screen->tess_offchip_ring_size; addr = LLVMBuildAdd(builder, addr, - LLVMConstInt(ctx->i32, tf_offset, 0), ""); + LLVMConstInt(ctx->ac.i32, tf_offset, 0), ""); } uint32_t rsrc3 = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) | @@ -420,10 +420,10 @@ static LLVMValueRef get_tess_ring_descriptor(struct si_shader_context *ctx, LLVMValueRef desc[4]; desc[0] = addr; - desc[1] = LLVMConstInt(ctx->i32, + desc[1] = LLVMConstInt(ctx->ac.i32, S_008F04_BASE_ADDRESS_HI(ctx->screen->info.address32_hi), 0); - desc[2] = LLVMConstInt(ctx->i32, 0xffffffff, 0); - desc[3] = LLVMConstInt(ctx->i32, rsrc3, false); + desc[2] = LLVMConstInt(ctx->ac.i32, 0xffffffff, 0); + desc[3] = LLVMConstInt(ctx->ac.i32, rsrc3, false); return ac_build_gather_values(&ctx->ac, desc, 4); } @@ -479,7 +479,7 @@ static LLVMValueRef si_nir_load_tcs_varyings(struct ac_shader_abi *abi, } if (!param_index) { - param_index = LLVMConstInt(ctx->i32, const_index, 0); + param_index = LLVMConstInt(ctx->ac.i32, const_index, 0); } dw_addr = get_dw_address_from_generic_indices(ctx, stride, dw_addr, @@ -527,7 +527,7 @@ LLVMValueRef si_nir_load_input_tes(struct ac_shader_abi *abi, base = ac_get_arg(&ctx->ac, ctx->tcs_offchip_offset); if (!param_index) { - param_index = LLVMConstInt(ctx->i32, const_index, 0); + param_index = LLVMConstInt(ctx->ac.i32, const_index, 0); } addr = get_tcs_tes_buffer_address_from_generic_indices(ctx, vertex_index, @@ -587,7 +587,7 @@ static void si_nir_store_output_tcs(struct ac_shader_abi *abi, bool is_const = !param_index; if (!param_index) - param_index = LLVMConstInt(ctx->i32, const_index, 0); + param_index = LLVMConstInt(ctx->ac.i32, const_index, 0); const bool is_patch = var->data.patch || var->data.location == VARYING_SLOT_TESS_LEVEL_INNER || @@ -716,9 +716,9 @@ static LLVMValueRef load_tess_level(struct si_shader_context *ctx, base = ac_get_arg(&ctx->ac, ctx->tcs_offchip_offset); addr = get_tcs_tes_buffer_address(ctx, get_rel_patch_id(ctx), NULL, - LLVMConstInt(ctx->i32, param, 0)); + LLVMConstInt(ctx->ac.i32, param, 0)); - return buffer_load(ctx, ctx->f32, + return buffer_load(ctx, ctx->ac.f32, ~0, ctx->tess_offchip_ring, base, addr, true); } @@ -729,14 +729,14 @@ static LLVMValueRef load_tess_level_default(struct si_shader_context *ctx, LLVMValueRef buf, slot, val[4]; int i, offset; - slot = LLVMConstInt(ctx->i32, SI_HS_CONST_DEFAULT_TESS_LEVELS, 0); + slot = LLVMConstInt(ctx->ac.i32, SI_HS_CONST_DEFAULT_TESS_LEVELS, 0); buf = ac_get_arg(&ctx->ac, ctx->rw_buffers); buf = ac_build_load_to_sgpr(&ctx->ac, buf, slot); offset = semantic_name == TGSI_SEMANTIC_TESS_DEFAULT_INNER_LEVEL ? 4 : 0; for (i = 0; i < 4; i++) val[i] = si_buffer_load_const(ctx, buf, - LLVMConstInt(ctx->i32, (offset + i) * 4, 0)); + LLVMConstInt(ctx->ac.i32, (offset + i) * 4, 0)); return ac_build_gather_values(&ctx->ac, val, 4); } @@ -811,13 +811,13 @@ static void si_copy_tcs_inputs(struct si_shader_context *ctx) unsigned i = u_bit_scan64(&inputs); LLVMValueRef lds_ptr = LLVMBuildAdd(ctx->ac.builder, lds_base, - LLVMConstInt(ctx->i32, 4 * i, 0), + LLVMConstInt(ctx->ac.i32, 4 * i, 0), ""); LLVMValueRef buffer_addr = get_tcs_tes_buffer_address(ctx, get_rel_patch_id(ctx), invocation_id, - LLVMConstInt(ctx->i32, i, 0)); + LLVMConstInt(ctx->ac.i32, i, 0)); LLVMValueRef value = lshs_lds_load(ctx, ctx->ac.i32, ~0, lds_ptr); @@ -851,7 +851,7 @@ static void si_write_tess_factors(struct si_shader_context *ctx, */ ac_build_ifcc(&ctx->ac, LLVMBuildICmp(ctx->ac.builder, LLVMIntEQ, - invocation_id, ctx->i32_0, ""), 6503); + invocation_id, ctx->ac.i32_0, ""), 6503); /* Determine the layout of one tess factor element in the buffer. */ switch (shader->key.part.tcs.epilog.prim_mode) { @@ -876,8 +876,8 @@ static void si_write_tess_factors(struct si_shader_context *ctx, } for (i = 0; i < 4; i++) { - inner[i] = LLVMGetUndef(ctx->i32); - outer[i] = LLVMGetUndef(ctx->i32); + inner[i] = LLVMGetUndef(ctx->ac.i32); + outer[i] = LLVMGetUndef(ctx->ac.i32); } if (shader->key.part.tcs.epilog.invoc0_tess_factors_are_def) { @@ -895,10 +895,10 @@ static void si_write_tess_factors(struct si_shader_context *ctx, lds_base = tcs_out_current_patch_data_offset; lds_inner = LLVMBuildAdd(ctx->ac.builder, lds_base, - LLVMConstInt(ctx->i32, + LLVMConstInt(ctx->ac.i32, tess_inner_index * 4, 0), ""); lds_outer = LLVMBuildAdd(ctx->ac.builder, lds_base, - LLVMConstInt(ctx->i32, + LLVMConstInt(ctx->ac.i32, tess_outer_index * 4, 0), ""); for (i = 0; i < outer_comps; i++) { @@ -934,18 +934,18 @@ static void si_write_tess_factors(struct si_shader_context *ctx, tf_base = ac_get_arg(&ctx->ac, ctx->tcs_factor_offset); byteoffset = LLVMBuildMul(ctx->ac.builder, rel_patch_id, - LLVMConstInt(ctx->i32, 4 * stride, 0), ""); + LLVMConstInt(ctx->ac.i32, 4 * stride, 0), ""); ac_build_ifcc(&ctx->ac, LLVMBuildICmp(ctx->ac.builder, LLVMIntEQ, - rel_patch_id, ctx->i32_0, ""), 6504); + rel_patch_id, ctx->ac.i32_0, ""), 6504); /* Store the dynamic HS control word. */ offset = 0; if (ctx->screen->info.chip_class <= GFX8) { ac_build_buffer_store_dword(&ctx->ac, buffer, - LLVMConstInt(ctx->i32, 0x80000000, 0), - 1, ctx->i32_0, tf_base, + LLVMConstInt(ctx->ac.i32, 0x80000000, 0), + 1, ctx->ac.i32_0, tf_base, offset, ac_glc); offset += 4; } @@ -974,7 +974,7 @@ static void si_write_tess_factors(struct si_shader_context *ctx, param_outer = si_shader_io_get_unique_index_patch( TGSI_SEMANTIC_TESSOUTER, 0); tf_outer_offset = get_tcs_tes_buffer_address(ctx, rel_patch_id, NULL, - LLVMConstInt(ctx->i32, param_outer, 0)); + LLVMConstInt(ctx->ac.i32, param_outer, 0)); unsigned outer_vec_size = ac_has_vec3_support(ctx->screen->info.chip_class, false) ? @@ -988,7 +988,7 @@ static void si_write_tess_factors(struct si_shader_context *ctx, param_inner = si_shader_io_get_unique_index_patch( TGSI_SEMANTIC_TESSINNER, 0); tf_inner_offset = get_tcs_tes_buffer_address(ctx, rel_patch_id, NULL, - LLVMConstInt(ctx->i32, param_inner, 0)); + LLVMConstInt(ctx->ac.i32, param_inner, 0)); inner_vec = inner_comps == 1 ? inner[0] : ac_build_gather_values(&ctx->ac, inner, inner_comps); @@ -1026,16 +1026,16 @@ static void si_llvm_emit_tcs_epilogue(struct ac_shader_abi *abi, ac_build_endif(&ctx->ac, ctx->merged_wrap_if_label); values[0] = rel_patch_id; - values[1] = LLVMGetUndef(ctx->i32); - rel_patch_id = ac_build_phi(&ctx->ac, ctx->i32, 2, values, blocks); + values[1] = LLVMGetUndef(ctx->ac.i32); + rel_patch_id = ac_build_phi(&ctx->ac, ctx->ac.i32, 2, values, blocks); values[0] = tf_lds_offset; - values[1] = LLVMGetUndef(ctx->i32); - tf_lds_offset = ac_build_phi(&ctx->ac, ctx->i32, 2, values, blocks); + values[1] = LLVMGetUndef(ctx->ac.i32); + tf_lds_offset = ac_build_phi(&ctx->ac, ctx->ac.i32, 2, values, blocks); values[0] = invocation_id; - values[1] = ctx->i32_1; /* cause the epilog to skip threads */ - invocation_id = ac_build_phi(&ctx->ac, ctx->i32, 2, values, blocks); + values[1] = ctx->ac.i32_1; /* cause the epilog to skip threads */ + invocation_id = ac_build_phi(&ctx->ac, ctx->ac.i32, 2, values, blocks); } /* Return epilog parameters from this function. */ @@ -1171,7 +1171,7 @@ void si_llvm_emit_ls_epilogue(struct ac_shader_abi *abi, unsigned max_outputs, int param = si_shader_io_get_unique_index(name, index, false); LLVMValueRef dw_addr = LLVMBuildAdd(ctx->ac.builder, base_dw_addr, - LLVMConstInt(ctx->i32, param * 4, 0), ""); + LLVMConstInt(ctx->ac.i32, param * 4, 0), ""); for (chan = 0; chan < 4; chan++) { if (!(info->output_usagemask[i] & (1 << chan))) diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index bfbfc1aeec1..aa16f865288 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -1055,7 +1055,7 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, struct nir_shader *nir) ctx->shader->selector->info.colors_read; LLVMValueRef main_fn = ctx->main_fn; - LLVMValueRef undef = LLVMGetUndef(ctx->f32); + LLVMValueRef undef = LLVMGetUndef(ctx->ac.f32); unsigned offset = SI_PARAM_POS_FIXED_PT + 1; -- 2.30.2