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 **************************************************************************/
30 * Sung-Ching Lin <sclin@sis.com.tw>
31 * Eric Anholt <anholt@FreeBSD.org>
34 #include "sis_context.h"
39 #include "swrast/swrast.h"
44 sisContextPtr smesa = SIS_CONTEXT(ctx); \
45 __DRIdrawablePrivate *dPriv = smesa->driDrawable; \
46 struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \
47 GLuint pitch = srb->pitch; \
48 char *buf = srb->map; \
53 #define LOCAL_DEPTH_VARS \
54 sisContextPtr smesa = SIS_CONTEXT(ctx); \
55 __DRIdrawablePrivate *dPriv = smesa->driDrawable; \
56 struct sis_renderbuffer *srb = (struct sis_renderbuffer *) rb; \
59 #define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
61 #define HW_LOCK() do {} while(0);
63 #define HW_UNLOCK() do {} while(0);
66 #define SPANTMP_PIXEL_FMT GL_RGB
67 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
69 #define TAG(x) sis##x##_RGB565
70 #define TAG2(x,y) sis##x##_RGB565##y
75 /* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
76 Was there a reason to do so ? If so that'll won't work with that template... */
77 #define SPANTMP_PIXEL_FMT GL_BGRA
78 #define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
80 #define TAG(x) sis##x##_ARGB8888
81 #define TAG2(x,y) sis##x##_ARGB8888##y
85 /* 16 bit depthbuffer functions.
87 #define WRITE_DEPTH( _x, _y, d ) \
88 *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d;
90 #define READ_DEPTH( d, _x, _y ) \
91 d = *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch);
93 #define TAG(x) sis##x##_z16
97 /* 32 bit depthbuffer functions.
99 #define WRITE_DEPTH( _x, _y, d ) \
100 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d;
102 #define READ_DEPTH( d, _x, _y ) \
103 d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch);
105 #define TAG(x) sis##x##_z32
106 #include "depthtmp.h"
109 /* 8/24 bit interleaved depth/stencil functions
111 #define WRITE_DEPTH( _x, _y, d ) { \
112 GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch); \
114 tmp |= (d & 0x00ffffff); \
115 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
118 #define READ_DEPTH( d, _x, _y ) { \
119 d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0x00ffffff; \
122 #define TAG(x) sis##x##_z24_s8
123 #include "depthtmp.h"
125 #define WRITE_STENCIL( _x, _y, d ) { \
126 GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depth.pitch); \
129 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
132 #define READ_STENCIL( d, _x, _y ) \
133 d = (*(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0xff000000) >> 24;
135 #define TAG(x) sis##x##_z24_s8
136 #include "stenciltmp.h"
140 void sisSpanRenderStart( GLcontext
*ctx
)
142 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
144 SIS_FIREVERTICES(smesa
);
146 WaitEngIdle( smesa
);
149 void sisSpanRenderFinish( GLcontext
*ctx
)
151 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
153 _swrast_flush( ctx
);
158 sisDDInitSpanFuncs( GLcontext
*ctx
)
160 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
161 swdd
->SpanRenderStart
= sisSpanRenderStart
;
162 swdd
->SpanRenderFinish
= sisSpanRenderFinish
;
168 * Plug in the Get/Put routines for the given driRenderbuffer.
171 sisSetSpanFunctions(struct sis_renderbuffer
*srb
, const GLvisual
*vis
)
173 if (srb
->Base
.InternalFormat
== GL_RGBA
) {
174 if (vis
->redBits
== 5 && vis
->greenBits
== 6 && vis
->blueBits
== 5) {
175 sisInitPointers_RGB565( &srb
->Base
);
178 sisInitPointers_ARGB8888( &srb
->Base
);
181 else if (srb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT16
) {
182 sisInitDepthPointers_z16(&srb
->Base
);
184 else if (srb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT24
) {
185 sisInitDepthPointers_z24_s8(&srb
->Base
);
187 else if (srb
->Base
.InternalFormat
== GL_DEPTH_COMPONENT32
) {
188 sisInitDepthPointers_z32(&srb
->Base
);
190 else if (srb
->Base
.InternalFormat
== GL_STENCIL_INDEX8_EXT
) {
191 sisInitStencilPointers_z24_s8(&srb
->Base
);