summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/vc4/vc4_qir.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2017-08-14 09:45:54 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2017-08-14 09:45:54 +0000
commit4c58069f5013f0a621503525f7d5193bfe9976b3 (patch)
treebd8f8a08b889e9a8b99c9de01ae12459d527ea6d /lib/mesa/src/gallium/drivers/vc4/vc4_qir.c
parent5caa025e6b62d0456faad86c89f239a14d1eaadb (diff)
Import Mesa 17.1.6
Diffstat (limited to 'lib/mesa/src/gallium/drivers/vc4/vc4_qir.c')
-rw-r--r--lib/mesa/src/gallium/drivers/vc4/vc4_qir.c124
1 files changed, 89 insertions, 35 deletions
diff --git a/lib/mesa/src/gallium/drivers/vc4/vc4_qir.c b/lib/mesa/src/gallium/drivers/vc4/vc4_qir.c
index 4b94fcfb9..c829e7f93 100644
--- a/lib/mesa/src/gallium/drivers/vc4/vc4_qir.c
+++ b/lib/mesa/src/gallium/drivers/vc4/vc4_qir.c
@@ -76,13 +76,10 @@ static const struct qir_op_info qir_op_info[] = {
[QOP_FRAG_Z] = { "frag_z", 1, 0 },
[QOP_FRAG_W] = { "frag_w", 1, 0 },
- [QOP_TEX_S] = { "tex_s", 0, 2, true },
- [QOP_TEX_T] = { "tex_t", 0, 2, true },
- [QOP_TEX_R] = { "tex_r", 0, 2, true },
- [QOP_TEX_B] = { "tex_b", 0, 2, true },
- [QOP_TEX_DIRECT] = { "tex_direct", 0, 2, true },
[QOP_TEX_RESULT] = { "tex_result", 1, 0, true },
+ [QOP_THRSW] = { "thrsw", 0, 0, true },
+
[QOP_LOAD_IMM] = { "load_imm", 0, 1 },
[QOP_LOAD_IMM_U2] = { "load_imm_u2", 0, 1 },
[QOP_LOAD_IMM_I2] = { "load_imm_i2", 0, 1 },
@@ -103,12 +100,35 @@ qir_get_op_name(enum qop qop)
}
int
-qir_get_op_nsrc(enum qop qop)
+qir_get_non_sideband_nsrc(struct qinst *inst)
{
- if (qop < ARRAY_SIZE(qir_op_info) && qir_op_info[qop].name)
- return qir_op_info[qop].nsrc;
- else
- abort();
+ assert(qir_op_info[inst->op].name);
+ return qir_op_info[inst->op].nsrc;
+}
+
+int
+qir_get_nsrc(struct qinst *inst)
+{
+ assert(qir_op_info[inst->op].name);
+
+ int nsrc = qir_get_non_sideband_nsrc(inst);
+
+ /* Normal (non-direct) texture coordinate writes also implicitly load
+ * a uniform for the texture parameters.
+ */
+ if (qir_is_tex(inst) && inst->dst.file != QFILE_TEX_S_DIRECT)
+ nsrc++;
+
+ return nsrc;
+}
+
+/* The sideband uniform for textures gets stored after the normal ALU
+ * arguments.
+ */
+int
+qir_get_tex_uniform_src(struct qinst *inst)
+{
+ return qir_get_nsrc(inst) - 1;
}
/**
@@ -123,6 +143,11 @@ qir_has_side_effects(struct vc4_compile *c, struct qinst *inst)
case QFILE_TLB_COLOR_WRITE:
case QFILE_TLB_COLOR_WRITE_MS:
case QFILE_TLB_STENCIL_SETUP:
+ case QFILE_TEX_S_DIRECT:
+ case QFILE_TEX_S:
+ case QFILE_TEX_T:
+ case QFILE_TEX_R:
+ case QFILE_TEX_B:
return true;
default:
break;
@@ -139,7 +164,7 @@ qir_has_side_effect_reads(struct vc4_compile *c, struct qinst *inst)
* point/line coordinates reads, because they're generated by
* fixed-function hardware.
*/
- for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) {
+ for (int i = 0; i < qir_get_nsrc(inst); i++) {
if (inst->src[i].file == QFILE_VARY &&
c->input_slots[inst->src[i].index].slot == 0xff) {
return true;
@@ -156,6 +181,17 @@ qir_has_side_effect_reads(struct vc4_compile *c, struct qinst *inst)
}
bool
+qir_has_uniform_read(struct qinst *inst)
+{
+ for (int i = 0; i < qir_get_nsrc(inst); i++) {
+ if (inst->src[i].file == QFILE_UNIF)
+ return true;
+ }
+
+ return false;
+}
+
+bool
qir_is_mul(struct qinst *inst)
{
switch (inst->op) {
@@ -207,7 +243,30 @@ qir_is_raw_mov(struct qinst *inst)
bool
qir_is_tex(struct qinst *inst)
{
- return inst->op >= QOP_TEX_S && inst->op <= QOP_TEX_DIRECT;
+ switch (inst->dst.file) {
+ case QFILE_TEX_S_DIRECT:
+ case QFILE_TEX_S:
+ case QFILE_TEX_T:
+ case QFILE_TEX_R:
+ case QFILE_TEX_B:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool
+qir_has_implicit_tex_uniform(struct qinst *inst)
+{
+ switch (inst->dst.file) {
+ case QFILE_TEX_S:
+ case QFILE_TEX_T:
+ case QFILE_TEX_R:
+ case QFILE_TEX_B:
+ return true;
+ default:
+ return false;
+ }
}
bool
@@ -299,6 +358,11 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write)
[QFILE_FRAG_Y] = "frag_y",
[QFILE_FRAG_REV_FLAG] = "frag_rev_flag",
[QFILE_QPU_ELEMENT] = "elem",
+ [QFILE_TEX_S_DIRECT] = "tex_s_direct",
+ [QFILE_TEX_S] = "tex_s",
+ [QFILE_TEX_T] = "tex_t",
+ [QFILE_TEX_R] = "tex_r",
+ [QFILE_TEX_B] = "tex_b",
};
switch (reg.file) {
@@ -331,6 +395,11 @@ qir_print_reg(struct vc4_compile *c, struct qreg reg, bool write)
case QFILE_TLB_COLOR_WRITE_MS:
case QFILE_TLB_Z_WRITE:
case QFILE_TLB_STENCIL_SETUP:
+ case QFILE_TEX_S_DIRECT:
+ case QFILE_TEX_S:
+ case QFILE_TEX_T:
+ case QFILE_TEX_R:
+ case QFILE_TEX_B:
fprintf(stderr, "%s", files[reg.file]);
break;
@@ -371,7 +440,7 @@ qir_dump_inst(struct vc4_compile *c, struct qinst *inst)
}
}
- for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) {
+ for (int i = 0; i < qir_get_nsrc(inst); i++) {
fprintf(stderr, ", ");
qir_print_reg(c, inst->src[i], false);
vc4_qpu_disasm_unpack(stderr, inst->src[i].pack);
@@ -382,6 +451,7 @@ void
qir_dump(struct vc4_compile *c)
{
int ip = 0;
+ int pressure = 0;
qir_for_each_block(block, c) {
fprintf(stderr, "BLOCK %d:\n", block->index);
@@ -389,6 +459,8 @@ qir_dump(struct vc4_compile *c)
if (c->temp_start) {
bool first = true;
+ fprintf(stderr, "%3d ", pressure);
+
for (int i = 0; i < c->num_temps; i++) {
if (c->temp_start[i] != ip)
continue;
@@ -399,6 +471,7 @@ qir_dump(struct vc4_compile *c)
fprintf(stderr, ", ");
}
fprintf(stderr, "S%4d", i);
+ pressure++;
}
if (first)
@@ -420,6 +493,7 @@ qir_dump(struct vc4_compile *c)
fprintf(stderr, ", ");
}
fprintf(stderr, "E%4d", i);
+ pressure--;
}
if (first)
@@ -471,7 +545,6 @@ qir_inst(enum qop op, struct qreg dst, struct qreg src0, struct qreg src1)
inst->op = op;
inst->dst = dst;
- inst->src = calloc(2, sizeof(inst->src[0]));
inst->src[0] = src0;
inst->src[1] = src1;
inst->cond = QPU_COND_ALWAYS;
@@ -479,26 +552,6 @@ qir_inst(enum qop op, struct qreg dst, struct qreg src0, struct qreg src1)
return inst;
}
-struct qinst *
-qir_inst4(enum qop op, struct qreg dst,
- struct qreg a,
- struct qreg b,
- struct qreg c,
- struct qreg d)
-{
- struct qinst *inst = CALLOC_STRUCT(qinst);
-
- inst->op = op;
- inst->dst = dst;
- inst->src = calloc(4, sizeof(*inst->src));
- inst->src[0] = a;
- inst->src[1] = b;
- inst->src[2] = c;
- inst->src[3] = d;
-
- return inst;
-}
-
static void
qir_emit(struct vc4_compile *c, struct qinst *inst)
{
@@ -593,6 +646,7 @@ qir_compile_init(void)
list_inithead(&c->blocks);
qir_set_emit_block(c, qir_new_block(c));
+ c->last_top_block = c->cur_block;
c->output_position_index = -1;
c->output_color_index = -1;
@@ -612,7 +666,6 @@ qir_remove_instruction(struct vc4_compile *c, struct qinst *qinst)
c->defs[qinst->dst.index] = NULL;
list_del(&qinst->link);
- free(qinst->src);
free(qinst);
}
@@ -744,6 +797,7 @@ qir_optimize(struct vc4_compile *c)
OPTPASS(qir_opt_dead_code);
OPTPASS(qir_opt_small_immediates);
OPTPASS(qir_opt_vpm);
+ OPTPASS(qir_opt_coalesce_ff_writes);
if (!progress)
break;