3
* GLX Hardware Device Driver for Sun Creator/Creator3D
4
* Copyright (C) 2000, 2001 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 "ffb_xmesa.h"
29
#include "ffb_context.h"
31
#include "main/imports.h"
32
#include "tnl/t_context.h"
33
#include "swrast_setup/swrast_setup.h"
34
#include "math/m_translate.h"
38
static void ffb_copy_pv_oneside(GLcontext *ctx, GLuint edst, GLuint esrc)
40
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
41
ffb_vertex *dst = &fmesa->verts[edst];
42
ffb_vertex *src = &fmesa->verts[esrc];
45
fprintf(stderr, "ffb_copy_pv_oneside: edst(%d) esrc(%d)\n", edst, esrc);
47
dst->color[0].alpha = src->color[0].alpha;
48
dst->color[0].red = src->color[0].red;
49
dst->color[0].green = src->color[0].green;
50
dst->color[0].blue = src->color[0].blue;
53
static void ffb_copy_pv_twoside(GLcontext *ctx, GLuint edst, GLuint esrc)
55
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
56
ffb_vertex *dst = &fmesa->verts[edst];
57
ffb_vertex *src = &fmesa->verts[esrc];
60
fprintf(stderr, "ffb_copy_pv_twoside: edst(%d) esrc(%d)\n", edst, esrc);
62
dst->color[0].alpha = src->color[0].alpha;
63
dst->color[0].red = src->color[0].red;
64
dst->color[0].green = src->color[0].green;
65
dst->color[0].blue = src->color[0].blue;
66
dst->color[1].alpha = src->color[1].alpha;
67
dst->color[1].red = src->color[1].red;
68
dst->color[1].green = src->color[1].green;
69
dst->color[1].blue = src->color[1].blue;
72
#define FFB_VB_RGBA_BIT 0x01
73
#define FFB_VB_XYZ_BIT 0x02
74
#define FFB_VB_TWOSIDE_BIT 0x04
75
#define FFB_VB_MAX 0x08
77
typedef void (*ffb_emit_func)(GLcontext *, GLuint, GLuint);
81
tnl_interp_func interp;
82
} setup_tab[FFB_VB_MAX];
85
#define IND (FFB_VB_XYZ_BIT)
87
#include "ffb_vbtmp.h"
89
#define IND (FFB_VB_RGBA_BIT)
91
#include "ffb_vbtmp.h"
93
#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)
95
#include "ffb_vbtmp.h"
97
#define IND (FFB_VB_TWOSIDE_BIT)
99
#include "ffb_vbtmp.h"
101
#define IND (FFB_VB_XYZ_BIT | FFB_VB_TWOSIDE_BIT)
102
#define TAG(x) x##_wt
103
#include "ffb_vbtmp.h"
105
#define IND (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
106
#define TAG(x) x##_gt
107
#include "ffb_vbtmp.h"
109
#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
110
#define TAG(x) x##_wgt
111
#include "ffb_vbtmp.h"
113
static void init_setup_tab( void )
125
static void ffbPrintSetupFlags(char *msg, GLuint flags)
127
fprintf(stderr, "%s(%x): %s%s%s\n",
130
(flags & FFB_VB_XYZ_BIT) ? " xyz," : "",
131
(flags & FFB_VB_RGBA_BIT) ? " rgba," : "",
132
(flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : "");
136
static void ffbDDBuildVertices(GLcontext *ctx, GLuint start, GLuint count,
139
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
141
newinputs |= fmesa->setupnewinputs;
142
fmesa->setupnewinputs = 0;
147
if (newinputs & VERT_BIT_POS) {
148
setup_tab[fmesa->setupindex].emit(ctx, start, count);
152
if (newinputs & VERT_BIT_COLOR0)
153
ind |= (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT);
155
ind &= fmesa->setupindex;
158
setup_tab[ind].emit(ctx, start, count);
162
void ffbChooseVertexState( GLcontext *ctx )
164
TNLcontext *tnl = TNL_CONTEXT(ctx);
165
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
166
int ind = FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT;
168
if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
169
ind |= FFB_VB_TWOSIDE_BIT;
172
ffbPrintSetupFlags("ffb: full setup function", ind);
175
fmesa->setupindex = ind;
177
tnl->Driver.Render.BuildVertices = ffbDDBuildVertices;
178
tnl->Driver.Render.Interp = setup_tab[ind].interp;
179
if (ind & FFB_VB_TWOSIDE_BIT)
180
tnl->Driver.Render.CopyPV = ffb_copy_pv_twoside;
182
tnl->Driver.Render.CopyPV = ffb_copy_pv_oneside;
185
void ffbInitVB( GLcontext *ctx )
187
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
188
GLuint size = TNL_CONTEXT(ctx)->vb.Size;
190
fmesa->verts = (ffb_vertex *)ALIGN_MALLOC(size * sizeof(ffb_vertex), 32);
193
static int firsttime = 1;
202
void ffbFreeVB( GLcontext *ctx )
204
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
206
ALIGN_FREE(fmesa->verts);