~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/windows/gldirect/dx7/gld_vb_d3d_render_dx7.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
*
3
 
*                        Mesa 3-D graphics library
4
 
*                        Direct3D Driver Interface
5
 
*
6
 
*  ========================================================================
7
 
*
8
 
*   Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
9
 
*
10
 
*   Permission is hereby granted, free of charge, to any person obtaining a
11
 
*   copy of this software and associated documentation files (the "Software"),
12
 
*   to deal in the Software without restriction, including without limitation
13
 
*   the rights to use, copy, modify, merge, publish, distribute, sublicense,
14
 
*   and/or sell copies of the Software, and to permit persons to whom the
15
 
*   Software is furnished to do so, subject to the following conditions:
16
 
*
17
 
*   The above copyright notice and this permission notice shall be included
18
 
*   in all copies or substantial portions of the Software.
19
 
*
20
 
*   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21
 
*   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
 
*   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23
 
*   SCITECH SOFTWARE INC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24
 
*   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
25
 
*   OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
 
*   SOFTWARE.
27
 
*
28
 
*  ======================================================================
29
 
*
30
 
* Language:     ANSI C
31
 
* Environment:  Windows 9x/2000/XP/XBox (Win32)
32
 
*
33
 
* Description:  GLDirect fastpath pipeline stage
34
 
*
35
 
****************************************************************************/
36
 
 
37
 
//---------------------------------------------------------------------------
38
 
 
39
 
//#include "../GLDirect.h"
40
 
//#include "../gld_log.h"
41
 
//#include "gld_dx8.h"
42
 
 
43
 
#include "dglcontext.h"
44
 
#include "ddlog.h"
45
 
#include "gld_dx7.h"
46
 
 
47
 
//---------------------------------------------------------------------------
48
 
 
49
 
#include "glheader.h"
50
 
#include "context.h"
51
 
#include "macros.h"
52
 
// #include "mem.h"
53
 
#include "mtypes.h"
54
 
//#include "mmath.h"
55
 
 
56
 
#include "math/m_matrix.h"
57
 
#include "math/m_xform.h"
58
 
 
59
 
#include "tnl/t_pipeline.h"
60
 
 
61
 
//---------------------------------------------------------------------------
62
 
/*
63
 
__inline void _gldSetVertexShaderConstants(
64
 
        GLcontext *ctx,
65
 
        GLD_driver_dx8 *gld)
66
 
{
67
 
        D3DXMATRIX mat, matView, matProj;
68
 
        GLfloat         *pM;
69
 
 
70
 
        // Mesa 5: Altered to a Stack
71
 
        //pM = ctx->ModelView.m;
72
 
        pM = ctx->ModelviewMatrixStack.Top->m;
73
 
        matView._11 = pM[0];
74
 
        matView._12 = pM[1];
75
 
        matView._13 = pM[2];
76
 
        matView._14 = pM[3];
77
 
        matView._21 = pM[4];
78
 
        matView._22 = pM[5];
79
 
        matView._23 = pM[6];
80
 
        matView._24 = pM[7];
81
 
        matView._31 = pM[8];
82
 
        matView._32 = pM[9];
83
 
        matView._33 = pM[10];
84
 
        matView._34 = pM[11];
85
 
        matView._41 = pM[12];
86
 
        matView._42 = pM[13];
87
 
        matView._43 = pM[14];
88
 
        matView._44 = pM[15];
89
 
 
90
 
        // Mesa 5: Altered to a Stack
91
 
        //pM = ctx->ProjectionMatrix.m;
92
 
        pM = ctx->ProjectionMatrixStack.Top->m;
93
 
        matProj._11 = pM[0];
94
 
        matProj._12 = pM[1];
95
 
        matProj._13 = pM[2];
96
 
        matProj._14 = pM[3];
97
 
        matProj._21 = pM[4];
98
 
        matProj._22 = pM[5];
99
 
        matProj._23 = pM[6];
100
 
        matProj._24 = pM[7];
101
 
        matProj._31 = pM[8];
102
 
        matProj._32 = pM[9];
103
 
        matProj._33 = pM[10];
104
 
        matProj._34 = pM[11];
105
 
        matProj._41 = pM[12];
106
 
        matProj._42 = pM[13];
107
 
        matProj._43 = pM[14];
108
 
        matProj._44 = pM[15];
109
 
 
110
 
        D3DXMatrixMultiply( &mat, &matView, &matProj );
111
 
        D3DXMatrixTranspose( &mat, &mat );
112
 
 
113
 
        _GLD_DX8_DEV(SetVertexShaderConstant(gld->pDev, 0, &mat, 4));
114
 
}
115
 
*/
116
 
