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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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"
43 #include "wine/wined3d_interface.h"
44 #include "wine/wined3d_gl.h"
47 #define MAX_PALETTES 256
48 #define MAX_STREAMS 16
49 #define MAX_TEXTURES 8
50 #define MAX_SAMPLERS 16
51 #define MAX_ACTIVE_LIGHTS 8
52 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
53 #define MAX_LEVELS 256
55 #define MAX_VSHADER_CONSTANTS 96
56 #define MAX_PSHADER_CONSTANTS 32
58 /* Used for CreateStateBlock */
59 #define NUM_SAVEDPIXELSTATES_R 35
60 #define NUM_SAVEDPIXELSTATES_T 18
61 #define NUM_SAVEDPIXELSTATES_S 12
62 #define NUM_SAVEDVERTEXSTATES_R 31
63 #define NUM_SAVEDVERTEXSTATES_T 2
64 #define NUM_SAVEDVERTEXSTATES_S 1
66 extern const DWORD SavedPixelStates_R
[NUM_SAVEDPIXELSTATES_R
];
67 extern const DWORD SavedPixelStates_T
[NUM_SAVEDPIXELSTATES_T
];
68 extern const DWORD SavedPixelStates_S
[NUM_SAVEDPIXELSTATES_S
];
69 extern const DWORD SavedVertexStates_R
[NUM_SAVEDVERTEXSTATES_R
];
70 extern const DWORD SavedVertexStates_T
[NUM_SAVEDVERTEXSTATES_T
];
71 extern const DWORD SavedVertexStates_S
[NUM_SAVEDVERTEXSTATES_S
];
73 typedef enum _WINELOOKUP
{
74 WINELOOKUP_WARPPARAM
= 0,
75 WINELOOKUP_MAGFILTER
= 1,
79 extern int minLookup
[MAX_LOOKUPS
];
80 extern int maxLookup
[MAX_LOOKUPS
];
81 extern DWORD
*stateLookup
[MAX_LOOKUPS
];
83 extern DWORD minMipLookup
[D3DTEXF_ANISOTROPIC
+ 1][D3DTEXF_LINEAR
+ 1];
85 typedef struct _WINED3DGLTYPE
{
93 /* NOTE: Make sure these are in the correct numerical order. (see /include/d3d9types.h typedef enum _D3DDECLTYPE) */
94 WINED3DGLTYPE
static const glTypeLookup
[D3DDECLTYPE_UNUSED
] = {
95 {D3DDECLTYPE_FLOAT1
, 1, GL_FLOAT
, GL_FALSE
,sizeof(float)},
96 {D3DDECLTYPE_FLOAT2
, 2, GL_FLOAT
, GL_FALSE
,sizeof(float)},
97 {D3DDECLTYPE_FLOAT3
, 3, GL_FLOAT
, GL_FALSE
,sizeof(float)},
98 {D3DDECLTYPE_FLOAT4
, 4, GL_FLOAT
, GL_FALSE
,sizeof(float)},
99 {D3DDECLTYPE_D3DCOLOR
, 4, GL_UNSIGNED_BYTE
, GL_TRUE
,sizeof(BYTE
)},
100 {D3DDECLTYPE_UBYTE4
, 4, GL_UNSIGNED_BYTE
, GL_FALSE
,sizeof(BYTE
)},
101 {D3DDECLTYPE_SHORT2
, 2, GL_SHORT
, GL_FALSE
,sizeof(short int)},
102 {D3DDECLTYPE_SHORT4
, 4, GL_SHORT
, GL_FALSE
,sizeof(short int)},
103 {D3DDECLTYPE_UBYTE4N
, 4, GL_UNSIGNED_BYTE
, GL_FALSE
,sizeof(BYTE
)},
104 {D3DDECLTYPE_SHORT2N
, 2, GL_SHORT
, GL_FALSE
,sizeof(short int)},
105 {D3DDECLTYPE_SHORT4N
, 4, GL_SHORT
, GL_FALSE
,sizeof(short int)},
106 {D3DDECLTYPE_USHORT2N
, 2, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
107 {D3DDECLTYPE_USHORT4N
, 4, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
108 {D3DDECLTYPE_UDEC3
, 3, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
109 {D3DDECLTYPE_DEC3N
, 3, GL_SHORT
, GL_FALSE
,sizeof(short int)},
110 {D3DDECLTYPE_FLOAT16_2
, 2, GL_FLOAT
, GL_FALSE
,sizeof(short int)},
111 {D3DDECLTYPE_FLOAT16_4
, 4, GL_FLOAT
, GL_FALSE
,sizeof(short int)}};
113 #define WINED3D_ATR_TYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].d3dType
114 #define WINED3D_ATR_SIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].size
115 #define WINED3D_ATR_GLTYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].glType
116 #define WINED3D_ATR_NORMALIZED(_attribute) glTypeLookup[sd->u.s._attribute.dwType].normalized
117 #define WINED3D_ATR_TYPESIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].typesize
135 typedef struct wined3d_settings_s
{
136 /* vertex and pixel shader modes */
141 /* nonpower 2 function */
143 } wined3d_settings_t
;
145 extern wined3d_settings_t wined3d_settings
;
149 extern void (*wine_tsx11_lock_ptr
)(void);
150 extern void (*wine_tsx11_unlock_ptr
)(void);
152 /* As GLX relies on X, this is needed */
156 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
157 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
159 #define ENTER_GL() wine_tsx11_lock_ptr()
160 #define LEAVE_GL() wine_tsx11_unlock_ptr()
163 /*****************************************************************************
167 /* GL related defines */
168 /* ------------------ */
169 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
170 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
171 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
172 #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
174 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
175 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
176 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
177 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
179 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
180 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
181 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
182 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
184 #define D3DCOLORTOGLFLOAT4(dw, vec) \
185 (vec)[0] = D3DCOLOR_R(dw); \
186 (vec)[1] = D3DCOLOR_G(dw); \
187 (vec)[2] = D3DCOLOR_B(dw); \
188 (vec)[3] = D3DCOLOR_A(dw);
190 /* Note: The following is purely to keep the source code as clear from #ifdefs as possible */
191 #if defined(GL_VERSION_1_3)
192 #define GLACTIVETEXTURE(textureNo) \
193 glActiveTexture(GL_TEXTURE0 + textureNo); \
194 checkGLcall("glActiveTexture");
195 #define GLCLIENTACTIVETEXTURE(textureNo) \
196 glClientActiveTexture(GL_TEXTURE0 + textureNo);
197 #define GLMULTITEXCOORD1F(a,b) \
198 glMultiTexCoord1f(GL_TEXTURE0 + a, b);
199 #define GLMULTITEXCOORD2F(a,b,c) \
200 glMultiTexCoord2f(GL_TEXTURE0 + a, b, c);
201 #define GLMULTITEXCOORD3F(a,b,c,d) \
202 glMultiTexCoord3f(GL_TEXTURE0 + a, b, c, d);
203 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
204 glMultiTexCoord4f(GL_TEXTURE0 + a, b, c, d, e);
205 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP
207 #define GLACTIVETEXTURE(textureNo) \
208 glActiveTextureARB(GL_TEXTURE0_ARB + textureNo); \
209 checkGLcall("glActiveTextureARB");
210 #define GLCLIENTACTIVETEXTURE(textureNo) \
211 glClientActiveTextureARB(GL_TEXTURE0_ARB + textureNo);
212 #define GLMULTITEXCOORD1F(a,b) \
213 glMultiTexCoord1fARB(GL_TEXTURE0_ARB + a, b);
214 #define GLMULTITEXCOORD2F(a,b,c) \
215 glMultiTexCoord2fARB(GL_TEXTURE0_ARB + a, b, c);
216 #define GLMULTITEXCOORD3F(a,b,c,d) \
217 glMultiTexCoord3fARB(GL_TEXTURE0_ARB + a, b, c, d);
218 #define GLMULTITEXCOORD4F(a,b,c,d,e) \
219 glMultiTexCoord4fARB(GL_TEXTURE0_ARB + a, b, c, d, e);
220 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
223 /* DirectX Device Limits */
224 /* --------------------- */
225 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
227 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
228 See MaxStreams in MSDN under GetDeviceCaps */
229 /* Maximum number of constants provided to the shaders */
230 #define HIGHEST_TRANSFORMSTATE 512
231 /* Highest value in D3DTRANSFORMSTATETYPE */
232 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
234 #define MAX_PALETTES 256
236 /* Checking of API calls */
237 /* --------------------- */
238 #define checkGLcall(A) \
240 GLint err = glGetError(); \
241 if (err == GL_NO_ERROR) { \
242 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
245 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
246 err, A, __FILE__, __LINE__); \
247 err = glGetError(); \
248 } while (err != GL_NO_ERROR); \
251 /* Trace routines / diagnostics */
252 /* ---------------------------- */
254 /* Dump out a matrix and copy it */
255 #define conv_mat(mat,gl_mat) \
257 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
258 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
259 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
260 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
261 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
264 /* Macro to dump out the current state of the light chain */
265 #define DUMP_LIGHT_CHAIN() \
267 PLIGHTINFOEL *el = This->stateBlock->lights;\
269 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
274 /* Trace vector and strided data information */
275 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
276 #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);
278 /* Defines used for optimizations */
280 /* Only reapply what is necessary */
281 #define REAPPLY_ALPHAOP 0x0001
282 #define REAPPLY_ALL 0xFFFF
284 /* Advance declaration of structures to satisfy compiler */
285 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl
;
286 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl
;
287 typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl
;
291 /* TODO: Move some of this to the device */
292 long globalChangeGlRam(long glram
);
294 /* Memory and object tracking */
296 /*Structure for holding information on all direct3d objects
297 useful for making sure tracking is ok and when release is called on a device!
298 and probably quite handy for debugging and dumping states out
300 typedef struct WineD3DGlobalStatistics
{
301 int glsurfaceram
; /* The aproximate amount of glTexture memory allocated for textures */
302 } WineD3DGlobalStatistics
;
304 extern WineD3DGlobalStatistics
* wineD3DGlobalStatistics
;
306 /* Global variables */
307 extern const float identity
[16];
309 /*****************************************************************************
310 * Compilable extra diagnostics
313 /* Trace information per-vertex: (extremely high amount of trace) */
314 #if 0 /* NOTE: Must be 0 in cvs */
315 # define VTRACE(A) TRACE A
320 /* Checking of per-vertex related GL calls */
321 /* --------------------- */
322 #define vcheckGLcall(A) \
324 GLint err = glGetError(); \
325 if (err == GL_NO_ERROR) { \
326 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
329 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
330 err, A, __FILE__, __LINE__); \
331 err = glGetError(); \
332 } while (err != GL_NO_ERROR); \
335 /* TODO: Confirm each of these works when wined3d move completed */
336 #if 0 /* NOTE: Must be 0 in cvs */
337 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
338 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
339 is enabled, and if it doesn't exists it is disabled. */
340 # define FRAME_DEBUGGING
341 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
342 the file is deleted */
343 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
344 # define SINGLE_FRAME_DEBUGGING
346 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
347 It can only be enabled when FRAME_DEBUGGING is also enabled
348 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
350 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
351 # define SHOW_FRAME_MAKEUP 1
353 /* The following, when enabled, lets you see the makeup of the all the textures used during each
354 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
355 The contents of the textures assigned to each stage are written into
356 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
357 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
358 # define SHOW_TEXTURE_MAKEUP 0
361 extern BOOL isDumpingFrames
;
362 extern LONG primCounter
;
365 /*****************************************************************************
369 /* Routine common to the draw primitive and draw indexed primitive routines */
370 void drawPrimitive(IWineD3DDevice
*iface
,
374 long StartVertexIndex
,
375 UINT numberOfVertices
,
380 WineDirect3DVertexStridedData
*DrawPrimStrideData
);
382 void primitiveConvertToStridedData(IWineD3DDevice
*iface
,
383 WineDirect3DVertexStridedData
*strided
,
384 LONG BaseVertexIndex
);
386 DWORD
get_flexible_vertex_size(DWORD d3dvtVertexType
);
390 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
391 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
393 /* Routine to fill gl caps for swapchains and IWineD3D */
394 BOOL
IWineD3DImpl_FillGLCaps(WineD3D_GL_Info
*gl_info
,
397 /*****************************************************************************
398 * Internal representation of a light
400 typedef struct PLIGHTINFOEL PLIGHTINFOEL
;
401 struct PLIGHTINFOEL
{
402 WINED3DLIGHT OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
409 /* Converted parms to speed up swapping lights */
419 /*****************************************************************************
420 * IWineD3D implementation structure
422 typedef struct IWineD3DImpl
424 /* IUnknown fields */
425 const IWineD3DVtbl
*lpVtbl
;
426 LONG ref
; /* Note: Ref counting not required */
428 /* WineD3D Information */
434 WineD3D_GL_Info gl_info
;
437 extern const IWineD3DVtbl IWineD3D_Vtbl
;
439 typedef struct SwapChainList
{
440 IWineD3DSwapChain
*swapchain
;
441 struct SwapChainList
*next
;
444 /** Hacked out start of a context manager!! **/
445 typedef struct glContext
{
452 IWineD3DSurface
*pSurface
;
453 #if 0 /* TODO: someway to represent the state of the context */
454 IWineD3DStateBlock
*pStateBlock
;
456 /* a few other things like format */
459 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
460 (since it will break quite a few things until contexts are managed properly!) */
461 extern BOOL pbuffer_support
;
462 /* allocate one pbuffer per surface */
463 extern BOOL pbuffer_per_surface
;
465 /* Maximum number of contexts/pbuffers to keep in cache,
466 set to 100 because ATI's drivers don't support deleting pBuffers properly
467 this needs to be migrated to a list and some option availalbe for controle the cache size.
469 #define CONTEXT_CACHE 100
471 typedef struct ResourceList
{
472 IWineD3DResource
*resource
;
473 struct ResourceList
*next
;
476 /* A helper function that dumps a resource list */
477 void dumpResources(ResourceList
*resources
);
479 /*****************************************************************************
480 * IWineD3DDevice implementation structure
482 typedef struct IWineD3DDeviceImpl
484 /* IUnknown fields */
485 const IWineD3DDeviceVtbl
*lpVtbl
;
486 LONG ref
; /* Note: Ref counting not required */
488 /* WineD3D Information */
492 /* X and GL Information */
493 GLint maxConcurrentLights
;
496 BOOL modelview_valid
;
498 BOOL view_ident
; /* true iff view matrix is identity */
499 BOOL last_was_rhw
; /* true iff last draw_primitive was in xyzrhw mode */
500 BOOL viewport_changed
; /* Was the viewport changed since the last draw? */
501 GLenum tracking_parm
; /* Which source is tracking current colour */
502 LONG tracking_color
; /* used iff GL_COLOR_MATERIAL was enabled */
503 #define DISABLED_TRACKING 0 /* Disabled */
504 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
505 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
506 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
511 BOOL texture_shader_active
; /* TODO: Confirm use is correct */
512 BOOL last_was_notclipped
;
514 /* State block related */
515 BOOL isRecordingState
;
516 IWineD3DStateBlockImpl
*stateBlock
;
517 IWineD3DStateBlockImpl
*updateStateBlock
;
519 /* Internal use fields */
520 WINED3DDEVICE_CREATION_PARAMETERS createParms
;
524 SwapChainList
*swapchains
;
526 ResourceList
*resources
; /* a linked list to track resources created by the device */
528 /* Render Target Support */
529 IWineD3DSurface
*depthStencilBuffer
;
531 IWineD3DSurface
*renderTarget
;
532 IWineD3DSurface
*stencilBufferTarget
;
534 /* palettes texture management */
535 PALETTEENTRY palettes
[MAX_PALETTES
][256];
538 /* For rendering to a texture using glCopyTexImage */
539 BOOL renderUpsideDown
;
541 /* Cursor management */
548 /* Textures for when no other textures are mapped */
549 UINT dummyTextureName
[MAX_TEXTURES
];
551 /* Debug stream management */
554 /* Device state management */
556 BOOL d3d_initialized
;
558 /* Screen buffer resources */
559 glContext contextCache
[CONTEXT_CACHE
];
561 /* A flag to check if endscene has been called before changing the render tartet */
564 /* process vertex shaders using software or hardware */
565 BOOL softwareVertexProcessing
;
567 /* DirectDraw stuff */
569 IWineD3DSurface
*ddraw_primary
;
570 DWORD ddraw_width
, ddraw_height
;
571 WINED3DFORMAT ddraw_format
;
573 } IWineD3DDeviceImpl
;
575 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl
;
577 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
578 * anybody uses it for much so a good implementation is optional. */
579 typedef struct PrivateData
581 struct PrivateData
* next
;
584 DWORD flags
; /* DDSPD_* */
585 DWORD uniqueness_value
;
596 /* OpenGL ortho matrix setup */
597 void d3ddevice_set_ortho(IWineD3DDeviceImpl
*This
, BOOL dontclip
);
599 /*****************************************************************************
600 * IWineD3DResource implementation structure
602 typedef struct IWineD3DResourceClass
604 /* IUnknown fields */
605 LONG ref
; /* Note: Ref counting not required */
607 /* WineD3DResource Information */
609 WINED3DRESOURCETYPE resourceType
;
610 IWineD3DDeviceImpl
*wineD3DDevice
;
614 WINED3DFORMAT format
;
615 BYTE
*allocatedMemory
;
616 PrivateData
*privateData
;
618 } IWineD3DResourceClass
;
620 typedef struct IWineD3DResourceImpl
622 /* IUnknown & WineD3DResource Information */
623 const IWineD3DResourceVtbl
*lpVtbl
;
624 IWineD3DResourceClass resource
;
625 } IWineD3DResourceImpl
;
628 /*****************************************************************************
629 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
631 typedef struct IWineD3DVertexBufferImpl
633 /* IUnknown & WineD3DResource Information */
634 const IWineD3DVertexBufferVtbl
*lpVtbl
;
635 IWineD3DResourceClass resource
;
637 /* WineD3DVertexBuffer specifics */
640 } IWineD3DVertexBufferImpl
;
642 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl
;
645 /*****************************************************************************
646 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
648 typedef struct IWineD3DIndexBufferImpl
650 /* IUnknown & WineD3DResource Information */
651 const IWineD3DIndexBufferVtbl
*lpVtbl
;
652 IWineD3DResourceClass resource
;
654 /* WineD3DVertexBuffer specifics */
655 } IWineD3DIndexBufferImpl
;
657 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl
;
659 /*****************************************************************************
660 * IWineD3DBaseTexture D3D- > openGL state map lookups
662 #define WINED3DFUNC_NOTSUPPORTED -2
663 #define WINED3DFUNC_UNIMPLEMENTED -1
665 typedef enum winetexturestates
{
666 WINED3DTEXSTA_ADDRESSU
= 0,
667 WINED3DTEXSTA_ADDRESSV
= 1,
668 WINED3DTEXSTA_ADDRESSW
= 2,
669 WINED3DTEXSTA_BORDERCOLOR
= 3,
670 WINED3DTEXSTA_MAGFILTER
= 4,
671 WINED3DTEXSTA_MINFILTER
= 5,
672 WINED3DTEXSTA_MIPFILTER
= 6,
673 WINED3DTEXSTA_MAXMIPLEVEL
= 7,
674 WINED3DTEXSTA_MAXANISOTROPY
= 8,
675 WINED3DTEXSTA_SRGBTEXTURE
= 9,
676 WINED3DTEXSTA_ELEMENTINDEX
= 10,
677 WINED3DTEXSTA_DMAPOFFSET
= 11,
678 WINED3DTEXSTA_TSSADDRESSW
= 12,
679 MAX_WINETEXTURESTATES
= 13,
682 typedef struct Wined3dTextureStateMap
{
685 } Wined3dTextureStateMap
;
687 /*****************************************************************************
688 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
690 typedef struct IWineD3DBaseTextureClass
698 WINED3DTEXTUREFILTERTYPE filterType
;
699 DWORD states
[MAX_WINETEXTURESTATES
];
701 } IWineD3DBaseTextureClass
;
703 typedef struct IWineD3DBaseTextureImpl
705 /* IUnknown & WineD3DResource Information */
706 const IWineD3DBaseTextureVtbl
*lpVtbl
;
707 IWineD3DResourceClass resource
;
708 IWineD3DBaseTextureClass baseTexture
;
710 } IWineD3DBaseTextureImpl
;
712 /*****************************************************************************
713 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
715 typedef struct IWineD3DTextureImpl
717 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
718 const IWineD3DTextureVtbl
*lpVtbl
;
719 IWineD3DResourceClass resource
;
720 IWineD3DBaseTextureClass baseTexture
;
722 /* IWineD3DTexture */
723 IWineD3DSurface
*surfaces
[MAX_LEVELS
];
727 float pow2scalingFactorX
;
728 float pow2scalingFactorY
;
730 } IWineD3DTextureImpl
;
732 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl
;
734 /*****************************************************************************
735 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
737 typedef struct IWineD3DCubeTextureImpl
739 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
740 const IWineD3DCubeTextureVtbl
*lpVtbl
;
741 IWineD3DResourceClass resource
;
742 IWineD3DBaseTextureClass baseTexture
;
744 /* IWineD3DCubeTexture */
745 IWineD3DSurface
*surfaces
[6][MAX_LEVELS
];
748 float pow2scalingFactor
;
750 } IWineD3DCubeTextureImpl
;
752 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl
;
754 typedef struct _WINED3DVOLUMET_DESC
759 } WINED3DVOLUMET_DESC
;
761 /*****************************************************************************
762 * IWineD3DVolume implementation structure (extends IUnknown)
764 typedef struct IWineD3DVolumeImpl
766 /* IUnknown & WineD3DResource fields */
767 const IWineD3DVolumeVtbl
*lpVtbl
;
768 IWineD3DResourceClass resource
;
770 /* WineD3DVolume Information */
771 WINED3DVOLUMET_DESC currentDesc
;
772 IWineD3DBase
*container
;
777 WINED3DBOX lockedBox
;
782 } IWineD3DVolumeImpl
;
784 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl
;
786 /*****************************************************************************
787 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
789 typedef struct IWineD3DVolumeTextureImpl
791 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
792 const IWineD3DVolumeTextureVtbl
*lpVtbl
;
793 IWineD3DResourceClass resource
;
794 IWineD3DBaseTextureClass baseTexture
;
796 /* IWineD3DVolumeTexture */
797 IWineD3DVolume
*volumes
[MAX_LEVELS
];
802 } IWineD3DVolumeTextureImpl
;
804 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl
;
806 typedef struct _WINED3DSURFACET_DESC
808 WINED3DMULTISAMPLE_TYPE MultiSampleType
;
809 DWORD MultiSampleQuality
;
812 } WINED3DSURFACET_DESC
;
814 /*****************************************************************************
815 * Structure for DIB Surfaces (GetDC and GDI surfaces)
817 typedef struct wineD3DSurface_DIB
{
822 } wineD3DSurface_DIB
;
824 /*****************************************************************************
825 * IWineD3DSurface implementation structure
827 struct IWineD3DSurfaceImpl
829 /* IUnknown & IWineD3DResource Information */
830 const IWineD3DSurfaceVtbl
*lpVtbl
;
831 IWineD3DResourceClass resource
;
833 /* IWineD3DSurface fields */
834 IWineD3DBase
*container
;
835 WINED3DSURFACET_DESC currentDesc
;
836 IWineD3DPaletteImpl
*palette
;
841 /* TODO: move this off into a management class(maybe!) */
848 /* Oversized texture */
852 /* precalculated x and y scalings for texture coords */
853 float pow2scalingFactorX
; /* = (Width / pow2Width ) */
854 float pow2scalingFactorY
; /* = (Height / pow2Height) */
860 glDescriptor glDescription
;
863 wineD3DSurface_DIB dib
;
866 /* Color keys for DDraw */
867 DDCOLORKEY DestBltCKey
;
868 DDCOLORKEY DestOverlayCKey
;
869 DDCOLORKEY SrcOverlayCKey
;
870 DDCOLORKEY SrcBltCKey
;
875 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl
;
876 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl
;
878 /* Predeclare the shared Surface functions */
879 HRESULT WINAPI
IWineD3DSurfaceImpl_QueryInterface(IWineD3DSurface
*iface
, REFIID riid
, LPVOID
*ppobj
);
880 ULONG WINAPI
IWineD3DSurfaceImpl_AddRef(IWineD3DSurface
*iface
);
881 ULONG WINAPI
IWineD3DSurfaceImpl_Release(IWineD3DSurface
*iface
);
882 HRESULT WINAPI
IWineD3DSurfaceImpl_GetParent(IWineD3DSurface
*iface
, IUnknown
**pParent
);
883 HRESULT WINAPI
IWineD3DSurfaceImpl_GetDevice(IWineD3DSurface
*iface
, IWineD3DDevice
** ppDevice
);
884 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPrivateData(IWineD3DSurface
*iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
);
885 HRESULT WINAPI
IWineD3DSurfaceImpl_GetPrivateData(IWineD3DSurface
*iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
);
886 HRESULT WINAPI
IWineD3DSurfaceImpl_FreePrivateData(IWineD3DSurface
*iface
, REFGUID refguid
);
887 DWORD WINAPI
IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface
*iface
, DWORD PriorityNew
);
888 DWORD WINAPI
IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface
*iface
);
889 void WINAPI
IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface
*iface
);
890 WINED3DRESOURCETYPE WINAPI
IWineD3DSurfaceImpl_GetType(IWineD3DSurface
*iface
);
891 HRESULT WINAPI
IWineD3DSurfaceImpl_GetContainerParent(IWineD3DSurface
* iface
, IUnknown
**ppContainerParent
);
892 HRESULT WINAPI
IWineD3DSurfaceImpl_GetContainer(IWineD3DSurface
* iface
, REFIID riid
, void** ppContainer
);
893 HRESULT WINAPI
IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface
*iface
, WINED3DSURFACE_DESC
*pDesc
);
894 HRESULT WINAPI
IWineD3DSurfaceImpl_GetBltStatus(IWineD3DSurface
*iface
, DWORD Flags
);
895 HRESULT WINAPI
IWineD3DSurfaceImpl_GetFlipStatus(IWineD3DSurface
*iface
, DWORD Flags
);
896 HRESULT WINAPI
IWineD3DSurfaceImpl_IsLost(IWineD3DSurface
*iface
);
897 HRESULT WINAPI
IWineD3DSurfaceImpl_Restore(IWineD3DSurface
*iface
);
898 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface
*iface
, WINED3DFORMAT Format
, BYTE
*Surface
, DWORD Size
);
899 HRESULT WINAPI
IWineD3DSurfaceImpl_GetPalette(IWineD3DSurface
*iface
, IWineD3DPalette
**Pal
);
900 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface
*iface
, IWineD3DPalette
*Pal
);
901 HRESULT WINAPI
IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface
*iface
, DWORD Flags
, DDCOLORKEY
*CKey
);
902 HRESULT WINAPI
IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface
*iface
);
903 extern HRESULT WINAPI
IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface
*iface
, CONST RECT
* pDirtyRect
);
904 HRESULT WINAPI
IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface
*iface
, IWineD3DBase
*container
);
905 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPBufferState(IWineD3DSurface
*iface
, BOOL inPBuffer
, BOOL inTexture
);
906 void WINAPI
IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface
*iface
, UINT textureName
, int target
);
907 void WINAPI
IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface
*iface
, glDescriptor
**glDescription
);
908 const void *WINAPI
IWineD3DSurfaceImpl_GetData(IWineD3DSurface
*iface
);
909 HRESULT WINAPI
IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface
*iface
, WINED3DFORMAT format
);
910 HRESULT WINAPI
IWineGDISurfaceImpl_Blt(IWineD3DSurface
*iface
, RECT
*DestRect
, IWineD3DSurface
*SrcSurface
, RECT
*SrcRect
, DWORD Flags
, DDBLTFX
*DDBltFx
);
911 HRESULT WINAPI
IWineGDISurfaceImpl_BltFast(IWineD3DSurface
*iface
, DWORD dstx
, DWORD dsty
, IWineD3DSurface
*Source
, RECT
*rsrc
, DWORD trans
);
912 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface
*iface
, IWineD3DPalette
*Pal
);
913 HRESULT WINAPI
IWineD3DSurfaceImpl_GetDC(IWineD3DSurface
*iface
, HDC
*pHDC
);
914 HRESULT WINAPI
IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface
*iface
, HDC hDC
);
915 DWORD WINAPI
IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface
*iface
);
916 HRESULT WINAPI
IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface
*iface
);
919 #define SFLAG_OVERSIZE 0x0001 /* Surface is bigger than gl size, blts only */
920 #define SFLAG_CONVERTED 0x0002 /* Converted for color keying or Palettized */
921 #define SFLAG_DIBSECTION 0x0004 /* Has a DIB section attached for getdc */
922 #define SFLAG_DIRTY 0x0008 /* Surface was locked by the app */
923 #define SFLAG_LOCKABLE 0x0010 /* Surface can be locked */
924 #define SFLAG_DISCARD 0x0020 /* ??? */
925 #define SFLAG_LOCKED 0x0040 /* Surface is locked atm */
926 #define SFLAG_ACTIVELOCK 0x0080 /* Not locked, but surface memory is needed */
927 #define SFLAG_INTEXTURE 0x0100 /* ??? */
928 #define SFLAG_INPBUFFER 0x0200 /* ??? */
929 #define SFLAG_NONPOW2 0x0400 /* Surface sizes are not a power of 2 */
930 #define SFLAG_DYNLOCK 0x0800 /* Surface is often locked by the app */
931 #define SFLAG_DYNCHANGE 0x1800 /* Surface contents are changed very often, implies DYNLOCK */
932 #define SFLAG_DCINUSE 0x2000 /* Set between GetDC and ReleaseDC calls */
933 #define SFLAG_GLDIRTY 0x4000 /* The opengl texture is more up to date than the surface mem */
934 #define SFLAG_LOST 0x8000 /* Surface lost flag for DDraw */
936 /* In some conditions the surface memory must not be freed:
937 * SFLAG_OVERSIZE: Not all data can be kept in GL
938 * SFLAG_CONVERTED: Converting the data back would take too long
939 * SFLAG_DIBSECTION: The dib code manages the memory
940 * SFLAG_DIRTY: GL surface isn't up to date
941 * SFLAG_LOCKED: The app requires access to the surface data
942 * SFLAG_ACTIVELOCK: Some wined3d code needs the memory
943 * SFLAG_DYNLOCK: Avoid freeing the data for performance
944 * SFLAG_DYNCHANGE: Same reason as DYNLOCK
946 #define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
955 BOOL
CalculateTexRect(IWineD3DSurfaceImpl
*This
, RECT
*Rect
, float glTexCoord
[4]);
957 /*****************************************************************************
958 * IWineD3DVertexDeclaration implementation structure
960 typedef struct IWineD3DVertexDeclarationImpl
{
961 /* IUnknown Information */
962 const IWineD3DVertexDeclarationVtbl
*lpVtbl
;
963 LONG ref
; /* Note: Ref counting not required */
966 /** precomputed fvf if simple declaration */
967 IWineD3DDeviceImpl
*wineD3DDevice
;
968 DWORD fvf
[MAX_STREAMS
];
971 /** dx8 compatible Declaration fields */
972 DWORD
* pDeclaration8
;
973 DWORD declaration8Length
;
976 D3DVERTEXELEMENT9
*pDeclaration9
;
977 UINT declaration9NumElements
;
979 WINED3DVERTEXELEMENT
*pDeclarationWine
;
980 UINT declarationWNumElements
;
984 } IWineD3DVertexDeclarationImpl
;
986 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl
;
988 /*****************************************************************************
989 * IWineD3DStateBlock implementation structure
992 /* Internal state Block for Begin/End/Capture/Create/Apply info */
993 /* Note: Very long winded but gl Lists are not flexible enough */
994 /* to resolve everything we need, so doing it manually for now */
995 typedef struct SAVEDSTATES
{
999 BOOL streamSource
[MAX_STREAMS
];
1000 BOOL streamFreq
[MAX_STREAMS
];
1001 BOOL textures
[MAX_TEXTURES
];
1002 BOOL transform
[HIGHEST_TRANSFORMSTATE
+ 1];
1004 BOOL renderState
[WINEHIGHEST_RENDER_STATE
+ 1];
1005 BOOL textureState
[MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
1006 BOOL samplerState
[MAX_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
1007 BOOL clipplane
[MAX_CLIPPLANES
];
1010 BOOL pixelShaderConstants
[MAX_PSHADER_CONSTANTS
];
1012 BOOL vertexShaderConstants
[MAX_VSHADER_CONSTANTS
];
1016 WINESHADERCNST_NONE
= 0,
1017 WINESHADERCNST_FLOAT
= 1,
1018 WINESHADERCNST_INTEGER
= 2,
1019 WINESHADERCNST_BOOL
= 3
1022 struct IWineD3DStateBlockImpl
1024 /* IUnknown fields */
1025 const IWineD3DStateBlockVtbl
*lpVtbl
;
1026 LONG ref
; /* Note: Ref counting not required */
1028 /* IWineD3DStateBlock information */
1030 IWineD3DDeviceImpl
*wineD3DDevice
;
1031 WINED3DSTATEBLOCKTYPE blockType
;
1033 /* Array indicating whether things have been set or changed */
1034 SAVEDSTATES changed
;
1037 /* Drawing - Vertex Shader or FVF related */
1039 /* Vertex Shader Declaration */
1040 IWineD3DVertexDeclaration
*vertexDecl
;
1042 IWineD3DVertexShader
*vertexShader
;
1044 /* Vertex Shader Constants */
1045 BOOL vertexShaderConstantB
[MAX_VSHADER_CONSTANTS
];
1046 INT vertexShaderConstantI
[MAX_VSHADER_CONSTANTS
* 4];
1047 float vertexShaderConstantF
[MAX_VSHADER_CONSTANTS
* 4];
1048 WINESHADERCNST vertexShaderConstantT
[MAX_VSHADER_CONSTANTS
]; /* TODO: Think about changing this to a char to possibly save a little memory */
1052 UINT streamStride
[MAX_STREAMS
];
1053 UINT streamOffset
[MAX_STREAMS
];
1054 IWineD3DVertexBuffer
*streamSource
[MAX_STREAMS
];
1055 UINT streamFreq
[MAX_STREAMS
];
1056 UINT streamFlags
[MAX_STREAMS
]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
1059 IWineD3DIndexBuffer
* pIndexData
;
1060 UINT baseVertexIndex
; /* Note: only used for d3d8 */
1063 D3DMATRIX transforms
[HIGHEST_TRANSFORMSTATE
+ 1];
1066 PLIGHTINFOEL
*lights
; /* NOTE: active GL lights must be front of the chain */
1069 double clipplane
[MAX_CLIPPLANES
][4];
1070 WINED3DCLIPSTATUS clip_status
;
1073 WINED3DVIEWPORT viewport
;
1076 WINED3DMATERIAL material
;
1079 IWineD3DPixelShader
*pixelShader
;
1081 /* Pixel Shader Constants */
1082 BOOL pixelShaderConstantB
[MAX_PSHADER_CONSTANTS
];
1083 INT pixelShaderConstantI
[MAX_PSHADER_CONSTANTS
* 4];
1084 float pixelShaderConstantF
[MAX_PSHADER_CONSTANTS
* 4];
1085 WINESHADERCNST pixelShaderConstantT
[MAX_PSHADER_CONSTANTS
]; /* TODO: Think about changing this to a char to possibly save a little memory */
1087 /* Indexed Vertex Blending */
1088 D3DVERTEXBLENDFLAGS vertex_blend
;
1092 DWORD renderState
[WINEHIGHEST_RENDER_STATE
+ 1];
1095 IWineD3DBaseTexture
*textures
[MAX_TEXTURES
];
1096 int textureDimensions
[MAX_SAMPLERS
];
1098 /* Texture State Stage */
1099 DWORD textureState
[MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
1100 /* Sampler States */
1101 DWORD samplerState
[MAX_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
1105 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl
;
1107 /*****************************************************************************
1108 * IWineD3DQueryImpl implementation structure (extends IUnknown)
1110 typedef struct IWineD3DQueryImpl
1112 const IWineD3DQueryVtbl
*lpVtbl
;
1113 LONG ref
; /* Note: Ref counting not required */
1116 /*TODO: replace with iface usage */
1118 IWineD3DDevice
*wineD3DDevice
;
1120 IWineD3DDeviceImpl
*wineD3DDevice
;
1122 /* IWineD3DQuery fields */
1125 /* TODO: Think about using a IUnknown instead of a void* */
1129 } IWineD3DQueryImpl
;
1131 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl
;
1133 /* Datastructures for IWineD3DQueryImpl.extendedData */
1134 typedef struct WineQueryOcclusionData
{
1135 unsigned int queryId
;
1136 } WineQueryOcclusionData
;
1139 /*****************************************************************************
1140 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
1143 typedef struct IWineD3DSwapChainImpl
1146 IWineD3DSwapChainVtbl
*lpVtbl
;
1147 LONG ref
; /* Note: Ref counting not required */
1150 IWineD3DDeviceImpl
*wineD3DDevice
;
1152 /* IWineD3DSwapChain fields */
1153 IWineD3DSurface
*backBuffer
;
1154 IWineD3DSurface
*frontBuffer
;
1155 BOOL wantsDepthStencilBuffer
;
1156 D3DPRESENT_PARAMETERS presentParms
;
1158 /* TODO: move everything up to drawable off into a context manager
1159 and store the 'data' in the contextManagerData interface.
1160 IUnknown *contextManagerData;
1168 XVisualInfo
*visInfo
;
1169 GLXContext render_ctx
;
1170 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1172 } IWineD3DSwapChainImpl
;
1174 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl
;
1176 /*****************************************************************************
1177 * Utility function prototypes
1180 /* Trace routines */
1181 const char* debug_d3dformat(WINED3DFORMAT fmt
);
1182 const char* debug_d3ddevicetype(D3DDEVTYPE devtype
);
1183 const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res
);
1184 const char* debug_d3dusage(DWORD usage
);
1185 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType
);
1186 const char* debug_d3drenderstate(DWORD state
);
1187 const char* debug_d3dtexturestate(DWORD state
);
1188 const char* debug_d3dpool(WINED3DPOOL pool
);
1190 /* Routines for GL <-> D3D values */
1191 GLenum
StencilOp(DWORD op
);
1192 void set_tex_op(IWineD3DDevice
*iface
, BOOL isAlpha
, int Stage
, D3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
);
1193 void set_texture_matrix(const float *smat
, DWORD flags
, BOOL calculatedCoords
);
1194 void GetSrcAndOpFromValue(DWORD iValue
, BOOL isAlphaArg
, GLenum
* source
, GLenum
* operand
);
1196 SHORT
D3DFmtGetBpp(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1197 GLenum
D3DFmt2GLFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1198 GLenum
D3DFmt2GLType(IWineD3DDeviceImpl
*This
, D3DFORMAT fmt
);
1199 GLint
D3DFmt2GLIntFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1201 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat
, D3DFORMAT StencilBufferFormat
, int *attribs
, int* nAttribs
, BOOL alternate
);
1204 void multiply_matrix(D3DMATRIX
*dest
, D3DMATRIX
*src1
, D3DMATRIX
*src2
);
1206 /*****************************************************************************
1207 * To enable calling of inherited functions, requires prototypes
1209 * Note: Only require classes which are subclassed, ie resource, basetexture,
1211 /*** IUnknown methods ***/
1212 extern HRESULT WINAPI
IWineD3DResourceImpl_QueryInterface(IWineD3DResource
*iface
, REFIID riid
, void** ppvObject
);
1213 extern ULONG WINAPI
IWineD3DResourceImpl_AddRef(IWineD3DResource
*iface
);
1214 extern ULONG WINAPI
IWineD3DResourceImpl_Release(IWineD3DResource
*iface
);
1215 /*** IWineD3DResource methods ***/
1216 extern HRESULT WINAPI
IWineD3DResourceImpl_GetParent(IWineD3DResource
*iface
, IUnknown
**pParent
);
1217 extern HRESULT WINAPI
IWineD3DResourceImpl_GetDevice(IWineD3DResource
*iface
, IWineD3DDevice
** ppDevice
);
1218 extern HRESULT WINAPI
IWineD3DResourceImpl_SetPrivateData(IWineD3DResource
*iface
, REFGUID refguid
, CONST
void * pData
, DWORD SizeOfData
, DWORD Flags
);
1219 extern HRESULT WINAPI
IWineD3DResourceImpl_GetPrivateData(IWineD3DResource
*iface
, REFGUID refguid
, void * pData
, DWORD
* pSizeOfData
);
1220 extern HRESULT WINAPI
IWineD3DResourceImpl_FreePrivateData(IWineD3DResource
*iface
, REFGUID refguid
);
1221 extern DWORD WINAPI
IWineD3DResourceImpl_SetPriority(IWineD3DResource
*iface
, DWORD PriorityNew
);
1222 extern DWORD WINAPI
IWineD3DResourceImpl_GetPriority(IWineD3DResource
*iface
);
1223 extern void WINAPI
IWineD3DResourceImpl_PreLoad(IWineD3DResource
*iface
);
1224 extern WINED3DRESOURCETYPE WINAPI
IWineD3DResourceImpl_GetType(IWineD3DResource
*iface
);
1225 /*** class static members ***/
1226 void IWineD3DResourceImpl_CleanUp(IWineD3DResource
*iface
);
1228 /*** IUnknown methods ***/
1229 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture
*iface
, REFIID riid
, void** ppvObject
);
1230 extern ULONG WINAPI
IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture
*iface
);
1231 extern ULONG WINAPI
IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture
*iface
);
1232 /*** IWineD3DResource methods ***/
1233 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture
*iface
, IUnknown
**pParent
);
1234 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture
*iface
, IWineD3DDevice
** ppDevice
);
1235 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
, CONST
void * pData
, DWORD SizeOfData
, DWORD Flags
);
1236 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
, void * pData
, DWORD
* pSizeOfData
);
1237 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
);
1238 extern DWORD WINAPI
IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture
*iface
, DWORD PriorityNew
);
1239 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture
*iface
);
1240 extern void WINAPI
IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture
*iface
);
1241 extern WINED3DRESOURCETYPE WINAPI
IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture
*iface
);
1242 /*** IWineD3DBaseTexture methods ***/
1243 extern DWORD WINAPI
IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture
*iface
, DWORD LODNew
);
1244 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture
*iface
);
1245 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture
*iface
);
1246 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture
*iface
, WINED3DTEXTUREFILTERTYPE FilterType
);
1247 extern WINED3DTEXTUREFILTERTYPE WINAPI
IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture
*iface
);
1248 extern void WINAPI
IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture
*iface
);
1249 extern BOOL WINAPI
IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture
*iface
, BOOL
);
1250 extern BOOL WINAPI
IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture
*iface
);
1252 extern BYTE
* WINAPI
IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer
* iface
, DWORD iOffset
);
1253 extern HRESULT WINAPI
IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer
* iface
);
1254 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture
*iface
);
1255 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture
*iface
);
1256 extern void WINAPI
IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture
*iface
, const DWORD textureStates
[WINED3D_HIGHEST_TEXTURE_STATE
+ 1], const DWORD samplerStates
[WINED3D_HIGHEST_SAMPLER_STATE
+ 1]);
1257 /*** class static members ***/
1258 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture
*iface
);
1260 /* An enum for the type of constants that are used... addressing causes
1261 * problems with being able to work out what's used and what's not.. so
1262 * maybe we'll have to rely on the server vertex shader const functions?
1264 enum vsConstantsEnum
{
1265 VS_CONSTANT_NOT_USED
= 0,
1266 VS_CONSTANT_CONSTANT
,
1267 VS_CONSTANT_INTEGER
,
1268 VS_CONSTANT_BOOLEAN
,
1272 struct SHADER_OPCODE_ARG
;
1273 typedef void (*shader_fct_t
)();
1274 typedef void (*SHADER_HANDLER
) (struct SHADER_OPCODE_ARG
*);
1277 /* This must be 0 in the main branch until GLSL is at least mostly implemented.
1278 Also, think about making it a winecfg option to use GLSL (if the card supports it)
1279 or ARB_vertex_program. Ideally, we want to use GLSL if it's available, but until
1280 everything is implemented, we'll probably have better luck with the ARB generation */
1281 #define USING_GLSL 0
1283 #define SHADER_PGMSIZE 65535
1284 typedef struct SHADER_BUFFER
{
1287 unsigned int lineNo
;
1290 typedef struct SHADER_OPCODE
{
1291 unsigned int opcode
;
1294 CONST UINT num_params
;
1295 shader_fct_t soft_fct
;
1296 SHADER_HANDLER hw_fct
;
1297 SHADER_HANDLER hw_glsl_fct
;
1302 typedef struct SHADER_OPCODE_ARG
{
1303 IWineD3DBaseShader
* shader
;
1304 CONST SHADER_OPCODE
* opcode
;
1310 SHADER_BUFFER
* buffer
;
1311 } SHADER_OPCODE_ARG
;
1313 typedef struct SHADER_LIMITS
{
1314 unsigned int temporary
;
1315 unsigned int texture
;
1316 unsigned int constant_int
;
1317 unsigned int constant_float
;
1318 unsigned int constant_bool
;
1319 unsigned int address
;
1322 /** Keeps track of details for TEX_M#x# shader opcodes which need to
1323 maintain state information between multiple codes */
1324 typedef struct SHADER_PARSE_STATE
{
1325 unsigned int current_row
;
1326 DWORD texcoord_w
[2];
1327 } SHADER_PARSE_STATE
;
1329 /* Base Shader utility functions.
1330 * (may move callers into the same file in the future) */
1331 extern int shader_addline(
1332 SHADER_BUFFER
* buffer
,
1333 const char* fmt
, ...);
1335 extern const SHADER_OPCODE
* shader_get_opcode(
1336 IWineD3DBaseShader
*iface
,
1339 /*****************************************************************************
1340 * IDirect3DBaseShader implementation structure
1342 typedef struct IWineD3DBaseShaderClass
1346 SHADER_LIMITS limits
;
1347 SHADER_PARSE_STATE parse_state
;
1348 CONST SHADER_OPCODE
*shader_ins
;
1349 CONST DWORD
*function
;
1350 UINT functionLength
;
1352 } IWineD3DBaseShaderClass
;
1354 typedef struct IWineD3DBaseShaderImpl
{
1356 const IWineD3DBaseShaderVtbl
*lpVtbl
;
1359 /* IWineD3DBaseShader */
1360 IWineD3DBaseShaderClass baseShader
;
1361 } IWineD3DBaseShaderImpl
;
1363 extern void shader_program_dump_decl_usage(
1367 extern void generate_base_shader(
1368 IWineD3DBaseShader
*iface
,
1369 SHADER_BUFFER
* buffer
,
1370 CONST DWORD
* pFunction
);
1372 extern void shader_dump_ins_modifiers(
1373 const DWORD output
);
1375 extern void shader_dump_param(
1376 IWineD3DBaseShader
*iface
,
1378 const DWORD addr_token
,
1381 extern int shader_get_param(
1382 IWineD3DBaseShader
* iface
,
1383 const DWORD
* pToken
,
1387 extern int shader_skip_unrecognized(
1388 IWineD3DBaseShader
* iface
,
1389 const DWORD
* pToken
);
1391 inline static int shader_get_regtype(const DWORD param
) {
1392 return (((param
& D3DSP_REGTYPE_MASK
) >> D3DSP_REGTYPE_SHIFT
) |
1393 ((param
& D3DSP_REGTYPE_MASK2
) >> D3DSP_REGTYPE_SHIFT2
));
1396 inline static BOOL
shader_is_pshader_version(DWORD token
) {
1397 return 0xFFFF0000 == (token
& 0xFFFF0000);
1400 inline static BOOL
shader_is_vshader_version(DWORD token
) {
1401 return 0xFFFE0000 == (token
& 0xFFFF0000);
1404 inline static BOOL
shader_is_comment(DWORD token
) {
1405 return D3DSIO_COMMENT
== (token
& D3DSI_OPCODE_MASK
);
1408 /*****************************************************************************
1409 * IDirect3DVertexShader implementation structure
1411 typedef struct IWineD3DVertexShaderImpl
{
1413 const IWineD3DVertexShaderVtbl
*lpVtbl
;
1414 LONG ref
; /* Note: Ref counting not required */
1416 /* IWineD3DBaseShader */
1417 IWineD3DBaseShaderClass baseShader
;
1419 /* IWineD3DVertexShaderImpl */
1421 IWineD3DDeviceImpl
*wineD3DDevice
;
1425 /* vertex declaration array mapping */
1426 BOOL namedArrays
; /* don't map use named functions */
1427 BOOL declaredArrays
; /* mapping requires */
1428 INT arrayUsageMap
[WINED3DSHADERDECLUSAGE_MAX_USAGE
]; /* lookup table for the maps */
1429 INT highestConstant
;
1430 CHAR constantsUsedBitmap
[256];
1431 /* 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 */
1432 /* run time datas... */
1434 IWineD3DVertexDeclaration
*vertexDeclaration
;
1435 #if 0 /* needs reworking */
1436 /* run time datas */
1437 VSHADERINPUTDATA input
;
1438 VSHADEROUTPUTDATA output
;
1440 } IWineD3DVertexShaderImpl
;
1441 extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins
[];
1442 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl
;
1444 /*****************************************************************************
1445 * IDirect3DPixelShader implementation structure
1447 typedef struct IWineD3DPixelShaderImpl
{
1448 /* IUnknown parts */
1449 const IWineD3DPixelShaderVtbl
*lpVtbl
;
1450 LONG ref
; /* Note: Ref counting not required */
1452 /* IWineD3DBaseShader */
1453 IWineD3DBaseShaderClass baseShader
;
1455 /* IWineD3DPixelShaderImpl */
1457 IWineD3DDeviceImpl
*wineD3DDevice
;
1459 CHAR constants
[WINED3D_PSHADER_MAX_CONSTANTS
];
1464 #if 0 /* needs reworking */
1465 PSHADERINPUTDATA input
;
1466 PSHADEROUTPUTDATA output
;
1468 } IWineD3DPixelShaderImpl
;
1470 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins
[];
1471 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl
;
1473 /*****************************************************************************
1474 * IWineD3DPalette implementation structure
1476 struct IWineD3DPaletteImpl
{
1477 /* IUnknown parts */
1478 const IWineD3DPaletteVtbl
*lpVtbl
;
1482 IWineD3DDeviceImpl
*wineD3DDevice
;
1484 /* IWineD3DPalette */
1486 WORD palVersion
; /*| */
1487 WORD palNumEntries
; /*| LOGPALETTE */
1488 PALETTEENTRY palents
[256]; /*| */
1489 /* This is to store the palette in 'screen format' */
1490 int screen_palents
[256];
1494 extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl
;
1495 DWORD
IWineD3DPaletteImpl_Size(DWORD dwFlags
);
1497 /* DirectDraw utility functions */
1498 extern WINED3DFORMAT
pixelformat_for_depth(DWORD depth
);
1499 LONG
get_bitmask_red(WINED3DFORMAT fmt
);
1500 LONG
get_bitmask_green(WINED3DFORMAT fmt
);
1501 LONG
get_bitmask_blue(WINED3DFORMAT fmt
);
1502 LONG
get_bitmask_alpha(WINED3DFORMAT fmt
);
1503 BOOL
isFourcc(WINED3DFORMAT fmt
);