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"
45 #include "wine/list.h"
48 #define MAX_PALETTES 256
49 #define MAX_STREAMS 16
50 #define MAX_TEXTURES 8
51 #define MAX_SAMPLERS 16
52 #define MAX_ACTIVE_LIGHTS 8
53 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
54 #define MAX_LEVELS 256
56 #define MAX_VSHADER_CONSTANTS 96
57 #define MAX_PSHADER_CONSTANTS 32
59 /* Used for CreateStateBlock */
60 #define NUM_SAVEDPIXELSTATES_R 35
61 #define NUM_SAVEDPIXELSTATES_T 18
62 #define NUM_SAVEDPIXELSTATES_S 12
63 #define NUM_SAVEDVERTEXSTATES_R 31
64 #define NUM_SAVEDVERTEXSTATES_T 2
65 #define NUM_SAVEDVERTEXSTATES_S 1
67 extern const DWORD SavedPixelStates_R
[NUM_SAVEDPIXELSTATES_R
];
68 extern const DWORD SavedPixelStates_T
[NUM_SAVEDPIXELSTATES_T
];
69 extern const DWORD SavedPixelStates_S
[NUM_SAVEDPIXELSTATES_S
];
70 extern const DWORD SavedVertexStates_R
[NUM_SAVEDVERTEXSTATES_R
];
71 extern const DWORD SavedVertexStates_T
[NUM_SAVEDVERTEXSTATES_T
];
72 extern const DWORD SavedVertexStates_S
[NUM_SAVEDVERTEXSTATES_S
];
74 typedef enum _WINELOOKUP
{
75 WINELOOKUP_WARPPARAM
= 0,
76 WINELOOKUP_MAGFILTER
= 1,
80 extern int minLookup
[MAX_LOOKUPS
];
81 extern int maxLookup
[MAX_LOOKUPS
];
82 extern DWORD
*stateLookup
[MAX_LOOKUPS
];
84 extern DWORD minMipLookup
[D3DTEXF_ANISOTROPIC
+ 1][D3DTEXF_LINEAR
+ 1];
86 typedef struct _WINED3DGLTYPE
{
94 /* NOTE: Make sure these are in the correct numerical order. (see /include/d3d9types.h typedef enum _D3DDECLTYPE) */
95 WINED3DGLTYPE
static const glTypeLookup
[D3DDECLTYPE_UNUSED
] = {
96 {D3DDECLTYPE_FLOAT1
, 1, GL_FLOAT
, GL_FALSE
,sizeof(float)},
97 {D3DDECLTYPE_FLOAT2
, 2, GL_FLOAT
, GL_FALSE
,sizeof(float)},
98 {D3DDECLTYPE_FLOAT3
, 3, GL_FLOAT
, GL_FALSE
,sizeof(float)},
99 {D3DDECLTYPE_FLOAT4
, 4, GL_FLOAT
, GL_FALSE
,sizeof(float)},
100 {D3DDECLTYPE_D3DCOLOR
, 4, GL_UNSIGNED_BYTE
, GL_TRUE
,sizeof(BYTE
)},
101 {D3DDECLTYPE_UBYTE4
, 4, GL_UNSIGNED_BYTE
, GL_FALSE
,sizeof(BYTE
)},
102 {D3DDECLTYPE_SHORT2
, 2, GL_SHORT
, GL_FALSE
,sizeof(short int)},
103 {D3DDECLTYPE_SHORT4
, 4, GL_SHORT
, GL_FALSE
,sizeof(short int)},
104 {D3DDECLTYPE_UBYTE4N
, 4, GL_UNSIGNED_BYTE
, GL_FALSE
,sizeof(BYTE
)},
105 {D3DDECLTYPE_SHORT2N
, 2, GL_SHORT
, GL_FALSE
,sizeof(short int)},
106 {D3DDECLTYPE_SHORT4N
, 4, GL_SHORT
, GL_FALSE
,sizeof(short int)},
107 {D3DDECLTYPE_USHORT2N
, 2, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
108 {D3DDECLTYPE_USHORT4N
, 4, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
109 {D3DDECLTYPE_UDEC3
, 3, GL_UNSIGNED_SHORT
, GL_FALSE
,sizeof(short int)},
110 {D3DDECLTYPE_DEC3N
, 3, GL_SHORT
, GL_FALSE
,sizeof(short int)},
111 {D3DDECLTYPE_FLOAT16_2
, 2, GL_FLOAT
, GL_FALSE
,sizeof(short int)},
112 {D3DDECLTYPE_FLOAT16_4
, 4, GL_FLOAT
, GL_FALSE
,sizeof(short int)}};
114 #define WINED3D_ATR_TYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].d3dType
115 #define WINED3D_ATR_SIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].size
116 #define WINED3D_ATR_GLTYPE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].glType
117 #define WINED3D_ATR_NORMALIZED(_attribute) glTypeLookup[sd->u.s._attribute.dwType].normalized
118 #define WINED3D_ATR_TYPESIZE(_attribute) glTypeLookup[sd->u.s._attribute.dwType].typesize
138 #define SHADER_GLSL 2
140 typedef struct wined3d_settings_s
{
141 /* vertex and pixel shader modes */
145 /* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
146 we should use it. However, until it's fully implemented, we'll leave it as a registry
147 setting for developers. */
150 /* nonpower 2 function */
152 } wined3d_settings_t
;
154 extern wined3d_settings_t wined3d_settings
;
158 extern void (*wine_tsx11_lock_ptr
)(void);
159 extern void (*wine_tsx11_unlock_ptr
)(void);
161 /* As GLX relies on X, this is needed */
165 #define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
166 #define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
168 #define ENTER_GL() wine_tsx11_lock_ptr()
169 #define LEAVE_GL() wine_tsx11_unlock_ptr()
172 /*****************************************************************************
176 /* GL related defines */
177 /* ------------------ */
178 #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
179 #define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
180 #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
181 #define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
183 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
184 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
185 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
186 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
188 #define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
189 #define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
190 #define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
191 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
193 #define D3DCOLORTOGLFLOAT4(dw, vec) \
194 (vec)[0] = D3DCOLOR_R(dw); \
195 (vec)[1] = D3DCOLOR_G(dw); \
196 (vec)[2] = D3DCOLOR_B(dw); \
197 (vec)[3] = D3DCOLOR_A(dw);
199 #define GLTEXTURECUBEMAP GL_TEXTURE_CUBE_MAP_ARB
201 /* DirectX Device Limits */
202 /* --------------------- */
203 #define MAX_LEVELS 256 /* Maximum number of mipmap levels. Guessed at 256 */
205 #define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
206 See MaxStreams in MSDN under GetDeviceCaps */
207 /* Maximum number of constants provided to the shaders */
208 #define HIGHEST_TRANSFORMSTATE 512
209 /* Highest value in D3DTRANSFORMSTATETYPE */
210 #define MAX_CLIPPLANES D3DMAXUSERCLIPPLANES
212 #define MAX_PALETTES 256
214 /* Checking of API calls */
215 /* --------------------- */
216 #define checkGLcall(A) \
218 GLint err = glGetError(); \
219 if (err == GL_NO_ERROR) { \
220 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
223 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
224 err, A, __FILE__, __LINE__); \
225 err = glGetError(); \
226 } while (err != GL_NO_ERROR); \
229 /* Trace routines / diagnostics */
230 /* ---------------------------- */
232 /* Dump out a matrix and copy it */
233 #define conv_mat(mat,gl_mat) \
235 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
236 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
237 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
238 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
239 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
242 /* Macro to dump out the current state of the light chain */
243 #define DUMP_LIGHT_CHAIN() \
245 PLIGHTINFOEL *el = This->stateBlock->lights;\
247 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
252 /* Trace vector and strided data information */
253 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
254 #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);
256 /* Defines used for optimizations */
258 /* Only reapply what is necessary */
259 #define REAPPLY_ALPHAOP 0x0001
260 #define REAPPLY_ALL 0xFFFF
262 /* Advance declaration of structures to satisfy compiler */
263 typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl
;
264 typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl
;
265 typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl
;
269 /* TODO: Move some of this to the device */
270 long globalChangeGlRam(long glram
);
272 /* Memory and object tracking */
274 /*Structure for holding information on all direct3d objects
275 useful for making sure tracking is ok and when release is called on a device!
276 and probably quite handy for debugging and dumping states out
278 typedef struct WineD3DGlobalStatistics
{
279 int glsurfaceram
; /* The aproximate amount of glTexture memory allocated for textures */
280 } WineD3DGlobalStatistics
;
282 extern WineD3DGlobalStatistics
* wineD3DGlobalStatistics
;
284 /* Global variables */
285 extern const float identity
[16];
287 /*****************************************************************************
288 * Compilable extra diagnostics
291 /* Trace information per-vertex: (extremely high amount of trace) */
292 #if 0 /* NOTE: Must be 0 in cvs */
293 # define VTRACE(A) TRACE A
298 /* Checking of per-vertex related GL calls */
299 /* --------------------- */
300 #define vcheckGLcall(A) \
302 GLint err = glGetError(); \
303 if (err == GL_NO_ERROR) { \
304 VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
307 FIXME(">>>>>>>>>>>>>>>>> %x from %s @ %s / %d\n", \
308 err, A, __FILE__, __LINE__); \
309 err = glGetError(); \
310 } while (err != GL_NO_ERROR); \
313 /* TODO: Confirm each of these works when wined3d move completed */
314 #if 0 /* NOTE: Must be 0 in cvs */
315 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
316 of each frame, a check is made for the existence of C:\D3DTRACE, and if if exists d3d trace
317 is enabled, and if it doesn't exists it is disabled. */
318 # define FRAME_DEBUGGING
319 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
320 the file is deleted */
321 # if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
322 # define SINGLE_FRAME_DEBUGGING
324 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
325 It can only be enabled when FRAME_DEBUGGING is also enabled
326 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
328 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
329 # define SHOW_FRAME_MAKEUP 1
331 /* The following, when enabled, lets you see the makeup of the all the textures used during each
332 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
333 The contents of the textures assigned to each stage are written into
334 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
335 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
336 # define SHOW_TEXTURE_MAKEUP 0
339 extern BOOL isDumpingFrames
;
340 extern LONG primCounter
;
343 /*****************************************************************************
347 /* Routine common to the draw primitive and draw indexed primitive routines */
348 void drawPrimitive(IWineD3DDevice
*iface
,
352 long StartVertexIndex
,
353 UINT numberOfVertices
,
358 WineDirect3DVertexStridedData
*DrawPrimStrideData
);
360 void primitiveConvertToStridedData(IWineD3DDevice
*iface
,
361 WineDirect3DVertexStridedData
*strided
,
362 LONG BaseVertexIndex
);
364 DWORD
get_flexible_vertex_size(DWORD d3dvtVertexType
);
368 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
369 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
371 /* Routine to fill gl caps for swapchains and IWineD3D */
372 BOOL
IWineD3DImpl_FillGLCaps(WineD3D_GL_Info
*gl_info
,
375 /*****************************************************************************
376 * Internal representation of a light
378 typedef struct PLIGHTINFOEL PLIGHTINFOEL
;
379 struct PLIGHTINFOEL
{
380 WINED3DLIGHT OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
387 /* Converted parms to speed up swapping lights */
397 /* The default light parameters */
398 extern const WINED3DLIGHT WINED3D_default_light
;
400 /*****************************************************************************
401 * IWineD3D implementation structure
403 typedef struct IWineD3DImpl
405 /* IUnknown fields */
406 const IWineD3DVtbl
*lpVtbl
;
407 LONG ref
; /* Note: Ref counting not required */
409 /* WineD3D Information */
415 WineD3D_GL_Info gl_info
;
418 extern const IWineD3DVtbl IWineD3D_Vtbl
;
420 /** Hacked out start of a context manager!! **/
421 typedef struct glContext
{
428 IWineD3DSurface
*pSurface
;
429 #if 0 /* TODO: someway to represent the state of the context */
430 IWineD3DStateBlock
*pStateBlock
;
432 /* a few other things like format */
435 /* TODO: setup some flags in the regestry to enable, disable pbuffer support
436 (since it will break quite a few things until contexts are managed properly!) */
437 extern BOOL pbuffer_support
;
438 /* allocate one pbuffer per surface */
439 extern BOOL pbuffer_per_surface
;
441 /* Maximum number of contexts/pbuffers to keep in cache,
442 set to 100 because ATI's drivers don't support deleting pBuffers properly
443 this needs to be migrated to a list and some option availalbe for controle the cache size.
445 #define CONTEXT_CACHE 100
447 typedef struct ResourceList
{
448 IWineD3DResource
*resource
;
449 struct ResourceList
*next
;
452 /* A helper function that dumps a resource list */
453 void dumpResources(ResourceList
*resources
);
455 /*****************************************************************************
456 * IWineD3DDevice implementation structure
458 typedef struct IWineD3DDeviceImpl
460 /* IUnknown fields */
461 const IWineD3DDeviceVtbl
*lpVtbl
;
462 LONG ref
; /* Note: Ref counting not required */
464 /* WineD3D Information */
468 /* X and GL Information */
469 GLint maxConcurrentLights
;
472 BOOL modelview_valid
;
474 BOOL view_ident
; /* true iff view matrix is identity */
475 BOOL last_was_rhw
; /* true iff last draw_primitive was in xyzrhw mode */
476 BOOL viewport_changed
; /* Was the viewport changed since the last draw? */
477 GLenum tracking_parm
; /* Which source is tracking current colour */
478 LONG tracking_color
; /* used iff GL_COLOR_MATERIAL was enabled */
479 #define DISABLED_TRACKING 0 /* Disabled */
480 #define IS_TRACKING 1 /* tracking_parm is tracking diffuse color */
481 #define NEEDS_TRACKING 2 /* Tracking needs to be enabled when needed */
482 #define NEEDS_DISABLE 3 /* Tracking needs to be disabled when needed*/
487 BOOL texture_shader_active
; /* TODO: Confirm use is correct */
488 BOOL last_was_notclipped
;
490 /* State block related */
491 BOOL isRecordingState
;
492 IWineD3DStateBlockImpl
*stateBlock
;
493 IWineD3DStateBlockImpl
*updateStateBlock
;
495 /* Internal use fields */
496 WINED3DDEVICE_CREATION_PARAMETERS createParms
;
500 IWineD3DSwapChain
**swapchains
;
501 uint NumberOfSwapChains
;
503 ResourceList
*resources
; /* a linked list to track resources created by the device */
505 /* Render Target Support */
506 IWineD3DSurface
*depthStencilBuffer
;
508 IWineD3DSurface
*renderTarget
;
509 IWineD3DSurface
*stencilBufferTarget
;
511 /* palettes texture management */
512 PALETTEENTRY palettes
[MAX_PALETTES
][256];
515 /* For rendering to a texture using glCopyTexImage */
516 BOOL renderUpsideDown
;
518 /* Cursor management */
525 /* Textures for when no other textures are mapped */
526 UINT dummyTextureName
[MAX_TEXTURES
];
528 /* Debug stream management */
531 /* Device state management */
533 BOOL d3d_initialized
;
535 /* Screen buffer resources */
536 glContext contextCache
[CONTEXT_CACHE
];
538 /* A flag to check if endscene has been called before changing the render tartet */
541 /* process vertex shaders using software or hardware */
542 BOOL softwareVertexProcessing
;
544 /* DirectDraw stuff */
546 IWineD3DSurface
*ddraw_primary
;
547 DWORD ddraw_width
, ddraw_height
;
548 WINED3DFORMAT ddraw_format
;
550 /* List of GLSL shader programs and their associated vertex & pixel shaders */
551 struct list glsl_shader_progs
;
553 } IWineD3DDeviceImpl
;
555 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl
;
557 /* Support for IWineD3DResource ::Set/Get/FreePrivateData. I don't think
558 * anybody uses it for much so a good implementation is optional. */
559 typedef struct PrivateData
561 struct PrivateData
* next
;
564 DWORD flags
; /* DDSPD_* */
565 DWORD uniqueness_value
;
576 void d3ddevice_set_ortho(IWineD3DDeviceImpl
*This
);
578 /*****************************************************************************
579 * IWineD3DResource implementation structure
581 typedef struct IWineD3DResourceClass
583 /* IUnknown fields */
584 LONG ref
; /* Note: Ref counting not required */
586 /* WineD3DResource Information */
588 WINED3DRESOURCETYPE resourceType
;
589 IWineD3DDeviceImpl
*wineD3DDevice
;
593 WINED3DFORMAT format
;
594 BYTE
*allocatedMemory
;
595 PrivateData
*privateData
;
597 } IWineD3DResourceClass
;
599 typedef struct IWineD3DResourceImpl
601 /* IUnknown & WineD3DResource Information */
602 const IWineD3DResourceVtbl
*lpVtbl
;
603 IWineD3DResourceClass resource
;
604 } IWineD3DResourceImpl
;
607 /*****************************************************************************
608 * IWineD3DVertexBuffer implementation structure (extends IWineD3DResourceImpl)
610 typedef struct IWineD3DVertexBufferImpl
612 /* IUnknown & WineD3DResource Information */
613 const IWineD3DVertexBufferVtbl
*lpVtbl
;
614 IWineD3DResourceClass resource
;
616 /* WineD3DVertexBuffer specifics */
619 } IWineD3DVertexBufferImpl
;
621 extern const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl
;
624 /*****************************************************************************
625 * IWineD3DIndexBuffer implementation structure (extends IWineD3DResourceImpl)
627 typedef struct IWineD3DIndexBufferImpl
629 /* IUnknown & WineD3DResource Information */
630 const IWineD3DIndexBufferVtbl
*lpVtbl
;
631 IWineD3DResourceClass resource
;
633 /* WineD3DVertexBuffer specifics */
634 } IWineD3DIndexBufferImpl
;
636 extern const IWineD3DIndexBufferVtbl IWineD3DIndexBuffer_Vtbl
;
638 /*****************************************************************************
639 * IWineD3DBaseTexture D3D- > openGL state map lookups
641 #define WINED3DFUNC_NOTSUPPORTED -2
642 #define WINED3DFUNC_UNIMPLEMENTED -1
644 typedef enum winetexturestates
{
645 WINED3DTEXSTA_ADDRESSU
= 0,
646 WINED3DTEXSTA_ADDRESSV
= 1,
647 WINED3DTEXSTA_ADDRESSW
= 2,
648 WINED3DTEXSTA_BORDERCOLOR
= 3,
649 WINED3DTEXSTA_MAGFILTER
= 4,
650 WINED3DTEXSTA_MINFILTER
= 5,
651 WINED3DTEXSTA_MIPFILTER
= 6,
652 WINED3DTEXSTA_MAXMIPLEVEL
= 7,
653 WINED3DTEXSTA_MAXANISOTROPY
= 8,
654 WINED3DTEXSTA_SRGBTEXTURE
= 9,
655 WINED3DTEXSTA_ELEMENTINDEX
= 10,
656 WINED3DTEXSTA_DMAPOFFSET
= 11,
657 WINED3DTEXSTA_TSSADDRESSW
= 12,
658 MAX_WINETEXTURESTATES
= 13,
661 typedef struct Wined3dTextureStateMap
{
664 } Wined3dTextureStateMap
;
666 /*****************************************************************************
667 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
669 typedef struct IWineD3DBaseTextureClass
677 WINED3DTEXTUREFILTERTYPE filterType
;
678 DWORD states
[MAX_WINETEXTURESTATES
];
680 } IWineD3DBaseTextureClass
;
682 typedef struct IWineD3DBaseTextureImpl
684 /* IUnknown & WineD3DResource Information */
685 const IWineD3DBaseTextureVtbl
*lpVtbl
;
686 IWineD3DResourceClass resource
;
687 IWineD3DBaseTextureClass baseTexture
;
689 } IWineD3DBaseTextureImpl
;
691 /*****************************************************************************
692 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
694 typedef struct IWineD3DTextureImpl
696 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
697 const IWineD3DTextureVtbl
*lpVtbl
;
698 IWineD3DResourceClass resource
;
699 IWineD3DBaseTextureClass baseTexture
;
701 /* IWineD3DTexture */
702 IWineD3DSurface
*surfaces
[MAX_LEVELS
];
706 float pow2scalingFactorX
;
707 float pow2scalingFactorY
;
709 } IWineD3DTextureImpl
;
711 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl
;
713 /*****************************************************************************
714 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
716 typedef struct IWineD3DCubeTextureImpl
718 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
719 const IWineD3DCubeTextureVtbl
*lpVtbl
;
720 IWineD3DResourceClass resource
;
721 IWineD3DBaseTextureClass baseTexture
;
723 /* IWineD3DCubeTexture */
724 IWineD3DSurface
*surfaces
[6][MAX_LEVELS
];
727 float pow2scalingFactor
;
729 } IWineD3DCubeTextureImpl
;
731 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl
;
733 typedef struct _WINED3DVOLUMET_DESC
738 } WINED3DVOLUMET_DESC
;
740 /*****************************************************************************
741 * IWineD3DVolume implementation structure (extends IUnknown)
743 typedef struct IWineD3DVolumeImpl
745 /* IUnknown & WineD3DResource fields */
746 const IWineD3DVolumeVtbl
*lpVtbl
;
747 IWineD3DResourceClass resource
;
749 /* WineD3DVolume Information */
750 WINED3DVOLUMET_DESC currentDesc
;
751 IWineD3DBase
*container
;
756 WINED3DBOX lockedBox
;
761 } IWineD3DVolumeImpl
;
763 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl
;
765 /*****************************************************************************
766 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
768 typedef struct IWineD3DVolumeTextureImpl
770 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
771 const IWineD3DVolumeTextureVtbl
*lpVtbl
;
772 IWineD3DResourceClass resource
;
773 IWineD3DBaseTextureClass baseTexture
;
775 /* IWineD3DVolumeTexture */
776 IWineD3DVolume
*volumes
[MAX_LEVELS
];
781 } IWineD3DVolumeTextureImpl
;
783 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl
;
785 typedef struct _WINED3DSURFACET_DESC
787 WINED3DMULTISAMPLE_TYPE MultiSampleType
;
788 DWORD MultiSampleQuality
;
791 } WINED3DSURFACET_DESC
;
793 /*****************************************************************************
794 * Structure for DIB Surfaces (GetDC and GDI surfaces)
796 typedef struct wineD3DSurface_DIB
{
801 } wineD3DSurface_DIB
;
803 /*****************************************************************************
804 * IWineD3DSurface implementation structure
806 struct IWineD3DSurfaceImpl
808 /* IUnknown & IWineD3DResource Information */
809 const IWineD3DSurfaceVtbl
*lpVtbl
;
810 IWineD3DResourceClass resource
;
812 /* IWineD3DSurface fields */
813 IWineD3DBase
*container
;
814 WINED3DSURFACET_DESC currentDesc
;
815 IWineD3DPaletteImpl
*palette
;
820 /* TODO: move this off into a management class(maybe!) */
827 /* Oversized texture */
831 /* precalculated x and y scalings for texture coords */
832 float pow2scalingFactorX
; /* = (Width / pow2Width ) */
833 float pow2scalingFactorY
; /* = (Height / pow2Height) */
839 glDescriptor glDescription
;
842 wineD3DSurface_DIB dib
;
845 /* Color keys for DDraw */
846 DDCOLORKEY DestBltCKey
;
847 DDCOLORKEY DestOverlayCKey
;
848 DDCOLORKEY SrcOverlayCKey
;
849 DDCOLORKEY SrcBltCKey
;
854 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl
;
855 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl
;
857 /* Predeclare the shared Surface functions */
858 HRESULT WINAPI
IWineD3DSurfaceImpl_QueryInterface(IWineD3DSurface
*iface
, REFIID riid
, LPVOID
*ppobj
);
859 ULONG WINAPI
IWineD3DSurfaceImpl_AddRef(IWineD3DSurface
*iface
);
860 ULONG WINAPI
IWineD3DSurfaceImpl_Release(IWineD3DSurface
*iface
);
861 HRESULT WINAPI
IWineD3DSurfaceImpl_GetParent(IWineD3DSurface
*iface
, IUnknown
**pParent
);
862 HRESULT WINAPI
IWineD3DSurfaceImpl_GetDevice(IWineD3DSurface
*iface
, IWineD3DDevice
** ppDevice
);
863 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPrivateData(IWineD3DSurface
*iface
, REFGUID refguid
, CONST
void* pData
, DWORD SizeOfData
, DWORD Flags
);
864 HRESULT WINAPI
IWineD3DSurfaceImpl_GetPrivateData(IWineD3DSurface
*iface
, REFGUID refguid
, void* pData
, DWORD
* pSizeOfData
);
865 HRESULT WINAPI
IWineD3DSurfaceImpl_FreePrivateData(IWineD3DSurface
*iface
, REFGUID refguid
);
866 DWORD WINAPI
IWineD3DSurfaceImpl_SetPriority(IWineD3DSurface
*iface
, DWORD PriorityNew
);
867 DWORD WINAPI
IWineD3DSurfaceImpl_GetPriority(IWineD3DSurface
*iface
);
868 void WINAPI
IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface
*iface
);
869 WINED3DRESOURCETYPE WINAPI
IWineD3DSurfaceImpl_GetType(IWineD3DSurface
*iface
);
870 HRESULT WINAPI
IWineD3DSurfaceImpl_GetContainerParent(IWineD3DSurface
* iface
, IUnknown
**ppContainerParent
);
871 HRESULT WINAPI
IWineD3DSurfaceImpl_GetContainer(IWineD3DSurface
* iface
, REFIID riid
, void** ppContainer
);
872 HRESULT WINAPI
IWineD3DSurfaceImpl_GetDesc(IWineD3DSurface
*iface
, WINED3DSURFACE_DESC
*pDesc
);
873 HRESULT WINAPI
IWineD3DSurfaceImpl_GetBltStatus(IWineD3DSurface
*iface
, DWORD Flags
);
874 HRESULT WINAPI
IWineD3DSurfaceImpl_GetFlipStatus(IWineD3DSurface
*iface
, DWORD Flags
);
875 HRESULT WINAPI
IWineD3DSurfaceImpl_IsLost(IWineD3DSurface
*iface
);
876 HRESULT WINAPI
IWineD3DSurfaceImpl_Restore(IWineD3DSurface
*iface
);
877 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPixelFormat(IWineD3DSurface
*iface
, WINED3DFORMAT Format
, BYTE
*Surface
, DWORD Size
);
878 HRESULT WINAPI
IWineD3DSurfaceImpl_GetPalette(IWineD3DSurface
*iface
, IWineD3DPalette
**Pal
);
879 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface
*iface
, IWineD3DPalette
*Pal
);
880 HRESULT WINAPI
IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface
*iface
, DWORD Flags
, DDCOLORKEY
*CKey
);
881 HRESULT WINAPI
IWineD3DSurfaceImpl_CleanDirtyRect(IWineD3DSurface
*iface
);
882 extern HRESULT WINAPI
IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface
*iface
, CONST RECT
* pDirtyRect
);
883 HRESULT WINAPI
IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface
*iface
, IWineD3DBase
*container
);
884 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPBufferState(IWineD3DSurface
*iface
, BOOL inPBuffer
, BOOL inTexture
);
885 void WINAPI
IWineD3DSurfaceImpl_SetGlTextureDesc(IWineD3DSurface
*iface
, UINT textureName
, int target
);
886 void WINAPI
IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface
*iface
, glDescriptor
**glDescription
);
887 const void *WINAPI
IWineD3DSurfaceImpl_GetData(IWineD3DSurface
*iface
);
888 HRESULT WINAPI
IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface
*iface
, WINED3DFORMAT format
);
889 HRESULT WINAPI
IWineGDISurfaceImpl_Blt(IWineD3DSurface
*iface
, RECT
*DestRect
, IWineD3DSurface
*SrcSurface
, RECT
*SrcRect
, DWORD Flags
, DDBLTFX
*DDBltFx
);
890 HRESULT WINAPI
IWineGDISurfaceImpl_BltFast(IWineD3DSurface
*iface
, DWORD dstx
, DWORD dsty
, IWineD3DSurface
*Source
, RECT
*rsrc
, DWORD trans
);
891 HRESULT WINAPI
IWineD3DSurfaceImpl_SetPalette(IWineD3DSurface
*iface
, IWineD3DPalette
*Pal
);
892 HRESULT WINAPI
IWineD3DSurfaceImpl_GetDC(IWineD3DSurface
*iface
, HDC
*pHDC
);
893 HRESULT WINAPI
IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface
*iface
, HDC hDC
);
894 DWORD WINAPI
IWineD3DSurfaceImpl_GetPitch(IWineD3DSurface
*iface
);
895 HRESULT WINAPI
IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface
*iface
);
898 #define SFLAG_OVERSIZE 0x0001 /* Surface is bigger than gl size, blts only */
899 #define SFLAG_CONVERTED 0x0002 /* Converted for color keying or Palettized */
900 #define SFLAG_DIBSECTION 0x0004 /* Has a DIB section attached for getdc */
901 #define SFLAG_DIRTY 0x0008 /* Surface was locked by the app */
902 #define SFLAG_LOCKABLE 0x0010 /* Surface can be locked */
903 #define SFLAG_DISCARD 0x0020 /* ??? */
904 #define SFLAG_LOCKED 0x0040 /* Surface is locked atm */
905 #define SFLAG_ACTIVELOCK 0x0080 /* Not locked, but surface memory is needed */
906 #define SFLAG_INTEXTURE 0x0100 /* ??? */
907 #define SFLAG_INPBUFFER 0x0200 /* ??? */
908 #define SFLAG_NONPOW2 0x0400 /* Surface sizes are not a power of 2 */
909 #define SFLAG_DYNLOCK 0x0800 /* Surface is often locked by the app */
910 #define SFLAG_DYNCHANGE 0x1800 /* Surface contents are changed very often, implies DYNLOCK */
911 #define SFLAG_DCINUSE 0x2000 /* Set between GetDC and ReleaseDC calls */
912 #define SFLAG_GLDIRTY 0x4000 /* The opengl texture is more up to date than the surface mem */
913 #define SFLAG_LOST 0x8000 /* Surface lost flag for DDraw */
915 /* In some conditions the surface memory must not be freed:
916 * SFLAG_OVERSIZE: Not all data can be kept in GL
917 * SFLAG_CONVERTED: Converting the data back would take too long
918 * SFLAG_DIBSECTION: The dib code manages the memory
919 * SFLAG_DIRTY: GL surface isn't up to date
920 * SFLAG_LOCKED: The app requires access to the surface data
921 * SFLAG_ACTIVELOCK: Some wined3d code needs the memory
922 * SFLAG_DYNLOCK: Avoid freeing the data for performance
923 * SFLAG_DYNCHANGE: Same reason as DYNLOCK
925 #define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
934 BOOL
CalculateTexRect(IWineD3DSurfaceImpl
*This
, RECT
*Rect
, float glTexCoord
[4]);
936 /*****************************************************************************
937 * IWineD3DVertexDeclaration implementation structure
939 typedef struct IWineD3DVertexDeclarationImpl
{
940 /* IUnknown Information */
941 const IWineD3DVertexDeclarationVtbl
*lpVtbl
;
942 LONG ref
; /* Note: Ref counting not required */
945 /** precomputed fvf if simple declaration */
946 IWineD3DDeviceImpl
*wineD3DDevice
;
947 DWORD fvf
[MAX_STREAMS
];
950 /** dx8 compatible Declaration fields */
951 DWORD
* pDeclaration8
;
952 DWORD declaration8Length
;
955 D3DVERTEXELEMENT9
*pDeclaration9
;
956 UINT declaration9NumElements
;
958 WINED3DVERTEXELEMENT
*pDeclarationWine
;
959 UINT declarationWNumElements
;
963 } IWineD3DVertexDeclarationImpl
;
965 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl
;
967 /*****************************************************************************
968 * IWineD3DStateBlock implementation structure
971 /* Internal state Block for Begin/End/Capture/Create/Apply info */
972 /* Note: Very long winded but gl Lists are not flexible enough */
973 /* to resolve everything we need, so doing it manually for now */
974 typedef struct SAVEDSTATES
{
978 BOOL streamSource
[MAX_STREAMS
];
979 BOOL streamFreq
[MAX_STREAMS
];
980 BOOL textures
[MAX_TEXTURES
];
981 BOOL transform
[HIGHEST_TRANSFORMSTATE
+ 1];
983 BOOL renderState
[WINEHIGHEST_RENDER_STATE
+ 1];
984 BOOL textureState
[MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
985 BOOL samplerState
[MAX_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
986 BOOL clipplane
[MAX_CLIPPLANES
];
989 BOOL pixelShaderConstantsB
[MAX_PSHADER_CONSTANTS
];
990 BOOL pixelShaderConstantsI
[MAX_PSHADER_CONSTANTS
];
991 BOOL pixelShaderConstantsF
[MAX_PSHADER_CONSTANTS
];
993 BOOL vertexShaderConstantsB
[MAX_VSHADER_CONSTANTS
];
994 BOOL vertexShaderConstantsI
[MAX_VSHADER_CONSTANTS
];
995 BOOL vertexShaderConstantsF
[MAX_VSHADER_CONSTANTS
];
998 struct IWineD3DStateBlockImpl
1000 /* IUnknown fields */
1001 const IWineD3DStateBlockVtbl
*lpVtbl
;
1002 LONG ref
; /* Note: Ref counting not required */
1004 /* IWineD3DStateBlock information */
1006 IWineD3DDeviceImpl
*wineD3DDevice
;
1007 WINED3DSTATEBLOCKTYPE blockType
;
1009 /* Array indicating whether things have been set or changed */
1010 SAVEDSTATES changed
;
1013 /* Drawing - Vertex Shader or FVF related */
1015 /* Vertex Shader Declaration */
1016 IWineD3DVertexDeclaration
*vertexDecl
;
1018 IWineD3DVertexShader
*vertexShader
;
1020 /* Vertex Shader Constants */
1021 BOOL vertexShaderConstantB
[MAX_VSHADER_CONSTANTS
];
1022 INT vertexShaderConstantI
[MAX_VSHADER_CONSTANTS
* 4];
1023 float vertexShaderConstantF
[MAX_VSHADER_CONSTANTS
* 4];
1027 UINT streamStride
[MAX_STREAMS
];
1028 UINT streamOffset
[MAX_STREAMS
];
1029 IWineD3DVertexBuffer
*streamSource
[MAX_STREAMS
];
1030 UINT streamFreq
[MAX_STREAMS
];
1031 UINT streamFlags
[MAX_STREAMS
]; /*0 | D3DSTREAMSOURCE_INSTANCEDATA | D3DSTREAMSOURCE_INDEXEDDATA */
1034 IWineD3DIndexBuffer
* pIndexData
;
1035 UINT baseVertexIndex
; /* Note: only used for d3d8 */
1038 D3DMATRIX transforms
[HIGHEST_TRANSFORMSTATE
+ 1];
1041 PLIGHTINFOEL
*lights
; /* NOTE: active GL lights must be front of the chain */
1044 double clipplane
[MAX_CLIPPLANES
][4];
1045 WINED3DCLIPSTATUS clip_status
;
1048 WINED3DVIEWPORT viewport
;
1051 WINED3DMATERIAL material
;
1054 IWineD3DPixelShader
*pixelShader
;
1056 /* Pixel Shader Constants */
1057 BOOL pixelShaderConstantB
[MAX_PSHADER_CONSTANTS
];
1058 INT pixelShaderConstantI
[MAX_PSHADER_CONSTANTS
* 4];
1059 float pixelShaderConstantF
[MAX_PSHADER_CONSTANTS
* 4];
1061 /* Indexed Vertex Blending */
1062 D3DVERTEXBLENDFLAGS vertex_blend
;
1066 DWORD renderState
[WINEHIGHEST_RENDER_STATE
+ 1];
1069 IWineD3DBaseTexture
*textures
[MAX_TEXTURES
];
1070 int textureDimensions
[MAX_SAMPLERS
];
1072 /* Texture State Stage */
1073 DWORD textureState
[MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
1074 /* Sampler States */
1075 DWORD samplerState
[MAX_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
1077 /* Current GLSL Shader Program */
1078 GLhandleARB shaderPrgId
;
1081 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl
;
1083 /*****************************************************************************
1084 * IWineD3DQueryImpl implementation structure (extends IUnknown)
1086 typedef struct IWineD3DQueryImpl
1088 const IWineD3DQueryVtbl
*lpVtbl
;
1089 LONG ref
; /* Note: Ref counting not required */
1092 /*TODO: replace with iface usage */
1094 IWineD3DDevice
*wineD3DDevice
;
1096 IWineD3DDeviceImpl
*wineD3DDevice
;
1098 /* IWineD3DQuery fields */
1101 /* TODO: Think about using a IUnknown instead of a void* */
1105 } IWineD3DQueryImpl
;
1107 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl
;
1109 /* Datastructures for IWineD3DQueryImpl.extendedData */
1110 typedef struct WineQueryOcclusionData
{
1111 unsigned int queryId
;
1112 } WineQueryOcclusionData
;
1115 /*****************************************************************************
1116 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
1119 typedef struct IWineD3DSwapChainImpl
1122 IWineD3DSwapChainVtbl
*lpVtbl
;
1123 LONG ref
; /* Note: Ref counting not required */
1126 IWineD3DDeviceImpl
*wineD3DDevice
;
1128 /* IWineD3DSwapChain fields */
1129 IWineD3DSurface
*backBuffer
;
1130 IWineD3DSurface
*frontBuffer
;
1131 BOOL wantsDepthStencilBuffer
;
1132 D3DPRESENT_PARAMETERS presentParms
;
1134 /* TODO: move everything up to drawable off into a context manager
1135 and store the 'data' in the contextManagerData interface.
1136 IUnknown *contextManagerData;
1144 XVisualInfo
*visInfo
;
1145 GLXContext render_ctx
;
1146 /* This has been left in device for now, but needs moving off into a rendertarget management class and separated out from swapchains and devices. */
1148 } IWineD3DSwapChainImpl
;
1150 extern IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl
;
1152 /*****************************************************************************
1153 * Utility function prototypes
1156 /* Trace routines */
1157 const char* debug_d3dformat(WINED3DFORMAT fmt
);
1158 const char* debug_d3ddevicetype(D3DDEVTYPE devtype
);
1159 const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res
);
1160 const char* debug_d3dusage(DWORD usage
);
1161 const char* debug_d3dprimitivetype(D3DPRIMITIVETYPE PrimitiveType
);
1162 const char* debug_d3drenderstate(DWORD state
);
1163 const char* debug_d3dsamplerstate(DWORD state
);
1164 const char* debug_d3dtexturestate(DWORD state
);
1165 const char* debug_d3dpool(WINED3DPOOL pool
);
1167 /* Routines for GL <-> D3D values */
1168 GLenum
StencilOp(DWORD op
);
1169 void set_tex_op(IWineD3DDevice
*iface
, BOOL isAlpha
, int Stage
, D3DTEXTUREOP op
, DWORD arg1
, DWORD arg2
, DWORD arg3
);
1170 void set_texture_matrix(const float *smat
, DWORD flags
, BOOL calculatedCoords
);
1171 void GetSrcAndOpFromValue(DWORD iValue
, BOOL isAlphaArg
, GLenum
* source
, GLenum
* operand
);
1173 SHORT
D3DFmtGetBpp(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1174 GLenum
D3DFmt2GLFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1175 GLenum
D3DFmt2GLType(IWineD3DDeviceImpl
*This
, D3DFORMAT fmt
);
1176 GLint
D3DFmt2GLIntFmt(IWineD3DDeviceImpl
* This
, D3DFORMAT fmt
);
1178 int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat
, D3DFORMAT StencilBufferFormat
, int *attribs
, int* nAttribs
, BOOL alternate
);
1181 void multiply_matrix(D3DMATRIX
*dest
, D3DMATRIX
*src1
, D3DMATRIX
*src2
);
1183 /*****************************************************************************
1184 * To enable calling of inherited functions, requires prototypes
1186 * Note: Only require classes which are subclassed, ie resource, basetexture,
1188 /*** IUnknown methods ***/
1189 extern HRESULT WINAPI
IWineD3DResourceImpl_QueryInterface(IWineD3DResource
*iface
, REFIID riid
, void** ppvObject
);
1190 extern ULONG WINAPI
IWineD3DResourceImpl_AddRef(IWineD3DResource
*iface
);
1191 extern ULONG WINAPI
IWineD3DResourceImpl_Release(IWineD3DResource
*iface
);
1192 /*** IWineD3DResource methods ***/
1193 extern HRESULT WINAPI
IWineD3DResourceImpl_GetParent(IWineD3DResource
*iface
, IUnknown
**pParent
);
1194 extern HRESULT WINAPI
IWineD3DResourceImpl_GetDevice(IWineD3DResource
*iface
, IWineD3DDevice
** ppDevice
);
1195 extern HRESULT WINAPI
IWineD3DResourceImpl_SetPrivateData(IWineD3DResource
*iface
, REFGUID refguid
, CONST
void * pData
, DWORD SizeOfData
, DWORD Flags
);
1196 extern HRESULT WINAPI
IWineD3DResourceImpl_GetPrivateData(IWineD3DResource
*iface
, REFGUID refguid
, void * pData
, DWORD
* pSizeOfData
);
1197 extern HRESULT WINAPI
IWineD3DResourceImpl_FreePrivateData(IWineD3DResource
*iface
, REFGUID refguid
);
1198 extern DWORD WINAPI
IWineD3DResourceImpl_SetPriority(IWineD3DResource
*iface
, DWORD PriorityNew
);
1199 extern DWORD WINAPI
IWineD3DResourceImpl_GetPriority(IWineD3DResource
*iface
);
1200 extern void WINAPI
IWineD3DResourceImpl_PreLoad(IWineD3DResource
*iface
);
1201 extern WINED3DRESOURCETYPE WINAPI
IWineD3DResourceImpl_GetType(IWineD3DResource
*iface
);
1202 /*** class static members ***/
1203 void IWineD3DResourceImpl_CleanUp(IWineD3DResource
*iface
);
1205 /*** IUnknown methods ***/
1206 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture
*iface
, REFIID riid
, void** ppvObject
);
1207 extern ULONG WINAPI
IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture
*iface
);
1208 extern ULONG WINAPI
IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture
*iface
);
1209 /*** IWineD3DResource methods ***/
1210 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture
*iface
, IUnknown
**pParent
);
1211 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture
*iface
, IWineD3DDevice
** ppDevice
);
1212 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
, CONST
void * pData
, DWORD SizeOfData
, DWORD Flags
);
1213 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
, void * pData
, DWORD
* pSizeOfData
);
1214 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture
*iface
, REFGUID refguid
);
1215 extern DWORD WINAPI
IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture
*iface
, DWORD PriorityNew
);
1216 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture
*iface
);
1217 extern void WINAPI
IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture
*iface
);
1218 extern WINED3DRESOURCETYPE WINAPI
IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture
*iface
);
1219 /*** IWineD3DBaseTexture methods ***/
1220 extern DWORD WINAPI
IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture
*iface
, DWORD LODNew
);
1221 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture
*iface
);
1222 extern DWORD WINAPI
IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture
*iface
);
1223 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture
*iface
, WINED3DTEXTUREFILTERTYPE FilterType
);
1224 extern WINED3DTEXTUREFILTERTYPE WINAPI
IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture
*iface
);
1225 extern void WINAPI
IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture
*iface
);
1226 extern BOOL WINAPI
IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture
*iface
, BOOL
);
1227 extern BOOL WINAPI
IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture
*iface
);
1229 extern BYTE
* WINAPI
IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer
* iface
, DWORD iOffset
);
1230 extern HRESULT WINAPI
IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer
* iface
);
1231 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture
*iface
);
1232 extern HRESULT WINAPI
IWineD3DBaseTextureImpl_UnBindTexture(IWineD3DBaseTexture
*iface
);
1233 extern void WINAPI
IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture
*iface
, const DWORD textureStates
[WINED3D_HIGHEST_TEXTURE_STATE
+ 1], const DWORD samplerStates
[WINED3D_HIGHEST_SAMPLER_STATE
+ 1]);
1234 /*** class static members ***/
1235 void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture
*iface
);
1237 struct SHADER_OPCODE_ARG
;
1238 typedef void (*shader_fct_t
)();
1239 typedef void (*SHADER_HANDLER
) (struct SHADER_OPCODE_ARG
*);
1241 /* Struct to maintain a list of GLSL shader programs and their associated pixel and
1242 * vertex shaders. A list of this type is maintained on the DeviceImpl, and is only
1243 * used if the user is using GLSL shaders. */
1244 struct glsl_shader_prog_link
{
1246 GLhandleARB programId
;
1247 IWineD3DVertexShader
* vertexShader
;
1248 IWineD3DPixelShader
* pixelShader
;
1251 typedef struct shader_reg_maps
{
1256 CHAR constantsF
[256]; /* TODO: Make this dynamic */
1257 /* TODO: Integer and bool constants */
1260 #define SHADER_PGMSIZE 65535
1261 typedef struct SHADER_BUFFER
{
1264 unsigned int lineNo
;
1267 typedef struct SHADER_OPCODE
{
1268 unsigned int opcode
;
1271 CONST UINT num_params
;
1272 shader_fct_t soft_fct
;
1273 SHADER_HANDLER hw_fct
;
1274 SHADER_HANDLER hw_glsl_fct
;
1279 typedef struct SHADER_OPCODE_ARG
{
1280 IWineD3DBaseShader
* shader
;
1281 shader_reg_maps
* reg_maps
;
1282 CONST SHADER_OPCODE
* opcode
;
1288 SHADER_BUFFER
* buffer
;
1289 } SHADER_OPCODE_ARG
;
1291 typedef struct SHADER_LIMITS
{
1292 unsigned int temporary
;
1293 unsigned int texture
;
1294 unsigned int constant_int
;
1295 unsigned int constant_float
;
1296 unsigned int constant_bool
;
1297 unsigned int address
;
1298 unsigned int attributes
;
1301 /** Keeps track of details for TEX_M#x# shader opcodes which need to
1302 maintain state information between multiple codes */
1303 typedef struct SHADER_PARSE_STATE
{
1304 unsigned int current_row
;
1305 DWORD texcoord_w
[2];
1306 } SHADER_PARSE_STATE
;
1308 /* Base Shader utility functions.
1309 * (may move callers into the same file in the future) */
1310 extern int shader_addline(
1311 SHADER_BUFFER
* buffer
,
1312 const char* fmt
, ...);
1314 extern const SHADER_OPCODE
* shader_get_opcode(
1315 IWineD3DBaseShader
*iface
,
1318 /* ARB shader program Prototypes */
1319 extern void shader_hw_def(SHADER_OPCODE_ARG
*arg
);
1321 /* GLSL helper programs */
1322 extern void set_glsl_shader_program(IWineD3DDevice
*iface
);
1324 /** The following translate DirectX pixel/vertex shader opcodes to GLSL lines */
1325 extern void shader_glsl_map2gl(SHADER_OPCODE_ARG
* arg
);
1326 extern void shader_glsl_arith(SHADER_OPCODE_ARG
* arg
);
1327 extern void shader_glsl_mov(SHADER_OPCODE_ARG
* arg
);
1328 extern void shader_glsl_mad(SHADER_OPCODE_ARG
* arg
);
1329 extern void shader_glsl_mnxn(SHADER_OPCODE_ARG
* arg
);
1330 extern void shader_glsl_lrp(SHADER_OPCODE_ARG
* arg
);
1331 extern void shader_glsl_dot(SHADER_OPCODE_ARG
* arg
);
1332 extern void shader_glsl_rcp(SHADER_OPCODE_ARG
* arg
);
1333 extern void shader_glsl_cnd(SHADER_OPCODE_ARG
* arg
);
1334 extern void shader_glsl_compare(SHADER_OPCODE_ARG
* arg
);
1335 extern void shader_glsl_def(SHADER_OPCODE_ARG
* arg
);
1336 extern void shader_glsl_cmp(SHADER_OPCODE_ARG
* arg
);
1337 /** GLSL Pixel Shader Prototypes */
1338 extern void pshader_glsl_tex(SHADER_OPCODE_ARG
* arg
);
1339 extern void pshader_glsl_texcoord(SHADER_OPCODE_ARG
* arg
);
1340 extern void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG
* arg
);
1341 extern void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG
* arg
);
1343 /*****************************************************************************
1344 * IDirect3DBaseShader implementation structure
1346 typedef struct IWineD3DBaseShaderClass
1350 SHADER_LIMITS limits
;
1351 SHADER_PARSE_STATE parse_state
;
1352 CONST SHADER_OPCODE
*shader_ins
;
1353 CONST DWORD
*function
;
1354 UINT functionLength
;
1356 } IWineD3DBaseShaderClass
;
1358 typedef struct IWineD3DBaseShaderImpl
{
1360 const IWineD3DBaseShaderVtbl
*lpVtbl
;
1363 /* IWineD3DBaseShader */
1364 IWineD3DBaseShaderClass baseShader
;
1365 } IWineD3DBaseShaderImpl
;
1367 extern void shader_program_dump_decl_usage(
1371 extern void generate_base_shader(
1372 IWineD3DBaseShader
*iface
,
1373 SHADER_BUFFER
* buffer
,
1374 CONST DWORD
* pFunction
);
1376 extern void shader_dump_ins_modifiers(
1377 const DWORD output
);
1379 extern void shader_dump_param(
1380 IWineD3DBaseShader
*iface
,
1382 const DWORD addr_token
,
1385 extern int shader_get_param(
1386 IWineD3DBaseShader
* iface
,
1387 const DWORD
* pToken
,
1391 extern int shader_skip_unrecognized(
1392 IWineD3DBaseShader
* iface
,
1393 const DWORD
* pToken
);
1395 extern void print_glsl_info_log(
1396 WineD3D_GL_Info
*gl_info
,
1399 inline static int shader_get_regtype(const DWORD param
) {
1400 return (((param
& D3DSP_REGTYPE_MASK
) >> D3DSP_REGTYPE_SHIFT
) |
1401 ((param
& D3DSP_REGTYPE_MASK2
) >> D3DSP_REGTYPE_SHIFT2
));
1404 extern unsigned int shader_get_float_offset(const DWORD reg
);
1406 inline static BOOL
shader_is_pshader_version(DWORD token
) {
1407 return 0xFFFF0000 == (token
& 0xFFFF0000);
1410 inline static BOOL
shader_is_vshader_version(DWORD token
) {
1411 return 0xFFFE0000 == (token
& 0xFFFF0000);
1414 inline static BOOL
shader_is_comment(DWORD token
) {
1415 return D3DSIO_COMMENT
== (token
& D3DSI_OPCODE_MASK
);
1418 /*****************************************************************************
1419 * IDirect3DVertexShader implementation structure
1421 typedef struct IWineD3DVertexShaderImpl
{
1423 const IWineD3DVertexShaderVtbl
*lpVtbl
;
1424 LONG ref
; /* Note: Ref counting not required */
1426 /* IWineD3DBaseShader */
1427 IWineD3DBaseShaderClass baseShader
;
1429 /* IWineD3DVertexShaderImpl */
1431 IWineD3DDeviceImpl
*wineD3DDevice
;
1435 /* vertex declaration array mapping */
1436 BOOL namedArrays
; /* don't map use named functions */
1437 BOOL declaredArrays
; /* mapping requires */
1438 INT arrayUsageMap
[WINED3DSHADERDECLUSAGE_MAX_USAGE
]; /* lookup table for the maps */
1440 /* run time datas... */
1442 IWineD3DVertexDeclaration
*vertexDeclaration
;
1443 #if 0 /* needs reworking */
1444 /* run time datas */
1445 VSHADERINPUTDATA input
;
1446 VSHADEROUTPUTDATA output
;
1448 } IWineD3DVertexShaderImpl
;
1449 extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins
[];
1450 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl
;
1452 /*****************************************************************************
1453 * IDirect3DPixelShader implementation structure
1455 typedef struct IWineD3DPixelShaderImpl
{
1456 /* IUnknown parts */
1457 const IWineD3DPixelShaderVtbl
*lpVtbl
;
1458 LONG ref
; /* Note: Ref counting not required */
1460 /* IWineD3DBaseShader */
1461 IWineD3DBaseShaderClass baseShader
;
1463 /* IWineD3DPixelShaderImpl */
1465 IWineD3DDeviceImpl
*wineD3DDevice
;
1470 #if 0 /* needs reworking */
1471 PSHADERINPUTDATA input
;
1472 PSHADEROUTPUTDATA output
;
1474 } IWineD3DPixelShaderImpl
;
1476 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins
[];
1477 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl
;
1479 /*****************************************************************************
1480 * IWineD3DPalette implementation structure
1482 struct IWineD3DPaletteImpl
{
1483 /* IUnknown parts */
1484 const IWineD3DPaletteVtbl
*lpVtbl
;
1488 IWineD3DDeviceImpl
*wineD3DDevice
;
1490 /* IWineD3DPalette */
1492 WORD palVersion
; /*| */
1493 WORD palNumEntries
; /*| LOGPALETTE */
1494 PALETTEENTRY palents
[256]; /*| */
1495 /* This is to store the palette in 'screen format' */
1496 int screen_palents
[256];
1500 extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl
;
1501 DWORD
IWineD3DPaletteImpl_Size(DWORD dwFlags
);
1503 /* DirectDraw utility functions */
1504 extern WINED3DFORMAT
pixelformat_for_depth(DWORD depth
);
1505 LONG
get_bitmask_red(WINED3DFORMAT fmt
);
1506 LONG
get_bitmask_green(WINED3DFORMAT fmt
);
1507 LONG
get_bitmask_blue(WINED3DFORMAT fmt
);
1508 LONG
get_bitmask_alpha(WINED3DFORMAT fmt
);
1509 BOOL
isFourcc(WINED3DFORMAT fmt
);