2 * Direct3D wine internal private include file
4 * Copyright 2002-2003 The wine-d3d team
5 * Copyright 2002-2003 Raphael Junqueira
6 * Copyright 2004 Jason Edmeades
7 * Copyright 2005 Oliver Stieber
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifndef __WINE_WINED3D_PRIVATE_H
25 #define __WINE_WINED3D_PRIVATE_H
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
37 #include "wine/debug.h"
38 #include "wine/unicode.h"
41 #include "d3d9types.h"
42 #include "wine/wined3d_interface.h"
43 #include "wine/wined3d_gl.h"
46 #define MAX_PALETTES 256
47 #define MAX_STREAMS 16
48 #define MAX_TEXTURES 8
49 #define MAX_SAMPLERS 16
50 #define MAX_ACTIVE_LIGHTS 8
51 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
52 #define MAX_LEVELS 256
54 #define MAX_VSHADER_CONSTANTS 96
56 /* Used for CreateStateBlock */
57 #define NUM_SAVEDPIXELSTATES_R 35
58 #define NUM_SAVEDPIXELSTATES_T 18
59 #define NUM_SAVEDPIXELSTATES_S 12
60 #define NUM_SAVEDVERTEXSTATES_R 31
61 #define NUM_SAVEDVERTEXSTATES_T 2
62 #define NUM_SAVEDVERTEXSTATES_S 1
64 extern const DWORD SavedPixelStates_R
[NUM_SAVEDPIXELSTATES_R
];
65 extern const DWORD SavedPixelStates_T
[NUM_SAVEDPIXELSTATES_T
];
66 extern const DWORD SavedPixelStates_S
[NUM_SAVEDPIXELSTATES_S
];
67 extern const DWORD SavedVertexStates_R
[NUM_SAVEDVERTEXSTATES_R
];
68 extern const DWORD SavedVertexStates_T
[NUM_SAVEDVERTEXSTATES_T
];
69 extern const DWORD SavedVertexStates_S
[NUM_SAVEDVERTEXSTATES_S
];
71 typedef enum _WINELOOKUP
{
72 WINELOOKUP_WARPPARAM
= 0,
73 WINELOOKUP_MAGFILTER
= 1,
77 extern int minLookup
[MAX_LOOKUPS
];
78 extern int maxLookup
[MAX_LOOKUPS
];
79 extern DWORD
*stateLookup
[MAX_LOOKUPS
];
81 extern DWORD minMipLookup
[D3DTEXF_ANISOTROPIC
+ 1][D3DTEXF_LINEAR
+ 1];
83 /* NOTE: Make sure these are in the correct numerical order. (see /include/d3d9types.h typedef enum _D3DDECLTYPE) */
84 UINT
static const glTypeLookup
[D3DDECLTYPE_UNUSED
][5] = {
85 {D3DDECLTYPE_FLOAT1
, 1, GL_FLOAT
, GL_FALSE
,sizeof(float)},
86 {D3DDECLTYPE_FLOAT2
, 2, GL_FLOAT
, GL_FALSE
,sizeof(float)},
87 {D3DDECLTYPE_FLOAT3
, 3, GL_FLOAT
, GL_FALSE
,sizeof(float)},
88 {D3DDECLTYPE_FLOAT4
, 4, GL_FLOAT
, GL_FALSE
,sizeof(float)},
89 {D3DDECLTYPE_D3DCOLOR
, 4, GL_UNSIGNED_BYTE
, GL_TRUE
,sizeof(BYTE
)},
90 {D3DDECLTYPE_UBYTE4
, 4, GL_UNSIGNED_BYTE
, GL_FALSE
,sizeof(BYTE
)},
91 {D3DDECLTYPE_SHORT2
, 2, GL_SHORT
, GL_FALSE
,sizeof(short int)},
92 {D3DDECLTYPE_SHORT4
, 4, GL_SHORT
, GL_FALSE
,sizeof(short int)},
93 {D3DDECLTYPE_UBYTE4N
, 4, GL_UNSIGNED_BYTE
, GL_FALSE
,sizeof(BYTE
)},
94 {D3DDECLTYPE_SHORT2N
, 2, GL_SHORT
, GL_FALSE
,sizeof(short int)},
95 {D3DDECLTYPE_SHORT4N
, 4, GL_SHORT
, GL_FALSE
,sizeof(short int)},
96 {D3DDECLTYPE_USHORT2N
, 2, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
97 {D3DDECLTYPE_USHORT4N
, 4, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
98 {D3DDECLTYPE_UDEC3
, 3, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
99 {D3DDECLTYPE_DEC3N
, 3, GL_SHORT
, GL_FALSE
,sizeof(short int)},
100 {D3DDECLTYPE_FLOAT16_2
, 2, GL_FLOAT
, GL_FALSE
,sizeof(short int)},
101 {D3DDECLTYPE_FLOAT16_4
, 4, GL_FLOAT
, GL_FALSE
,sizeof(short int)}};
103 #define WINED3D_ATR_TYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType][0]
104 #define WINED3D_ATR_SIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType][1]
105 #define WINED3D_ATR_GLTYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType][2]
106 #define WINED3D_ATR_NORMALIZED(_attribute) glTypeLookup[sd->u.s._attribute.dwType][3]
107 #define WINED3D_ATR_TYPESIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType][4]
122 typedef struct wined3d_settings_s
{
123 /* vertex and pixel shader modes */
127 } wined3d_settings_t
;
129 extern wined3d_settings_t wined3d_settings
;
133 extern void (*wine_tsx11_lock_ptr
)(void);
134 extern void (*wine_tsx11_unlock_ptr
)(void);
136 /* As GLX relies on X, this is needed */
140 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
141 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
143 #define ENTER_GL() wine_tsx11_lock_ptr()
144 #define LEAVE_GL() wine_tsx11_unlock_ptr()
147 /*****************************************************************************
151 /* GL related defines */
152 /* ------------------ */
153 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
154 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
155 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
156 #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
158 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
159 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
160 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
161 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
163 #define D3DCOLORTOGLFLOAT4(dw, vec) \
164 (vec)[0] = D3DCOLOR_R(dw); \
165 (vec)[1] = D3DCOLOR_G(dw); \
166 (vec)[2] = D3DCOLOR_B(dw); \
167 (vec)[3] = D3DCOLOR_A(dw);
169 /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
170 #if defined(GL_VERSION_1_3)
171 #define GLACTIVETEXTURE(textureNo) \
172 glActiveTexture(GL_TEXTURE0 + textureNo); \
173 checkGLcall("glActiveTexture");
174 #define GLCLIENTACTIVETEXTURE(textureNo) \
175 glClientActiveTexture(GL_TEXTURE0 + textureNo);
176 #define GLMULTITEXCOORD1F(a,b) \
177 glMultiTexCoord1f(GL_TEXTURE0 + a, b);
178 #define GLMULTITEXCOORD2F(a,b,c) \
179 glMultiTexCoord2f(GL_TEXTURE0 + a, b, c);
180 #define GLMULTITEXCOORD3F(a,b,c,d) \
181 glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d);
182 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
183 glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e);
184 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP
186 #define GLACTIVETEXTURE(textureNo) \
187 glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \
188 checkGLcall("glActiveTextureARB");
189 #define GLCLIENTACTIVETEXTURE(textureNo) \
190 glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
191 #define GLMULTITEXCOORD1F(a,b) \
192 glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b);
193 #define GLMULTITEXCOORD2F(a,b,c) \
194 glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c);
195 #define GLMULTITEXCOORD3F(a,b,c,d) \
196 glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d);
197 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
198 glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e);
199 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
202 /* DirectX Device Limits */
203 /* --------------------- */
204 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
206 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
207 See MaxStreams in MSDN under GetDeviceCaps */
208 /* Maximum number of constants provided to the shaders */
209 #define HIGHEST_TRANSFORMSTATE 512
210 /* Highest value in D3DTRANSFORMSTATETYPE */
211 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
213 #define MAX_PALETTES 256
215 /* Checking of API calls */
216 /* --------------------- */
217 #define checkGLcall(A) \
219 GLint err = glGetError(); \
220 if (err != GL_NO_ERROR) { \
221 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
223 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
227 /* Trace routines / diagnostics */
228 /* ---------------------------- */
230 /* Dump out a matrix and copy it */
231 #define conv_mat(mat,gl_mat) \
233 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
234 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
235 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
236 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
237 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
240 /* Macro to dump out the current state of the light chain */
241 #define DUMP_LIGHT_CHAIN() \
243 PLIGHTINFOEL *el = This->stateBlock->lights;\
245 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
250 /* Trace vector and strided data information */
251 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
252 #define TRACE_STRIDED(sd,name) TRACE( #name "=(data:%p, stride:%ld, type:%ld)\n", sd->u.s.name.lpData, sd->u.s.name.dwStride, sd->u.s.name.dwType);
254 /* Defines used for optimizations */
256 /* Only reapply what is necessary */
257 #define REAPPLY_ALPHAOP 0x0001
258 #define REAPPLY_ALL 0xFFFF
260 /* Advance declaration of structures to satisfy compiler */
261 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl
;
262 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl
;
266 /* TODO: Move some of this to the device */
267 long globalChangeGlRam(long glram
);
269 /* Memory and object tracking */
271 /*Structure for holding information on all direct3d objects
272 useful for making sure tracking is ok and when release is called on a device!
273 and probably quite handy for debugging and dumping states out
275 typedef struct WineD3DGlobalStatistics
{
276 int glsurfaceram
; /* The aproximate amount of glTexture memory allocated for textures */
277 } WineD3DGlobalStatistics
;
279 extern WineD3DGlobalStatistics
* wineD3DGlobalStatistics
;
281 /* Global variables */
282 extern const float identity
[16];
284 /*****************************************************************************
285 * Compilable extra diagnostics
288 /* Trace information per-vertex: (extremely high amount of trace) */
289 #if 0 /* NOTE: Must be 0 in cvs */
290 # define VTRACE(A) TRACE A
295 /* Checking of per-vertex related GL calls */
296 #define vcheckGLcall(A) \
298 GLint err = glGetError(); \
299 if (err != GL_NO_ERROR) { \
300 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", err, A, __FILE__, __LINE__); \
302 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
306 /* TODO: Confirm each of these works when wined3d move completed */
307 #if 0 /* NOTE: Must be 0 in cvs */
308 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
309 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
310 is enabled, and if it doesn't exists it is disabled. */
311 # define FRAME_DEBUGGING
312 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
313 the file is deleted */
314 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
315 # define SINGLE_FRAME_DEBUGGING
317 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
318 It can only be enabled when FRAME_DEBUGGING is also enabled
319 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
321 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
322 # define SHOW_FRAME_MAKEUP 1
324 /* The following, when enabled, lets you see the makeup of the all the textures used during each
325 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
326 The contents of the textures assigned to each stage are written into
327 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
328 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
329 # define SHOW_TEXTURE_MAKEUP 0
332 extern BOOL isDumpingFrames
;
333 extern LONG primCounter
;
336 /*****************************************************************************
340 /* Routine common to the draw primitive and draw indexed primitive routines */
341 void drawPrimitive(IWineD3DDevice
*iface
,
345 long StartVertexIndex
,
346 UINT numberOfVertices
,
352 /*****************************************************************************
353 * Structures required to draw primitives
356 typedef struct Direct3DStridedData
{
357 BYTE
*lpData
; /* Pointer to start of data */
358 DWORD dwStride
; /* Stride between occurances of this data */
359 DWORD dwType
; /* Type (as in D3DVSDT_TYPE) */
360 } Direct3DStridedData
;
362 typedef struct Direct3DVertexStridedData
{
365 Direct3DStridedData position
;
366 Direct3DStridedData blendWeights
;
367 Direct3DStridedData blendMatrixIndices
;
368 Direct3DStridedData normal
;
369 Direct3DStridedData pSize
;
370 Direct3DStridedData diffuse
;
371 Direct3DStridedData specular
;
372 Direct3DStridedData texCoords
[MAX_TEXTURES
];
373 Direct3DStridedData position2
; /* tween data */
374 Direct3DStridedData normal2
; /* tween data */
375 Direct3DStridedData tangent
;
376 Direct3DStridedData binormal
;
377 Direct3DStridedData tessFactor
;
378 Direct3DStridedData fog
;
379 Direct3DStridedData depth
;
380 Direct3DStridedData sample
;
382 Direct3DStridedData input
[16]; /* Indexed by constants in D3DVSDE_REGISTER */
384 } Direct3DVertexStridedData
;
386 /*****************************************************************************
387 * Internal representation of a light
389 typedef struct PLIGHTINFOEL PLIGHTINFOEL
;
390 struct PLIGHTINFOEL
{
391 WINED3DLIGHT OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
398 /* Converted parms to speed up swapping lights */
408 /*****************************************************************************
409 * IWineD3D implementation structure
411 typedef struct IWineD3DImpl
413 /* IUnknown fields */
414 const IWineD3DVtbl
*lpVtbl
;
415 LONG ref
; /* Note: Ref counting not required */
417 /* WineD3D Information */
423 WineD3D_GL_Info gl_info
;
426 extern const IWineD3DVtbl IWineD3D_Vtbl
;
428 typedef struct SwapChainList
{
429 IWineD3DSwapChain
*swapchain
;
430 struct SwapChainList
*next
;
433 /** Hacked out start of a context manager!! **/
434 typedef struct glContext
{
441 IWineD3DSurface
*pSurface
;
442 #if 0 /* TODO: someway to represent the state of the context */
443 IWineD3DStateBlock
*pStateBlock
;
445 /* a few other things like format */
448 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
449 (since it will break quite a few things until contexts are managed properly!) */
450 extern BOOL pbuffer_support
;
451 /* allocate one pbuffer per surface */
452 extern BOOL pbuffer_per_surface
;
454 /* Maximum number of contexts/pbuffers to keep in cache,
455 set to 100 because ATI's drivers don't support deleting pBuffers properly
456 this needs to be migrated to a list and some option availalbe for controle the cache size.
458 #define CONTEXT_CACHE 100
460 typedef struct ResourceList
{
461 IWineD3DResource
*resource
;
462 struct ResourceList
*next
;
465 /*****************************************************************************
466 * IWineD3DDevice implementation structure
468 typedef struct IWineD3DDeviceImpl
470 /* IUnknown fields */
471 const IWineD3DDeviceVtbl
*lpVtbl
;
472 LONG ref
; /* Note: Ref counting not required */
474 /* WineD3D Information */
478 /* X and GL Information */
479 GLint maxConcurrentLights
;
482 BOOL modelview_valid
;
484 BOOL view_ident
; /* true iff view matrix is identity */
485 BOOL last_was_rhw
; /* true iff last draw_primitive was in xyzrhw mode */
486 GLenum tracking_parm
; /* Which source is tracking current colour */
487 LONG tracking_color
; /* used iff GL_COLOR_MATERIAL was enabled */
488 #define DISABLED_TRACKING 0 /* Disabled */
489 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
490 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
491 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
496 BOOL texture_shader_active
; /* TODO: Confirm use is correct */
498 /* State block related */
499 BOOL isRecordingState
;
500 IWineD3DStateBlockImpl
*stateBlock
;
501 IWineD3DStateBlockImpl
*updateStateBlock
;
503 /* Internal use fields */
504 D3DDEVICE_CREATION_PARAMETERS createParms
;
508 SwapChainList
*swapchains
;
510 ResourceList
*resources
; /* a linked list to track resources created by the device */
512 /* Render Target Support */
513 IWineD3DSurface
*depthStencilBuffer
;
515 IWineD3DSurface
*renderTarget
;
516 IWineD3DSurface
*stencilBufferTarget
;
518 /* palettes texture management */
519 PALETTEENTRY palettes
[MAX_PALETTES
][256];
522 /* For rendering to a texture using glCopyTexImage */
523 BOOL renderUpsideDown
;
525 /* Cursor management */
532 /* Textures for when no other textures are mapped */
533 UINT dummyTextureName
[MAX_TEXTURES
];
535 /* Debug stream management */
538 /* Screen buffer resources */
539 glContext contextCache
[CONTEXT_CACHE
];
541 /* A flag to check if endscene has been called before changing the render tartet */
543 } IWineD3DDeviceImpl
;
545 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl
;
547 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
548 * anybody uses it for much so a good implementation is optional. */
549 typedef struct PrivateData
551 struct PrivateData
* next
;
554 DWORD flags
; /* DDSPD_* */
555 DWORD uniqueness_value
;
566 /*****************************************************************************
567 * IWineD3DResource implementation structure
569 typedef struct IWineD3DResourceClass
571 /* IUnknown fields */
572 LONG ref
; /* Note: Ref counting not required */
574 /* WineD3DResource Information */
576 D3DRESOURCETYPE resourceType
;
577 IWineD3DDeviceImpl
*wineD3DDevice
;
581 WINED3DFORMAT format
;
582 BYTE
*allocatedMemory
;
583 PrivateData
*privateData
;
585 } IWineD3DResourceClass
;
587 typedef struct IWineD3DResourceImpl
589 /* IUnknown & WineD3DResource Information */
590 const IWineD3DResourceVtbl
*lpVtbl
;
591 IWineD3DResourceClass resource
;
592 } IWineD3DResourceImpl
;
595 /*****************************************************************************
596 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
598 typedef struct IWineD3DVertexBufferImpl
600 /* IUnknown & WineD3DResource Information */
601 const IWineD3DVertexBufferVtbl
*lpVtbl
;
602 IWineD3DResourceClass resource
;
604 /* WineD3DVertexBuffer specifics */
607 } IWineD3DVertexBufferImpl
;
609 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl
;
612 /*****************************************************************************
613 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
615 typedef struct IWineD3DIndexBufferImpl
617 /* IUnknown & WineD3DResource Information */
618 const IWineD3DIndexBufferVtbl
*lpVtbl
;
619 IWineD3DResourceClass resource
;
621 /* WineD3DVertexBuffer specifics */
622 } IWineD3DIndexBufferImpl
;
624 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl
;
626 /*****************************************************************************
627 * IWineD3DBaseTexture D3D- > openGL state map lookups
629 #define WINED3DFUNC_NOTSUPPORTED -2
630 #define WINED3DFUNC_UNIMPLEMENTED -1
632 typedef enum winetexturestates
{
633 WINED3DTEXSTA_ADDRESSU
= 0,
634 WINED3DTEXSTA_ADDRESSV
= 1,
635 WINED3DTEXSTA_ADDRESSW
= 2,
636 WINED3DTEXSTA_BORDERCOLOR
= 3,
637 WINED3DTEXSTA_MAGFILTER
= 4,
638 WINED3DTEXSTA_MINFILTER
= 5,
639 WINED3DTEXSTA_MIPFILTER
= 6,
640 WINED3DTEXSTA_MAXMIPLEVEL
= 7,
641 WINED3DTEXSTA_MAXANISOTROPY
= 8,
642 WINED3DTEXSTA_SRGBTEXTURE
= 9,
643 WINED3DTEXSTA_ELEMENTINDEX
= 10,
644 WINED3DTEXSTA_DMAPOFFSET
= 11,
645 WINED3DTEXSTA_TSSADDRESSW
= 12,
646 MAX_WINETEXTURESTATES
= 13,
649 typedef struct Wined3dTextureStateMap
{
652 } Wined3dTextureStateMap
;
654 /*****************************************************************************
655 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
657 typedef struct IWineD3DBaseTextureClass
665 D3DTEXTUREFILTERTYPE filterType
;
666 DWORD states
[MAX_WINETEXTURESTATES
];
668 } IWineD3DBaseTextureClass
;
670 typedef struct IWineD3DBaseTextureImpl
672 /* IUnknown & WineD3DResource Information */
673 const IWineD3DBaseTextureVtbl
*lpVtbl
;
674 IWineD3DResourceClass resource
;
675 IWineD3DBaseTextureClass baseTexture
;
677 } IWineD3DBaseTextureImpl
;
679 /*****************************************************************************
680 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
682 typedef struct IWineD3DTextureImpl
684 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
685 const IWineD3DTextureVtbl
*lpVtbl
;
686 IWineD3DResourceClass resource
;
687 IWineD3DBaseTextureClass baseTexture
;
689 /* IWineD3DTexture */
690 IWineD3DSurface
*surfaces
[MAX_LEVELS
];
694 float pow2scalingFactorX
;
695 float pow2scalingFactorY
;
697 } IWineD3DTextureImpl
;
699 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl
;
701 /*****************************************************************************
702 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
704 typedef struct IWineD3DCubeTextureImpl
706 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
707 const IWineD3DCubeTextureVtbl
*lpVtbl
;
708 IWineD3DResourceClass resource
;
709 IWineD3DBaseTextureClass baseTexture
;
711 /* IWineD3DCubeTexture */
712 IWineD3DSurface
*surfaces
[6][MAX_LEVELS
];
715 float pow2scalingFactor
;
717 } IWineD3DCubeTextureImpl
;
719 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl
;
721 /*****************************************************************************
722 * IWineD3DVolume implementation structure (extends IUnknown)
724 typedef struct IWineD3DVolumeImpl
726 /* IUnknown & WineD3DResource fields */
727 const IWineD3DVolumeVtbl
*lpVtbl
;
728 IWineD3DResourceClass resource
;
730 /* WineD3DVolume Information */
731 D3DVOLUME_DESC currentDesc
;
742 } IWineD3DVolumeImpl
;
744 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl
;
746 /*****************************************************************************
747 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
749 typedef struct IWineD3DVolumeTextureImpl
751 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
752 const IWineD3DVolumeTextureVtbl
*lpVtbl
;
753 IWineD3DResourceClass resource
;
754 IWineD3DBaseTextureClass baseTexture
;
756 /* IWineD3DVolumeTexture */
757 IWineD3DVolume
*volumes
[MAX_LEVELS
];
762 } IWineD3DVolumeTextureImpl
;
764 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl
;
766 typedef struct _WINED3DSURFACET_DESC
768 D3DMULTISAMPLE_TYPE MultiSampleType
;
769 DWORD MultiSampleQuality
;
772 } WINED3DSURFACET_DESC
;
774 /*****************************************************************************
775 * IWineD3DSurface implementation structure
777 struct IWineD3DSurfaceImpl
779 /* IUnknown & IWineD3DResource Information */
780 const IWineD3DSurfaceVtbl
*lpVtbl
;
781 IWineD3DResourceClass resource
;
783 /* IWineD3DSurface fields */
785 WINED3DSURFACET_DESC currentDesc
;
790 /* TODO: move this off into a management class(maybe!) */
798 /* precalculated x and y scalings for texture coords */
799 float pow2scalingFactorX
; /* = (Width / pow2Width ) */
800 float pow2scalingFactorY
; /* = (Height / pow2Height) */
815 glDescriptor glDescription
;
818 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl
;
820 /*****************************************************************************
821 * IWineD3DVertexDeclaration implementation structure
823 typedef struct IWineD3DVertexDeclarationImpl
{
824 /* IUnknown Information */
825 const IWineD3DVertexDeclarationVtbl
*lpVtbl
;
826 LONG ref
; /* Note: Ref counting not required */
829 /** precomputed fvf if simple declaration */
830 IWineD3DDeviceImpl
*wineD3DDevice
;
831 DWORD fvf
[MAX_STREAMS
];
834 /** dx8 compatible Declaration fields */
835 DWORD
* pDeclaration8
;
836 DWORD declaration8Length
;
839 D3DVERTEXELEMENT9
* pDeclaration9
;
840 UINT declaration9NumElements
;
841 } IWineD3DVertexDeclarationImpl
;
843 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl
;
845 /*****************************************************************************
846 * IWineD3DStateBlock implementation structure
849 /* Internal state Block for Begin/End/Capture/Create/Apply info */
850 /* Note: Very long winded but gl Lists are not flexible enough */
851 /* to resolve everything we need, so doing it manually for now */
852 typedef struct SAVEDSTATES
{
856 BOOL streamSource
[MAX_STREAMS
];
857 BOOL streamFreq
[MAX_STREAMS
];
858 BOOL textures
[MAX_TEXTURES
];
859 BOOL transform
[HIGHEST_TRANSFORMSTATE
+ 1];
861 BOOL renderState
[WINEHIGHEST_RENDER_STATE
+ 1];
862 BOOL textureState
[MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
863 BOOL samplerState
[MAX_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
864 BOOL clipplane
[MAX_CLIPPLANES
];
870 struct IWineD3DStateBlockImpl
872 /* IUnknown fields */
873 const IWineD3DStateBlockVtbl
*lpVtbl
;
874 LONG ref
; /* Note: Ref counting not required */
876 /* IWineD3DStateBlock information */
878 IWineD3DDeviceImpl
*wineD3DDevice
;
879 WINED3DSTATEBLOCKTYPE blockType
;
881 /* Array indicating whether things have been set or changed */
885 /* Drawing - Vertex Shader or FVF related */
887 /* Vertex Shader Declaration */
888 IWineD3DVertexDeclaration
*vertexDecl
;
890 IWineD3DVertexShader
*vertexShader
; /* @TODO: Replace void * with IWineD3DVertexShader * */
892 /* Vertex Shader Constants */
893 BOOL vertexShaderConstantB
[MAX_VSHADER_CONSTANTS
];
894 UINT vertexShaderConstantI
[MAX_VSHADER_CONSTANTS
* 4];
895 float vertexShaderConstantF
[MAX_VSHADER_CONSTANTS
* 4];
897 BOOL softwareVertexProcessing
;
901 UINT streamStride
[MAX_STREAMS
];
902 UINT streamOffset
[MAX_STREAMS
];
903 IWineD3DVertexBuffer
*streamSource
[MAX_STREAMS
];
904 UINT streamFreq
[MAX_STREAMS
];
905 UINT streamFlags
[MAX_STREAMS
]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
908 IWineD3DIndexBuffer
* pIndexData
;
909 UINT baseVertexIndex
; /* Note: only used for d3d8 */
912 D3DMATRIX transforms
[HIGHEST_TRANSFORMSTATE
+ 1];
915 PLIGHTINFOEL
*lights
; /* NOTE: active GL lights must be front of the chain */
918 double clipplane
[MAX_CLIPPLANES
][4];
919 WINED3DCLIPSTATUS clip_status
;
922 WINED3DVIEWPORT viewport
;
925 WINED3DMATERIAL material
;
928 void *pixelShader
; /* TODO: Replace void * with IWineD3DPixelShader * */
930 /* Indexed Vertex Blending */
931 D3DVERTEXBLENDFLAGS vertex_blend
;
935 DWORD renderState
[WINEHIGHEST_RENDER_STATE
+ 1];
938 IWineD3DBaseTexture
*textures
[MAX_TEXTURES
];
939 int textureDimensions
[MAX_SAMPLERS
];
941 /* Texture State Stage */
942 DWORD textureState
[MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
944 DWORD samplerState
[MAX_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
948 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl
;
950 /*****************************************************************************
951 * IWineD3DQueryImpl implementation structure (extends IUnknown)
953 typedef struct IWineD3DQueryImpl
955 const IWineD3DQueryVtbl
*lpVtbl
;
956 LONG ref
; /* Note: Ref counting not required */
959 /*TODO: replace with iface usage */
961 IWineD3DDevice
*wineD3DDevice
;
963 IWineD3DDeviceImpl
*wineD3DDevice
;
965 /* IWineD3DQuery fields */
973 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl
;
975 /*****************************************************************************
976 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
979 typedef struct IWineD3DSwapChainImpl
982 IWineD3DSwapChainVtbl
*lpVtbl
;
983 LONG ref
; /* Note: Ref counting not required */
986 IWineD3DDeviceImpl
*wineD3DDevice
;
988 /* IWineD3DSwapChain fields */
989 IWineD3DSurface
*backBuffer
;
990 IWineD3DSurface
*frontBuffer
;
991 BOOL wantsDepthStencilBuffer
;
992 D3DPRESENT_PARAMETERS presentParms
;
994 /* TODO: move everything upto drawable off into a context manager
995 and store the 'data' in the contextManagerData interface.
996 IUnknown *contextManagerData;
1004 XVisualInfo
*visInfo
;
1005 GLXContext render_ctx
;
1006 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1008 } IWineD3DSwapChainImpl
;
1010 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl
;
1012 /*****************************************************************************
1013 * Utility function prototypes
1016 /* Trace routines */
1017 const char* debug_d3dformat(WINED3DFORMAT fmt
);
1018 const char* debug_d3ddevicetype(D3DDEVTYPE devtype
);
1019 const char* debug_d3dresourcetype(D3DRESOURCETYPE res
);
1020 const char* debug_d3dusage(DWORD usage
);
1021 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType
);
1022 const char* debug_d3drenderstate(DWORD state
);
1023 const char* debug_d3dtexturestate(DWORD state
);
1024 const char* debug_d3dpool(D3DPOOL pool
);
1026 /* Routines for GL <-> D3D values */
1027 GLenum
StencilOp(DWORD op
);
1028 void set_tex_op(IWineD3DDevice
*iface
, BOOL isAlpha
, int Stage
, D3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
);
1029 void set_texture_matrix(const float *smat
, DWORD flags
, BOOL calculatedCoords
);
1030 void GetSrcAndOpFromValue(DWORD iValue
, BOOL isAlphaArg
, GLenum
* source
, GLenum
* operand
);
1032 SHORT
D3DFmtGetBpp(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1033 GLenum
D3DFmt2GLFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1034 GLenum
D3DFmt2GLType(IWineD3DDeviceImpl
*This
, D3DFORMAT fmt
);
1035 GLint
D3DFmt2GLIntFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1037 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat
, D3DFORMAT StencilBufferFormat
, int *attribs
, int* nAttribs
, BOOL alternate
);
1040 /*****************************************************************************
1041 * To enable calling of inherited functions, requires prototypes
1043 * Note: Only require classes which are subclassed, ie resource, basetexture,
1045 /*** IUnknown methods ***/
1046 extern HRESULT WINAPI
IWineD3DResourceImpl_QueryInterface(IWineD3DResource
*iface
, REFIID riid
, void** ppvObject
);
1047 extern ULONG WINAPI
IWineD3DResourceImpl_AddRef(IWineD3DResource
*iface
);
1048 extern ULONG WINAPI
IWineD3DResourceImpl_Release(IWineD3DResource
*iface
);
1049 /*** IWineD3DResource methods ***/
1050 extern HRESULT WINAPI
IWineD3DResourceImpl_GetParent(IWineD3DResource
*iface
, IUnknown
**pParent
);
1051 extern HRESULT WINAPI
IWineD3DResourceImpl_GetDevice(IWineD3DResource
*iface
, IWineD3DDevice
** ppDevice
);
1052 extern HRESULT WINAPI
IWineD3DResourceImpl_SetPrivateData(IWineD3DResource
*iface
, REFGUID refguid
, CONST
void * pData
, DWORD SizeOfData
, DWORD Flags
);
1053 extern HRESULT WINAPI
IWineD3DResourceImpl_GetPrivateData(IWineD3DResource
*iface
, REFGUID refguid
, void * pData
, DWORD
* pSizeOfData
);
1054 extern HRESULT WINAPI
IWineD3DResourceImpl_FreePrivateData(IWineD3DResource
*iface
, REFGUID refguid
);
1055 extern DWORD WINAPI
IWineD3DResourceImpl_SetPriority(IWineD3DResource
*iface
, DWORD PriorityNew
);
1056 extern DWORD WINAPI
IWineD3DResourceImpl_GetPriority(IWineD3DResource
*iface
);
1057 extern void WINAPI
IWineD3DResourceImpl_PreLoad(IWineD3DResource
*iface
);
1058 extern D3DRESOURCETYPE WINAPI
IWineD3DResourceImpl_GetType(IWineD3DResource
*iface
);
1059 /*** class static members ***/
1060 void IWineD3DResourceImpl_CleanUp(IWineD3DResource
*iface
);
1062 /*** IUnknown methods ***/
1063 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture
*iface
, REFIID riid
, void** ppvObject
);
1064 extern ULONG WINAPI
IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture
*iface
);
1065 extern ULONG WINAPI
IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture
*iface
);
1066 /*** IWineD3DResource methods ***/
1067 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture
*iface
, IUnknown
**pParent
);
1068 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture
*iface
, IWineD3DDevice
** ppDevice
);
1069 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
, CONST
void * pData
, DWORD SizeOfData
, DWORD Flags
);
1070 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
, void * pData
, DWORD
* pSizeOfData
);
1071 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
);
1072 extern DWORD WINAPI
IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture
*iface
, DWORD PriorityNew
);
1073 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture
*iface
);
1074 extern void WINAPI
IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture
*iface
);
1075 extern D3DRESOURCETYPE WINAPI
IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture
*iface
);
1076 /*** IWineD3DBaseTexture methods ***/
1077 extern DWORD WINAPI
IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture
*iface
, DWORD LODNew
);
1078 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture
*iface
);
1079 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture
*iface
);
1080 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture
*iface
, D3DTEXTUREFILTERTYPE FilterType
);
1081 extern D3DTEXTUREFILTERTYPE WINAPI
IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture
*iface
);
1082 extern void WINAPI
IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture
*iface
);
1083 extern BOOL WINAPI
IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture
*iface
, BOOL
);
1084 extern BOOL WINAPI
IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture
*iface
);
1086 extern BYTE
* WINAPI
IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer
* iface
, DWORD iOffset
);
1087 extern HRESULT WINAPI
IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer
* iface
);
1088 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture
*iface
);
1089 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture
*iface
);
1090 extern void WINAPI
IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture
*iface
, const DWORD textureStates
[WINED3D_HIGHEST_TEXTURE_STATE
+ 1], const DWORD samplerStates
[WINED3D_HIGHEST_SAMPLER_STATE
+ 1]);
1091 /*** class static members ***/
1092 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture
*iface
);
1094 /* an emul for the type of constants that are used... adressing causes problems with being able to work out what's used and what's not.. so maybe we'll have to rely on the server vertex shader const functions? */
1095 enum vsConstantsEnum
{
1096 VS_CONSTANT_NOT_USED
= 0,
1097 VS_CONSTANT_CONSTANT
,
1098 VS_CONSTANT_INTEGER
,
1099 VS_CONSTANT_BOOLEAN
,
1103 /*****************************************************************************
1104 * IDirect3DVertexShader implementation structure
1106 typedef struct IWineD3DVertexShaderImpl
{
1108 const IWineD3DVertexShaderVtbl
*lpVtbl
;
1109 LONG ref
; /* Note: Ref counting not required */
1112 IWineD3DDeviceImpl
*wineD3DDevice
;
1114 /* IWineD3DVertexShaderImpl */
1115 CONST DWORD
*function
;
1116 UINT functionLength
;
1121 /* vertex declaration array mapping */
1122 BOOL namedArrays
; /* don't map use named functions */
1123 BOOL declaredArrays
; /* mapping requires */
1124 INT arrayUsageMap
[WINED3DSHADERDECLUSAGE_MAX_USAGE
]; /* lookup table for the maps */
1125 INT highestConstant
;
1126 CHAR constantsUsedBitmap
[256];
1127 /* FIXME: This needs to be populated with some flags of VS_CONSTANT_NOT_USED, VS_CONSTANT_CONSTANT, VS_CONSTANT_INTEGER, VS_CONSTANT_BOOLEAN, VS_CONSTANT_FLOAT, a half byte bitmap will be the best option, but I'll keep it as chards for siplicity */
1128 /* run time datas... */
1131 #if 0 /* needs reworking */
1132 /* run time datas */
1133 VSHADERINPUTDATA input
;
1134 VSHADEROUTPUTDATA output
;
1136 } IWineD3DVertexShaderImpl
;
1137 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl
;
1139 /*****************************************************************************
1140 * IDirect3DPixelShader implementation structure
1142 typedef struct IWineD3DPixelShaderImpl
{
1144 const IWineD3DPixelShaderVtbl
*lpVtbl
;
1145 LONG ref
; /* Note: Ref counting not required */
1148 IWineD3DDeviceImpl
*wineD3DDevice
;
1151 /* IWineD3DPixelShaderImpl */
1152 CONST DWORD
*function
;
1153 UINT functionLength
;
1155 #if 0 /* needs reworking */
1156 /* run time datas */
1158 PSHADERINPUTDATA input
;
1159 PSHADEROUTPUTDATA output
;
1161 } IWineD3DPixelShaderImpl
;
1163 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl
;