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 VALUE_TYPE GLushort
89 #define WRITE_DEPTH( _x, _y, d ) \
90 *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch) = d;
92 #define READ_DEPTH( d, _x, _y ) \
93 d = *(GLushort *)(buf + (_x)*2 + (_y)*srb->pitch);
95 #define TAG(x) sis##x##_z16
99 /* 32 bit depthbuffer functions.
101 #define VALUE_TYPE GLuint
103 #define WRITE_DEPTH( _x, _y, d ) \
104 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = d;
106 #define READ_DEPTH( d, _x, _y ) \
107 d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch);
109 #define TAG(x) sis##x##_z32
110 #include "depthtmp.h"
113 /* 8/24 bit interleaved depth/stencil functions
115 #define VALUE_TYPE GLuint
117 #define WRITE_DEPTH( _x, _y, d ) { \
118 GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch); \
120 tmp |= (d & 0x00ffffff); \
121 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
124 #define READ_DEPTH( d, _x, _y ) { \
125 d = *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0x00ffffff; \
128 #define TAG(x) sis##x##_z24_s8
129 #include "depthtmp.h"
131 #define WRITE_STENCIL( _x, _y, d ) { \
132 GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depth.pitch); \
135 *(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) = tmp; \
138 #define READ_STENCIL( d, _x, _y ) \
139 d = (*(GLuint *)(buf + (_x)*4 + (_y)*srb->pitch) & 0xff000000) >> 24;
141 #define TAG(x) sis##x##_z24_s8
142 #include "stenciltmp.h"
146 void sisSpanRenderStart( GLcontext
*ctx
)
148 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
150 SIS_FIREVERTICES(smesa
);
152 WaitEngIdle( smesa
);
155 void sisSpanRenderFinish( GLcontext
*ctx
)
157 sisContextPtr smesa
= SIS_CONTEXT(ctx
);
159 _swrast_flush( ctx
);
164 sisDDInitSpanFuncs( GLcontext
*ctx
)
166 struct swrast_device_driver
*swdd
= _swrast_GetDeviceDriverReference(ctx
);
167 swdd
->SpanRenderStart
= sisSpanRenderStart
;
168 swdd
->SpanRenderFinish
= sisSpanRenderFinish
;
174 * Plug in the Get/Put routines for the given driRenderbuffer.
177 sisSetSpanFunctions(struct sis_renderbuffer
*srb
, const GLvisual
*vis
)
179 if (srb
->Base
.Format
== MESA_FORMAT_RGB565
) {
180 sisInitPointers_RGB565( &srb
->Base
);
182 else if (srb
->Base
.Format
== MESA_FORMAT_ARGB8888
) {
183 sisInitPointers_ARGB8888( &srb
->Base
);
185 else if (srb
->Base
.Format
== MESA_FORMAT_Z16
) {
186 sisInitDepthPointers_z16(&srb
->Base
);
188 else if (srb
->Base
.Format
== MESA_FORMAT_S8_Z24
) {
189 sisInitDepthPointers_z24_s8(&srb
->Base
);
191 else if (srb
->Base
.Format
== MESA_FORMAT_Z32
) {
192 sisInitDepthPointers_z32(&srb
->Base
);
194 else if (srb
->Base
.Format
== MESA_FORMAT_S8
) {
195 sisInitStencilPointers_z24_s8(&srb
->Base
);