And switch to the xxx2 versions of the ac/llvm functions.
Reviewed-by: Mihai Preda <mhpreda@gmail.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19035>
static LLVMValueRef ngg_get_query_buf(struct si_shader_context *ctx)
{
LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
-
- return ac_build_load_to_sgpr(&ctx->ac, buf_ptr,
- LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_BUF, false));
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
+ return ac_build_load_to_sgpr2(&ctx->ac, type, buf_ptr,
+ LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_BUF, false));
}
static LLVMValueRef ngg_get_emulated_counters_buf(struct si_shader_context *ctx)
{
LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
- return ac_build_load_to_sgpr(&ctx->ac, buf_ptr,
- LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_EMULATED_COUNTERS_BUF, false));
+ return ac_build_load_to_sgpr2(&ctx->ac, type, buf_ptr,
+ LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_EMULATED_COUNTERS_BUF, false));
}
/**
/* Load the viewport state for small prim culling. */
bool prim_is_lines = shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES;
LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->small_prim_cull_info);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->small_prim_cull_info);
/* Lines will always use the non-AA viewport transformation. */
- LLVMValueRef vp = ac_build_load_to_sgpr(&ctx->ac, ptr,
- prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0);
+ LLVMValueRef vp = ac_build_load_to_sgpr2(&ctx->ac, type, ptr,
+ prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0);
vp = LLVMBuildBitCast(builder, vp, ctx->ac.v4f32, "");
vp_scale[0] = ac_llvm_extract_elem(&ctx->ac, vp, 0);
vp_scale[1] = ac_llvm_extract_elem(&ctx->ac, vp, 1);
options.cull_w = true;
if (prim_is_lines) {
- ptr = LLVMBuildPointerCast(ctx->ac.builder, ptr,
- LLVMPointerType(ctx->ac.v2f32, AC_ADDR_SPACE_CONST_32BIT), "");
- LLVMValueRef terms = ac_build_load_to_sgpr(&ctx->ac, ptr, LLVMConstInt(ctx->ac.i32, 4, 0));
+ LLVMValueRef terms = ac_build_load_to_sgpr2(&ctx->ac, ctx->ac.v2f32, ptr, LLVMConstInt(ctx->ac.i32, 4, 0));
terms = LLVMBuildBitCast(builder, terms, ctx->ac.v2f32, "");
clip_half_line_width[0] = ac_llvm_extract_elem(&ctx->ac, terms, 0);
clip_half_line_width[1] = ac_llvm_extract_elem(&ctx->ac, terms, 1);
case nir_intrinsic_load_tess_level_inner_default: {
LLVMValueRef slot = LLVMConstInt(ctx->ac.i32, SI_HS_CONST_DEFAULT_TESS_LEVELS, 0);
LLVMValueRef buf = ac_get_arg(&ctx->ac, ctx->internal_bindings);
- buf = ac_build_load_to_sgpr(&ctx->ac, buf, slot);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
+ buf = ac_build_load_to_sgpr2(&ctx->ac, type, buf, slot);
int offset = op == nir_intrinsic_load_tess_level_inner_default ? 4 : 0;
LLVMValueRef val[4];
case nir_intrinsic_load_viewport_xy_scale_and_offset: {
bool prim_is_lines = ctx->shader->key.ge.opt.ngg_culling & SI_NGG_CULL_LINES;
LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->small_prim_cull_info);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->small_prim_cull_info);
LLVMValueRef terms =
- ac_build_load_to_sgpr(&ctx->ac, ptr, prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0);
+ ac_build_load_to_sgpr2(&ctx->ac, type, ptr, prim_is_lines ? ctx->ac.i32_1 : ctx->ac.i32_0);
return LLVMBuildBitCast(ctx->ac.builder, terms, ctx->ac.v4f32, "");
}
{
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
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);
+ LLVMValueRef const_resource = ac_build_load_to_sgpr2(&ctx->ac, type, ptr, constbuf_index);
LLVMValueRef addr = LLVMConstInt(ctx->ac.i32, ucp_id * 16, 0);
return ac_build_buffer_load(&ctx->ac, const_resource, 4, NULL, addr, NULL,
ctx->ac.f32, 0, true, true);
{
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
- return ac_build_load_to_sgpr(
- &ctx->ac, buf_ptr, LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false));
+ return ac_build_load_to_sgpr2(
+ &ctx->ac, type, buf_ptr, LLVMConstInt(ctx->ac.i32, SI_VS_STREAMOUT_BUF0 + buffer, false));
}
bool si_llvm_translate_nir(struct si_shader_context *ctx, struct si_shader *shader,
if (ctx->shader->key.ge.opt.ngg_culling &&
ctx->shader->key.ge.part.vs.prolog.instance_divisor_is_fetched) {
LLVMValueRef buf = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
ctx->instance_divisor_constbuf =
- ac_build_load_to_sgpr(
- &ctx->ac, buf, LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0));
+ ac_build_load_to_sgpr2(
+ &ctx->ac, type, buf, LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0));
}
break;
static LLVMValueRef ngg_get_emulated_counters_buf(struct si_shader_context *ctx)
{
LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
- return ac_build_load_to_sgpr(&ctx->ac, buf_ptr,
- LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_EMULATED_COUNTERS_BUF, false));
+ return ac_build_load_to_sgpr2(&ctx->ac, type, buf_ptr,
+ LLVMConstInt(ctx->ac.i32, SI_GS_QUERY_EMULATED_COUNTERS_BUF, false));
}
void si_llvm_gs_build_end(struct si_shader_context *ctx)
LLVMBuilderRef builder = ctx->ac.builder;
LLVMValueRef offset = LLVMConstInt(ctx->ac.i32, SI_RING_GSVS, 0);
LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
- LLVMValueRef base_ring = ac_build_load_to_sgpr(&ctx->ac, buf_ptr, offset);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
+ LLVMValueRef base_ring = ac_build_load_to_sgpr2(&ctx->ac, type, buf_ptr, offset);
/* The conceptual layout of the GSVS ring is
* v0c0 .. vLv0 v0c1 .. vLc1 ..
si_llvm_create_main_func(&ctx, false);
LLVMValueRef buf_ptr = ac_get_arg(&ctx.ac, ctx.internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx.ac, &ctx.args, ctx.internal_bindings);
ctx.gsvs_ring[0] =
- ac_build_load_to_sgpr(&ctx.ac, buf_ptr, LLVMConstInt(ctx.ac.i32, SI_RING_GSVS, 0));
+ ac_build_load_to_sgpr2(&ctx.ac, type, buf_ptr, LLVMConstInt(ctx.ac.i32, SI_RING_GSVS, 0));
LLVMValueRef voffset =
LLVMBuildMul(ctx.ac.builder, ctx.abi.vertex_id, LLVMConstInt(ctx.ac.i32, 4, 0), "");
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
LLVMValueRef desc = ac_get_arg(&ctx->ac, ctx->internal_bindings);
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);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
+ LLVMValueRef resource = ac_build_load_to_sgpr2(&ctx->ac, type, desc, buf_index);
/* offset = sample_id * 8 (8 = 2 floats containing samplepos.xy) */
LLVMValueRef offset0 =
ptr =
LLVMBuildPointerCast(ctx->ac.builder, ptr, ac_array_in_const32_addr_space(ctx->ac.v8i32), "");
image =
- ac_build_load_to_sgpr(&ctx->ac, ptr, LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0 / 2, 0));
+ ac_build_load_to_sgpr2(&ctx->ac, ctx->ac.v8i32, ptr, LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0 / 2, 0));
unsigned chan = 0;
if (ctx->screen->info.gfx_level < GFX11 &&
ctx->shader->key.ps.mono.fbfetch_msaa &&
!(ctx->screen->debug_flags & DBG(NO_FMASK))) {
- fmask = ac_build_load_to_sgpr(&ctx->ac, ptr,
+
+ fmask = ac_build_load_to_sgpr2(&ctx->ac, ctx->ac.v8i32, ptr,
LLVMConstInt(ctx->ac.i32, SI_PS_IMAGE_COLORBUF0_FMASK / 2, 0));
ac_apply_fmask_to_sample(&ctx->ac, fmask, args.coords,
/* Load the buffer descriptor. */
slot = LLVMConstInt(ctx->ac.i32, SI_PS_CONST_POLY_STIPPLE, 0);
- desc = ac_build_load_to_sgpr(&ctx->ac, param_internal_bindings, slot);
+
+ desc = ac_build_load_to_sgpr2(&ctx->ac, ctx->ac.v4i32, param_internal_bindings, slot);
/* The stipple pattern is 32x32, each row has 32 bits. */
offset = LLVMBuildMul(builder, address[1], LLVMConstInt(ctx->ac.i32, 4, 0), "");
index =
LLVMBuildAdd(ctx->ac.builder, index, LLVMConstInt(ctx->ac.i32, SI_NUM_SHADER_BUFFERS, 0), "");
- return ac_build_load_to_sgpr(&ctx->ac, ptr, index);
+ return ac_build_load_to_sgpr2(&ctx->ac,
+ ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->const_and_shader_buffers),
+ ptr,
+ index);
}
static LLVMValueRef load_ssbo(struct ac_shader_abi *abi, LLVMValueRef index, bool write, bool non_uniform)
return ac_get_arg(&ctx->ac, ctx->cs_shaderbuf[LLVMConstIntGetZExtValue(index)]);
LLVMValueRef rsrc_ptr = ac_get_arg(&ctx->ac, ctx->const_and_shader_buffers);
-
index = si_llvm_bound_index(ctx, index, ctx->num_shader_buffers);
index = LLVMBuildSub(ctx->ac.builder, LLVMConstInt(ctx->ac.i32, SI_NUM_SHADER_BUFFERS - 1, 0),
index, "");
- return ac_build_load_to_sgpr(&ctx->ac, rsrc_ptr, index);
+ return ac_build_load_to_sgpr2(&ctx->ac,
+ ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->const_and_shader_buffers),
+ rsrc_ptr, index);
}
/**
/* AC_DESC_FMASK is handled exactly like AC_DESC_IMAGE. The caller should
* adjust "index" to point to FMASK. */
-static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, LLVMValueRef list,
+static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, LLVMTypeRef type, LLVMValueRef list,
LLVMValueRef index, enum ac_descriptor_type desc_type,
bool uses_store, bool bindless)
{
if (desc_type == AC_DESC_BUFFER) {
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->ac.v4i32), "");
+ type = ctx->ac.v4i32;
} else {
assert(desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_FMASK);
}
if (bindless)
- rsrc = ac_build_load_to_sgpr_uint_wraparound(&ctx->ac, list, index);
+ rsrc = ac_build_load_to_sgpr_uint_wraparound2(&ctx->ac, type, list, index);
else
- rsrc = ac_build_load_to_sgpr(&ctx->ac, list, index);
+ rsrc = ac_build_load_to_sgpr2(&ctx->ac, type, list, index);
if (desc_type == AC_DESC_IMAGE)
rsrc = fixup_image_desc(ctx, rsrc, uses_store);
/**
* Load an image view, fmask view. or sampler state descriptor.
*/
-static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMValueRef list,
+static LLVMValueRef si_load_sampler_desc(struct si_shader_context *ctx, LLVMTypeRef list_type,
+ LLVMValueRef list,
LLVMValueRef index, enum ac_descriptor_type type)
{
LLVMBuilderRef builder = ctx->ac.builder;
/* The buffer is in [4:7]. */
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->ac.v4i32), "");
+ list_type = ctx->ac.v4i32;
break;
case AC_DESC_FMASK:
/* The FMASK is at [8:15]. */
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->ac.v4i32), "");
+ list_type = ctx->ac.v4i32;
break;
case AC_DESC_PLANE_0:
case AC_DESC_PLANE_1:
unreachable("Plane descriptor requested in radeonsi.");
}
- return ac_build_load_to_sgpr(&ctx->ac, list, index);
+ return ac_build_load_to_sgpr2(&ctx->ac, list_type, list, index);
}
static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned descriptor_set,
if (bindless) {
LLVMValueRef list = ac_get_arg(&ctx->ac, ctx->bindless_samplers_and_images);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->bindless_samplers_and_images);
/* dynamic_index is the bindless handle */
if (image) {
dynamic_index = LLVMBuildAdd(ctx->ac.builder, dynamic_index, ctx->ac.i32_1, "");
}
- return si_load_image_desc(ctx, list, dynamic_index, desc_type, write, true);
+ return si_load_image_desc(ctx, type, list, dynamic_index, desc_type, write, true);
}
/* Since bindless handle arithmetic can contain an unsigned integer
dynamic_index =
LLVMBuildMul(ctx->ac.builder, dynamic_index, LLVMConstInt(ctx->ac.i64, 2, 0), "");
list = ac_build_pointer_add(&ctx->ac, ctx->ac.v8i32, list, dynamic_index);
- return si_load_sampler_desc(ctx, list, ctx->ac.i32_0, desc_type);
+ return si_load_sampler_desc(ctx, type, list, ctx->ac.i32_0, desc_type);
}
unsigned num_slots = image ? ctx->num_images : ctx->num_samplers;
const_index = base_index;
LLVMValueRef list = ac_get_arg(&ctx->ac, ctx->samplers_and_images);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->samplers_and_images);
LLVMValueRef index = LLVMConstInt(ctx->ac.i32, const_index, false);
if (dynamic_index) {
}
index = LLVMBuildSub(ctx->ac.builder, LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGE_SLOTS - 1, 0),
index, "");
- return si_load_image_desc(ctx, list, index, desc_type, write, false);
+ return si_load_image_desc(ctx, type, list, index, desc_type, write, false);
}
index = LLVMBuildAdd(ctx->ac.builder, index,
LLVMConstInt(ctx->ac.i32, SI_NUM_IMAGE_SLOTS / 2, 0), "");
- return si_load_sampler_desc(ctx, list, index, desc_type);
+ return si_load_sampler_desc(ctx, type, list, index, desc_type);
}
void si_llvm_init_resource_callbacks(struct si_shader_context *ctx)
vb_desc = ac_get_arg(&ctx->ac, ctx->vb_descriptors[input_index]);
} else {
unsigned index = input_index - num_vbos_in_user_sgprs;
- vb_desc = ac_build_load_to_sgpr(&ctx->ac, ac_get_arg(&ctx->ac, ctx->args.vertex_buffers),
- LLVMConstInt(ctx->ac.i32, index, 0));
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->args.vertex_buffers);
+ vb_desc = ac_build_load_to_sgpr2(&ctx->ac, type, ac_get_arg(&ctx->ac, ctx->args.vertex_buffers),
+ LLVMConstInt(ctx->ac.i32, index, 0));
}
if (ctx->abi.vertex_id_replaced) {
LLVMValueRef so_write_offset[4] = {};
LLVMValueRef so_buffers[4];
LLVMValueRef buf_ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
for (i = 0; i < 4; i++) {
if (!so->stride[i])
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);
+ so_buffers[i] = ac_build_load_to_sgpr2(&ctx->ac, type, buf_ptr, offset);
LLVMValueRef so_offset = ac_get_arg(&ctx->ac, ctx->args.streamout_offset[i]);
so_offset = LLVMBuildMul(builder, so_offset, LLVMConstInt(ctx->ac.i32, 4, 0), "");
unsigned const_chan;
LLVMValueRef base_elt;
LLVMValueRef ptr = ac_get_arg(&ctx->ac, ctx->internal_bindings);
+ LLVMTypeRef type = ac_get_arg_pointee_type(&ctx->ac, &ctx->args, ctx->internal_bindings);
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);
+ LLVMValueRef const_resource = ac_build_load_to_sgpr2(&ctx->ac, type, ptr, constbuf_index);
unsigned clipdist_mask = ctx->shader->selector->info.clipdist_mask &
~ctx->shader->key.ge.opt.kill_clip_distances;
LLVMBuildPointerCast(ctx->ac.builder,
ac_get_arg(&ctx->ac, ctx->internal_bindings),
LLVMPointerType(ctx->ac.i32, AC_ADDR_SPACE_CONST_32BIT), "");
- attr_address = ac_build_load_to_sgpr(&ctx->ac, ptr,
- LLVMConstInt(ctx->ac.i32, SI_GS_ATTRIBUTE_RING * 4, 0));
+ attr_address = ac_build_load_to_sgpr2(&ctx->ac, ctx->ac.i32, ptr,
+ LLVMConstInt(ctx->ac.i32, SI_GS_ATTRIBUTE_RING * 4, 0));
} else {
attr_address = ac_get_arg(&ctx->ac, ctx->gs_attr_address);
}
if (key->vs_prolog.states.instance_divisor_is_fetched) {
LLVMValueRef list = si_prolog_get_internal_bindings(ctx);
LLVMValueRef buf_index = LLVMConstInt(ctx->ac.i32, SI_VS_CONST_INSTANCE_DIVISORS, 0);
- instance_divisor_constbuf = ac_build_load_to_sgpr(&ctx->ac, list, buf_index);
+ instance_divisor_constbuf = ac_build_load_to_sgpr2(&ctx->ac, ctx->ac.v4i32, list, buf_index);
}
for (i = 0; i < key->vs_prolog.num_inputs; i++) {