1
/* -*- mode: c; c-basic-offset: 3 -*- */
3
* Copyright 2000 Gareth Hughes
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 (including the next
14
* paragraph) shall be included in all copies or substantial portions of the
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
* GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
* Gareth Hughes <gareth@valinux.com>
28
* Leif Delgass <ldelgass@retinalburn.net>
29
* Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
32
#include "mach64_context.h"
33
#include "mach64_ioctl.h"
34
#include "mach64_span.h"
36
#include "swrast/swrast.h"
41
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
42
__DRIscreen *sPriv = mmesa->driScreen; \
43
__DRIdrawable *dPriv = mmesa->driDrawable; \
44
driRenderbuffer *drb = (driRenderbuffer *) rb; \
45
GLuint height = dPriv->h; \
49
#define LOCAL_DEPTH_VARS \
50
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
51
__DRIdrawable *dPriv = mmesa->driDrawable; \
52
__DRIscreen *driScreen = mmesa->driScreen; \
53
driRenderbuffer *drb = (driRenderbuffer *) rb; \
54
GLuint height = dPriv->h; \
55
char *buf = (char *)(driScreen->pFB + drb->offset + \
56
(dPriv->x + dPriv->y * drb->pitch) * 2)
58
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
60
#define Y_FLIP( _y ) (height - _y - 1)
64
/* FIXME could/should we use dPriv->numClipRects like the other drivers? */
65
#define HW_CLIPLOOP() \
67
int _nc = mmesa->numClipRects; \
70
int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \
71
int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \
72
int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \
73
int maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY;
75
#define HW_ENDCLIPLOOP() \
83
/* ================================================================
87
/* 16 bit, RGB565 color spanline and pixel functions
89
#define SPANTMP_PIXEL_FMT GL_RGB
90
#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
92
#define TAG(x) mach64##x##_RGB565
93
#define TAG2(x,y) mach64##x##_RGB565##y
94
#define GET_PTR(X,Y) (sPriv->pFB + drb->offset \
95
+ ((dPriv->y + (Y)) * drb->pitch + (dPriv->x + (X))) * drb->cpp)
99
/* 32 bit, ARGB8888 color spanline and pixel functions
101
/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
102
Was there a reason to do so ? If so that'll won't work with that template... */
103
#define SPANTMP_PIXEL_FMT GL_BGRA
104
#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
106
#define TAG(x) mach64##x##_ARGB8888
107
#define TAG2(x,y) mach64##x##_ARGB8888##y
108
#define GET_PTR(X,Y) (sPriv->pFB + drb->offset \
109
+ ((dPriv->y + (Y)) * drb->pitch + (dPriv->x + (X))) * drb->cpp)
110
#include "spantmp2.h"
113
/* ================================================================
117
/* 16 bit depthbuffer functions.
119
#define VALUE_TYPE GLushort
121
#define WRITE_DEPTH( _x, _y, d ) \
122
*(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2) = d;
124
#define READ_DEPTH( d, _x, _y ) \
125
d = *(GLushort *)(buf + ((_x) + (_y) * drb->pitch) * 2);
127
#define TAG(x) mach64##x##_z16
128
#include "depthtmp.h"
131
static void mach64SpanRenderStart( struct gl_context *ctx )
133
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
134
LOCK_HARDWARE( mmesa );
135
FINISH_DMA_LOCKED( mmesa );
138
static void mach64SpanRenderFinish( struct gl_context *ctx )
140
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
141
_swrast_flush( ctx );
142
UNLOCK_HARDWARE( mmesa );
145
void mach64DDInitSpanFuncs( struct gl_context *ctx )
147
struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
148
swdd->SpanRenderStart = mach64SpanRenderStart;
149
swdd->SpanRenderFinish = mach64SpanRenderFinish;
154
* Plug in the Get/Put routines for the given driRenderbuffer.
157
mach64SetSpanFunctions(driRenderbuffer *drb, const struct gl_config *vis)
159
if (drb->Base.Format == MESA_FORMAT_RGB565) {
160
mach64InitPointers_RGB565(&drb->Base);
162
else if (drb->Base.Format == MESA_FORMAT_ARGB8888) {
163
mach64InitPointers_ARGB8888(&drb->Base);
165
else if (drb->Base.Format == MESA_FORMAT_Z16) {
166
mach64InitDepthPointers_z16(&drb->Base);