wined3d: Store the sRGB constants as wined3d_vec4 structures.
[wine.git] / dlls / wined3d / wined3d_private.h
blobe5d52ea38f8de12d3f15ffc5ae9d5dc37cd28ea3
1 /*
2 * Direct3D wine internal private include file
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 * Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #ifndef __WINE_WINED3D_PRIVATE_H
26 #define __WINE_WINED3D_PRIVATE_H
28 #ifdef USE_WIN32_OPENGL
29 #define WINE_GLAPI __stdcall
30 #else
31 #define WINE_GLAPI
32 #endif
34 #include <assert.h>
35 #include <stdarg.h>
36 #include <math.h>
37 #include <limits.h>
38 #include "ntstatus.h"
39 #define WIN32_NO_STATUS
40 #define NONAMELESSUNION
41 #define NONAMELESSSTRUCT
42 #define COBJMACROS
43 #include "windef.h"
44 #include "winbase.h"
45 #include "winreg.h"
46 #include "wingdi.h"
47 #include "winuser.h"
48 #include "winternl.h"
49 #include "ddk/d3dkmthk.h"
50 #include "wine/debug.h"
51 #include "wine/heap.h"
52 #include "wine/unicode.h"
54 #include "objbase.h"
55 #include "wine/wined3d.h"
56 #include "wined3d_gl.h"
57 #include "wined3d_vk.h"
58 #include "wine/list.h"
59 #include "wine/rbtree.h"
60 #include "wine/wgl_driver.h"
62 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
64 /* Driver quirks */
65 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
66 #define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
67 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
68 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
69 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
70 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
71 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
72 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
73 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
74 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
75 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
77 struct wined3d_fragment_pipe_ops;
78 struct wined3d_adapter;
79 struct wined3d_context;
80 struct wined3d_state;
81 struct wined3d_swapchain_gl;
82 struct wined3d_texture_gl;
83 struct wined3d_vertex_pipe_ops;
85 enum wined3d_ffp_idx
87 WINED3D_FFP_POSITION = 0,
88 WINED3D_FFP_BLENDWEIGHT = 1,
89 WINED3D_FFP_BLENDINDICES = 2,
90 WINED3D_FFP_NORMAL = 3,
91 WINED3D_FFP_PSIZE = 4,
92 WINED3D_FFP_DIFFUSE = 5,
93 WINED3D_FFP_SPECULAR = 6,
94 WINED3D_FFP_TEXCOORD0 = 7,
95 WINED3D_FFP_TEXCOORD1 = 8,
96 WINED3D_FFP_TEXCOORD2 = 9,
97 WINED3D_FFP_TEXCOORD3 = 10,
98 WINED3D_FFP_TEXCOORD4 = 11,
99 WINED3D_FFP_TEXCOORD5 = 12,
100 WINED3D_FFP_TEXCOORD6 = 13,
101 WINED3D_FFP_TEXCOORD7 = 14,
102 WINED3D_FFP_ATTRIBS_COUNT = 15,
105 enum wined3d_ffp_emit_idx
107 WINED3D_FFP_EMIT_FLOAT1,
108 WINED3D_FFP_EMIT_FLOAT2,
109 WINED3D_FFP_EMIT_FLOAT3,
110 WINED3D_FFP_EMIT_FLOAT4,
111 WINED3D_FFP_EMIT_D3DCOLOR,
112 WINED3D_FFP_EMIT_UBYTE4,
113 WINED3D_FFP_EMIT_SHORT2,
114 WINED3D_FFP_EMIT_SHORT4,
115 WINED3D_FFP_EMIT_UBYTE4N,
116 WINED3D_FFP_EMIT_SHORT2N,
117 WINED3D_FFP_EMIT_SHORT4N,
118 WINED3D_FFP_EMIT_USHORT2N,
119 WINED3D_FFP_EMIT_USHORT4N,
120 WINED3D_FFP_EMIT_UDEC3,
121 WINED3D_FFP_EMIT_DEC3N,
122 WINED3D_FFP_EMIT_FLOAT16_2,
123 WINED3D_FFP_EMIT_FLOAT16_4,
124 WINED3D_FFP_EMIT_INVALID,
125 WINED3D_FFP_EMIT_COUNT,
128 /* Texture format fixups */
130 enum fixup_channel_source
132 CHANNEL_SOURCE_ZERO = 0,
133 CHANNEL_SOURCE_ONE = 1,
134 CHANNEL_SOURCE_X = 2,
135 CHANNEL_SOURCE_Y = 3,
136 CHANNEL_SOURCE_Z = 4,
137 CHANNEL_SOURCE_W = 5,
138 CHANNEL_SOURCE_COMPLEX0 = 6,
139 CHANNEL_SOURCE_COMPLEX1 = 7,
142 enum complex_fixup
144 COMPLEX_FIXUP_NONE = 0,
145 COMPLEX_FIXUP_YUY2 = 1,
146 COMPLEX_FIXUP_UYVY = 2,
147 COMPLEX_FIXUP_YV12 = 3,
148 COMPLEX_FIXUP_P8 = 4,
149 COMPLEX_FIXUP_NV12 = 5,
152 #include <pshpack2.h>
153 struct color_fixup_desc
155 unsigned short x_sign_fixup : 1;
156 unsigned short x_source : 3;
157 unsigned short y_sign_fixup : 1;
158 unsigned short y_source : 3;
159 unsigned short z_sign_fixup : 1;
160 unsigned short z_source : 3;
161 unsigned short w_sign_fixup : 1;
162 unsigned short w_source : 3;
164 #include <poppack.h>
166 struct wined3d_d3d_limits
168 unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
169 DWORD vs_uniform_count;
170 DWORD ps_uniform_count;
171 unsigned int varying_count;
172 unsigned int ffp_textures;
173 unsigned int ffp_blend_stages;
174 unsigned int ffp_vertex_blend_matrices;
175 unsigned int active_light_count;
177 unsigned int max_rt_count;
178 unsigned int max_clip_distances;
179 unsigned int texture_size;
180 float pointsize_max;
183 typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
184 typedef void (WINE_GLAPI *wined3d_ffp_texcoord_func)(GLenum unit, const void *data);
185 typedef void (WINE_GLAPI *wined3d_generic_attrib_func)(GLuint idx, const void *data);
186 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
188 struct wined3d_ffp_attrib_ops
190 wined3d_ffp_attrib_func position[WINED3D_FFP_EMIT_COUNT];
191 wined3d_ffp_attrib_func diffuse[WINED3D_FFP_EMIT_COUNT];
192 wined3d_ffp_attrib_func specular[WINED3D_FFP_EMIT_COUNT];
193 wined3d_ffp_attrib_func normal[WINED3D_FFP_EMIT_COUNT];
194 wined3d_ffp_texcoord_func texcoord[WINED3D_FFP_EMIT_COUNT];
195 wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT];
198 struct wined3d_d3d_info
200 struct wined3d_d3d_limits limits;
201 struct wined3d_ffp_attrib_ops ffp_attrib_ops;
202 uint32_t wined3d_creation_flags;
203 uint32_t xyzrhw : 1;
204 uint32_t emulated_flatshading : 1;
205 uint32_t ffp_generic_attributes : 1;
206 uint32_t ffp_alpha_test : 1;
207 uint32_t vs_clipping : 1;
208 uint32_t shader_color_key : 1;
209 uint32_t shader_double_precision : 1;
210 uint32_t shader_output_interpolation : 1;
211 uint32_t viewport_array_index_any_shader : 1;
212 uint32_t texture_npot : 1;
213 uint32_t texture_npot_conditional : 1;
214 uint32_t draw_base_vertex_offset : 1;
215 uint32_t vertex_bgra : 1;
216 uint32_t texture_swizzle : 1;
217 uint32_t srgb_read_control : 1;
218 uint32_t srgb_write_control : 1;
219 uint32_t clip_control : 1;
220 uint32_t full_ffp_varyings : 1;
221 enum wined3d_feature_level feature_level;
223 DWORD multisample_draw_location;
226 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
227 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
229 static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
231 struct color_fixup_desc fixup =
233 0u, complex_fixup & (1u << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
234 0u, complex_fixup & (1u << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
235 0u, complex_fixup & (1u << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
236 0u, complex_fixup & (1u << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
238 return fixup;
241 static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
243 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
246 static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
248 return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
251 static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
253 return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
256 static inline BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
258 return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
259 && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
260 && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
261 && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
264 static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
266 enum complex_fixup complex_fixup = 0;
267 if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
268 if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
269 if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
270 if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
271 return complex_fixup;
274 /* Device caps */
275 #define WINED3D_MAX_STREAMS 16
276 #define WINED3D_MAX_TEXTURES 8
277 #define WINED3D_MAX_FRAGMENT_SAMPLERS 16
278 #define WINED3D_MAX_VERTEX_SAMPLERS 4
279 #define WINED3D_MAX_COMBINED_SAMPLERS (WINED3D_MAX_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS)
280 #define WINED3D_MAX_ACTIVE_LIGHTS 8
281 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
282 #define WINED3D_MAX_CLIP_DISTANCES 8
283 #define MAX_CONSTANT_BUFFERS 15
284 #define MAX_SAMPLER_OBJECTS 16
285 #define MAX_SHADER_RESOURCE_VIEWS 128
286 #define MAX_RENDER_TARGET_VIEWS 8
287 #define MAX_UNORDERED_ACCESS_VIEWS 8
288 #define MAX_TGSM_REGISTERS 8192
289 #define MAX_VERTEX_BLENDS 4
291 struct min_lookup
293 GLenum mip[WINED3D_TEXF_LINEAR + 1];
296 extern const struct min_lookup minMipLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
297 extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
299 GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN;
301 static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
303 if (func < WINED3D_CMP_NEVER || func > WINED3D_CMP_ALWAYS)
304 return WINED3D_CMP_ALWAYS;
305 return func;
308 static inline GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
310 return magLookup[mag_filter];
313 static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,
314 enum wined3d_texture_filter_type mip_filter)
316 return minMipLookup[min_filter].mip[mip_filter];
319 /* float_16_to_32() and float_32_to_16() (see implementation in
320 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
321 * to standard C floats and vice versa. They do not depend on the encoding
322 * of the C float, so they are platform independent, but slow. On x86 and
323 * other IEEE 754 compliant platforms the conversion can be accelerated by
324 * bit shifting the exponent and mantissa. There are also some SSE-based
325 * assembly routines out there.
327 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
329 static inline float float_16_to_32(const unsigned short *in)
331 const unsigned short s = ((*in) & 0x8000u);
332 const unsigned short e = ((*in) & 0x7c00u) >> 10;
333 const unsigned short m = (*in) & 0x3ffu;
334 const float sgn = (s ? -1.0f : 1.0f);
336 if(e == 0) {
337 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
338 else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
339 } else if(e < 31) {
340 return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
341 } else {
342 if(m == 0) return sgn * INFINITY;
343 else return NAN;
347 static inline float float_24_to_32(DWORD in)
349 const float sgn = in & 0x800000u ? -1.0f : 1.0f;
350 const unsigned short e = (in & 0x780000u) >> 19;
351 const unsigned int m = in & 0x7ffffu;
353 if (e == 0)
355 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
356 else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
358 else if (e < 15)
360 return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
362 else
364 if (m == 0) return sgn * INFINITY;
365 else return NAN;
369 static inline unsigned int wined3d_popcount(unsigned int x)
371 #ifdef HAVE___BUILTIN_POPCOUNT
372 return __builtin_popcount(x);
373 #else
374 x -= x >> 1 & 0x55555555;
375 x = (x & 0x33333333) + (x >> 2 & 0x33333333);
376 return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
377 #endif
380 static inline void wined3d_pause(void)
382 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
383 __asm__ __volatile__( "rep;nop" : : : "memory" );
384 #endif
387 #define ORM_BACKBUFFER 0
388 #define ORM_FBO 1
390 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
391 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
393 enum wined3d_renderer
395 WINED3D_RENDERER_AUTO,
396 WINED3D_RENDERER_VULKAN,
397 WINED3D_RENDERER_OPENGL,
398 WINED3D_RENDERER_NO3D,
401 enum wined3d_shader_backend
403 WINED3D_SHADER_BACKEND_AUTO,
404 WINED3D_SHADER_BACKEND_GLSL,
405 WINED3D_SHADER_BACKEND_ARB,
406 WINED3D_SHADER_BACKEND_NONE,
409 /* NOTE: When adding fields to this structure, make sure to update the default
410 * values in wined3d_main.c as well. */
411 struct wined3d_settings
413 unsigned int cs_multithreaded;
414 DWORD max_gl_version;
415 int offscreen_rendering_mode;
416 unsigned short pci_vendor_id;
417 unsigned short pci_device_id;
418 /* Memory tracking and object counting. */
419 UINT64 emulated_textureram;
420 char *logo;
421 unsigned int multisample_textures;
422 unsigned int sample_count;
423 BOOL check_float_constants;
424 unsigned int strict_shader_math;
425 unsigned int max_sm_vs;
426 unsigned int max_sm_hs;
427 unsigned int max_sm_ds;
428 unsigned int max_sm_gs;
429 unsigned int max_sm_ps;
430 unsigned int max_sm_cs;
431 enum wined3d_renderer renderer;
432 enum wined3d_shader_backend shader_backend;
435 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
437 enum wined3d_shader_byte_code_format
439 WINED3D_SHADER_BYTE_CODE_FORMAT_SM1,
440 WINED3D_SHADER_BYTE_CODE_FORMAT_SM4,
443 enum wined3d_shader_resource_type
445 WINED3D_SHADER_RESOURCE_NONE,
446 WINED3D_SHADER_RESOURCE_BUFFER,
447 WINED3D_SHADER_RESOURCE_TEXTURE_1D,
448 WINED3D_SHADER_RESOURCE_TEXTURE_2D,
449 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
450 WINED3D_SHADER_RESOURCE_TEXTURE_3D,
451 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
452 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
453 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
454 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
455 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
458 #define WINED3D_SHADER_CONST_VS_F 0x00000001
459 #define WINED3D_SHADER_CONST_VS_I 0x00000002
460 #define WINED3D_SHADER_CONST_VS_B 0x00000004
461 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
462 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
463 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
464 #define WINED3D_SHADER_CONST_PS_F 0x00000040
465 #define WINED3D_SHADER_CONST_PS_I 0x00000080
466 #define WINED3D_SHADER_CONST_PS_B 0x00000100
467 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
468 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
469 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
470 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
471 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
472 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
473 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
474 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
475 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
476 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
477 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
478 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
479 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
480 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
482 enum wined3d_shader_register_type
484 WINED3DSPR_TEMP = 0,
485 WINED3DSPR_INPUT = 1,
486 WINED3DSPR_CONST = 2,
487 WINED3DSPR_ADDR = 3,
488 WINED3DSPR_TEXTURE = 3,
489 WINED3DSPR_RASTOUT = 4,
490 WINED3DSPR_ATTROUT = 5,
491 WINED3DSPR_TEXCRDOUT = 6,
492 WINED3DSPR_OUTPUT = 6,
493 WINED3DSPR_CONSTINT = 7,
494 WINED3DSPR_COLOROUT = 8,
495 WINED3DSPR_DEPTHOUT = 9,
496 WINED3DSPR_SAMPLER = 10,
497 WINED3DSPR_CONST2 = 11,
498 WINED3DSPR_CONST3 = 12,
499 WINED3DSPR_CONST4 = 13,
500 WINED3DSPR_CONSTBOOL = 14,
501 WINED3DSPR_LOOP = 15,
502 WINED3DSPR_TEMPFLOAT16 = 16,
503 WINED3DSPR_MISCTYPE = 17,
504 WINED3DSPR_LABEL = 18,
505 WINED3DSPR_PREDICATE = 19,
506 WINED3DSPR_IMMCONST,
507 WINED3DSPR_CONSTBUFFER,
508 WINED3DSPR_IMMCONSTBUFFER,
509 WINED3DSPR_PRIMID,
510 WINED3DSPR_NULL,
511 WINED3DSPR_RESOURCE,
512 WINED3DSPR_UAV,
513 WINED3DSPR_OUTPOINTID,
514 WINED3DSPR_FORKINSTID,
515 WINED3DSPR_JOININSTID,
516 WINED3DSPR_INCONTROLPOINT,
517 WINED3DSPR_OUTCONTROLPOINT,
518 WINED3DSPR_PATCHCONST,
519 WINED3DSPR_TESSCOORD,
520 WINED3DSPR_GROUPSHAREDMEM,
521 WINED3DSPR_THREADID,
522 WINED3DSPR_THREADGROUPID,
523 WINED3DSPR_LOCALTHREADID,
524 WINED3DSPR_LOCALTHREADINDEX,
525 WINED3DSPR_IDXTEMP,
526 WINED3DSPR_STREAM,
527 WINED3DSPR_FUNCTIONBODY,
528 WINED3DSPR_FUNCTIONPOINTER,
529 WINED3DSPR_COVERAGE,
530 WINED3DSPR_SAMPLEMASK,
531 WINED3DSPR_GSINSTID,
532 WINED3DSPR_DEPTHOUTGE,
533 WINED3DSPR_DEPTHOUTLE,
534 WINED3DSPR_RASTERIZER,
537 enum wined3d_data_type
539 WINED3D_DATA_FLOAT,
540 WINED3D_DATA_INT,
541 WINED3D_DATA_RESOURCE,
542 WINED3D_DATA_SAMPLER,
543 WINED3D_DATA_UAV,
544 WINED3D_DATA_UINT,
545 WINED3D_DATA_UNORM,
546 WINED3D_DATA_SNORM,
547 WINED3D_DATA_OPAQUE,
550 enum wined3d_immconst_type
552 WINED3D_IMMCONST_SCALAR,
553 WINED3D_IMMCONST_VEC4,
556 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
558 enum wined3d_shader_src_modifier
560 WINED3DSPSM_NONE = 0,
561 WINED3DSPSM_NEG = 1,
562 WINED3DSPSM_BIAS = 2,
563 WINED3DSPSM_BIASNEG = 3,
564 WINED3DSPSM_SIGN = 4,
565 WINED3DSPSM_SIGNNEG = 5,
566 WINED3DSPSM_COMP = 6,
567 WINED3DSPSM_X2 = 7,
568 WINED3DSPSM_X2NEG = 8,
569 WINED3DSPSM_DZ = 9,
570 WINED3DSPSM_DW = 10,
571 WINED3DSPSM_ABS = 11,
572 WINED3DSPSM_ABSNEG = 12,
573 WINED3DSPSM_NOT = 13,
576 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
577 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
578 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
579 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
580 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
582 enum wined3d_shader_dst_modifier
584 WINED3DSPDM_NONE = 0,
585 WINED3DSPDM_SATURATE = 1,
586 WINED3DSPDM_PARTIALPRECISION = 2,
587 WINED3DSPDM_MSAMPCENTROID = 4,
590 enum wined3d_shader_interpolation_mode
592 WINED3DSIM_NONE = 0,
593 WINED3DSIM_CONSTANT = 1,
594 WINED3DSIM_LINEAR = 2,
595 WINED3DSIM_LINEAR_CENTROID = 3,
596 WINED3DSIM_LINEAR_NOPERSPECTIVE = 4,
597 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
598 WINED3DSIM_LINEAR_SAMPLE = 6,
599 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
602 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
603 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
605 enum wined3d_shader_global_flags
607 WINED3DSGF_REFACTORING_ALLOWED = 0x1,
608 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4,
609 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8,
612 enum wined3d_shader_sync_flags
614 WINED3DSSF_THREAD_GROUP = 0x1,
615 WINED3DSSF_GROUP_SHARED_MEMORY = 0x2,
618 enum wined3d_shader_uav_flags
620 WINED3DSUF_GLOBALLY_COHERENT = 0x2,
621 WINED3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
624 enum wined3d_tessellator_domain
626 WINED3D_TESSELLATOR_DOMAIN_LINE = 1,
627 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
628 WINED3D_TESSELLATOR_DOMAIN_QUAD = 3,
631 enum wined3d_tessellator_output_primitive
633 WINED3D_TESSELLATOR_OUTPUT_POINT = 1,
634 WINED3D_TESSELLATOR_OUTPUT_LINE = 2,
635 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
636 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
639 enum wined3d_tessellator_partitioning
641 WINED3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
642 WINED3D_TESSELLATOR_PARTITIONING_POW2 = 2,
643 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
644 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
647 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
648 #define WINED3DSI_TEXLD_PROJECT 0x1
649 #define WINED3DSI_TEXLD_BIAS 0x2
650 #define WINED3DSI_INDEXED_DYNAMIC 0x4
651 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
652 #define WINED3DSI_RESINFO_UINT 0x2
653 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
654 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
656 #define WINED3DSI_PRECISE_X 0x100
657 #define WINED3DSI_PRECISE_Y 0x200
658 #define WINED3DSI_PRECISE_Z 0x400
659 #define WINED3DSI_PRECISE_W 0x800
660 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
661 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
662 #define WINED3DSI_PRECISE_SHIFT 8
664 enum wined3d_shader_rel_op
666 WINED3D_SHADER_REL_OP_GT = 1,
667 WINED3D_SHADER_REL_OP_EQ = 2,
668 WINED3D_SHADER_REL_OP_GE = 3,
669 WINED3D_SHADER_REL_OP_LT = 4,
670 WINED3D_SHADER_REL_OP_NE = 5,
671 WINED3D_SHADER_REL_OP_LE = 6,
674 enum wined3d_shader_conditional_op
676 WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
677 WINED3D_SHADER_CONDITIONAL_OP_Z = 1
680 #define WINED3D_SM1_VS 0xfffeu
681 #define WINED3D_SM1_PS 0xffffu
682 #define WINED3D_SM4_PS 0x0000u
683 #define WINED3D_SM4_VS 0x0001u
684 #define WINED3D_SM4_GS 0x0002u
685 #define WINED3D_SM5_HS 0x0003u
686 #define WINED3D_SM5_DS 0x0004u
687 #define WINED3D_SM5_CS 0x0005u
689 /* Shader version tokens, and shader end tokens */
690 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
691 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
693 /* Shader backends */
695 /* TODO: Make this dynamic, based on shader limits ? */
696 #define MAX_ATTRIBS 16
697 #define MAX_REG_ADDR 1
698 #define MAX_REG_TEXCRD 8
699 #define MAX_REG_INPUT 32
700 #define MAX_REG_OUTPUT 32
701 #define WINED3D_MAX_CBS 15
702 #define WINED3D_MAX_CONSTS_B 16
703 #define WINED3D_MAX_CONSTS_I 16
704 #define WINED3D_MAX_VS_CONSTS_F 256
705 #define WINED3D_MAX_PS_CONSTS_F 224
707 /* FIXME: This needs to go up to 2048 for
708 * Shader model 3 according to msdn (and for software shaders) */
709 #define MAX_LABELS 16
711 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
713 struct wined3d_string_buffer
715 struct list entry;
716 char *buffer;
717 unsigned int buffer_size;
718 unsigned int content_size;
721 enum WINED3D_SHADER_INSTRUCTION_HANDLER
723 WINED3DSIH_ABS,
724 WINED3DSIH_ADD,
725 WINED3DSIH_AND,
726 WINED3DSIH_ATOMIC_AND,
727 WINED3DSIH_ATOMIC_CMP_STORE,
728 WINED3DSIH_ATOMIC_IADD,
729 WINED3DSIH_ATOMIC_IMAX,
730 WINED3DSIH_ATOMIC_IMIN,
731 WINED3DSIH_ATOMIC_OR,
732 WINED3DSIH_ATOMIC_UMAX,
733 WINED3DSIH_ATOMIC_UMIN,
734 WINED3DSIH_ATOMIC_XOR,
735 WINED3DSIH_BEM,
736 WINED3DSIH_BFI,
737 WINED3DSIH_BFREV,
738 WINED3DSIH_BREAK,
739 WINED3DSIH_BREAKC,
740 WINED3DSIH_BREAKP,
741 WINED3DSIH_BUFINFO,
742 WINED3DSIH_CALL,
743 WINED3DSIH_CALLNZ,
744 WINED3DSIH_CASE,
745 WINED3DSIH_CMP,
746 WINED3DSIH_CND,
747 WINED3DSIH_CONTINUE,
748 WINED3DSIH_CONTINUEP,
749 WINED3DSIH_COUNTBITS,
750 WINED3DSIH_CRS,
751 WINED3DSIH_CUT,
752 WINED3DSIH_CUT_STREAM,
753 WINED3DSIH_DCL,
754 WINED3DSIH_DCL_CONSTANT_BUFFER,
755 WINED3DSIH_DCL_FUNCTION_BODY,
756 WINED3DSIH_DCL_FUNCTION_TABLE,
757 WINED3DSIH_DCL_GLOBAL_FLAGS,
758 WINED3DSIH_DCL_GS_INSTANCES,
759 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT,
760 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT,
761 WINED3DSIH_DCL_HS_MAX_TESSFACTOR,
762 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
763 WINED3DSIH_DCL_INDEX_RANGE,
764 WINED3DSIH_DCL_INDEXABLE_TEMP,
765 WINED3DSIH_DCL_INPUT,
766 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT,
767 WINED3DSIH_DCL_INPUT_PRIMITIVE,
768 WINED3DSIH_DCL_INPUT_PS,
769 WINED3DSIH_DCL_INPUT_PS_SGV,
770 WINED3DSIH_DCL_INPUT_PS_SIV,
771 WINED3DSIH_DCL_INPUT_SGV,
772 WINED3DSIH_DCL_INPUT_SIV,
773 WINED3DSIH_DCL_INTERFACE,
774 WINED3DSIH_DCL_OUTPUT,
775 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT,
776 WINED3DSIH_DCL_OUTPUT_SIV,
777 WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
778 WINED3DSIH_DCL_RESOURCE_RAW,
779 WINED3DSIH_DCL_RESOURCE_STRUCTURED,
780 WINED3DSIH_DCL_SAMPLER,
781 WINED3DSIH_DCL_STREAM,
782 WINED3DSIH_DCL_TEMPS,
783 WINED3DSIH_DCL_TESSELLATOR_DOMAIN,
784 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE,
785 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING,
786 WINED3DSIH_DCL_TGSM_RAW,
787 WINED3DSIH_DCL_TGSM_STRUCTURED,
788 WINED3DSIH_DCL_THREAD_GROUP,
789 WINED3DSIH_DCL_UAV_RAW,
790 WINED3DSIH_DCL_UAV_STRUCTURED,
791 WINED3DSIH_DCL_UAV_TYPED,
792 WINED3DSIH_DCL_VERTICES_OUT,
793 WINED3DSIH_DEF,
794 WINED3DSIH_DEFAULT,
795 WINED3DSIH_DEFB,
796 WINED3DSIH_DEFI,
797 WINED3DSIH_DIV,
798 WINED3DSIH_DP2,
799 WINED3DSIH_DP2ADD,
800 WINED3DSIH_DP3,
801 WINED3DSIH_DP4,
802 WINED3DSIH_DST,
803 WINED3DSIH_DSX,
804 WINED3DSIH_DSX_COARSE,
805 WINED3DSIH_DSX_FINE,
806 WINED3DSIH_DSY,
807 WINED3DSIH_DSY_COARSE,
808 WINED3DSIH_DSY_FINE,
809 WINED3DSIH_ELSE,
810 WINED3DSIH_EMIT,
811 WINED3DSIH_EMIT_STREAM,
812 WINED3DSIH_ENDIF,
813 WINED3DSIH_ENDLOOP,
814 WINED3DSIH_ENDREP,
815 WINED3DSIH_ENDSWITCH,
816 WINED3DSIH_EQ,
817 WINED3DSIH_EVAL_SAMPLE_INDEX,
818 WINED3DSIH_EXP,
819 WINED3DSIH_EXPP,
820 WINED3DSIH_F16TOF32,
821 WINED3DSIH_F32TOF16,
822 WINED3DSIH_FCALL,
823 WINED3DSIH_FIRSTBIT_HI,
824 WINED3DSIH_FIRSTBIT_LO,
825 WINED3DSIH_FIRSTBIT_SHI,
826 WINED3DSIH_FRC,
827 WINED3DSIH_FTOI,
828 WINED3DSIH_FTOU,
829 WINED3DSIH_GATHER4,
830 WINED3DSIH_GATHER4_C,
831 WINED3DSIH_GATHER4_PO,
832 WINED3DSIH_GATHER4_PO_C,
833 WINED3DSIH_GE,
834 WINED3DSIH_HS_CONTROL_POINT_PHASE,
835 WINED3DSIH_HS_DECLS,
836 WINED3DSIH_HS_FORK_PHASE,
837 WINED3DSIH_HS_JOIN_PHASE,
838 WINED3DSIH_IADD,
839 WINED3DSIH_IBFE,
840 WINED3DSIH_IEQ,
841 WINED3DSIH_IF,
842 WINED3DSIH_IFC,
843 WINED3DSIH_IGE,
844 WINED3DSIH_ILT,
845 WINED3DSIH_IMAD,
846 WINED3DSIH_IMAX,
847 WINED3DSIH_IMIN,
848 WINED3DSIH_IMM_ATOMIC_ALLOC,
849 WINED3DSIH_IMM_ATOMIC_AND,
850 WINED3DSIH_IMM_ATOMIC_CMP_EXCH,
851 WINED3DSIH_IMM_ATOMIC_CONSUME,
852 WINED3DSIH_IMM_ATOMIC_EXCH,
853 WINED3DSIH_IMM_ATOMIC_IADD,
854 WINED3DSIH_IMM_ATOMIC_IMAX,
855 WINED3DSIH_IMM_ATOMIC_IMIN,
856 WINED3DSIH_IMM_ATOMIC_OR,
857 WINED3DSIH_IMM_ATOMIC_UMAX,
858 WINED3DSIH_IMM_ATOMIC_UMIN,
859 WINED3DSIH_IMM_ATOMIC_XOR,
860 WINED3DSIH_IMUL,
861 WINED3DSIH_INE,
862 WINED3DSIH_INEG,
863 WINED3DSIH_ISHL,
864 WINED3DSIH_ISHR,
865 WINED3DSIH_ITOF,
866 WINED3DSIH_LABEL,
867 WINED3DSIH_LD,
868 WINED3DSIH_LD2DMS,
869 WINED3DSIH_LD_RAW,
870 WINED3DSIH_LD_STRUCTURED,
871 WINED3DSIH_LD_UAV_TYPED,
872 WINED3DSIH_LIT,
873 WINED3DSIH_LOD,
874 WINED3DSIH_LOG,
875 WINED3DSIH_LOGP,
876 WINED3DSIH_LOOP,
877 WINED3DSIH_LRP,
878 WINED3DSIH_LT,
879 WINED3DSIH_M3x2,
880 WINED3DSIH_M3x3,
881 WINED3DSIH_M3x4,
882 WINED3DSIH_M4x3,
883 WINED3DSIH_M4x4,
884 WINED3DSIH_MAD,
885 WINED3DSIH_MAX,
886 WINED3DSIH_MIN,
887 WINED3DSIH_MOV,
888 WINED3DSIH_MOVA,
889 WINED3DSIH_MOVC,
890 WINED3DSIH_MUL,
891 WINED3DSIH_NE,
892 WINED3DSIH_NOP,
893 WINED3DSIH_NOT,
894 WINED3DSIH_NRM,
895 WINED3DSIH_OR,
896 WINED3DSIH_PHASE,
897 WINED3DSIH_POW,
898 WINED3DSIH_RCP,
899 WINED3DSIH_REP,
900 WINED3DSIH_RESINFO,
901 WINED3DSIH_RET,
902 WINED3DSIH_RETP,
903 WINED3DSIH_ROUND_NE,
904 WINED3DSIH_ROUND_NI,
905 WINED3DSIH_ROUND_PI,
906 WINED3DSIH_ROUND_Z,
907 WINED3DSIH_RSQ,
908 WINED3DSIH_SAMPLE,
909 WINED3DSIH_SAMPLE_B,
910 WINED3DSIH_SAMPLE_C,
911 WINED3DSIH_SAMPLE_C_LZ,
912 WINED3DSIH_SAMPLE_GRAD,
913 WINED3DSIH_SAMPLE_INFO,
914 WINED3DSIH_SAMPLE_LOD,
915 WINED3DSIH_SAMPLE_POS,
916 WINED3DSIH_SETP,
917 WINED3DSIH_SGE,
918 WINED3DSIH_SGN,
919 WINED3DSIH_SINCOS,
920 WINED3DSIH_SLT,
921 WINED3DSIH_SQRT,
922 WINED3DSIH_STORE_RAW,
923 WINED3DSIH_STORE_STRUCTURED,
924 WINED3DSIH_STORE_UAV_TYPED,
925 WINED3DSIH_SUB,
926 WINED3DSIH_SWAPC,
927 WINED3DSIH_SWITCH,
928 WINED3DSIH_SYNC,
929 WINED3DSIH_TEX,
930 WINED3DSIH_TEXBEM,
931 WINED3DSIH_TEXBEML,
932 WINED3DSIH_TEXCOORD,
933 WINED3DSIH_TEXDEPTH,
934 WINED3DSIH_TEXDP3,
935 WINED3DSIH_TEXDP3TEX,
936 WINED3DSIH_TEXKILL,
937 WINED3DSIH_TEXLDD,
938 WINED3DSIH_TEXLDL,
939 WINED3DSIH_TEXM3x2DEPTH,
940 WINED3DSIH_TEXM3x2PAD,
941 WINED3DSIH_TEXM3x2TEX,
942 WINED3DSIH_TEXM3x3,
943 WINED3DSIH_TEXM3x3DIFF,
944 WINED3DSIH_TEXM3x3PAD,
945 WINED3DSIH_TEXM3x3SPEC,
946 WINED3DSIH_TEXM3x3TEX,
947 WINED3DSIH_TEXM3x3VSPEC,
948 WINED3DSIH_TEXREG2AR,
949 WINED3DSIH_TEXREG2GB,
950 WINED3DSIH_TEXREG2RGB,
951 WINED3DSIH_UBFE,
952 WINED3DSIH_UDIV,
953 WINED3DSIH_UGE,
954 WINED3DSIH_ULT,
955 WINED3DSIH_UMAX,
956 WINED3DSIH_UMIN,
957 WINED3DSIH_UMUL,
958 WINED3DSIH_USHR,
959 WINED3DSIH_UTOF,
960 WINED3DSIH_XOR,
961 WINED3DSIH_TABLE_SIZE
964 struct wined3d_shader_version
966 enum wined3d_shader_type type;
967 BYTE major;
968 BYTE minor;
971 struct wined3d_shader_resource_info
973 enum wined3d_shader_resource_type type;
974 enum wined3d_data_type data_type;
975 unsigned int flags;
976 unsigned int stride;
979 #define WINED3D_SAMPLER_DEFAULT ~0x0u
981 struct wined3d_shader_sampler_map_entry
983 unsigned int resource_idx;
984 unsigned int sampler_idx;
985 unsigned int bind_idx;
988 struct wined3d_shader_sampler_map
990 struct wined3d_shader_sampler_map_entry *entries;
991 size_t size;
992 size_t count;
995 struct wined3d_shader_immediate_constant_buffer
997 unsigned int vec4_count;
998 DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
1001 struct wined3d_shader_indexable_temp
1003 struct list entry;
1004 unsigned int register_idx;
1005 unsigned int register_size;
1006 unsigned int component_count;
1009 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1011 struct wined3d_shader_reg_maps
1013 struct wined3d_shader_version shader_version;
1014 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
1015 BYTE address; /* MAX_REG_ADDR, 1 */
1016 WORD labels; /* MAX_LABELS, 16 */
1017 DWORD temporary; /* 32 */
1018 unsigned int temporary_count;
1019 DWORD *constf; /* pixel, vertex */
1020 struct list indexable_temps;
1021 const struct wined3d_shader_immediate_constant_buffer *icb;
1022 union
1024 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1025 BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1026 } u;
1027 DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1028 DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1029 WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1030 WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1031 WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1032 WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1033 UINT cb_sizes[WINED3D_MAX_CBS];
1035 struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS];
1036 struct wined3d_shader_sampler_map sampler_map;
1037 DWORD sampler_comparison_mode;
1038 BYTE bumpmat; /* WINED3D_MAX_TEXTURES, 8 */
1039 BYTE luminanceparams; /* WINED3D_MAX_TEXTURES, 8 */
1040 struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
1041 DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1042 DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1044 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1045 DWORD cull_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1046 DWORD usesnrm : 1;
1047 DWORD vpos : 1;
1048 DWORD usesdsx : 1;
1049 DWORD usesdsy : 1;
1050 DWORD usestexldd : 1;
1051 DWORD usesmova : 1;
1052 DWORD usesfacing : 1;
1053 DWORD usesrelconstF : 1;
1054 DWORD fog : 1;
1055 DWORD usestexldl : 1;
1056 DWORD usesifc : 1;
1057 DWORD usescall : 1;
1058 DWORD usespow : 1;
1059 DWORD point_size : 1;
1060 DWORD vocp : 1;
1061 DWORD input_rel_addressing : 1;
1062 DWORD viewport_array : 1;
1063 DWORD sample_mask : 1;
1064 DWORD padding : 14;
1066 DWORD rt_mask; /* Used render targets, 32 max. */
1068 /* Whether or not loops are used in this shader, and nesting depth */
1069 unsigned int loop_depth;
1070 unsigned int min_rel_offset, max_rel_offset;
1072 struct wined3d_shader_tgsm *tgsm;
1073 SIZE_T tgsm_capacity;
1074 unsigned int tgsm_count;
1077 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1078 * state information between multiple instructions. */
1079 struct wined3d_shader_tex_mx
1081 unsigned int current_row;
1082 DWORD texcoord_w[2];
1085 struct wined3d_shader_parser_state
1087 unsigned int current_loop_depth;
1088 unsigned int current_loop_reg;
1089 BOOL in_subroutine;
1092 struct wined3d_shader_context
1094 const struct wined3d_shader *shader;
1095 const struct wined3d_gl_info *gl_info;
1096 const struct wined3d_shader_reg_maps *reg_maps;
1097 struct wined3d_string_buffer *buffer;
1098 struct wined3d_shader_tex_mx *tex_mx;
1099 struct wined3d_shader_parser_state *state;
1100 void *backend_data;
1103 struct wined3d_shader_register_index
1105 const struct wined3d_shader_src_param *rel_addr;
1106 unsigned int offset;
1109 struct wined3d_shader_register
1111 enum wined3d_shader_register_type type;
1112 enum wined3d_data_type data_type;
1113 struct wined3d_shader_register_index idx[2];
1114 enum wined3d_immconst_type immconst_type;
1115 union
1117 DWORD immconst_data[4];
1118 unsigned fp_body_idx;
1119 } u;
1122 struct wined3d_shader_dst_param
1124 struct wined3d_shader_register reg;
1125 DWORD write_mask;
1126 DWORD modifiers;
1127 DWORD shift;
1130 struct wined3d_shader_src_param
1132 struct wined3d_shader_register reg;
1133 DWORD swizzle;
1134 enum wined3d_shader_src_modifier modifiers;
1137 struct wined3d_shader_index_range
1139 struct wined3d_shader_dst_param first_register;
1140 unsigned int last_register;
1143 struct wined3d_shader_semantic
1145 enum wined3d_decl_usage usage;
1146 UINT usage_idx;
1147 enum wined3d_shader_resource_type resource_type;
1148 enum wined3d_data_type resource_data_type;
1149 struct wined3d_shader_dst_param reg;
1152 enum wined3d_shader_input_sysval_semantic
1154 WINED3D_SIV_POSITION = 1,
1155 WINED3D_SIV_CLIP_DISTANCE = 2,
1156 WINED3D_SIV_CULL_DISTANCE = 3,
1157 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
1158 WINED3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
1159 WINED3D_SIV_VERTEX_ID = 6,
1160 WINED3D_SIV_PRIMITIVE_ID = 7,
1161 WINED3D_SIV_INSTANCE_ID = 8,
1162 WINED3D_SIV_IS_FRONT_FACE = 9,
1163 WINED3D_SIV_SAMPLE_INDEX = 10,
1164 WINED3D_SIV_QUAD_U0_TESS_FACTOR = 11,
1165 WINED3D_SIV_QUAD_V0_TESS_FACTOR = 12,
1166 WINED3D_SIV_QUAD_U1_TESS_FACTOR = 13,
1167 WINED3D_SIV_QUAD_V1_TESS_FACTOR = 14,
1168 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
1169 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
1170 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
1171 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
1172 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
1173 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
1174 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
1175 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
1178 struct wined3d_shader_register_semantic
1180 struct wined3d_shader_dst_param reg;
1181 enum wined3d_shader_input_sysval_semantic sysval_semantic;
1184 struct wined3d_shader_structured_resource
1186 struct wined3d_shader_dst_param reg;
1187 unsigned int byte_stride;
1190 struct wined3d_shader_tgsm
1192 unsigned int size;
1193 unsigned int stride;
1196 struct wined3d_shader_tgsm_raw
1198 struct wined3d_shader_dst_param reg;
1199 unsigned int byte_count;
1202 struct wined3d_shader_tgsm_structured
1204 struct wined3d_shader_dst_param reg;
1205 unsigned int byte_stride;
1206 unsigned int structure_count;
1209 struct wined3d_shader_thread_group_size
1211 unsigned int x, y, z;
1214 struct wined3d_shader_function_table_pointer
1216 unsigned int index;
1217 unsigned int array_size;
1218 unsigned int body_count;
1219 unsigned int table_count;
1222 struct wined3d_shader_texel_offset
1224 signed char u, v, w;
1227 struct wined3d_shader_primitive_type
1229 enum wined3d_primitive_type type;
1230 unsigned int patch_vertex_count;
1233 struct wined3d_shader_instruction
1235 const struct wined3d_shader_context *ctx;
1236 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
1237 DWORD flags;
1238 unsigned int dst_count;
1239 unsigned int src_count;
1240 const struct wined3d_shader_dst_param *dst;
1241 const struct wined3d_shader_src_param *src;
1242 struct wined3d_shader_texel_offset texel_offset;
1243 BOOL coissue;
1244 const struct wined3d_shader_src_param *predicate;
1245 union
1247 struct wined3d_shader_semantic semantic;
1248 struct wined3d_shader_register_semantic register_semantic;
1249 struct wined3d_shader_primitive_type primitive_type;
1250 struct wined3d_shader_dst_param dst;
1251 struct wined3d_shader_src_param src;
1252 unsigned int count;
1253 unsigned int index;
1254 const struct wined3d_shader_immediate_constant_buffer *icb;
1255 struct wined3d_shader_structured_resource structured_resource;
1256 struct wined3d_shader_tgsm_raw tgsm_raw;
1257 struct wined3d_shader_tgsm_structured tgsm_structured;
1258 struct wined3d_shader_thread_group_size thread_group_size;
1259 enum wined3d_tessellator_domain tessellator_domain;
1260 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1261 enum wined3d_tessellator_partitioning tessellator_partitioning;
1262 float max_tessellation_factor;
1263 struct wined3d_shader_index_range index_range;
1264 struct wined3d_shader_indexable_temp indexable_temp;
1265 struct wined3d_shader_function_table_pointer fp;
1266 } declaration;
1269 static inline BOOL wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction *ins)
1271 return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1274 struct wined3d_shader_attribute
1276 enum wined3d_decl_usage usage;
1277 UINT usage_idx;
1280 struct wined3d_shader_loop_control
1282 unsigned int count;
1283 unsigned int start;
1284 int step;
1287 struct wined3d_shader_frontend
1289 void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1290 const struct wined3d_shader_signature *output_signature);
1291 void (*shader_free)(void *data);
1292 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1293 void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1294 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1297 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
1298 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
1300 HRESULT shader_extract_from_dxbc(struct wined3d_shader *shader,
1301 unsigned int max_shader_version, enum wined3d_shader_byte_code_format *format) DECLSPEC_HIDDEN;
1302 BOOL shader_get_stream_output_register_info(const struct wined3d_shader *shader,
1303 const struct wined3d_stream_output_element *so_element, unsigned int *register_idx,
1304 unsigned int *component_idx) DECLSPEC_HIDDEN;
1306 typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
1308 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1309 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1310 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1311 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1312 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1314 struct shader_caps
1316 unsigned int vs_version;
1317 unsigned int hs_version;
1318 unsigned int ds_version;
1319 unsigned int gs_version;
1320 unsigned int ps_version;
1321 unsigned int cs_version;
1323 unsigned int vs_uniform_count;
1324 unsigned int ps_uniform_count;
1325 float ps_1x_max_value;
1326 unsigned int varying_count;
1328 DWORD wined3d_caps;
1331 enum wined3d_gl_resource_type
1333 WINED3D_GL_RES_TYPE_TEX_1D = 0,
1334 WINED3D_GL_RES_TYPE_TEX_2D = 1,
1335 WINED3D_GL_RES_TYPE_TEX_3D = 2,
1336 WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
1337 WINED3D_GL_RES_TYPE_TEX_RECT = 4,
1338 WINED3D_GL_RES_TYPE_BUFFER = 5,
1339 WINED3D_GL_RES_TYPE_RB = 6,
1340 WINED3D_GL_RES_TYPE_COUNT = 7,
1343 enum wined3d_vertex_processing_mode
1345 WINED3D_VP_MODE_FF,
1346 WINED3D_VP_MODE_SHADER,
1347 WINED3D_VP_MODE_NONE,
1350 #define WINED3D_CONST_NUM_UNUSED ~0U
1352 enum wined3d_ffp_ps_fog_mode
1354 WINED3D_FFP_PS_FOG_OFF,
1355 WINED3D_FFP_PS_FOG_LINEAR,
1356 WINED3D_FFP_PS_FOG_EXP,
1357 WINED3D_FFP_PS_FOG_EXP2,
1360 /* Stateblock dependent parameters which have to be hardcoded
1361 * into the shader code
1364 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1365 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1366 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1367 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1368 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1370 /* Used for Shader Model 1 pixel shaders to track the bound texture
1371 * type. 2D and RECT textures are separated through NP2 fixup. */
1372 enum wined3d_shader_tex_types
1374 WINED3D_SHADER_TEX_2D = 0,
1375 WINED3D_SHADER_TEX_3D = 1,
1376 WINED3D_SHADER_TEX_CUBE = 2,
1377 WINED3D_SHADER_TEX_ERR = 3,
1380 struct ps_compile_args
1382 struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
1383 enum wined3d_vertex_processing_mode vp_mode;
1384 enum wined3d_ffp_ps_fog_mode fog;
1385 DWORD tex_types; /* ps 1 - 3, 16 textures */
1386 WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1387 WORD srgb_correction;
1388 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1389 D3D9 has a limit of 16 samplers and the fixup is superfluous
1390 in D3D10 (unconditional NP2 support mandatory). */
1391 WORD np2_fixup;
1392 WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1393 WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
1394 WORD padding_to_dword;
1395 DWORD pointsprite : 1;
1396 DWORD flatshading : 1;
1397 DWORD alpha_test_func : 3;
1398 DWORD render_offscreen : 1;
1399 DWORD rt_alpha_swizzle : 8; /* MAX_RENDER_TARGET_VIEWS, 8 */
1400 DWORD padding : 18;
1403 enum fog_src_type
1405 VS_FOG_Z = 0,
1406 VS_FOG_COORD = 1
1409 struct vs_compile_args
1411 BYTE fog_src;
1412 BYTE clip_enabled : 1;
1413 BYTE point_size : 1;
1414 BYTE per_vertex_point_size : 1;
1415 BYTE flatshading : 1;
1416 BYTE next_shader_type : 3;
1417 BYTE padding : 1;
1418 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1419 unsigned int next_shader_input_count;
1420 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1423 struct ds_compile_args
1425 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1426 enum wined3d_tessellator_partitioning tessellator_partitioning;
1427 unsigned int output_count : 16;
1428 unsigned int next_shader_type : 3;
1429 unsigned int render_offscreen : 1;
1430 unsigned int padding : 12;
1431 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1434 struct gs_compile_args
1436 unsigned int output_count;
1437 enum wined3d_primitive_type primitive_type;
1438 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1441 struct wined3d_shader_backend_ops
1443 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1444 void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1445 void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1446 const struct wined3d_state *state);
1447 void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1448 const struct wined3d_state *state);
1449 void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1450 void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1451 void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1452 void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1453 const struct wined3d_state *state);
1454 void (*shader_destroy)(struct wined3d_shader *shader);
1455 HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1456 const struct wined3d_fragment_pipe_ops *fragment_pipe);
1457 void (*shader_free_private)(struct wined3d_device *device, struct wined3d_context *context);
1458 BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1459 void (*shader_free_context_data)(struct wined3d_context *context);
1460 void (*shader_init_context_state)(struct wined3d_context *context);
1461 void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps);
1462 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1463 BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1466 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
1467 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
1468 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
1470 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1472 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1473 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1474 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1475 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1477 static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1479 wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1480 wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1481 wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1482 wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1485 extern const struct wined3d_vec4 wined3d_srgb_const[] DECLSPEC_HIDDEN;
1487 static inline float wined3d_srgb_from_linear(float colour)
1489 if (colour < 0.0f)
1490 return 0.0f;
1491 if (colour < wined3d_srgb_const[1].x)
1492 return colour * wined3d_srgb_const[0].w;
1493 if (colour < 1.0f)
1494 return wined3d_srgb_const[0].y * powf(colour, wined3d_srgb_const[0].x) - wined3d_srgb_const[0].z;
1495 return 1.0f;
1498 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
1499 const struct wined3d_color *colour)
1501 colour_srgb->r = wined3d_srgb_from_linear(colour->r);
1502 colour_srgb->g = wined3d_srgb_from_linear(colour->g);
1503 colour_srgb->b = wined3d_srgb_from_linear(colour->b);
1504 colour_srgb->a = colour->a;
1507 #define WINED3D_HIGHEST_TRANSFORM_STATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */
1509 void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1510 const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1512 /* Checking of API calls */
1513 /* --------------------- */
1514 #ifndef WINE_NO_DEBUG_MSGS
1515 #define checkGLcall(A) \
1516 do { \
1517 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1518 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1519 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1520 } while(0)
1521 #else
1522 #define checkGLcall(A) do {} while(0)
1523 #endif
1525 struct wined3d_bo_address
1527 UINT_PTR buffer_object;
1528 BYTE *addr;
1531 struct wined3d_const_bo_address
1533 UINT_PTR buffer_object;
1534 const BYTE *addr;
1537 static inline struct wined3d_const_bo_address *wined3d_const_bo_address(struct wined3d_bo_address *data)
1539 return (struct wined3d_const_bo_address *)data;
1542 struct wined3d_stream_info_element
1544 const struct wined3d_format *format;
1545 struct wined3d_bo_address data;
1546 GLsizei stride;
1547 unsigned int stream_idx;
1548 unsigned int divisor;
1551 struct wined3d_stream_info
1553 struct wined3d_stream_info_element elements[MAX_ATTRIBS];
1554 DWORD position_transformed : 1;
1555 DWORD all_vbo : 1;
1556 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1557 WORD use_map; /* MAX_ATTRIBS, 16 */
1560 void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_info,
1561 const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
1563 struct wined3d_direct_dispatch_parameters
1565 unsigned int group_count_x;
1566 unsigned int group_count_y;
1567 unsigned int group_count_z;
1570 struct wined3d_indirect_dispatch_parameters
1572 struct wined3d_buffer *buffer;
1573 unsigned int offset;
1576 struct wined3d_dispatch_parameters
1578 BOOL indirect;
1579 union
1581 struct wined3d_direct_dispatch_parameters direct;
1582 struct wined3d_indirect_dispatch_parameters indirect;
1583 } u;
1586 struct wined3d_direct_draw_parameters
1588 int base_vertex_idx;
1589 unsigned int start_idx;
1590 unsigned int index_count;
1591 unsigned int start_instance;
1592 unsigned int instance_count;
1595 struct wined3d_indirect_draw_parameters
1597 struct wined3d_buffer *buffer;
1598 unsigned int offset;
1601 struct wined3d_draw_parameters
1603 BOOL indirect;
1604 union
1606 struct wined3d_direct_draw_parameters direct;
1607 struct wined3d_indirect_draw_parameters indirect;
1608 } u;
1609 BOOL indexed;
1612 void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
1613 const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
1614 void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
1615 const struct wined3d_dispatch_parameters *dispatch_parameters) DECLSPEC_HIDDEN;
1617 #define eps 1e-8f
1619 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1620 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1622 enum wined3d_pipeline
1624 WINED3D_PIPELINE_GRAPHICS,
1625 WINED3D_PIPELINE_COMPUTE,
1626 WINED3D_PIPELINE_COUNT,
1629 /* Routines and structures related to state management */
1631 #define STATE_RENDER(a) (a)
1632 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1634 #define STATE_TEXTURESTAGE(stage, num) \
1635 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1636 #define STATE_IS_TEXTURESTAGE(a) \
1637 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1639 /* + 1 because samplers start with 0 */
1640 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1641 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1643 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1644 #define STATE_IS_GRAPHICS_SHADER(a) \
1645 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1647 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1648 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1649 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1650 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1652 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1653 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1655 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1656 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1658 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1659 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1661 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1662 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1663 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1664 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1666 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1667 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1669 #define STATE_VIEWPORT (STATE_VDECL + 1)
1670 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1672 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1673 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1674 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1675 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1677 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1678 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1680 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1681 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1683 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1684 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1686 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1687 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1689 #define STATE_POINTSPRITECOORDORIGIN (STATE_RASTERIZER + 1)
1690 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1692 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1693 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1695 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1696 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1698 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1699 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1701 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1702 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1704 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1705 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1707 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1708 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1710 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1711 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1713 #define STATE_COMPUTE_OFFSET (STATE_BLEND_FACTOR + 1)
1715 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1716 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1718 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1719 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1721 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1722 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1724 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1725 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1727 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1728 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1730 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1731 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1733 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1734 #define STATE_CONSTANT_BUFFER(a) \
1735 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1736 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1737 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1739 enum fogsource {
1740 FOGSOURCE_FFP,
1741 FOGSOURCE_VS,
1742 FOGSOURCE_COORD,
1745 union wined3d_gl_fence_object
1747 GLuint id;
1748 GLsync sync;
1751 enum wined3d_fence_result
1753 WINED3D_FENCE_OK,
1754 WINED3D_FENCE_WAITING,
1755 WINED3D_FENCE_NOT_STARTED,
1756 WINED3D_FENCE_WRONG_THREAD,
1757 WINED3D_FENCE_ERROR,
1760 struct wined3d_fence
1762 struct list entry;
1763 union wined3d_gl_fence_object object;
1764 struct wined3d_context_gl *context_gl;
1767 HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
1768 void wined3d_fence_destroy(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
1769 void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device) DECLSPEC_HIDDEN;
1770 enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
1771 struct wined3d_device *device) DECLSPEC_HIDDEN;
1773 /* Direct3D terminology with little modifications. We do not have an issued
1774 * state because only the driver knows about it, but we have a created state
1775 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1776 enum wined3d_query_state
1778 QUERY_CREATED,
1779 QUERY_SIGNALLED,
1780 QUERY_BUILDING
1783 struct wined3d_query_ops
1785 BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
1786 BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
1787 void (*query_destroy)(struct wined3d_query *query);
1790 struct wined3d_query
1792 LONG ref;
1794 void *parent;
1795 const struct wined3d_parent_ops *parent_ops;
1796 struct wined3d_device *device;
1797 enum wined3d_query_state state;
1798 enum wined3d_query_type type;
1799 const void *data;
1800 DWORD data_size;
1801 const struct wined3d_query_ops *query_ops;
1803 LONG counter_main, counter_retrieved;
1804 struct list poll_list_entry;
1806 GLuint buffer_object;
1807 UINT64 *map_ptr;
1810 HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
1811 const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
1812 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl,
1813 struct wined3d_query *query) DECLSPEC_HIDDEN;
1815 struct wined3d_event_query
1817 struct wined3d_query query;
1819 struct wined3d_fence fence;
1820 BOOL signalled;
1823 struct wined3d_occlusion_query
1825 struct wined3d_query query;
1827 struct list entry;
1828 GLuint id;
1829 struct wined3d_context_gl *context_gl;
1830 UINT64 samples;
1831 BOOL started;
1834 struct wined3d_timestamp_query
1836 struct wined3d_query query;
1838 struct list entry;
1839 GLuint id;
1840 struct wined3d_context_gl *context_gl;
1841 UINT64 timestamp;
1844 union wined3d_gl_so_statistics_query
1846 GLuint id[2];
1847 struct
1849 GLuint written;
1850 GLuint generated;
1851 } query;
1854 struct wined3d_so_statistics_query
1856 struct wined3d_query query;
1858 struct list entry;
1859 union wined3d_gl_so_statistics_query u;
1860 struct wined3d_context_gl *context_gl;
1861 unsigned int stream_idx;
1862 struct wined3d_query_data_so_statistics statistics;
1863 BOOL started;
1866 union wined3d_gl_pipeline_statistics_query
1868 GLuint id[11];
1869 struct
1871 GLuint vertices;
1872 GLuint primitives;
1873 GLuint vertex_shader;
1874 GLuint tess_control_shader;
1875 GLuint tess_eval_shader;
1876 GLuint geometry_shader;
1877 GLuint geometry_primitives;
1878 GLuint fragment_shader;
1879 GLuint compute_shader;
1880 GLuint clipping_input;
1881 GLuint clipping_output;
1882 } query;
1885 struct wined3d_pipeline_statistics_query
1887 struct wined3d_query query;
1889 struct list entry;
1890 union wined3d_gl_pipeline_statistics_query u;
1891 struct wined3d_context_gl *context_gl;
1892 struct wined3d_query_data_pipeline_statistics statistics;
1893 BOOL started;
1896 struct wined3d_gl_view
1898 GLenum target;
1899 GLuint name;
1902 struct wined3d_rendertarget_info
1904 struct wined3d_gl_view gl_view;
1905 struct wined3d_resource *resource;
1906 unsigned int sub_resource_idx;
1907 unsigned int layer_count;
1910 struct wined3d_fb_state
1912 struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
1913 struct wined3d_rendertarget_view *depth_stencil;
1916 #define MAX_GL_FRAGMENT_SAMPLERS 32
1918 struct wined3d_context
1920 const struct wined3d_d3d_info *d3d_info;
1921 const struct wined3d_state_entry *state_table;
1922 uint32_t dirty_graphics_states[STATE_HIGHEST / (sizeof(uint32_t) * CHAR_BIT) + 1];
1923 uint32_t dirty_compute_states[STATE_COMPUTE_COUNT / (sizeof(uint32_t) * CHAR_BIT) + 1];
1925 struct wined3d_device *device;
1926 struct wined3d_swapchain *swapchain;
1927 struct
1929 struct wined3d_texture *texture;
1930 unsigned int sub_resource_idx;
1931 } current_rt;
1933 /* Stores some information about the context state for optimization */
1934 DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1935 DWORD update_shader_resource_bindings : 1;
1936 DWORD update_compute_shader_resource_bindings : 1;
1937 DWORD update_unordered_access_view_bindings : 1;
1938 DWORD update_compute_unordered_access_view_bindings : 1;
1939 DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
1940 DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */
1941 DWORD last_was_pshader : 1;
1942 DWORD last_was_vshader : 1;
1943 DWORD last_was_diffuse : 1;
1944 DWORD last_was_specular : 1;
1945 DWORD last_was_normal : 1;
1947 DWORD last_was_ffp_blit : 1;
1948 DWORD last_was_blit : 1;
1949 DWORD last_was_ckey : 1;
1950 DWORD namedArraysLoaded : 1;
1951 DWORD texShaderBumpMap : 8; /* WINED3D_MAX_TEXTURES, 8 */
1952 DWORD lastWasPow2Texture : 8; /* WINED3D_MAX_TEXTURES, 8 */
1953 DWORD fixed_function_usage_map : 8; /* WINED3D_MAX_TEXTURES, 8 */
1954 DWORD lowest_disabled_stage : 4; /* Max WINED3D_MAX_TEXTURES, 8 */
1956 DWORD use_immediate_mode_draw : 1;
1957 DWORD uses_uavs : 1;
1958 DWORD transform_feedback_active : 1;
1959 DWORD transform_feedback_paused : 1;
1960 DWORD fog_coord : 1;
1961 DWORD render_offscreen : 1;
1962 DWORD current : 1;
1963 DWORD destroyed : 1;
1964 DWORD destroy_delayed : 1;
1965 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1966 DWORD padding : 15;
1968 DWORD constant_update_mask;
1969 DWORD numbered_array_mask;
1970 enum fogsource fog_source;
1972 UINT instance_count;
1974 void *shader_backend_data;
1975 void *fragment_pipe_data;
1977 struct wined3d_stream_info stream_info;
1979 /* Fences for GL_APPLE_flush_buffer_range */
1980 struct wined3d_fence *buffer_fences[MAX_ATTRIBS];
1981 unsigned int buffer_fence_count;
1983 unsigned int viewport_count;
1984 unsigned int scissor_rect_count;
1987 void wined3d_context_cleanup(struct wined3d_context *context) DECLSPEC_HIDDEN;
1989 HRESULT wined3d_context_no3d_init(struct wined3d_context *context_no3d,
1990 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
1992 struct wined3d_context_gl
1994 struct wined3d_context c;
1996 const struct wined3d_gl_info *gl_info;
1998 DWORD tid; /* Thread ID which owns this context at the moment. */
2000 uint32_t dc_is_private : 1;
2001 uint32_t dc_has_format : 1; /* Only meaningful for private DCs. */
2002 uint32_t fog_enabled : 1;
2003 uint32_t diffuse_attrib_to_1 : 1;
2004 uint32_t rebind_fbo : 1;
2005 uint32_t untracked_material_count : 2; /* Max value 2 */
2006 uint32_t needs_set : 1;
2007 uint32_t valid : 1;
2008 uint32_t padding : 23;
2010 uint32_t default_attrib_value_set;
2012 GLenum tracking_parm; /* Which source is tracking current colour. */
2013 GLenum untracked_materials[2];
2014 SIZE blit_size;
2015 unsigned int active_texture;
2017 GLenum *texture_type;
2019 /* The WGL context. */
2020 unsigned int level;
2021 HGLRC restore_ctx;
2022 HDC restore_dc;
2023 int restore_pf;
2024 HWND restore_pf_win;
2025 HGLRC gl_ctx;
2026 HDC dc;
2027 int pixel_format;
2028 HWND window;
2029 GLint aux_buffers;
2031 /* FBOs. */
2032 unsigned int fbo_entry_count;
2033 struct list fbo_list;
2034 struct list fbo_destroy_list;
2035 struct fbo_entry *current_fbo;
2036 GLuint fbo_read_binding;
2037 GLuint fbo_draw_binding;
2038 struct wined3d_rendertarget_info blit_targets[MAX_RENDER_TARGET_VIEWS];
2039 uint32_t draw_buffers_mask; /* Enabled draw buffers, 31 max. */
2041 /* Queries. */
2042 struct list occlusion_queries;
2043 struct list fences;
2044 struct list timestamp_queries;
2045 struct list so_statistics_queries;
2046 struct list pipeline_statistics_queries;
2048 GLuint *free_occlusion_queries;
2049 SIZE_T free_occlusion_query_size;
2050 unsigned int free_occlusion_query_count;
2052 union wined3d_gl_fence_object *free_fences;
2053 SIZE_T free_fence_size;
2054 unsigned int free_fence_count;
2056 GLuint *free_timestamp_queries;
2057 SIZE_T free_timestamp_query_size;
2058 unsigned int free_timestamp_query_count;
2060 union wined3d_gl_so_statistics_query *free_so_statistics_queries;
2061 SIZE_T free_so_statistics_query_size;
2062 unsigned int free_so_statistics_query_count;
2064 union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
2065 SIZE_T free_pipeline_statistics_query_size;
2066 unsigned int free_pipeline_statistics_query_count;
2068 GLuint blit_vbo;
2070 unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
2071 unsigned int rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS];
2073 /* Extension emulation. */
2074 GLint gl_fog_source;
2075 GLfloat fog_coord_value;
2076 GLfloat colour[4], fog_start, fog_end, fog_colour[4];
2078 GLuint dummy_arbfp_prog;
2081 static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_context *context)
2083 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2086 static inline const struct wined3d_context_gl *wined3d_context_gl_const(const struct wined3d_context *context)
2088 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2091 struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
2092 struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2093 void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
2094 const struct wined3d_gl_info *gl_info, unsigned int unit) DECLSPEC_HIDDEN;
2095 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
2096 struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2097 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
2098 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2099 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
2100 struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2101 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
2102 struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2103 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
2104 struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2105 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
2106 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2107 BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, const struct wined3d_state *state,
2108 unsigned int rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2109 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl *context_gl, GLenum target,
2110 struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
2111 struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
2112 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
2113 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2114 void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
2115 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2116 void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
2117 GLenum target, GLuint name) DECLSPEC_HIDDEN;
2118 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
2119 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
2120 const struct wined3d_bo_address *dst, GLenum dst_binding,
2121 const struct wined3d_bo_address *src, GLenum src_binding, size_t size) DECLSPEC_HIDDEN;
2122 void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2123 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
2124 unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2125 enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2126 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl,
2127 struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
2128 const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2129 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t mask) DECLSPEC_HIDDEN;
2130 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2131 void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2132 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2133 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2134 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2135 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2136 struct wined3d_context_gl *wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN;
2137 GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2138 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
2139 const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2140 HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
2141 struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
2142 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
2143 const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2144 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
2145 const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags) DECLSPEC_HIDDEN;
2146 struct wined3d_context_gl *wined3d_context_gl_reacquire(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2147 void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2148 BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2149 void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN;
2150 void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
2151 const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
2152 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2153 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl,
2154 const struct wined3d_bo_address *data, GLenum binding) DECLSPEC_HIDDEN;
2155 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl,
2156 const struct wined3d_state *state) DECLSPEC_HIDDEN;
2158 struct wined3d_context_vk
2160 struct wined3d_context c;
2163 void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2164 HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
2165 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2167 typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2169 struct wined3d_state_entry
2171 unsigned int representative;
2172 APPLYSTATEFUNC apply;
2175 struct wined3d_state_entry_template
2177 DWORD state;
2178 struct wined3d_state_entry content;
2179 unsigned int extension;
2182 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2183 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2184 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2186 struct fragment_caps
2188 DWORD wined3d_caps;
2189 DWORD PrimitiveMiscCaps;
2190 DWORD TextureOpCaps;
2191 DWORD MaxTextureBlendStages;
2192 DWORD MaxSimultaneousTextures;
2195 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2196 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2198 struct wined3d_fragment_pipe_ops
2200 void (*fp_enable)(const struct wined3d_context *context, BOOL enable);
2201 void (*get_caps)(const struct wined3d_adapter *adapter, struct fragment_caps *caps);
2202 DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2203 void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2204 void (*free_private)(struct wined3d_device *device, struct wined3d_context *context);
2205 BOOL (*allocate_context_data)(struct wined3d_context *context);
2206 void (*free_context_data)(struct wined3d_context *context);
2207 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2208 const struct wined3d_state_entry_template *states;
2211 struct wined3d_vertex_caps
2213 BOOL xyzrhw;
2214 BOOL emulated_flatshading;
2215 BOOL ffp_generic_attributes;
2216 DWORD max_active_lights;
2217 DWORD max_vertex_blend_matrices;
2218 DWORD max_vertex_blend_matrix_index;
2219 DWORD vertex_processing_caps;
2220 DWORD fvf_caps;
2221 DWORD max_user_clip_planes;
2222 DWORD raster_caps;
2225 struct wined3d_vertex_pipe_ops
2227 void (*vp_enable)(const struct wined3d_context *context, BOOL enable);
2228 void (*vp_get_caps)(const struct wined3d_adapter *adapter, struct wined3d_vertex_caps *caps);
2229 DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2230 void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2231 void (*vp_free)(struct wined3d_device *device, struct wined3d_context *context);
2232 const struct wined3d_state_entry_template *vp_states;
2235 extern const struct wined3d_state_entry_template misc_state_template[] DECLSPEC_HIDDEN;
2236 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN;
2237 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN;
2238 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN;
2239 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN;
2240 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN;
2241 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN;
2242 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN;
2244 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN;
2245 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN;
2246 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN;
2248 /* "Base" state table */
2249 HRESULT compile_state_table(struct wined3d_state_entry *state_table, APPLYSTATEFUNC **dev_multistate_funcs,
2250 const struct wined3d_d3d_info *d3d_info, const BOOL *supported_extensions,
2251 const struct wined3d_vertex_pipe_ops *vertex, const struct wined3d_fragment_pipe_ops *fragment,
2252 const struct wined3d_state_entry_template *misc) DECLSPEC_HIDDEN;
2254 enum wined3d_blit_op
2256 WINED3D_BLIT_OP_COLOR_BLIT,
2257 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST,
2258 WINED3D_BLIT_OP_COLOR_BLIT_CKEY,
2259 WINED3D_BLIT_OP_DEPTH_BLIT,
2260 WINED3D_BLIT_OP_RAW_BLIT,
2263 struct wined3d_blitter
2265 const struct wined3d_blitter_ops *ops;
2266 struct wined3d_blitter *next;
2269 struct wined3d_blitter_ops
2271 void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2272 void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2273 unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2274 const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2275 DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2276 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
2277 const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
2278 DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
2279 enum wined3d_texture_filter_type filter);
2282 void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
2283 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2284 struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
2285 void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
2286 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2287 void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
2288 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2289 struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next,
2290 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2291 void wined3d_raw_blitter_create(struct wined3d_blitter **next,
2292 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2294 BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct wined3d_gl_info *gl_info,
2295 const struct wined3d_resource *src_resource, DWORD src_location,
2296 const struct wined3d_resource *dst_resource, DWORD dst_location) DECLSPEC_HIDDEN;
2298 BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
2300 HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2301 DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
2302 void context_gl_resource_released(struct wined3d_device *device,
2303 GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2304 void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2305 void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2306 void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
2307 void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
2308 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2309 void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
2310 void context_state_drawbuf(struct wined3d_context *context,
2311 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2312 void context_state_fb(struct wined3d_context *context,
2313 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2315 /*****************************************************************************
2316 * Internal representation of a light
2318 struct wined3d_light_info
2320 struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2321 DWORD OriginalIndex;
2322 LONG glIndex;
2323 BOOL enabled;
2325 /* Converted parms to speed up swapping lights */
2326 struct wined3d_vec4 position;
2327 struct wined3d_vec4 direction;
2328 float exponent;
2329 float cutoff;
2331 struct list entry;
2334 /* The default light parameters */
2335 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
2337 struct wined3d_pixel_format
2339 int iPixelFormat; /* WGL pixel format */
2340 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2341 int redSize, greenSize, blueSize, alphaSize, colorSize;
2342 int depthSize, stencilSize;
2343 BOOL windowDrawable;
2344 BOOL doubleBuffer;
2345 int auxBuffers;
2346 int numSamples;
2349 enum wined3d_pci_vendor
2351 HW_VENDOR_SOFTWARE = 0x0000,
2352 HW_VENDOR_AMD = 0x1002,
2353 HW_VENDOR_NVIDIA = 0x10de,
2354 HW_VENDOR_VMWARE = 0x15ad,
2355 HW_VENDOR_REDHAT = 0x1af4,
2356 HW_VENDOR_INTEL = 0x8086,
2359 enum wined3d_pci_device
2361 CARD_WINE = 0x0000,
2363 CARD_AMD_RAGE_128PRO = 0x5246,
2364 CARD_AMD_RADEON_7200 = 0x5144,
2365 CARD_AMD_RADEON_8500 = 0x514c,
2366 CARD_AMD_RADEON_9500 = 0x4144,
2367 CARD_AMD_RADEON_XPRESS_200M = 0x5955,
2368 CARD_AMD_RADEON_X700 = 0x5e4c,
2369 CARD_AMD_RADEON_X1600 = 0x71c2,
2370 CARD_AMD_RADEON_HD2350 = 0x94c7,
2371 CARD_AMD_RADEON_HD2600 = 0x9581,
2372 CARD_AMD_RADEON_HD2900 = 0x9400,
2373 CARD_AMD_RADEON_HD3200 = 0x9620,
2374 CARD_AMD_RADEON_HD3850 = 0x9515,
2375 CARD_AMD_RADEON_HD4200M = 0x9712,
2376 CARD_AMD_RADEON_HD4350 = 0x954f,
2377 CARD_AMD_RADEON_HD4600 = 0x9495,
2378 CARD_AMD_RADEON_HD4700 = 0x944e,
2379 CARD_AMD_RADEON_HD4800 = 0x944c,
2380 CARD_AMD_RADEON_HD5400 = 0x68f9,
2381 CARD_AMD_RADEON_HD5600 = 0x68d8,
2382 CARD_AMD_RADEON_HD5700 = 0x68be,
2383 CARD_AMD_RADEON_HD5800 = 0x6898,
2384 CARD_AMD_RADEON_HD5900 = 0x689c,
2385 CARD_AMD_RADEON_HD6300 = 0x9803,
2386 CARD_AMD_RADEON_HD6400 = 0x6770,
2387 CARD_AMD_RADEON_HD6490M = 0x6760,
2388 CARD_AMD_RADEON_HD6410D = 0x9644,
2389 CARD_AMD_RADEON_HD6480G = 0x9648,
2390 CARD_AMD_RADEON_HD6550D = 0x9640,
2391 CARD_AMD_RADEON_HD6600 = 0x6758,
2392 CARD_AMD_RADEON_HD6600M = 0x6741,
2393 CARD_AMD_RADEON_HD6700 = 0x68ba,
2394 CARD_AMD_RADEON_HD6800 = 0x6739,
2395 CARD_AMD_RADEON_HD6900 = 0x6719,
2396 CARD_AMD_RADEON_HD7660D = 0x9901,
2397 CARD_AMD_RADEON_HD7700 = 0x683d,
2398 CARD_AMD_RADEON_HD7800 = 0x6819,
2399 CARD_AMD_RADEON_HD7870 = 0x6818,
2400 CARD_AMD_RADEON_HD7900 = 0x679a,
2401 CARD_AMD_RADEON_HD8600M = 0x6660,
2402 CARD_AMD_RADEON_HD8670 = 0x6610,
2403 CARD_AMD_RADEON_HD8770 = 0x665c,
2404 CARD_AMD_RADEON_R3 = 0x9830,
2405 CARD_AMD_RADEON_R7 = 0x130f,
2406 CARD_AMD_RADEON_R9_285 = 0x6939,
2407 CARD_AMD_RADEON_R9_290 = 0x67b1,
2408 CARD_AMD_RADEON_R9_290X = 0x67b0,
2409 CARD_AMD_RADEON_R9_FURY = 0x7300,
2410 CARD_AMD_RADEON_R9_M370X = 0x6821,
2411 CARD_AMD_RADEON_R9_M380 = 0x6647,
2412 CARD_AMD_RADEON_R9_M395X = 0x6920,
2413 CARD_AMD_RADEON_RX_460 = 0x67ef,
2414 CARD_AMD_RADEON_RX_480 = 0x67df,
2415 CARD_AMD_RADEON_RX_VEGA_10 = 0x687f,
2416 CARD_AMD_RADEON_RX_VEGA_20 = 0x66af,
2418 CARD_NVIDIA_RIVA_128 = 0x0018,
2419 CARD_NVIDIA_RIVA_TNT = 0x0020,
2420 CARD_NVIDIA_RIVA_TNT2 = 0x0028,
2421 CARD_NVIDIA_GEFORCE = 0x0100,
2422 CARD_NVIDIA_GEFORCE2_MX = 0x0110,
2423 CARD_NVIDIA_GEFORCE2 = 0x0150,
2424 CARD_NVIDIA_GEFORCE3 = 0x0200,
2425 CARD_NVIDIA_GEFORCE4_MX = 0x0170,
2426 CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
2427 CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
2428 CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
2429 CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
2430 CARD_NVIDIA_GEFORCE_6200 = 0x014f,
2431 CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
2432 CARD_NVIDIA_GEFORCE_6800 = 0x0041,
2433 CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2434 CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
2435 CARD_NVIDIA_GEFORCE_7600 = 0x0391,
2436 CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
2437 CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2438 CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
2439 CARD_NVIDIA_GEFORCE_8400GS = 0x0404,
2440 CARD_NVIDIA_GEFORCE_8500GT = 0x0421,
2441 CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
2442 CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
2443 CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
2444 CARD_NVIDIA_GEFORCE_8800GTX = 0x0191,
2445 CARD_NVIDIA_GEFORCE_9200 = 0x086d,
2446 CARD_NVIDIA_GEFORCE_9300 = 0x086c,
2447 CARD_NVIDIA_GEFORCE_9400M = 0x0863,
2448 CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
2449 CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
2450 CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
2451 CARD_NVIDIA_GEFORCE_9700MGT = 0x064a,
2452 CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
2453 CARD_NVIDIA_GEFORCE_210 = 0x0a23,
2454 CARD_NVIDIA_GEFORCE_GT220 = 0x0a20,
2455 CARD_NVIDIA_GEFORCE_GT240 = 0x0ca3,
2456 CARD_NVIDIA_GEFORCE_GTS250 = 0x0615,
2457 CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
2458 CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
2459 CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
2460 CARD_NVIDIA_GEFORCE_315M = 0x0a7a,
2461 CARD_NVIDIA_GEFORCE_320M = 0x08a3,
2462 CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
2463 CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
2464 CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
2465 CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
2466 CARD_NVIDIA_GEFORCE_410M = 0x1055,
2467 CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
2468 CARD_NVIDIA_GEFORCE_GT425M = 0x0df0,
2469 CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
2470 CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
2471 CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
2472 CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
2473 CARD_NVIDIA_GEFORCE_GTX460M = 0x0dd1,
2474 CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
2475 CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
2476 CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
2477 CARD_NVIDIA_GEFORCE_GT520 = 0x1040,
2478 CARD_NVIDIA_GEFORCE_GT525M = 0x0dec,
2479 CARD_NVIDIA_GEFORCE_GT540M = 0x0df4,
2480 CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
2481 CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
2482 CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
2483 CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
2484 CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
2485 CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
2486 CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
2487 CARD_NVIDIA_GEFORCE_GT610 = 0x104a,
2488 CARD_NVIDIA_GEFORCE_GT630 = 0x0f00,
2489 CARD_NVIDIA_GEFORCE_GT630M = 0x0de9,
2490 CARD_NVIDIA_GEFORCE_GT640 = 0x0fc1,
2491 CARD_NVIDIA_GEFORCE_GT640M = 0x0fd2,
2492 CARD_NVIDIA_GEFORCE_GT650M = 0x0fd1,
2493 CARD_NVIDIA_GEFORCE_GTX650 = 0x0fc6,
2494 CARD_NVIDIA_GEFORCE_GTX650TI = 0x11c6,
2495 CARD_NVIDIA_GEFORCE_GTX660 = 0x11c0,
2496 CARD_NVIDIA_GEFORCE_GTX660M = 0x0fd4,
2497 CARD_NVIDIA_GEFORCE_GTX660TI = 0x1183,
2498 CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
2499 CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
2500 CARD_NVIDIA_GEFORCE_GTX675MX_1 = 0x11a7,
2501 CARD_NVIDIA_GEFORCE_GTX675MX_2 = 0x11a2,
2502 CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
2503 CARD_NVIDIA_GEFORCE_GTX690 = 0x1188,
2504 CARD_NVIDIA_GEFORCE_GT720 = 0x128b,
2505 CARD_NVIDIA_GEFORCE_GT730 = 0x1287,
2506 CARD_NVIDIA_GEFORCE_GT730M = 0x0fe1,
2507 CARD_NVIDIA_GEFORCE_GT740M = 0x1292,
2508 CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
2509 CARD_NVIDIA_GEFORCE_GT755M = 0x0fcd,
2510 CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
2511 CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
2512 CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
2513 CARD_NVIDIA_GEFORCE_GTX760TI = 0x1193,
2514 CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2,
2515 CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0,
2516 CARD_NVIDIA_GEFORCE_GTX770 = 0x1184,
2517 CARD_NVIDIA_GEFORCE_GTX775M = 0x119d,
2518 CARD_NVIDIA_GEFORCE_GTX780 = 0x1004,
2519 CARD_NVIDIA_GEFORCE_GTX780M = 0x119e,
2520 CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a,
2521 CARD_NVIDIA_GEFORCE_GTXTITAN = 0x1005,
2522 CARD_NVIDIA_GEFORCE_GTXTITANB = 0x100c,
2523 CARD_NVIDIA_GEFORCE_GTXTITANX = 0x17c2,
2524 CARD_NVIDIA_GEFORCE_GTXTITANZ = 0x1001,
2525 CARD_NVIDIA_GEFORCE_820M = 0x0fed,
2526 CARD_NVIDIA_GEFORCE_830M = 0x1340,
2527 CARD_NVIDIA_GEFORCE_840M = 0x1341,
2528 CARD_NVIDIA_GEFORCE_845M = 0x1344,
2529 CARD_NVIDIA_GEFORCE_GTX850M = 0x1391,
2530 CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
2531 CARD_NVIDIA_GEFORCE_GTX870M = 0x1199,
2532 CARD_NVIDIA_GEFORCE_GTX880M = 0x1198,
2533 CARD_NVIDIA_GEFORCE_940M = 0x1347,
2534 CARD_NVIDIA_GEFORCE_GTX950 = 0x1402,
2535 CARD_NVIDIA_GEFORCE_GTX950M = 0x139a,
2536 CARD_NVIDIA_GEFORCE_GTX960 = 0x1401,
2537 CARD_NVIDIA_GEFORCE_GTX960M = 0x139b,
2538 CARD_NVIDIA_GEFORCE_GTX970 = 0x13c2,
2539 CARD_NVIDIA_GEFORCE_GTX970M = 0x13d8,
2540 CARD_NVIDIA_GEFORCE_GTX980 = 0x13c0,
2541 CARD_NVIDIA_GEFORCE_GTX980TI = 0x17c8,
2542 CARD_NVIDIA_GEFORCE_GTX1050 = 0x1c81,
2543 CARD_NVIDIA_GEFORCE_GTX1050TI = 0x1c82,
2544 CARD_NVIDIA_GEFORCE_GTX1060 = 0x1c03,
2545 CARD_NVIDIA_GEFORCE_GTX1070 = 0x1b81,
2546 CARD_NVIDIA_GEFORCE_GTX1080 = 0x1b80,
2547 CARD_NVIDIA_GEFORCE_GTX1080TI = 0x1b06,
2548 CARD_NVIDIA_TITANX_PASCAL = 0x1b00,
2549 CARD_NVIDIA_TITANV = 0x1d81,
2550 CARD_NVIDIA_GEFORCE_GTX1660TI = 0x2182,
2551 CARD_NVIDIA_GEFORCE_RTX2060 = 0x1f08,
2552 CARD_NVIDIA_GEFORCE_RTX2070 = 0x1f07,
2553 CARD_NVIDIA_GEFORCE_RTX2080 = 0x1e87,
2554 CARD_NVIDIA_GEFORCE_RTX2080TI = 0x1e07,
2556 CARD_REDHAT_VIRGL = 0x1010,
2558 CARD_VMWARE_SVGA3D = 0x0405,
2560 CARD_INTEL_830M = 0x3577,
2561 CARD_INTEL_855GM = 0x3582,
2562 CARD_INTEL_845G = 0x2562,
2563 CARD_INTEL_865G = 0x2572,
2564 CARD_INTEL_915G = 0x2582,
2565 CARD_INTEL_E7221G = 0x258a,
2566 CARD_INTEL_915GM = 0x2592,
2567 CARD_INTEL_945G = 0x2772,
2568 CARD_INTEL_945GM = 0x27a2,
2569 CARD_INTEL_945GME = 0x27ae,
2570 CARD_INTEL_Q35 = 0x29b2,
2571 CARD_INTEL_G33 = 0x29c2,
2572 CARD_INTEL_Q33 = 0x29d2,
2573 CARD_INTEL_PNVG = 0xa001,
2574 CARD_INTEL_PNVM = 0xa011,
2575 CARD_INTEL_965Q = 0x2992,
2576 CARD_INTEL_965G = 0x2982,
2577 CARD_INTEL_946GZ = 0x2972,
2578 CARD_INTEL_965GM = 0x2a02,
2579 CARD_INTEL_965GME = 0x2a12,
2580 CARD_INTEL_GM45 = 0x2a42,
2581 CARD_INTEL_IGD = 0x2e02,
2582 CARD_INTEL_Q45 = 0x2e12,
2583 CARD_INTEL_G45 = 0x2e22,
2584 CARD_INTEL_G41 = 0x2e32,
2585 CARD_INTEL_B43 = 0x2e92,
2586 CARD_INTEL_ILKD = 0x0042,
2587 CARD_INTEL_ILKM = 0x0046,
2588 CARD_INTEL_SNBD = 0x0122,
2589 CARD_INTEL_SNBM = 0x0126,
2590 CARD_INTEL_SNBS = 0x010a,
2591 CARD_INTEL_IVBD = 0x0162,
2592 CARD_INTEL_IVBM = 0x0166,
2593 CARD_INTEL_IVBS = 0x015a,
2594 CARD_INTEL_HWD = 0x0412,
2595 CARD_INTEL_HWM = 0x0416,
2596 CARD_INTEL_HD5000_1 = 0x0a26,
2597 CARD_INTEL_HD5000_2 = 0x0422,
2598 CARD_INTEL_I5100_1 = 0x0a22,
2599 CARD_INTEL_I5100_2 = 0x0a2a,
2600 CARD_INTEL_I5100_3 = 0x0a2b,
2601 CARD_INTEL_I5100_4 = 0x0a2e,
2602 CARD_INTEL_IP5200_1 = 0x0d22,
2603 CARD_INTEL_IP5200_2 = 0x0d26,
2604 CARD_INTEL_IP5200_3 = 0x0d2a,
2605 CARD_INTEL_IP5200_4 = 0x0d2b,
2606 CARD_INTEL_IP5200_5 = 0x0d2e,
2607 CARD_INTEL_IP5200_6 = 0x0c22,
2608 CARD_INTEL_HD5300 = 0x161e,
2609 CARD_INTEL_HD5500 = 0x1616,
2610 CARD_INTEL_HD5600 = 0x1612,
2611 CARD_INTEL_HD6000 = 0x1626,
2612 CARD_INTEL_I6100 = 0x162b,
2613 CARD_INTEL_IP6200 = 0x1622,
2614 CARD_INTEL_IPP6300 = 0x162a,
2615 CARD_INTEL_HD510_1 = 0x1902,
2616 CARD_INTEL_HD510_2 = 0x1906,
2617 CARD_INTEL_HD510_3 = 0x190b,
2618 CARD_INTEL_HD515 = 0x191e,
2619 CARD_INTEL_HD520_1 = 0x1916,
2620 CARD_INTEL_HD520_2 = 0x1921,
2621 CARD_INTEL_HD530_1 = 0x1912,
2622 CARD_INTEL_HD530_2 = 0x191b,
2623 CARD_INTEL_HDP530 = 0x191d,
2624 CARD_INTEL_I540 = 0x1926,
2625 CARD_INTEL_I550 = 0x1927,
2626 CARD_INTEL_I555 = 0x192b,
2627 CARD_INTEL_IP555 = 0x192d,
2628 CARD_INTEL_IP580_1 = 0x1932,
2629 CARD_INTEL_IP580_2 = 0x193b,
2630 CARD_INTEL_IPP580_1 = 0x193a,
2631 CARD_INTEL_IPP580_2 = 0x193d,
2632 CARD_INTEL_UHD617 = 0x87c0,
2633 CARD_INTEL_HD620 = 0x5916,
2634 CARD_INTEL_HD630_1 = 0x5912,
2635 CARD_INTEL_HD630_2 = 0x591b,
2638 struct wined3d_fbo_ops
2640 GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
2641 void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
2642 void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
2643 void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
2644 void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
2645 GLsizei width, GLsizei height);
2646 void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
2647 GLenum internalformat, GLsizei width, GLsizei height);
2648 void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
2649 GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
2650 void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
2651 void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
2652 void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
2653 GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
2654 void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
2655 GLuint texture, GLint level);
2656 void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
2657 GLenum textarget, GLuint texture, GLint level);
2658 void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
2659 GLenum textarget, GLuint texture, GLint level);
2660 void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
2661 GLenum textarget, GLuint texture, GLint level, GLint layer);
2662 void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
2663 GLuint texture, GLint level, GLint layer);
2664 void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
2665 GLenum renderbuffertarget, GLuint renderbuffer);
2666 void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
2667 GLenum pname, GLint *params);
2668 void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2669 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2670 void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
2673 struct wined3d_gl_limits
2675 UINT buffers;
2676 UINT lights;
2677 UINT textures;
2678 UINT texture_coords;
2679 unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
2680 unsigned int samplers[WINED3D_SHADER_TYPE_COUNT];
2681 unsigned int graphics_samplers;
2682 unsigned int combined_samplers;
2683 UINT general_combiners;
2684 UINT user_clip_distances;
2685 UINT texture3d_size;
2686 UINT anisotropy;
2687 float shininess;
2688 UINT samples;
2689 UINT vertex_attribs;
2691 unsigned int texture_buffer_offset_alignment;
2693 unsigned int framebuffer_width;
2694 unsigned int framebuffer_height;
2696 UINT glsl_varyings;
2697 UINT glsl_vs_float_constants;
2698 UINT glsl_ps_float_constants;
2700 UINT arb_vs_float_constants;
2701 UINT arb_vs_native_constants;
2702 UINT arb_vs_instructions;
2703 UINT arb_vs_temps;
2704 UINT arb_ps_float_constants;
2705 UINT arb_ps_local_constants;
2706 UINT arb_ps_native_constants;
2707 UINT arb_ps_instructions;
2708 UINT arb_ps_temps;
2711 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
2712 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2713 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits,
2714 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2716 struct wined3d_gl_info
2718 DWORD selected_gl_version;
2719 DWORD glsl_version;
2720 struct wined3d_gl_limits limits;
2721 DWORD reserved_glsl_constants, reserved_arb_constants;
2722 DWORD quirks;
2723 BOOL supported[WINED3D_GL_EXT_COUNT];
2724 GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
2726 HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
2727 struct opengl_funcs gl_ops;
2728 struct wined3d_fbo_ops fbo_ops;
2730 void (WINE_GLAPI *p_glDisableWINE)(GLenum cap);
2731 void (WINE_GLAPI *p_glEnableWINE)(GLenum cap);
2734 /* The driver names reflect the lowest GPU supported
2735 * by a certain driver, so DRIVER_AMD_R300 supports
2736 * R3xx, R4xx and R5xx GPUs. */
2737 enum wined3d_display_driver
2739 DRIVER_AMD_RAGE_128PRO,
2740 DRIVER_AMD_R100,
2741 DRIVER_AMD_R300,
2742 DRIVER_AMD_R600,
2743 DRIVER_AMD_RX,
2744 DRIVER_INTEL_GMA800,
2745 DRIVER_INTEL_GMA900,
2746 DRIVER_INTEL_GMA950,
2747 DRIVER_INTEL_GMA3000,
2748 DRIVER_INTEL_HD4000,
2749 DRIVER_NVIDIA_TNT,
2750 DRIVER_NVIDIA_GEFORCE2MX,
2751 DRIVER_NVIDIA_GEFORCEFX,
2752 DRIVER_NVIDIA_GEFORCE6,
2753 DRIVER_NVIDIA_GEFORCE8,
2754 DRIVER_REDHAT_VIRGL,
2755 DRIVER_VMWARE,
2756 DRIVER_WINE,
2757 DRIVER_UNKNOWN,
2760 struct wined3d_gpu_description
2762 enum wined3d_pci_vendor vendor;
2763 enum wined3d_pci_device device;
2764 const char *description;
2765 enum wined3d_display_driver driver;
2766 unsigned int vidmem;
2769 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
2770 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
2771 const struct wined3d_gpu_description *wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor,
2772 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
2773 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
2774 enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
2776 /* 512 in Direct3D 8/9, 128 in DXGI. */
2777 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
2779 struct wined3d_driver_info
2781 enum wined3d_pci_vendor vendor;
2782 enum wined3d_pci_device device;
2783 const char *name;
2784 char description[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH];
2785 UINT64 vram_bytes;
2786 UINT64 sysmem_bytes;
2787 DWORD version_high;
2788 DWORD version_low;
2791 void wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
2792 const struct wined3d_gpu_description *gpu_description,
2793 UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
2795 struct wined3d_adapter_ops
2797 void (*adapter_destroy)(struct wined3d_adapter *adapter);
2798 HRESULT (*adapter_create_device)(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
2799 enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
2800 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
2801 struct wined3d_device_parent *device_parent, struct wined3d_device **device);
2802 void (*adapter_destroy_device)(struct wined3d_device *device);
2803 struct wined3d_context *(*adapter_acquire_context)(struct wined3d_device *device,
2804 struct wined3d_texture *texture, unsigned int sub_resource_idx);
2805 void (*adapter_release_context)(struct wined3d_context *context);
2806 void (*adapter_get_wined3d_caps)(const struct wined3d_adapter *adapter, struct wined3d_caps *caps);
2807 BOOL (*adapter_check_format)(const struct wined3d_adapter *adapter,
2808 const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
2809 const struct wined3d_format *ds_format);
2810 HRESULT (*adapter_init_3d)(struct wined3d_device *device);
2811 void (*adapter_uninit_3d)(struct wined3d_device *device);
2812 void *(*adapter_map_bo_address)(struct wined3d_context *context,
2813 const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags);
2814 void (*adapter_unmap_bo_address)(struct wined3d_context *context,
2815 const struct wined3d_bo_address *data, GLenum binding);
2816 HRESULT (*adapter_create_swapchain)(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
2817 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
2818 void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain);
2819 HRESULT (*adapter_create_buffer)(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
2820 const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
2821 struct wined3d_buffer **buffer);
2822 void (*adapter_destroy_buffer)(struct wined3d_buffer *buffer);
2823 HRESULT (*adapter_create_texture)(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
2824 unsigned int layer_count, unsigned int level_count, uint32_t flags, void *parent,
2825 const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
2826 void (*adapter_destroy_texture)(struct wined3d_texture *texture);
2827 HRESULT (*adapter_create_rendertarget_view)(const struct wined3d_view_desc *desc,
2828 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2829 struct wined3d_rendertarget_view **view);
2830 void (*adapter_destroy_rendertarget_view)(struct wined3d_rendertarget_view *view);
2831 HRESULT (*adapter_create_shader_resource_view)(const struct wined3d_view_desc *desc,
2832 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2833 struct wined3d_shader_resource_view **view);
2834 void (*adapter_destroy_shader_resource_view)(struct wined3d_shader_resource_view *view);
2835 HRESULT (*adapter_create_unordered_access_view)(const struct wined3d_view_desc *desc,
2836 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2837 struct wined3d_unordered_access_view **view);
2838 void (*adapter_destroy_unordered_access_view)(struct wined3d_unordered_access_view *view);
2839 HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
2840 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
2841 void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
2842 HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
2843 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
2844 void (*adapter_destroy_query)(struct wined3d_query *query);
2845 void (*adapter_flush_context)(struct wined3d_context *context);
2848 /* The adapter structure */
2849 struct wined3d_adapter
2851 unsigned int ordinal;
2852 POINT monitor_position;
2853 enum wined3d_format_id screen_format;
2855 struct wined3d_gl_info gl_info;
2856 struct wined3d_d3d_info d3d_info;
2857 struct wined3d_driver_info driver_info;
2858 UINT64 vram_bytes_used;
2859 GUID driver_uuid;
2860 GUID device_uuid;
2861 LUID luid;
2863 WCHAR device_name[CCHDEVICENAME]; /* for use with e.g. ChangeDisplaySettings() */
2865 void *formats;
2866 size_t format_size;
2868 const struct wined3d_vertex_pipe_ops *vertex_pipe;
2869 const struct wined3d_fragment_pipe_ops *fragment_pipe;
2870 const struct wined3d_shader_backend_ops *shader_backend;
2871 const struct wined3d_adapter_ops *adapter_ops;
2874 BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal,
2875 const struct wined3d_adapter_ops *adapter_ops) DECLSPEC_HIDDEN;
2876 void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
2878 struct wined3d_adapter_gl
2880 struct wined3d_adapter a;
2882 struct wined3d_pixel_format *pixel_formats;
2883 unsigned int pixel_format_count;
2886 static inline struct wined3d_adapter_gl *wined3d_adapter_gl(struct wined3d_adapter *adapter)
2888 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
2891 static inline const struct wined3d_adapter_gl *wined3d_adapter_gl_const(const struct wined3d_adapter *adapter)
2893 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
2896 struct wined3d_adapter *wined3d_adapter_gl_create(unsigned int ordinal,
2897 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
2899 struct wined3d_adapter_vk
2901 struct wined3d_adapter a;
2903 struct wined3d_vk_info vk_info;
2904 VkPhysicalDevice physical_device;
2906 VkPhysicalDeviceLimits device_limits;
2909 static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter)
2911 return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a);
2914 struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
2915 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
2917 struct wined3d_caps_gl_ctx
2919 HDC dc;
2920 HWND wnd;
2921 HGLRC gl_ctx;
2922 HDC restore_dc;
2923 HGLRC restore_gl_ctx;
2925 const struct wined3d_gl_info *gl_info;
2926 GLuint test_vbo;
2927 GLuint test_program_id;
2930 BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
2931 struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
2932 BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
2933 BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk,
2934 const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN;
2935 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
2937 BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
2939 void install_gl_compat_wrapper(struct wined3d_gl_info *gl_info, enum wined3d_gl_extension ext) DECLSPEC_HIDDEN;
2941 enum wined3d_projection_type
2943 WINED3D_PROJECTION_NONE = 0,
2944 WINED3D_PROJECTION_COUNT3 = 1,
2945 WINED3D_PROJECTION_COUNT4 = 2
2948 /*****************************************************************************
2949 * Fixed function pipeline replacements
2951 #define ARG_UNUSED 0xff
2952 struct texture_stage_op
2954 unsigned cop : 8;
2955 unsigned carg1 : 8;
2956 unsigned carg2 : 8;
2957 unsigned carg0 : 8;
2959 unsigned aop : 8;
2960 unsigned aarg1 : 8;
2961 unsigned aarg2 : 8;
2962 unsigned aarg0 : 8;
2964 struct color_fixup_desc color_fixup;
2965 unsigned tex_type : 3;
2966 unsigned tmp_dst : 1;
2967 unsigned projected : 2;
2968 unsigned padding : 10;
2971 struct ffp_frag_settings
2973 struct texture_stage_op op[WINED3D_MAX_TEXTURES];
2974 enum wined3d_ffp_ps_fog_mode fog;
2975 unsigned char sRGB_write;
2976 unsigned char emul_clipplanes;
2977 unsigned char texcoords_initialized;
2978 unsigned char color_key_enabled : 1;
2979 unsigned char pointsprite : 1;
2980 unsigned char flatshading : 1;
2981 unsigned char alpha_test_func : 3;
2982 unsigned char padding : 2;
2985 struct ffp_frag_desc
2987 struct wine_rb_entry entry;
2988 struct ffp_frag_settings settings;
2991 int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
2992 int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
2994 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
2996 void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
2997 struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
2998 const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
2999 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
3000 void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
3001 void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
3003 enum wined3d_ffp_vs_fog_mode
3005 WINED3D_FFP_VS_FOG_OFF = 0,
3006 WINED3D_FFP_VS_FOG_FOGCOORD = 1,
3007 WINED3D_FFP_VS_FOG_DEPTH = 2,
3008 WINED3D_FFP_VS_FOG_RANGE = 3,
3011 #define WINED3D_FFP_TCI_SHIFT 16
3012 #define WINED3D_FFP_TCI_MASK 0xffu
3014 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3015 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3017 struct wined3d_ffp_vs_settings
3019 DWORD point_light_count : 4;
3020 DWORD spot_light_count : 4;
3021 DWORD directional_light_count : 4;
3022 DWORD parallel_point_light_count : 4;
3023 DWORD diffuse_source : 2;
3024 DWORD emissive_source : 2;
3025 DWORD ambient_source : 2;
3026 DWORD specular_source : 2;
3027 DWORD transformed : 1;
3028 DWORD vertexblends : 2;
3029 DWORD clipping : 1;
3030 DWORD normal : 1;
3031 DWORD normalize : 1;
3032 DWORD lighting : 1;
3033 DWORD localviewer : 1;
3035 DWORD point_size : 1;
3036 DWORD per_vertex_point_size : 1;
3037 DWORD fog_mode : 2;
3038 DWORD texcoords : 8; /* WINED3D_MAX_TEXTURES */
3039 DWORD ortho_fog : 1;
3040 DWORD flatshading : 1;
3041 DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
3042 DWORD padding : 2;
3044 DWORD texgen[WINED3D_MAX_TEXTURES];
3047 struct wined3d_ffp_vs_desc
3049 struct wine_rb_entry entry;
3050 struct wined3d_ffp_vs_settings settings;
3053 void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
3054 const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) DECLSPEC_HIDDEN;
3056 struct wined3d
3058 LONG ref;
3059 unsigned int flags;
3060 unsigned int adapter_count;
3061 struct wined3d_adapter *adapters[1];
3064 BOOL wined3d_filter_messages(HWND window, BOOL filter) DECLSPEC_HIDDEN;
3065 void wined3d_hook_swapchain(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3066 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN;
3067 void wined3d_unhook_swapchain(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3068 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
3070 BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size) DECLSPEC_HIDDEN;
3072 struct wined3d_blend_state
3074 LONG refcount;
3075 struct wined3d_blend_state_desc desc;
3077 void *parent;
3078 const struct wined3d_parent_ops *parent_ops;
3080 struct wined3d_device *device;
3083 struct wined3d_rasterizer_state
3085 LONG refcount;
3086 struct wined3d_rasterizer_state_desc desc;
3088 void *parent;
3089 const struct wined3d_parent_ops *parent_ops;
3091 struct wined3d_device *device;
3094 struct wined3d_stream_output
3096 struct wined3d_buffer *buffer;
3097 UINT offset;
3100 struct wined3d_stream_state
3102 struct wined3d_buffer *buffer;
3103 UINT offset;
3104 UINT stride;
3105 UINT frequency;
3106 UINT flags;
3109 #define LIGHTMAP_SIZE 43
3110 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
3112 struct wined3d_light_state
3114 /* Light hashmap. Collisions are handled using linked lists. */
3115 struct list light_map[LIGHTMAP_SIZE];
3116 const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS];
3119 #define WINED3D_STATE_NO_REF 0x00000001
3120 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3122 struct wined3d_state
3124 DWORD flags;
3125 const struct wined3d_fb_state *fb;
3127 struct wined3d_vertex_declaration *vertex_declaration;
3128 struct wined3d_stream_output stream_output[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
3129 struct wined3d_stream_state streams[WINED3D_MAX_STREAMS + 1 /* tesselated pseudo-stream */];
3130 struct wined3d_buffer *index_buffer;
3131 enum wined3d_format_id index_format;
3132 unsigned int index_offset;
3133 int base_vertex_index;
3134 int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3135 GLenum gl_primitive_type;
3136 GLint gl_patch_vertices;
3137 struct wined3d_query *predicate;
3138 BOOL predicate_value;
3140 struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
3141 struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
3142 struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
3143 struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
3144 struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
3146 BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
3147 struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
3148 struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3150 BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
3151 struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
3152 struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3154 struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
3155 DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
3156 DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
3158 struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3159 struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES];
3160 struct wined3d_material material;
3161 struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS];
3162 unsigned int viewport_count;
3163 RECT scissor_rects[WINED3D_MAX_VIEWPORTS];
3164 unsigned int scissor_rect_count;
3166 struct wined3d_light_state light_state;
3168 DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
3169 struct wined3d_blend_state *blend_state;
3170 struct wined3d_color blend_factor;
3171 struct wined3d_rasterizer_state *rasterizer_state;
3174 struct wined3d_dummy_textures
3176 GLuint tex_1d;
3177 GLuint tex_2d;
3178 GLuint tex_rect;
3179 GLuint tex_3d;
3180 GLuint tex_cube;
3181 GLuint tex_cube_array;
3182 GLuint tex_1d_array;
3183 GLuint tex_2d_array;
3184 GLuint tex_buffer;
3185 GLuint tex_2d_ms;
3186 GLuint tex_2d_ms_array;
3189 #define WINED3D_UNMAPPED_STAGE ~0u
3191 /* Multithreaded flag. Removed from the public header to signal that
3192 * wined3d_device_create() ignores it. */
3193 #define WINED3DCREATE_MULTITHREADED 0x00000004
3195 struct wined3d_stateblock_state
3197 struct wined3d_vertex_declaration *vertex_declaration;
3198 struct wined3d_stream_state streams[WINED3D_MAX_STREAMS + 1];
3199 struct wined3d_buffer *index_buffer;
3200 enum wined3d_format_id index_format;
3201 int base_vertex_index;
3203 struct wined3d_shader *vs;
3204 struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3205 struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
3206 BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
3208 struct wined3d_shader *ps;
3209 struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3210 struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
3211 BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
3213 DWORD rs[WINEHIGHEST_RENDER_STATE + 1];
3214 struct wined3d_color blend_factor;
3216 struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
3217 DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
3218 DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
3220 struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3221 struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES];
3222 struct wined3d_material material;
3223 struct wined3d_viewport viewport;
3224 RECT scissor_rect;
3226 struct wined3d_light_state light_state;
3229 struct wined3d_device
3231 LONG ref;
3233 /* WineD3D Information */
3234 struct wined3d_device_parent *device_parent;
3235 struct wined3d *wined3d;
3236 struct wined3d_adapter *adapter;
3238 const struct wined3d_shader_backend_ops *shader_backend;
3239 void *shader_priv;
3240 void *fragment_priv;
3241 void *vertex_priv;
3242 struct wined3d_state_entry state_table[STATE_HIGHEST + 1];
3243 /* Array of functions for states which are handled by more than one pipeline part */
3244 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
3245 struct wined3d_blitter *blitter;
3247 BYTE bCursorVisible : 1;
3248 BYTE d3d_initialized : 1;
3249 BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3250 BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
3251 BYTE restore_screensaver : 1;
3252 BYTE padding : 3;
3254 unsigned char surface_alignment; /* Line Alignment of surfaces */
3256 WORD padding2 : 16;
3258 enum wined3d_feature_level feature_level;
3260 struct wined3d_state state;
3261 struct wined3d_stateblock *recording;
3262 struct wined3d_stateblock_state stateblock_state;
3263 struct wined3d_stateblock_state *update_stateblock_state;
3265 /* Internal use fields */
3266 struct wined3d_device_creation_parameters create_parms;
3267 HWND focus_window;
3269 struct wined3d_rendertarget_view *back_buffer_view;
3270 struct wined3d_swapchain **swapchains;
3271 UINT swapchain_count;
3272 unsigned int max_frame_latency;
3274 struct list resources; /* a linked list to track resources created by the device */
3275 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
3276 struct wine_rb_tree samplers;
3278 /* Render Target Support */
3279 struct wined3d_fb_state fb;
3280 struct wined3d_rendertarget_view *auto_depth_stencil_view;
3282 /* Cursor management */
3283 UINT xHotSpot;
3284 UINT yHotSpot;
3285 UINT xScreenSpace;
3286 UINT yScreenSpace;
3287 UINT cursorWidth, cursorHeight;
3288 struct wined3d_texture *cursor_texture;
3289 HCURSOR hardwareCursor;
3291 /* The Wine logo texture */
3292 struct wined3d_texture *logo_texture;
3294 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3295 struct wined3d_sampler *default_sampler;
3296 struct wined3d_sampler *null_sampler;
3298 /* Command stream */
3299 struct wined3d_cs *cs;
3301 /* Context management */
3302 struct wined3d_context **contexts;
3303 UINT context_count;
3306 void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN;
3307 void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb,
3308 UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags,
3309 const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
3310 BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3311 void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3312 void wined3d_device_create_primary_opengl_context_cs(void *object) DECLSPEC_HIDDEN;
3313 void wined3d_device_delete_opengl_contexts_cs(void *object) DECLSPEC_HIDDEN;
3314 HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d,
3315 unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3316 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3317 struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3318 LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
3319 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
3320 void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3321 void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3322 void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
3323 HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device,
3324 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3325 void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN;
3327 struct wined3d_device_no3d
3329 struct wined3d_device d;
3331 struct wined3d_context context_no3d;
3334 static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_device *device)
3336 return CONTAINING_RECORD(device, struct wined3d_device_no3d, d);
3339 struct wined3d_device_gl
3341 struct wined3d_device d;
3343 /* Textures for when no other textures are bound. */
3344 struct wined3d_dummy_textures dummy_textures;
3347 static inline struct wined3d_device_gl *wined3d_device_gl(struct wined3d_device *device)
3349 return CONTAINING_RECORD(device, struct wined3d_device_gl, d);
3352 struct wined3d_device_vk
3354 struct wined3d_device d;
3356 struct wined3d_context_vk context_vk;
3358 VkDevice vk_device;
3359 VkQueue vk_queue;
3361 struct wined3d_vk_info vk_info;
3364 static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
3366 return CONTAINING_RECORD(device, struct wined3d_device_vk, d);
3369 static inline BOOL isStateDirty(const struct wined3d_context *context, unsigned int state_id)
3371 unsigned int idx = state_id / (sizeof(*context->dirty_graphics_states) * CHAR_BIT);
3372 unsigned int shift = state_id & ((sizeof(*context->dirty_graphics_states) * CHAR_BIT) - 1);
3373 return context->dirty_graphics_states[idx] & (1u << shift);
3376 static inline float wined3d_alpha_ref(const struct wined3d_state *state)
3378 return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
3381 const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
3382 const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN;
3383 const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d,
3384 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3385 const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
3387 static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
3389 return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
3392 struct wined3d_resource_ops
3394 ULONG (*resource_incref)(struct wined3d_resource *resource);
3395 ULONG (*resource_decref)(struct wined3d_resource *resource);
3396 void (*resource_preload)(struct wined3d_resource *resource);
3397 void (*resource_unload)(struct wined3d_resource *resource);
3398 HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
3399 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
3400 HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
3403 struct wined3d_resource
3405 LONG ref;
3406 LONG bind_count;
3407 LONG map_count;
3408 LONG access_count;
3409 struct wined3d_device *device;
3410 enum wined3d_resource_type type;
3411 enum wined3d_gl_resource_type gl_type;
3412 const struct wined3d_format *format;
3413 unsigned int format_flags;
3414 enum wined3d_multisample_type multisample_type;
3415 UINT multisample_quality;
3416 DWORD usage;
3417 unsigned int bind_flags;
3418 unsigned int access;
3419 WORD draw_binding;
3420 WORD map_binding;
3421 UINT width;
3422 UINT height;
3423 UINT depth;
3424 UINT size;
3425 DWORD priority;
3426 void *heap_memory;
3428 void *parent;
3429 const struct wined3d_parent_ops *parent_ops;
3430 const struct wined3d_resource_ops *resource_ops;
3432 struct list resource_list_entry;
3435 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
3437 return resource->resource_ops->resource_incref(resource);
3440 static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
3442 return resource->resource_ops->resource_decref(resource);
3445 static inline void wined3d_resource_acquire(struct wined3d_resource *resource)
3447 InterlockedIncrement(&resource->access_count);
3450 static inline void wined3d_resource_release(struct wined3d_resource *resource)
3452 InterlockedDecrement(&resource->access_count);
3455 void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3456 HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
3457 enum wined3d_resource_type type, const struct wined3d_format *format,
3458 enum wined3d_multisample_type multisample_type, unsigned int multisample_quality, unsigned int usage,
3459 unsigned int bind_flags, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
3460 unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
3461 const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
3462 void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3463 void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3464 const struct wined3d_format *wined3d_resource_get_decompress_format(
3465 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3466 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3467 GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3468 GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3469 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3470 BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3471 void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3473 /* Tests show that the start address of resources is 32 byte aligned */
3474 #define RESOURCE_ALIGNMENT 16
3475 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3477 #define WINED3D_LOCATION_DISCARDED 0x00000001
3478 #define WINED3D_LOCATION_SYSMEM 0x00000002
3479 #define WINED3D_LOCATION_USER_MEMORY 0x00000004
3480 #define WINED3D_LOCATION_BUFFER 0x00000008
3481 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3482 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3483 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3484 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3485 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3487 const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN;
3489 struct wined3d_blt_info
3491 GLenum bind_target;
3492 struct wined3d_vec3 texcoords[4];
3495 struct wined3d_texture_ops
3497 BOOL (*texture_prepare_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3498 struct wined3d_context *context, unsigned int location);
3499 BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3500 struct wined3d_context *context, unsigned int location);
3501 void (*texture_upload_data)(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr,
3502 const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch,
3503 unsigned int src_slice_pitch, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3504 unsigned int dst_location, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z);
3505 void (*texture_download_data)(struct wined3d_context *context, struct wined3d_texture *src_texture,
3506 unsigned int src_sub_resource_idx, unsigned int src_location, const struct wined3d_box *src_box,
3507 const struct wined3d_bo_address *dst_bo_addr, const struct wined3d_format *dst_format,
3508 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z,
3509 unsigned int dst_row_pitch, unsigned int dst_slice_pitch);
3512 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3513 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3514 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3515 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3516 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3517 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3518 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3519 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3520 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3521 #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
3522 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3523 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3524 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3525 #define WINED3D_TEXTURE_DISCARD 0x00002000
3526 #define WINED3D_TEXTURE_GET_DC 0x00004000
3527 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3528 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3530 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3532 struct wined3d_texture
3534 struct wined3d_resource resource;
3535 const struct wined3d_texture_ops *texture_ops;
3536 struct wined3d_swapchain *swapchain;
3537 unsigned int pow2_width;
3538 unsigned int pow2_height;
3539 UINT layer_count;
3540 UINT level_count;
3541 unsigned int download_count;
3542 unsigned int sysmem_count;
3543 float pow2_matrix[16];
3544 UINT lod;
3545 DWORD sampler;
3546 DWORD flags;
3547 DWORD update_map_binding;
3549 void *user_memory;
3550 unsigned int row_pitch;
3551 unsigned int slice_pitch;
3553 /* May only be accessed from the command stream worker thread. */
3554 struct wined3d_texture_async
3556 DWORD flags;
3558 /* Color keys for DDraw */
3559 struct wined3d_color_key dst_blt_color_key;
3560 struct wined3d_color_key src_blt_color_key;
3561 struct wined3d_color_key dst_overlay_color_key;
3562 struct wined3d_color_key src_overlay_color_key;
3563 struct wined3d_color_key gl_color_key;
3564 DWORD color_key_flags;
3565 } async;
3567 struct wined3d_overlay_info
3569 struct list entry;
3570 struct list overlays;
3571 struct wined3d_texture *dst_texture;
3572 unsigned int dst_sub_resource_idx;
3573 RECT src_rect;
3574 RECT dst_rect;
3575 } *overlay_info;
3577 struct wined3d_dc_info
3579 HBITMAP bitmap;
3580 HDC dc;
3581 } *dc_info;
3583 struct wined3d_texture_sub_resource
3585 void *parent;
3586 const struct wined3d_parent_ops *parent_ops;
3588 unsigned int offset;
3589 unsigned int size;
3591 unsigned int map_count;
3592 DWORD locations;
3593 GLuint buffer_object;
3594 } *sub_resources;
3597 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s, SIZE_T level_count, SIZE_T layer_count)
3599 struct wined3d_texture *t;
3601 if (level_count > ((~(SIZE_T)0 - s) / sizeof(*t->sub_resources)) / layer_count)
3602 return NULL;
3604 return heap_alloc_zero(s + level_count * layer_count * sizeof(*t->sub_resources));
3607 static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
3609 return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
3612 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture,
3613 unsigned int level)
3615 return max(1, texture->resource.width >> level);
3618 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture,
3619 unsigned int level)
3621 return max(1, texture->resource.height >> level);
3624 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture,
3625 unsigned int level)
3627 return max(1, texture->resource.depth >> level);
3630 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
3631 unsigned int level)
3633 return max(1, texture->pow2_width >> level);
3636 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
3637 unsigned int level)
3639 return max(1, texture->pow2_height >> level);
3642 static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture,
3643 unsigned int level, struct wined3d_box *box)
3645 wined3d_box_set(box, 0, 0,
3646 wined3d_texture_get_level_width(texture, level),
3647 wined3d_texture_get_level_height(texture, level),
3648 0, wined3d_texture_get_level_depth(texture, level));
3651 HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3652 const struct wined3d_box *dst_box, struct wined3d_texture *src_texture,
3653 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
3654 const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
3655 void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *context,
3656 enum wined3d_texture_filter_type filter, struct wined3d_texture *src_texture,
3657 unsigned int src_sub_resource_idx, DWORD src_location, const RECT *src_rect,
3658 struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, DWORD dst_location,
3659 const RECT *dst_rect) DECLSPEC_HIDDEN;
3660 void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
3661 const RECT *rect, struct wined3d_blt_info *info) DECLSPEC_HIDDEN;
3662 void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
3663 BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN;
3664 void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3665 struct wined3d_context *context, DWORD src_location, DWORD dst_location) DECLSPEC_HIDDEN;
3667 HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
3668 unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
3669 void wined3d_texture_cleanup(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3670 void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3671 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN;
3672 GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3673 void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3674 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
3675 void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
3676 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
3677 void wined3d_texture_load(struct wined3d_texture *texture,
3678 struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
3679 BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
3680 unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3681 BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3682 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3683 void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN;
3684 void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
3685 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3686 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3687 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
3688 HWND window, RECT *rect) DECLSPEC_HIDDEN;
3689 void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3690 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture,
3691 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
3692 void wined3d_texture_validate_location(struct wined3d_texture *texture,
3693 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
3695 HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device,
3696 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
3697 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3699 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
3701 struct gl_texture
3703 struct wined3d_sampler_desc sampler_desc;
3704 unsigned int base_level;
3705 GLuint name;
3708 struct wined3d_texture_gl
3710 struct wined3d_texture t;
3712 struct gl_texture texture_rgb, texture_srgb;
3714 GLenum target;
3716 GLuint rb_multisample;
3717 GLuint rb_resolved;
3719 struct list renderbuffers;
3720 const struct wined3d_renderbuffer_entry *current_renderbuffer;
3723 static inline struct wined3d_texture_gl *wined3d_texture_gl(struct wined3d_texture *texture)
3725 return CONTAINING_RECORD(texture, struct wined3d_texture_gl, t);
3728 static inline struct gl_texture *wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl *texture_gl,
3729 BOOL srgb)
3731 return srgb ? &texture_gl->texture_srgb : &texture_gl->texture_rgb;
3734 static inline GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl,
3735 unsigned int sub_resource_idx)
3737 static const GLenum cube_targets[] =
3739 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
3740 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
3741 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
3742 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
3743 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
3744 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
3747 return texture_gl->t.resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP
3748 ? cube_targets[sub_resource_idx / texture_gl->t.level_count] : texture_gl->target;
3751 static inline BOOL wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl *texture_gl,
3752 DWORD location)
3754 if (location == WINED3D_LOCATION_RB_MULTISAMPLE)
3755 return TRUE;
3756 if (location != WINED3D_LOCATION_TEXTURE_RGB && location != WINED3D_LOCATION_TEXTURE_SRGB)
3757 return FALSE;
3758 return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
3761 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl,
3762 const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
3763 void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
3764 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
3765 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
3766 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
3767 HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, struct wined3d_device *device,
3768 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
3769 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3770 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
3771 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
3772 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl,
3773 struct wined3d_context_gl *context_gl, unsigned int level,
3774 const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;
3775 void wined3d_texture_gl_unload_texture(struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
3777 struct wined3d_texture_vk
3779 struct wined3d_texture t;
3782 static inline struct wined3d_texture_vk *wined3d_texture_vk(struct wined3d_texture *texture)
3784 return CONTAINING_RECORD(texture, struct wined3d_texture_vk, t);
3787 HRESULT wined3d_texture_vk_init(struct wined3d_texture_vk *texture_vk, struct wined3d_device *device,
3788 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
3789 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3791 struct wined3d_renderbuffer_entry
3793 struct list entry;
3794 GLuint id;
3795 UINT width;
3796 UINT height;
3799 struct wined3d_fbo_resource
3801 GLuint object;
3802 GLenum target;
3803 GLuint level, layer;
3806 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
3807 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
3808 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
3810 struct fbo_entry
3812 struct list entry;
3813 DWORD flags;
3814 DWORD rt_mask;
3815 GLuint id;
3816 struct wined3d_fbo_entry_key
3818 DWORD rb_namespace;
3819 struct wined3d_fbo_resource objects[MAX_RENDER_TARGET_VIEWS + 1];
3820 } key;
3823 struct wined3d_sampler
3825 struct wine_rb_entry entry;
3826 LONG refcount;
3827 struct wined3d_device *device;
3828 void *parent;
3829 const struct wined3d_parent_ops *parent_ops;
3830 struct wined3d_sampler_desc desc;
3833 struct wined3d_sampler_gl
3835 struct wined3d_sampler s;
3837 GLuint name;
3840 static inline struct wined3d_sampler_gl *wined3d_sampler_gl(struct wined3d_sampler *sampler)
3842 return CONTAINING_RECORD(sampler, struct wined3d_sampler_gl, s);
3845 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl *sampler_gl, unsigned int unit,
3846 struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
3847 void wined3d_sampler_gl_init(struct wined3d_sampler_gl *sampler_gl,
3848 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3849 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3851 void wined3d_sampler_vk_init(struct wined3d_sampler *sampler_vk,
3852 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3853 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3855 struct wined3d_vertex_declaration_element
3857 const struct wined3d_format *format;
3858 BOOL ffp_valid;
3859 unsigned int input_slot;
3860 unsigned int offset;
3861 unsigned int output_slot;
3862 enum wined3d_input_classification input_slot_class;
3863 unsigned int instance_data_step_rate;
3864 BYTE method;
3865 BYTE usage;
3866 BYTE usage_idx;
3869 struct wined3d_vertex_declaration
3871 LONG ref;
3872 void *parent;
3873 const struct wined3d_parent_ops *parent_ops;
3874 struct wined3d_device *device;
3876 struct wined3d_vertex_declaration_element *elements;
3877 unsigned int element_count;
3879 BOOL position_transformed;
3882 struct wined3d_saved_states
3884 DWORD transform[(WINED3D_HIGHEST_TRANSFORM_STATE >> 5) + 1];
3885 WORD streamSource; /* WINED3D_MAX_STREAMS, 16 */
3886 WORD streamFreq; /* WINED3D_MAX_STREAMS, 16 */
3887 DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
3888 DWORD textureState[WINED3D_MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
3889 WORD samplerState[WINED3D_MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
3890 DWORD clipplane; /* WINED3D_MAX_USER_CLIP_PLANES, 32 */
3891 WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
3892 WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
3893 BOOL ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3894 WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
3895 WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
3896 BOOL vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3897 DWORD textures : 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
3898 DWORD indices : 1;
3899 DWORD material : 1;
3900 DWORD viewport : 1;
3901 DWORD vertexDecl : 1;
3902 DWORD pixelShader : 1;
3903 DWORD vertexShader : 1;
3904 DWORD scissorRect : 1;
3905 DWORD blend_state : 1;
3906 DWORD store_stream_offset : 1;
3907 DWORD padding : 3;
3910 struct StageState {
3911 DWORD stage;
3912 DWORD state;
3915 struct wined3d_stateblock
3917 LONG ref; /* Note: Ref counting not required */
3918 struct wined3d_device *device;
3920 /* Array indicating whether things have been set or changed */
3921 struct wined3d_saved_states changed;
3922 struct wined3d_stateblock_state stateblock_state;
3924 /* Contained state management */
3925 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
3926 unsigned int num_contained_render_states;
3927 DWORD contained_transform_states[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3928 unsigned int num_contained_transform_states;
3929 DWORD contained_vs_consts_i[WINED3D_MAX_CONSTS_I];
3930 unsigned int num_contained_vs_consts_i;
3931 DWORD contained_vs_consts_b[WINED3D_MAX_CONSTS_B];
3932 unsigned int num_contained_vs_consts_b;
3933 DWORD contained_vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3934 unsigned int num_contained_vs_consts_f;
3935 DWORD contained_ps_consts_i[WINED3D_MAX_CONSTS_I];
3936 unsigned int num_contained_ps_consts_i;
3937 DWORD contained_ps_consts_b[WINED3D_MAX_CONSTS_B];
3938 unsigned int num_contained_ps_consts_b;
3939 DWORD contained_ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3940 unsigned int num_contained_ps_consts_f;
3941 struct StageState contained_tss_states[WINED3D_MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
3942 unsigned int num_contained_tss_states;
3943 struct StageState contained_sampler_states[WINED3D_MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
3944 unsigned int num_contained_sampler_states;
3947 void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
3949 void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
3950 const struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
3951 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
3953 void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
3954 struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
3955 struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
3956 unsigned int idx) DECLSPEC_HIDDEN;
3957 HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
3958 const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
3960 void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
3961 void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
3962 const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN;
3963 void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
3965 enum wined3d_cs_queue_id
3967 WINED3D_CS_QUEUE_DEFAULT = 0,
3968 WINED3D_CS_QUEUE_MAP,
3969 WINED3D_CS_QUEUE_COUNT,
3972 enum wined3d_push_constants
3974 WINED3D_PUSH_CONSTANTS_VS_F,
3975 WINED3D_PUSH_CONSTANTS_PS_F,
3976 WINED3D_PUSH_CONSTANTS_VS_I,
3977 WINED3D_PUSH_CONSTANTS_PS_I,
3978 WINED3D_PUSH_CONSTANTS_VS_B,
3979 WINED3D_PUSH_CONSTANTS_PS_B,
3982 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
3983 #define WINED3D_CS_QUEUE_SIZE 0x100000u
3984 #define WINED3D_CS_SPIN_COUNT 10000000u
3986 struct wined3d_cs_queue
3988 LONG head, tail;
3989 BYTE data[WINED3D_CS_QUEUE_SIZE];
3992 struct wined3d_cs_ops
3994 void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
3995 void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
3996 void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
3997 void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p,
3998 unsigned int start_idx, unsigned int count, const void *constants);
4001 struct wined3d_cs
4003 const struct wined3d_cs_ops *ops;
4004 struct wined3d_device *device;
4005 struct wined3d_fb_state fb;
4006 struct wined3d_state state;
4007 HMODULE wined3d_module;
4008 HANDLE thread;
4009 DWORD thread_id;
4011 struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
4012 size_t data_size, start, end;
4013 void *data;
4014 struct list query_poll_list;
4015 BOOL queries_flushed;
4017 HANDLE event;
4018 BOOL waiting_for_event;
4019 LONG pending_presents;
4022 struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN;
4023 void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4024 void wined3d_cs_destroy_object(struct wined3d_cs *cs,
4025 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4026 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
4027 struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
4028 void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
4029 unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
4030 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
4031 const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4032 void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
4033 DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4034 void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined3d_rendertarget_view *view,
4035 const RECT *rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4036 void wined3d_cs_emit_clear_unordered_access_view_uint(struct wined3d_cs *cs,
4037 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value) DECLSPEC_HIDDEN;
4038 void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buffer *dst_buffer,
4039 unsigned int offset, struct wined3d_unordered_access_view *uav) DECLSPEC_HIDDEN;
4040 void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
4041 unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) DECLSPEC_HIDDEN;
4042 void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs,
4043 struct wined3d_buffer *buffer, unsigned int offset) DECLSPEC_HIDDEN;
4044 void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
4045 int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
4046 unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
4047 void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
4048 struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) DECLSPEC_HIDDEN;
4049 void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4050 void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4051 void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4052 void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
4053 const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags) DECLSPEC_HIDDEN;
4054 void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN;
4055 void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4056 void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state,
4057 const struct wined3d_color *blend_factor) DECLSPEC_HIDDEN;
4058 void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
4059 const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
4060 void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
4061 WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
4062 void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
4063 UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4064 void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
4065 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4066 void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
4067 enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN;
4068 void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light_info *light) DECLSPEC_HIDDEN;
4069 void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) DECLSPEC_HIDDEN;
4070 void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
4071 void wined3d_cs_emit_set_predication(struct wined3d_cs *cs,
4072 struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
4073 void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs,
4074 struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN;
4075 void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
4076 enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
4077 void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx,
4078 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4079 void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
4080 UINT view_idx, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4081 void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type,
4082 UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
4083 void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx,
4084 enum wined3d_sampler_state state, DWORD value) DECLSPEC_HIDDEN;
4085 void wined3d_cs_emit_set_scissor_rects(struct wined3d_cs *cs, unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN;
4086 void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type,
4087 struct wined3d_shader *shader) DECLSPEC_HIDDEN;
4088 void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx,
4089 struct wined3d_buffer *buffer, UINT offset) DECLSPEC_HIDDEN;
4090 void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx,
4091 struct wined3d_buffer *buffer, UINT offset, UINT stride) DECLSPEC_HIDDEN;
4092 void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx,
4093 UINT frequency, UINT flags) DECLSPEC_HIDDEN;
4094 void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4095 void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage,
4096 enum wined3d_texture_stage_state state, DWORD value) DECLSPEC_HIDDEN;
4097 void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
4098 const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
4099 void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
4100 unsigned int view_idx, struct wined3d_unordered_access_view *view,
4101 unsigned int initial_count) DECLSPEC_HIDDEN;
4102 void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
4103 struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
4104 void wined3d_cs_emit_set_viewports(struct wined3d_cs *cs, unsigned int viewport_count, const struct wined3d_viewport *viewports) DECLSPEC_HIDDEN;
4105 void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4106 void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource,
4107 unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
4108 unsigned int slice_pitch) DECLSPEC_HIDDEN;
4109 void wined3d_cs_init_object(struct wined3d_cs *cs,
4110 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4111 HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
4112 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
4113 HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource,
4114 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
4116 static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
4118 cs->ops->finish(cs, queue_id);
4121 static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
4122 unsigned int start_idx, unsigned int count, const void *constants)
4124 cs->ops->push_constants(cs, p, start_idx, count, constants);
4127 static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
4129 const struct wined3d_cs *cs = resource->device->cs;
4131 if (!cs->thread || cs->thread_id == GetCurrentThreadId())
4132 return;
4134 while (InterlockedCompareExchange(&resource->access_count, 0, 0))
4135 wined3d_pause();
4138 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
4139 * fixed function semantics as D3DCOLOR or FLOAT16 */
4140 enum wined3d_buffer_conversion_type
4142 CONV_NONE,
4143 CONV_D3DCOLOR,
4144 CONV_POSITIONT,
4147 struct wined3d_map_range
4149 UINT offset;
4150 UINT size;
4153 struct wined3d_buffer_ops
4155 BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer,
4156 struct wined3d_context *context, unsigned int location);
4157 void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
4158 unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges);
4159 void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
4160 unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges);
4163 struct wined3d_buffer
4165 struct wined3d_resource resource;
4166 const struct wined3d_buffer_ops *buffer_ops;
4168 unsigned int structure_byte_stride;
4169 DWORD flags;
4170 DWORD locations;
4171 void *map_ptr;
4173 struct wined3d_map_range *maps;
4174 SIZE_T maps_size, modified_areas;
4175 struct wined3d_fence *fence;
4177 /* conversion stuff */
4178 UINT decl_change_count, full_conversion_count;
4179 UINT draw_count;
4180 UINT stride; /* 0 if no conversion */
4181 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
4182 UINT conversion_stride; /* 0 if no shifted conversion */
4185 static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
4187 return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
4190 void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4191 DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer,
4192 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4193 void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
4194 void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
4195 const struct wined3d_state *state) DECLSPEC_HIDDEN;
4196 BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
4197 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4198 BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
4199 void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
4200 struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
4201 void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
4202 const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
4204 HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device,
4205 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4206 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4208 struct wined3d_buffer_gl
4210 struct wined3d_buffer b;
4212 GLuint buffer_object;
4213 GLenum buffer_object_usage;
4214 GLenum buffer_type_hint;
4217 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
4219 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
4222 void wined3d_buffer_gl_destroy_buffer_object(struct wined3d_buffer_gl *buffer_gl,
4223 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4224 HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device,
4225 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4226 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4228 struct wined3d_buffer_vk
4230 struct wined3d_buffer b;
4233 static inline struct wined3d_buffer_vk *wined3d_buffer_vk(struct wined3d_buffer *buffer)
4235 return CONTAINING_RECORD(buffer, struct wined3d_buffer_vk, b);
4238 HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device,
4239 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4240 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4242 struct wined3d_rendertarget_view
4244 LONG refcount;
4246 struct wined3d_resource *resource;
4247 void *parent;
4248 const struct wined3d_parent_ops *parent_ops;
4250 const struct wined3d_format *format;
4251 unsigned int format_flags;
4252 unsigned int sub_resource_idx;
4253 unsigned int layer_count;
4255 unsigned int width;
4256 unsigned int height;
4258 struct wined3d_view_desc desc;
4261 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4262 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
4263 const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
4264 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
4265 DWORD location) DECLSPEC_HIDDEN;
4266 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
4267 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4268 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,
4269 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4270 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
4271 DWORD location) DECLSPEC_HIDDEN;
4273 HRESULT wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view *view_no3d,
4274 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4275 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4277 struct wined3d_rendertarget_view_gl
4279 struct wined3d_rendertarget_view v;
4280 struct wined3d_gl_view gl_view;
4283 static inline struct wined3d_rendertarget_view_gl *wined3d_rendertarget_view_gl(
4284 struct wined3d_rendertarget_view *view)
4286 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_gl, v);
4289 HRESULT wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl *view_gl,
4290 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4291 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4293 struct wined3d_rendertarget_view_vk
4295 struct wined3d_rendertarget_view v;
4298 static inline struct wined3d_rendertarget_view_vk *wined3d_rendertarget_view_vk(
4299 struct wined3d_rendertarget_view *view)
4301 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_vk, v);
4304 HRESULT wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk *view_vk,
4305 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4306 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4308 struct wined3d_shader_resource_view
4310 LONG refcount;
4312 struct wined3d_resource *resource;
4313 void *parent;
4314 const struct wined3d_parent_ops *parent_ops;
4316 const struct wined3d_format *format;
4318 struct wined3d_view_desc desc;
4321 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4322 void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4324 struct wined3d_shader_resource_view_gl
4326 struct wined3d_shader_resource_view v;
4327 struct wined3d_gl_view gl_view;
4330 static inline struct wined3d_shader_resource_view_gl *wined3d_shader_resource_view_gl(
4331 struct wined3d_shader_resource_view *view)
4333 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_gl, v);
4336 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit,
4337 struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4338 HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl *view_gl,
4339 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4340 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4342 struct wined3d_shader_resource_view_vk
4344 struct wined3d_shader_resource_view v;
4347 static inline struct wined3d_shader_resource_view_vk *wined3d_shader_resource_view_vk(
4348 struct wined3d_shader_resource_view *view)
4350 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_vk, v);
4353 HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk *view_vk,
4354 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4355 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4357 struct wined3d_unordered_access_view
4359 LONG refcount;
4361 struct wined3d_resource *resource;
4362 void *parent;
4363 const struct wined3d_parent_ops *parent_ops;
4365 const struct wined3d_format *format;
4367 struct wined3d_view_desc desc;
4370 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
4371 void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_view *view,
4372 const struct wined3d_uvec4 *clear_value, struct wined3d_context *context) DECLSPEC_HIDDEN;
4373 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
4374 struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
4375 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
4376 DWORD location) DECLSPEC_HIDDEN;
4377 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
4378 unsigned int value) DECLSPEC_HIDDEN;
4380 struct wined3d_unordered_access_view_gl
4382 struct wined3d_unordered_access_view v;
4383 struct wined3d_gl_view gl_view;
4384 GLuint counter_bo;
4387 static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_view_gl(
4388 struct wined3d_unordered_access_view *view)
4390 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_gl, v);
4393 HRESULT wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl *view_gl,
4394 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4395 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4397 struct wined3d_unordered_access_view_vk
4399 struct wined3d_unordered_access_view v;
4402 static inline struct wined3d_unordered_access_view_vk *wined3d_unordered_access_view_vk(
4403 struct wined3d_unordered_access_view *view)
4405 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_vk, v);
4408 HRESULT wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk *view_vk,
4409 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4410 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4412 struct wined3d_swapchain_state
4414 struct wined3d_swapchain_desc desc;
4416 struct wined3d_display_mode original_mode, d3d_mode;
4417 RECT original_window_rect;
4419 /* Window styles to restore when switching fullscreen mode. */
4420 LONG style;
4421 LONG exstyle;
4422 HWND device_window;
4425 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
4426 HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
4427 HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
4428 HWND window, unsigned int w, unsigned int h) DECLSPEC_HIDDEN;
4430 struct wined3d_swapchain_ops
4432 void (*swapchain_present)(struct wined3d_swapchain *swapchain,
4433 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, DWORD flags);
4434 void (*swapchain_frontbuffer_updated)(struct wined3d_swapchain *swapchain);
4437 struct wined3d_swapchain
4439 LONG ref;
4440 void *parent;
4441 const struct wined3d_parent_ops *parent_ops;
4442 const struct wined3d_swapchain_ops *swapchain_ops;
4443 struct wined3d_device *device;
4445 struct wined3d_texture **back_buffers;
4446 struct wined3d_texture *front_buffer;
4447 struct wined3d_gamma_ramp orig_gamma;
4448 BOOL render_to_fbo, reapply_mode;
4449 const struct wined3d_format *ds_format;
4450 struct wined3d_palette *palette;
4451 RECT front_buffer_update;
4452 unsigned int swap_interval;
4453 unsigned int max_frame_latency;
4455 LONG prev_time, frames; /* Performance tracking */
4457 struct wined3d_swapchain_state state;
4458 HWND win_handle;
4461 void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
4462 void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4463 void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4464 void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain,
4465 const struct wined3d_device *device) DECLSPEC_HIDDEN;
4467 HRESULT wined3d_swapchain_no3d_init(struct wined3d_swapchain *swapchain_no3d,
4468 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4469 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4471 struct wined3d_swapchain_gl
4473 struct wined3d_swapchain s;
4475 struct wined3d_context_gl **contexts;
4476 SIZE_T contexts_size;
4477 SIZE_T context_count;
4479 HDC backup_dc;
4480 HWND backup_wnd;
4483 static inline struct wined3d_swapchain_gl *wined3d_swapchain_gl(struct wined3d_swapchain *swapchain)
4485 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_gl, s);
4488 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4489 void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4490 HDC wined3d_swapchain_gl_get_backup_dc(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4491 struct wined3d_context_gl *wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4492 HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl,
4493 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4494 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4496 HRESULT wined3d_swapchain_vk_init(struct wined3d_swapchain *swapchain_vk,
4497 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4498 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4500 /*****************************************************************************
4501 * Utility function prototypes
4504 /* Trace routines */
4505 const char *debug_bo_address(const struct wined3d_bo_address *address) DECLSPEC_HIDDEN;
4506 const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
4507 const char *debug_color(const struct wined3d_color *color) DECLSPEC_HIDDEN;
4508 const char *debug_const_bo_address(const struct wined3d_const_bo_address *address) DECLSPEC_HIDDEN;
4509 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
4510 const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
4511 const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
4512 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) DECLSPEC_HIDDEN;
4513 const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
4514 const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
4515 const char *debug_d3ddeclmethod(enum wined3d_decl_method method) DECLSPEC_HIDDEN;
4516 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
4517 const char *debug_d3dinput_classification(enum wined3d_input_classification classification) DECLSPEC_HIDDEN;
4518 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
4519 const char *debug_d3drenderstate(enum wined3d_render_state state) DECLSPEC_HIDDEN;
4520 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HIDDEN;
4521 const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
4522 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
4523 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
4524 const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
4525 const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
4526 const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
4527 const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
4528 const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
4529 const char *debug_ivec4(const struct wined3d_ivec4 *v) DECLSPEC_HIDDEN;
4530 const char *debug_uvec4(const struct wined3d_uvec4 *v) DECLSPEC_HIDDEN;
4531 const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
4532 const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
4533 const char *wined3d_debug_feature_level(enum wined3d_feature_level level) DECLSPEC_HIDDEN;
4534 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4536 BOOL is_invalid_op(const struct wined3d_state *state, int stage,
4537 enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
4538 void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
4539 BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
4540 INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
4541 void texture_activate_dimensions(struct wined3d_texture *texture,
4542 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
4543 void sampler_texdim(struct wined3d_context *context,
4544 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4545 void tex_alphaop(struct wined3d_context *context,
4546 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4547 void apply_pixelshader(struct wined3d_context *context,
4548 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4549 void state_alpha_test(struct wined3d_context *context,
4550 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4551 void state_fogcolor(struct wined3d_context *context,
4552 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4553 void state_fogdensity(struct wined3d_context *context,
4554 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4555 void state_fogstartend(struct wined3d_context *context,
4556 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4557 void state_fog_fragpart(struct wined3d_context *context,
4558 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4559 void state_nop(struct wined3d_context *context,
4560 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4561 void state_srgbwrite(struct wined3d_context *context,
4562 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4564 void state_clipping(struct wined3d_context *context,
4565 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4566 void clipplane(struct wined3d_context *context,
4567 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4568 void state_pointsprite_w(struct wined3d_context *context,
4569 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4570 void state_pointsprite(struct wined3d_context *context,
4571 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4572 void state_shademode(struct wined3d_context *context,
4573 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4575 GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
4576 enum wined3d_primitive_type d3d_primitive_type_from_gl(GLenum primitive_type) DECLSPEC_HIDDEN;
4578 /* Math utils */
4579 void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
4580 const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
4582 void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
4584 struct wined3d_shader_lconst
4586 struct list entry;
4587 unsigned int idx;
4588 DWORD value[4];
4591 struct wined3d_shader_limits
4593 unsigned int sampler;
4594 unsigned int constant_int;
4595 unsigned int constant_float;
4596 unsigned int constant_bool;
4597 unsigned int packed_output;
4598 unsigned int packed_input;
4601 #ifdef __GNUC__
4602 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
4603 #else
4604 #define PRINTF_ATTR(fmt,args)
4605 #endif
4607 struct wined3d_string_buffer_list
4609 struct list list;
4612 struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4613 void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN;
4614 void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4615 void string_buffer_list_init(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4616 void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4618 int shader_addline(struct wined3d_string_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
4619 BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc) DECLSPEC_HIDDEN;
4620 int shader_vaddline(struct wined3d_string_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
4622 struct wined3d_shader_phase
4624 const DWORD *start;
4625 const DWORD *end;
4626 unsigned int instance_count;
4627 unsigned int temporary_count;
4630 struct wined3d_vertex_shader
4632 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
4635 struct wined3d_hull_shader
4637 struct
4639 struct wined3d_shader_phase *control_point;
4640 unsigned int fork_count;
4641 unsigned int join_count;
4642 struct wined3d_shader_phase *fork;
4643 SIZE_T fork_size;
4644 struct wined3d_shader_phase *join;
4645 SIZE_T join_size;
4646 } phases;
4647 unsigned int output_vertex_count;
4648 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
4649 enum wined3d_tessellator_partitioning tessellator_partitioning;
4652 struct wined3d_domain_shader
4654 enum wined3d_tessellator_domain tessellator_domain;
4657 struct wined3d_geometry_shader
4659 enum wined3d_primitive_type input_type;
4660 enum wined3d_primitive_type output_type;
4661 unsigned int vertices_out;
4662 unsigned int instance_count;
4664 struct wined3d_stream_output_desc so_desc;
4667 struct wined3d_pixel_shader
4669 /* Pixel shader input semantics */
4670 DWORD input_reg_map[MAX_REG_INPUT];
4671 DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
4672 unsigned int declared_in_count;
4674 /* Some information about the shader behavior */
4675 BOOL color0_mov;
4676 DWORD color0_reg;
4678 BOOL force_early_depth_stencil;
4679 enum wined3d_shader_register_type depth_output;
4680 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
4683 struct wined3d_compute_shader
4685 struct wined3d_shader_thread_group_size thread_group_size;
4688 struct wined3d_shader
4690 LONG ref;
4691 const struct wined3d_shader_limits *limits;
4692 const DWORD *function;
4693 unsigned int functionLength;
4694 void *byte_code;
4695 unsigned int byte_code_size;
4696 BOOL load_local_constsF;
4697 const struct wined3d_shader_frontend *frontend;
4698 void *frontend_data;
4699 void *backend_data;
4701 void *parent;
4702 const struct wined3d_parent_ops *parent_ops;
4704 /* Programs this shader is linked with */
4705 struct list linked_programs;
4707 /* Immediate constants (override global ones) */
4708 struct list constantsB;
4709 struct list constantsF;
4710 struct list constantsI;
4711 struct wined3d_shader_reg_maps reg_maps;
4712 BOOL lconst_inf_or_nan;
4714 struct wined3d_shader_signature input_signature;
4715 struct wined3d_shader_signature output_signature;
4716 struct wined3d_shader_signature patch_constant_signature;
4718 /* Pointer to the parent device */
4719 struct wined3d_device *device;
4720 struct list shader_list_entry;
4722 union
4724 struct wined3d_vertex_shader vs;
4725 struct wined3d_hull_shader hs;
4726 struct wined3d_domain_shader ds;
4727 struct wined3d_geometry_shader gs;
4728 struct wined3d_pixel_shader ps;
4729 struct wined3d_compute_shader cs;
4730 } u;
4733 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
4734 unsigned int resource_idx, DWORD tex_types) DECLSPEC_HIDDEN;
4735 void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4736 BOOL position_transformed, struct ps_compile_args *args,
4737 const struct wined3d_context *context) DECLSPEC_HIDDEN;
4739 BOOL vshader_get_input(const struct wined3d_shader *shader,
4740 BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
4741 void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4742 WORD swizzle_map, struct vs_compile_args *args,
4743 const struct wined3d_context *context) DECLSPEC_HIDDEN;
4745 void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4746 struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
4748 void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4749 struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
4751 void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4752 BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4753 void string_buffer_free(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4754 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
4755 unsigned int max) DECLSPEC_HIDDEN;
4756 HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
4757 const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
4758 const DWORD *start, const DWORD *end) DECLSPEC_HIDDEN;
4759 BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
4761 static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
4763 switch (reg->type)
4765 case WINED3DSPR_RASTOUT:
4766 /* oFog & oPts */
4767 if (reg->idx[0].offset)
4768 return TRUE;
4769 /* oPos */
4770 return FALSE;
4772 case WINED3DSPR_CONSTBOOL: /* b# */
4773 case WINED3DSPR_DEPTHOUT: /* oDepth */
4774 case WINED3DSPR_DEPTHOUTGE:
4775 case WINED3DSPR_DEPTHOUTLE:
4776 case WINED3DSPR_LOOP: /* aL */
4777 case WINED3DSPR_OUTPOINTID:
4778 case WINED3DSPR_PREDICATE: /* p0 */
4779 case WINED3DSPR_PRIMID: /* primID */
4780 case WINED3DSPR_COVERAGE: /* vCoverage */
4781 case WINED3DSPR_SAMPLEMASK: /* oMask */
4782 return TRUE;
4784 case WINED3DSPR_MISCTYPE:
4785 switch (reg->idx[0].offset)
4787 case 0: /* vPos */
4788 return FALSE;
4789 case 1: /* vFace */
4790 return TRUE;
4791 default:
4792 return FALSE;
4795 case WINED3DSPR_IMMCONST:
4796 return reg->immconst_type == WINED3D_IMMCONST_SCALAR;
4798 default:
4799 return FALSE;
4803 static inline void shader_get_position_fixup(const struct wined3d_context *context,
4804 const struct wined3d_state *state, unsigned int fixup_count, float *position_fixup)
4806 float center_offset;
4807 unsigned int i;
4809 if (context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)
4810 center_offset = 63.0f / 64.0f;
4811 else
4812 center_offset = -1.0f / 64.0f;
4814 for (i = 0; i < fixup_count; ++i)
4816 position_fixup[4 * i ] = 1.0f;
4817 position_fixup[4 * i + 1] = 1.0f;
4818 position_fixup[4 * i + 2] = center_offset / state->viewports[i].width;
4819 position_fixup[4 * i + 3] = -center_offset / state->viewports[i].height;
4821 if (context->render_offscreen)
4823 position_fixup[4 * i + 1] *= -1.0f;
4824 position_fixup[4 * i + 3] *= -1.0f;
4829 static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
4831 struct wined3d_shader_lconst *lconst;
4833 if (shader->load_local_constsF)
4834 return FALSE;
4836 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
4838 if (lconst->idx == reg)
4839 return TRUE;
4842 return FALSE;
4845 void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4846 void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4847 unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4848 void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4849 struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4850 void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4851 unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4852 void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state,
4853 float *out_min, float *out_max) DECLSPEC_HIDDEN;
4854 void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
4855 float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
4856 void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
4857 float *start, float *end) DECLSPEC_HIDDEN;
4859 /* Using additional shader constants (uniforms in GLSL / program environment
4860 * or local parameters in ARB) is costly:
4861 * ARB only knows float4 parameters and GLSL compiler are not really smart
4862 * when it comes to efficiently pack float2 uniforms, so no space is wasted
4863 * (in fact most compilers map a float2 to a full float4 uniform).
4865 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
4866 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
4867 * into a single shader constant (uniform / program parameter).
4869 * This structure is shared between the GLSL and the ARB backend.*/
4870 struct ps_np2fixup_info {
4871 unsigned char idx[WINED3D_MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
4872 WORD active; /* bitfield indicating if we can apply the fixup */
4873 WORD num_consts;
4876 void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL program) DECLSPEC_HIDDEN;
4877 void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLuint program) DECLSPEC_HIDDEN;
4879 struct wined3d_palette
4881 LONG ref;
4882 struct wined3d_device *device;
4884 unsigned int size;
4885 RGBQUAD colors[256];
4886 DWORD flags;
4889 /* DirectDraw utility functions */
4890 extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
4892 /*****************************************************************************
4893 * Pixel format management
4896 /* WineD3D pixel format flags */
4897 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x00000001
4898 #define WINED3DFMT_FLAG_FILTERING 0x00000002
4899 #define WINED3DFMT_FLAG_DEPTH 0x00000004
4900 #define WINED3DFMT_FLAG_STENCIL 0x00000008
4901 #define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
4902 #define WINED3DFMT_FLAG_EXTENSION 0x00000020
4903 #define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
4904 #define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
4905 #define WINED3DFMT_FLAG_DECOMPRESS 0x00000100
4906 #define WINED3DFMT_FLAG_FLOAT 0x00000200
4907 #define WINED3DFMT_FLAG_BUMPMAP 0x00000400
4908 #define WINED3DFMT_FLAG_SRGB_READ 0x00000800
4909 #define WINED3DFMT_FLAG_SRGB_WRITE 0x00001000
4910 #define WINED3DFMT_FLAG_VTF 0x00002000
4911 #define WINED3DFMT_FLAG_SHADOW 0x00004000
4912 #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
4913 #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
4914 #define WINED3DFMT_FLAG_BLOCKS 0x00020000
4915 #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
4916 #define WINED3DFMT_FLAG_TEXTURE 0x00080000
4917 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
4918 #define WINED3DFMT_FLAG_INTEGER 0x00200000
4919 #define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
4920 #define WINED3DFMT_FLAG_NORMALISED 0x00800000
4921 #define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE 0x01000000
4922 #define WINED3DFMT_FLAG_BLIT 0x02000000
4923 #define WINED3DFMT_FLAG_MAPPABLE 0x04000000
4925 struct wined3d_rational
4927 UINT numerator;
4928 UINT denominator;
4931 struct wined3d_color_key_conversion
4933 enum wined3d_format_id dst_format;
4934 void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch,
4935 unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key);
4938 struct wined3d_format
4940 enum wined3d_format_id id;
4942 D3DDDIFORMAT ddi_format;
4943 unsigned int component_count;
4944 DWORD red_size;
4945 DWORD green_size;
4946 DWORD blue_size;
4947 DWORD alpha_size;
4948 DWORD red_offset;
4949 DWORD green_offset;
4950 DWORD blue_offset;
4951 DWORD alpha_offset;
4952 UINT byte_count;
4953 BYTE depth_size;
4954 BYTE stencil_size;
4956 UINT block_width;
4957 UINT block_height;
4958 UINT block_byte_count;
4960 enum wined3d_ffp_emit_idx emit_idx;
4962 UINT conv_byte_count;
4963 DWORD multisample_types;
4964 unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
4965 float depth_bias_scale;
4966 struct wined3d_rational height_scale;
4967 struct color_fixup_desc color_fixup;
4968 void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4969 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
4970 unsigned int width, unsigned int height, unsigned int depth);
4971 void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4972 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
4973 unsigned int width, unsigned int height, unsigned int depth);
4974 void (*decompress)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4975 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
4976 unsigned int width, unsigned int height, unsigned int depth);
4978 enum wined3d_format_id typeless_id;
4981 const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
4982 enum wined3d_format_id format_id, unsigned int bind_flags) DECLSPEC_HIDDEN;
4983 void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
4984 unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
4985 UINT wined3d_format_calculate_size(const struct wined3d_format *format,
4986 UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
4987 DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
4988 const struct wined3d_color *color) DECLSPEC_HIDDEN;
4989 void wined3d_format_get_float_color_key(const struct wined3d_format *format,
4990 const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
4991 BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
4992 enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
4993 const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
4994 const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
4995 BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
4996 enum wined3d_format_id format2) DECLSPEC_HIDDEN;
4998 struct wined3d_format_gl
5000 struct wined3d_format f;
5002 GLenum vtx_type;
5003 GLint vtx_format;
5005 GLint internal;
5006 GLint srgb_internal;
5007 GLint rt_internal;
5008 GLint format;
5009 GLint type;
5011 GLenum view_class;
5014 static inline const struct wined3d_format_gl *wined3d_format_gl(const struct wined3d_format *format)
5016 return CONTAINING_RECORD(format, struct wined3d_format_gl, f);
5019 struct wined3d_format_vk
5021 struct wined3d_format f;
5023 VkFormat vk_format;
5026 static inline const struct wined3d_format_vk *wined3d_format_vk(const struct wined3d_format *format)
5028 return CONTAINING_RECORD(format, struct wined3d_format_vk, f);
5031 BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
5033 static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
5035 return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
5038 static inline BOOL use_vs(const struct wined3d_state *state)
5040 /* Check state->vertex_declaration to allow this to be used before the
5041 * stream info is validated, for example in device_update_tex_unit_map(). */
5042 return state->shader[WINED3D_SHADER_TYPE_VERTEX]
5043 && (!state->vertex_declaration || !state->vertex_declaration->position_transformed);
5046 static inline BOOL use_ps(const struct wined3d_state *state)
5048 return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
5051 static inline void context_apply_state(struct wined3d_context *context,
5052 const struct wined3d_state *state, DWORD state_id)
5054 const struct wined3d_state_entry *state_table = context->state_table;
5055 unsigned int rep = state_table[state_id].representative;
5056 state_table[rep].apply(context, state, rep);
5059 static inline BOOL is_srgb_enabled(const DWORD *sampler_states)
5061 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
5062 * the behaviour of the AMD Windows driver.
5064 * Might & Magic: Heroes VI - Shades of Darkness sets
5065 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
5066 * pointer—presumably by accident—and expects sRGB decoding to be
5067 * disabled. */
5068 return sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
5071 static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
5072 const struct wined3d_texture *texture)
5074 unsigned int flags = texture->resource.format_flags
5075 & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
5077 return (!context->d3d_info->srgb_read_control
5078 || (flags && flags != (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)))
5079 && context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL;
5082 static inline BOOL needs_srgb_write(const struct wined3d_context *context,
5083 const struct wined3d_state *state, const struct wined3d_fb_state *fb)
5085 return (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
5086 || state->render_states[WINED3D_RS_SRGBWRITEENABLE])
5087 && fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
5090 static inline GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl,
5091 const struct wined3d_context *context, BOOL srgb)
5093 return srgb && needs_separate_srgb_gl_texture(context, &texture_gl->t)
5094 ? texture_gl->texture_srgb.name : texture_gl->texture_rgb.name;
5097 static inline BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
5099 return d3d_info->texture_swizzle && !is_complex_fixup(format->color_fixup) && !is_scaling_fixup(format->color_fixup);
5102 static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
5104 return geometry_shader
5105 && geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
5108 static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
5109 unsigned int offset, unsigned int count)
5111 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5112 const unsigned int idx = offset / word_bit_count;
5113 const unsigned int shift = offset % word_bit_count;
5114 DWORD mask = (1u << count) - 1;
5115 DWORD ret;
5117 ret = (bitstream[idx] >> shift) & mask;
5118 if (shift + count > word_bit_count)
5120 const unsigned int extracted_bit_count = word_bit_count - shift;
5121 const unsigned int remaining_bit_count = count - extracted_bit_count;
5122 mask = (1u << remaining_bit_count) - 1;
5123 ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
5125 return ret;
5128 static inline void wined3d_insert_bits(DWORD *bitstream,
5129 unsigned int offset, unsigned int count, DWORD bits)
5131 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5132 const unsigned int idx = offset / word_bit_count;
5133 const unsigned int shift = offset % word_bit_count;
5134 DWORD mask = (1u << count) - 1;
5136 bitstream[idx] |= (bits & mask) << shift;
5137 if (shift + count > word_bit_count)
5139 const unsigned int inserted_bit_count = word_bit_count - shift;
5140 const unsigned int remaining_bit_count = count - inserted_bit_count;
5141 mask = (1u << remaining_bit_count) - 1;
5142 bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
5146 static inline void wined3d_from_cs(const struct wined3d_cs *cs)
5148 if (cs->thread)
5149 assert(cs->thread_id == GetCurrentThreadId());
5152 static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
5154 assert(cs->thread_id != GetCurrentThreadId());
5157 static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map,
5158 enum wined3d_material_color_source source)
5160 if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE))
5161 return source;
5162 if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR))
5163 return source;
5164 return WINED3D_MCS_MATERIAL;
5167 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse,
5168 enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient,
5169 enum wined3d_material_color_source *specular, const struct wined3d_state *state,
5170 const struct wined3d_stream_info *si)
5172 if (!state->render_states[WINED3D_RS_LIGHTING])
5174 *diffuse = WINED3D_MCS_COLOR1;
5175 *specular = WINED3D_MCS_COLOR2;
5176 *emissive = *ambient = WINED3D_MCS_MATERIAL;
5178 return;
5181 if (!state->render_states[WINED3D_RS_COLORVERTEX])
5183 *diffuse = *emissive = *ambient = *specular = WINED3D_MCS_MATERIAL;
5185 return;
5188 *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]);
5189 *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]);
5190 *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]);
5191 *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]);
5194 static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,
5195 const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
5197 struct wined3d_vec4 tmp;
5199 tmp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31 + v->w * m->_41;
5200 tmp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32 + v->w * m->_42;
5201 tmp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33 + v->w * m->_43;
5202 tmp.w = v->x * m->_14 + v->y * m->_24 + v->z * m->_34 + v->w * m->_44;
5204 *dst = tmp;
5207 BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
5209 void compute_normal_matrix(float *normal_matrix, BOOL legacy_lighting,
5210 const struct wined3d_matrix *modelview) DECLSPEC_HIDDEN;
5212 static inline struct wined3d_context *context_acquire(struct wined3d_device *device,
5213 struct wined3d_texture *texture, unsigned int sub_resource_idx)
5215 wined3d_from_cs(device->cs);
5217 return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx);
5220 static inline void context_release(struct wined3d_context *context)
5222 context->device->adapter->adapter_ops->adapter_release_context(context);
5225 static inline float wined3d_get_float_state(const struct wined3d_state *state, enum wined3d_render_state rs)
5227 union
5229 DWORD d;
5230 float f;
5232 tmpvalue;
5234 tmpvalue.d = state->render_states[rs];
5235 return tmpvalue.f;
5238 static inline void *wined3d_context_map_bo_address(struct wined3d_context *context,
5239 const struct wined3d_bo_address *data, size_t size, GLenum binding, uint32_t flags)
5241 return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, binding, flags);
5244 static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context,
5245 const struct wined3d_bo_address *data, GLenum binding)
5247 return context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, binding);
5250 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
5251 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
5253 #endif