VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h@ 23571

最後變更 在這個檔案從23571是 23571,由 vboxsync 提交於 15 年 前

crOpenGL: update to wine 1.1.30

  • 屬性 svn:eol-style 設為 native
檔案大小: 112.1 KB
 
1/*
2 * Direct3D wine internal private include file
3 *
4 * Copyright 2002-2003 The wine-d3d team
5 * Copyright 2002-2003 Raphael Junqueira
6 * Copyright 2002-2003, 2004 Jason Edmeades
7 * Copyright 2005 Oliver Stieber
8 *
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.
13 *
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.
18 *
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
22 */
23
24/*
25 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
26 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
27 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
28 * a choice of LGPL license versions is made available with the language indicating
29 * that LGPLv2 or any later version may be used, or where a choice of which version
30 * of the LGPL is applied is otherwise unspecified.
31 */
32
33#ifndef __WINE_WINED3D_PRIVATE_H
34#define __WINE_WINED3D_PRIVATE_H
35
36#include <stdarg.h>
37#include <math.h>
38#define NONAMELESSUNION
39#define NONAMELESSSTRUCT
40#define COBJMACROS
41#include "windef.h"
42#include "winbase.h"
43#include "winreg.h"
44#include "wingdi.h"
45#include "winuser.h"
46#include "wine/debug.h"
47#include "wine/unicode.h"
48
49#include "objbase.h"
50#include "wine/wined3d.h"
51#include "wined3d_gl.h"
52#include "wine/list.h"
53#include "wine/rbtree.h"
54
55/* Driver quirks */
56#define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
57#define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
58#define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
59#define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
60
61/* Texture format fixups */
62
63enum fixup_channel_source
64{
65 CHANNEL_SOURCE_ZERO = 0,
66 CHANNEL_SOURCE_ONE = 1,
67 CHANNEL_SOURCE_X = 2,
68 CHANNEL_SOURCE_Y = 3,
69 CHANNEL_SOURCE_Z = 4,
70 CHANNEL_SOURCE_W = 5,
71 CHANNEL_SOURCE_YUV0 = 6,
72 CHANNEL_SOURCE_YUV1 = 7,
73};
74
75enum yuv_fixup
76{
77 YUV_FIXUP_YUY2 = 0,
78 YUV_FIXUP_UYVY = 1,
79 YUV_FIXUP_YV12 = 2,
80};
81
82#include <pshpack2.h>
83struct color_fixup_desc
84{
85 unsigned x_sign_fixup : 1;
86 unsigned x_source : 3;
87 unsigned y_sign_fixup : 1;
88 unsigned y_source : 3;
89 unsigned z_sign_fixup : 1;
90 unsigned z_source : 3;
91 unsigned w_sign_fixup : 1;
92 unsigned w_source : 3;
93};
94#include <poppack.h>
95
96static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
97 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
98
99static inline struct color_fixup_desc create_color_fixup_desc(
100 int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1,
101 int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)
102{
103 struct color_fixup_desc fixup =
104 {
105 sign0, src0,
106 sign1, src1,
107 sign2, src2,
108 sign3, src3,
109 };
110 return fixup;
111}
112
113static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup)
114{
115 struct color_fixup_desc fixup =
116 {
117 0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
118 0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
119 0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
120 0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
121 };
122 return fixup;
123}
124
125static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
126{
127 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
128}
129
130static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup)
131{
132 return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1;
133}
134
135static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup)
136{
137 enum yuv_fixup yuv_fixup = 0;
138 if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0);
139 if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1);
140 if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2);
141 if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3);
142 return yuv_fixup;
143}
144
145void *wined3d_rb_alloc(size_t size) DECLSPEC_HIDDEN;
146void *wined3d_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN;
147void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN;
148
149/* Device caps */
150#define MAX_PALETTES 65536
151#define MAX_STREAMS 16
152#define MAX_TEXTURES 8
153#define MAX_FRAGMENT_SAMPLERS 16
154#define MAX_VERTEX_SAMPLERS 4
155#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
156#define MAX_ACTIVE_LIGHTS 8
157#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
158
159/* Used for CreateStateBlock */
160#define NUM_SAVEDPIXELSTATES_R 35
161#define NUM_SAVEDPIXELSTATES_T 18
162#define NUM_SAVEDPIXELSTATES_S 12
163#define NUM_SAVEDVERTEXSTATES_R 34
164#define NUM_SAVEDVERTEXSTATES_T 2
165#define NUM_SAVEDVERTEXSTATES_S 1
166
167extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R] DECLSPEC_HIDDEN;
168extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T] DECLSPEC_HIDDEN;
169extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S] DECLSPEC_HIDDEN;
170extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R] DECLSPEC_HIDDEN;
171extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T] DECLSPEC_HIDDEN;
172extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S] DECLSPEC_HIDDEN;
173
174typedef enum _WINELOOKUP {
175 WINELOOKUP_WARPPARAM = 0,
176 MAX_LOOKUPS = 1
177} WINELOOKUP;
178
179extern const int minLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
180extern const int maxLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
181extern DWORD *stateLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
182
183struct min_lookup
184{
185 GLenum mip[WINED3DTEXF_LINEAR + 1];
186};
187
188const struct min_lookup minMipLookup[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
189const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
190const struct min_lookup minMipLookup_noMip[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
191const GLenum magLookup[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
192const GLenum magLookup_noFilter[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
193
194static inline GLenum wined3d_gl_mag_filter(const GLenum mag_lookup[], WINED3DTEXTUREFILTERTYPE mag_filter)
195{
196 return mag_lookup[mag_filter];
197}
198
199static inline GLenum wined3d_gl_min_mip_filter(const struct min_lookup min_mip_lookup[],
200 WINED3DTEXTUREFILTERTYPE min_filter, WINED3DTEXTUREFILTERTYPE mip_filter)
201{
202 return min_mip_lookup[min_filter].mip[mip_filter];
203}
204
205/* float_16_to_32() and float_32_to_16() (see implementation in
206 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
207 * to standard C floats and vice versa. They do not depend on the encoding
208 * of the C float, so they are platform independent, but slow. On x86 and
209 * other IEEE 754 compliant platforms the conversion can be accelerated by
210 * bit shifting the exponent and mantissa. There are also some SSE-based
211 * assembly routines out there.
212 *
213 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
214 */
215static inline float float_16_to_32(const unsigned short *in) {
216 unsigned long fNaN = 0x7fc00000;
217 unsigned long fNegInf = 0xff800000;
218 unsigned long fInf = 0x7f800000;
219
220 const unsigned short s = ((*in) & 0x8000);
221 const unsigned short e = ((*in) & 0x7C00) >> 10;
222 const unsigned short m = (*in) & 0x3FF;
223 const float sgn = (s ? -1.0f : 1.0f);
224
225 if(e == 0) {
226 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
227 else return sgn * pow(2, -14.0f) * ((float)m / 1024.0f);
228 } else if(e < 31) {
229 return sgn * pow(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
230 } else {
231 if(m == 0) return sgn>0? *(float*)(&fInf) : *(float*)(&fNegInf); //sgn / 0.0f; /* +INF / -INF */
232 else return *(float*)(&fNaN); //0.0f / 0.0f; /* NAN */
233 }
234}
235
236static inline float float_24_to_32(DWORD in)
237{
238 const float sgn = in & 0x800000 ? -1.0f : 1.0f;
239 const unsigned short e = (in & 0x780000) >> 19;
240 const unsigned short m = in & 0x7ffff;
241 unsigned long fNaN = 0x7fc00000;
242 unsigned long fNegInf = 0xff800000;
243 unsigned long fInf = 0x7f800000;
244
245 if (e == 0)
246 {
247 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
248 else return sgn * pow(2, -6.0f) * ((float)m / 524288.0f);
249 }
250 else if (e < 15)
251 {
252 return sgn * pow(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
253 }
254 else
255 {
256 if (m == 0) return sgn>0? *(float*)(&fInf) : *(float*)(&fNegInf); //sgn / 0.0f; /* +INF / -INF */
257 else return *(float*)(&fNaN); //0.0f / 0.0f; /* NAN */
258 }
259}
260
261/**
262 * Settings
263 */
264#define VS_NONE 0
265#define VS_HW 1
266
267#define PS_NONE 0
268#define PS_HW 1
269
270#define VBO_NONE 0
271#define VBO_HW 1
272
273#define NP2_NONE 0
274#define NP2_REPACK 1
275#define NP2_NATIVE 2
276
277#define ORM_BACKBUFFER 0
278#define ORM_PBUFFER 1
279#define ORM_FBO 2
280
281#define SHADER_ARB 1
282#define SHADER_GLSL 2
283#define SHADER_ATI 3
284#define SHADER_NONE 4
285
286#define RTL_DISABLE -1
287#define RTL_READDRAW 1
288#define RTL_READTEX 2
289
290#define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
291#define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
292
293/* NOTE: When adding fields to this structure, make sure to update the default
294 * values in wined3d_main.c as well. */
295typedef struct wined3d_settings_s {
296/* vertex and pixel shader modes */
297 int vs_mode;
298 int ps_mode;
299/* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
300 we should use it. However, until it's fully implemented, we'll leave it as a registry
301 setting for developers. */
302 BOOL glslRequested;
303 int offscreen_rendering_mode;
304 int rendertargetlock_mode;
305 unsigned short pci_vendor_id;
306 unsigned short pci_device_id;
307/* Memory tracking and object counting */
308 unsigned int emulated_textureram;
309 char *logo;
310 int allow_multisampling;
311} wined3d_settings_t;
312
313extern wined3d_settings_t wined3d_settings DECLSPEC_HIDDEN;
314
315typedef enum _WINED3DSAMPLER_TEXTURE_TYPE
316{
317 WINED3DSTT_UNKNOWN = 0,
318 WINED3DSTT_1D = 1,
319 WINED3DSTT_2D = 2,
320 WINED3DSTT_CUBE = 3,
321 WINED3DSTT_VOLUME = 4,
322} WINED3DSAMPLER_TEXTURE_TYPE;
323
324typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE
325{
326 WINED3DSPR_TEMP = 0,
327 WINED3DSPR_INPUT = 1,
328 WINED3DSPR_CONST = 2,
329 WINED3DSPR_ADDR = 3,
330 WINED3DSPR_TEXTURE = 3,
331 WINED3DSPR_RASTOUT = 4,
332 WINED3DSPR_ATTROUT = 5,
333 WINED3DSPR_TEXCRDOUT = 6,
334 WINED3DSPR_OUTPUT = 6,
335 WINED3DSPR_CONSTINT = 7,
336 WINED3DSPR_COLOROUT = 8,
337 WINED3DSPR_DEPTHOUT = 9,
338 WINED3DSPR_SAMPLER = 10,
339 WINED3DSPR_CONST2 = 11,
340 WINED3DSPR_CONST3 = 12,
341 WINED3DSPR_CONST4 = 13,
342 WINED3DSPR_CONSTBOOL = 14,
343 WINED3DSPR_LOOP = 15,
344 WINED3DSPR_TEMPFLOAT16 = 16,
345 WINED3DSPR_MISCTYPE = 17,
346 WINED3DSPR_LABEL = 18,
347 WINED3DSPR_PREDICATE = 19,
348 WINED3DSPR_IMMCONST,
349 WINED3DSPR_CONSTBUFFER,
350} WINED3DSHADER_PARAM_REGISTER_TYPE;
351
352enum wined3d_immconst_type
353{
354 WINED3D_IMMCONST_FLOAT,
355 WINED3D_IMMCONST_FLOAT4,
356};
357
358typedef enum _WINED3DVS_RASTOUT_OFFSETS
359{
360 WINED3DSRO_POSITION = 0,
361 WINED3DSRO_FOG = 1,
362 WINED3DSRO_POINT_SIZE = 2,
363} WINED3DVS_RASTOUT_OFFSETS;
364
365#define WINED3DSP_NOSWIZZLE (0 | (1 << 2) | (2 << 4) | (3 << 6))
366
367typedef enum _WINED3DSHADER_PARAM_SRCMOD_TYPE
368{
369 WINED3DSPSM_NONE = 0,
370 WINED3DSPSM_NEG = 1,
371 WINED3DSPSM_BIAS = 2,
372 WINED3DSPSM_BIASNEG = 3,
373 WINED3DSPSM_SIGN = 4,
374 WINED3DSPSM_SIGNNEG = 5,
375 WINED3DSPSM_COMP = 6,
376 WINED3DSPSM_X2 = 7,
377 WINED3DSPSM_X2NEG = 8,
378 WINED3DSPSM_DZ = 9,
379 WINED3DSPSM_DW = 10,
380 WINED3DSPSM_ABS = 11,
381 WINED3DSPSM_ABSNEG = 12,
382 WINED3DSPSM_NOT = 13,
383} WINED3DSHADER_PARAM_SRCMOD_TYPE;
384
385#define WINED3DSP_WRITEMASK_0 0x1 /* .x r */
386#define WINED3DSP_WRITEMASK_1 0x2 /* .y g */
387#define WINED3DSP_WRITEMASK_2 0x4 /* .z b */
388#define WINED3DSP_WRITEMASK_3 0x8 /* .w a */
389#define WINED3DSP_WRITEMASK_ALL 0xf /* all */
390
391typedef enum _WINED3DSHADER_PARAM_DSTMOD_TYPE
392{
393 WINED3DSPDM_NONE = 0,
394 WINED3DSPDM_SATURATE = 1,
395 WINED3DSPDM_PARTIALPRECISION = 2,
396 WINED3DSPDM_MSAMPCENTROID = 4,
397} WINED3DSHADER_PARAM_DSTMOD_TYPE;
398
399typedef enum _WINED3DSHADER_INSTRUCTION_OPCODE_TYPE
400{
401 WINED3DSIO_NOP = 0,
402 WINED3DSIO_MOV = 1,
403 WINED3DSIO_ADD = 2,
404 WINED3DSIO_SUB = 3,
405 WINED3DSIO_MAD = 4,
406 WINED3DSIO_MUL = 5,
407 WINED3DSIO_RCP = 6,
408 WINED3DSIO_RSQ = 7,
409 WINED3DSIO_DP3 = 8,
410 WINED3DSIO_DP4 = 9,
411 WINED3DSIO_MIN = 10,
412 WINED3DSIO_MAX = 11,
413 WINED3DSIO_SLT = 12,
414 WINED3DSIO_SGE = 13,
415 WINED3DSIO_EXP = 14,
416 WINED3DSIO_LOG = 15,
417 WINED3DSIO_LIT = 16,
418 WINED3DSIO_DST = 17,
419 WINED3DSIO_LRP = 18,
420 WINED3DSIO_FRC = 19,
421 WINED3DSIO_M4x4 = 20,
422 WINED3DSIO_M4x3 = 21,
423 WINED3DSIO_M3x4 = 22,
424 WINED3DSIO_M3x3 = 23,
425 WINED3DSIO_M3x2 = 24,
426 WINED3DSIO_CALL = 25,
427 WINED3DSIO_CALLNZ = 26,
428 WINED3DSIO_LOOP = 27,
429 WINED3DSIO_RET = 28,
430 WINED3DSIO_ENDLOOP = 29,
431 WINED3DSIO_LABEL = 30,
432 WINED3DSIO_DCL = 31,
433 WINED3DSIO_POW = 32,
434 WINED3DSIO_CRS = 33,
435 WINED3DSIO_SGN = 34,
436 WINED3DSIO_ABS = 35,
437 WINED3DSIO_NRM = 36,
438 WINED3DSIO_SINCOS = 37,
439 WINED3DSIO_REP = 38,
440 WINED3DSIO_ENDREP = 39,
441 WINED3DSIO_IF = 40,
442 WINED3DSIO_IFC = 41,
443 WINED3DSIO_ELSE = 42,
444 WINED3DSIO_ENDIF = 43,
445 WINED3DSIO_BREAK = 44,
446 WINED3DSIO_BREAKC = 45,
447 WINED3DSIO_MOVA = 46,
448 WINED3DSIO_DEFB = 47,
449 WINED3DSIO_DEFI = 48,
450
451 WINED3DSIO_TEXCOORD = 64,
452 WINED3DSIO_TEXKILL = 65,
453 WINED3DSIO_TEX = 66,
454 WINED3DSIO_TEXBEM = 67,
455 WINED3DSIO_TEXBEML = 68,
456 WINED3DSIO_TEXREG2AR = 69,
457 WINED3DSIO_TEXREG2GB = 70,
458 WINED3DSIO_TEXM3x2PAD = 71,
459 WINED3DSIO_TEXM3x2TEX = 72,
460 WINED3DSIO_TEXM3x3PAD = 73,
461 WINED3DSIO_TEXM3x3TEX = 74,
462 WINED3DSIO_TEXM3x3DIFF = 75,
463 WINED3DSIO_TEXM3x3SPEC = 76,
464 WINED3DSIO_TEXM3x3VSPEC = 77,
465 WINED3DSIO_EXPP = 78,
466 WINED3DSIO_LOGP = 79,
467 WINED3DSIO_CND = 80,
468 WINED3DSIO_DEF = 81,
469 WINED3DSIO_TEXREG2RGB = 82,
470 WINED3DSIO_TEXDP3TEX = 83,
471 WINED3DSIO_TEXM3x2DEPTH = 84,
472 WINED3DSIO_TEXDP3 = 85,
473 WINED3DSIO_TEXM3x3 = 86,
474 WINED3DSIO_TEXDEPTH = 87,
475 WINED3DSIO_CMP = 88,
476 WINED3DSIO_BEM = 89,
477 WINED3DSIO_DP2ADD = 90,
478 WINED3DSIO_DSX = 91,
479 WINED3DSIO_DSY = 92,
480 WINED3DSIO_TEXLDD = 93,
481 WINED3DSIO_SETP = 94,
482 WINED3DSIO_TEXLDL = 95,
483 WINED3DSIO_BREAKP = 96,
484
485 WINED3DSIO_PHASE = 0xfffd,
486 WINED3DSIO_COMMENT = 0xfffe,
487 WINED3DSIO_END = 0Xffff,
488} WINED3DSHADER_INSTRUCTION_OPCODE_TYPE;
489
490/* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
491#define WINED3DSI_TEXLD_PROJECT 1
492#define WINED3DSI_TEXLD_BIAS 2
493
494typedef enum COMPARISON_TYPE
495{
496 COMPARISON_GT = 1,
497 COMPARISON_EQ = 2,
498 COMPARISON_GE = 3,
499 COMPARISON_LT = 4,
500 COMPARISON_NE = 5,
501 COMPARISON_LE = 6,
502} COMPARISON_TYPE;
503
504#define WINED3D_SM1_VS 0xfffe
505#define WINED3D_SM1_PS 0xffff
506#define WINED3D_SM4_PS 0x0000
507#define WINED3D_SM4_VS 0x0001
508#define WINED3D_SM4_GS 0x0002
509
510/* Shader version tokens, and shader end tokens */
511#define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
512#define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
513
514/* Shader backends */
515
516/* TODO: Make this dynamic, based on shader limits ? */
517#define MAX_ATTRIBS 16
518#define MAX_REG_ADDR 1
519#define MAX_REG_TEMP 32
520#define MAX_REG_TEXCRD 8
521#define MAX_REG_INPUT 12
522#define MAX_REG_OUTPUT 12
523#define MAX_CONST_I 16
524#define MAX_CONST_B 16
525
526/* FIXME: This needs to go up to 2048 for
527 * Shader model 3 according to msdn (and for software shaders) */
528#define MAX_LABELS 16
529
530#define SHADER_PGMSIZE 65535
531
532struct wined3d_shader_buffer
533{
534 char *buffer;
535 unsigned int bsize;
536 unsigned int lineNo;
537 BOOL newline;
538};
539
540enum WINED3D_SHADER_INSTRUCTION_HANDLER
541{
542 WINED3DSIH_ABS,
543 WINED3DSIH_ADD,
544 WINED3DSIH_BEM,
545 WINED3DSIH_BREAK,
546 WINED3DSIH_BREAKC,
547 WINED3DSIH_BREAKP,
548 WINED3DSIH_CALL,
549 WINED3DSIH_CALLNZ,
550 WINED3DSIH_CMP,
551 WINED3DSIH_CND,
552 WINED3DSIH_CRS,
553 WINED3DSIH_DCL,
554 WINED3DSIH_DEF,
555 WINED3DSIH_DEFB,
556 WINED3DSIH_DEFI,
557 WINED3DSIH_DP2ADD,
558 WINED3DSIH_DP3,
559 WINED3DSIH_DP4,
560 WINED3DSIH_DST,
561 WINED3DSIH_DSX,
562 WINED3DSIH_DSY,
563 WINED3DSIH_ELSE,
564 WINED3DSIH_ENDIF,
565 WINED3DSIH_ENDLOOP,
566 WINED3DSIH_ENDREP,
567 WINED3DSIH_EXP,
568 WINED3DSIH_EXPP,
569 WINED3DSIH_FRC,
570 WINED3DSIH_IF,
571 WINED3DSIH_IFC,
572 WINED3DSIH_LABEL,
573 WINED3DSIH_LIT,
574 WINED3DSIH_LOG,
575 WINED3DSIH_LOGP,
576 WINED3DSIH_LOOP,
577 WINED3DSIH_LRP,
578 WINED3DSIH_M3x2,
579 WINED3DSIH_M3x3,
580 WINED3DSIH_M3x4,
581 WINED3DSIH_M4x3,
582 WINED3DSIH_M4x4,
583 WINED3DSIH_MAD,
584 WINED3DSIH_MAX,
585 WINED3DSIH_MIN,
586 WINED3DSIH_MOV,
587 WINED3DSIH_MOVA,
588 WINED3DSIH_MUL,
589 WINED3DSIH_NOP,
590 WINED3DSIH_NRM,
591 WINED3DSIH_PHASE,
592 WINED3DSIH_POW,
593 WINED3DSIH_RCP,
594 WINED3DSIH_REP,
595 WINED3DSIH_RET,
596 WINED3DSIH_RSQ,
597 WINED3DSIH_SETP,
598 WINED3DSIH_SGE,
599 WINED3DSIH_SGN,
600 WINED3DSIH_SINCOS,
601 WINED3DSIH_SLT,
602 WINED3DSIH_SUB,
603 WINED3DSIH_TEX,
604 WINED3DSIH_TEXBEM,
605 WINED3DSIH_TEXBEML,
606 WINED3DSIH_TEXCOORD,
607 WINED3DSIH_TEXDEPTH,
608 WINED3DSIH_TEXDP3,
609 WINED3DSIH_TEXDP3TEX,
610 WINED3DSIH_TEXKILL,
611 WINED3DSIH_TEXLDD,
612 WINED3DSIH_TEXLDL,
613 WINED3DSIH_TEXM3x2DEPTH,
614 WINED3DSIH_TEXM3x2PAD,
615 WINED3DSIH_TEXM3x2TEX,
616 WINED3DSIH_TEXM3x3,
617 WINED3DSIH_TEXM3x3DIFF,
618 WINED3DSIH_TEXM3x3PAD,
619 WINED3DSIH_TEXM3x3SPEC,
620 WINED3DSIH_TEXM3x3TEX,
621 WINED3DSIH_TEXM3x3VSPEC,
622 WINED3DSIH_TEXREG2AR,
623 WINED3DSIH_TEXREG2GB,
624 WINED3DSIH_TEXREG2RGB,
625 WINED3DSIH_TABLE_SIZE
626};
627
628enum wined3d_shader_type
629{
630 WINED3D_SHADER_TYPE_PIXEL,
631 WINED3D_SHADER_TYPE_VERTEX,
632 WINED3D_SHADER_TYPE_GEOMETRY,
633};
634
635struct wined3d_shader_version
636{
637 enum wined3d_shader_type type;
638 BYTE major;
639 BYTE minor;
640};
641
642#define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
643
644typedef struct shader_reg_maps
645{
646 struct wined3d_shader_version shader_version;
647 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
648 BYTE address; /* MAX_REG_ADDR, 1 */
649 WORD labels; /* MAX_LABELS, 16 */
650 DWORD temporary; /* MAX_REG_TEMP, 32 */
651 DWORD *constf; /* pixel, vertex */
652 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
653 WORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 16 */
654 WORD output_registers; /* MAX_REG_OUTPUT, 12 */
655 WORD integer_constants; /* MAX_CONST_I, 16 */
656 WORD boolean_constants; /* MAX_CONST_B, 16 */
657 WORD local_int_consts; /* MAX_CONST_I, 16 */
658 WORD local_bool_consts; /* MAX_CONST_B, 16 */
659
660 WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
661 BYTE bumpmat; /* MAX_TEXTURES, 8 */
662 BYTE luminanceparams; /* MAX_TEXTURES, 8 */
663
664 WORD usesnrm : 1;
665 WORD vpos : 1;
666 WORD usesdsx : 1;
667 WORD usesdsy : 1;
668 WORD usestexldd : 1;
669 WORD usesmova : 1;
670 WORD usesfacing : 1;
671 WORD usesrelconstF : 1;
672 WORD fog : 1;
673 WORD usestexldl : 1;
674 WORD usesifc : 1;
675 WORD usescall : 1;
676 WORD padding : 4;
677
678 /* Whether or not loops are used in this shader, and nesting depth */
679 unsigned loop_depth;
680 unsigned highest_render_target;
681
682} shader_reg_maps;
683
684struct wined3d_shader_context
685{
686 IWineD3DBaseShader *shader;
687 const struct shader_reg_maps *reg_maps;
688 struct wined3d_shader_buffer *buffer;
689 void *backend_data;
690};
691
692struct wined3d_shader_register
693{
694 WINED3DSHADER_PARAM_REGISTER_TYPE type;
695 UINT idx;
696 UINT array_idx;
697 const struct wined3d_shader_src_param *rel_addr;
698 enum wined3d_immconst_type immconst_type;
699 DWORD immconst_data[4];
700};
701
702struct wined3d_shader_dst_param
703{
704 struct wined3d_shader_register reg;
705 DWORD write_mask;
706 DWORD modifiers;
707 DWORD shift;
708};
709
710struct wined3d_shader_src_param
711{
712 struct wined3d_shader_register reg;
713 DWORD swizzle;
714 DWORD modifiers;
715};
716
717struct wined3d_shader_instruction
718{
719 const struct wined3d_shader_context *ctx;
720 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
721 DWORD flags;
722 BOOL coissue;
723 DWORD predicate;
724 UINT dst_count;
725 const struct wined3d_shader_dst_param *dst;
726 UINT src_count;
727 const struct wined3d_shader_src_param *src;
728};
729
730struct wined3d_shader_semantic
731{
732 WINED3DDECLUSAGE usage;
733 UINT usage_idx;
734 WINED3DSAMPLER_TEXTURE_TYPE sampler_type;
735 struct wined3d_shader_dst_param reg;
736};
737
738struct wined3d_shader_attribute
739{
740 WINED3DDECLUSAGE usage;
741 UINT usage_idx;
742};
743
744struct wined3d_shader_loop_control
745{
746 unsigned int count;
747 unsigned int start;
748 int step;
749};
750
751struct wined3d_shader_frontend
752{
753 void *(*shader_init)(const DWORD *ptr, const struct wined3d_shader_signature *output_signature);
754 void (*shader_free)(void *data);
755 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
756 void (*shader_read_opcode)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size);
757 void (*shader_read_src_param)(void *data, const DWORD **ptr, struct wined3d_shader_src_param *src_param,
758 struct wined3d_shader_src_param *src_rel_addr);
759 void (*shader_read_dst_param)(void *data, const DWORD **ptr, struct wined3d_shader_dst_param *dst_param,
760 struct wined3d_shader_src_param *dst_rel_addr);
761 void (*shader_read_semantic)(const DWORD **ptr, struct wined3d_shader_semantic *semantic);
762 void (*shader_read_comment)(const DWORD **ptr, const char **comment);
763 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
764};
765
766extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
767extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
768
769typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
770
771struct shader_caps {
772 DWORD VertexShaderVersion;
773 DWORD MaxVertexShaderConst;
774
775 DWORD PixelShaderVersion;
776 float PixelShader1xMaxValue;
777 DWORD MaxPixelShaderConst;
778
779 WINED3DVSHADERCAPS2_0 VS20Caps;
780 WINED3DPSHADERCAPS2_0 PS20Caps;
781
782 DWORD MaxVShaderInstructionsExecuted;
783 DWORD MaxPShaderInstructionsExecuted;
784 DWORD MaxVertexShader30InstructionSlots;
785 DWORD MaxPixelShader30InstructionSlots;
786
787 BOOL VSClipping;
788};
789
790enum tex_types
791{
792 tex_1d = 0,
793 tex_2d = 1,
794 tex_3d = 2,
795 tex_cube = 3,
796 tex_rect = 4,
797 tex_type_count = 5,
798};
799
800enum vertexprocessing_mode {
801 fixedfunction,
802 vertexshader,
803 pretransformed
804};
805
806#define WINED3D_CONST_NUM_UNUSED ~0U
807
808enum fogmode {
809 FOG_OFF,
810 FOG_LINEAR,
811 FOG_EXP,
812 FOG_EXP2
813};
814
815/* Stateblock dependent parameters which have to be hardcoded
816 * into the shader code
817 */
818struct ps_compile_args {
819 struct color_fixup_desc color_fixup[MAX_FRAGMENT_SAMPLERS];
820 enum vertexprocessing_mode vp_mode;
821 enum fogmode fog;
822 /* Projected textures(ps 1.0-1.3) */
823 /* Texture types(2D, Cube, 3D) in ps 1.x */
824 BOOL srgb_correction;
825 WORD np2_fixup;
826 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
827 D3D9 has a limit of 16 samplers and the fixup is superfluous
828 in D3D10 (unconditional NP2 support mandatory). */
829};
830
831enum fog_src_type {
832 VS_FOG_Z = 0,
833 VS_FOG_COORD = 1
834};
835
836struct vs_compile_args {
837 WORD fog_src;
838 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
839};
840
841struct wined3d_context;
842
843typedef struct {
844 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
845 void (*shader_select)(const struct wined3d_context *context, BOOL usePS, BOOL useVS);
846 void (*shader_select_depth_blt)(IWineD3DDevice *iface, enum tex_types tex_type);
847 void (*shader_deselect_depth_blt)(IWineD3DDevice *iface);
848 void (*shader_update_float_vertex_constants)(IWineD3DDevice *iface, UINT start, UINT count);
849 void (*shader_update_float_pixel_constants)(IWineD3DDevice *iface, UINT start, UINT count);
850 void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS);
851 void (*shader_load_np2fixup_constants)(IWineD3DDevice *iface, char usePS, char useVS);
852 void (*shader_destroy)(IWineD3DBaseShader *iface);
853 HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
854 void (*shader_free_private)(IWineD3DDevice *iface);
855 BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface);
856 void (*shader_get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
857 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
858 void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins);
859} shader_backend_t;
860
861extern const shader_backend_t glsl_shader_backend DECLSPEC_HIDDEN;
862extern const shader_backend_t arb_program_shader_backend DECLSPEC_HIDDEN;
863extern const shader_backend_t none_shader_backend DECLSPEC_HIDDEN;
864
865/* X11 locking */
866
867extern void (* CDECL wine_tsx11_lock_ptr)(void) DECLSPEC_HIDDEN;
868extern void (* CDECL wine_tsx11_unlock_ptr)(void) DECLSPEC_HIDDEN;
869
870/* As GLX relies on X, this is needed */
871extern int num_lock DECLSPEC_HIDDEN;
872
873#if 0
874#define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
875#define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
876#else
877#define ENTER_GL() wine_tsx11_lock_ptr()
878#define LEAVE_GL() wine_tsx11_unlock_ptr()
879#endif
880
881/*****************************************************************************
882 * Defines
883 */
884
885/* GL related defines */
886/* ------------------ */
887#define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0)
888#define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName)
889#define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
890#define GL_VEND(_VendName) (GLINFO_LOCATION.gl_vendor == VENDOR_##_VendName ? TRUE : FALSE)
891
892#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
893#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
894#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
895#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
896
897#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
898#define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
899#define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
900#define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
901
902#define D3DCOLORTOGLFLOAT4(dw, vec) do { \
903 (vec)[0] = D3DCOLOR_R(dw); \
904 (vec)[1] = D3DCOLOR_G(dw); \
905 (vec)[2] = D3DCOLOR_B(dw); \
906 (vec)[3] = D3DCOLOR_A(dw); \
907} while(0)
908
909/* DirectX Device Limits */
910/* --------------------- */
911#define MAX_MIP_LEVELS 32 /* Maximum number of mipmap levels. */
912#define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
913 See MaxStreams in MSDN under GetDeviceCaps */
914#define HIGHEST_TRANSFORMSTATE WINED3DTS_WORLDMATRIX(255) /* Highest value in WINED3DTRANSFORMSTATETYPE */
915
916/* Checking of API calls */
917/* --------------------- */
918#ifndef WINE_NO_DEBUG_MSGS
919#define checkGLcall(A) \
920do { \
921 GLint err; \
922 if(!__WINE_IS_DEBUG_ON(_FIXME, __wine_dbch___default)) break; \
923 err = glGetError(); \
924 if (err == GL_NO_ERROR) { \
925 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
926 \
927 } else do { \
928 FIXME(">>>>>>>>>>>>>>>>> %s (%#x) from %s @ %s / %d\n", \
929 debug_glerror(err), err, A, __FILE__, __LINE__); \
930 err = glGetError(); \
931 } while (err != GL_NO_ERROR); \
932} while(0)
933#else
934#define checkGLcall(A) do {} while(0)
935#endif
936
937/* Trace routines / diagnostics */
938/* ---------------------------- */
939
940/* Dump out a matrix and copy it */
941#define conv_mat(mat,gl_mat) \
942do { \
943 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
944 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
945 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
946 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
947 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
948} while (0)
949
950/* Macro to dump out the current state of the light chain */
951#define DUMP_LIGHT_CHAIN() \
952do { \
953 PLIGHTINFOEL *el = This->stateBlock->lights;\
954 while (el) { \
955 TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
956 el = el->next; \
957 } \
958} while(0)
959
960/* Trace vector and strided data information */
961#define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w)
962#define TRACE_STRIDED(si, name) do { if (si->use_map & (1 << name)) \
963 TRACE( #name "=(data:%p, stride:%d, format:%#x, vbo %d, stream %u)\n", \
964 si->elements[name].data, si->elements[name].stride, si->elements[name].format_desc->format, \
965 si->elements[name].buffer_object, si->elements[name].stream_idx); } while(0)
966
967/* Defines used for optimizations */
968
969/* Only reapply what is necessary */
970#define REAPPLY_ALPHAOP 0x0001
971#define REAPPLY_ALL 0xFFFF
972
973/* Advance declaration of structures to satisfy compiler */
974typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
975typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
976typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
977typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
978
979/* Global variables */
980extern const float identity[16] DECLSPEC_HIDDEN;
981
982/*****************************************************************************
983 * Compilable extra diagnostics
984 */
985
986/* Trace information per-vertex: (extremely high amount of trace) */
987#if 0 /* NOTE: Must be 0 in cvs */
988# define VTRACE(A) TRACE A
989#else
990# define VTRACE(A)
991#endif
992
993/* TODO: Confirm each of these works when wined3d move completed */
994#if 0 /* NOTE: Must be 0 in cvs */
995 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
996 of each frame, a check is made for the existence of C:\D3DTRACE, and if it exists d3d trace
997 is enabled, and if it doesn't exist it is disabled. */
998# define FRAME_DEBUGGING
999 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
1000 the file is deleted */
1001# if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
1002# define SINGLE_FRAME_DEBUGGING
1003# endif
1004 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
1005 It can only be enabled when FRAME_DEBUGGING is also enabled
1006 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
1007 array is drawn. */
1008# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
1009# define SHOW_FRAME_MAKEUP 1
1010# endif
1011 /* The following, when enabled, lets you see the makeup of the all the textures used during each
1012 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
1013 The contents of the textures assigned to each stage are written into
1014 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
1015# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
1016# define SHOW_TEXTURE_MAKEUP 0
1017# endif
1018extern BOOL isOn;
1019extern BOOL isDumpingFrames;
1020extern LONG primCounter;
1021#endif
1022
1023enum wined3d_ffp_idx
1024{
1025 WINED3D_FFP_POSITION = 0,
1026 WINED3D_FFP_BLENDWEIGHT = 1,
1027 WINED3D_FFP_BLENDINDICES = 2,
1028 WINED3D_FFP_NORMAL = 3,
1029 WINED3D_FFP_PSIZE = 4,
1030 WINED3D_FFP_DIFFUSE = 5,
1031 WINED3D_FFP_SPECULAR = 6,
1032 WINED3D_FFP_TEXCOORD0 = 7,
1033 WINED3D_FFP_TEXCOORD1 = 8,
1034 WINED3D_FFP_TEXCOORD2 = 9,
1035 WINED3D_FFP_TEXCOORD3 = 10,
1036 WINED3D_FFP_TEXCOORD4 = 11,
1037 WINED3D_FFP_TEXCOORD5 = 12,
1038 WINED3D_FFP_TEXCOORD6 = 13,
1039 WINED3D_FFP_TEXCOORD7 = 14,
1040};
1041
1042enum wined3d_ffp_emit_idx
1043{
1044 WINED3D_FFP_EMIT_FLOAT1 = 0,
1045 WINED3D_FFP_EMIT_FLOAT2 = 1,
1046 WINED3D_FFP_EMIT_FLOAT3 = 2,
1047 WINED3D_FFP_EMIT_FLOAT4 = 3,
1048 WINED3D_FFP_EMIT_D3DCOLOR = 4,
1049 WINED3D_FFP_EMIT_UBYTE4 = 5,
1050 WINED3D_FFP_EMIT_SHORT2 = 6,
1051 WINED3D_FFP_EMIT_SHORT4 = 7,
1052 WINED3D_FFP_EMIT_UBYTE4N = 8,
1053 WINED3D_FFP_EMIT_SHORT2N = 9,
1054 WINED3D_FFP_EMIT_SHORT4N = 10,
1055 WINED3D_FFP_EMIT_USHORT2N = 11,
1056 WINED3D_FFP_EMIT_USHORT4N = 12,
1057 WINED3D_FFP_EMIT_UDEC3 = 13,
1058 WINED3D_FFP_EMIT_DEC3N = 14,
1059 WINED3D_FFP_EMIT_FLOAT16_2 = 15,
1060 WINED3D_FFP_EMIT_FLOAT16_4 = 16,
1061 WINED3D_FFP_EMIT_COUNT = 17
1062};
1063
1064struct wined3d_stream_info_element
1065{
1066 const struct GlPixelFormatDesc *format_desc;
1067 GLsizei stride;
1068 const BYTE *data;
1069 UINT stream_idx;
1070 GLuint buffer_object;
1071};
1072
1073struct wined3d_stream_info
1074{
1075 struct wined3d_stream_info_element elements[MAX_ATTRIBS];
1076 BOOL position_transformed;
1077 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1078 WORD use_map; /* MAX_ATTRIBS, 16 */
1079};
1080
1081/*****************************************************************************
1082 * Prototypes
1083 */
1084
1085/* Routine common to the draw primitive and draw indexed primitive routines */
1086void drawPrimitive(IWineD3DDevice *iface, UINT index_count,
1087 UINT start_idx, UINT idxBytes, const void *idxData) DECLSPEC_HIDDEN;
1088DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
1089
1090typedef void (WINE_GLAPI *glAttribFunc)(const void *data);
1091typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, const void *data);
1092extern glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
1093extern glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
1094extern glAttribFunc specular_func_3ubv DECLSPEC_HIDDEN;
1095extern glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
1096extern glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
1097extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
1098
1099#define eps 1e-8
1100
1101#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1102 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1103
1104/* Routines and structures related to state management */
1105
1106#define STATE_RENDER(a) (a)
1107#define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1108
1109#define STATE_TEXTURESTAGE(stage, num) (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1110#define STATE_IS_TEXTURESTAGE(a) ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1111
1112/* + 1 because samplers start with 0 */
1113#define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1114#define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
1115
1116#define STATE_PIXELSHADER (STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1) + 1)
1117#define STATE_IS_PIXELSHADER(a) ((a) == STATE_PIXELSHADER)
1118
1119#define STATE_TRANSFORM(a) (STATE_PIXELSHADER + (a))
1120#define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)))
1121
1122#define STATE_STREAMSRC (STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)) + 1)
1123#define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1124#define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1125#define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1126
1127#define STATE_VDECL (STATE_INDEXBUFFER + 1)
1128#define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1129
1130#define STATE_VSHADER (STATE_VDECL + 1)
1131#define STATE_IS_VSHADER(a) ((a) == STATE_VSHADER)
1132
1133#define STATE_VIEWPORT (STATE_VSHADER + 1)
1134#define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1135
1136#define STATE_VERTEXSHADERCONSTANT (STATE_VIEWPORT + 1)
1137#define STATE_PIXELSHADERCONSTANT (STATE_VERTEXSHADERCONSTANT + 1)
1138#define STATE_IS_VERTEXSHADERCONSTANT(a) ((a) == STATE_VERTEXSHADERCONSTANT)
1139#define STATE_IS_PIXELSHADERCONSTANT(a) ((a) == STATE_PIXELSHADERCONSTANT)
1140
1141#define STATE_ACTIVELIGHT(a) (STATE_PIXELSHADERCONSTANT + (a) + 1)
1142#define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS))
1143
1144#define STATE_SCISSORRECT (STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS - 1) + 1)
1145#define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1146
1147#define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1148#define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIPPLANES - 1))
1149
1150#define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIPPLANES))
1151
1152#define STATE_FRONTFACE (STATE_MATERIAL + 1)
1153
1154#define STATE_HIGHEST (STATE_FRONTFACE)
1155
1156enum fogsource {
1157 FOGSOURCE_FFP,
1158 FOGSOURCE_VS,
1159 FOGSOURCE_COORD,
1160};
1161
1162#define WINED3D_MAX_FBO_ENTRIES 64
1163
1164struct wined3d_occlusion_query
1165{
1166 struct list entry;
1167 GLuint id;
1168 struct wined3d_context *context;
1169};
1170
1171struct wined3d_event_query
1172{
1173 struct list entry;
1174 GLuint id;
1175 struct wined3d_context *context;
1176};
1177
1178struct wined3d_context
1179{
1180 const struct wined3d_gl_info *gl_info;
1181 /* State dirtification
1182 * dirtyArray is an array that contains markers for dirty states. numDirtyEntries states are dirty, their numbers are in indices
1183 * 0...numDirtyEntries - 1. isStateDirty is a redundant copy of the dirtyArray. Technically only one of them would be needed,
1184 * but with the help of both it is easy to find out if a state is dirty(just check the array index), and for applying dirty states
1185 * only numDirtyEntries array elements have to be checked, not STATE_HIGHEST states.
1186 */
1187 DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */
1188 DWORD numDirtyEntries;
1189 DWORD isStateDirty[STATE_HIGHEST/32 + 1]; /* Bitmap to find out quickly if a state is dirty */
1190
1191 IWineD3DSurface *surface;
1192 IWineD3DSurface *current_rt;
1193 DWORD tid; /* Thread ID which owns this context at the moment */
1194
1195 /* Stores some information about the context state for optimization */
1196 WORD render_offscreen : 1;
1197 WORD draw_buffer_dirty : 1;
1198 WORD last_was_rhw : 1; /* true iff last draw_primitive was in xyzrhw mode */
1199 WORD last_was_pshader : 1;
1200 WORD last_was_vshader : 1;
1201 WORD namedArraysLoaded : 1;
1202 WORD numberedArraysLoaded : 1;
1203 WORD last_was_blit : 1;
1204 WORD last_was_ckey : 1;
1205 WORD fog_coord : 1;
1206 WORD isPBuffer : 1;
1207 WORD fog_enabled : 1;
1208 WORD num_untracked_materials : 2; /* Max value 2 */
1209 WORD current : 1;
1210 WORD destroyed : 1;
1211 BYTE texShaderBumpMap; /* MAX_TEXTURES, 8 */
1212 BYTE lastWasPow2Texture; /* MAX_TEXTURES, 8 */
1213 DWORD numbered_array_mask;
1214 GLenum tracking_parm; /* Which source is tracking current colour */
1215 GLenum untracked_materials[2];
1216 UINT blit_w, blit_h;
1217 enum fogsource fog_source;
1218
1219 char *vshader_const_dirty, *pshader_const_dirty;
1220
1221 /* The actual opengl context */
1222 HGLRC glCtx;
1223 HWND win_handle;
1224 HDC hdc;
1225 HPBUFFERARB pbuffer;
1226 GLint aux_buffers;
1227
1228 /* FBOs */
1229 UINT fbo_entry_count;
1230 struct list fbo_list;
1231 struct fbo_entry *current_fbo;
1232 GLuint src_fbo;
1233 GLuint dst_fbo;
1234 GLuint fbo_read_binding;
1235 GLuint fbo_draw_binding;
1236
1237 /* Queries */
1238 GLuint *free_occlusion_queries;
1239 UINT free_occlusion_query_size;
1240 UINT free_occlusion_query_count;
1241 struct list occlusion_queries;
1242
1243 GLuint *free_event_queries;
1244 UINT free_event_query_size;
1245 UINT free_event_query_count;
1246 struct list event_queries;
1247
1248 /* Extension emulation */
1249 GLint gl_fog_source;
1250 GLfloat fog_coord_value;
1251 GLfloat color[4], fogstart, fogend, fogcolor[4];
1252 GLuint dummy_arbfp_prog;
1253};
1254
1255typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *ctx);
1256
1257struct StateEntry
1258{
1259 DWORD representative;
1260 APPLYSTATEFUNC apply;
1261};
1262
1263struct StateEntryTemplate
1264{
1265 DWORD state;
1266 struct StateEntry content;
1267 GL_SupportedExt extension;
1268};
1269
1270struct fragment_caps
1271{
1272 DWORD PrimitiveMiscCaps;
1273 DWORD TextureOpCaps;
1274 DWORD MaxTextureBlendStages;
1275 DWORD MaxSimultaneousTextures;
1276};
1277
1278struct fragment_pipeline
1279{
1280 void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);
1281 void (*get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
1282 HRESULT (*alloc_private)(IWineD3DDevice *iface);
1283 void (*free_private)(IWineD3DDevice *iface);
1284 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
1285 const struct StateEntryTemplate *states;
1286 BOOL ffp_proj_control;
1287};
1288
1289extern const struct StateEntryTemplate misc_state_template[] DECLSPEC_HIDDEN;
1290extern const struct StateEntryTemplate ffp_vertexstate_template[] DECLSPEC_HIDDEN;
1291extern const struct fragment_pipeline ffp_fragment_pipeline DECLSPEC_HIDDEN;
1292extern const struct fragment_pipeline atifs_fragment_pipeline DECLSPEC_HIDDEN;
1293extern const struct fragment_pipeline arbfp_fragment_pipeline DECLSPEC_HIDDEN;
1294extern const struct fragment_pipeline nvts_fragment_pipeline DECLSPEC_HIDDEN;
1295extern const struct fragment_pipeline nvrc_fragment_pipeline DECLSPEC_HIDDEN;
1296
1297/* "Base" state table */
1298HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
1299 const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex,
1300 const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
1301
1302/* Shaders for color conversions in blits */
1303struct blit_shader
1304{
1305 HRESULT (*alloc_private)(IWineD3DDevice *iface);
1306 void (*free_private)(IWineD3DDevice *iface);
1307 HRESULT (*set_shader)(IWineD3DDevice *iface, const struct GlPixelFormatDesc *format_desc,
1308 GLenum textype, UINT width, UINT height);
1309 void (*unset_shader)(IWineD3DDevice *iface);
1310 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
1311};
1312
1313extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
1314extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
1315
1316typedef enum ContextUsage {
1317 CTXUSAGE_RESOURCELOAD = 1, /* Only loads textures: No State is applied */
1318 CTXUSAGE_DRAWPRIM = 2, /* OpenGL states are set up for blitting DirectDraw surfaces */
1319 CTXUSAGE_BLIT = 3, /* OpenGL states are set up 3D drawing */
1320 CTXUSAGE_CLEAR = 4, /* Drawable and states are set up for clearing */
1321} ContextUsage;
1322
1323struct wined3d_context *ActivateContext(IWineD3DDeviceImpl *This,
1324 IWineD3DSurface *target, enum ContextUsage usage) DECLSPEC_HIDDEN;
1325struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win,
1326 BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms) DECLSPEC_HIDDEN;
1327void DestroyContext(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
1328void context_alloc_event_query(struct wined3d_context *context,
1329 struct wined3d_event_query *query) DECLSPEC_HIDDEN;
1330void context_alloc_occlusion_query(struct wined3d_context *context,
1331 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
1332void context_resource_released(IWineD3DDevice *iface,
1333 IWineD3DResource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
1334void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo) DECLSPEC_HIDDEN;
1335void context_attach_depth_stencil_fbo(struct wined3d_context *context,
1336 GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
1337void context_attach_surface_fbo(const struct wined3d_context *context,
1338 GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
1339void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
1340void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
1341struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
1342DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
1343BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN;
1344void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
1345
1346void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
1347HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
1348
1349/* Macros for doing basic GPU detection based on opengl capabilities */
1350#define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE])
1351#define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
1352#define WINE_D3D8_CAPABLE(gl_info) WINE_D3D7_CAPABLE(gl_info) && (gl_info->supported[ARB_MULTISAMPLE] && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
1353#define WINE_D3D9_CAPABLE(gl_info) WINE_D3D8_CAPABLE(gl_info) && (gl_info->supported[ARB_FRAGMENT_PROGRAM] && gl_info->supported[ARB_VERTEX_SHADER])
1354
1355/* Default callbacks for implicit object destruction */
1356extern ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pSurface) DECLSPEC_HIDDEN;
1357
1358/*****************************************************************************
1359 * Internal representation of a light
1360 */
1361typedef struct PLIGHTINFOEL PLIGHTINFOEL;
1362struct PLIGHTINFOEL {
1363 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
1364 DWORD OriginalIndex;
1365 LONG glIndex;
1366 BOOL changed;
1367 BOOL enabledChanged;
1368 BOOL enabled;
1369
1370 /* Converted parms to speed up swapping lights */
1371 float lightPosn[4];
1372 float lightDirn[4];
1373 float exponent;
1374 float cutoff;
1375
1376 struct list entry;
1377};
1378
1379/* The default light parameters */
1380extern const WINED3DLIGHT WINED3D_default_light DECLSPEC_HIDDEN;
1381
1382typedef struct WineD3D_PixelFormat
1383{
1384 int iPixelFormat; /* WGL pixel format */
1385 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
1386 int redSize, greenSize, blueSize, alphaSize;
1387 int depthSize, stencilSize;
1388 BOOL windowDrawable;
1389 BOOL pbufferDrawable;
1390 BOOL doubleBuffer;
1391 int auxBuffers;
1392 int numSamples;
1393} WineD3D_PixelFormat;
1394
1395/* The adapter structure */
1396struct WineD3DAdapter
1397{
1398 UINT num;
1399 BOOL opengl;
1400 POINT monitorPoint;
1401 struct wined3d_gl_info gl_info;
1402 const char *driver;
1403 const char *description;
1404 WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
1405 int nCfgs;
1406 WineD3D_PixelFormat *cfgs;
1407 BOOL brokenStencil; /* Set on cards which only offer mixed depth+stencil */
1408 unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */
1409 unsigned int UsedTextureRam;
1410};
1411
1412extern BOOL initPixelFormats(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
1413BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
1414extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram) DECLSPEC_HIDDEN;
1415extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
1416
1417/*****************************************************************************
1418 * High order patch management
1419 */
1420struct WineD3DRectPatch
1421{
1422 UINT Handle;
1423 float *mem;
1424 WineDirect3DVertexStridedData strided;
1425 WINED3DRECTPATCH_INFO RectPatchInfo;
1426 float numSegs[4];
1427 char has_normals, has_texcoords;
1428 struct list entry;
1429};
1430
1431HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, struct WineD3DRectPatch *patch) DECLSPEC_HIDDEN;
1432
1433enum projection_types
1434{
1435 proj_none = 0,
1436 proj_count3 = 1,
1437 proj_count4 = 2
1438};
1439
1440enum dst_arg
1441{
1442 resultreg = 0,
1443 tempreg = 1
1444};
1445
1446/*****************************************************************************
1447 * Fixed function pipeline replacements
1448 */
1449#define ARG_UNUSED 0xff
1450
1451struct texture_stage_op
1452{
1453 unsigned cop : 8;
1454 unsigned carg1 : 8;
1455 unsigned carg2 : 8;
1456 unsigned carg0 : 8;
1457
1458 unsigned aop : 8;
1459 unsigned aarg1 : 8;
1460 unsigned aarg2 : 8;
1461 unsigned aarg0 : 8;
1462
1463 struct color_fixup_desc color_fixup;
1464 unsigned tex_type : 3;
1465 unsigned dst : 1;
1466 unsigned projected : 2;
1467 unsigned padding : 10;
1468};
1469
1470struct ffp_frag_settings {
1471 struct texture_stage_op op[MAX_TEXTURES];
1472 enum fogmode fog;
1473 /* Use shorts instead of chars to get dword alignment */
1474 unsigned short sRGB_write;
1475 unsigned short emul_clipplanes;
1476};
1477
1478struct ffp_frag_desc
1479{
1480 struct wine_rb_entry entry;
1481 struct ffp_frag_settings settings;
1482};
1483
1484extern const struct wine_rb_functions wined3d_ffp_frag_program_rb_functions DECLSPEC_HIDDEN;
1485extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
1486
1487void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings,
1488 BOOL ignore_textype) DECLSPEC_HIDDEN;
1489const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
1490 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
1491void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
1492
1493/*****************************************************************************
1494 * IWineD3D implementation structure
1495 */
1496typedef struct IWineD3DImpl
1497{
1498 /* IUnknown fields */
1499 const IWineD3DVtbl *lpVtbl;
1500 LONG ref; /* Note: Ref counting not required */
1501
1502 /* WineD3D Information */
1503 IUnknown *parent;
1504 UINT dxVersion;
1505
1506 UINT adapter_count;
1507 struct WineD3DAdapter adapters[1];
1508} IWineD3DImpl;
1509
1510extern const IWineD3DVtbl IWineD3D_Vtbl DECLSPEC_HIDDEN;
1511
1512BOOL InitAdapters(IWineD3DImpl *This) DECLSPEC_HIDDEN;
1513
1514/* A helper function that dumps a resource list */
1515void dumpResources(struct list *list) DECLSPEC_HIDDEN;
1516
1517/*****************************************************************************
1518 * IWineD3DDevice implementation structure
1519 */
1520#define WINED3D_UNMAPPED_STAGE ~0U
1521
1522/* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
1523#define WINED3DCREATE_MULTITHREADED 0x00000004
1524
1525struct IWineD3DDeviceImpl
1526{
1527 /* IUnknown fields */
1528 const IWineD3DDeviceVtbl *lpVtbl;
1529 LONG ref; /* Note: Ref counting not required */
1530
1531 /* WineD3D Information */
1532 IUnknown *parent;
1533 IWineD3DDeviceParent *device_parent;
1534 IWineD3D *wineD3D;
1535 struct WineD3DAdapter *adapter;
1536
1537 /* Window styles to restore when switching fullscreen mode */
1538 LONG style;
1539 LONG exStyle;
1540
1541 /* X and GL Information */
1542 GLint maxConcurrentLights;
1543 GLenum offscreenBuffer;
1544
1545 /* Selected capabilities */
1546 int vs_selected_mode;
1547 int ps_selected_mode;
1548 const shader_backend_t *shader_backend;
1549 void *shader_priv;
1550 void *fragment_priv;
1551 void *blit_priv;
1552 struct StateEntry StateTable[STATE_HIGHEST + 1];
1553 /* Array of functions for states which are handled by more than one pipeline part */
1554 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
1555 const struct fragment_pipeline *frag_pipe;
1556 const struct blit_shader *blitter;
1557
1558 unsigned int max_ffp_textures, max_ffp_texture_stages;
1559 DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */
1560 DWORD vs_clipping;
1561
1562 WORD view_ident : 1; /* true iff view matrix is identity */
1563 WORD untransformed : 1;
1564 WORD vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */
1565 WORD isRecordingState : 1;
1566 WORD isInDraw : 1;
1567 WORD bCursorVisible : 1;
1568 WORD haveHardwareCursor : 1;
1569 WORD d3d_initialized : 1;
1570 WORD inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
1571 WORD softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
1572 WORD useDrawStridedSlow : 1;
1573 WORD instancedDraw : 1;
1574 WORD padding : 4;
1575
1576 BYTE fixed_function_usage_map; /* MAX_TEXTURES, 8 */
1577
1578#define DDRAW_PITCH_ALIGNMENT 8
1579#define D3D8_PITCH_ALIGNMENT 4
1580 unsigned char surface_alignment; /* Line Alignment of surfaces */
1581
1582 /* State block related */
1583 IWineD3DStateBlockImpl *stateBlock;
1584 IWineD3DStateBlockImpl *updateStateBlock;
1585
1586 /* Internal use fields */
1587 WINED3DDEVICE_CREATION_PARAMETERS createParms;
1588 UINT adapterNo;
1589 WINED3DDEVTYPE devType;
1590
1591 IWineD3DSwapChain **swapchains;
1592 UINT NumberOfSwapChains;
1593
1594 struct list resources; /* a linked list to track resources created by the device */
1595 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
1596 unsigned int highest_dirty_ps_const, highest_dirty_vs_const;
1597
1598 /* Render Target Support */
1599 IWineD3DSurface **render_targets;
1600 IWineD3DSurface *auto_depth_stencil_buffer;
1601 IWineD3DSurface *stencilBufferTarget;
1602
1603 /* palettes texture management */
1604 UINT NumberOfPalettes;
1605 PALETTEENTRY **palettes;
1606 UINT currentPalette;
1607 UINT paletteConversionShader;
1608
1609 /* For rendering to a texture using glCopyTexImage */
1610 GLenum *draw_buffers;
1611 GLuint depth_blt_texture;
1612 GLuint depth_blt_rb;
1613 UINT depth_blt_rb_w;
1614 UINT depth_blt_rb_h;
1615
1616 /* Cursor management */
1617 UINT xHotSpot;
1618 UINT yHotSpot;
1619 UINT xScreenSpace;
1620 UINT yScreenSpace;
1621 UINT cursorWidth, cursorHeight;
1622 GLuint cursorTexture;
1623 HCURSOR hardwareCursor;
1624
1625 /* The Wine logo surface */
1626 IWineD3DSurface *logo_surface;
1627
1628 /* Textures for when no other textures are mapped */
1629 UINT dummyTextureName[MAX_TEXTURES];
1630
1631 /* Device state management */
1632 HRESULT state;
1633
1634 /* DirectDraw stuff */
1635 DWORD ddraw_width, ddraw_height;
1636 WINED3DFORMAT ddraw_format;
1637
1638 /* Final position fixup constant */
1639 float posFixup[4];
1640
1641 /* With register combiners we can skip junk texture stages */
1642 DWORD texUnitMap[MAX_COMBINED_SAMPLERS];
1643 DWORD rev_tex_unit_map[MAX_COMBINED_SAMPLERS];
1644
1645 /* Stream source management */
1646 struct wined3d_stream_info strided_streams;
1647 const WineDirect3DVertexStridedData *up_strided;
1648
1649 /* Context management */
1650 struct wined3d_context **contexts;
1651 UINT numContexts;
1652 struct wined3d_context *pbufferContext; /* The context that has a pbuffer as drawable */
1653 DWORD pbufferWidth, pbufferHeight; /* Size of the buffer drawable */
1654
1655 /* High level patch management */
1656#define PATCHMAP_SIZE 43
1657#define PATCHMAP_HASHFUNC(x) ((x) % PATCHMAP_SIZE) /* Primitive and simple function */
1658 struct list patches[PATCHMAP_SIZE];
1659 struct WineD3DRectPatch *currentPatch;
1660};
1661
1662extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl DECLSPEC_HIDDEN;
1663
1664void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
1665void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
1666void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
1667 BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
1668void device_stream_info_from_strided(IWineD3DDeviceImpl *This,
1669 const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN;
1670HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
1671 const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
1672void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN;
1673void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) DECLSPEC_HIDDEN;
1674static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state)
1675{
1676 DWORD idx = state >> 5;
1677 BYTE shift = state & 0x1f;
1678 return context->isStateDirty[idx] & (1 << shift);
1679}
1680
1681/* Support for IWineD3DResource ::Set/Get/FreePrivateData. */
1682typedef struct PrivateData
1683{
1684 struct list entry;
1685
1686 GUID tag;
1687 DWORD flags; /* DDSPD_* */
1688
1689 union
1690 {
1691 LPVOID data;
1692 LPUNKNOWN object;
1693 } ptr;
1694
1695 DWORD size;
1696} PrivateData;
1697
1698/*****************************************************************************
1699 * IWineD3DResource implementation structure
1700 */
1701typedef struct IWineD3DResourceClass
1702{
1703 /* IUnknown fields */
1704 LONG ref; /* Note: Ref counting not required */
1705
1706 /* WineD3DResource Information */
1707 IUnknown *parent;
1708 WINED3DRESOURCETYPE resourceType;
1709 IWineD3DDeviceImpl *wineD3DDevice;
1710 WINED3DPOOL pool;
1711 UINT size;
1712 DWORD usage;
1713 const struct GlPixelFormatDesc *format_desc;
1714 DWORD priority;
1715 BYTE *allocatedMemory; /* Pointer to the real data location */
1716 BYTE *heapMemory; /* Pointer to the HeapAlloced block of memory */
1717 struct list privateData;
1718 struct list resource_list_entry;
1719 const struct wined3d_parent_ops *parent_ops;
1720} IWineD3DResourceClass;
1721
1722typedef struct IWineD3DResourceImpl
1723{
1724 /* IUnknown & WineD3DResource Information */
1725 const IWineD3DResourceVtbl *lpVtbl;
1726 IWineD3DResourceClass resource;
1727} IWineD3DResourceImpl;
1728
1729void resource_cleanup(IWineD3DResource *iface) DECLSPEC_HIDDEN;
1730HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid) DECLSPEC_HIDDEN;
1731HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice **device) DECLSPEC_HIDDEN;
1732HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent) DECLSPEC_HIDDEN;
1733DWORD resource_get_priority(IWineD3DResource *iface) DECLSPEC_HIDDEN;
1734HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
1735 void *data, DWORD *data_size) DECLSPEC_HIDDEN;
1736HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
1737 IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
1738 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
1739WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface) DECLSPEC_HIDDEN;
1740DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority) DECLSPEC_HIDDEN;
1741HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
1742 const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
1743
1744/* Tests show that the start address of resources is 32 byte aligned */
1745#define RESOURCE_ALIGNMENT 32
1746
1747/*****************************************************************************
1748 * IWineD3DBaseTexture D3D- > openGL state map lookups
1749 */
1750
1751typedef enum winetexturestates {
1752 WINED3DTEXSTA_ADDRESSU = 0,
1753 WINED3DTEXSTA_ADDRESSV = 1,
1754 WINED3DTEXSTA_ADDRESSW = 2,
1755 WINED3DTEXSTA_BORDERCOLOR = 3,
1756 WINED3DTEXSTA_MAGFILTER = 4,
1757 WINED3DTEXSTA_MINFILTER = 5,
1758 WINED3DTEXSTA_MIPFILTER = 6,
1759 WINED3DTEXSTA_MAXMIPLEVEL = 7,
1760 WINED3DTEXSTA_MAXANISOTROPY = 8,
1761 WINED3DTEXSTA_SRGBTEXTURE = 9,
1762 WINED3DTEXSTA_ELEMENTINDEX = 10,
1763 WINED3DTEXSTA_DMAPOFFSET = 11,
1764 WINED3DTEXSTA_TSSADDRESSW = 12,
1765 MAX_WINETEXTURESTATES = 13,
1766} winetexturestates;
1767
1768enum WINED3DSRGB
1769{
1770 SRGB_ANY = 0, /* Uses the cached value(e.g. external calls) */
1771 SRGB_RGB = 1, /* Loads the rgb texture */
1772 SRGB_SRGB = 2, /* Loads the srgb texture */
1773 SRGB_BOTH = 3, /* Loads both textures */
1774};
1775
1776struct gl_texture
1777{
1778 DWORD states[MAX_WINETEXTURESTATES];
1779 BOOL dirty;
1780 GLuint name;
1781};
1782
1783/*****************************************************************************
1784 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
1785 */
1786typedef struct IWineD3DBaseTextureClass
1787{
1788 struct gl_texture texture_rgb, texture_srgb;
1789 UINT levels;
1790 float pow2Matrix[16];
1791 UINT LOD;
1792 WINED3DTEXTUREFILTERTYPE filterType;
1793 LONG bindCount;
1794 DWORD sampler;
1795 BOOL is_srgb;
1796 BOOL pow2Matrix_identity;
1797 const struct min_lookup *minMipLookup;
1798 const GLenum *magLookup;
1799 void (*internal_preload)(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb);
1800} IWineD3DBaseTextureClass;
1801
1802void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
1803
1804typedef struct IWineD3DBaseTextureImpl
1805{
1806 /* IUnknown & WineD3DResource Information */
1807 const IWineD3DBaseTextureVtbl *lpVtbl;
1808 IWineD3DResourceClass resource;
1809 IWineD3DBaseTextureClass baseTexture;
1810
1811} IWineD3DBaseTextureImpl;
1812
1813void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
1814 const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
1815 const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]) DECLSPEC_HIDDEN;
1816HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc) DECLSPEC_HIDDEN;
1817void basetexture_cleanup(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1818void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1819WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1820BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1821DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1822DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1823HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
1824 IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
1825 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
1826HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
1827 WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
1828BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty) DECLSPEC_HIDDEN;
1829DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod) DECLSPEC_HIDDEN;
1830void basetexture_unload(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1831
1832/*****************************************************************************
1833 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
1834 */
1835typedef struct IWineD3DTextureImpl
1836{
1837 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
1838 const IWineD3DTextureVtbl *lpVtbl;
1839 IWineD3DResourceClass resource;
1840 IWineD3DBaseTextureClass baseTexture;
1841
1842 /* IWineD3DTexture */
1843 IWineD3DSurface *surfaces[MAX_MIP_LEVELS];
1844 UINT target;
1845 BOOL cond_np2;
1846
1847} IWineD3DTextureImpl;
1848
1849HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
1850 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
1851 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
1852
1853/*****************************************************************************
1854 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
1855 */
1856typedef struct IWineD3DCubeTextureImpl
1857{
1858 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
1859 const IWineD3DCubeTextureVtbl *lpVtbl;
1860 IWineD3DResourceClass resource;
1861 IWineD3DBaseTextureClass baseTexture;
1862
1863 /* IWineD3DCubeTexture */
1864 IWineD3DSurface *surfaces[6][MAX_MIP_LEVELS];
1865} IWineD3DCubeTextureImpl;
1866
1867HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
1868 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
1869 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
1870
1871typedef struct _WINED3DVOLUMET_DESC
1872{
1873 UINT Width;
1874 UINT Height;
1875 UINT Depth;
1876} WINED3DVOLUMET_DESC;
1877
1878/*****************************************************************************
1879 * IWineD3DVolume implementation structure (extends IUnknown)
1880 */
1881typedef struct IWineD3DVolumeImpl
1882{
1883 /* IUnknown & WineD3DResource fields */
1884 const IWineD3DVolumeVtbl *lpVtbl;
1885 IWineD3DResourceClass resource;
1886
1887 /* WineD3DVolume Information */
1888 WINED3DVOLUMET_DESC currentDesc;
1889 IWineD3DBase *container;
1890 BOOL lockable;
1891 BOOL locked;
1892 WINED3DBOX lockedBox;
1893 WINED3DBOX dirtyBox;
1894 BOOL dirty;
1895} IWineD3DVolumeImpl;
1896
1897void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
1898HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
1899 UINT height, UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
1900 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
1901
1902/*****************************************************************************
1903 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
1904 */
1905typedef struct IWineD3DVolumeTextureImpl
1906{
1907 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
1908 const IWineD3DVolumeTextureVtbl *lpVtbl;
1909 IWineD3DResourceClass resource;
1910 IWineD3DBaseTextureClass baseTexture;
1911
1912 /* IWineD3DVolumeTexture */
1913 IWineD3DVolume *volumes[MAX_MIP_LEVELS];
1914} IWineD3DVolumeTextureImpl;
1915
1916HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height,
1917 UINT depth, UINT levels, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
1918 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
1919
1920typedef struct _WINED3DSURFACET_DESC
1921{
1922 WINED3DMULTISAMPLE_TYPE MultiSampleType;
1923 DWORD MultiSampleQuality;
1924 UINT Width;
1925 UINT Height;
1926} WINED3DSURFACET_DESC;
1927
1928/*****************************************************************************
1929 * Structure for DIB Surfaces (GetDC and GDI surfaces)
1930 */
1931typedef struct wineD3DSurface_DIB {
1932 HBITMAP DIBsection;
1933 void* bitmap_data;
1934 UINT bitmap_size;
1935 HGDIOBJ holdbitmap;
1936 BOOL client_memory;
1937} wineD3DSurface_DIB;
1938
1939typedef struct {
1940 struct list entry;
1941 GLuint id;
1942 UINT width;
1943 UINT height;
1944} renderbuffer_entry_t;
1945
1946struct fbo_entry
1947{
1948 struct list entry;
1949 IWineD3DSurface **render_targets;
1950 IWineD3DSurface *depth_stencil;
1951 BOOL attached;
1952 GLuint id;
1953};
1954
1955/*****************************************************************************
1956 * IWineD3DClipp implementation structure
1957 */
1958typedef struct IWineD3DClipperImpl
1959{
1960 const IWineD3DClipperVtbl *lpVtbl;
1961 LONG ref;
1962
1963 IUnknown *Parent;
1964 HWND hWnd;
1965} IWineD3DClipperImpl;
1966
1967
1968/*****************************************************************************
1969 * IWineD3DSurface implementation structure
1970 */
1971struct IWineD3DSurfaceImpl
1972{
1973 /* IUnknown & IWineD3DResource Information */
1974 const IWineD3DSurfaceVtbl *lpVtbl;
1975 IWineD3DResourceClass resource;
1976
1977 /* IWineD3DSurface fields */
1978 IWineD3DBase *container;
1979 WINED3DSURFACET_DESC currentDesc;
1980 IWineD3DPaletteImpl *palette; /* D3D7 style palette handling */
1981 PALETTEENTRY *palette9; /* D3D8/9 style palette handling */
1982
1983 /* TODO: move this off into a management class(maybe!) */
1984 DWORD Flags;
1985
1986 UINT pow2Width;
1987 UINT pow2Height;
1988
1989 /* A method to retrieve the drawable size. Not in the Vtable to make it changeable */
1990 void (*get_drawable_size)(struct wined3d_context *context, UINT *width, UINT *height);
1991
1992 /* Oversized texture */
1993 RECT glRect;
1994
1995 /* PBO */
1996 GLuint pbo;
1997 GLuint texture_name;
1998 GLuint texture_name_srgb;
1999 GLint texture_level;
2000 GLenum texture_target;
2001
2002 RECT lockedRect;
2003 RECT dirtyRect;
2004 int lockCount;
2005#define MAXLOCKCOUNT 50 /* After this amount of locks do not free the sysmem copy */
2006
2007 /* For GetDC */
2008 wineD3DSurface_DIB dib;
2009 HDC hDC;
2010
2011 /* Color keys for DDraw */
2012 WINEDDCOLORKEY DestBltCKey;
2013 WINEDDCOLORKEY DestOverlayCKey;
2014 WINEDDCOLORKEY SrcOverlayCKey;
2015 WINEDDCOLORKEY SrcBltCKey;
2016 DWORD CKeyFlags;
2017
2018 WINEDDCOLORKEY glCKey;
2019
2020 struct list renderbuffers;
2021 renderbuffer_entry_t *current_renderbuffer;
2022
2023 /* DirectDraw clippers */
2024 IWineD3DClipper *clipper;
2025
2026 /* DirectDraw Overlay handling */
2027 RECT overlay_srcrect;
2028 RECT overlay_destrect;
2029 IWineD3DSurfaceImpl *overlay_dest;
2030 struct list overlays;
2031 struct list overlay_entry;
2032};
2033
2034extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl DECLSPEC_HIDDEN;
2035extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl DECLSPEC_HIDDEN;
2036
2037UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc,
2038 UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
2039void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
2040HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
2041 UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
2042 UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
2043 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
2044
2045/* Predeclare the shared Surface functions */
2046HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface,
2047 REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
2048ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2049HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) DECLSPEC_HIDDEN;
2050HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) DECLSPEC_HIDDEN;
2051HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface,
2052 REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags) DECLSPEC_HIDDEN;
2053HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface,
2054 REFGUID refguid, void *pData, DWORD *pSizeOfData) DECLSPEC_HIDDEN;
2055HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) DECLSPEC_HIDDEN;
2056DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) DECLSPEC_HIDDEN;
2057DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2058WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2059HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetContainer(IWineD3DSurface* iface,
2060 REFIID riid, void **ppContainer) DECLSPEC_HIDDEN;
2061HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc) DECLSPEC_HIDDEN;
2062HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
2063HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
2064HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2065HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2066HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) DECLSPEC_HIDDEN;
2067HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) DECLSPEC_HIDDEN;
2068HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface,
2069 DWORD Flags, const WINEDDCOLORKEY *CKey) DECLSPEC_HIDDEN;
2070HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) DECLSPEC_HIDDEN;
2071DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2072HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2073HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) DECLSPEC_HIDDEN;
2074HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) DECLSPEC_HIDDEN;
2075HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface,
2076 DWORD Flags, IWineD3DSurface *Ref) DECLSPEC_HIDDEN;
2077HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
2078 IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX) DECLSPEC_HIDDEN;
2079HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper) DECLSPEC_HIDDEN;
2080HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper) DECLSPEC_HIDDEN;
2081HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) DECLSPEC_HIDDEN;
2082HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2083HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
2084 const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
2085HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
2086 IWineD3DSurface *Source, const RECT *rsrc, DWORD trans) DECLSPEC_HIDDEN;
2087HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT *pLockedRect,
2088 const RECT *pRect, DWORD Flags) DECLSPEC_HIDDEN;
2089void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb) DECLSPEC_HIDDEN;
2090const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
2091
2092void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2093void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2094void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2095void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2096
2097void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) DECLSPEC_HIDDEN;
2098
2099/* Surface flags: */
2100#define SFLAG_OVERSIZE 0x00000001 /* Surface is bigger than gl size, blts only */
2101#define SFLAG_CONVERTED 0x00000002 /* Converted for color keying or Palettized */
2102#define SFLAG_DIBSECTION 0x00000004 /* Has a DIB section attached for GetDC */
2103#define SFLAG_LOCKABLE 0x00000008 /* Surface can be locked */
2104#define SFLAG_DISCARD 0x00000010 /* ??? */
2105#define SFLAG_LOCKED 0x00000020 /* Surface is locked atm */
2106#define SFLAG_INTEXTURE 0x00000040 /* The GL texture contains the newest surface content */
2107#define SFLAG_INSRGBTEX 0x00000080 /* The GL srgb texture contains the newest surface content */
2108#define SFLAG_INDRAWABLE 0x00000100 /* The gl drawable contains the most up to date data */
2109#define SFLAG_INSYSMEM 0x00000200 /* The system memory copy is most up to date */
2110#define SFLAG_NONPOW2 0x00000400 /* Surface sizes are not a power of 2 */
2111#define SFLAG_DYNLOCK 0x00000800 /* Surface is often locked by the app */
2112#define SFLAG_DCINUSE 0x00001000 /* Set between GetDC and ReleaseDC calls */
2113#define SFLAG_LOST 0x00002000 /* Surface lost flag for DDraw */
2114#define SFLAG_USERPTR 0x00004000 /* The application allocated the memory for this surface */
2115#define SFLAG_GLCKEY 0x00008000 /* The gl texture was created with a color key */
2116#define SFLAG_CLIENT 0x00010000 /* GL_APPLE_client_storage is used on that texture */
2117#define SFLAG_ALLOCATED 0x00020000 /* A gl texture is allocated for this surface */
2118#define SFLAG_SRGBALLOCATED 0x00040000 /* A srgb gl texture is allocated for this surface */
2119#define SFLAG_PBO 0x00080000 /* Has a PBO attached for speeding up data transfers for dynamically locked surfaces */
2120#define SFLAG_NORMCOORD 0x00100000 /* Set if the GL texture coords are normalized(non-texture rectangle) */
2121#define SFLAG_DS_ONSCREEN 0x00200000 /* Is a depth stencil, last modified onscreen */
2122#define SFLAG_DS_OFFSCREEN 0x00400000 /* Is a depth stencil, last modified offscreen */
2123#define SFLAG_INOVERLAYDRAW 0x00800000 /* Overlay drawing is in progress. Recursion prevention */
2124#define SFLAG_SWAPCHAIN 0x01000000 /* The surface is part of a swapchain */
2125
2126/* In some conditions the surface memory must not be freed:
2127 * SFLAG_OVERSIZE: Not all data can be kept in GL
2128 * SFLAG_CONVERTED: Converting the data back would take too long
2129 * SFLAG_DIBSECTION: The dib code manages the memory
2130 * SFLAG_LOCKED: The app requires access to the surface data
2131 * SFLAG_DYNLOCK: Avoid freeing the data for performance
2132 * SFLAG_PBO: PBOs don't use 'normal' memory. It is either allocated by the driver or must be NULL.
2133 * SFLAG_CLIENT: OpenGL uses our memory as backup
2134 */
2135#define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
2136 SFLAG_CONVERTED | \
2137 SFLAG_DIBSECTION | \
2138 SFLAG_LOCKED | \
2139 SFLAG_DYNLOCK | \
2140 SFLAG_USERPTR | \
2141 SFLAG_PBO | \
2142 SFLAG_CLIENT)
2143
2144#define SFLAG_LOCATIONS (SFLAG_INSYSMEM | \
2145 SFLAG_INTEXTURE | \
2146 SFLAG_INDRAWABLE | \
2147 SFLAG_INSRGBTEX)
2148
2149#define SFLAG_DS_LOCATIONS (SFLAG_DS_ONSCREEN | \
2150 SFLAG_DS_OFFSCREEN)
2151#define SFLAG_DS_DISCARDED SFLAG_DS_LOCATIONS
2152
2153BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) DECLSPEC_HIDDEN;
2154
2155typedef enum {
2156 NO_CONVERSION,
2157 CONVERT_PALETTED,
2158 CONVERT_PALETTED_CK,
2159 CONVERT_CK_565,
2160 CONVERT_CK_5551,
2161 CONVERT_CK_4444,
2162 CONVERT_CK_4444_ARGB,
2163 CONVERT_CK_1555,
2164 CONVERT_555,
2165 CONVERT_CK_RGB24,
2166 CONVERT_CK_8888,
2167 CONVERT_CK_8888_ARGB,
2168 CONVERT_RGB32_888,
2169 CONVERT_V8U8,
2170 CONVERT_L6V5U5,
2171 CONVERT_X8L8V8U8,
2172 CONVERT_Q8W8V8U8,
2173 CONVERT_V16U16,
2174 CONVERT_A4L4,
2175 CONVERT_G16R16,
2176 CONVERT_R16G16F,
2177 CONVERT_R32G32F,
2178 CONVERT_D15S1,
2179 CONVERT_D24X4S4,
2180 CONVERT_D24FS8,
2181} CONVERT_TYPES;
2182
2183HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format,
2184 GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) DECLSPEC_HIDDEN;
2185
2186BOOL palette9_changed(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
2187
2188/*****************************************************************************
2189 * IWineD3DVertexDeclaration implementation structure
2190 */
2191#define MAX_ATTRIBS 16
2192
2193struct wined3d_vertex_declaration_element
2194{
2195 const struct GlPixelFormatDesc *format_desc;
2196 BOOL ffp_valid;
2197 WORD input_slot;
2198 WORD offset;
2199 UINT output_slot;
2200 BYTE method;
2201 BYTE usage;
2202 BYTE usage_idx;
2203};
2204
2205typedef struct IWineD3DVertexDeclarationImpl {
2206 /* IUnknown Information */
2207 const IWineD3DVertexDeclarationVtbl *lpVtbl;
2208 LONG ref;
2209
2210 IUnknown *parent;
2211 const struct wined3d_parent_ops *parent_ops;
2212 IWineD3DDeviceImpl *wineD3DDevice;
2213
2214 struct wined3d_vertex_declaration_element *elements;
2215 UINT element_count;
2216
2217 DWORD streams[MAX_STREAMS];
2218 UINT num_streams;
2219 BOOL position_transformed;
2220 BOOL half_float_conv_needed;
2221} IWineD3DVertexDeclarationImpl;
2222
2223HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
2224 const WINED3DVERTEXELEMENT *elements, UINT element_count,
2225 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
2226
2227/*****************************************************************************
2228 * IWineD3DStateBlock implementation structure
2229 */
2230
2231/* Internal state Block for Begin/End/Capture/Create/Apply info */
2232/* Note: Very long winded but gl Lists are not flexible enough */
2233/* to resolve everything we need, so doing it manually for now */
2234typedef struct SAVEDSTATES {
2235 DWORD transform[(HIGHEST_TRANSFORMSTATE >> 5) + 1];
2236 WORD streamSource; /* MAX_STREAMS, 16 */
2237 WORD streamFreq; /* MAX_STREAMS, 16 */
2238 DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
2239 DWORD textureState[MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
2240 WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
2241 DWORD textures; /* MAX_COMBINED_SAMPLERS, 20 */
2242 DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
2243 WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */
2244 WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */
2245 BOOL *pixelShaderConstantsF;
2246 WORD vertexShaderConstantsB; /* MAX_CONST_B, 16 */
2247 WORD vertexShaderConstantsI; /* MAX_CONST_I, 16 */
2248 BOOL *vertexShaderConstantsF;
2249 WORD primitive_type : 1;
2250 WORD indices : 1;
2251 WORD material : 1;
2252 WORD viewport : 1;
2253 WORD vertexDecl : 1;
2254 WORD pixelShader : 1;
2255 WORD vertexShader : 1;
2256 WORD scissorRect : 1;
2257 WORD padding : 1;
2258} SAVEDSTATES;
2259
2260struct StageState {
2261 DWORD stage;
2262 DWORD state;
2263};
2264
2265struct IWineD3DStateBlockImpl
2266{
2267 /* IUnknown fields */
2268 const IWineD3DStateBlockVtbl *lpVtbl;
2269 LONG ref; /* Note: Ref counting not required */
2270
2271 /* IWineD3DStateBlock information */
2272 IUnknown *parent;
2273 IWineD3DDeviceImpl *wineD3DDevice;
2274 WINED3DSTATEBLOCKTYPE blockType;
2275
2276 /* Array indicating whether things have been set or changed */
2277 SAVEDSTATES changed;
2278
2279 /* Vertex Shader Declaration */
2280 IWineD3DVertexDeclaration *vertexDecl;
2281
2282 IWineD3DVertexShader *vertexShader;
2283
2284 /* Vertex Shader Constants */
2285 BOOL vertexShaderConstantB[MAX_CONST_B];
2286 INT vertexShaderConstantI[MAX_CONST_I * 4];
2287 float *vertexShaderConstantF;
2288
2289 /* primitive type */
2290 GLenum gl_primitive_type;
2291
2292 /* Stream Source */
2293 BOOL streamIsUP;
2294 UINT streamStride[MAX_STREAMS];
2295 UINT streamOffset[MAX_STREAMS + 1 /* tesselated pseudo-stream */ ];
2296 IWineD3DBuffer *streamSource[MAX_STREAMS];
2297 UINT streamFreq[MAX_STREAMS + 1];
2298 UINT streamFlags[MAX_STREAMS + 1]; /*0 | WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA */
2299
2300 /* Indices */
2301 IWineD3DBuffer* pIndexData;
2302 WINED3DFORMAT IndexFmt;
2303 INT baseVertexIndex;
2304 INT loadBaseVertexIndex; /* non-indexed drawing needs 0 here, indexed baseVertexIndex */
2305
2306 /* Transform */
2307 WINED3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
2308
2309 /* Light hashmap . Collisions are handled using standard wine double linked lists */
2310#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
2311#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
2312 struct list lightMap[LIGHTMAP_SIZE]; /* Mashmap containing the lights */
2313 PLIGHTINFOEL *activeLights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
2314
2315 /* Clipping */
2316 double clipplane[MAX_CLIPPLANES][4];
2317 WINED3DCLIPSTATUS clip_status;
2318
2319 /* ViewPort */
2320 WINED3DVIEWPORT viewport;
2321
2322 /* Material */
2323 WINED3DMATERIAL material;
2324
2325 /* Pixel Shader */
2326 IWineD3DPixelShader *pixelShader;
2327
2328 /* Pixel Shader Constants */
2329 BOOL pixelShaderConstantB[MAX_CONST_B];
2330 INT pixelShaderConstantI[MAX_CONST_I * 4];
2331 float *pixelShaderConstantF;
2332
2333 /* RenderState */
2334 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
2335
2336 /* Texture */
2337 IWineD3DBaseTexture *textures[MAX_COMBINED_SAMPLERS];
2338
2339 /* Texture State Stage */
2340 DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
2341 DWORD lowest_disabled_stage;
2342 /* Sampler States */
2343 DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
2344
2345 /* Scissor test rectangle */
2346 RECT scissorRect;
2347
2348 /* Contained state management */
2349 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
2350 unsigned int num_contained_render_states;
2351 DWORD contained_transform_states[HIGHEST_TRANSFORMSTATE + 1];
2352 unsigned int num_contained_transform_states;
2353 DWORD contained_vs_consts_i[MAX_CONST_I];
2354 unsigned int num_contained_vs_consts_i;
2355 DWORD contained_vs_consts_b[MAX_CONST_B];
2356 unsigned int num_contained_vs_consts_b;
2357 DWORD *contained_vs_consts_f;
2358 unsigned int num_contained_vs_consts_f;
2359 DWORD contained_ps_consts_i[MAX_CONST_I];
2360 unsigned int num_contained_ps_consts_i;
2361 DWORD contained_ps_consts_b[MAX_CONST_B];
2362 unsigned int num_contained_ps_consts_b;
2363 DWORD *contained_ps_consts_f;
2364 unsigned int num_contained_ps_consts_f;
2365 struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
2366 unsigned int num_contained_tss_states;
2367 struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
2368 unsigned int num_contained_sampler_states;
2369};
2370
2371extern void stateblock_savedstates_set(IWineD3DStateBlock *iface, SAVEDSTATES *states, BOOL value) DECLSPEC_HIDDEN;
2372extern void stateblock_copy(IWineD3DStateBlock *destination, IWineD3DStateBlock *source) DECLSPEC_HIDDEN;
2373
2374extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl DECLSPEC_HIDDEN;
2375
2376/* Direct3D terminology with little modifications. We do not have an issued state
2377 * because only the driver knows about it, but we have a created state because d3d
2378 * allows GetData on a created issue, but opengl doesn't
2379 */
2380enum query_state {
2381 QUERY_CREATED,
2382 QUERY_SIGNALLED,
2383 QUERY_BUILDING
2384};
2385/*****************************************************************************
2386 * IWineD3DQueryImpl implementation structure (extends IUnknown)
2387 */
2388typedef struct IWineD3DQueryImpl
2389{
2390 const IWineD3DQueryVtbl *lpVtbl;
2391 LONG ref; /* Note: Ref counting not required */
2392
2393 IUnknown *parent;
2394 /*TODO: replace with iface usage */
2395#if 0
2396 IWineD3DDevice *wineD3DDevice;
2397#else
2398 IWineD3DDeviceImpl *wineD3DDevice;
2399#endif
2400
2401 /* IWineD3DQuery fields */
2402 enum query_state state;
2403 WINED3DQUERYTYPE type;
2404 /* TODO: Think about using a IUnknown instead of a void* */
2405 void *extendedData;
2406} IWineD3DQueryImpl;
2407
2408extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl DECLSPEC_HIDDEN;
2409extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl DECLSPEC_HIDDEN;
2410extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl DECLSPEC_HIDDEN;
2411
2412/* IWineD3DBuffer */
2413
2414/* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
2415 * fixed function semantics as D3DCOLOR or FLOAT16 */
2416enum wined3d_buffer_conversion_type
2417{
2418 CONV_NONE,
2419 CONV_D3DCOLOR,
2420 CONV_POSITIONT,
2421 CONV_FLOAT16_2, /* Also handles FLOAT16_4 */
2422};
2423
2424#define WINED3D_BUFFER_OPTIMIZED 0x01 /* Optimize has been called for the buffer */
2425#define WINED3D_BUFFER_DIRTY 0x02 /* Buffer data has been modified */
2426#define WINED3D_BUFFER_HASDESC 0x04 /* A vertex description has been found */
2427#define WINED3D_BUFFER_CREATEBO 0x08 /* Attempt to create a buffer object next PreLoad */
2428#define WINED3D_BUFFER_DOUBLEBUFFER 0x10 /* Use a vbo and local allocated memory */
2429
2430struct wined3d_buffer
2431{
2432 const struct IWineD3DBufferVtbl *vtbl;
2433 IWineD3DResourceClass resource;
2434
2435 struct wined3d_buffer_desc desc;
2436
2437 GLuint buffer_object;
2438 GLenum buffer_object_usage;
2439 GLenum buffer_type_hint;
2440 UINT buffer_object_size;
2441 LONG bind_count;
2442 DWORD flags;
2443
2444 UINT dirty_start;
2445 UINT dirty_end;
2446 LONG lock_count;
2447
2448 /* conversion stuff */
2449 UINT conversion_count;
2450 UINT draw_count;
2451 UINT stride; /* 0 if no conversion */
2452 UINT conversion_stride; /* 0 if no shifted conversion */
2453 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
2454 /* Extra load offsets, for FLOAT16 conversion */
2455 UINT *conversion_shift; /* NULL if no shifted conversion */
2456};
2457
2458const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object) DECLSPEC_HIDDEN;
2459BYTE *buffer_get_sysmem(struct wined3d_buffer *This) DECLSPEC_HIDDEN;
2460HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
2461 UINT size, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, GLenum bind_hint,
2462 const char *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
2463
2464/* IWineD3DRendertargetView */
2465struct wined3d_rendertarget_view
2466{
2467 const struct IWineD3DRendertargetViewVtbl *vtbl;
2468 LONG refcount;
2469
2470 IWineD3DResource *resource;
2471 IUnknown *parent;
2472};
2473
2474extern const IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl DECLSPEC_HIDDEN;
2475
2476/*****************************************************************************
2477 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
2478 */
2479
2480typedef struct IWineD3DSwapChainImpl
2481{
2482 /*IUnknown part*/
2483 const IWineD3DSwapChainVtbl *lpVtbl;
2484 LONG ref; /* Note: Ref counting not required */
2485
2486 IUnknown *parent;
2487 IWineD3DDeviceImpl *wineD3DDevice;
2488
2489 /* IWineD3DSwapChain fields */
2490 IWineD3DSurface **backBuffer;
2491 IWineD3DSurface *frontBuffer;
2492 WINED3DPRESENT_PARAMETERS presentParms;
2493 DWORD orig_width, orig_height;
2494 WINED3DFORMAT orig_fmt;
2495 WINED3DGAMMARAMP orig_gamma;
2496
2497 long prev_time, frames; /* Performance tracking */
2498 unsigned int vSyncCounter;
2499
2500 struct wined3d_context **context;
2501 unsigned int num_contexts;
2502
2503 HWND win_handle;
2504} IWineD3DSwapChainImpl;
2505
2506extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl DECLSPEC_HIDDEN;
2507const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl DECLSPEC_HIDDEN;
2508void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc) DECLSPEC_HIDDEN;
2509
2510HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface,
2511 REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
2512ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
2513ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
2514HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown **ppParent) DECLSPEC_HIDDEN;
2515HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface,
2516 IWineD3DSurface *pDestSurface) DECLSPEC_HIDDEN;
2517HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer,
2518 WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) DECLSPEC_HIDDEN;
2519HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface,
2520 WINED3DRASTER_STATUS *pRasterStatus) DECLSPEC_HIDDEN;
2521HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface,
2522 WINED3DDISPLAYMODE *pMode) DECLSPEC_HIDDEN;
2523HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface,
2524 IWineD3DDevice **ppDevice) DECLSPEC_HIDDEN;
2525HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface,
2526 WINED3DPRESENT_PARAMETERS *pPresentationParameters) DECLSPEC_HIDDEN;
2527HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
2528 DWORD Flags, const WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
2529HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
2530 WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
2531
2532struct wined3d_context *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
2533
2534#define DEFAULT_REFRESH_RATE 0
2535
2536/*****************************************************************************
2537 * Utility function prototypes
2538 */
2539
2540/* Trace routines */
2541const char *debug_d3dformat(WINED3DFORMAT fmt) DECLSPEC_HIDDEN;
2542const char *debug_d3ddevicetype(WINED3DDEVTYPE devtype) DECLSPEC_HIDDEN;
2543const char *debug_d3dresourcetype(WINED3DRESOURCETYPE res) DECLSPEC_HIDDEN;
2544const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
2545const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
2546const char *debug_d3ddeclmethod(WINED3DDECLMETHOD method) DECLSPEC_HIDDEN;
2547const char *debug_d3ddeclusage(BYTE usage) DECLSPEC_HIDDEN;
2548const char *debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) DECLSPEC_HIDDEN;
2549const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN;
2550const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN;
2551const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
2552const char *debug_d3dtexturestate(DWORD state) DECLSPEC_HIDDEN;
2553const char *debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) DECLSPEC_HIDDEN;
2554const char *debug_d3dpool(WINED3DPOOL pool) DECLSPEC_HIDDEN;
2555const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
2556const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
2557const char *debug_d3dbasis(WINED3DBASISTYPE basis) DECLSPEC_HIDDEN;
2558const char *debug_d3ddegree(WINED3DDEGREETYPE order) DECLSPEC_HIDDEN;
2559const char *debug_d3dtop(WINED3DTEXTUREOP d3dtop) DECLSPEC_HIDDEN;
2560void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
2561const char *debug_surflocation(DWORD flag) DECLSPEC_HIDDEN;
2562
2563/* Routines for GL <-> D3D values */
2564GLenum StencilOp(DWORD op) DECLSPEC_HIDDEN;
2565GLenum CompareFunc(DWORD func) DECLSPEC_HIDDEN;
2566BOOL is_invalid_op(IWineD3DDeviceImpl *This, int stage, WINED3DTEXTUREOP op,
2567 DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
2568void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op,
2569 DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
2570void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords,
2571 BOOL transformed, DWORD coordtype, BOOL ffp_can_disable_proj) DECLSPEC_HIDDEN;
2572void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock,
2573 struct wined3d_context *context) DECLSPEC_HIDDEN;
2574void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock,
2575 struct wined3d_context *context) DECLSPEC_HIDDEN;
2576void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock,
2577 struct wined3d_context *context) DECLSPEC_HIDDEN;
2578void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock,
2579 struct wined3d_context *context) DECLSPEC_HIDDEN;
2580void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock,
2581 struct wined3d_context *context) DECLSPEC_HIDDEN;
2582void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock,
2583 struct wined3d_context *context) DECLSPEC_HIDDEN;
2584void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock,
2585 struct wined3d_context *context) DECLSPEC_HIDDEN;
2586void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
2587 struct wined3d_context *context) DECLSPEC_HIDDEN;
2588
2589void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect) DECLSPEC_HIDDEN;
2590GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
2591void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
2592void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location) DECLSPEC_HIDDEN;
2593void surface_set_compatible_renderbuffer(IWineD3DSurface *iface,
2594 unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
2595void surface_set_texture_name(IWineD3DSurface *iface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
2596void surface_set_texture_target(IWineD3DSurface *iface, GLenum target) DECLSPEC_HIDDEN;
2597
2598BOOL getColorBits(const struct GlPixelFormatDesc *format_desc,
2599 short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize) DECLSPEC_HIDDEN;
2600BOOL getDepthStencilBits(const struct GlPixelFormatDesc *format_desc,
2601 short *depthSize, short *stencilSize) DECLSPEC_HIDDEN;
2602
2603/* Math utils */
2604void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2) DECLSPEC_HIDDEN;
2605UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN;
2606unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN;
2607
2608typedef struct local_constant {
2609 struct list entry;
2610 unsigned int idx;
2611 DWORD value[4];
2612} local_constant;
2613
2614typedef struct SHADER_LIMITS {
2615 unsigned int temporary;
2616 unsigned int texcoord;
2617 unsigned int sampler;
2618 unsigned int constant_int;
2619 unsigned int constant_float;
2620 unsigned int constant_bool;
2621 unsigned int address;
2622 unsigned int packed_output;
2623 unsigned int packed_input;
2624 unsigned int attributes;
2625 unsigned int label;
2626} SHADER_LIMITS;
2627
2628/* Keeps track of details for TEX_M#x# shader opcodes which need to
2629 * maintain state information between multiple codes */
2630typedef struct SHADER_PARSE_STATE {
2631 unsigned int current_row;
2632 DWORD texcoord_w[2];
2633} SHADER_PARSE_STATE;
2634
2635#ifdef __GNUC__
2636#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
2637#else
2638#define PRINTF_ATTR(fmt,args)
2639#endif
2640
2641/* Base Shader utility functions. */
2642int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
2643int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
2644
2645/* Vertex shader utility functions */
2646extern BOOL vshader_get_input(IWineD3DVertexShader *iface,
2647 BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
2648
2649extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) DECLSPEC_HIDDEN;
2650
2651/*****************************************************************************
2652 * IDirect3DBaseShader implementation structure
2653 */
2654typedef struct IWineD3DBaseShaderClass
2655{
2656 LONG ref;
2657 SHADER_LIMITS limits;
2658 SHADER_PARSE_STATE parse_state;
2659 DWORD *function;
2660 UINT functionLength;
2661 UINT cur_loop_depth, cur_loop_regno;
2662 BOOL load_local_constsF;
2663 const struct wined3d_shader_frontend *frontend;
2664 void *frontend_data;
2665 void *backend_data;
2666
2667 IUnknown *parent;
2668 const struct wined3d_parent_ops *parent_ops;
2669
2670 /* Programs this shader is linked with */
2671 struct list linked_programs;
2672
2673 /* Immediate constants (override global ones) */
2674 struct list constantsB;
2675 struct list constantsF;
2676 struct list constantsI;
2677 shader_reg_maps reg_maps;
2678
2679 /* Pointer to the parent device */
2680 IWineD3DDevice *device;
2681 struct list shader_list_entry;
2682
2683} IWineD3DBaseShaderClass;
2684
2685typedef struct IWineD3DBaseShaderImpl {
2686 /* IUnknown */
2687 const IWineD3DBaseShaderVtbl *lpVtbl;
2688
2689 /* IWineD3DBaseShader */
2690 IWineD3DBaseShaderClass baseShader;
2691} IWineD3DBaseShaderImpl;
2692
2693void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
2694BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
2695void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
2696void shader_cleanup(IWineD3DBaseShader *iface) DECLSPEC_HIDDEN;
2697void shader_dump_src_param(const struct wined3d_shader_src_param *param,
2698 const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
2699void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
2700 const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
2701unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN;
2702void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
2703 const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
2704HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
2705 struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
2706 struct wined3d_shader_signature_element *input_signature,
2707 struct wined3d_shader_signature_element *output_signature,
2708 const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN;
2709void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
2710 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
2711BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN;
2712const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN;
2713void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN;
2714
2715static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
2716{
2717 return type == WINED3D_SHADER_TYPE_PIXEL;
2718}
2719
2720static inline BOOL shader_is_vshader_version(enum wined3d_shader_type type)
2721{
2722 return type == WINED3D_SHADER_TYPE_VERTEX;
2723}
2724
2725static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
2726{
2727 switch (reg->type)
2728 {
2729 case WINED3DSPR_RASTOUT:
2730 /* oFog & oPts */
2731 if (reg->idx != 0) return TRUE;
2732 /* oPos */
2733 return FALSE;
2734
2735 case WINED3DSPR_DEPTHOUT: /* oDepth */
2736 case WINED3DSPR_CONSTBOOL: /* b# */
2737 case WINED3DSPR_LOOP: /* aL */
2738 case WINED3DSPR_PREDICATE: /* p0 */
2739 return TRUE;
2740
2741 case WINED3DSPR_MISCTYPE:
2742 switch(reg->idx)
2743 {
2744 case 0: /* vPos */
2745 return FALSE;
2746 case 1: /* vFace */
2747 return TRUE;
2748 default:
2749 return FALSE;
2750 }
2751
2752 case WINED3DSPR_IMMCONST:
2753 switch(reg->immconst_type)
2754 {
2755 case WINED3D_IMMCONST_FLOAT:
2756 return TRUE;
2757 default:
2758 return FALSE;
2759 }
2760
2761 default:
2762 return FALSE;
2763 }
2764}
2765
2766static inline BOOL shader_constant_is_local(IWineD3DBaseShaderImpl* This, DWORD reg) {
2767 local_constant* lconst;
2768
2769 if(This->baseShader.load_local_constsF) return FALSE;
2770 LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
2771 if(lconst->idx == reg) return TRUE;
2772 }
2773 return FALSE;
2774
2775}
2776
2777/*****************************************************************************
2778 * IDirect3DVertexShader implementation structures
2779 */
2780typedef struct IWineD3DVertexShaderImpl {
2781 /* IUnknown parts */
2782 const IWineD3DVertexShaderVtbl *lpVtbl;
2783
2784 /* IWineD3DBaseShader */
2785 IWineD3DBaseShaderClass baseShader;
2786
2787 /* Vertex shader input and output semantics */
2788 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
2789 struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
2790
2791 UINT min_rel_offset, max_rel_offset;
2792 UINT rel_offset;
2793} IWineD3DVertexShaderImpl;
2794
2795void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,
2796 struct vs_compile_args *args) DECLSPEC_HIDDEN;
2797HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device,
2798 const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
2799 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
2800
2801/*****************************************************************************
2802 * IDirect3DPixelShader implementation structure
2803 */
2804
2805/* Using additional shader constants (uniforms in GLSL / program environment
2806 * or local parameters in ARB) is costly:
2807 * ARB only knows float4 parameters and GLSL compiler are not really smart
2808 * when it comes to efficiently pack float2 uniforms, so no space is wasted
2809 * (in fact most compilers map a float2 to a full float4 uniform).
2810 *
2811 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
2812 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
2813 * into a single shader constant (uniform / program parameter).
2814 *
2815 * This structure is shared between the GLSL and the ARB backend.*/
2816struct ps_np2fixup_info {
2817 unsigned char idx[MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
2818 WORD active; /* bitfield indicating if we can apply the fixup */
2819 WORD num_consts;
2820};
2821
2822typedef struct IWineD3DPixelShaderImpl {
2823 /* IUnknown parts */
2824 const IWineD3DPixelShaderVtbl *lpVtbl;
2825
2826 /* IWineD3DBaseShader */
2827 IWineD3DBaseShaderClass baseShader;
2828
2829 /* Pixel shader input semantics */
2830 struct wined3d_shader_signature_element input_signature[MAX_REG_INPUT];
2831 DWORD input_reg_map[MAX_REG_INPUT];
2832 BOOL input_reg_used[MAX_REG_INPUT];
2833 unsigned int declared_in_count;
2834
2835 /* Some information about the shader behavior */
2836 char vpos_uniform;
2837
2838 BOOL color0_mov;
2839 DWORD color0_reg;
2840
2841} IWineD3DPixelShaderImpl;
2842
2843HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
2844 const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
2845 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
2846void pixelshader_update_samplers(struct shader_reg_maps *reg_maps,
2847 IWineD3DBaseTexture * const *textures) DECLSPEC_HIDDEN;
2848void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,
2849 struct ps_compile_args *args) DECLSPEC_HIDDEN;
2850
2851/* sRGB correction constants */
2852static const float srgb_cmp = 0.0031308f;
2853static const float srgb_mul_low = 12.92f;
2854static const float srgb_pow = 0.41666f;
2855static const float srgb_mul_high = 1.055f;
2856static const float srgb_sub_high = 0.055f;
2857
2858/*****************************************************************************
2859 * IWineD3DPalette implementation structure
2860 */
2861struct IWineD3DPaletteImpl {
2862 /* IUnknown parts */
2863 const IWineD3DPaletteVtbl *lpVtbl;
2864 LONG ref;
2865
2866 IUnknown *parent;
2867 IWineD3DDeviceImpl *wineD3DDevice;
2868
2869 /* IWineD3DPalette */
2870 HPALETTE hpal;
2871 WORD palVersion; /*| */
2872 WORD palNumEntries; /*| LOGPALETTE */
2873 PALETTEENTRY palents[256]; /*| */
2874 /* This is to store the palette in 'screen format' */
2875 int screen_palents[256];
2876 DWORD Flags;
2877};
2878
2879extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl DECLSPEC_HIDDEN;
2880DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags) DECLSPEC_HIDDEN;
2881
2882/* DirectDraw utility functions */
2883extern WINED3DFORMAT pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
2884
2885/*****************************************************************************
2886 * Pixel format management
2887 */
2888
2889/* WineD3D pixel format flags */
2890#define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x1
2891#define WINED3DFMT_FLAG_FILTERING 0x2
2892#define WINED3DFMT_FLAG_DEPTH 0x4
2893#define WINED3DFMT_FLAG_STENCIL 0x8
2894#define WINED3DFMT_FLAG_RENDERTARGET 0x10
2895#define WINED3DFMT_FLAG_FOURCC 0x20
2896#define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x40
2897#define WINED3DFMT_FLAG_COMPRESSED 0x80
2898#define WINED3DFMT_FLAG_GETDC 0x100
2899
2900struct GlPixelFormatDesc
2901{
2902 WINED3DFORMAT format;
2903 DWORD red_mask;
2904 DWORD green_mask;
2905 DWORD blue_mask;
2906 DWORD alpha_mask;
2907 UINT byte_count;
2908 WORD depth_size;
2909 WORD stencil_size;
2910
2911 UINT block_width;
2912 UINT block_height;
2913 UINT block_byte_count;
2914
2915 enum wined3d_ffp_emit_idx emit_idx;
2916 GLint component_count;
2917 GLenum gl_vtx_type;
2918 GLint gl_vtx_format;
2919 GLboolean gl_normalized;
2920 unsigned int component_size;
2921
2922 GLint glInternal;
2923 GLint glGammaInternal;
2924 GLint rtInternal;
2925 GLint glFormat;
2926 GLint glType;
2927 unsigned int Flags;
2928 float heightscale;
2929 struct color_fixup_desc color_fixup;
2930};
2931
2932const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
2933 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2934
2935static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
2936{
2937 /* Check stateblock->vertexDecl to allow this to be used from
2938 * IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because
2939 * stateblock->vertexShader implies a vertex declaration instead of ddraw
2940 * style strided data. */
2941 return (stateblock->vertexShader
2942 && !((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed
2943 && stateblock->wineD3DDevice->vs_selected_mode != SHADER_NONE);
2944}
2945
2946static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
2947{
2948 return (stateblock->pixelShader
2949 && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE);
2950}
2951
2952void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface,
2953 WINED3DRECT *src_rect, IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect,
2954 const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) DECLSPEC_HIDDEN;
2955
2956/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
2957#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
2958
2959#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette