int inst_ptr; /* current instruction pointer */
struct etna_inst code[ETNA_MAX_INSTRUCTIONS * ETNA_INST_SIZE];
+ /* constants */
+ uint64_t consts[ETNA_MAX_IMM];
+
/* There was an error during compilation */
bool error;
};
-#define compile_error(ctx, args...) ({ \
- printf(args); \
- ctx->error = true; \
- assert(0); \
-})
-
/* io related lowering
* run after lower_int_to_float because it adds i2f/f2i ops
*/
lod_bias = &tex->src[i].src;
lod_bias_idx = i;
break;
+ case nir_tex_src_comparator:
+ break;
default:
assert(0);
break;
static void
etna_emit_tex(struct etna_compile *c, nir_texop op, unsigned texid, unsigned dst_swiz,
struct etna_inst_dst dst, struct etna_inst_src coord,
- struct etna_inst_src lod_bias)
+ struct etna_inst_src lod_bias, struct etna_inst_src compare)
{
struct etna_inst inst = {
.dst = dst,
if (lod_bias.use)
inst.src[1] = lod_bias;
+ if (compare.use)
+ inst.src[2] = compare;
+
switch (op) {
case nir_texop_tex: inst.opcode = INST_OPCODE_TEXLD; break;
case nir_texop_txb: inst.opcode = INST_OPCODE_TEXLDB; break;
OPT_V(s, nir_opt_algebraic);
OPT_V(s, nir_lower_bool_to_float);
} else {
- OPT_V(s, nir_lower_idiv);
+ OPT_V(s, nir_lower_idiv, nir_lower_idiv_fast);
OPT_V(s, nir_lower_bool_to_int32);
}
if (DBG_ENABLED(ETNA_DBG_DUMP_SHADERS))
nir_print_shader(s, stdout);
- uint64_t consts[ETNA_MAX_IMM] = {};
-
unsigned block_ptr[nir_shader_get_entrypoint(s)->num_blocks];
c->block_ptr = block_ptr;
- struct emit_options options = {
- .max_temps = ETNA_MAX_TEMPS,
- .max_consts = ETNA_MAX_IMM / 4,
- .id_reg = sf->num_reg,
- .single_const_src = c->specs->halti < 5,
- .etna_new_transcendentals = c->specs->has_new_transcendentals,
- .no_integers = c->specs->halti < 2,
- .user = c,
- .consts = consts,
- };
unsigned num_consts;
- ASSERTED bool ok = emit_shader(c->nir, &options, &v->num_temps, &num_consts);
+ ASSERTED bool ok = emit_shader(c, &v->num_temps, &num_consts);
assert(ok);
/* empty shader, emit NOP */
emit_inst(c, &(struct etna_inst) { .opcode = INST_OPCODE_NOP });
/* assemble instructions, fixing up labels */
- uint32_t *code = MALLOC(c->inst_ptr * 16 + 1024);
+ uint32_t *code = MALLOC(c->inst_ptr * 16);
for (unsigned i = 0; i < c->inst_ptr; i++) {
struct etna_inst *inst = &c->code[i];
if (inst->opcode == INST_OPCODE_BRANCH)
v->code = code;
v->needs_icache = c->inst_ptr > specs->max_instructions;
- copy_uniform_state_to_shader(v, consts, num_consts);
+ copy_uniform_state_to_shader(v, c->consts, num_consts);
if (s->info.stage == MESA_SHADER_FRAGMENT) {
v->input_count_unk8 = 31; /* XXX what is this */