From: Marek Olšák <marek.ol...@amd.com> --- src/gallium/drivers/radeonsi/si_shader.c | 68 +++++++++---------- .../drivers/radeonsi/si_shader_tgsi_mem.c | 15 ++-- 2 files changed, 38 insertions(+), 45 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 9a674ba8e26..c39b80bb396 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -17,21 +17,20 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "gallivm/lp_bld_const.h" #include "gallivm/lp_bld_intr.h" -#include "gallivm/lp_bld_arit.h" #include "util/u_memory.h" #include "util/u_string.h" #include "tgsi/tgsi_build.h" #include "tgsi/tgsi_util.h" #include "tgsi/tgsi_dump.h" #include "ac_exp_param.h" #include "ac_shader_util.h" #include "ac_llvm_util.h" #include "si_shader_internal.h" @@ -341,35 +340,35 @@ static LLVMValueRef get_tcs_out_patch_stride(struct si_shader_context *ctx) unsigned vertex_dw_stride = get_tcs_out_vertex_dw_stride_constant(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); } static LLVMValueRef get_tcs_out_patch0_offset(struct si_shader_context *ctx) { - return lp_build_mul_imm(&ctx->bld_base.uint_bld, - si_unpack_param(ctx, - ctx->param_tcs_out_lds_offsets, - 0, 16), - 4); + return LLVMBuildMul(ctx->ac.builder, + si_unpack_param(ctx, + ctx->param_tcs_out_lds_offsets, + 0, 16), + LLVMConstInt(ctx->i32, 4, 0), ""); } static LLVMValueRef get_tcs_out_patch0_patch_data_offset(struct si_shader_context *ctx) { - return lp_build_mul_imm(&ctx->bld_base.uint_bld, - si_unpack_param(ctx, - ctx->param_tcs_out_lds_offsets, - 16, 16), - 4); + return LLVMBuildMul(ctx->ac.builder, + si_unpack_param(ctx, + ctx->param_tcs_out_lds_offsets, + 16, 16), + LLVMConstInt(ctx->i32, 4, 0), ""); } static LLVMValueRef get_tcs_in_current_patch_offset(struct si_shader_context *ctx) { LLVMValueRef patch_stride = get_tcs_in_patch_stride(ctx); LLVMValueRef rel_patch_id = get_rel_patch_id(ctx); return LLVMBuildMul(ctx->ac.builder, patch_stride, rel_patch_id, ""); } @@ -1149,41 +1148,41 @@ static LLVMValueRef lds_load(struct lp_build_tgsi_context *bld_base, /* Split 64-bit loads. */ if (llvm_type_is_64bit(ctx, type)) { LLVMValueRef lo, hi; lo = lds_load(bld_base, ctx->i32, swizzle, dw_addr); hi = lds_load(bld_base, ctx->i32, swizzle + 1, dw_addr); return si_llvm_emit_fetch_64bit(bld_base, type, lo, hi); } - dw_addr = lp_build_add(&bld_base->uint_bld, dw_addr, - LLVMConstInt(ctx->i32, swizzle, 0)); + dw_addr = LLVMBuildAdd(ctx->ac.builder, dw_addr, + LLVMConstInt(ctx->i32, swizzle, 0), ""); value = ac_lds_load(&ctx->ac, dw_addr); return LLVMBuildBitCast(ctx->ac.builder, value, type, ""); } /** * Store to LDS. * * \param swizzle offset (typically 0..3) * \param dw_addr address in dwords * \param value value to store */ static void lds_store(struct si_shader_context *ctx, unsigned dw_offset_imm, LLVMValueRef dw_addr, LLVMValueRef value) { - dw_addr = lp_build_add(&ctx->bld_base.uint_bld, dw_addr, - LLVMConstInt(ctx->i32, dw_offset_imm, 0)); + dw_addr = LLVMBuildAdd(ctx->ac.builder, dw_addr, + LLVMConstInt(ctx->i32, dw_offset_imm, 0), ""); ac_lds_store(&ctx->ac, dw_addr, value); } enum si_tess_ring { TCS_FACTOR_RING, TESS_OFFCHIP_RING_TCS, TESS_OFFCHIP_RING_TES, }; @@ -1612,21 +1611,20 @@ static void si_nir_store_output_tcs(struct ac_shader_abi *abi, LLVMValueRef si_llvm_load_input_gs(struct ac_shader_abi *abi, unsigned input_index, unsigned vtx_offset_param, LLVMTypeRef type, unsigned swizzle) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); struct lp_build_tgsi_context *bld_base = &ctx->bld_base; struct si_shader *shader = ctx->shader; - struct lp_build_context *uint = &ctx->bld_base.uint_bld; LLVMValueRef vtx_offset, soffset; struct tgsi_shader_info *info = &shader->selector->info; unsigned semantic_name = info->input_semantic_name[input_index]; unsigned semantic_index = info->input_semantic_index[input_index]; unsigned param; LLVMValueRef value; param = si_shader_io_get_unique_index(semantic_name, semantic_index, false); /* GFX9 has the ESGS ring in LDS. */ @@ -1664,21 +1662,22 @@ LLVMValueRef si_llvm_load_input_gs(struct ac_shader_abi *abi, values[chan] = si_llvm_load_input_gs(abi, input_index, vtx_offset_param, type, chan); } return ac_build_gather_values(&ctx->ac, values, TGSI_NUM_CHANNELS); } /* Get the vertex offset parameter on GFX6. */ LLVMValueRef gs_vtx_offset = ctx->gs_vtx_offset[vtx_offset_param]; - vtx_offset = lp_build_mul_imm(uint, gs_vtx_offset, 4); + vtx_offset = LLVMBuildMul(ctx->ac.builder, gs_vtx_offset, + LLVMConstInt(ctx->i32, 4, 0), ""); soffset = LLVMConstInt(ctx->i32, (param * 4 + swizzle) * 256, 0); value = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, ctx->i32_0, vtx_offset, soffset, 0, 1, 0, true, false); if (llvm_type_is_64bit(ctx, type)) { LLVMValueRef value2; soffset = LLVMConstInt(ctx->i32, (param * 4 + swizzle + 1) * 256, 0); value2 = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, @@ -1993,27 +1992,26 @@ static LLVMValueRef buffer_load_const(struct si_shader_context *ctx, LLVMValueRef resource, LLVMValueRef offset) { return ac_build_buffer_load(&ctx->ac, resource, 1, NULL, offset, NULL, 0, 0, 0, true, true); } static LLVMValueRef load_sample_position(struct ac_shader_abi *abi, LLVMValueRef sample_id) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); - struct lp_build_context *uint_bld = &ctx->bld_base.uint_bld; LLVMValueRef desc = LLVMGetParam(ctx->main_fn, ctx->param_rw_buffers); LLVMValueRef buf_index = LLVMConstInt(ctx->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 = lp_build_mul_imm(uint_bld, sample_id, 8); + 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 pos[4] = { buffer_load_const(ctx, resource, offset0), buffer_load_const(ctx, resource, offset1), LLVMConstReal(ctx->f32, 0), LLVMConstReal(ctx->f32, 0) }; return ac_build_gather_values(&ctx->ac, pos, 4); @@ -2021,35 +2019,34 @@ static LLVMValueRef load_sample_position(struct ac_shader_abi *abi, LLVMValueRef static LLVMValueRef load_sample_mask_in(struct ac_shader_abi *abi) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); return ac_to_integer(&ctx->ac, abi->sample_coverage); } static LLVMValueRef si_load_tess_coord(struct ac_shader_abi *abi) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); - struct lp_build_context *bld = &ctx->bld_base.base; - LLVMValueRef coord[4] = { LLVMGetParam(ctx->main_fn, ctx->param_tes_u), LLVMGetParam(ctx->main_fn, ctx->param_tes_v), ctx->ac.f32_0, ctx->ac.f32_0 }; /* For triangles, the vector should be (u, v, 1-u-v). */ if (ctx->shader->selector->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == - PIPE_PRIM_TRIANGLES) - coord[2] = lp_build_sub(bld, ctx->ac.f32_1, - lp_build_add(bld, coord[0], coord[1])); - + PIPE_PRIM_TRIANGLES) { + coord[2] = LLVMBuildFSub(ctx->ac.builder, ctx->ac.f32_1, + LLVMBuildFAdd(ctx->ac.builder, + coord[0], coord[1], ""), ""); + } return ac_build_gather_values(&ctx->ac, coord, 4); } static LLVMValueRef load_tess_level(struct si_shader_context *ctx, unsigned semantic_name) { LLVMValueRef base, addr; int param = si_shader_io_get_unique_index_patch(semantic_name, 0); @@ -2704,23 +2701,23 @@ static void si_llvm_emit_clipvertex(struct si_shader_context *ctx, /* Compute dot products of position and user clip plane vectors */ for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) { for (const_chan = 0; const_chan < TGSI_NUM_CHANNELS; const_chan++) { LLVMValueRef addr = LLVMConstInt(ctx->i32, ((reg_index * 4 + chan) * 4 + const_chan) * 4, 0); base_elt = buffer_load_const(ctx, const_resource, addr); args->out[chan] = - lp_build_add(&ctx->bld_base.base, args->out[chan], - lp_build_mul(&ctx->bld_base.base, base_elt, - out_elts[const_chan])); + LLVMBuildFAdd(ctx->ac.builder, args->out[chan], + LLVMBuildFMul(ctx->ac.builder, base_elt, + out_elts[const_chan], ""), ""); } } args->enabled_channels = 0xf; args->valid_mask = 0; args->done = 0; args->target = V_008DFC_SQ_EXP_POS + 2 + reg_index; args->compr = 0; } } @@ -4326,21 +4323,20 @@ static unsigned si_llvm_get_stream(struct lp_build_tgsi_context *bld_base, return stream; } /* Emit one vertex from the geometry shader */ static void si_llvm_emit_vertex(struct ac_shader_abi *abi, unsigned stream, LLVMValueRef *addrs) { struct si_shader_context *ctx = si_shader_context_from_abi(abi); struct tgsi_shader_info *info = &ctx->shader->selector->info; - struct lp_build_context *uint = &ctx->bld_base.uint_bld; struct si_shader *shader = ctx->shader; struct lp_build_if_state if_state; LLVMValueRef soffset = LLVMGetParam(ctx->main_fn, ctx->param_gs2vs_offset); LLVMValueRef gs_next_vertex; LLVMValueRef can_emit; unsigned chan, offset; int i; /* Write vertex attribute values to GSVS ring */ @@ -4373,36 +4369,35 @@ static void si_llvm_emit_vertex(struct ac_shader_abi *abi, if (!(info->output_usagemask[i] & (1 << chan)) || ((info->output_streams[i] >> (2 * chan)) & 3) != stream) continue; LLVMValueRef out_val = LLVMBuildLoad(ctx->ac.builder, addrs[4 * i + chan], ""); LLVMValueRef voffset = LLVMConstInt(ctx->i32, offset * shader->selector->gs_max_out_vertices, 0); offset++; - voffset = lp_build_add(uint, voffset, gs_next_vertex); - voffset = lp_build_mul_imm(uint, voffset, 4); + voffset = LLVMBuildAdd(ctx->ac.builder, voffset, gs_next_vertex, ""); + voffset = LLVMBuildMul(ctx->ac.builder, voffset, + LLVMConstInt(ctx->i32, 4, 0), ""); out_val = ac_to_integer(&ctx->ac, out_val); ac_build_buffer_store_dword(&ctx->ac, ctx->gsvs_ring[stream], out_val, 1, voffset, soffset, 0, 1, 1, true, true); } } - gs_next_vertex = lp_build_add(uint, gs_next_vertex, - ctx->i32_1); - + gs_next_vertex = LLVMBuildAdd(ctx->ac.builder, gs_next_vertex, ctx->i32_1, ""); LLVMBuildStore(ctx->ac.builder, gs_next_vertex, ctx->gs_next_vertex[stream]); /* Signal vertex emission */ ac_build_sendmsg(&ctx->ac, AC_SENDMSG_GS_OP_EMIT | AC_SENDMSG_GS | (stream << 8), si_get_gs_wave_id(ctx)); if (!use_kill) lp_build_endif(&if_state); } /* Emit one vertex from the geometry shader */ @@ -5727,22 +5722,20 @@ static void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret) /* Generate code for the hardware VS shader stage to go with a geometry shader */ struct si_shader * si_generate_gs_copy_shader(struct si_screen *sscreen, struct si_compiler *compiler, struct si_shader_selector *gs_selector, struct pipe_debug_callback *debug) { struct si_shader_context ctx; struct si_shader *shader; LLVMBuilderRef builder; - struct lp_build_tgsi_context *bld_base = &ctx.bld_base; - struct lp_build_context *uint = &bld_base->uint_bld; struct si_shader_output_values *outputs; struct tgsi_shader_info *gsinfo = &gs_selector->info; int i, r; outputs = MALLOC(gsinfo->num_outputs * sizeof(outputs[0])); if (!outputs) return NULL; shader = CALLOC_STRUCT(si_shader); @@ -5761,21 +5754,22 @@ si_generate_gs_copy_shader(struct si_screen *sscreen, si_init_shader_ctx(&ctx, sscreen, compiler); ctx.shader = shader; ctx.type = PIPE_SHADER_VERTEX; builder = ctx.ac.builder; create_function(&ctx); preload_ring_buffers(&ctx); LLVMValueRef voffset = - lp_build_mul_imm(uint, ctx.abi.vertex_id, 4); + LLVMBuildMul(ctx.ac.builder, ctx.abi.vertex_id, + LLVMConstInt(ctx.i32, 4, 0), ""); /* Fetch the vertex stream ID.*/ LLVMValueRef stream_id; if (gs_selector->so.num_outputs) stream_id = si_unpack_param(&ctx, ctx.param_streamout_config, 24, 2); else stream_id = ctx.i32_0; /* Fill in output information. */ diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c index ef561d409d7..a3091c09d69 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c @@ -18,21 +18,20 @@ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "si_shader_internal.h" #include "si_pipe.h" #include "sid.h" -#include "gallivm/lp_bld_arit.h" #include "gallivm/lp_bld_intr.h" #include "tgsi/tgsi_build.h" #include "tgsi/tgsi_util.h" #include "ac_llvm_util.h" static void build_tex_intrinsic(const struct lp_build_tgsi_action *action, struct lp_build_tgsi_context *bld_base, struct lp_build_emit_data *emit_data); static const struct lp_build_tgsi_action tex_action; @@ -1481,47 +1480,47 @@ static void tex_fetch_args( if (target == TGSI_TEXTURE_2D_MSAA || target == TGSI_TEXTURE_2D_ARRAY_MSAA) { ac_apply_fmask_to_sample(&ctx->ac, fmask_ptr, args.coords, target == TGSI_TEXTURE_2D_ARRAY_MSAA); } if (opcode == TGSI_OPCODE_TXF || opcode == TGSI_OPCODE_TXF_LZ) { /* add tex offsets */ if (inst->Texture.NumOffsets) { - struct lp_build_context *uint_bld = &bld_base->uint_bld; const struct tgsi_texture_offset *off = inst->TexOffsets; assert(inst->Texture.NumOffsets == 1); switch (target) { case TGSI_TEXTURE_3D: - args.coords[2] = lp_build_add(uint_bld, args.coords[2], - ctx->imms[off->Index * TGSI_NUM_CHANNELS + off->SwizzleZ]); + args.coords[2] = + LLVMBuildAdd(ctx->ac.builder, args.coords[2], + ctx->imms[off->Index * TGSI_NUM_CHANNELS + off->SwizzleZ], ""); /* fall through */ case TGSI_TEXTURE_2D: case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_RECT: case TGSI_TEXTURE_SHADOWRECT: case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_SHADOW2D_ARRAY: args.coords[1] = - lp_build_add(uint_bld, args.coords[1], - ctx->imms[off->Index * TGSI_NUM_CHANNELS + off->SwizzleY]); + LLVMBuildAdd(ctx->ac.builder, args.coords[1], + ctx->imms[off->Index * TGSI_NUM_CHANNELS + off->SwizzleY], ""); /* fall through */ case TGSI_TEXTURE_1D: case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_SHADOW1D_ARRAY: args.coords[0] = - lp_build_add(uint_bld, args.coords[0], - ctx->imms[off->Index * TGSI_NUM_CHANNELS + off->SwizzleX]); + LLVMBuildAdd(ctx->ac.builder, args.coords[0], + ctx->imms[off->Index * TGSI_NUM_CHANNELS + off->SwizzleX], ""); break; /* texture offsets do not apply to other texture targets */ } } } args.dmask = 0xf; if (opcode == TGSI_OPCODE_TG4) { unsigned gather_comp = 0; -- 2.17.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev