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