static struct qreg
vc4_ubo_load(struct vc4_compile *c, nir_intrinsic_instr *intr)
{
- nir_const_value *buffer_index =
- nir_src_as_const_value(intr->src[0]);
- assert(buffer_index->u32[0] == 1);
+ unsigned buffer_index = nir_src_as_uint(intr->src[0]);
+ assert(buffer_index == 1);
assert(c->stage == QSTAGE_FRAG);
struct qreg offset = ntq_get_src(c, intr->src[1], 0);
qir_ADD_dest(c, qir_reg(QFILE_TEX_S_DIRECT, 0),
offset,
- qir_uniform(c, QUNIFORM_UBO_ADDR, buffer_index->u32[0]));
+ qir_uniform(c, QUNIFORM_UBO_ADDR, buffer_index));
c->num_texture_samples++;
static void
ntq_emit_color_read(struct vc4_compile *c, nir_intrinsic_instr *instr)
{
- assert(nir_src_as_const_value(instr->src[0])->u32[0] == 0);
+ assert(nir_src_as_uint(instr->src[0]) == 0);
/* Reads of the per-sample color need to be done in
* order.
ntq_emit_load_input(struct vc4_compile *c, nir_intrinsic_instr *instr)
{
assert(instr->num_components == 1);
-
- nir_const_value *const_offset = nir_src_as_const_value(instr->src[0]);
- assert(const_offset && "vc4 doesn't support indirect inputs");
+ assert(nir_src_is_const(instr->src[0]) &&
+ "vc4 doesn't support indirect inputs");
if (c->stage == QSTAGE_FRAG &&
nir_intrinsic_base(instr) >= VC4_NIR_TLB_COLOR_READ_INPUT) {
return;
}
- uint32_t offset = nir_intrinsic_base(instr) + const_offset->u32[0];
+ uint32_t offset = nir_intrinsic_base(instr) +
+ nir_src_as_uint(instr->src[0]);
int comp = nir_intrinsic_component(instr);
ntq_store_dest(c, &instr->dest, 0,
qir_MOV(c, c->inputs[offset * 4 + comp]));
static void
ntq_emit_intrinsic(struct vc4_compile *c, nir_intrinsic_instr *instr)
{
- nir_const_value *const_offset;
unsigned offset;
switch (instr->intrinsic) {
case nir_intrinsic_load_uniform:
assert(instr->num_components == 1);
- const_offset = nir_src_as_const_value(instr->src[0]);
- if (const_offset) {
- offset = nir_intrinsic_base(instr) + const_offset->u32[0];
+ if (nir_src_is_const(instr->src[0])) {
+ offset = nir_intrinsic_base(instr) +
+ nir_src_as_uint(instr->src[0]);
assert(offset % 4 == 0);
/* We need dwords */
offset = offset / 4;
break;
case nir_intrinsic_store_output:
- const_offset = nir_src_as_const_value(instr->src[1]);
- assert(const_offset && "vc4 doesn't support indirect outputs");
- offset = nir_intrinsic_base(instr) + const_offset->u32[0];
+ assert(nir_src_is_const(instr->src[1]) &&
+ "vc4 doesn't support indirect outputs");
+ offset = nir_intrinsic_base(instr) +
+ nir_src_as_uint(instr->src[1]);
/* MSAA color outputs are the only case where we have an
* output that's not lowered to being a store of a single 32