Silence gcc 3.4 warnings on ReactOS. Mostly unused var warnings. (patch 1015696)
[mesa.git] / src / mesa / swrast / s_auxbuffer.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #include "glheader.h"
27 #include "imports.h"
28
29 #include "s_auxbuffer.h"
30 #include "s_context.h"
31
32
33
34 /**
35 * Allocate memory for the software auxillary buffers associated with
36 * the given GLframebuffer. Free any currently allocated aux buffers
37 * first.
38 */
39 void
40 _swrast_alloc_aux_buffers( GLframebuffer *buffer )
41 {
42 GLint i;
43
44 for (i = 0; i < buffer->Visual.numAuxBuffers; i++) {
45 if (buffer->AuxBuffers[i]) {
46 _mesa_free(buffer->AuxBuffers[i]);
47 buffer->AuxBuffers[i] = NULL;
48 }
49
50 buffer->AuxBuffers[i] = (GLchan *) _mesa_malloc(buffer->Width
51 * buffer->Height * 4 * sizeof(GLchan));
52 }
53 }
54
55
56
57 /* RGBA */
58 #define NAME(PREFIX) PREFIX##_aux
59 #define SPAN_VARS \
60 const SWcontext *swrast = SWRAST_CONTEXT(ctx);
61 #define INIT_PIXEL_PTR(P, X, Y) \
62 GLchan *P = swrast->CurAuxBuffer + ((Y) * ctx->DrawBuffer->Width + (X)) * 4; \
63 assert(swrast->CurAuxBuffer);
64
65 #define INC_PIXEL_PTR(P) P += 4
66 #if CHAN_TYPE == GL_FLOAT
67 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
68 P[0] = MAX2((R), 0.0F); \
69 P[1] = MAX2((G), 0.0F); \
70 P[2] = MAX2((B), 0.0F); \
71 P[3] = CHAN_MAXF
72 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
73 P[0] = MAX2((R), 0.0F); \
74 P[1] = MAX2((G), 0.0F); \
75 P[2] = MAX2((B), 0.0F); \
76 P[3] = CLAMP((A), 0.0F, CHAN_MAXF)
77 #else
78 #define STORE_RGB_PIXEL(P, X, Y, R, G, B) \
79 P[0] = R; P[1] = G; P[2] = B; P[3] = CHAN_MAX
80 #define STORE_RGBA_PIXEL(P, X, Y, R, G, B, A) \
81 P[0] = R; P[1] = G; P[2] = B; P[3] = A
82 #endif
83 #define FETCH_RGBA_PIXEL(R, G, B, A, P) \
84 R = P[0]; G = P[1]; B = P[2]; A = P[3]
85 #include "swrast/s_spantemp.h"
86
87
88
89 /**
90 * Called from driver's SetBuffer() function to choose an aux buffer.
91 */
92 void
93 _swrast_use_aux_buffer(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit)
94 {
95 SWcontext *swrast = SWRAST_CONTEXT(ctx);
96 (void) buffer;
97
98 switch (bufferBit) {
99 case DD_AUX0_BIT:
100 ASSERT(buffer->Visual.numAuxBuffers >= 1);
101 swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[0];
102 break;
103 case DD_AUX1_BIT:
104 ASSERT(buffer->Visual.numAuxBuffers >= 2);
105 swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[1];
106 break;
107 case DD_AUX2_BIT:
108 ASSERT(buffer->Visual.numAuxBuffers >= 3);
109 swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[2];
110 break;
111 case DD_AUX3_BIT:
112 ASSERT(buffer->Visual.numAuxBuffers >= 4);
113 swrast->CurAuxBuffer = ctx->DrawBuffer->AuxBuffers[3];
114 break;
115 default:
116 swrast->CurAuxBuffer = NULL;
117 }
118
119 swrast->Driver.WriteRGBASpan = write_rgba_span_aux;
120 swrast->Driver.WriteRGBSpan = write_rgb_span_aux;
121 swrast->Driver.WriteMonoRGBASpan = write_monorgba_span_aux;
122 swrast->Driver.WriteRGBAPixels = write_rgba_pixels_aux;
123 swrast->Driver.WriteMonoRGBAPixels = write_monorgba_pixels_aux;
124 swrast->Driver.ReadRGBASpan = read_rgba_span_aux;
125 swrast->Driver.ReadRGBAPixels = read_rgba_pixels_aux;
126 }
127