-
-
-void
-_swrast_alloc_buffers( GLframebuffer *buffer )
-{
- /* Reallocate other buffers if needed. */
- if (buffer->UseSoftwareDepthBuffer) {
- _swrast_alloc_depth_buffer( buffer );
- }
- if (buffer->UseSoftwareStencilBuffer) {
- _swrast_alloc_stencil_buffer( buffer );
- }
- if (buffer->UseSoftwareAccumBuffer) {
- _swrast_alloc_accum_buffer( buffer );
- }
- if (buffer->UseSoftwareAlphaBuffers) {
- _swrast_alloc_alpha_buffers( buffer );
- }
-}
-
-
-/*
- * Fallback for ctx->Driver.DrawBuffer()
- */
-void
-_swrast_DrawBuffer( GLcontext *ctx, GLenum mode )
-{
- _swrast_use_draw_buffer(ctx);
-}
-
-
-/*
- * Setup things so that we read/write spans from the user-designated
- * read buffer (set via glReadPixels). We usually just have to call
- * this for glReadPixels, glCopyPixels, etc.
- */
-void
-_swrast_use_read_buffer( GLcontext *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- /* Do this so the software-emulated alpha plane span functions work! */
- swrast->CurrentBuffer = ctx->Pixel._ReadSrcMask;
- /* Tell the device driver where to read/write spans */
- (*swrast->Driver.SetBuffer)( ctx, ctx->ReadBuffer, swrast->CurrentBuffer );
-}
-
-
-/*
- * Setup things so that we read/write spans from the default draw buffer.
- * This is the usual mode that Mesa's software rasterizer operates in.
- */
-void
-_swrast_use_draw_buffer( GLcontext *ctx )
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- /* The user can specify rendering to zero, one, two, or four color
- * buffers simultaneously with glDrawBuffer()!
- * We don't expect the span/point/line/triangle functions to deal with
- * that mess so we'll iterate over the multiple buffers as needed.
- * But usually we only render to one color buffer at a time.
- * We set ctx->Color._DriverDrawBuffer to that buffer and tell the
- * device driver to use that buffer.
- * Look in s_span.c's multi_write_rgba_span() function to see how
- * we loop over multiple color buffers when needed.
- */
-
- if (ctx->Color._DrawDestMask & FRONT_LEFT_BIT)
- swrast->CurrentBuffer = FRONT_LEFT_BIT;
- else if (ctx->Color._DrawDestMask & BACK_LEFT_BIT)
- swrast->CurrentBuffer = BACK_LEFT_BIT;
- else if (ctx->Color._DrawDestMask & FRONT_RIGHT_BIT)
- swrast->CurrentBuffer = FRONT_RIGHT_BIT;
- else if (ctx->Color._DrawDestMask & BACK_RIGHT_BIT)
- swrast->CurrentBuffer = BACK_RIGHT_BIT;
- else
- /* glDrawBuffer(GL_NONE) */
- swrast->CurrentBuffer = FRONT_LEFT_BIT; /* we always have this buffer */
-
- (*swrast->Driver.SetBuffer)( ctx, ctx->DrawBuffer, swrast->CurrentBuffer );
-}