}
}
-/**
- * Execute the given fragment shader
- * NOTE: we do everything in single-precision floating point; we don't
- * currently observe the single/half/fixed-precision qualifiers.
- * \param ctx - rendering context
- * \param program - the fragment program to execute
- * \param machine - machine state (register file)
- * \param maxInst - max number of instructions to execute
- * \return GL_TRUE if program completed or GL_FALSE if program executed KIL.
- */
-
struct ati_fs_opcode_st ati_fs_opcodes[] = {
{GL_ADD_ATI, 2},
{GL_SUB_ATI, 2},
if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) {
pass_tex -= GL_TEXTURE0_ARB;
COPY_4V(machine->Registers[idx],
- span->array->texcoords[pass_tex][column]);
+ span->array->attribs[FRAG_ATTRIB_TEX0 + pass_tex][column]);
}
else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI) {
pass_tex -= GL_REG_0_ATI;
if (coord_source >= GL_TEXTURE0_ARB && coord_source <= GL_TEXTURE7_ARB) {
coord_source -= GL_TEXTURE0_ARB;
- COPY_4V(tex_coords, span->array->texcoords[coord_source][column]);
+ COPY_4V(tex_coords,
+ span->array->attribs[FRAG_ATTRIB_TEX0 + coord_source][column]);
}
else if (coord_source >= GL_REG_0_ATI && coord_source <= GL_REG_5_ATI) {
coord_source -= GL_REG_0_ATI;
COPY_4V(src[optype][i], x); \
} while (0)
-static GLboolean
-execute_shader(GLcontext * ctx,
- const struct ati_fragment_shader *shader, GLuint maxInst,
+
+
+/**
+ * Execute the given fragment shader.
+ * NOTE: we do everything in single-precision floating point
+ * \param ctx - rendering context
+ * \param shader - the shader to execute
+ * \param machine - virtual machine state
+ * \param span - the SWspan we're operating on
+ * \param column - which pixel [i] we're operating on in the span
+ */
+static void
+execute_shader(GLcontext *ctx, const struct ati_fragment_shader *shader,
struct atifs_machine *machine, const SWspan *span,
- GLuint column)
+ GLuint column)
{
GLuint pc;
struct atifs_instruction *inst;
struct atifs_setupinst *texinst;
GLint optype;
- GLint i, j, pass;
+ GLuint i;
+ GLint j, pass;
GLint dstreg;
GLfloat src[2][3][4];
GLfloat zeros[4] = { 0.0, 0.0, 0.0, 0.0 };
/* setup the source registers for color and alpha ops */
for (optype = 0; optype < 2; optype++) {
- for (i = 0; i < inst->ArgCount[optype]; i++) {
+ for (i = 0; i < inst->ArgCount[optype]; i++) {
GLint index = inst->SrcReg[optype][i].Index;
if (index >= GL_REG_0_ATI && index <= GL_REG_5_ATI)
}
}
}
- return GL_TRUE;
}
machine->Registers[i][j] = 0.0;
}
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- GLubyte (*rgba)[4] = span->array->color.sz1.rgba;
- GLubyte (*spec)[4] = span->array->color.sz1.spec;
- inputs[ATI_FS_INPUT_PRIMARY][0] = UBYTE_TO_FLOAT(rgba[col][0]);
- inputs[ATI_FS_INPUT_PRIMARY][1] = UBYTE_TO_FLOAT(rgba[col][1]);
- inputs[ATI_FS_INPUT_PRIMARY][2] = UBYTE_TO_FLOAT(rgba[col][2]);
- inputs[ATI_FS_INPUT_PRIMARY][3] = UBYTE_TO_FLOAT(rgba[col][3]);
- inputs[ATI_FS_INPUT_SECONDARY][0] = UBYTE_TO_FLOAT(spec[col][0]);
- inputs[ATI_FS_INPUT_SECONDARY][1] = UBYTE_TO_FLOAT(spec[col][1]);
- inputs[ATI_FS_INPUT_SECONDARY][2] = UBYTE_TO_FLOAT(spec[col][2]);
- inputs[ATI_FS_INPUT_SECONDARY][3] = UBYTE_TO_FLOAT(spec[col][3]);
- }
- else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- GLushort (*rgba)[4] = span->array->color.sz2.rgba;
- GLushort (*spec)[4] = span->array->color.sz2.spec;
- inputs[ATI_FS_INPUT_PRIMARY][0] = USHORT_TO_FLOAT(rgba[col][0]);
- inputs[ATI_FS_INPUT_PRIMARY][1] = USHORT_TO_FLOAT(rgba[col][1]);
- inputs[ATI_FS_INPUT_PRIMARY][2] = USHORT_TO_FLOAT(rgba[col][2]);
- inputs[ATI_FS_INPUT_PRIMARY][3] = USHORT_TO_FLOAT(rgba[col][3]);
- inputs[ATI_FS_INPUT_SECONDARY][0] = USHORT_TO_FLOAT(spec[col][0]);
- inputs[ATI_FS_INPUT_SECONDARY][1] = USHORT_TO_FLOAT(spec[col][1]);
- inputs[ATI_FS_INPUT_SECONDARY][2] = USHORT_TO_FLOAT(spec[col][2]);
- inputs[ATI_FS_INPUT_SECONDARY][3] = USHORT_TO_FLOAT(spec[col][3]);
- }
- else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
- GLfloat (*spec)[4] = span->array->color.sz4.spec;
- COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], rgba[col]);
- COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], spec[col]);
- }
+ COPY_4V(inputs[ATI_FS_INPUT_PRIMARY], span->array->attribs[FRAG_ATTRIB_COL0][col]);
+ COPY_4V(inputs[ATI_FS_INPUT_SECONDARY], span->array->attribs[FRAG_ATTRIB_COL1][col]);
}
struct atifs_machine machine;
GLuint i;
+ /* incoming colors should be floats */
+ ASSERT(span->array->ChanType == GL_FLOAT);
+
ctx->_CurrentProgram = GL_FRAGMENT_SHADER_ATI;
for (i = 0; i < span->end; i++) {
if (span->array->mask[i]) {
init_machine(ctx, &machine, shader, span, i);
- /* can't really happen... */
- if (!execute_shader(ctx, shader, ~0, &machine, span, i)) {
- span->array->mask[i] = GL_FALSE;
- span->writeAll = GL_FALSE;
- }
+
+ execute_shader(ctx, shader, &machine, span, i);
/* store result color */
{
const GLfloat *colOut = machine.Registers[0];
- /*fprintf(stderr,"outputs %f %f %f %f\n",
+ /*fprintf(stderr,"outputs %f %f %f %f\n",
colOut[0], colOut[1], colOut[2], colOut[3]); */
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- GLubyte (*rgba)[4] = span->array->color.sz1.rgba;
- UNCLAMPED_FLOAT_TO_UBYTE(rgba[i][RCOMP], colOut[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(rgba[i][GCOMP], colOut[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(rgba[i][BCOMP], colOut[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(rgba[i][ACOMP], colOut[3]);
- }
- else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- GLushort (*rgba)[4] = span->array->color.sz2.rgba;
- UNCLAMPED_FLOAT_TO_USHORT(rgba[i][RCOMP], colOut[0]);
- UNCLAMPED_FLOAT_TO_USHORT(rgba[i][GCOMP], colOut[1]);
- UNCLAMPED_FLOAT_TO_USHORT(rgba[i][BCOMP], colOut[2]);
- UNCLAMPED_FLOAT_TO_USHORT(rgba[i][ACOMP], colOut[3]);
- }
- else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
- COPY_4V(rgba[i], colOut);
- }
+ COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], colOut);
}
}
}