summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_nvfragprog.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2006-10-17 22:23:32 +0000
committerBrian Paul <[email protected]>2006-10-17 22:23:32 +0000
commitc3caaa3dd45809e672177ab322445fe51d03af25 (patch)
tree00af90d49f1568b0dc68e565932de41b37e73431 /src/mesa/swrast/s_nvfragprog.c
parent32c3243e4d8237ecfeccd5a554abefaa0679e94b (diff)
Always convert colors to float before running a fragment shader/program.
Diffstat (limited to 'src/mesa/swrast/s_nvfragprog.c')
-rw-r--r--src/mesa/swrast/s_nvfragprog.c74
1 files changed, 13 insertions, 61 deletions
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 3dc9fdde6f9..20fbd5060b9 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -1466,47 +1466,14 @@ init_machine( GLcontext *ctx, struct fp_machine *machine,
wpos[3] = span->w + col * span->dwdx;
}
if (inputsRead & (1 << FRAG_ATTRIB_COL0)) {
- GLfloat *col0 = machine->Inputs[FRAG_ATTRIB_COL0];
ASSERT(span->arrayMask & SPAN_RGBA);
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- GLubyte (*rgba)[4] = span->array->color.sz1.rgba;
- col0[0] = UBYTE_TO_FLOAT(rgba[col][RCOMP]);
- col0[1] = UBYTE_TO_FLOAT(rgba[col][GCOMP]);
- col0[2] = UBYTE_TO_FLOAT(rgba[col][BCOMP]);
- col0[3] = UBYTE_TO_FLOAT(rgba[col][ACOMP]);
- }
- else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- GLushort (*rgba)[4] = span->array->color.sz2.rgba;
- col0[0] = USHORT_TO_FLOAT(rgba[col][RCOMP]);
- col0[1] = USHORT_TO_FLOAT(rgba[col][GCOMP]);
- col0[2] = USHORT_TO_FLOAT(rgba[col][BCOMP]);
- col0[3] = USHORT_TO_FLOAT(rgba[col][ACOMP]);
- }
- else {
- GLfloat (*rgba)[4] = span->array->color.sz4.rgba;
- COPY_4V(col0, rgba[col]);
- }
+ COPY_4V(machine->Inputs[FRAG_ATTRIB_COL0],
+ span->array->color.sz4.rgba[col]);
}
if (inputsRead & (1 << FRAG_ATTRIB_COL1)) {
- GLfloat *col1 = machine->Inputs[FRAG_ATTRIB_COL1];
- if (span->array->ChanType == GL_UNSIGNED_BYTE) {
- GLubyte (*rgba)[4] = span->array->color.sz1.spec;
- col1[0] = UBYTE_TO_FLOAT(rgba[col][RCOMP]);
- col1[1] = UBYTE_TO_FLOAT(rgba[col][GCOMP]);
- col1[2] = UBYTE_TO_FLOAT(rgba[col][BCOMP]);
- col1[3] = UBYTE_TO_FLOAT(rgba[col][ACOMP]);
- }
- else if (span->array->ChanType == GL_UNSIGNED_SHORT) {
- GLushort (*rgba)[4] = span->array->color.sz2.spec;
- col1[0] = USHORT_TO_FLOAT(rgba[col][RCOMP]);
- col1[1] = USHORT_TO_FLOAT(rgba[col][GCOMP]);
- col1[2] = USHORT_TO_FLOAT(rgba[col][BCOMP]);
- col1[3] = USHORT_TO_FLOAT(rgba[col][ACOMP]);
- }
- else {
- GLfloat (*rgba)[4] = span->array->color.sz4.spec;
- COPY_4V(col1, rgba[col]);
- }
+ ASSERT(span->arrayMask & SPAN_SPEC);
+ COPY_4V(machine->Inputs[FRAG_ATTRIB_COL1],
+ span->array->color.sz4.spec[col]);
}
if (inputsRead & (1 << FRAG_ATTRIB_FOGC)) {
GLfloat *fogc = machine->Inputs[FRAG_ATTRIB_FOGC];
@@ -1554,29 +1521,11 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end)
span->writeAll = GL_FALSE;
}
- /* Store output registers */
- {
- const GLfloat *colOut = machine.Outputs[FRAG_RESULT_COLR];
- 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_BYTE) {
- 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);
- }
- }
- /* depth value */
+ /* Store result color */
+ COPY_4V(span->array->color.sz4.rgba[i],
+ machine.Outputs[FRAG_RESULT_COLR]);
+
+ /* Store result depth/z */
if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) {
const GLfloat depth = machine.Outputs[FRAG_RESULT_DEPR][2];
if (depth <= 0.0)
@@ -1602,6 +1551,9 @@ _swrast_exec_fragment_program( GLcontext *ctx, SWspan *span )
{
const struct gl_fragment_program *program = ctx->FragmentProgram._Current;
+ /* incoming colors should be floats */
+ ASSERT(span->array->ChanType == GL_FLOAT);
+
ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */
if (program->Base.Parameters) {