summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2014-07-04 09:38:44 -0700
committerEric Anholt <[email protected]>2014-08-08 18:59:46 -0700
commitc29392751180e21a2857cade8d0b4902cbe9d001 (patch)
tree0da05c819c6b967723f1c9b04095da9e836cb02f /src/gallium/drivers
parentdb9f41ea8826d09a413059b681121e4bd05ce524 (diff)
vc4: Add WIP support for varyings.
It doesn't do all the interpolation yet, but more tests can run now. v2: Rebase on helpers.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/vc4/vc4_context.h1
-rw-r--r--src/gallium/drivers/vc4/vc4_draw.c2
-rw-r--r--src/gallium/drivers/vc4/vc4_program.c55
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.c1
-rw-r--r--src/gallium/drivers/vc4/vc4_qir.h2
-rw-r--r--src/gallium/drivers/vc4/vc4_qpu_emit.c6
6 files changed, 59 insertions, 8 deletions
diff --git a/src/gallium/drivers/vc4/vc4_context.h b/src/gallium/drivers/vc4/vc4_context.h
index 8258d3046c0..f36b96b0c25 100644
--- a/src/gallium/drivers/vc4/vc4_context.h
+++ b/src/gallium/drivers/vc4/vc4_context.h
@@ -80,6 +80,7 @@ struct vc4_compiled_shader {
struct vc4_shader_uniform_info uniforms[2];
uint32_t coord_shader_offset;
+ uint8_t num_inputs;
};
struct vc4_program_stateobj {
diff --git a/src/gallium/drivers/vc4/vc4_draw.c b/src/gallium/drivers/vc4/vc4_draw.c
index 10b5deb560e..d315f40ed20 100644
--- a/src/gallium/drivers/vc4/vc4_draw.c
+++ b/src/gallium/drivers/vc4/vc4_draw.c
@@ -177,7 +177,7 @@ vc4_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
cl_start_shader_reloc(&vc4->shader_rec, 7);
cl_u16(&vc4->shader_rec, VC4_SHADER_FLAG_ENABLE_CLIPPING);
cl_u8(&vc4->shader_rec, 0); /* fs num uniforms (unused) */
- cl_u8(&vc4->shader_rec, 0); /* fs num varyings */
+ cl_u8(&vc4->shader_rec, vc4->prog.fs->num_inputs);
cl_reloc(vc4, &vc4->shader_rec, vc4->prog.fs->bo, 0);
cl_reloc(vc4, &vc4->shader_rec, fs_ubo, fs_ubo_offset);
diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c
index 0b3cfb400af..12d188185cd 100644
--- a/src/gallium/drivers/vc4/vc4_program.c
+++ b/src/gallium/drivers/vc4/vc4_program.c
@@ -53,6 +53,8 @@ struct tgsi_to_qir {
uint32_t *uniform_data;
enum quniform_contents *uniform_contents;
uint32_t num_uniforms;
+ uint32_t num_inputs;
+ uint32_t num_outputs;
};
struct vc4_key {
@@ -184,6 +186,8 @@ update_dst(struct tgsi_to_qir *trans, struct tgsi_full_instruction *tgsi_inst,
break;
case TGSI_FILE_OUTPUT:
trans->outputs[tgsi_dst->Index * 4 + i] = val;
+ trans->num_outputs = MAX2(trans->num_outputs,
+ tgsi_dst->Index * 4 + i + 1);
break;
default:
fprintf(stderr, "unknown dst file %d\n", tgsi_dst->File);
@@ -266,6 +270,38 @@ tgsi_to_qir_abs(struct tgsi_to_qir *trans,
}
static void
+emit_tgsi_declaration(struct tgsi_to_qir *trans,
+ struct tgsi_full_declaration *decl)
+{
+ struct qcompile *c = trans->c;
+
+ switch (decl->Declaration.File) {
+ case TGSI_FILE_INPUT:
+ if (c->stage == QSTAGE_FRAG) {
+ for (int index = decl->Range.First;
+ index <= decl->Range.Last;
+ index++) {
+ for (int i = 0; i < 4; i++) {
+ struct qreg vary = {
+ QFILE_VARY,
+ index * 4 + i
+ };
+
+ /* XXX: multiply by W */
+ trans->inputs[index * 4 + i] =
+ qir_VARY_ADD_C(c,
+ qir_MOV(c,
+ vary));
+
+ trans->num_inputs++;
+ }
+ }
+ }
+ break;
+ }
+}
+
+static void
emit_tgsi_instruction(struct tgsi_to_qir *trans,
struct tgsi_full_instruction *tgsi_inst)
{
@@ -356,11 +392,6 @@ parse_tgsi_immediate(struct tgsi_to_qir *trans, struct tgsi_full_immediate *imm)
static void
emit_frag_init(struct tgsi_to_qir *trans)
{
- /* XXX: lols */
- for (int i = 0; i < 4; i++) {
- trans->inputs[i] = qir_uniform_ui(trans, fui(1.0));
- }
-
}
static void
@@ -453,10 +484,15 @@ emit_1_wc_write(struct tgsi_to_qir *trans)
static void
emit_vert_end(struct tgsi_to_qir *trans)
{
+ struct qcompile *c = trans->c;
+
emit_scaled_viewport_write(trans);
emit_zs_write(trans);
emit_1_wc_write(trans);
- /* XXX: write varyings */
+
+ for (int i = 4; i < trans->num_outputs; i++) {
+ qir_VPM_WRITE(c, trans->outputs[i]);
+ }
}
static void
@@ -523,6 +559,11 @@ vc4_shader_tgsi_to_qir(struct vc4_compiled_shader *shader, enum qstage stage,
tgsi_parse_token(&trans->parser);
switch (trans->parser.FullToken.Token.Type) {
+ case TGSI_TOKEN_TYPE_DECLARATION:
+ emit_tgsi_declaration(trans,
+ &trans->parser.FullToken.FullDeclaration);
+ break;
+
case TGSI_TOKEN_TYPE_INSTRUCTION:
emit_tgsi_instruction(trans,
&trans->parser.FullToken.FullInstruction);
@@ -603,8 +644,8 @@ vc4_fs_compile(struct vc4_context *vc4, struct vc4_compiled_shader *shader,
{
struct tgsi_to_qir *trans = vc4_shader_tgsi_to_qir(shader, QSTAGE_FRAG,
&key->base);
+ shader->num_inputs = trans->num_inputs;
copy_uniform_state_to_shader(shader, 0, trans);
-
shader->bo = vc4_bo_alloc_mem(vc4->screen, trans->c->qpu_insts,
trans->c->num_qpu_insts * sizeof(uint64_t),
"fs_code");
diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c
index 4ee1f018fc5..02342f212c3 100644
--- a/src/gallium/drivers/vc4/vc4_qir.c
+++ b/src/gallium/drivers/vc4/vc4_qir.c
@@ -59,6 +59,7 @@ static const struct qir_op_info qir_op_info[] = {
[QOP_VPM_WRITE] = { "vpm_write", 0, 1 },
[QOP_VPM_READ] = { "vpm_read", 0, 1 },
[QOP_TLB_COLOR_WRITE] = { "tlb_color", 0, 1 },
+ [QOP_VARY_ADD_C] = { "vary_add_c", 1, 1 },
};
static const char *
diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h
index 4263adcddd1..75b1933e6a6 100644
--- a/src/gallium/drivers/vc4/vc4_qir.h
+++ b/src/gallium/drivers/vc4/vc4_qir.h
@@ -68,6 +68,7 @@ enum qop {
QOP_VPM_WRITE,
QOP_VPM_READ,
QOP_TLB_COLOR_WRITE,
+ QOP_VARY_ADD_C,
};
struct simple_node {
@@ -178,6 +179,7 @@ QIR_ALU1(RSQ)
QIR_ALU1(EXP2)
QIR_ALU1(LOG2)
QIR_ALU2(PACK_SCALED)
+QIR_ALU1(VARY_ADD_C)
static inline void
qir_VPM_WRITE(struct qcompile *c, struct qreg a)
diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c
index 8cb5de15fff..f02fe822b07 100644
--- a/src/gallium/drivers/vc4/vc4_qpu_emit.c
+++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c
@@ -299,6 +299,12 @@ vc4_generate_code(struct qcompile *c)
qpu_m_NOP());
break;
+ case QOP_VARY_ADD_C:
+ insts[ni++] = qpu_inst(qpu_a_FADD(dst,
+ src[0], qpu_r5()),
+ qpu_m_NOP());
+ break;
+
case QOP_PACK_SCALED:
insts[ni++] = qpu_inst(qpu_a_MOV(dst, src[0]),
qpu_m_NOP());