[Mesa-dev] [PATCH 3/6] i965: Generalize GL_FIXED VS w/a support
Chris Forbes
chrisf at ijw.co.nz
Sun Oct 21 23:04:53 PDT 2012
Next few patches build on this to add other workarounds
for packed formats.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 14 +++++++-------
src/mesa/drivers/dri/i965/brw_vs.c | 9 +++++----
src/mesa/drivers/dri/i965/brw_vs.h | 14 +++++++++++---
src/mesa/drivers/dri/i965/brw_vs_emit.c | 20 +++++++++++---------
4 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index f54c49e..dba0a82 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -800,13 +800,13 @@ vec4_visitor::visit(ir_variable *ir)
* come in as floating point conversions of the integer values.
*/
for (int i = ir->location; i < ir->location + type_size(ir->type); i++) {
- if (!c->key.gl_fixed_input_size[i])
- continue;
-
- dst_reg dst = *reg;
- dst.type = brw_type_for_base_type(ir->type);
- dst.writemask = (1 << c->key.gl_fixed_input_size[i]) - 1;
- emit(MUL(dst, src_reg(dst), src_reg(1.0f / 65536.0f)));
+ uint8_t wa_flags = c->key.gl_attrib_wa_flags[i];
+ if (wa_flags & BRW_ATTRIB_WA_COMPONENTS) {
+ dst_reg dst = *reg;
+ dst.type = brw_type_for_base_type(ir->type);
+ dst.writemask = (1 << (wa_flags & BRW_ATTRIB_WA_COMPONENTS)) - 1;
+ emit(MUL(dst, src_reg(dst), src_reg(1.0f / 65536.0f)));
+ }
}
break;
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index 4e95074..c31092d 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -381,9 +381,9 @@ brw_vs_debug_recompile(struct brw_context *brw,
}
for (unsigned int i = 0; i < VERT_ATTRIB_MAX; i++) {
- found |= key_debug("GL_FIXED rescaling",
- old_key->gl_fixed_input_size[i],
- key->gl_fixed_input_size[i]);
+ found |= key_debug("Vertex attrib w/a flags",
+ old_key->gl_attrib_wa_flags[i],
+ key->gl_attrib_wa_flags[i]);
}
found |= key_debug("user clip flags",
@@ -465,9 +465,10 @@ static void brw_upload_vs_prog(struct brw_context *brw)
/* BRW_NEW_VERTICES */
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ /* TODO: flag w/a for packed vertex formats here too */
if (vp->program.Base.InputsRead & BITFIELD64_BIT(i) &&
brw->vb.inputs[i].glarray->Type == GL_FIXED) {
- key.gl_fixed_input_size[i] = brw->vb.inputs[i].glarray->Size;
+ key.gl_attrib_wa_flags[i] = brw->vb.inputs[i].glarray->Size;
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h b/src/mesa/drivers/dri/i965/brw_vs.h
index adeff7f..9da4cb0 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -39,13 +39,21 @@
#include "brw_program.h"
#include "program/program.h"
+/* fixup bits for gl_packed_input_flags,
+ * to enable various VS workarounds */
+#define BRW_ATTRIB_WA_COMPONENTS 7 /* mask for GL_FIXED scale channel count */
+#define BRW_ATTRIB_WA_NORMALIZE 8 /* normalize in shader */
+#define BRW_ATTRIB_WA_BGRA 16 /* swap r/b channels in shader */
+#define BRW_ATTRIB_WA_SIGN 32 /* interpret as signed in shader */
+#define BRW_ATTRIB_WA_SCALE 64 /* interpret as scaled in shader */
struct brw_vs_prog_key {
GLuint program_string_id;
- /**
- * Number of channels of the vertex attribute that need GL_FIXED rescaling
+
+ /*
+ * Per-attribute workaround flags
*/
- uint8_t gl_fixed_input_size[VERT_ATTRIB_MAX];
+ uint8_t gl_attrib_wa_flags[VERT_ATTRIB_MAX];
/**
* True if at least one clip flag is enabled, regardless of whether the
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 02239b4..a4742c7 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -1582,22 +1582,24 @@ accumulator_contains(struct brw_vs_compile *c, struct brw_reg val)
}
static void
-brw_vs_rescale_gl_fixed(struct brw_vs_compile *c)
+brw_vs_apply_attrib_wa(struct brw_vs_compile *c)
{
struct brw_compile *p = &c->func;
int i;
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ uint8_t wa_flags = c->key.gl_attrib_wa_flags[i];
if (!(c->prog_data.inputs_read & BITFIELD64_BIT(i)))
- continue;
+ continue;
- if (c->key.gl_fixed_input_size[i] != 0) {
- struct brw_reg reg = c->regs[PROGRAM_INPUT][i];
-
- brw_MUL(p,
- brw_writemask(reg, (1 << c->key.gl_fixed_input_size[i]) - 1),
- reg, brw_imm_f(1.0 / 65536.0));
+ if (wa_flags & BRW_ATTRIB_WA_COMPONENTS) {
+ struct brw_reg reg = c->regs[PROGRAM_INPUT][i];
+ brw_MUL(p,
+ brw_writemask(reg, (1 << (wa_flags & BRW_ATTRIB_WA_COMPONENTS)) - 1),
+ reg, brw_imm_f(1.0 / 65536.0));
}
+
+ /* TODO: emit other packed vertex attrib w/a shader code here. */
}
}
@@ -1625,7 +1627,7 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
*/
brw_vs_alloc_regs(c);
- brw_vs_rescale_gl_fixed(c);
+ brw_vs_apply_attrib_wa(c);
for (insn = 0; insn < nr_insns; insn++) {
--
1.7.12.4
More information about the mesa-dev
mailing list