struct ir3_block *b = ctx->block;
struct ir3_instruction *ldgb, *src0, *src1, *byte_offset, *offset;
- /* can this be non-const buffer_index? how do we handle that? */
- int ibo_idx = ir3_ssbo_to_ibo(ctx->so->shader, nir_src_as_uint(intr->src[0]));
+ struct ir3_instruction *ssbo = ir3_ssbo_to_ibo(ctx, intr->src[0]);
byte_offset = ir3_get_src(ctx, &intr->src[1])[0];
offset = ir3_get_src(ctx, &intr->src[2])[0];
}, 2);
src1 = offset;
- ldgb = ir3_LDGB(b, create_immed(b, ibo_idx), 0,
+ ldgb = ir3_LDGB(b, ssbo, 0,
src0, 0, src1, 0);
ldgb->regs[0]->wrmask = MASK(intr->num_components);
ldgb->cat6.iim_val = intr->num_components;
assert(wrmask == BITFIELD_MASK(intr->num_components));
- /* can this be non-const buffer_index? how do we handle that? */
- int ibo_idx = ir3_ssbo_to_ibo(ctx->so->shader, nir_src_as_uint(intr->src[1]));
+ struct ir3_instruction *ssbo = ir3_ssbo_to_ibo(ctx, intr->src[1]);
byte_offset = ir3_get_src(ctx, &intr->src[2])[0];
offset = ir3_get_src(ctx, &intr->src[3])[0];
create_immed(b, 0),
}, 2);
- stgb = ir3_STGB(b, create_immed(b, ibo_idx), 0, src0, 0, src1, 0, src2, 0);
+ stgb = ir3_STGB(b, ssbo, 0, src0, 0, src1, 0, src2, 0);
stgb->cat6.iim_val = ncomp;
stgb->cat6.d = 4;
stgb->cat6.type = TYPE_U32;
*offset;
type_t type = TYPE_U32;
- /* can this be non-const buffer_index? how do we handle that? */
- int ibo_idx = ir3_ssbo_to_ibo(ctx->so->shader, nir_src_as_uint(intr->src[0]));
- ssbo = create_immed(b, ibo_idx);
+ ssbo = ir3_ssbo_to_ibo(ctx, intr->src[0]);
byte_offset = ir3_get_src(ctx, &intr->src[1])[0];
offset = ir3_get_src(ctx, &intr->src[3])[0];
struct ir3_instruction *stib, *offset;
struct ir3_instruction * const *value = ir3_get_src(ctx, &intr->src[3]);
struct ir3_instruction * const *coords = ir3_get_src(ctx, &intr->src[1]);
+ struct ir3_instruction * ibo = ir3_image_to_ibo(ctx, intr->src[0]);
unsigned ncoords = ir3_get_image_coords(intr, NULL);
- unsigned slot = nir_src_as_uint(intr->src[0]);
- unsigned ibo_idx = ir3_image_to_ibo(ctx->so->shader, slot);
unsigned ncomp = ir3_get_num_components_for_image_format(nir_intrinsic_format(intr));
/* src0 is value
* one over the other in various cases.
*/
- stib = ir3_STIB(b, create_immed(b, ibo_idx), 0,
+ stib = ir3_STIB(b, ibo, 0,
ir3_create_collect(ctx, value, ncomp), 0,
ir3_create_collect(ctx, coords, ncoords), 0,
offset, 0);
emit_intrinsic_atomic_image(struct ir3_context *ctx, nir_intrinsic_instr *intr)
{
struct ir3_block *b = ctx->block;
- struct ir3_instruction *atomic, *image, *src0, *src1, *src2;
+ struct ir3_instruction *atomic, *src0, *src1, *src2;
struct ir3_instruction * const *coords = ir3_get_src(ctx, &intr->src[1]);
+ struct ir3_instruction * image = ir3_image_to_ibo(ctx, intr->src[0]);
unsigned ncoords = ir3_get_image_coords(intr, NULL);
- unsigned slot = nir_src_as_uint(intr->src[0]);
- unsigned ibo_idx = ir3_image_to_ibo(ctx->so->shader, slot);
-
- image = create_immed(b, ibo_idx);
/* src0 is value (or uvec2(value, compare))
* src1 is coords
instr->cat6.base = nir_intrinsic_desc_set(intrin);
}
-static struct ir3_instruction *
-ssbo_idx(struct ir3_context *ctx, nir_src src)
-{
- if (ir3_bindless_resource(src)) {
- ctx->so->bindless_ibo = true;
- return ir3_get_src(ctx, &src)[0];
- } else {
- /* can this be non-const buffer_index? how do we handle that? */
- int ibo_idx = ir3_ssbo_to_ibo(ctx->so->shader, nir_src_as_uint(src));
- return create_immed(ctx->block, ibo_idx);
- }
-}
-
-static struct ir3_instruction *
-image_idx(struct ir3_context *ctx, nir_src src)
-{
- if (ir3_bindless_resource(src)) {
- ctx->so->bindless_ibo = true;
- return ir3_get_src(ctx, &src)[0];
- } else {
- /* can this be non-const buffer_index? how do we handle that? */
- int ibo_idx = ir3_image_to_ibo(ctx->so->shader, nir_src_as_uint(src));
- return create_immed(ctx->block, ibo_idx);
- }
-}
-
/* src[] = { buffer_index, offset }. No const_index */
static void
emit_intrinsic_load_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr,
offset = ir3_get_src(ctx, &intr->src[2])[0];
- ldib = ir3_LDIB(b, ssbo_idx(ctx, intr->src[0]), 0, offset, 0);
+ ldib = ir3_LDIB(b, ir3_ssbo_to_ibo(ctx, intr->src[0]), 0, offset, 0);
ldib->regs[0]->wrmask = MASK(intr->num_components);
ldib->cat6.iim_val = intr->num_components;
ldib->cat6.d = 1;
val = ir3_create_collect(ctx, ir3_get_src(ctx, &intr->src[0]), ncomp);
offset = ir3_get_src(ctx, &intr->src[3])[0];
- stib = ir3_STIB(b, ssbo_idx(ctx, intr->src[1]), 0, offset, 0, val, 0);
+ stib = ir3_STIB(b, ir3_ssbo_to_ibo(ctx, intr->src[1]), 0, offset, 0, val, 0);
stib->cat6.iim_val = ncomp;
stib->cat6.d = 1;
stib->cat6.type = intr->src[0].ssa->bit_size == 16 ? TYPE_U16 : TYPE_U32;
struct ir3_instruction *atomic, *ibo, *src0, *src1, *data, *dummy;
type_t type = TYPE_U32;
- ibo = ssbo_idx(ctx, intr->src[0]);
+ ibo = ir3_ssbo_to_ibo(ctx, intr->src[0]);
data = ir3_get_src(ctx, &intr->src[2])[0];
struct ir3_instruction * const *coords = ir3_get_src(ctx, &intr->src[1]);
unsigned ncoords = ir3_get_image_coords(intr, NULL);
- ldib = ir3_LDIB(b, image_idx(ctx, intr->src[0]), 0,
+ ldib = ir3_LDIB(b, ir3_image_to_ibo(ctx, intr->src[0]), 0,
ir3_create_collect(ctx, coords, ncoords), 0);
ldib->regs[0]->wrmask = MASK(intr->num_components);
ldib->cat6.iim_val = intr->num_components;
/* src0 is offset, src1 is value:
*/
- stib = ir3_STIB(b, image_idx(ctx, intr->src[0]), 0,
+ stib = ir3_STIB(b, ir3_image_to_ibo(ctx, intr->src[0]), 0,
ir3_create_collect(ctx, coords, ncoords), 0,
ir3_create_collect(ctx, value, ncomp), 0);
stib->cat6.iim_val = ncomp;
struct ir3_instruction *value = ir3_get_src(ctx, &intr->src[3])[0];
unsigned ncoords = ir3_get_image_coords(intr, NULL);
- ibo = image_idx(ctx, intr->src[0]);
+ ibo = ir3_image_to_ibo(ctx, intr->src[0]);
/* So this gets a bit creative:
*
mapping->tex_base = num_textures;
}
-unsigned
-ir3_ssbo_to_ibo(struct ir3_shader *shader, unsigned ssbo)
+struct ir3_instruction *
+ir3_ssbo_to_ibo(struct ir3_context *ctx, nir_src src)
{
- return ssbo;
+ if (ir3_bindless_resource(src)) {
+ ctx->so->bindless_ibo = true;
+ return ir3_get_src(ctx, &src)[0];
+ } else {
+ /* can this be non-const buffer_index? how do we handle that? */
+ int ssbo_idx = nir_src_as_uint(src);
+ return create_immed(ctx->block, ssbo_idx);
+ }
}
unsigned
return mapping->ssbo_to_tex[ssbo] + mapping->tex_base;
}
-unsigned
-ir3_image_to_ibo(struct ir3_shader *shader, unsigned image)
+struct ir3_instruction *
+ir3_image_to_ibo(struct ir3_context *ctx, nir_src src)
{
- return shader->nir->info.num_ssbos + image;
+ if (ir3_bindless_resource(src)) {
+ ctx->so->bindless_ibo = true;
+ return ir3_get_src(ctx, &src)[0];
+ } else {
+ /* can this be non-const buffer_index? how do we handle that? */
+ int image_idx = nir_src_as_uint(src);
+ return create_immed(ctx->block, ctx->s->info.num_ssbos + image_idx);
+ }
}
unsigned
void ir3_ibo_mapping_init(struct ir3_ibo_mapping *mapping, unsigned num_textures);
-unsigned ir3_ssbo_to_ibo(struct ir3_shader *shader, unsigned ssbo);
+struct ir3_instruction *ir3_ssbo_to_ibo(struct ir3_context *ctx, nir_src src);
unsigned ir3_ssbo_to_tex(struct ir3_ibo_mapping *mapping, unsigned ssbo);
-unsigned ir3_image_to_ibo(struct ir3_shader *shader, unsigned image);
+struct ir3_instruction *ir3_image_to_ibo(struct ir3_context *ctx, nir_src src);
unsigned ir3_image_to_tex(struct ir3_ibo_mapping *mapping, unsigned image);
unsigned ir3_get_image_coords(const nir_intrinsic_instr *instr, unsigned *flagsp);