1 /**************************************************************************
3 Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
4 Copyright 2003 Eric Anholt
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 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
27 /* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_span.c,v 1.5 2001/03/21 16:14:26 dawes Exp $ */
31 * Sung-Ching Lin <sclin@sis.com.tw>
32 * Eric Anholt <anholt@FreeBSD.org>
35 #include "sis_context.h"
40 #include "swrast/swrast.h"
45 sisContextPtr smesa = SIS_CONTEXT(ctx); \
46 __DRIdrawablePrivate *dPriv = smesa->driDrawable; \
47 struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \
48 GLuint pitch = srb->pitch; \
49 char *buf = srb->map; \
54 #define LOCAL_DEPTH_VARS \
55 sisContextPtr smesa = SIS_CONTEXT(ctx); \
56 __DRIdrawablePrivate *dPriv = smesa->driDrawable; \
57 struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \
60 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
62 #define HW_LOCK() do {} while(0);
64 #define HW_UNLOCK() do {} while(0);
67 #define SPANTMP_PIXEL_FMT GL_RGB
68 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
70 #define TAG(x) sis##x##_RGB565
71 #define TAG2(x,y) sis##x##_RGB565##y
76 /* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
77 Was there a reason to do so ? If so that'll won't work with that template... */
78 #define SPANTMP_PIXEL_FMT GL_BGRA
79 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
81 #define TAG(x) sis##x##_ARGB8888
82 #define TAG2(x,y) sis##x##_ARGB8888##y
86 /* 16 bit depthbuffer functions.
88 #define WRITE_DEPTH( _x, _y, d ) \
89 *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d;
91 #define READ_DEPTH( d, _x, _y ) \
92 d = *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch);
94 #define TAG(x) sis##x##_z16
98 /* 32 bit depthbuffer functions.
100 #define WRITE_DEPTH( _x, _y, d ) \
101 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d;
103 #define READ_DEPTH( d, _x, _y ) \
104 d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch);
106 #define TAG(x) sis##x##_z32
107 #include "depthtmp.h"
110 /* 8/24 bit interleaved depth/stencil functions
112 #define WRITE_DEPTH( _x, _y, d ) { \
113 GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch); \
115 tmp |= (d & 0x00ffffff); \
116 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
119 #define READ_DEPTH( d, _x, _y ) { \
120 d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0x00ffffff; \
123 #define TAG(x) sis##x##_z24_s8
124 #include "depthtmp.h"
126 #define WRITE_STENCIL( _x, _y, d ) { \
127 GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depth.pitch); \
130 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
133 #define READ_STENCIL( d, _x, _y ) \
134 d = (*(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0xff000000) >> 24;
136 #define TAG(x) sis##x##_z24_s8
137 #include "stenciltmp.h"
141 void sisSpanRenderStart( GLcontext
*ctx
)
143 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
145 SIS_FIREVERTICES(smesa
);
147 WaitEngIdle( smesa
);
150 void sisSpanRenderFinish( GLcontext
*ctx
)
152 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
154 _swrast_flush( ctx
);
159 sisDDInitSpanFuncs( GLcontext
*ctx
)
161 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
162 swdd
->SpanRenderStart
= sisSpanRenderStart
;
163 swdd
->SpanRenderFinish
= sisSpanRenderFinish
;
169 * Plug in the Get/Put routines for the given driRenderbuffer.
172 sisSetSpanFunctions(struct sis_renderbuffer
*srb
, const GLvisual
*vis
)
174 if (srb
->Base
.InternalFormat
== GL_RGBA
) {
175 if (vis
->redBits
== 5 && vis
->greenBits
== 6 && vis
->blueBits
== 5) {
176 sisInitPointers_RGB565( &srb
->Base
);
179 sisInitPointers_ARGB8888( &srb
->Base
);
182 else if (srb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT16
) {
183 sisInitDepthPointers_z16(&srb
->Base
);
185 else if (srb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT24
) {
186 sisInitDepthPointers_z24_s8(&srb
->Base
);
188 else if (srb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT32
) {
189 sisInitDepthPointers_z32(&srb
->Base
);
191 else if (srb
->Base
.InternalFormat
== GL_STENCIL_INDEX8_EXT
) {
192 sisInitStencilPointers_z24_s8(&srb
->Base
);