summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast/s_context.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-03-11 17:00:39 -0600
committerBrian <[email protected]>2007-03-11 17:00:39 -0600
commit1c09bcfdda4083636a3ac27d804a34ef87875ce7 (patch)
tree9d97cdcff44f9a789e0bec8c15609d61c3db2d17 /src/mesa/swrast/s_context.c
parentd23dd812ad597ddbe82be5f95708ece9ad63a2fa (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_context.c')
-rw-r--r--src/mesa/swrast/s_context.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 8864c217a5e..00702b43013 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -548,6 +548,44 @@ _swrast_update_fragment_attribs(GLcontext *ctx)
}
+/**
+ * Update the swrast->_ColorOutputsMask which indicates which color
+ * renderbuffers (aka rendertargets) are being written to by the current
+ * fragment program.
+ * We also take glDrawBuffers() into account to skip outputs that are
+ * set to GL_NONE.
+ */
+static void
+_swrast_update_color_outputs(GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ swrast->_ColorOutputsMask = 0;
+ swrast->_NumColorOutputs = 0;
+
+ if (ctx->FragmentProgram._Current) {
+ const GLbitfield outputsWritten
+ = ctx->FragmentProgram._Current->Base.OutputsWritten;
+ GLuint output;
+ for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) {
+ if ((outputsWritten & (1 << (FRAG_RESULT_DATA0 + output)))
+ && (fb->_NumColorDrawBuffers[output] > 0)) {
+ swrast->_ColorOutputsMask |= (1 << output);
+ swrast->_NumColorOutputs = output + 1;
+ }
+ }
+ }
+ if (swrast->_ColorOutputsMask == 0x0) {
+ /* no fragment program, or frag prog didn't write to gl_FragData[] */
+ if (fb->_NumColorDrawBuffers[0] > 0) {
+ swrast->_ColorOutputsMask = 0x1;
+ swrast->_NumColorOutputs = 1;
+ }
+ }
+}
+
+
void
_swrast_validate_derived( GLcontext *ctx )
{
@@ -594,6 +632,9 @@ _swrast_validate_derived( GLcontext *ctx )
_NEW_TEXTURE))
_swrast_update_fragment_attribs(ctx);
+ if (swrast->NewState & (_NEW_PROGRAM | _NEW_BUFFERS))
+ _swrast_update_color_outputs(ctx);
+
swrast->NewState = 0;
swrast->StateChanges = 0;
swrast->InvalidateState = _swrast_invalidate_state;