diff options
author | Brian <[email protected]> | 2007-03-11 17:00:39 -0600 |
---|---|---|
committer | Brian <[email protected]> | 2007-03-11 17:00:39 -0600 |
commit | 1c09bcfdda4083636a3ac27d804a34ef87875ce7 (patch) | |
tree | 9d97cdcff44f9a789e0bec8c15609d61c3db2d17 /src/mesa/swrast/s_fragprog.c | |
parent | d23dd812ad597ddbe82be5f95708ece9ad63a2fa (diff) |
Implement support for GL_ARB_draw_buffers with GL_MAX_DRAW_BUFFERS > 1.
GL_MAX_DRAW_BUFFERS is currently 4.
Added gl_FragData[] output for fragment programs.
In _swrast_write_rgba_span() loop over the color outputs/renderbuffers.
Diffstat (limited to 'src/mesa/swrast/s_fragprog.c')
-rw-r--r-- | src/mesa/swrast/s_fragprog.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/mesa/swrast/s_fragprog.c b/src/mesa/swrast/s_fragprog.c index dbfc1b8c0cc..7260759306e 100644 --- a/src/mesa/swrast/s_fragprog.c +++ b/src/mesa/swrast/s_fragprog.c @@ -139,7 +139,9 @@ init_machine(GLcontext *ctx, struct gl_program_machine *machine, static void run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) { + SWcontext *swrast = SWRAST_CONTEXT(ctx); const struct gl_fragment_program *program = ctx->FragmentProgram._Current; + const GLbitfield outputsWritten = program->Base.OutputsWritten; struct gl_program_machine machine; GLuint i; @@ -148,12 +150,28 @@ run_program(GLcontext *ctx, SWspan *span, GLuint start, GLuint end) init_machine(ctx, &machine, program, span, i); if (_mesa_execute_program(ctx, &program->Base, &machine)) { + /* Store result color */ - COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], - machine.Outputs[FRAG_RESULT_COLR]); + if (outputsWritten & (1 << FRAG_RESULT_COLR)) { + COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0][i], + machine.Outputs[FRAG_RESULT_COLR]); + } + else { + /* Multiple drawbuffers / render targets + * Note that colors beyond 0 and 1 will overwrite other + * attributes, such as FOGC, TEX0, TEX1, etc. That's OK. + */ + GLuint output; + for (output = 0; output < swrast->_NumColorOutputs; output++) { + if (outputsWritten & (1 << (FRAG_RESULT_DATA0 + output))) { + COPY_4V(span->array->attribs[FRAG_ATTRIB_COL0+output][i], + machine.Outputs[FRAG_RESULT_DATA0 + output]); + } + } + } /* Store result depth/z */ - if (program->Base.OutputsWritten & (1 << FRAG_RESULT_DEPR)) { + if (outputsWritten & (1 << FRAG_RESULT_DEPR)) { const GLfloat depth = machine.Outputs[FRAG_RESULT_DEPR][2]; if (depth <= 0.0) span->array->z[i] = 0; |