summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_fragprog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast/s_fragprog.c')
-rw-r--r--src/mesa/swrast/s_fragprog.c24
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;