921a83d274247c7344d66b004a4852d0ac304ace
3 * GLX Hardware Device Driver for Sun Creator/Creator3D
4 * Copyright (C) 2000 David S. Miller
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * David S. Miller <davem@redhat.com>
28 #include "main/mtypes.h"
31 #include "ffb_context.h"
32 #include "ffb_stencil.h"
35 #include "swrast/swrast.h"
39 static void FFBWriteStencilSpan( GLcontext
*ctx
,
40 struct gl_renderbuffer
*rb
,
41 GLuint n
, GLint x
, GLint y
,
42 const void *values
, const GLubyte mask
[] )
44 const GLubyte
*stencil
= (const GLubyte
*) values
;
46 fprintf(stderr
, "FFBWriteStencilSpan: n(%d) x(%d) y(%d)\n",
49 if (ctx
->Depth
.Mask
) {
50 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
51 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
55 if (!fmesa
->hw_locked
)
58 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_OFF
|
59 FFB_FBC_YE_ON
| FFB_FBC_RGBE_OFF
);
60 fmesa
->regs
->ppc
= FFB_PPC_YS_VAR
;
61 FFBWait(fmesa
, fmesa
->regs
);
65 ((char *)fmesa
->sfb32
+
66 ((dPriv
->x
+ x
) << 2) +
67 ((dPriv
->y
+ y
) << 13));
69 for (i
= 0; i
< n
; i
++) {
71 *zptr
= (stencil
[i
] & 0xf) << 28;
76 fmesa
->regs
->fbc
= fmesa
->fbc
;
77 fmesa
->regs
->ppc
= fmesa
->ppc
;
78 fmesa
->ffbScreen
->rp_active
= 1;
79 if (!fmesa
->hw_locked
)
80 UNLOCK_HARDWARE(fmesa
);
84 static void FFBWriteStencilPixels( GLcontext
*ctx
,
85 struct gl_renderbuffer
*rb
,
87 const GLint x
[], const GLint y
[],
88 const void *values
, const GLubyte mask
[] )
90 const GLubyte
*stencil
= (const GLubyte
*) values
;
92 fprintf(stderr
, "FFBWriteStencilPixels: n(%d)\n", (int) n
);
94 if (ctx
->Depth
.Mask
) {
95 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
96 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
100 if (!fmesa
->hw_locked
)
101 LOCK_HARDWARE(fmesa
);
103 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_OFF
|
104 FFB_FBC_YE_ON
| FFB_FBC_RGBE_OFF
);
105 fmesa
->regs
->ppc
= FFB_PPC_YS_VAR
;
106 fmesa
->ffbScreen
->rp_active
= 1;
107 FFBWait(fmesa
, fmesa
->regs
);
109 zbase
= ((char *)fmesa
->sfb32
+
110 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
112 for (i
= 0; i
< n
; i
++) {
113 GLint y1
= (dPriv
->h
- y
[i
]);
118 (zbase
+ (x1
<< 2) + (y1
<< 13));
120 *zptr
= (stencil
[i
] & 0xf) << 28;
124 fmesa
->regs
->fbc
= fmesa
->fbc
;
125 fmesa
->regs
->ppc
= fmesa
->ppc
;
126 fmesa
->ffbScreen
->rp_active
= 1;
127 if (!fmesa
->hw_locked
)
128 UNLOCK_HARDWARE(fmesa
);
132 static void FFBReadStencilSpan( GLcontext
*ctx
,
133 struct gl_renderbuffer
*rb
,
134 GLuint n
, GLint x
, GLint y
,
137 GLubyte
*stencil
= (GLubyte
*) values
;
138 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
139 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
144 fprintf(stderr
, "FFBReadStencilSpan: n(%d) x(%d) y(%d)\n",
147 if (!fmesa
->hw_locked
)
148 LOCK_HARDWARE(fmesa
);
150 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
151 fmesa
->ffbScreen
->rp_active
= 1;
152 FFBWait(fmesa
, fmesa
->regs
);
156 ((char *)fmesa
->sfb32
+
157 ((dPriv
->x
+ x
) << 2) +
158 ((dPriv
->y
+ y
) << 13));
160 for (i
= 0; i
< n
; i
++) {
161 stencil
[i
] = (*zptr
>> 28) & 0xf;
166 fmesa
->regs
->fbc
= fmesa
->fbc
;
167 fmesa
->ffbScreen
->rp_active
= 1;
168 if (!fmesa
->hw_locked
)
169 UNLOCK_HARDWARE(fmesa
);
172 static void FFBReadStencilPixels( GLcontext
*ctx
,
173 struct gl_renderbuffer
*rb
,
174 GLuint n
, const GLint x
[], const GLint y
[],
177 GLubyte
*stencil
= (GLubyte
*) values
;
178 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
179 __DRIdrawablePrivate
*dPriv
= fmesa
->driDrawable
;
184 fprintf(stderr
, "FFBReadStencilPixels: n(%d)\n", (int) n
);
186 if (!fmesa
->hw_locked
)
187 LOCK_HARDWARE(fmesa
);
189 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
190 fmesa
->ffbScreen
->rp_active
= 1;
191 FFBWait(fmesa
, fmesa
->regs
);
193 zbase
= ((char *)fmesa
->sfb32
+
194 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
196 for (i
= 0; i
< n
; i
++) {
197 GLint y1
= (dPriv
->h
- y
[i
]);
202 (zbase
+ (x1
<< 2) + (y1
<< 13));
203 stencil
[i
] = (*zptr
>> 28) & 0xf;
207 fmesa
->regs
->fbc
= fmesa
->fbc
;
208 fmesa
->ffbScreen
->rp_active
= 1;
209 if (!fmesa
->hw_locked
)
210 UNLOCK_HARDWARE(fmesa
);
214 * Plug in the Get/Put routines for the given driRenderbuffer.
217 ffbSetStencilFunctions(driRenderbuffer
*drb
, const GLvisual
*vis
)
219 assert(drb
->Base
.InternalFormat
== GL_STENCIL_INDEX8_EXT
);
220 drb
->Base
.GetRow
= FFBReadStencilSpan
;
221 drb
->Base
.GetValues
= FFBReadStencilPixels
;
222 drb
->Base
.PutRow
= FFBWriteStencilSpan
;
223 /*drb->Base.PutMonoRow = FFBWriteMonoStencilSpan;*/
224 drb
->Base
.PutValues
= FFBWriteStencilPixels
;
225 drb
->Base
.PutMonoValues
= NULL
;