summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/r300
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/r300')
-rw-r--r--src/mesa/drivers/dri/r300/r300_context.h11
-rw-r--r--src/mesa/drivers/dri/r300/r300_emit.c13
-rw-r--r--src/mesa/drivers/dri/r300/r300_reg.h23
-rw-r--r--src/mesa/drivers/dri/r300/r300_state.c91
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.c1637
-rw-r--r--src/mesa/drivers/dri/r300/r300_vertprog.h6
6 files changed, 1020 insertions, 761 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h
index 6615bc79fb..0349bac9a2 100644
--- a/src/mesa/drivers/dri/r300/r300_context.h
+++ b/src/mesa/drivers/dri/r300/r300_context.h
@@ -568,19 +568,10 @@ struct r300_vertex_shader_fragment {
union {
GLuint d[VSF_MAX_FRAGMENT_LENGTH];
float f[VSF_MAX_FRAGMENT_LENGTH];
- VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH / 4];
+ struct r300_vertprog_instruction i[VSF_MAX_FRAGMENT_LENGTH / 4];
} body;
};
-#define VSF_DEST_PROGRAM 0x0
-#define VSF_DEST_MATRIX0 0x200
-#define VSF_DEST_MATRIX1 0x204
-#define VSF_DEST_MATRIX2 0x208
-#define VSF_DEST_VECTOR0 0x20c
-#define VSF_DEST_VECTOR1 0x20d
-#define VSF_DEST_UNKNOWN1 0x400
-#define VSF_DEST_UNKNOWN2 0x406
-
struct r300_vertex_shader_state {
struct r300_vertex_shader_fragment program;
};
diff --git a/src/mesa/drivers/dri/r300/r300_emit.c b/src/mesa/drivers/dri/r300/r300_emit.c
index 229439dfa8..424bf44e59 100644
--- a/src/mesa/drivers/dri/r300/r300_emit.c
+++ b/src/mesa/drivers/dri/r300/r300_emit.c
@@ -299,13 +299,14 @@ GLuint r300VAPOutputCntl0(GLcontext * ctx, GLuint OutputsWritten)
if (OutputsWritten & (1 << VERT_RESULT_COL1))
ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
-#if 0
- if (OutputsWritten & (1 << VERT_RESULT_BFC0))
- ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
-
- if (OutputsWritten & (1 << VERT_RESULT_BFC1))
- ret |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
+ if (OutputsWritten & (1 << VERT_RESULT_BFC0)
+ || OutputsWritten & (1 << VERT_RESULT_BFC1))
+ ret |=
+ R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT |
+ R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT |
+ R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;
+#if 0
if (OutputsWritten & (1 << VERT_RESULT_FOGC)) ;
#endif
diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
index e59919be49..1baa74c526 100644
--- a/src/mesa/drivers/dri/r300/r300_reg.h
+++ b/src/mesa/drivers/dri/r300/r300_reg.h
@@ -282,9 +282,32 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#define R300_VAP_PVS_UPLOAD_ADDRESS 0x2200
# define R300_PVS_UPLOAD_PROGRAM 0x00000000
+/* gap */
# define R300_PVS_UPLOAD_PARAMETERS 0x00000200
+/* gap */
+# define R300_PVS_UPLOAD_CLIP_PLANE0 0x00000400
+# define R300_PVS_UPLOAD_CLIP_PLANE1 0x00000401
+# define R300_PVS_UPLOAD_CLIP_PLANE2 0x00000402
+# define R300_PVS_UPLOAD_CLIP_PLANE3 0x00000403
+# define R300_PVS_UPLOAD_CLIP_PLANE4 0x00000404
+# define R300_PVS_UPLOAD_CLIP_PLANE5 0x00000405
# define R300_PVS_UPLOAD_POINTSIZE 0x00000406
+/*
+ * These are obsolete defines form r300_context.h, but they might give some
+ * clues when investigating the addresses further...
+ */
+#if 0
+#define VSF_DEST_PROGRAM 0x0
+#define VSF_DEST_MATRIX0 0x200
+#define VSF_DEST_MATRIX1 0x204
+#define VSF_DEST_MATRIX2 0x208
+#define VSF_DEST_VECTOR0 0x20c
+#define VSF_DEST_VECTOR1 0x20d
+#define VSF_DEST_UNKNOWN1 0x400
+#define VSF_DEST_UNKNOWN2 0x406
+#endif
+
/* gap */
#define R300_VAP_PVS_UPLOAD_DATA 0x2208
diff --git a/src/mesa/drivers/dri/r300/r300_state.c b/src/mesa/drivers/dri/r300/r300_state.c
index b5cf21d644..6789efd428 100644
--- a/src/mesa/drivers/dri/r300/r300_state.c
+++ b/src/mesa/drivers/dri/r300/r300_state.c
@@ -82,6 +82,8 @@ static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
rmesa->hw.blend_color.cmd[1] = PACK_COLOR_8888(color[3], color[0],
color[1], color[2]);
+ rmesa->hw.blend_color.cmd[2] = 0;
+ rmesa->hw.blend_color.cmd[3] = 0;
}
/**
@@ -317,20 +319,34 @@ static void r300UpdateCulling(GLcontext * ctx)
r300ContextPtr r300 = R300_CONTEXT(ctx);
uint32_t val = 0;
- R300_STATECHANGE(r300, cul);
if (ctx->Polygon.CullFlag) {
- if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
- val = R300_CULL_FRONT | R300_CULL_BACK;
- else if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_FRONT:
val = R300_CULL_FRONT;
- else
+ break;
+ case GL_BACK:
val = R300_CULL_BACK;
+ break;
+ case GL_FRONT_AND_BACK:
+ val = R300_CULL_FRONT | R300_CULL_BACK;
+ break;
+ default:
+ break;
+ }
+ }
- if (ctx->Polygon.FrontFace == GL_CW)
- val |= R300_FRONT_FACE_CW;
- else
- val |= R300_FRONT_FACE_CCW;
+ switch (ctx->Polygon.FrontFace) {
+ case GL_CW:
+ val |= R300_FRONT_FACE_CW;
+ break;
+ case GL_CCW:
+ val |= R300_FRONT_FACE_CCW;
+ break;
+ default:
+ break;
}
+
+ R300_STATECHANGE(r300, cul);
r300->hw.cul.cmd[R300_CUL_CULL] = val;
}
@@ -344,6 +360,20 @@ static void r300SetEarlyZState(GLcontext * ctx)
r300ContextPtr r300 = R300_CONTEXT(ctx);
R300_STATECHANGE(r300, zstencil_format);
+ switch (ctx->Visual.depthBits) {
+ case 16:
+ r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
+ break;
+ case 24:
+ r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
+ break;
+ default:
+ fprintf(stderr, "Error: Unsupported depth %d... exiting\n", ctx->Visual.depthBits);
+ _mesa_exit(-1);
+ }
+
+ // r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
+
if (ctx->Color.AlphaEnabled && ctx->Color.AlphaFunc != GL_ALWAYS)
/* disable early Z */
r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
@@ -355,6 +385,9 @@ static void r300SetEarlyZState(GLcontext * ctx)
/* disable early Z */
r300->hw.zstencil_format.cmd[2] = R300_EARLY_Z_DISABLE;
}
+
+ r300->hw.zstencil_format.cmd[3] = 0x00000003;
+ r300->hw.zstencil_format.cmd[4] = 0x00000000;
}
static void r300SetAlphaState(GLcontext * ctx)
@@ -403,6 +436,7 @@ static void r300SetAlphaState(GLcontext * ctx)
R300_STATECHANGE(r300, at);
r300->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
+ r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
r300SetEarlyZState(ctx);
}
@@ -513,6 +547,9 @@ static void r300UpdatePolygonMode(GLcontext * ctx)
R300_STATECHANGE(r300, polygon_mode);
r300->hw.polygon_mode.cmd[1] = hw_mode;
}
+
+ r300->hw.polygon_mode.cmd[2] = 0x00000001;
+ r300->hw.polygon_mode.cmd[3] = 0x00000000;
}
/**
@@ -762,6 +799,7 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
r300ContextPtr rmesa = R300_CONTEXT(ctx);
R300_STATECHANGE(rmesa, shade);
+ rmesa->hw.shade.cmd[1] = 0x00000002;
switch (mode) {
case GL_FLAT:
rmesa->hw.shade.cmd[2] = R300_RE_SHADE_MODEL_FLAT;
@@ -772,6 +810,8 @@ static void r300ShadeModel(GLcontext * ctx, GLenum mode)
default:
return;
}
+ rmesa->hw.shade.cmd[3] = 0x00000000;
+ rmesa->hw.shade.cmd[4] = 0x00000000;
}
static void r300StencilFuncSeparate(GLcontext * ctx, GLenum face,
@@ -1526,7 +1566,7 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
for (i = VERT_ATTRIB_POS; i < VERT_ATTRIB_MAX; i++) {
if (rmesa->state.sw_tcl_inputs[i] != -1) {
- prog->program.body.i[program_end].op = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT);
+ prog->program.body.i[program_end].opcode = EASY_VSF_OP(MUL, o_reg++, ALL, RESULT);
prog->program.body.i[program_end].src[0] = VSF_REG(rmesa->state.sw_tcl_inputs[i]);
prog->program.body.i[program_end].src[1] = VSF_ATTR_UNITY(rmesa->state.sw_tcl_inputs[i]);
prog->program.body.i[program_end].src[2] = VSF_UNITY(rmesa->state.sw_tcl_inputs[i]);
@@ -1536,7 +1576,7 @@ static void r300SetupDefaultVertexProgram(r300ContextPtr rmesa)
prog->program.length = program_end * 4;
- r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program));
+ r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program));
inst_count = (prog->program.length / 4) - 1;
R300_STATECHANGE(rmesa, pvs);
@@ -1570,7 +1610,7 @@ static void r300SetupRealVertexProgram(r300ContextPtr rmesa)
bump_vpu_count(rmesa->hw.vpp.cmd, param_count);
param_count /= 4;
- r300SetupVertexProgramFragment(rmesa, VSF_DEST_PROGRAM, &(prog->program));
+ r300SetupVertexProgramFragment(rmesa, R300_PVS_UPLOAD_PROGRAM, &(prog->program));
inst_count = (prog->program.length / 4) - 1;
R300_STATECHANGE(rmesa, pvs);
@@ -1848,15 +1888,10 @@ static void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0);
r300->hw.unk4260.cmd[3] = r300PackFloat32(1.0);
- r300->hw.shade.cmd[1] = 0x00000002;
r300ShadeModel(ctx, ctx->Light.ShadeModel);
- r300->hw.shade.cmd[3] = 0x00000000;
- r300->hw.shade.cmd[4] = 0x00000000;
r300PolygonMode(ctx, GL_FRONT, ctx->Polygon.FrontMode);
r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode);
- r300->hw.polygon_mode.cmd[2] = 0x00000001;
- r300->hw.polygon_mode.cmd[3] = 0x00000000;
r300->hw.zbias_cntl.cmd[1] = 0x00000000;
r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor,
@@ -1887,14 +1922,11 @@ static void r300ResetHwState(r300ContextPtr r300)
r300Fogfv(ctx, GL_FOG_COLOR, ctx->Fog.Color);
r300Fogfv(ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL);
- r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
r300->hw.unk4BD8.cmd[1] = 0;
r300->hw.unk4E00.cmd[1] = 0;
r300BlendColor(ctx, ctx->Color.BlendColor);
- r300->hw.blend_color.cmd[2] = 0;
- r300->hw.blend_color.cmd[3] = 0;
/* Again, r300ClearBuffer uses this */
r300->hw.cb.cmd[R300_CB_OFFSET] =
@@ -1925,25 +1957,6 @@ static void r300ResetHwState(r300ContextPtr r300)
r300->hw.unk4EA0.cmd[1] = 0x00000000;
r300->hw.unk4EA0.cmd[2] = 0xffffffff;
- switch (ctx->Visual.depthBits) {
- case 16:
- r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
- break;
- case 24:
- r300->hw.zstencil_format.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
- break;
- default:
- fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
- ctx->Visual.depthBits);
- _mesa_exit(-1);
-
- }
- /* z compress? */
- //r300->hw.zstencil_format.cmd[1] |= R300_DEPTH_FORMAT_UNK32;
-
- r300->hw.zstencil_format.cmd[3] = 0x00000003;
- r300->hw.zstencil_format.cmd[4] = 0x00000000;
-
r300->hw.zb.cmd[R300_ZB_OFFSET] =
r300->radeon.radeonScreen->depthOffset +
r300->radeon.radeonScreen->fbLocation;
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c
index 16dddf6557..0fb6110494 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.c
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.c
@@ -29,6 +29,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* \file
*
* \author Aapo Tahkola <aet@rasterburn.org>
+ *
+ * \author Oliver McFadden <z3ro.geek@gmail.com>
*/
#include "glheader.h"
@@ -55,54 +57,58 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#error Cannot change these!
#endif
-#define SCALAR_FLAG (1<<31)
-#define FLAG_MASK (1<<31)
-#define OP_MASK (0xf) /* we are unlikely to have more than 15 */
-#define OPN(operator, ip) {#operator, OPCODE_##operator, ip}
-
-static struct {
- char *name;
- int opcode;
- unsigned long ip; /* number of input operands and flags */
-} op_names[] = {
- /* *INDENT-OFF* */
- OPN(ABS, 1),
- OPN(ADD, 2),
- OPN(ARL, 1 | SCALAR_FLAG),
- OPN(DP3, 2),
- OPN(DP4, 2),
- OPN(DPH, 2),
- OPN(DST, 2),
- OPN(EX2, 1 | SCALAR_FLAG),
- OPN(EXP, 1 | SCALAR_FLAG),
- OPN(FLR, 1),
- OPN(FRC, 1),
- OPN(LG2, 1 | SCALAR_FLAG),
- OPN(LIT, 1),
- OPN(LOG, 1 | SCALAR_FLAG),
- OPN(MAD, 3),
- OPN(MAX, 2),
- OPN(MIN, 2),
- OPN(MOV, 1),
- OPN(MUL, 2),
- OPN(POW, 2 | SCALAR_FLAG),
- OPN(RCP, 1 | SCALAR_FLAG),
- OPN(RSQ, 1 | SCALAR_FLAG),
- OPN(SGE, 2),
- OPN(SLT, 2),
- OPN(SUB, 2),
- OPN(SWZ, 1),
- OPN(XPD, 2),
- OPN(RCC, 0), //extra
- OPN(PRINT, 0),
- OPN(END, 0)
- /* *INDENT-ON* */
-};
-
-#undef OPN
+/* TODO: Get rid of t_src_class call */
+#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
+ ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
+ t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
+ (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
+ t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \
+
+#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
+ t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+
+#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
+ t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+
+#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
+ SWIZZLE_ZERO, SWIZZLE_ZERO, \
+ t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+
+#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
+ SWIZZLE_ONE, SWIZZLE_ONE, \
+ SWIZZLE_ONE, SWIZZLE_ONE, \
+ t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+
+#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
+ SWIZZLE_ONE, SWIZZLE_ONE, \
+ SWIZZLE_ONE, SWIZZLE_ONE, \
+ t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+
+#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
+ SWIZZLE_ONE, SWIZZLE_ONE, \
+ SWIZZLE_ONE, SWIZZLE_ONE, \
+ t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+
+/* DP4 version seems to trigger some hw peculiarity */
+//#define PREFER_DP4
+
+#define FREE_TEMPS() \
+ do { \
+ if(u_temp_i < vp->num_temporaries) { \
+ WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
+ vp->native = GL_FALSE; \
+ } \
+ u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
+ } while (0)
int r300VertexProgUpdateParams(GLcontext * ctx,
- struct r300_vertex_program_cont *vp, float *dst)
+ struct r300_vertex_program_cont *vp,
+ float *dst)
{
int pi;
struct gl_vertex_program *mesa_vp = &vp->mesa_program;
@@ -234,8 +240,8 @@ static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
int i;
if (vp == NULL) {
- fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__,
- caller);
+ fprintf(stderr, "vp null in call to %s from %s\n",
+ __FUNCTION__, caller);
return;
}
@@ -276,6 +282,8 @@ static unsigned long t_src_index(struct r300_vertex_program *vp,
}
}
+/* these two functions should probably be merged... */
+
static unsigned long t_src(struct r300_vertex_program *vp,
struct prog_src_register *src)
{
@@ -294,7 +302,9 @@ static unsigned long t_src(struct r300_vertex_program *vp,
static unsigned long t_src_scalar(struct r300_vertex_program *vp,
struct prog_src_register *src)
{
-
+ /* src->NegateBase uses the NEGATE_ flags from program_instruction.h,
+ * which equal our VSF_FLAGS_ values, so it's safe to just pass it here.
+ */
return MAKE_VSF_SOURCE(t_src_index(vp, src),
t_swizzle(GET_SWZ(src->Swizzle, 0)),
t_swizzle(GET_SWZ(src->Swizzle, 0)),
@@ -306,128 +316,727 @@ static unsigned long t_src_scalar(struct r300_vertex_program *vp,
(src->RelAddr << 4);
}
-static unsigned long t_opcode(enum prog_opcode opcode)
+static GLboolean valid_dst(struct r300_vertex_program *vp,
+ struct prog_dst_register *dst)
{
+ if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
+ return GL_FALSE;
+ } else if (dst->File == PROGRAM_ADDRESS) {
+ assert(dst->Index == 0);
+ }
+
+ return GL_TRUE;
+}
- switch (opcode) {
- /* *INDENT-OFF* */
- case OPCODE_ARL: return R300_VPI_OUT_OP_ARL;
- case OPCODE_DST: return R300_VPI_OUT_OP_DST;
- case OPCODE_EX2: return R300_VPI_OUT_OP_EX2;
- case OPCODE_EXP: return R300_VPI_OUT_OP_EXP;
- case OPCODE_FRC: return R300_VPI_OUT_OP_FRC;
- case OPCODE_LG2: return R300_VPI_OUT_OP_LG2;
- case OPCODE_LOG: return R300_VPI_OUT_OP_LOG;
- case OPCODE_MAX: return R300_VPI_OUT_OP_MAX;
- case OPCODE_MIN: return R300_VPI_OUT_OP_MIN;
- case OPCODE_MUL: return R300_VPI_OUT_OP_MUL;
- case OPCODE_RCP: return R300_VPI_OUT_OP_RCP;
- case OPCODE_RSQ: return R300_VPI_OUT_OP_RSQ;
- case OPCODE_SGE: return R300_VPI_OUT_OP_SGE;
- case OPCODE_SLT: return R300_VPI_OUT_OP_SLT;
- case OPCODE_DP4: return R300_VPI_OUT_OP_DOT;
- /* *INDENT-ON* */
+/*
+ * Instruction Inputs Output Description
+ * ----------- ------ ------ --------------------------------
+ * ABS v v absolute value
+ * ADD v,v v add
+ * ARL s a address register load
+ * DP3 v,v ssss 3-component dot product
+ * DP4 v,v ssss 4-component dot product
+ * DPH v,v ssss homogeneous dot product
+ * DST v,v v distance vector
+ * EX2 s ssss exponential base 2
+ * EXP s v exponential base 2 (approximate)
+ * FLR v v floor
+ * FRC v v fraction
+ * LG2 s ssss logarithm base 2
+ * LIT v v compute light coefficients
+ * LOG s v logarithm base 2 (approximate)
+ * MAD v,v,v v multiply and add
+ * MAX v,v v maximum
+ * MIN v,v v minimum
+ * MOV v v move
+ * MUL v,v v multiply
+ * POW s,s ssss exponentiate
+ * RCP s ssss reciprocal
+ * RSQ s ssss reciprocal square root
+ * SGE v,v v set on greater than or equal
+ * SLT v,v v set on less than
+ * SUB v,v v subtract
+ * SWZ v v extended swizzle
+ * XPD v,v v cross product
+ *
+ * Table X.5: Summary of vertex program instructions. "v" indicates a
+ * floating-point vector input or output, "s" indicates a floating-point
+ * scalar input, "ssss" indicates a scalar output replicated across a
+ * 4-component result vector, and "a" indicates a single address register
+ * component.
+ */
- default:
- fprintf(stderr, "%s: Should not be called with opcode %d!",
- __FUNCTION__, opcode);
- }
- _mesa_exit(-1);
- return 0;
+static void t_opcode_abs(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
+ t_src_class(src[0].File),
+ (!src[0].
+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ (src[0].RelAddr << 4);
+ o_inst->src[2] = 0;
}
-static unsigned long op_operands(enum prog_opcode opcode)
+static void t_opcode_add(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
{
- int i;
+ unsigned long hw_op;
- /* Can we trust mesas opcodes to be in order ? */
- for (i = 0; i < sizeof(op_names) / sizeof(*op_names); i++)
- if (op_names[i].opcode == opcode)
- return op_names[i].ip;
+#if 1
+ hw_op = (src[0].File == PROGRAM_TEMPORARY
+ && src[1].File ==
+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+ R300_VPI_OUT_OP_MAD;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = ONE_SRC_0;
+ o_inst->src[1] = t_src(vp, &src[0]);
+ o_inst->src[2] = t_src(vp, &src[1]);
+#else
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
- fprintf(stderr, "op %d not found in op_names\n", opcode);
- _mesa_exit(-1);
- return 0;
+#endif
}
-static GLboolean valid_dst(struct r300_vertex_program *vp,
- struct prog_dst_register *dst)
+static void t_opcode_arl(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
{
- if (dst->File == PROGRAM_OUTPUT && vp->outputs[dst->Index] == -1) {
- return GL_FALSE;
- } else if (dst->File == PROGRAM_ADDRESS) {
- assert(dst->Index == 0);
- }
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ARL, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
- return GL_TRUE;
+static void t_opcode_dp3(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+ SWIZZLE_ZERO, t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+ (src[0].RelAddr << 4);
+
+ o_inst->src[1] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+ SWIZZLE_ZERO, t_src_class(src[1].File),
+ src[1].
+ NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+ (src[1].RelAddr << 4);
+
+ o_inst->src[2] = ZERO_SRC_1;
}
-/* TODO: Get rid of t_src_class call */
-#define CMP_SRCS(a, b) ((a.RelAddr != b.RelAddr) || (a.Index != b.Index && \
- ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
- t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
- (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
- t_src_class(b.File) == VSF_IN_CLASS_ATTR)))) \
+static void t_opcode_dp4(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
-#define ZERO_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
- SWIZZLE_ZERO, SWIZZLE_ZERO, \
- SWIZZLE_ZERO, SWIZZLE_ZERO, \
- t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+static void t_opcode_dph(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+ VSF_IN_COMPONENT_ONE, t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_XYZ : VSF_FLAG_NONE) |
+ (src[0].RelAddr << 4);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
-#define ZERO_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
- SWIZZLE_ZERO, SWIZZLE_ZERO, \
- SWIZZLE_ZERO, SWIZZLE_ZERO, \
- t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+static void t_opcode_dst(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_DST, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
-#define ZERO_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
- SWIZZLE_ZERO, SWIZZLE_ZERO, \
- SWIZZLE_ZERO, SWIZZLE_ZERO, \
- t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+static void t_opcode_ex2(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_EX2, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src_scalar(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
-#define ONE_SRC_0 (MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), \
- SWIZZLE_ONE, SWIZZLE_ONE, \
- SWIZZLE_ONE, SWIZZLE_ONE, \
- t_src_class(src[0].File), VSF_FLAG_NONE) | (src[0].RelAddr << 4))
+static void t_opcode_exp(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_EXP, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src_scalar(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
-#define ONE_SRC_1 (MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), \
- SWIZZLE_ONE, SWIZZLE_ONE, \
- SWIZZLE_ONE, SWIZZLE_ONE, \
- t_src_class(src[1].File), VSF_FLAG_NONE) | (src[1].RelAddr << 4))
+static struct r300_vertprog_instruction *t_opcode_flr(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3],
+ int *u_temp_i)
+{
+ /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
+ ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, *u_temp_i,
+ t_dst_mask(vpi->DstReg.WriteMask),
+ VSF_OUT_CLASS_TMP);
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+ o_inst++;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] =
+ MAKE_VSF_SOURCE(*u_temp_i, VSF_IN_COMPONENT_X,
+ VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z,
+ VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP,
+ /* Not 100% sure about this */
+ (!src[0].
+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE
+ /*VSF_FLAG_ALL */ );
+
+ o_inst->src[2] = ZERO_SRC_0;
+ (*u_temp_i)--;
+
+ return o_inst;
+}
-#define ONE_SRC_2 (MAKE_VSF_SOURCE(t_src_index(vp, &src[2]), \
- SWIZZLE_ONE, SWIZZLE_ONE, \
- SWIZZLE_ONE, SWIZZLE_ONE, \
- t_src_class(src[2].File), VSF_FLAG_NONE) | (src[2].RelAddr << 4))
+static void t_opcode_frc(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
-/* DP4 version seems to trigger some hw peculiarity */
-//#define PREFER_DP4
+static void t_opcode_lg2(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ (src[0].RelAddr << 4);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
-#define FREE_TEMPS() \
- do { \
- if(u_temp_i < vp->num_temporaries) { \
- WARN_ONCE("Ran out of temps, num temps %d, us %d\n", vp->num_temporaries, u_temp_i); \
- vp->native = GL_FALSE; \
- } \
- u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1; \
- } while (0)
+static void t_opcode_lit(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ /* NOTE: Users swizzling might not work. */
+ o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ VSF_IN_COMPONENT_ZERO, // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[0].
+ RelAddr << 4);
+ o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ VSF_IN_COMPONENT_ZERO, // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[0].
+ RelAddr << 4);
+ o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ VSF_IN_COMPONENT_ZERO, // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[0].
+ RelAddr << 4);
+}
-static void r300TranslateVertexShader(struct r300_vertex_program *vp,
- struct prog_instruction *vpi)
+static void t_opcode_log(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_LOG, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src_scalar(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
+
+static void t_opcode_mad(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
{
- int i, cur_reg = 0;
- VERTEX_SHADER_INSTRUCTION *o_inst;
- unsigned long operands;
- int are_srcs_scalar;
unsigned long hw_op;
- /* Initial value should be last tmp reg that hw supports.
- Strangely enough r300 doesnt mind even though these would be out of range.
- Smart enough to realize that it doesnt need it? */
- int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1;
- struct prog_src_register src[3];
- vp->pos_end = 0; /* Not supported yet */
- vp->program.length = 0;
- /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
+ hw_op = (src[0].File == PROGRAM_TEMPORARY
+ && src[1].File == PROGRAM_TEMPORARY
+ && src[2].File ==
+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+ R300_VPI_OUT_OP_MAD;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = t_src(vp, &src[2]);
+}
+
+static void t_opcode_max(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_min(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_MIN, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_mov(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
+
+#if 1
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+#else
+ hw_op =
+ (src[0].File ==
+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+ R300_VPI_OUT_OP_MAD;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ONE_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+#endif
+}
+
+static void t_opcode_mul(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ unsigned long hw_op;
+
+ // HW mul can take third arg but appears to have some other limitations.
+
+ hw_op = (src[0].File == PROGRAM_TEMPORARY
+ && src[1].File ==
+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+ R300_VPI_OUT_OP_MAD;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+
+ o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_pow(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_POW, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src_scalar(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = t_src_scalar(vp, &src[1]);
+}
+
+static void t_opcode_rcp(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_RCP, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src_scalar(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
+
+static void t_opcode_rsq(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_RSQ, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src_scalar(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+}
+
+static void t_opcode_sge(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_SGE, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_slt(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_SLT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = t_src(vp, &src[1]);
+ o_inst->src[2] = ZERO_SRC_1;
+}
+
+static void t_opcode_sub(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ unsigned long hw_op;
+
+ //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
+
+#if 1
+ hw_op = (src[0].File == PROGRAM_TEMPORARY
+ && src[1].File ==
+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+ R300_VPI_OUT_OP_MAD;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ONE_SRC_0;
+ o_inst->src[2] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
+ t_src_class(src[1].File),
+ (!src[1].
+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ (src[1].RelAddr << 4);
+#else
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] =
+ MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
+ t_src_class(src[1].File),
+ (!src[1].
+ NegateBase) ? VSF_FLAG_ALL : VSF_FLAG_NONE) |
+ (src[1].RelAddr << 4);
+ o_inst->src[2] = 0;
+#endif
+}
+
+static void t_opcode_swz(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3])
+{
+ //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
+
+#if 1
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ZERO_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+#else
+ hw_op =
+ (src[0].File ==
+ PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
+ R300_VPI_OUT_OP_MAD;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+ o_inst->src[0] = t_src(vp, &src[0]);
+ o_inst->src[1] = ONE_SRC_0;
+ o_inst->src[2] = ZERO_SRC_0;
+#endif
+}
+
+static struct r300_vertprog_instruction *t_opcode_xpd(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi,
+ struct r300_vertprog_instruction *o_inst,
+ struct prog_src_register src[3],
+ int *u_temp_i)
+{
+ /* mul r0, r1.yzxw, r2.zxyw
+ mad r0, -r2.yzxw, r1.zxyw, r0
+ NOTE: might need MAD_2
+ */
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, *u_temp_i,
+ t_dst_mask(vpi->DstReg.WriteMask),
+ VSF_OUT_CLASS_TMP);
+
+ o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[0].
+ RelAddr << 4);
+
+ o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
+ t_src_class(src[1].File),
+ src[1].
+ NegateBase ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[1].
+ RelAddr << 4);
+
+ o_inst->src[2] = ZERO_SRC_1;
+ o_inst++;
+ (*u_temp_i)--;
+
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask),
+ t_dst_class(vpi->DstReg.File));
+
+ o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
+ t_src_class(src[1].File),
+ (!src[1].
+ NegateBase) ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[1].
+ RelAddr << 4);
+
+ o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_src_class(src[0].File),
+ src[0].
+ NegateBase ? VSF_FLAG_ALL :
+ VSF_FLAG_NONE) | (src[0].
+ RelAddr << 4);
+
+ o_inst->src[2] =
+ MAKE_VSF_SOURCE(*u_temp_i + 1, VSF_IN_COMPONENT_X,
+ VSF_IN_COMPONENT_Y, VSF_IN_COMPONENT_Z,
+ VSF_IN_COMPONENT_W, VSF_IN_CLASS_TMP,
+ VSF_FLAG_NONE);
+
+ return o_inst;
+}
+
+static void t_inputs_outputs(struct r300_vertex_program *vp)
+{
+ int i;
+ int cur_reg = 0;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
vp->inputs[i] = -1;
@@ -437,39 +1046,71 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
assert(vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS));
- /* Assign outputs */
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS))
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_HPOS)) {
vp->outputs[VERT_RESULT_HPOS] = cur_reg++;
+ }
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ))
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_PSIZ)) {
vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
+ }
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0))
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL0)) {
vp->outputs[VERT_RESULT_COL0] = cur_reg++;
+ }
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1))
- vp->outputs[VERT_RESULT_COL1] = cur_reg++;
-
-#if 0 /* Not supported yet */
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0))
- vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_COL1)) {
+ vp->outputs[VERT_RESULT_COL1] =
+ vp->outputs[VERT_RESULT_COL0] + 1;
+ cur_reg = vp->outputs[VERT_RESULT_COL1] + 1;
+ }
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1))
- vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC0)) {
+ vp->outputs[VERT_RESULT_BFC0] =
+ vp->outputs[VERT_RESULT_COL0] + 2;
+ cur_reg = vp->outputs[VERT_RESULT_BFC0] + 1;
+ }
- if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC))
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_BFC1)) {
+ vp->outputs[VERT_RESULT_BFC1] =
+ vp->outputs[VERT_RESULT_COL0] + 3;
+ cur_reg = vp->outputs[VERT_RESULT_BFC1] + 1;
+ }
+#if 0
+ if (vp->key.OutputsWritten & (1 << VERT_RESULT_FOGC)) {
vp->outputs[VERT_RESULT_FOGC] = cur_reg++;
+ }
#endif
- for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++)
- if (vp->key.OutputsWritten & (1 << i))
+ for (i = VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++) {
+ if (vp->key.OutputsWritten & (1 << i)) {
vp->outputs[i] = cur_reg++;
+ }
+ }
+}
+
+static void r300TranslateVertexShader(struct r300_vertex_program *vp,
+ struct prog_instruction *vpi)
+{
+ int i;
+ struct r300_vertprog_instruction *o_inst;
+ unsigned long num_operands;
+ /* Initial value should be last tmp reg that hw supports.
+ Strangely enough r300 doesnt mind even though these would be out of range.
+ Smart enough to realize that it doesnt need it? */
+ int u_temp_i = VSF_MAX_FRAGMENT_TEMPS - 1;
+ struct prog_src_register src[3];
+ vp->pos_end = 0; /* Not supported yet */
+ vp->program.length = 0;
+ /*vp->num_temporaries=mesa_vp->Base.NumTemporaries; */
vp->translated = GL_TRUE;
vp->native = GL_TRUE;
- o_inst = vp->program.body.i;
- for (; vpi->Opcode != OPCODE_END; vpi++, o_inst++) {
+ t_inputs_outputs(vp);
+
+ for (o_inst = vp->program.body.i; vpi->Opcode != OPCODE_END;
+ vpi++, o_inst++) {
+
FREE_TEMPS();
if (!valid_dst(vp, &vpi->DstReg)) {
@@ -478,29 +1119,30 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
vpi->DstReg.Index = u_temp_i;
}
- operands = op_operands(vpi->Opcode);
- are_srcs_scalar = operands & SCALAR_FLAG;
- operands &= OP_MASK;
+ num_operands = _mesa_num_inst_src_regs(vpi->Opcode);
- for (i = 0; i < operands; i++)
+ /* copy the sources (src) from mesa into a local variable... is this needed? */
+ for (i = 0; i < num_operands; i++) {
src[i] = vpi->SrcReg[i];
+ }
- if (operands == 3) { /* TODO: scalars */
+ if (num_operands == 3) { /* TODO: scalars */
if (CMP_SRCS(src[1], src[2])
|| CMP_SRCS(src[0], src[2])) {
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
- VSF_FLAG_ALL,
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
+ u_temp_i, VSF_FLAG_ALL,
VSF_OUT_CLASS_TMP);
o_inst->src[0] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
+ MAKE_VSF_SOURCE(t_src_index
+ (vp, &src[2]),
SWIZZLE_X, SWIZZLE_Y,
SWIZZLE_Z, SWIZZLE_W,
- t_src_class(src[2].File),
- VSF_FLAG_NONE) | (src[2].
- RelAddr <<
- 4);
+ t_src_class(src[2].
+ File),
+ VSF_FLAG_NONE) |
+ (src[2].RelAddr << 4);
o_inst->src[1] = ZERO_SRC_2;
o_inst->src[2] = ZERO_SRC_2;
@@ -511,24 +1153,24 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
src[2].RelAddr = 0;
u_temp_i--;
}
-
}
- if (operands >= 2) {
+ if (num_operands >= 2) {
if (CMP_SRCS(src[1], src[0])) {
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
- VSF_FLAG_ALL,
+ o_inst->opcode =
+ MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
+ u_temp_i, VSF_FLAG_ALL,
VSF_OUT_CLASS_TMP);
o_inst->src[0] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ MAKE_VSF_SOURCE(t_src_index
+ (vp, &src[0]),
SWIZZLE_X, SWIZZLE_Y,
SWIZZLE_Z, SWIZZLE_W,
- t_src_class(src[0].File),
- VSF_FLAG_NONE) | (src[0].
- RelAddr <<
- 4);
+ t_src_class(src[0].
+ File),
+ VSF_FLAG_NONE) |
+ (src[0].RelAddr << 4);
o_inst->src[1] = ZERO_SRC_0;
o_inst->src[2] = ZERO_SRC_0;
@@ -541,517 +1183,101 @@ static void r300TranslateVertexShader(struct r300_vertex_program *vp,
}
}
- /* These ops need special handling. */
switch (vpi->Opcode) {
- case OPCODE_POW:
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_POW,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src_scalar(vp, &src[0]);
- o_inst->src[1] = ZERO_SRC_0;
- o_inst->src[2] = t_src_scalar(vp, &src[1]);
- goto next;
-
- case OPCODE_MOV: //ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
- case OPCODE_SWZ:
-#if 1
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = ZERO_SRC_0;
- o_inst->src[2] = ZERO_SRC_0;
-#else
- hw_op =
- (src[0].File ==
- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
- R300_VPI_OUT_OP_MAD;
-
- o_inst->op =
- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = ONE_SRC_0;
- o_inst->src[2] = ZERO_SRC_0;
-#endif
-
- goto next;
-
+ case OPCODE_ABS:
+ t_opcode_abs(vp, vpi, o_inst, src);
+ break;
case OPCODE_ADD:
-#if 1
- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
- src[1].File ==
- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
- R300_VPI_OUT_OP_MAD;
-
- o_inst->op =
- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = ONE_SRC_0;
- o_inst->src[1] = t_src(vp, &src[0]);
- o_inst->src[2] = t_src(vp, &src[1]);
-#else
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = t_src(vp, &src[1]);
- o_inst->src[2] = ZERO_SRC_1;
-
-#endif
- goto next;
-
- case OPCODE_MAD:
- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
- src[1].File == PROGRAM_TEMPORARY &&
- src[2].File ==
- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
- R300_VPI_OUT_OP_MAD;
-
- o_inst->op =
- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = t_src(vp, &src[1]);
- o_inst->src[2] = t_src(vp, &src[2]);
- goto next;
-
- case OPCODE_MUL: /* HW mul can take third arg but appears to have some other limitations. */
- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
- src[1].File ==
- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
- R300_VPI_OUT_OP_MAD;
-
- o_inst->op =
- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = t_src(vp, &src[1]);
-
- o_inst->src[2] = ZERO_SRC_1;
- goto next;
-
- case OPCODE_DP3: //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_DOT,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 1)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 2)),
- SWIZZLE_ZERO,
- t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_XYZ :
- VSF_FLAG_NONE) | (src[0].
- RelAddr << 4);
-
- o_inst->src[1] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 1)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 2)),
- SWIZZLE_ZERO,
- t_src_class(src[1].File),
- src[1].
- NegateBase ? VSF_FLAG_XYZ :
- VSF_FLAG_NONE) | (src[1].
- RelAddr << 4);
-
- o_inst->src[2] = ZERO_SRC_1;
- goto next;
-
- case OPCODE_SUB: //ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
-#if 1
- hw_op = (src[0].File == PROGRAM_TEMPORARY &&
- src[1].File ==
- PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 :
- R300_VPI_OUT_OP_MAD;
-
- o_inst->op =
- MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = ONE_SRC_0;
- o_inst->src[2] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 1)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 2)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 3)),
- t_src_class(src[1].File),
- (!src[1].
- NegateBase) ? VSF_FLAG_ALL :
- VSF_FLAG_NONE) | (src[1].
- RelAddr << 4);
-#else
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 1)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 2)),
- t_swizzle(GET_SWZ
- (src[1].Swizzle, 3)),
- t_src_class(src[1].File),
- (!src[1].
- NegateBase) ? VSF_FLAG_ALL :
- VSF_FLAG_NONE) | (src[1].
- RelAddr << 4);
- o_inst->src[2] = 0;
-#endif
- goto next;
-
- case OPCODE_ABS: //MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_MAX,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 1)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 2)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 3)),
- t_src_class(src[0].File),
- (!src[0].
- NegateBase) ? VSF_FLAG_ALL :
- VSF_FLAG_NONE) | (src[0].
- RelAddr << 4);
- o_inst->src[2] = 0;
- goto next;
-
+ t_opcode_add(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_ARL:
+ t_opcode_arl(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_DP3:
+ t_opcode_dp3(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_DP4:
+ t_opcode_dp4(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_DPH:
+ t_opcode_dph(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_DST:
+ t_opcode_dst(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_EX2:
+ t_opcode_ex2(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_EXP:
+ t_opcode_exp(vp, vpi, o_inst, src);
+ break;
case OPCODE_FLR:
- /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
- ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
-
- o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i,
- t_dst_mask(vpi->DstReg.
- WriteMask),
- VSF_OUT_CLASS_TMP);
-
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = ZERO_SRC_0;
- o_inst->src[2] = ZERO_SRC_0;
- o_inst++;
-
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_ADD,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = MAKE_VSF_SOURCE(u_temp_i,
- VSF_IN_COMPONENT_X,
- VSF_IN_COMPONENT_Y,
- VSF_IN_COMPONENT_Z,
- VSF_IN_COMPONENT_W,
- VSF_IN_CLASS_TMP,
- /* Not 100% sure about this */
- (!src[0].
- NegateBase) ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE
- /*VSF_FLAG_ALL */ );
-
- o_inst->src[2] = ZERO_SRC_0;
- u_temp_i--;
- goto next;
-
- case OPCODE_LG2: // LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_LG2,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_ALL :
- VSF_FLAG_NONE) | (src[0].
- RelAddr << 4);
- o_inst->src[1] = ZERO_SRC_0;
- o_inst->src[2] = ZERO_SRC_0;
- goto next;
-
- case OPCODE_LIT: //LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_LIT,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
- /* NOTE: Users swizzling might not work. */
- o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
- VSF_IN_COMPONENT_ZERO, // z
- t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
- t_src_class(src[0].
- File),
- src[0].
- NegateBase ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[0].RelAddr << 4);
- o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
- VSF_IN_COMPONENT_ZERO, // z
- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
- t_src_class(src[0].
- File),
- src[0].
- NegateBase ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[0].RelAddr << 4);
- o_inst->src[2] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
- VSF_IN_COMPONENT_ZERO, // z
- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
- t_src_class(src[0].
- File),
- src[0].
- NegateBase ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[0].RelAddr << 4);
- goto next;
-
- case OPCODE_DPH: //DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_DOT,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] =
- MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 0)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 1)),
- t_swizzle(GET_SWZ
- (src[0].Swizzle, 2)),
- VSF_IN_COMPONENT_ONE,
- t_src_class(src[0].File),
- src[0].
- NegateBase ? VSF_FLAG_XYZ :
- VSF_FLAG_NONE) | (src[0].
- RelAddr << 4);
- o_inst->src[1] = t_src(vp, &src[1]);
- o_inst->src[2] = ZERO_SRC_1;
- goto next;
-
- case OPCODE_XPD:
- /* mul r0, r1.yzxw, r2.zxyw
- mad r0, -r2.yzxw, r1.zxyw, r0
- NOTE: might need MAD_2
- */
-
- o_inst->op = MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i,
- t_dst_mask(vpi->DstReg.
- WriteMask),
- VSF_OUT_CLASS_TMP);
-
- o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
- t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
- t_src_class(src[0].
- File),
- src[0].
- NegateBase ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[0].RelAddr << 4);
-
- o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
- t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
- t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
- t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
- t_src_class(src[1].
- File),
- src[1].
- NegateBase ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[1].RelAddr << 4);
-
- o_inst->src[2] = ZERO_SRC_1;
- o_inst++;
- u_temp_i--;
-
- o_inst->op =
- MAKE_VSF_OP(R300_VPI_OUT_OP_MAD,
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- o_inst->src[0] = MAKE_VSF_SOURCE(t_src_index(vp, &src[1]), t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
- t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
- t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
- t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
- t_src_class(src[1].
- File),
- (!src[1].
- NegateBase) ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[1].RelAddr << 4);
-
- o_inst->src[1] = MAKE_VSF_SOURCE(t_src_index(vp, &src[0]), t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
- t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
- t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
- t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
- t_src_class(src[0].
- File),
- src[0].
- NegateBase ?
- VSF_FLAG_ALL :
- VSF_FLAG_NONE) |
- (src[0].RelAddr << 4);
-
- o_inst->src[2] = MAKE_VSF_SOURCE(u_temp_i + 1,
- VSF_IN_COMPONENT_X,
- VSF_IN_COMPONENT_Y,
- VSF_IN_COMPONENT_Z,
- VSF_IN_COMPONENT_W,
- VSF_IN_CLASS_TMP,
- VSF_FLAG_NONE);
-
- goto next;
-
- case OPCODE_RCC:
- fprintf(stderr, "Dont know how to handle op %d yet\n",
- vpi->Opcode);
- _mesa_exit(-1);
+ /* FIXME */
+ o_inst = t_opcode_flr(vp, vpi, o_inst, src, &u_temp_i);
+ break;
+ case OPCODE_FRC:
+ t_opcode_frc(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_LG2:
+ t_opcode_lg2(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_LIT:
+ t_opcode_lit(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_LOG:
+ t_opcode_log(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_MAD:
+ t_opcode_mad(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_MAX:
+ t_opcode_max(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_MIN:
+ t_opcode_min(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_MOV:
+ t_opcode_mov(vp, vpi, o_inst, src);
break;
- case OPCODE_END:
+ case OPCODE_MUL:
+ t_opcode_mul(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_POW:
+ t_opcode_pow(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_RCP:
+ t_opcode_rcp(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_RSQ:
+ t_opcode_rsq(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_SGE:
+ t_opcode_sge(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_SLT:
+ t_opcode_slt(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_SUB:
+ t_opcode_sub(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_SWZ:
+ t_opcode_swz(vp, vpi, o_inst, src);
+ break;
+ case OPCODE_XPD:
+ /* FIXME */
+ o_inst = t_opcode_xpd(vp, vpi, o_inst, src, &u_temp_i);
break;
default:
+ assert(0);
break;
}
-
- o_inst->op =
- MAKE_VSF_OP(t_opcode(vpi->Opcode),
- t_dst_index(vp, &vpi->DstReg),
- t_dst_mask(vpi->DstReg.WriteMask),
- t_dst_class(vpi->DstReg.File));
-
- if (are_srcs_scalar) {
- switch (operands) {
- case 1:
- o_inst->src[0] = t_src_scalar(vp, &src[0]);
- o_inst->src[1] = ZERO_SRC_0;
- o_inst->src[2] = ZERO_SRC_0;
- break;
-
- case 2:
- o_inst->src[0] = t_src_scalar(vp, &src[0]);
- o_inst->src[1] = t_src_scalar(vp, &src[1]);
- o_inst->src[2] = ZERO_SRC_1;
- break;
-
- case 3:
- o_inst->src[0] = t_src_scalar(vp, &src[0]);
- o_inst->src[1] = t_src_scalar(vp, &src[1]);
- o_inst->src[2] = t_src_scalar(vp, &src[2]);
- break;
-
- default:
- fprintf(stderr,
- "scalars and op RCC not handled yet");
- _mesa_exit(-1);
- break;
- }
- } else {
- switch (operands) {
- case 1:
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = ZERO_SRC_0;
- o_inst->src[2] = ZERO_SRC_0;
- break;
-
- case 2:
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = t_src(vp, &src[1]);
- o_inst->src[2] = ZERO_SRC_1;
- break;
-
- case 3:
- o_inst->src[0] = t_src(vp, &src[0]);
- o_inst->src[1] = t_src(vp, &src[1]);
- o_inst->src[2] = t_src(vp, &src[2]);
- break;
-
- default:
- fprintf(stderr,
- "scalars and op RCC not handled yet");
- _mesa_exit(-1);
- break;
- }
- }
- next:;
}
- /* Will most likely segfault before we get here... fix later. */
- if (o_inst - vp->program.body.i >= VSF_MAX_FRAGMENT_LENGTH / 4) {
+ vp->program.length = (o_inst - vp->program.body.i) * 4;
+ if (vp->program.length >= VSF_MAX_FRAGMENT_LENGTH) {
vp->program.length = 0;
vp->native = GL_FALSE;
- return;
}
- vp->program.length = (o_inst - vp->program.body.i) * 4;
#if 0
fprintf(stderr, "hw program:\n");
for (i = 0; i < vp->program.length; i++)
@@ -1065,7 +1291,8 @@ static void position_invariant(struct gl_program *prog)
struct gl_program_parameter_list *paramList;
int i;
- gl_state_index tokens[STATE_LENGTH] = { STATE_MVP_MATRIX, 0, 0, 0, 0 };
+ gl_state_index tokens[STATE_LENGTH] =
+ { STATE_MVP_MATRIX, 0, 0, 0, 0 };
/* tokens[4] = matrix modifier */
#ifdef PREFER_DP4
@@ -1159,8 +1386,8 @@ static void insert_wpos(struct r300_vertex_program *vp,
prog->NumInstructions - 1);
/* END */
_mesa_copy_instructions(&vpi[prog->NumInstructions + 1],
- &prog->Instructions[prog->NumInstructions - 1],
- 1);
+ &prog->Instructions[prog->NumInstructions -
+ 1], 1);
vpi_insert = &vpi[prog->NumInstructions - 1];
vpi_insert[i].Opcode = OPCODE_MOV;
@@ -1206,8 +1433,8 @@ static void pos_as_texcoord(struct r300_vertex_program *vp,
prog->NumTemporaries++;
for (vpi = prog->Instructions; vpi->Opcode != OPCODE_END; vpi++) {
- if (vpi->DstReg.File == PROGRAM_OUTPUT &&
- vpi->DstReg.Index == VERT_RESULT_HPOS) {
+ if (vpi->DstReg.File == PROGRAM_OUTPUT
+ && vpi->DstReg.Index == VERT_RESULT_HPOS) {
vpi->DstReg.File = PROGRAM_TEMPORARY;
vpi->DstReg.Index = tempregi;
}
@@ -1223,20 +1450,18 @@ static struct r300_vertex_program *build_program(struct r300_vertex_program_key
vp = _mesa_calloc(sizeof(*vp));
_mesa_memcpy(&vp->key, wanted_key, sizeof(vp->key));
-
vp->wpos_idx = wpos_idx;
if (mesa_vp->IsPositionInvariant) {
position_invariant(&mesa_vp->Base);
}
- if (wpos_idx > -1)
+ if (wpos_idx > -1) {
pos_as_texcoord(vp, &mesa_vp->Base);
+ }
assert(mesa_vp->Base.NumInstructions);
-
vp->num_temporaries = mesa_vp->Base.NumTemporaries;
-
r300TranslateVertexShader(vp, mesa_vp->Base.Instructions);
return vp;
@@ -1252,11 +1477,10 @@ void r300SelectVertexShader(r300ContextPtr r300)
struct r300_vertex_program *vp;
GLint wpos_idx;
- vpc = (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
+ vpc =
+ (struct r300_vertex_program_cont *)ctx->VertexProgram._Current;
InputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
- wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
-
wpos_idx = -1;
if (InputsRead & FRAG_BIT_WPOS) {
for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
@@ -1271,28 +1495,35 @@ void r300SelectVertexShader(r300ContextPtr r300)
InputsRead |= (FRAG_BIT_TEX0 << i);
wpos_idx = i;
}
+ wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
+ wanted_key.OutputsWritten = vpc->mesa_program.Base.OutputsWritten;
+
+ wanted_key.OutputsWritten |= 1 << VERT_RESULT_HPOS;
- if (InputsRead & FRAG_BIT_COL0)
+ if (InputsRead & FRAG_BIT_COL0) {
wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL0;
+ }
- if ((InputsRead & FRAG_BIT_COL1) /*||
- (InputsRead & FRAG_BIT_FOGC) */ )
+ if ((InputsRead & FRAG_BIT_COL1)) {
wanted_key.OutputsWritten |= 1 << VERT_RESULT_COL1;
+ }
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
- if (InputsRead & (FRAG_BIT_TEX0 << i))
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (InputsRead & (FRAG_BIT_TEX0 << i)) {
wanted_key.OutputsWritten |=
1 << (VERT_RESULT_TEX0 + i);
+ }
+ }
- wanted_key.InputsRead = vpc->mesa_program.Base.InputsRead;
if (vpc->mesa_program.IsPositionInvariant) {
/* we wan't position don't we ? */
wanted_key.InputsRead |= (1 << VERT_ATTRIB_POS);
+ wanted_key.OutputsWritten |= (1 << VERT_RESULT_HPOS);
}
for (vp = vpc->progs; vp; vp = vp->next)
- if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key)) ==
- 0) {
+ if (_mesa_memcmp(&vp->key, &wanted_key, sizeof(wanted_key))
+ == 0) {
r300->selected_vp = vp;
return;
}
diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.h b/src/mesa/drivers/dri/r300/r300_vertprog.h
index 252d5a901f..2d399e243a 100644
--- a/src/mesa/drivers/dri/r300/r300_vertprog.h
+++ b/src/mesa/drivers/dri/r300/r300_vertprog.h
@@ -3,10 +3,10 @@
#include "r300_reg.h"
-typedef struct {
- GLuint op;
+struct r300_vertprog_instruction {
+ GLuint opcode;
GLuint src[3];
-} VERTEX_SHADER_INSTRUCTION;
+};
#define VSF_FLAG_X 1
#define VSF_FLAG_Y 2