//---------------------------------------------------------------------------
117
 
 
118
 
static GLboolean gld_d3d_render_stage_run(
119
 
        GLcontext *ctx,
120
 
        struct tnl_pipeline_stage *stage)
121
 
{
122
 
        GLD_context                             *gldCtx = GLD_GET_CONTEXT(ctx);
123
 
        GLD_driver_dx7                  *gld    = GLD_GET_DX7_DRIVER(gldCtx);
124
 
 
125
 
        TNLcontext                              *tnl;
126
 
        struct vertex_buffer    *VB;
127
 
        tnl_render_func                         *tab;
128
 
        GLint                                   pass;
129
 
        GLD_pb_dx7                              *gldPB = &gld->PB3d;
130
 
        DWORD                                   dwFlags;
131
 
 
132
 
/*
133
 
        static int count = 0;
134
 
        count++;
135
 
        if (count != 2)
136
 
                return GL_FALSE;
137
 
*/
138
 
        // The "check" function should disable this stage,
139
 
        // but we'll test gld->bUseMesaTnL anyway.
140
 
        if (gld->bUseMesaTnL) {
141
 
                // Do nothing in this stage, but continue pipeline
142
 
                return GL_TRUE;
143
 
        }
144
 
        
145
 
        tnl = TNL_CONTEXT(ctx);
146
 
        VB = &tnl->vb;
147
 
        pass = 0;
148
 
 
149
 
   tnl->Driver.Render.Start( ctx );
150
 
 
151
 
#if 0
152
 
   // For debugging: Useful to see if an app passes colour data in
153
 
   // an unusual format.
154
 
   switch (VB->ColorPtr[0]->Type) {
155
 
   case GL_FLOAT:
156
 
           ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_FLOAT\n");
157
 
           break;
158
 
   case GL_UNSIGNED_BYTE:
159
 
           ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: GL_UNSIGNED_BYTE\n");
160
 
           break;
161
 
   default:
162
 
           ddlogMessage(GLDLOG_SYSTEM, "ColorPtr: *?*\n");
163
 
           break;
164
 
   }
165
 
#endif
166
 
 
167
 
   tnl->Driver.Render.Points            = gld_Points3D_DX7;
168
 
   if (ctx->_TriangleCaps & DD_FLATSHADE) {
169
 
           tnl->Driver.Render.Line              = gld_Line3DFlat_DX7;
170
 
           tnl->Driver.Render.Triangle  = gld_Triangle3DFlat_DX7;
171
 
           tnl->Driver.Render.Quad              = gld_Quad3DFlat_DX7;
172
 
   } else {
173
 
           tnl->Driver.Render.Line              = gld_Line3DSmooth_DX7;
174
 
           tnl->Driver.Render.Triangle  = gld_Triangle3DSmooth_DX7;
175
 
           tnl->Driver.Render.Quad              = gld_Quad3DSmooth_DX7;
176
 
   }
177
 
 
178
 
//      _GLD_DX7_VB(Lock(gldPB->pVB, 0, 0, &gldPB->pPoints, D3DLOCK_DISCARD));
179
 
        dwFlags = DDLOCK_DISCARDCONTENTS | DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY;
180
 
        _GLD_DX7_VB(Lock(gldPB->pVB, dwFlags, &gldPB->pPoints, NULL));
181
 
        gldPB->nPoints = gldPB->nLines = gldPB->nTriangles = 0;
182
 
        // Allocate primitive pointers
183
 
        // gldPB->pPoints is always first
184
 
        gldPB->pLines           = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstLine);
