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"
37 static void FFBWriteStencilSpan( GLcontext
*ctx
,
38 struct gl_renderbuffer
*rb
,
39 GLuint n
, GLint x
, GLint y
,
40 const void *values
, const GLubyte mask
[] )
42 const GLubyte
*stencil
= (const GLubyte
*) values
;
44 fprintf(stderr
, "FFBWriteStencilSpan: n(%d) x(%d) y(%d)\n",
47 if (ctx
->Depth
.Mask
) {
48 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
49 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
53 if (!fmesa
->hw_locked
)
56 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_OFF
|
57 FFB_FBC_YE_ON
| FFB_FBC_RGBE_OFF
);
58 fmesa
->regs
->ppc
= FFB_PPC_YS_VAR
;
59 FFBWait(fmesa
, fmesa
->regs
);
63 ((char *)fmesa
->sfb32
+
64 ((dPriv
->x
+ x
) << 2) +
65 ((dPriv
->y
+ y
) << 13));
67 for (i
= 0; i
< n
; i
++) {
69 *zptr
= (stencil
[i
] & 0xf) << 28;
74 fmesa
->regs
->fbc
= fmesa
->fbc
;
75 fmesa
->regs
->ppc
= fmesa
->ppc
;
76 fmesa
->ffbScreen
->rp_active
= 1;
77 if (!fmesa
->hw_locked
)
78 UNLOCK_HARDWARE(fmesa
);
82 static void FFBWriteStencilPixels( GLcontext
*ctx
,
83 struct gl_renderbuffer
*rb
,
85 const GLint x
[], const GLint y
[],
86 const void *values
, const GLubyte mask
[] )
88 const GLubyte
*stencil
= (const GLubyte
*) values
;
90 fprintf(stderr
, "FFBWriteStencilPixels: n(%d)\n", (int) n
);
92 if (ctx
->Depth
.Mask
) {
93 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
94 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
98 if (!fmesa
->hw_locked
)
101 fmesa
->regs
->fbc
= (FFB_FBC_WB_C
| FFB_FBC_ZE_OFF
|
102 FFB_FBC_YE_ON
| FFB_FBC_RGBE_OFF
);
103 fmesa
->regs
->ppc
= FFB_PPC_YS_VAR
;
104 fmesa
->ffbScreen
->rp_active
= 1;
105 FFBWait(fmesa
, fmesa
->regs
);
107 zbase
= ((char *)fmesa
->sfb32
+
108 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
110 for (i
= 0; i
< n
; i
++) {
111 GLint y1
= (dPriv
->h
- y
[i
]);
116 (zbase
+ (x1
<< 2) + (y1
<< 13));
118 *zptr
= (stencil
[i
] & 0xf) << 28;
122 fmesa
->regs
->fbc
= fmesa
->fbc
;
123 fmesa
->regs
->ppc
= fmesa
->ppc
;
124 fmesa
->ffbScreen
->rp_active
= 1;
125 if (!fmesa
->hw_locked
)
126 UNLOCK_HARDWARE(fmesa
);
130 static void FFBReadStencilSpan( GLcontext
*ctx
,
131 struct gl_renderbuffer
*rb
,
132 GLuint n
, GLint x
, GLint y
,
135 GLubyte
*stencil
= (GLubyte
*) values
;
136 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
137 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
142 fprintf(stderr
, "FFBReadStencilSpan: n(%d) x(%d) y(%d)\n",
145 if (!fmesa
->hw_locked
)
146 LOCK_HARDWARE(fmesa
);
148 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
149 fmesa
->ffbScreen
->rp_active
= 1;
150 FFBWait(fmesa
, fmesa
->regs
);
154 ((char *)fmesa
->sfb32
+
155 ((dPriv
->x
+ x
) << 2) +
156 ((dPriv
->y
+ y
) << 13));
158 for (i
= 0; i
< n
; i
++) {
159 stencil
[i
] = (*zptr
>> 28) & 0xf;
164 fmesa
->regs
->fbc
= fmesa
->fbc
;
165 fmesa
->ffbScreen
->rp_active
= 1;
166 if (!fmesa
->hw_locked
)
167 UNLOCK_HARDWARE(fmesa
);
170 static void FFBReadStencilPixels( GLcontext
*ctx
,
171 struct gl_renderbuffer
*rb
,
172 GLuint n
, const GLint x
[], const GLint y
[],
175 GLubyte
*stencil
= (GLubyte
*) values
;
176 ffbContextPtr fmesa
= FFB_CONTEXT(ctx
);
177 __DRIdrawable
*dPriv
= fmesa
->driDrawable
;
182 fprintf(stderr
, "FFBReadStencilPixels: n(%d)\n", (int) n
);
184 if (!fmesa
->hw_locked
)
185 LOCK_HARDWARE(fmesa
);
187 fmesa
->regs
->fbc
= FFB_FBC_RB_C
;
188 fmesa
->ffbScreen
->rp_active
= 1;
189 FFBWait(fmesa
, fmesa
->regs
);
191 zbase
= ((char *)fmesa
->sfb32
+
192 (dPriv
->x
<< 2) + (dPriv
->y
<< 13));
194 for (i
= 0; i
< n
; i
++) {
195 GLint y1
= (dPriv
->h
- y
[i
]);
200 (zbase
+ (x1
<< 2) + (y1
<< 13));
201 stencil
[i
] = (*zptr
>> 28) & 0xf;
205 fmesa
->regs
->fbc
= fmesa
->fbc
;
206 fmesa
->ffbScreen
->rp_active
= 1;
207 if (!fmesa
->hw_locked
)
208 UNLOCK_HARDWARE(fmesa
);
212 * Plug in the Get/Put routines for the given driRenderbuffer.
215 ffbSetStencilFunctions(driRenderbuffer
*drb
, const GLvisual
*vis
)
217 assert(drb
->Base
.InternalFormat
== GL_STENCIL_INDEX8_EXT
);
218 drb
->Base
.GetRow
= FFBReadStencilSpan
;
219 drb
->Base
.GetValues
= FFBReadStencilPixels
;
220 drb
->Base
.PutRow
= FFBWriteStencilSpan
;
221 /*drb->Base.PutMonoRow = FFBWriteMonoStencilSpan;*/
222 drb
->Base
.PutValues
= FFBWriteStencilPixels
;
223 drb
->Base
.PutMonoValues
= NULL
;