185
 
        gldPB->pTriangles       = gldPB->pPoints + (gldPB->dwStride * gldPB->iFirstTriangle);
186
 
        
187
 
        ASSERT(tnl->Driver.Render.BuildVertices);
188
 
        ASSERT(tnl->Driver.Render.PrimitiveNotify);
189
 
        ASSERT(tnl->Driver.Render.Points);
190
 
        ASSERT(tnl->Driver.Render.Line);
191
 
        ASSERT(tnl->Driver.Render.Triangle);
192
 
        ASSERT(tnl->Driver.Render.Quad);
193
 
        ASSERT(tnl->Driver.Render.ResetLineStipple);
194
 
        ASSERT(tnl->Driver.Render.Interp);
195
 
        ASSERT(tnl->Driver.Render.CopyPV);
196
 
        ASSERT(tnl->Driver.Render.ClippedLine);
197
 
        ASSERT(tnl->Driver.Render.ClippedPolygon);
198
 
        ASSERT(tnl->Driver.Render.Finish);
199
 
 
200
 
        tab = (VB->Elts ? tnl->Driver.Render.PrimTabElts : tnl->Driver.Render.PrimTabVerts);
201
 
        
202
 
        do {
203
 
                GLuint i, length, flags = 0;
204
 
                for (i = 0 ; !(flags & PRIM_END) ; i += length)
205
 
                {
206
 
                        flags = VB->Primitive[i].mode;
207
 
                        length= VB->Primitive[i].count;
208
 
                        ASSERT(length || (flags & PRIM_END));
209
 
                        ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
210
 
                        if (length)
211
 
                                tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
212
 
                }
213
 
        } while (tnl->Driver.Render.Multipass &&
214
 
                tnl->Driver.Render.Multipass( ctx, ++pass ));
215
 
        
216
 
        _GLD_DX7_VB(Unlock(gldPB->pVB));
217
 
 
218
 
//      _GLD_DX7_DEV(SetStreamSource(gld->pDev, 0, gldPB->pVB, gldPB->dwStride));
219
 
 
220
 
        _GLD_DX7_DEV(SetTransform(gld->pDev, D3DTRANSFORMSTATE_PROJECTION, &gld->matProjection));
221
 
        _GLD_DX7_DEV(SetTransform(gld->pDev, D3DTRANSFORMSTATE_WORLD, &gld->matModelView));
222
 
 
223
 
        if (gldPB->nPoints) {
224
 
//              _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_POINTLIST, 0, gldPB->nPoints));
225
 
                _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_POINTLIST, gldPB->pVB, 0, gldPB->nPoints, 0));
226
 
                gldPB->nPoints = 0;
227
 
        }
228
 
 
229
 
        if (gldPB->nLines) {
230
 
//              _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_LINELIST, gldPB->iFirstLine, gldPB->nLines));
231
 
                _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_LINELIST, gldPB->pVB, gldPB->iFirstLine, gldPB->nLines, 0));
232
 
                gldPB->nLines = 0;
233
 
        }
234
 
 
235
 
        if (gldPB->nTriangles) {
236
 
//              _GLD_DX7_DEV(DrawPrimitive(gld->pDev, D3DPT_TRIANGLELIST, gldPB->iFirstTriangle, gldPB->nTriangles));
237
 
                _GLD_DX7_DEV(DrawPrimitiveVB(gld->pDev, D3DPT_TRIANGLELIST, gldPB->pVB, gldPB->iFirstTriangle, gldPB->nTriangles, 0));
238
 
                gldPB->nTriangles = 0;
239
 
        }
240
 
 
241
 
        return GL_FALSE;                /* finished the pipe */
242
 
}
243
 
 
244
 
 
245
 
//---------------------------------------------------------------------------
246
 
 
247
 
const struct tnl_pipeline_stage _gld_d3d_render_stage =
248
 
{
249
 
   "gld_d3d_render_stage",
250
 
   NULL,
251
 
   NULL,
252
 
   NULL,
253
 
   NULL,
254
 
   gld_d3d_render_stage_run                     /* run */
255
 
};
256
 
 
257
 
//---------------------------------------------------------------------------