wined3d: Move the fill mode to wined3d_rasterizer_state.
[wine.git] / dlls / wined3d / wined3d_private.h
blobdb4660cf58606f3acd44e0dad29c6f1f90f412e8
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 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
79 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
80 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
82 struct wined3d_fragment_pipe_ops;
83 struct wined3d_adapter;
84 struct wined3d_context;
85 struct wined3d_gl_info;
86 struct wined3d_state;
87 struct wined3d_swapchain_gl;
88 struct wined3d_texture_gl;
89 struct wined3d_vertex_pipe_ops;
91 enum wined3d_ffp_idx
93 WINED3D_FFP_POSITION = 0,
94 WINED3D_FFP_BLENDWEIGHT = 1,
95 WINED3D_FFP_BLENDINDICES = 2,
96 WINED3D_FFP_NORMAL = 3,
97 WINED3D_FFP_PSIZE = 4,
98 WINED3D_FFP_DIFFUSE = 5,
99 WINED3D_FFP_SPECULAR = 6,
100 WINED3D_FFP_TEXCOORD0 = 7,
101 WINED3D_FFP_TEXCOORD1 = 8,
102 WINED3D_FFP_TEXCOORD2 = 9,
103 WINED3D_FFP_TEXCOORD3 = 10,
104 WINED3D_FFP_TEXCOORD4 = 11,
105 WINED3D_FFP_TEXCOORD5 = 12,
106 WINED3D_FFP_TEXCOORD6 = 13,
107 WINED3D_FFP_TEXCOORD7 = 14,
108 WINED3D_FFP_ATTRIBS_COUNT = 15,
111 enum wined3d_ffp_emit_idx
113 WINED3D_FFP_EMIT_FLOAT1,
114 WINED3D_FFP_EMIT_FLOAT2,
115 WINED3D_FFP_EMIT_FLOAT3,
116 WINED3D_FFP_EMIT_FLOAT4,
117 WINED3D_FFP_EMIT_D3DCOLOR,
118 WINED3D_FFP_EMIT_UBYTE4,
119 WINED3D_FFP_EMIT_SHORT2,
120 WINED3D_FFP_EMIT_SHORT4,
121 WINED3D_FFP_EMIT_UBYTE4N,
122 WINED3D_FFP_EMIT_SHORT2N,
123 WINED3D_FFP_EMIT_SHORT4N,
124 WINED3D_FFP_EMIT_USHORT2N,
125 WINED3D_FFP_EMIT_USHORT4N,
126 WINED3D_FFP_EMIT_UDEC3,
127 WINED3D_FFP_EMIT_DEC3N,
128 WINED3D_FFP_EMIT_FLOAT16_2,
129 WINED3D_FFP_EMIT_FLOAT16_4,
130 WINED3D_FFP_EMIT_INVALID,
131 WINED3D_FFP_EMIT_COUNT,
134 /* Texture format fixups */
136 enum fixup_channel_source
138 CHANNEL_SOURCE_ZERO = 0,
139 CHANNEL_SOURCE_ONE = 1,
140 CHANNEL_SOURCE_X = 2,
141 CHANNEL_SOURCE_Y = 3,
142 CHANNEL_SOURCE_Z = 4,
143 CHANNEL_SOURCE_W = 5,
144 CHANNEL_SOURCE_COMPLEX0 = 6,
145 CHANNEL_SOURCE_COMPLEX1 = 7,
148 enum complex_fixup
150 COMPLEX_FIXUP_NONE = 0,
151 COMPLEX_FIXUP_YUY2 = 1,
152 COMPLEX_FIXUP_UYVY = 2,
153 COMPLEX_FIXUP_YV12 = 3,
154 COMPLEX_FIXUP_P8 = 4,
155 COMPLEX_FIXUP_NV12 = 5,
158 #include <pshpack2.h>
159 struct color_fixup_desc
161 unsigned short x_sign_fixup : 1;
162 unsigned short x_source : 3;
163 unsigned short y_sign_fixup : 1;
164 unsigned short y_source : 3;
165 unsigned short z_sign_fixup : 1;
166 unsigned short z_source : 3;
167 unsigned short w_sign_fixup : 1;
168 unsigned short w_source : 3;
170 #include <poppack.h>
172 struct wined3d_d3d_limits
174 unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
175 DWORD vs_uniform_count;
176 DWORD ps_uniform_count;
177 unsigned int varying_count;
178 unsigned int ffp_textures;
179 unsigned int ffp_blend_stages;
180 unsigned int ffp_vertex_blend_matrices;
181 unsigned int active_light_count;
183 unsigned int max_rt_count;
184 unsigned int max_clip_distances;
185 unsigned int texture_size;
186 float pointsize_max;
189 typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
190 typedef void (WINE_GLAPI *wined3d_ffp_texcoord_func)(GLenum unit, const void *data);
191 typedef void (WINE_GLAPI *wined3d_generic_attrib_func)(GLuint idx, const void *data);
192 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
194 struct wined3d_ffp_attrib_ops
196 wined3d_ffp_attrib_func position[WINED3D_FFP_EMIT_COUNT];
197 wined3d_ffp_attrib_func diffuse[WINED3D_FFP_EMIT_COUNT];
198 wined3d_ffp_attrib_func specular[WINED3D_FFP_EMIT_COUNT];
199 wined3d_ffp_attrib_func normal[WINED3D_FFP_EMIT_COUNT];
200 wined3d_ffp_texcoord_func texcoord[WINED3D_FFP_EMIT_COUNT];
201 wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT];
204 struct wined3d_d3d_info
206 struct wined3d_d3d_limits limits;
207 struct wined3d_ffp_attrib_ops ffp_attrib_ops;
208 uint32_t wined3d_creation_flags;
209 uint32_t xyzrhw : 1;
210 uint32_t emulated_flatshading : 1;
211 uint32_t ffp_generic_attributes : 1;
212 uint32_t ffp_alpha_test : 1;
213 uint32_t vs_clipping : 1;
214 uint32_t shader_color_key : 1;
215 uint32_t shader_double_precision : 1;
216 uint32_t shader_output_interpolation : 1;
217 uint32_t viewport_array_index_any_shader : 1;
218 uint32_t texture_npot : 1;
219 uint32_t texture_npot_conditional : 1;
220 uint32_t draw_base_vertex_offset : 1;
221 uint32_t vertex_bgra : 1;
222 uint32_t texture_swizzle : 1;
223 uint32_t srgb_read_control : 1;
224 uint32_t srgb_write_control : 1;
225 uint32_t clip_control : 1;
226 uint32_t full_ffp_varyings : 1;
227 enum wined3d_feature_level feature_level;
229 DWORD multisample_draw_location;
232 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
233 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
235 static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
237 struct color_fixup_desc fixup =
239 0u, complex_fixup & (1u << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
240 0u, complex_fixup & (1u << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
241 0u, complex_fixup & (1u << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
242 0u, complex_fixup & (1u << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
244 return fixup;
247 static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
249 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
252 static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
254 return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
257 static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
259 return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
262 static inline BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
264 return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
265 && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
266 && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
267 && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
270 static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
272 enum complex_fixup complex_fixup = 0;
273 if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
274 if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
275 if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
276 if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
277 return complex_fixup;
280 /* Device caps */
281 #define WINED3D_MAX_ACTIVE_LIGHTS 8
282 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
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;
300 VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
302 static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
304 if (func < WINED3D_CMP_NEVER || func > WINED3D_CMP_ALWAYS)
305 return WINED3D_CMP_ALWAYS;
306 return func;
309 static inline GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
311 return magLookup[mag_filter];
314 static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,
315 enum wined3d_texture_filter_type mip_filter)
317 return minMipLookup[min_filter].mip[mip_filter];
320 /* float_16_to_32() and float_32_to_16() (see implementation in
321 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
322 * to standard C floats and vice versa. They do not depend on the encoding
323 * of the C float, so they are platform independent, but slow. On x86 and
324 * other IEEE 754 compliant platforms the conversion can be accelerated by
325 * bit shifting the exponent and mantissa. There are also some SSE-based
326 * assembly routines out there.
328 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
330 static inline float float_16_to_32(const unsigned short *in)
332 const unsigned short s = ((*in) & 0x8000u);
333 const unsigned short e = ((*in) & 0x7c00u) >> 10;
334 const unsigned short m = (*in) & 0x3ffu;
335 const float sgn = (s ? -1.0f : 1.0f);
337 if(e == 0) {
338 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
339 else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
340 } else if(e < 31) {
341 return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
342 } else {
343 if(m == 0) return sgn * INFINITY;
344 else return NAN;
348 static inline float float_24_to_32(DWORD in)
350 const float sgn = in & 0x800000u ? -1.0f : 1.0f;
351 const unsigned short e = (in & 0x780000u) >> 19;
352 const unsigned int m = in & 0x7ffffu;
354 if (e == 0)
356 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
357 else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
359 else if (e < 15)
361 return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
363 else
365 if (m == 0) return sgn * INFINITY;
366 else return NAN;
370 static inline unsigned int wined3d_popcount(unsigned int x)
372 #ifdef HAVE___BUILTIN_POPCOUNT
373 return __builtin_popcount(x);
374 #else
375 x -= x >> 1 & 0x55555555;
376 x = (x & 0x33333333) + (x >> 2 & 0x33333333);
377 return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
378 #endif
381 static inline void wined3d_pause(void)
383 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
384 __asm__ __volatile__( "rep;nop" : : : "memory" );
385 #endif
388 #define ORM_BACKBUFFER 0
389 #define ORM_FBO 1
391 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
392 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
394 enum wined3d_renderer
396 WINED3D_RENDERER_AUTO,
397 WINED3D_RENDERER_VULKAN,
398 WINED3D_RENDERER_OPENGL,
399 WINED3D_RENDERER_NO3D,
402 enum wined3d_shader_backend
404 WINED3D_SHADER_BACKEND_AUTO,
405 WINED3D_SHADER_BACKEND_GLSL,
406 WINED3D_SHADER_BACKEND_ARB,
407 WINED3D_SHADER_BACKEND_NONE,
410 /* NOTE: When adding fields to this structure, make sure to update the default
411 * values in wined3d_main.c as well. */
412 struct wined3d_settings
414 unsigned int cs_multithreaded;
415 DWORD max_gl_version;
416 int offscreen_rendering_mode;
417 unsigned short pci_vendor_id;
418 unsigned short pci_device_id;
419 /* Memory tracking and object counting. */
420 UINT64 emulated_textureram;
421 char *logo;
422 unsigned int multisample_textures;
423 unsigned int sample_count;
424 BOOL check_float_constants;
425 unsigned int strict_shader_math;
426 unsigned int max_sm_vs;
427 unsigned int max_sm_hs;
428 unsigned int max_sm_ds;
429 unsigned int max_sm_gs;
430 unsigned int max_sm_ps;
431 unsigned int max_sm_cs;
432 enum wined3d_renderer renderer;
433 enum wined3d_shader_backend shader_backend;
436 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
438 enum wined3d_shader_byte_code_format
440 WINED3D_SHADER_BYTE_CODE_FORMAT_SM1,
441 WINED3D_SHADER_BYTE_CODE_FORMAT_SM4,
444 enum wined3d_shader_resource_type
446 WINED3D_SHADER_RESOURCE_NONE,
447 WINED3D_SHADER_RESOURCE_BUFFER,
448 WINED3D_SHADER_RESOURCE_TEXTURE_1D,
449 WINED3D_SHADER_RESOURCE_TEXTURE_2D,
450 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
451 WINED3D_SHADER_RESOURCE_TEXTURE_3D,
452 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
453 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
454 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
455 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
456 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
459 #define WINED3D_SHADER_CONST_VS_F 0x00000001
460 #define WINED3D_SHADER_CONST_VS_I 0x00000002
461 #define WINED3D_SHADER_CONST_VS_B 0x00000004
462 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
463 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
464 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
465 #define WINED3D_SHADER_CONST_PS_F 0x00000040
466 #define WINED3D_SHADER_CONST_PS_I 0x00000080
467 #define WINED3D_SHADER_CONST_PS_B 0x00000100
468 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
469 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
470 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
471 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
472 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
473 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
474 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
475 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
476 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
477 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
478 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
479 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
480 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
481 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
483 enum wined3d_shader_register_type
485 WINED3DSPR_TEMP = 0,
486 WINED3DSPR_INPUT = 1,
487 WINED3DSPR_CONST = 2,
488 WINED3DSPR_ADDR = 3,
489 WINED3DSPR_TEXTURE = 3,
490 WINED3DSPR_RASTOUT = 4,
491 WINED3DSPR_ATTROUT = 5,
492 WINED3DSPR_TEXCRDOUT = 6,
493 WINED3DSPR_OUTPUT = 6,
494 WINED3DSPR_CONSTINT = 7,
495 WINED3DSPR_COLOROUT = 8,
496 WINED3DSPR_DEPTHOUT = 9,
497 WINED3DSPR_SAMPLER = 10,
498 WINED3DSPR_CONST2 = 11,
499 WINED3DSPR_CONST3 = 12,
500 WINED3DSPR_CONST4 = 13,
501 WINED3DSPR_CONSTBOOL = 14,
502 WINED3DSPR_LOOP = 15,
503 WINED3DSPR_TEMPFLOAT16 = 16,
504 WINED3DSPR_MISCTYPE = 17,
505 WINED3DSPR_LABEL = 18,
506 WINED3DSPR_PREDICATE = 19,
507 WINED3DSPR_IMMCONST,
508 WINED3DSPR_CONSTBUFFER,
509 WINED3DSPR_IMMCONSTBUFFER,
510 WINED3DSPR_PRIMID,
511 WINED3DSPR_NULL,
512 WINED3DSPR_RESOURCE,
513 WINED3DSPR_UAV,
514 WINED3DSPR_OUTPOINTID,
515 WINED3DSPR_FORKINSTID,
516 WINED3DSPR_JOININSTID,
517 WINED3DSPR_INCONTROLPOINT,
518 WINED3DSPR_OUTCONTROLPOINT,
519 WINED3DSPR_PATCHCONST,
520 WINED3DSPR_TESSCOORD,
521 WINED3DSPR_GROUPSHAREDMEM,
522 WINED3DSPR_THREADID,
523 WINED3DSPR_THREADGROUPID,
524 WINED3DSPR_LOCALTHREADID,
525 WINED3DSPR_LOCALTHREADINDEX,
526 WINED3DSPR_IDXTEMP,
527 WINED3DSPR_STREAM,
528 WINED3DSPR_FUNCTIONBODY,
529 WINED3DSPR_FUNCTIONPOINTER,
530 WINED3DSPR_COVERAGE,
531 WINED3DSPR_SAMPLEMASK,
532 WINED3DSPR_GSINSTID,
533 WINED3DSPR_DEPTHOUTGE,
534 WINED3DSPR_DEPTHOUTLE,
535 WINED3DSPR_RASTERIZER,
538 enum wined3d_data_type
540 WINED3D_DATA_FLOAT,
541 WINED3D_DATA_INT,
542 WINED3D_DATA_RESOURCE,
543 WINED3D_DATA_SAMPLER,
544 WINED3D_DATA_UAV,
545 WINED3D_DATA_UINT,
546 WINED3D_DATA_UNORM,
547 WINED3D_DATA_SNORM,
548 WINED3D_DATA_OPAQUE,
551 enum wined3d_immconst_type
553 WINED3D_IMMCONST_SCALAR,
554 WINED3D_IMMCONST_VEC4,
557 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
559 enum wined3d_shader_src_modifier
561 WINED3DSPSM_NONE = 0,
562 WINED3DSPSM_NEG = 1,
563 WINED3DSPSM_BIAS = 2,
564 WINED3DSPSM_BIASNEG = 3,
565 WINED3DSPSM_SIGN = 4,
566 WINED3DSPSM_SIGNNEG = 5,
567 WINED3DSPSM_COMP = 6,
568 WINED3DSPSM_X2 = 7,
569 WINED3DSPSM_X2NEG = 8,
570 WINED3DSPSM_DZ = 9,
571 WINED3DSPSM_DW = 10,
572 WINED3DSPSM_ABS = 11,
573 WINED3DSPSM_ABSNEG = 12,
574 WINED3DSPSM_NOT = 13,
577 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
578 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
579 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
580 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
581 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
583 enum wined3d_shader_dst_modifier
585 WINED3DSPDM_NONE = 0,
586 WINED3DSPDM_SATURATE = 1,
587 WINED3DSPDM_PARTIALPRECISION = 2,
588 WINED3DSPDM_MSAMPCENTROID = 4,
591 enum wined3d_shader_interpolation_mode
593 WINED3DSIM_NONE = 0,
594 WINED3DSIM_CONSTANT = 1,
595 WINED3DSIM_LINEAR = 2,
596 WINED3DSIM_LINEAR_CENTROID = 3,
597 WINED3DSIM_LINEAR_NOPERSPECTIVE = 4,
598 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
599 WINED3DSIM_LINEAR_SAMPLE = 6,
600 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
603 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
604 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
606 enum wined3d_shader_global_flags
608 WINED3DSGF_REFACTORING_ALLOWED = 0x1,
609 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4,
610 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8,
613 enum wined3d_shader_sync_flags
615 WINED3DSSF_THREAD_GROUP = 0x1,
616 WINED3DSSF_GROUP_SHARED_MEMORY = 0x2,
619 enum wined3d_shader_uav_flags
621 WINED3DSUF_GLOBALLY_COHERENT = 0x2,
622 WINED3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
625 enum wined3d_tessellator_domain
627 WINED3D_TESSELLATOR_DOMAIN_LINE = 1,
628 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
629 WINED3D_TESSELLATOR_DOMAIN_QUAD = 3,
632 enum wined3d_tessellator_output_primitive
634 WINED3D_TESSELLATOR_OUTPUT_POINT = 1,
635 WINED3D_TESSELLATOR_OUTPUT_LINE = 2,
636 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
637 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
640 enum wined3d_tessellator_partitioning
642 WINED3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
643 WINED3D_TESSELLATOR_PARTITIONING_POW2 = 2,
644 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
645 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
648 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
649 #define WINED3DSI_TEXLD_PROJECT 0x1
650 #define WINED3DSI_TEXLD_BIAS 0x2
651 #define WINED3DSI_INDEXED_DYNAMIC 0x4
652 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
653 #define WINED3DSI_RESINFO_UINT 0x2
654 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
655 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
657 #define WINED3DSI_PRECISE_X 0x100
658 #define WINED3DSI_PRECISE_Y 0x200
659 #define WINED3DSI_PRECISE_Z 0x400
660 #define WINED3DSI_PRECISE_W 0x800
661 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
662 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
663 #define WINED3DSI_PRECISE_SHIFT 8
665 enum wined3d_shader_rel_op
667 WINED3D_SHADER_REL_OP_GT = 1,
668 WINED3D_SHADER_REL_OP_EQ = 2,
669 WINED3D_SHADER_REL_OP_GE = 3,
670 WINED3D_SHADER_REL_OP_LT = 4,
671 WINED3D_SHADER_REL_OP_NE = 5,
672 WINED3D_SHADER_REL_OP_LE = 6,
675 enum wined3d_shader_conditional_op
677 WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
678 WINED3D_SHADER_CONDITIONAL_OP_Z = 1
681 #define WINED3D_SM1_VS 0xfffeu
682 #define WINED3D_SM1_PS 0xffffu
683 #define WINED3D_SM4_PS 0x0000u
684 #define WINED3D_SM4_VS 0x0001u
685 #define WINED3D_SM4_GS 0x0002u
686 #define WINED3D_SM5_HS 0x0003u
687 #define WINED3D_SM5_DS 0x0004u
688 #define WINED3D_SM5_CS 0x0005u
690 /* Shader version tokens, and shader end tokens */
691 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
692 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
694 /* Shader backends */
696 /* TODO: Make this dynamic, based on shader limits ? */
697 #define MAX_ATTRIBS 16
698 #define MAX_REG_ADDR 1
699 #define MAX_REG_TEXCRD 8
700 #define MAX_REG_INPUT 32
701 #define MAX_REG_OUTPUT 32
702 #define WINED3D_MAX_CBS 15
704 /* FIXME: This needs to go up to 2048 for
705 * Shader model 3 according to msdn (and for software shaders) */
706 #define MAX_LABELS 16
708 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
710 struct wined3d_string_buffer
712 struct list entry;
713 char *buffer;
714 unsigned int buffer_size;
715 unsigned int content_size;
718 enum WINED3D_SHADER_INSTRUCTION_HANDLER
720 WINED3DSIH_ABS,
721 WINED3DSIH_ADD,
722 WINED3DSIH_AND,
723 WINED3DSIH_ATOMIC_AND,
724 WINED3DSIH_ATOMIC_CMP_STORE,
725 WINED3DSIH_ATOMIC_IADD,
726 WINED3DSIH_ATOMIC_IMAX,
727 WINED3DSIH_ATOMIC_IMIN,
728 WINED3DSIH_ATOMIC_OR,
729 WINED3DSIH_ATOMIC_UMAX,
730 WINED3DSIH_ATOMIC_UMIN,
731 WINED3DSIH_ATOMIC_XOR,
732 WINED3DSIH_BEM,
733 WINED3DSIH_BFI,
734 WINED3DSIH_BFREV,
735 WINED3DSIH_BREAK,
736 WINED3DSIH_BREAKC,
737 WINED3DSIH_BREAKP,
738 WINED3DSIH_BUFINFO,
739 WINED3DSIH_CALL,
740 WINED3DSIH_CALLNZ,
741 WINED3DSIH_CASE,
742 WINED3DSIH_CMP,
743 WINED3DSIH_CND,
744 WINED3DSIH_CONTINUE,
745 WINED3DSIH_CONTINUEP,
746 WINED3DSIH_COUNTBITS,
747 WINED3DSIH_CRS,
748 WINED3DSIH_CUT,
749 WINED3DSIH_CUT_STREAM,
750 WINED3DSIH_DCL,
751 WINED3DSIH_DCL_CONSTANT_BUFFER,
752 WINED3DSIH_DCL_FUNCTION_BODY,
753 WINED3DSIH_DCL_FUNCTION_TABLE,
754 WINED3DSIH_DCL_GLOBAL_FLAGS,
755 WINED3DSIH_DCL_GS_INSTANCES,
756 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT,
757 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT,
758 WINED3DSIH_DCL_HS_MAX_TESSFACTOR,
759 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
760 WINED3DSIH_DCL_INDEX_RANGE,
761 WINED3DSIH_DCL_INDEXABLE_TEMP,
762 WINED3DSIH_DCL_INPUT,
763 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT,
764 WINED3DSIH_DCL_INPUT_PRIMITIVE,
765 WINED3DSIH_DCL_INPUT_PS,
766 WINED3DSIH_DCL_INPUT_PS_SGV,
767 WINED3DSIH_DCL_INPUT_PS_SIV,
768 WINED3DSIH_DCL_INPUT_SGV,
769 WINED3DSIH_DCL_INPUT_SIV,
770 WINED3DSIH_DCL_INTERFACE,
771 WINED3DSIH_DCL_OUTPUT,
772 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT,
773 WINED3DSIH_DCL_OUTPUT_SIV,
774 WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
775 WINED3DSIH_DCL_RESOURCE_RAW,
776 WINED3DSIH_DCL_RESOURCE_STRUCTURED,
777 WINED3DSIH_DCL_SAMPLER,
778 WINED3DSIH_DCL_STREAM,
779 WINED3DSIH_DCL_TEMPS,
780 WINED3DSIH_DCL_TESSELLATOR_DOMAIN,
781 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE,
782 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING,
783 WINED3DSIH_DCL_TGSM_RAW,
784 WINED3DSIH_DCL_TGSM_STRUCTURED,
785 WINED3DSIH_DCL_THREAD_GROUP,
786 WINED3DSIH_DCL_UAV_RAW,
787 WINED3DSIH_DCL_UAV_STRUCTURED,
788 WINED3DSIH_DCL_UAV_TYPED,
789 WINED3DSIH_DCL_VERTICES_OUT,
790 WINED3DSIH_DEF,
791 WINED3DSIH_DEFAULT,
792 WINED3DSIH_DEFB,
793 WINED3DSIH_DEFI,
794 WINED3DSIH_DIV,
795 WINED3DSIH_DP2,
796 WINED3DSIH_DP2ADD,
797 WINED3DSIH_DP3,
798 WINED3DSIH_DP4,
799 WINED3DSIH_DST,
800 WINED3DSIH_DSX,
801 WINED3DSIH_DSX_COARSE,
802 WINED3DSIH_DSX_FINE,
803 WINED3DSIH_DSY,
804 WINED3DSIH_DSY_COARSE,
805 WINED3DSIH_DSY_FINE,
806 WINED3DSIH_ELSE,
807 WINED3DSIH_EMIT,
808 WINED3DSIH_EMIT_STREAM,
809 WINED3DSIH_ENDIF,
810 WINED3DSIH_ENDLOOP,
811 WINED3DSIH_ENDREP,
812 WINED3DSIH_ENDSWITCH,
813 WINED3DSIH_EQ,
814 WINED3DSIH_EVAL_SAMPLE_INDEX,
815 WINED3DSIH_EXP,
816 WINED3DSIH_EXPP,
817 WINED3DSIH_F16TOF32,
818 WINED3DSIH_F32TOF16,
819 WINED3DSIH_FCALL,
820 WINED3DSIH_FIRSTBIT_HI,
821 WINED3DSIH_FIRSTBIT_LO,
822 WINED3DSIH_FIRSTBIT_SHI,
823 WINED3DSIH_FRC,
824 WINED3DSIH_FTOI,
825 WINED3DSIH_FTOU,
826 WINED3DSIH_GATHER4,
827 WINED3DSIH_GATHER4_C,
828 WINED3DSIH_GATHER4_PO,
829 WINED3DSIH_GATHER4_PO_C,
830 WINED3DSIH_GE,
831 WINED3DSIH_HS_CONTROL_POINT_PHASE,
832 WINED3DSIH_HS_DECLS,
833 WINED3DSIH_HS_FORK_PHASE,
834 WINED3DSIH_HS_JOIN_PHASE,
835 WINED3DSIH_IADD,
836 WINED3DSIH_IBFE,
837 WINED3DSIH_IEQ,
838 WINED3DSIH_IF,
839 WINED3DSIH_IFC,
840 WINED3DSIH_IGE,
841 WINED3DSIH_ILT,
842 WINED3DSIH_IMAD,
843 WINED3DSIH_IMAX,
844 WINED3DSIH_IMIN,
845 WINED3DSIH_IMM_ATOMIC_ALLOC,
846 WINED3DSIH_IMM_ATOMIC_AND,
847 WINED3DSIH_IMM_ATOMIC_CMP_EXCH,
848 WINED3DSIH_IMM_ATOMIC_CONSUME,
849 WINED3DSIH_IMM_ATOMIC_EXCH,
850 WINED3DSIH_IMM_ATOMIC_IADD,
851 WINED3DSIH_IMM_ATOMIC_IMAX,
852 WINED3DSIH_IMM_ATOMIC_IMIN,
853 WINED3DSIH_IMM_ATOMIC_OR,
854 WINED3DSIH_IMM_ATOMIC_UMAX,
855 WINED3DSIH_IMM_ATOMIC_UMIN,
856 WINED3DSIH_IMM_ATOMIC_XOR,
857 WINED3DSIH_IMUL,
858 WINED3DSIH_INE,
859 WINED3DSIH_INEG,
860 WINED3DSIH_ISHL,
861 WINED3DSIH_ISHR,
862 WINED3DSIH_ITOF,
863 WINED3DSIH_LABEL,
864 WINED3DSIH_LD,
865 WINED3DSIH_LD2DMS,
866 WINED3DSIH_LD_RAW,
867 WINED3DSIH_LD_STRUCTURED,
868 WINED3DSIH_LD_UAV_TYPED,
869 WINED3DSIH_LIT,
870 WINED3DSIH_LOD,
871 WINED3DSIH_LOG,
872 WINED3DSIH_LOGP,
873 WINED3DSIH_LOOP,
874 WINED3DSIH_LRP,
875 WINED3DSIH_LT,
876 WINED3DSIH_M3x2,
877 WINED3DSIH_M3x3,
878 WINED3DSIH_M3x4,
879 WINED3DSIH_M4x3,
880 WINED3DSIH_M4x4,
881 WINED3DSIH_MAD,
882 WINED3DSIH_MAX,
883 WINED3DSIH_MIN,
884 WINED3DSIH_MOV,
885 WINED3DSIH_MOVA,
886 WINED3DSIH_MOVC,
887 WINED3DSIH_MUL,
888 WINED3DSIH_NE,
889 WINED3DSIH_NOP,
890 WINED3DSIH_NOT,
891 WINED3DSIH_NRM,
892 WINED3DSIH_OR,
893 WINED3DSIH_PHASE,
894 WINED3DSIH_POW,
895 WINED3DSIH_RCP,
896 WINED3DSIH_REP,
897 WINED3DSIH_RESINFO,
898 WINED3DSIH_RET,
899 WINED3DSIH_RETP,
900 WINED3DSIH_ROUND_NE,
901 WINED3DSIH_ROUND_NI,
902 WINED3DSIH_ROUND_PI,
903 WINED3DSIH_ROUND_Z,
904 WINED3DSIH_RSQ,
905 WINED3DSIH_SAMPLE,
906 WINED3DSIH_SAMPLE_B,
907 WINED3DSIH_SAMPLE_C,
908 WINED3DSIH_SAMPLE_C_LZ,
909 WINED3DSIH_SAMPLE_GRAD,
910 WINED3DSIH_SAMPLE_INFO,
911 WINED3DSIH_SAMPLE_LOD,
912 WINED3DSIH_SAMPLE_POS,
913 WINED3DSIH_SETP,
914 WINED3DSIH_SGE,
915 WINED3DSIH_SGN,
916 WINED3DSIH_SINCOS,
917 WINED3DSIH_SLT,
918 WINED3DSIH_SQRT,
919 WINED3DSIH_STORE_RAW,
920 WINED3DSIH_STORE_STRUCTURED,
921 WINED3DSIH_STORE_UAV_TYPED,
922 WINED3DSIH_SUB,
923 WINED3DSIH_SWAPC,
924 WINED3DSIH_SWITCH,
925 WINED3DSIH_SYNC,
926 WINED3DSIH_TEX,
927 WINED3DSIH_TEXBEM,
928 WINED3DSIH_TEXBEML,
929 WINED3DSIH_TEXCOORD,
930 WINED3DSIH_TEXDEPTH,
931 WINED3DSIH_TEXDP3,
932 WINED3DSIH_TEXDP3TEX,
933 WINED3DSIH_TEXKILL,
934 WINED3DSIH_TEXLDD,
935 WINED3DSIH_TEXLDL,
936 WINED3DSIH_TEXM3x2DEPTH,
937 WINED3DSIH_TEXM3x2PAD,
938 WINED3DSIH_TEXM3x2TEX,
939 WINED3DSIH_TEXM3x3,
940 WINED3DSIH_TEXM3x3DIFF,
941 WINED3DSIH_TEXM3x3PAD,
942 WINED3DSIH_TEXM3x3SPEC,
943 WINED3DSIH_TEXM3x3TEX,
944 WINED3DSIH_TEXM3x3VSPEC,
945 WINED3DSIH_TEXREG2AR,
946 WINED3DSIH_TEXREG2GB,
947 WINED3DSIH_TEXREG2RGB,
948 WINED3DSIH_UBFE,
949 WINED3DSIH_UDIV,
950 WINED3DSIH_UGE,
951 WINED3DSIH_ULT,
952 WINED3DSIH_UMAX,
953 WINED3DSIH_UMIN,
954 WINED3DSIH_UMUL,
955 WINED3DSIH_USHR,
956 WINED3DSIH_UTOF,
957 WINED3DSIH_XOR,
958 WINED3DSIH_TABLE_SIZE
961 struct wined3d_shader_version
963 enum wined3d_shader_type type;
964 BYTE major;
965 BYTE minor;
968 struct wined3d_shader_resource_info
970 enum wined3d_shader_resource_type type;
971 enum wined3d_data_type data_type;
972 unsigned int flags;
973 unsigned int stride;
976 #define WINED3D_SAMPLER_DEFAULT ~0x0u
978 struct wined3d_shader_sampler_map_entry
980 unsigned int resource_idx;
981 unsigned int sampler_idx;
982 unsigned int bind_idx;
985 struct wined3d_shader_sampler_map
987 struct wined3d_shader_sampler_map_entry *entries;
988 size_t size;
989 size_t count;
992 struct wined3d_shader_immediate_constant_buffer
994 unsigned int vec4_count;
995 DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
998 struct wined3d_shader_indexable_temp
1000 struct list entry;
1001 unsigned int register_idx;
1002 unsigned int register_size;
1003 unsigned int component_count;
1006 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1008 struct wined3d_shader_reg_maps
1010 struct wined3d_shader_version shader_version;
1011 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
1012 BYTE address; /* MAX_REG_ADDR, 1 */
1013 WORD labels; /* MAX_LABELS, 16 */
1014 DWORD temporary; /* 32 */
1015 unsigned int temporary_count;
1016 DWORD *constf; /* pixel, vertex */
1017 struct list indexable_temps;
1018 const struct wined3d_shader_immediate_constant_buffer *icb;
1019 union
1021 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1022 BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1023 } u;
1024 DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1025 DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1026 WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1027 WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1028 WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1029 WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1030 UINT cb_sizes[WINED3D_MAX_CBS];
1032 struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS];
1033 struct wined3d_shader_sampler_map sampler_map;
1034 DWORD sampler_comparison_mode;
1035 BYTE bumpmat; /* WINED3D_MAX_TEXTURES, 8 */
1036 BYTE luminanceparams; /* WINED3D_MAX_TEXTURES, 8 */
1037 struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
1038 DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1039 DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1041 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1042 DWORD cull_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1043 DWORD usesnrm : 1;
1044 DWORD vpos : 1;
1045 DWORD usesdsx : 1;
1046 DWORD usesdsy : 1;
1047 DWORD usestexldd : 1;
1048 DWORD usesmova : 1;
1049 DWORD usesfacing : 1;
1050 DWORD usesrelconstF : 1;
1051 DWORD fog : 1;
1052 DWORD usestexldl : 1;
1053 DWORD usesifc : 1;
1054 DWORD usescall : 1;
1055 DWORD usespow : 1;
1056 DWORD point_size : 1;
1057 DWORD vocp : 1;
1058 DWORD input_rel_addressing : 1;
1059 DWORD viewport_array : 1;
1060 DWORD sample_mask : 1;
1061 DWORD padding : 14;
1063 DWORD rt_mask; /* Used render targets, 32 max. */
1065 /* Whether or not loops are used in this shader, and nesting depth */
1066 unsigned int loop_depth;
1067 unsigned int min_rel_offset, max_rel_offset;
1069 struct wined3d_shader_tgsm *tgsm;
1070 SIZE_T tgsm_capacity;
1071 unsigned int tgsm_count;
1074 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1075 * state information between multiple instructions. */
1076 struct wined3d_shader_tex_mx
1078 unsigned int current_row;
1079 DWORD texcoord_w[2];
1082 struct wined3d_shader_parser_state
1084 unsigned int current_loop_depth;
1085 unsigned int current_loop_reg;
1086 BOOL in_subroutine;
1089 struct wined3d_shader_context
1091 const struct wined3d_shader *shader;
1092 const struct wined3d_shader_reg_maps *reg_maps;
1093 struct wined3d_string_buffer *buffer;
1094 struct wined3d_shader_tex_mx *tex_mx;
1095 struct wined3d_shader_parser_state *state;
1096 void *backend_data;
1099 struct wined3d_shader_register_index
1101 const struct wined3d_shader_src_param *rel_addr;
1102 unsigned int offset;
1105 struct wined3d_shader_register
1107 enum wined3d_shader_register_type type;
1108 enum wined3d_data_type data_type;
1109 struct wined3d_shader_register_index idx[2];
1110 enum wined3d_immconst_type immconst_type;
1111 union
1113 DWORD immconst_data[4];
1114 unsigned fp_body_idx;
1115 } u;
1118 struct wined3d_shader_dst_param
1120 struct wined3d_shader_register reg;
1121 DWORD write_mask;
1122 DWORD modifiers;
1123 DWORD shift;
1126 struct wined3d_shader_src_param
1128 struct wined3d_shader_register reg;
1129 DWORD swizzle;
1130 enum wined3d_shader_src_modifier modifiers;
1133 struct wined3d_shader_index_range
1135 struct wined3d_shader_dst_param first_register;
1136 unsigned int last_register;
1139 struct wined3d_shader_semantic
1141 enum wined3d_decl_usage usage;
1142 UINT usage_idx;
1143 enum wined3d_shader_resource_type resource_type;
1144 enum wined3d_data_type resource_data_type;
1145 struct wined3d_shader_dst_param reg;
1148 enum wined3d_shader_input_sysval_semantic
1150 WINED3D_SIV_POSITION = 1,
1151 WINED3D_SIV_CLIP_DISTANCE = 2,
1152 WINED3D_SIV_CULL_DISTANCE = 3,
1153 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
1154 WINED3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
1155 WINED3D_SIV_VERTEX_ID = 6,
1156 WINED3D_SIV_PRIMITIVE_ID = 7,
1157 WINED3D_SIV_INSTANCE_ID = 8,
1158 WINED3D_SIV_IS_FRONT_FACE = 9,
1159 WINED3D_SIV_SAMPLE_INDEX = 10,
1160 WINED3D_SIV_QUAD_U0_TESS_FACTOR = 11,
1161 WINED3D_SIV_QUAD_V0_TESS_FACTOR = 12,
1162 WINED3D_SIV_QUAD_U1_TESS_FACTOR = 13,
1163 WINED3D_SIV_QUAD_V1_TESS_FACTOR = 14,
1164 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
1165 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
1166 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
1167 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
1168 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
1169 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
1170 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
1171 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
1174 struct wined3d_shader_register_semantic
1176 struct wined3d_shader_dst_param reg;
1177 enum wined3d_shader_input_sysval_semantic sysval_semantic;
1180 struct wined3d_shader_structured_resource
1182 struct wined3d_shader_dst_param reg;
1183 unsigned int byte_stride;
1186 struct wined3d_shader_tgsm
1188 unsigned int size;
1189 unsigned int stride;
1192 struct wined3d_shader_tgsm_raw
1194 struct wined3d_shader_dst_param reg;
1195 unsigned int byte_count;
1198 struct wined3d_shader_tgsm_structured
1200 struct wined3d_shader_dst_param reg;
1201 unsigned int byte_stride;
1202 unsigned int structure_count;
1205 struct wined3d_shader_thread_group_size
1207 unsigned int x, y, z;
1210 struct wined3d_shader_function_table_pointer
1212 unsigned int index;
1213 unsigned int array_size;
1214 unsigned int body_count;
1215 unsigned int table_count;
1218 struct wined3d_shader_texel_offset
1220 signed char u, v, w;
1223 struct wined3d_shader_primitive_type
1225 enum wined3d_primitive_type type;
1226 unsigned int patch_vertex_count;
1229 struct wined3d_shader_instruction
1231 const struct wined3d_shader_context *ctx;
1232 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
1233 DWORD flags;
1234 unsigned int dst_count;
1235 unsigned int src_count;
1236 const struct wined3d_shader_dst_param *dst;
1237 const struct wined3d_shader_src_param *src;
1238 struct wined3d_shader_texel_offset texel_offset;
1239 BOOL coissue;
1240 const struct wined3d_shader_src_param *predicate;
1241 union
1243 struct wined3d_shader_semantic semantic;
1244 struct wined3d_shader_register_semantic register_semantic;
1245 struct wined3d_shader_primitive_type primitive_type;
1246 struct wined3d_shader_dst_param dst;
1247 struct wined3d_shader_src_param src;
1248 unsigned int count;
1249 unsigned int index;
1250 const struct wined3d_shader_immediate_constant_buffer *icb;
1251 struct wined3d_shader_structured_resource structured_resource;
1252 struct wined3d_shader_tgsm_raw tgsm_raw;
1253 struct wined3d_shader_tgsm_structured tgsm_structured;
1254 struct wined3d_shader_thread_group_size thread_group_size;
1255 enum wined3d_tessellator_domain tessellator_domain;
1256 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1257 enum wined3d_tessellator_partitioning tessellator_partitioning;
1258 float max_tessellation_factor;
1259 struct wined3d_shader_index_range index_range;
1260 struct wined3d_shader_indexable_temp indexable_temp;
1261 struct wined3d_shader_function_table_pointer fp;
1262 } declaration;
1265 static inline BOOL wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction *ins)
1267 return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1270 struct wined3d_shader_attribute
1272 enum wined3d_decl_usage usage;
1273 UINT usage_idx;
1276 struct wined3d_shader_loop_control
1278 unsigned int count;
1279 unsigned int start;
1280 int step;
1283 struct wined3d_shader_frontend
1285 void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1286 const struct wined3d_shader_signature *output_signature);
1287 void (*shader_free)(void *data);
1288 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1289 void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1290 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1293 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
1294 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
1296 HRESULT shader_extract_from_dxbc(struct wined3d_shader *shader,
1297 unsigned int max_shader_version, enum wined3d_shader_byte_code_format *format) DECLSPEC_HIDDEN;
1298 BOOL shader_get_stream_output_register_info(const struct wined3d_shader *shader,
1299 const struct wined3d_stream_output_element *so_element, unsigned int *register_idx,
1300 unsigned int *component_idx) DECLSPEC_HIDDEN;
1302 typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
1304 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1305 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1306 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1307 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1308 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1310 struct shader_caps
1312 unsigned int vs_version;
1313 unsigned int hs_version;
1314 unsigned int ds_version;
1315 unsigned int gs_version;
1316 unsigned int ps_version;
1317 unsigned int cs_version;
1319 unsigned int vs_uniform_count;
1320 unsigned int ps_uniform_count;
1321 float ps_1x_max_value;
1322 unsigned int varying_count;
1324 DWORD wined3d_caps;
1327 enum wined3d_gl_resource_type
1329 WINED3D_GL_RES_TYPE_TEX_1D = 0,
1330 WINED3D_GL_RES_TYPE_TEX_2D = 1,
1331 WINED3D_GL_RES_TYPE_TEX_3D = 2,
1332 WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
1333 WINED3D_GL_RES_TYPE_TEX_RECT = 4,
1334 WINED3D_GL_RES_TYPE_BUFFER = 5,
1335 WINED3D_GL_RES_TYPE_RB = 6,
1336 WINED3D_GL_RES_TYPE_COUNT = 7,
1339 enum wined3d_vertex_processing_mode
1341 WINED3D_VP_MODE_FF,
1342 WINED3D_VP_MODE_SHADER,
1343 WINED3D_VP_MODE_NONE,
1346 #define WINED3D_CONST_NUM_UNUSED ~0U
1348 enum wined3d_ffp_ps_fog_mode
1350 WINED3D_FFP_PS_FOG_OFF,
1351 WINED3D_FFP_PS_FOG_LINEAR,
1352 WINED3D_FFP_PS_FOG_EXP,
1353 WINED3D_FFP_PS_FOG_EXP2,
1356 /* Stateblock dependent parameters which have to be hardcoded
1357 * into the shader code
1360 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1361 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1362 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1363 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1364 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1366 /* Used for Shader Model 1 pixel shaders to track the bound texture
1367 * type. 2D and RECT textures are separated through NP2 fixup. */
1368 enum wined3d_shader_tex_types
1370 WINED3D_SHADER_TEX_2D = 0,
1371 WINED3D_SHADER_TEX_3D = 1,
1372 WINED3D_SHADER_TEX_CUBE = 2,
1373 WINED3D_SHADER_TEX_ERR = 3,
1376 struct ps_compile_args
1378 struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
1379 enum wined3d_vertex_processing_mode vp_mode;
1380 enum wined3d_ffp_ps_fog_mode fog;
1381 DWORD tex_types; /* ps 1 - 3, 16 textures */
1382 WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1383 WORD srgb_correction;
1384 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1385 D3D9 has a limit of 16 samplers and the fixup is superfluous
1386 in D3D10 (unconditional NP2 support mandatory). */
1387 WORD np2_fixup;
1388 WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1389 WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
1390 WORD padding_to_dword;
1391 DWORD pointsprite : 1;
1392 DWORD flatshading : 1;
1393 DWORD alpha_test_func : 3;
1394 DWORD render_offscreen : 1;
1395 DWORD rt_alpha_swizzle : 8; /* MAX_RENDER_TARGET_VIEWS, 8 */
1396 DWORD padding : 18;
1399 enum fog_src_type
1401 VS_FOG_Z = 0,
1402 VS_FOG_COORD = 1
1405 struct vs_compile_args
1407 BYTE fog_src;
1408 BYTE clip_enabled : 1;
1409 BYTE point_size : 1;
1410 BYTE per_vertex_point_size : 1;
1411 BYTE flatshading : 1;
1412 BYTE next_shader_type : 3;
1413 BYTE padding : 1;
1414 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1415 unsigned int next_shader_input_count;
1416 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1419 struct ds_compile_args
1421 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1422 enum wined3d_tessellator_partitioning tessellator_partitioning;
1423 unsigned int output_count : 16;
1424 unsigned int next_shader_type : 3;
1425 unsigned int render_offscreen : 1;
1426 unsigned int padding : 12;
1427 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1430 struct gs_compile_args
1432 unsigned int output_count;
1433 enum wined3d_primitive_type primitive_type;
1434 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1437 struct wined3d_shader_backend_ops
1439 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1440 void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1441 void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1442 const struct wined3d_state *state);
1443 void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1444 const struct wined3d_state *state);
1445 void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1446 void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1447 void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1448 void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1449 const struct wined3d_state *state);
1450 void (*shader_destroy)(struct wined3d_shader *shader);
1451 HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1452 const struct wined3d_fragment_pipe_ops *fragment_pipe);
1453 void (*shader_free_private)(struct wined3d_device *device, struct wined3d_context *context);
1454 BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1455 void (*shader_free_context_data)(struct wined3d_context *context);
1456 void (*shader_init_context_state)(struct wined3d_context *context);
1457 void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps);
1458 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1459 BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1462 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
1463 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
1464 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
1466 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1468 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1469 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1470 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1471 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1473 static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1475 wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1476 wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1477 wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1478 wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1481 extern const struct wined3d_vec4 wined3d_srgb_const[] DECLSPEC_HIDDEN;
1483 static inline float wined3d_srgb_from_linear(float colour)
1485 if (colour < 0.0f)
1486 return 0.0f;
1487 if (colour < wined3d_srgb_const[1].x)
1488 return colour * wined3d_srgb_const[0].w;
1489 if (colour < 1.0f)
1490 return wined3d_srgb_const[0].y * powf(colour, wined3d_srgb_const[0].x) - wined3d_srgb_const[0].z;
1491 return 1.0f;
1494 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
1495 const struct wined3d_color *colour)
1497 colour_srgb->r = wined3d_srgb_from_linear(colour->r);
1498 colour_srgb->g = wined3d_srgb_from_linear(colour->g);
1499 colour_srgb->b = wined3d_srgb_from_linear(colour->b);
1500 colour_srgb->a = colour->a;
1503 void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1504 const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1506 /* Checking of API calls */
1507 /* --------------------- */
1508 #ifndef WINE_NO_DEBUG_MSGS
1509 #define checkGLcall(A) \
1510 do { \
1511 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1512 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1513 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1514 } while(0)
1515 #else
1516 #define checkGLcall(A) do {} while(0)
1517 #endif
1519 struct wined3d_bo_vk
1521 VkBuffer vk_buffer;
1522 VkDeviceMemory vk_memory;
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_range
1904 unsigned int offset;
1905 unsigned int size;
1908 struct wined3d_rendertarget_info
1910 struct wined3d_gl_view gl_view;
1911 struct wined3d_resource *resource;
1912 unsigned int sub_resource_idx;
1913 unsigned int layer_count;
1916 struct wined3d_fb_state
1918 struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
1919 struct wined3d_rendertarget_view *depth_stencil;
1922 #define MAX_GL_FRAGMENT_SAMPLERS 32
1924 struct wined3d_context
1926 const struct wined3d_d3d_info *d3d_info;
1927 const struct wined3d_state_entry *state_table;
1928 uint32_t dirty_graphics_states[STATE_HIGHEST / (sizeof(uint32_t) * CHAR_BIT) + 1];
1929 uint32_t dirty_compute_states[STATE_COMPUTE_COUNT / (sizeof(uint32_t) * CHAR_BIT) + 1];
1931 struct wined3d_device *device;
1932 struct wined3d_swapchain *swapchain;
1933 struct
1935 struct wined3d_texture *texture;
1936 unsigned int sub_resource_idx;
1937 } current_rt;
1939 /* Stores some information about the context state for optimization */
1940 DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1941 DWORD update_shader_resource_bindings : 1;
1942 DWORD update_compute_shader_resource_bindings : 1;
1943 DWORD update_unordered_access_view_bindings : 1;
1944 DWORD update_compute_unordered_access_view_bindings : 1;
1945 DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
1946 DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */
1947 DWORD last_was_pshader : 1;
1948 DWORD last_was_vshader : 1;
1949 DWORD last_was_diffuse : 1;
1950 DWORD last_was_specular : 1;
1951 DWORD last_was_normal : 1;
1953 DWORD last_was_ffp_blit : 1;
1954 DWORD last_was_blit : 1;
1955 DWORD last_was_ckey : 1;
1956 DWORD namedArraysLoaded : 1;
1957 DWORD texShaderBumpMap : 8; /* WINED3D_MAX_TEXTURES, 8 */
1958 DWORD lastWasPow2Texture : 8; /* WINED3D_MAX_TEXTURES, 8 */
1959 DWORD fixed_function_usage_map : 8; /* WINED3D_MAX_TEXTURES, 8 */
1960 DWORD lowest_disabled_stage : 4; /* Max WINED3D_MAX_TEXTURES, 8 */
1962 DWORD use_immediate_mode_draw : 1;
1963 DWORD uses_uavs : 1;
1964 DWORD uses_fbo_attached_resources : 1;
1965 DWORD transform_feedback_active : 1;
1966 DWORD transform_feedback_paused : 1;
1967 DWORD fog_coord : 1;
1968 DWORD render_offscreen : 1;
1969 DWORD current : 1;
1970 DWORD destroyed : 1;
1971 DWORD destroy_delayed : 1;
1972 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1973 DWORD padding : 14;
1975 DWORD constant_update_mask;
1976 DWORD numbered_array_mask;
1977 enum fogsource fog_source;
1979 UINT instance_count;
1981 void *shader_backend_data;
1982 void *fragment_pipe_data;
1984 struct wined3d_stream_info stream_info;
1986 /* Fences for GL_APPLE_flush_buffer_range */
1987 struct wined3d_fence *buffer_fences[MAX_ATTRIBS];
1988 unsigned int buffer_fence_count;
1990 unsigned int viewport_count;
1991 unsigned int scissor_rect_count;
1994 void wined3d_context_cleanup(struct wined3d_context *context) DECLSPEC_HIDDEN;
1996 HRESULT wined3d_context_no3d_init(struct wined3d_context *context_no3d,
1997 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
1999 struct wined3d_context_gl
2001 struct wined3d_context c;
2003 const struct wined3d_gl_info *gl_info;
2005 DWORD tid; /* Thread ID which owns this context at the moment. */
2007 uint32_t dc_is_private : 1;
2008 uint32_t dc_has_format : 1; /* Only meaningful for private DCs. */
2009 uint32_t fog_enabled : 1;
2010 uint32_t diffuse_attrib_to_1 : 1;
2011 uint32_t rebind_fbo : 1;
2012 uint32_t untracked_material_count : 2; /* Max value 2 */
2013 uint32_t needs_set : 1;
2014 uint32_t valid : 1;
2015 uint32_t padding : 23;
2017 uint32_t default_attrib_value_set;
2019 GLenum tracking_parm; /* Which source is tracking current colour. */
2020 GLenum untracked_materials[2];
2021 SIZE blit_size;
2022 unsigned int active_texture;
2024 GLenum *texture_type;
2026 /* The WGL context. */
2027 unsigned int level;
2028 HGLRC restore_ctx;
2029 HDC restore_dc;
2030 int restore_pf;
2031 HWND restore_pf_win;
2032 HGLRC gl_ctx;
2033 HDC dc;
2034 int pixel_format;
2035 HWND window;
2036 GLint aux_buffers;
2038 /* FBOs. */
2039 unsigned int fbo_entry_count;
2040 struct list fbo_list;
2041 struct list fbo_destroy_list;
2042 struct fbo_entry *current_fbo;
2043 GLuint fbo_read_binding;
2044 GLuint fbo_draw_binding;
2045 struct wined3d_rendertarget_info blit_targets[MAX_RENDER_TARGET_VIEWS];
2046 uint32_t draw_buffers_mask; /* Enabled draw buffers, 31 max. */
2048 /* Queries. */
2049 struct list occlusion_queries;
2050 struct list fences;
2051 struct list timestamp_queries;
2052 struct list so_statistics_queries;
2053 struct list pipeline_statistics_queries;
2055 GLuint *free_occlusion_queries;
2056 SIZE_T free_occlusion_query_size;
2057 unsigned int free_occlusion_query_count;
2059 union wined3d_gl_fence_object *free_fences;
2060 SIZE_T free_fence_size;
2061 unsigned int free_fence_count;
2063 GLuint *free_timestamp_queries;
2064 SIZE_T free_timestamp_query_size;
2065 unsigned int free_timestamp_query_count;
2067 union wined3d_gl_so_statistics_query *free_so_statistics_queries;
2068 SIZE_T free_so_statistics_query_size;
2069 unsigned int free_so_statistics_query_count;
2071 union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
2072 SIZE_T free_pipeline_statistics_query_size;
2073 unsigned int free_pipeline_statistics_query_count;
2075 GLuint blit_vbo;
2077 unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
2078 unsigned int rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS];
2080 /* Extension emulation. */
2081 GLint gl_fog_source;
2082 GLfloat fog_coord_value;
2083 GLfloat colour[4], fog_start, fog_end, fog_colour[4];
2085 GLuint dummy_arbfp_prog;
2088 static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_context *context)
2090 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2093 static inline const struct wined3d_context_gl *wined3d_context_gl_const(const struct wined3d_context *context)
2095 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2098 struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
2099 struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2100 void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
2101 const struct wined3d_gl_info *gl_info, unsigned int unit) DECLSPEC_HIDDEN;
2102 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
2103 struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2104 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
2105 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2106 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
2107 struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2108 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
2109 struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2110 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
2111 struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2112 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
2113 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2114 BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, const struct wined3d_state *state,
2115 unsigned int rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2116 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl *context_gl, GLenum target,
2117 struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
2118 struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
2119 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
2120 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2121 void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
2122 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2123 void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
2124 GLenum target, GLuint name) DECLSPEC_HIDDEN;
2125 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
2126 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
2127 const struct wined3d_bo_address *dst, GLenum dst_binding,
2128 const struct wined3d_bo_address *src, GLenum src_binding, size_t size) DECLSPEC_HIDDEN;
2129 void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2130 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
2131 unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2132 enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2133 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl,
2134 struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
2135 const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2136 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t mask) DECLSPEC_HIDDEN;
2137 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2138 void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2139 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2140 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2141 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2142 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2143 struct wined3d_context_gl *wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN;
2144 GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2145 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
2146 const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2147 HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
2148 struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
2149 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
2150 const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2151 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
2152 const struct wined3d_bo_address *data, size_t size, GLenum binding, DWORD flags) DECLSPEC_HIDDEN;
2153 struct wined3d_context_gl *wined3d_context_gl_reacquire(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2154 void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2155 BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2156 void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN;
2157 void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
2158 const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
2159 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2160 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data,
2161 GLenum binding, unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN;
2162 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl,
2163 const struct wined3d_state *state) DECLSPEC_HIDDEN;
2165 struct wined3d_command_buffer_vk
2167 uint64_t id;
2168 VkCommandBuffer vk_command_buffer;
2169 VkFence vk_fence;
2172 struct wined3d_context_vk
2174 struct wined3d_context c;
2176 const struct wined3d_vk_info *vk_info;
2178 VkCommandPool vk_command_pool;
2179 struct wined3d_command_buffer_vk current_command_buffer;
2180 uint64_t completed_command_buffer_id;
2182 struct
2184 struct wined3d_command_buffer_vk *buffers;
2185 SIZE_T buffers_size;
2186 SIZE_T buffer_count;
2187 } submitted;
2190 static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
2192 return CONTAINING_RECORD(context, struct wined3d_context_vk, c);
2195 void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2196 BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
2197 VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2198 void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk,
2199 const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2200 VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2201 HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
2202 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2203 void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2204 void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id) DECLSPEC_HIDDEN;
2206 typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2208 struct wined3d_state_entry
2210 unsigned int representative;
2211 APPLYSTATEFUNC apply;
2214 struct wined3d_state_entry_template
2216 DWORD state;
2217 struct wined3d_state_entry content;
2218 unsigned int extension;
2221 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2222 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2223 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2225 struct fragment_caps
2227 DWORD wined3d_caps;
2228 DWORD PrimitiveMiscCaps;
2229 DWORD TextureOpCaps;
2230 DWORD MaxTextureBlendStages;
2231 DWORD MaxSimultaneousTextures;
2234 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2235 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2237 struct wined3d_fragment_pipe_ops
2239 void (*fp_enable)(const struct wined3d_context *context, BOOL enable);
2240 void (*get_caps)(const struct wined3d_adapter *adapter, struct fragment_caps *caps);
2241 DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2242 void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2243 void (*free_private)(struct wined3d_device *device, struct wined3d_context *context);
2244 BOOL (*allocate_context_data)(struct wined3d_context *context);
2245 void (*free_context_data)(struct wined3d_context *context);
2246 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2247 const struct wined3d_state_entry_template *states;
2250 struct wined3d_vertex_caps
2252 BOOL xyzrhw;
2253 BOOL emulated_flatshading;
2254 BOOL ffp_generic_attributes;
2255 DWORD max_active_lights;
2256 DWORD max_vertex_blend_matrices;
2257 DWORD max_vertex_blend_matrix_index;
2258 DWORD vertex_processing_caps;
2259 DWORD fvf_caps;
2260 DWORD max_user_clip_planes;
2261 DWORD raster_caps;
2264 struct wined3d_vertex_pipe_ops
2266 void (*vp_enable)(const struct wined3d_context *context, BOOL enable);
2267 void (*vp_get_caps)(const struct wined3d_adapter *adapter, struct wined3d_vertex_caps *caps);
2268 DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2269 void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2270 void (*vp_free)(struct wined3d_device *device, struct wined3d_context *context);
2271 const struct wined3d_state_entry_template *vp_states;
2274 extern const struct wined3d_state_entry_template misc_state_template[] DECLSPEC_HIDDEN;
2275 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN;
2276 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN;
2277 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN;
2278 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN;
2279 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN;
2280 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN;
2281 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN;
2283 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN;
2284 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN;
2285 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN;
2287 /* "Base" state table */
2288 HRESULT compile_state_table(struct wined3d_state_entry *state_table, APPLYSTATEFUNC **dev_multistate_funcs,
2289 const struct wined3d_d3d_info *d3d_info, const BOOL *supported_extensions,
2290 const struct wined3d_vertex_pipe_ops *vertex, const struct wined3d_fragment_pipe_ops *fragment,
2291 const struct wined3d_state_entry_template *misc) DECLSPEC_HIDDEN;
2293 enum wined3d_blit_op
2295 WINED3D_BLIT_OP_COLOR_BLIT,
2296 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST,
2297 WINED3D_BLIT_OP_COLOR_BLIT_CKEY,
2298 WINED3D_BLIT_OP_DEPTH_BLIT,
2299 WINED3D_BLIT_OP_RAW_BLIT,
2302 struct wined3d_blitter
2304 const struct wined3d_blitter_ops *ops;
2305 struct wined3d_blitter *next;
2308 struct wined3d_blitter_ops
2310 void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2311 void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2312 unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2313 const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2314 DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2315 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
2316 const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
2317 DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
2318 enum wined3d_texture_filter_type filter);
2321 void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
2322 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2323 struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
2324 void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
2325 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2326 void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
2327 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2328 struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next,
2329 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2330 void wined3d_raw_blitter_create(struct wined3d_blitter **next,
2331 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2333 BOOL fbo_blitter_supported(enum wined3d_blit_op blit_op, const struct wined3d_gl_info *gl_info,
2334 const struct wined3d_resource *src_resource, DWORD src_location,
2335 const struct wined3d_resource *dst_resource, DWORD dst_location) DECLSPEC_HIDDEN;
2337 BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
2339 HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2340 DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
2341 void context_gl_resource_released(struct wined3d_device *device,
2342 GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2343 void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2344 void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2345 void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
2346 void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
2347 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2348 void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
2349 void context_state_drawbuf(struct wined3d_context *context,
2350 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2351 void context_state_fb(struct wined3d_context *context,
2352 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2354 /*****************************************************************************
2355 * Internal representation of a light
2357 struct wined3d_light_info
2359 struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2360 DWORD OriginalIndex;
2361 LONG glIndex;
2362 BOOL enabled;
2364 /* Converted parms to speed up swapping lights */
2365 struct wined3d_vec4 position;
2366 struct wined3d_vec4 direction;
2367 float exponent;
2368 float cutoff;
2370 struct list entry;
2373 /* The default light parameters */
2374 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
2376 struct wined3d_pixel_format
2378 int iPixelFormat; /* WGL pixel format */
2379 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2380 int redSize, greenSize, blueSize, alphaSize, colorSize;
2381 int depthSize, stencilSize;
2382 BOOL windowDrawable;
2383 BOOL doubleBuffer;
2384 int auxBuffers;
2385 int numSamples;
2388 enum wined3d_pci_vendor
2390 HW_VENDOR_SOFTWARE = 0x0000,
2391 HW_VENDOR_AMD = 0x1002,
2392 HW_VENDOR_NVIDIA = 0x10de,
2393 HW_VENDOR_VMWARE = 0x15ad,
2394 HW_VENDOR_REDHAT = 0x1af4,
2395 HW_VENDOR_INTEL = 0x8086,
2398 enum wined3d_pci_device
2400 CARD_WINE = 0x0000,
2402 CARD_AMD_RAGE_128PRO = 0x5246,
2403 CARD_AMD_RADEON_7200 = 0x5144,
2404 CARD_AMD_RADEON_8500 = 0x514c,
2405 CARD_AMD_RADEON_9500 = 0x4144,
2406 CARD_AMD_RADEON_XPRESS_200M = 0x5955,
2407 CARD_AMD_RADEON_X700 = 0x5e4c,
2408 CARD_AMD_RADEON_X1600 = 0x71c2,
2409 CARD_AMD_RADEON_HD2350 = 0x94c7,
2410 CARD_AMD_RADEON_HD2600 = 0x9581,
2411 CARD_AMD_RADEON_HD2900 = 0x9400,
2412 CARD_AMD_RADEON_HD3200 = 0x9620,
2413 CARD_AMD_RADEON_HD3850 = 0x9515,
2414 CARD_AMD_RADEON_HD4200M = 0x9712,
2415 CARD_AMD_RADEON_HD4350 = 0x954f,
2416 CARD_AMD_RADEON_HD4600 = 0x9495,
2417 CARD_AMD_RADEON_HD4700 = 0x944e,
2418 CARD_AMD_RADEON_HD4800 = 0x944c,
2419 CARD_AMD_RADEON_HD5400 = 0x68f9,
2420 CARD_AMD_RADEON_HD5600 = 0x68d8,
2421 CARD_AMD_RADEON_HD5700 = 0x68be,
2422 CARD_AMD_RADEON_HD5800 = 0x6898,
2423 CARD_AMD_RADEON_HD5900 = 0x689c,
2424 CARD_AMD_RADEON_HD6300 = 0x9803,
2425 CARD_AMD_RADEON_HD6400 = 0x6770,
2426 CARD_AMD_RADEON_HD6490M = 0x6760,
2427 CARD_AMD_RADEON_HD6410D = 0x9644,
2428 CARD_AMD_RADEON_HD6480G = 0x9648,
2429 CARD_AMD_RADEON_HD6550D = 0x9640,
2430 CARD_AMD_RADEON_HD6600 = 0x6758,
2431 CARD_AMD_RADEON_HD6600M = 0x6741,
2432 CARD_AMD_RADEON_HD6700 = 0x68ba,
2433 CARD_AMD_RADEON_HD6800 = 0x6739,
2434 CARD_AMD_RADEON_HD6900 = 0x6719,
2435 CARD_AMD_RADEON_HD7660D = 0x9901,
2436 CARD_AMD_RADEON_HD7700 = 0x683d,
2437 CARD_AMD_RADEON_HD7800 = 0x6819,
2438 CARD_AMD_RADEON_HD7870 = 0x6818,
2439 CARD_AMD_RADEON_HD7900 = 0x679a,
2440 CARD_AMD_RADEON_HD8600M = 0x6660,
2441 CARD_AMD_RADEON_HD8670 = 0x6610,
2442 CARD_AMD_RADEON_HD8770 = 0x665c,
2443 CARD_AMD_RADEON_R3 = 0x9830,
2444 CARD_AMD_RADEON_R7 = 0x130f,
2445 CARD_AMD_RADEON_R9_285 = 0x6939,
2446 CARD_AMD_RADEON_R9_290 = 0x67b1,
2447 CARD_AMD_RADEON_R9_290X = 0x67b0,
2448 CARD_AMD_RADEON_R9_FURY = 0x7300,
2449 CARD_AMD_RADEON_R9_M370X = 0x6821,
2450 CARD_AMD_RADEON_R9_M380 = 0x6647,
2451 CARD_AMD_RADEON_R9_M395X = 0x6920,
2452 CARD_AMD_RADEON_RX_460 = 0x67ef,
2453 CARD_AMD_RADEON_RX_480 = 0x67df,
2454 CARD_AMD_RADEON_RX_VEGA_10 = 0x687f,
2455 CARD_AMD_RADEON_RX_VEGA_12 = 0x69af,
2456 CARD_AMD_RADEON_RX_VEGA_20 = 0x66af,
2457 CARD_AMD_RADEON_RX_NAVI_10 = 0x731f,
2459 CARD_NVIDIA_RIVA_128 = 0x0018,
2460 CARD_NVIDIA_RIVA_TNT = 0x0020,
2461 CARD_NVIDIA_RIVA_TNT2 = 0x0028,
2462 CARD_NVIDIA_GEFORCE = 0x0100,
2463 CARD_NVIDIA_GEFORCE2_MX = 0x0110,
2464 CARD_NVIDIA_GEFORCE2 = 0x0150,
2465 CARD_NVIDIA_GEFORCE3 = 0x0200,
2466 CARD_NVIDIA_GEFORCE4_MX = 0x0170,
2467 CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
2468 CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
2469 CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
2470 CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
2471 CARD_NVIDIA_GEFORCE_6200 = 0x014f,
2472 CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
2473 CARD_NVIDIA_GEFORCE_6800 = 0x0041,
2474 CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2475 CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
2476 CARD_NVIDIA_GEFORCE_7600 = 0x0391,
2477 CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
2478 CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2479 CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
2480 CARD_NVIDIA_GEFORCE_8400GS = 0x0404,
2481 CARD_NVIDIA_GEFORCE_8500GT = 0x0421,
2482 CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
2483 CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
2484 CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
2485 CARD_NVIDIA_GEFORCE_8800GTX = 0x0191,
2486 CARD_NVIDIA_GEFORCE_9200 = 0x086d,
2487 CARD_NVIDIA_GEFORCE_9300 = 0x086c,
2488 CARD_NVIDIA_GEFORCE_9400M = 0x0863,
2489 CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
2490 CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
2491 CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
2492 CARD_NVIDIA_GEFORCE_9700MGT = 0x064a,
2493 CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
2494 CARD_NVIDIA_GEFORCE_210 = 0x0a23,
2495 CARD_NVIDIA_GEFORCE_GT220 = 0x0a20,
2496 CARD_NVIDIA_GEFORCE_GT240 = 0x0ca3,
2497 CARD_NVIDIA_GEFORCE_GTS250 = 0x0615,
2498 CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
2499 CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
2500 CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
2501 CARD_NVIDIA_GEFORCE_315M = 0x0a7a,
2502 CARD_NVIDIA_GEFORCE_320M = 0x08a3,
2503 CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
2504 CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
2505 CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
2506 CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
2507 CARD_NVIDIA_GEFORCE_410M = 0x1055,
2508 CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
2509 CARD_NVIDIA_GEFORCE_GT425M = 0x0df0,
2510 CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
2511 CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
2512 CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
2513 CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
2514 CARD_NVIDIA_GEFORCE_GTX460M = 0x0dd1,
2515 CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
2516 CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
2517 CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
2518 CARD_NVIDIA_GEFORCE_GT520 = 0x1040,
2519 CARD_NVIDIA_GEFORCE_GT525M = 0x0dec,
2520 CARD_NVIDIA_GEFORCE_GT540M = 0x0df4,
2521 CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
2522 CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
2523 CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
2524 CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
2525 CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
2526 CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
2527 CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
2528 CARD_NVIDIA_GEFORCE_GT610 = 0x104a,
2529 CARD_NVIDIA_GEFORCE_GT630 = 0x0f00,
2530 CARD_NVIDIA_GEFORCE_GT630M = 0x0de9,
2531 CARD_NVIDIA_GEFORCE_GT640 = 0x0fc1,
2532 CARD_NVIDIA_GEFORCE_GT640M = 0x0fd2,
2533 CARD_NVIDIA_GEFORCE_GT650M = 0x0fd1,
2534 CARD_NVIDIA_GEFORCE_GTX650 = 0x0fc6,
2535 CARD_NVIDIA_GEFORCE_GTX650TI = 0x11c6,
2536 CARD_NVIDIA_GEFORCE_GTX660 = 0x11c0,
2537 CARD_NVIDIA_GEFORCE_GTX660M = 0x0fd4,
2538 CARD_NVIDIA_GEFORCE_GTX660TI = 0x1183,
2539 CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
2540 CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
2541 CARD_NVIDIA_GEFORCE_GTX675MX_1 = 0x11a7,
2542 CARD_NVIDIA_GEFORCE_GTX675MX_2 = 0x11a2,
2543 CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
2544 CARD_NVIDIA_GEFORCE_GTX690 = 0x1188,
2545 CARD_NVIDIA_GEFORCE_GT720 = 0x128b,
2546 CARD_NVIDIA_GEFORCE_GT730 = 0x1287,
2547 CARD_NVIDIA_GEFORCE_GT730M = 0x0fe1,
2548 CARD_NVIDIA_GEFORCE_GT740M = 0x1292,
2549 CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
2550 CARD_NVIDIA_GEFORCE_GT755M = 0x0fcd,
2551 CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
2552 CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
2553 CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
2554 CARD_NVIDIA_GEFORCE_GTX760TI = 0x1193,
2555 CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2,
2556 CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0,
2557 CARD_NVIDIA_GEFORCE_GTX770 = 0x1184,
2558 CARD_NVIDIA_GEFORCE_GTX775M = 0x119d,
2559 CARD_NVIDIA_GEFORCE_GTX780 = 0x1004,
2560 CARD_NVIDIA_GEFORCE_GTX780M = 0x119e,
2561 CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a,
2562 CARD_NVIDIA_GEFORCE_GTXTITAN = 0x1005,
2563 CARD_NVIDIA_GEFORCE_GTXTITANB = 0x100c,
2564 CARD_NVIDIA_GEFORCE_GTXTITANX = 0x17c2,
2565 CARD_NVIDIA_GEFORCE_GTXTITANZ = 0x1001,
2566 CARD_NVIDIA_GEFORCE_820M = 0x0fed,
2567 CARD_NVIDIA_GEFORCE_830M = 0x1340,
2568 CARD_NVIDIA_GEFORCE_840M = 0x1341,
2569 CARD_NVIDIA_GEFORCE_845M = 0x1344,
2570 CARD_NVIDIA_GEFORCE_GTX850M = 0x1391,
2571 CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
2572 CARD_NVIDIA_GEFORCE_GTX870M = 0x1199,
2573 CARD_NVIDIA_GEFORCE_GTX880M = 0x1198,
2574 CARD_NVIDIA_GEFORCE_940M = 0x1347,
2575 CARD_NVIDIA_GEFORCE_GTX950 = 0x1402,
2576 CARD_NVIDIA_GEFORCE_GTX950M = 0x139a,
2577 CARD_NVIDIA_GEFORCE_GTX960 = 0x1401,
2578 CARD_NVIDIA_GEFORCE_GTX960M = 0x139b,
2579 CARD_NVIDIA_GEFORCE_GTX970 = 0x13c2,
2580 CARD_NVIDIA_GEFORCE_GTX970M = 0x13d8,
2581 CARD_NVIDIA_GEFORCE_GTX980 = 0x13c0,
2582 CARD_NVIDIA_GEFORCE_GTX980TI = 0x17c8,
2583 CARD_NVIDIA_GEFORCE_GTX1050 = 0x1c81,
2584 CARD_NVIDIA_GEFORCE_GTX1050TI = 0x1c82,
2585 CARD_NVIDIA_GEFORCE_GTX1060_3GB = 0x1c02,
2586 CARD_NVIDIA_GEFORCE_GTX1060 = 0x1c03,
2587 CARD_NVIDIA_GEFORCE_GTX1070 = 0x1b81,
2588 CARD_NVIDIA_GEFORCE_GTX1080 = 0x1b80,
2589 CARD_NVIDIA_GEFORCE_GTX1080TI = 0x1b06,
2590 CARD_NVIDIA_TITANX_PASCAL = 0x1b00,
2591 CARD_NVIDIA_TITANV = 0x1d81,
2592 CARD_NVIDIA_GEFORCE_GTX1650SUPER= 0x2187,
2593 CARD_NVIDIA_GEFORCE_GTX1660TI = 0x2182,
2594 CARD_NVIDIA_GEFORCE_RTX2060 = 0x1f08,
2595 CARD_NVIDIA_GEFORCE_RTX2070 = 0x1f07,
2596 CARD_NVIDIA_GEFORCE_RTX2080 = 0x1e87,
2597 CARD_NVIDIA_GEFORCE_RTX2080TI = 0x1e07,
2599 CARD_REDHAT_VIRGL = 0x1010,
2601 CARD_VMWARE_SVGA3D = 0x0405,
2603 CARD_INTEL_830M = 0x3577,
2604 CARD_INTEL_855GM = 0x3582,
2605 CARD_INTEL_845G = 0x2562,
2606 CARD_INTEL_865G = 0x2572,
2607 CARD_INTEL_915G = 0x2582,
2608 CARD_INTEL_E7221G = 0x258a,
2609 CARD_INTEL_915GM = 0x2592,
2610 CARD_INTEL_945G = 0x2772,
2611 CARD_INTEL_945GM = 0x27a2,
2612 CARD_INTEL_945GME = 0x27ae,
2613 CARD_INTEL_Q35 = 0x29b2,
2614 CARD_INTEL_G33 = 0x29c2,
2615 CARD_INTEL_Q33 = 0x29d2,
2616 CARD_INTEL_PNVG = 0xa001,
2617 CARD_INTEL_PNVM = 0xa011,
2618 CARD_INTEL_965Q = 0x2992,
2619 CARD_INTEL_965G = 0x2982,
2620 CARD_INTEL_946GZ = 0x2972,
2621 CARD_INTEL_965GM = 0x2a02,
2622 CARD_INTEL_965GME = 0x2a12,
2623 CARD_INTEL_GM45 = 0x2a42,
2624 CARD_INTEL_IGD = 0x2e02,
2625 CARD_INTEL_Q45 = 0x2e12,
2626 CARD_INTEL_G45 = 0x2e22,
2627 CARD_INTEL_G41 = 0x2e32,
2628 CARD_INTEL_B43 = 0x2e92,
2629 CARD_INTEL_ILKD = 0x0042,
2630 CARD_INTEL_ILKM = 0x0046,
2631 CARD_INTEL_SNBD = 0x0122,
2632 CARD_INTEL_SNBM = 0x0126,
2633 CARD_INTEL_SNBS = 0x010a,
2634 CARD_INTEL_IVBD = 0x0162,
2635 CARD_INTEL_IVBM = 0x0166,
2636 CARD_INTEL_IVBS = 0x015a,
2637 CARD_INTEL_HWD = 0x0412,
2638 CARD_INTEL_HWM = 0x0416,
2639 CARD_INTEL_HD5000_1 = 0x0a26,
2640 CARD_INTEL_HD5000_2 = 0x0422,
2641 CARD_INTEL_I5100_1 = 0x0a22,
2642 CARD_INTEL_I5100_2 = 0x0a2a,
2643 CARD_INTEL_I5100_3 = 0x0a2b,
2644 CARD_INTEL_I5100_4 = 0x0a2e,
2645 CARD_INTEL_IP5200_1 = 0x0d22,
2646 CARD_INTEL_IP5200_2 = 0x0d26,
2647 CARD_INTEL_IP5200_3 = 0x0d2a,
2648 CARD_INTEL_IP5200_4 = 0x0d2b,
2649 CARD_INTEL_IP5200_5 = 0x0d2e,
2650 CARD_INTEL_IP5200_6 = 0x0c22,
2651 CARD_INTEL_HD5300 = 0x161e,
2652 CARD_INTEL_HD5500 = 0x1616,
2653 CARD_INTEL_HD5600 = 0x1612,
2654 CARD_INTEL_HD6000 = 0x1626,
2655 CARD_INTEL_I6100 = 0x162b,
2656 CARD_INTEL_IP6200 = 0x1622,
2657 CARD_INTEL_IPP6300 = 0x162a,
2658 CARD_INTEL_HD510_1 = 0x1902,
2659 CARD_INTEL_HD510_2 = 0x1906,
2660 CARD_INTEL_HD510_3 = 0x190b,
2661 CARD_INTEL_HD515 = 0x191e,
2662 CARD_INTEL_HD520_1 = 0x1916,
2663 CARD_INTEL_HD520_2 = 0x1921,
2664 CARD_INTEL_HD530_1 = 0x1912,
2665 CARD_INTEL_HD530_2 = 0x191b,
2666 CARD_INTEL_HDP530 = 0x191d,
2667 CARD_INTEL_I540 = 0x1926,
2668 CARD_INTEL_I550 = 0x1927,
2669 CARD_INTEL_I555 = 0x192b,
2670 CARD_INTEL_IP555 = 0x192d,
2671 CARD_INTEL_IP580_1 = 0x1932,
2672 CARD_INTEL_IP580_2 = 0x193b,
2673 CARD_INTEL_IPP580_1 = 0x193a,
2674 CARD_INTEL_IPP580_2 = 0x193d,
2675 CARD_INTEL_UHD617 = 0x87c0,
2676 CARD_INTEL_UHD620 = 0x3ea0,
2677 CARD_INTEL_HD615 = 0x591e,
2678 CARD_INTEL_HD620 = 0x5916,
2679 CARD_INTEL_HD630_1 = 0x5912,
2680 CARD_INTEL_HD630_2 = 0x591b,
2683 struct wined3d_fbo_ops
2685 GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
2686 void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
2687 void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
2688 void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
2689 void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
2690 GLsizei width, GLsizei height);
2691 void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
2692 GLenum internalformat, GLsizei width, GLsizei height);
2693 void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
2694 GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
2695 void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
2696 void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
2697 void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
2698 GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
2699 void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
2700 GLuint texture, GLint level);
2701 void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
2702 GLenum textarget, GLuint texture, GLint level);
2703 void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
2704 GLenum textarget, GLuint texture, GLint level);
2705 void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
2706 GLenum textarget, GLuint texture, GLint level, GLint layer);
2707 void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
2708 GLuint texture, GLint level, GLint layer);
2709 void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
2710 GLenum renderbuffertarget, GLuint renderbuffer);
2711 void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
2712 GLenum pname, GLint *params);
2713 void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2714 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2715 void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
2718 struct wined3d_gl_limits
2720 UINT buffers;
2721 UINT lights;
2722 UINT textures;
2723 UINT texture_coords;
2724 unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
2725 unsigned int samplers[WINED3D_SHADER_TYPE_COUNT];
2726 unsigned int graphics_samplers;
2727 unsigned int combined_samplers;
2728 UINT general_combiners;
2729 UINT user_clip_distances;
2730 unsigned int texture_size;
2731 UINT texture3d_size;
2732 UINT anisotropy;
2733 float shininess;
2734 UINT samples;
2735 UINT vertex_attribs;
2737 unsigned int texture_buffer_offset_alignment;
2739 unsigned int framebuffer_width;
2740 unsigned int framebuffer_height;
2742 UINT glsl_varyings;
2743 UINT glsl_vs_float_constants;
2744 UINT glsl_ps_float_constants;
2746 UINT arb_vs_float_constants;
2747 UINT arb_vs_native_constants;
2748 UINT arb_vs_instructions;
2749 UINT arb_vs_temps;
2750 UINT arb_ps_float_constants;
2751 UINT arb_ps_local_constants;
2752 UINT arb_ps_native_constants;
2753 UINT arb_ps_instructions;
2754 UINT arb_ps_temps;
2757 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
2758 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2759 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits,
2760 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2762 struct wined3d_gl_info
2764 DWORD selected_gl_version;
2765 DWORD glsl_version;
2766 struct wined3d_gl_limits limits;
2767 DWORD reserved_glsl_constants, reserved_arb_constants;
2768 DWORD quirks;
2769 BOOL supported[WINED3D_GL_EXT_COUNT];
2770 GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
2772 HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
2773 struct opengl_funcs gl_ops;
2774 struct wined3d_fbo_ops fbo_ops;
2776 void (WINE_GLAPI *p_glDisableWINE)(GLenum cap);
2777 void (WINE_GLAPI *p_glEnableWINE)(GLenum cap);
2780 /* The driver names reflect the lowest GPU supported
2781 * by a certain driver, so DRIVER_AMD_R300 supports
2782 * R3xx, R4xx and R5xx GPUs. */
2783 enum wined3d_display_driver
2785 DRIVER_AMD_RAGE_128PRO,
2786 DRIVER_AMD_R100,
2787 DRIVER_AMD_R300,
2788 DRIVER_AMD_R600,
2789 DRIVER_AMD_RX,
2790 DRIVER_INTEL_GMA800,
2791 DRIVER_INTEL_GMA900,
2792 DRIVER_INTEL_GMA950,
2793 DRIVER_INTEL_GMA3000,
2794 DRIVER_INTEL_HD4000,
2795 DRIVER_NVIDIA_TNT,
2796 DRIVER_NVIDIA_GEFORCE2MX,
2797 DRIVER_NVIDIA_GEFORCEFX,
2798 DRIVER_NVIDIA_GEFORCE6,
2799 DRIVER_NVIDIA_GEFORCE8,
2800 DRIVER_REDHAT_VIRGL,
2801 DRIVER_VMWARE,
2802 DRIVER_WINE,
2803 DRIVER_UNKNOWN,
2806 struct wined3d_gpu_description
2808 enum wined3d_pci_vendor vendor;
2809 enum wined3d_pci_device device;
2810 const char *description;
2811 enum wined3d_display_driver driver;
2812 unsigned int vidmem;
2815 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
2816 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
2817 const struct wined3d_gpu_description *wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor,
2818 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
2819 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
2820 enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
2822 /* 512 in Direct3D 8/9, 128 in DXGI. */
2823 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
2825 struct wined3d_driver_info
2827 enum wined3d_pci_vendor vendor;
2828 enum wined3d_pci_device device;
2829 const char *name;
2830 char description[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH];
2831 UINT64 vram_bytes;
2832 UINT64 sysmem_bytes;
2833 DWORD version_high;
2834 DWORD version_low;
2837 void wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
2838 const struct wined3d_gpu_description *gpu_description,
2839 UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
2841 struct wined3d_adapter_ops
2843 void (*adapter_destroy)(struct wined3d_adapter *adapter);
2844 HRESULT (*adapter_create_device)(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
2845 enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
2846 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
2847 struct wined3d_device_parent *device_parent, struct wined3d_device **device);
2848 void (*adapter_destroy_device)(struct wined3d_device *device);
2849 struct wined3d_context *(*adapter_acquire_context)(struct wined3d_device *device,
2850 struct wined3d_texture *texture, unsigned int sub_resource_idx);
2851 void (*adapter_release_context)(struct wined3d_context *context);
2852 void (*adapter_get_wined3d_caps)(const struct wined3d_adapter *adapter, struct wined3d_caps *caps);
2853 BOOL (*adapter_check_format)(const struct wined3d_adapter *adapter,
2854 const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
2855 const struct wined3d_format *ds_format);
2856 HRESULT (*adapter_init_3d)(struct wined3d_device *device);
2857 void (*adapter_uninit_3d)(struct wined3d_device *device);
2858 void *(*adapter_map_bo_address)(struct wined3d_context *context,
2859 const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags);
2860 void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data,
2861 uint32_t bind_flags, unsigned int range_count, const struct wined3d_range *ranges);
2862 void (*adapter_copy_bo_address)(struct wined3d_context *context,
2863 const struct wined3d_bo_address *dst, uint32_t dst_bind_flags,
2864 const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size);
2865 HRESULT (*adapter_create_swapchain)(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
2866 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
2867 void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain);
2868 HRESULT (*adapter_create_buffer)(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
2869 const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
2870 struct wined3d_buffer **buffer);
2871 void (*adapter_destroy_buffer)(struct wined3d_buffer *buffer);
2872 HRESULT (*adapter_create_texture)(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
2873 unsigned int layer_count, unsigned int level_count, uint32_t flags, void *parent,
2874 const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
2875 void (*adapter_destroy_texture)(struct wined3d_texture *texture);
2876 HRESULT (*adapter_create_rendertarget_view)(const struct wined3d_view_desc *desc,
2877 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2878 struct wined3d_rendertarget_view **view);
2879 void (*adapter_destroy_rendertarget_view)(struct wined3d_rendertarget_view *view);
2880 HRESULT (*adapter_create_shader_resource_view)(const struct wined3d_view_desc *desc,
2881 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2882 struct wined3d_shader_resource_view **view);
2883 void (*adapter_destroy_shader_resource_view)(struct wined3d_shader_resource_view *view);
2884 HRESULT (*adapter_create_unordered_access_view)(const struct wined3d_view_desc *desc,
2885 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
2886 struct wined3d_unordered_access_view **view);
2887 void (*adapter_destroy_unordered_access_view)(struct wined3d_unordered_access_view *view);
2888 HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
2889 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
2890 void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
2891 HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
2892 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
2893 void (*adapter_destroy_query)(struct wined3d_query *query);
2894 void (*adapter_flush_context)(struct wined3d_context *context);
2895 void (*adapter_clear_uav)(struct wined3d_context *context,
2896 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value);
2899 struct wined3d_output
2901 WCHAR device_name[CCHDEVICENAME];
2902 struct wined3d_adapter *adapter;
2904 D3DKMT_HANDLE kmt_adapter;
2905 D3DKMT_HANDLE kmt_device;
2906 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id;
2909 /* The adapter structure */
2910 struct wined3d_adapter
2912 unsigned int ordinal;
2913 POINT monitor_position;
2914 enum wined3d_format_id screen_format;
2916 struct wined3d_gl_info gl_info;
2917 struct wined3d_d3d_info d3d_info;
2918 struct wined3d_driver_info driver_info;
2919 struct wined3d_output *outputs;
2920 unsigned int output_count;
2921 UINT64 vram_bytes_used;
2922 GUID driver_uuid;
2923 GUID device_uuid;
2924 LUID luid;
2926 WCHAR device_name[CCHDEVICENAME]; /* for use with e.g. ChangeDisplaySettings() */
2928 void *formats;
2929 size_t format_size;
2931 const struct wined3d_vertex_pipe_ops *vertex_pipe;
2932 const struct wined3d_fragment_pipe_ops *fragment_pipe;
2933 const struct wined3d_shader_backend_ops *shader_backend;
2934 const struct wined3d_adapter_ops *adapter_ops;
2937 BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal,
2938 const struct wined3d_adapter_ops *adapter_ops) DECLSPEC_HIDDEN;
2939 void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
2941 struct wined3d_adapter_gl
2943 struct wined3d_adapter a;
2945 struct wined3d_pixel_format *pixel_formats;
2946 unsigned int pixel_format_count;
2949 static inline struct wined3d_adapter_gl *wined3d_adapter_gl(struct wined3d_adapter *adapter)
2951 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
2954 static inline const struct wined3d_adapter_gl *wined3d_adapter_gl_const(const struct wined3d_adapter *adapter)
2956 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
2959 struct wined3d_adapter *wined3d_adapter_gl_create(unsigned int ordinal,
2960 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
2962 struct wined3d_adapter_vk
2964 struct wined3d_adapter a;
2966 struct wined3d_vk_info vk_info;
2967 VkPhysicalDevice physical_device;
2969 VkPhysicalDeviceLimits device_limits;
2970 VkPhysicalDeviceMemoryProperties memory_properties;
2973 static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter)
2975 return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a);
2978 struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
2979 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
2980 unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
2981 uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
2983 struct wined3d_caps_gl_ctx
2985 HDC dc;
2986 HWND wnd;
2987 HGLRC gl_ctx;
2988 HDC restore_dc;
2989 HGLRC restore_gl_ctx;
2991 const struct wined3d_gl_info *gl_info;
2992 GLuint test_vbo;
2993 GLuint test_program_id;
2996 BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
2997 struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
2998 BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
2999 BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk,
3000 const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN;
3001 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
3003 BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3005 void install_gl_compat_wrapper(struct wined3d_gl_info *gl_info, enum wined3d_gl_extension ext) DECLSPEC_HIDDEN;
3007 enum wined3d_projection_type
3009 WINED3D_PROJECTION_NONE = 0,
3010 WINED3D_PROJECTION_COUNT3 = 1,
3011 WINED3D_PROJECTION_COUNT4 = 2
3014 /*****************************************************************************
3015 * Fixed function pipeline replacements
3017 #define ARG_UNUSED 0xff
3018 struct texture_stage_op
3020 unsigned cop : 8;
3021 unsigned carg1 : 8;
3022 unsigned carg2 : 8;
3023 unsigned carg0 : 8;
3025 unsigned aop : 8;
3026 unsigned aarg1 : 8;
3027 unsigned aarg2 : 8;
3028 unsigned aarg0 : 8;
3030 struct color_fixup_desc color_fixup;
3031 unsigned tex_type : 3;
3032 unsigned tmp_dst : 1;
3033 unsigned projected : 2;
3034 unsigned padding : 10;
3037 struct ffp_frag_settings
3039 struct texture_stage_op op[WINED3D_MAX_TEXTURES];
3040 enum wined3d_ffp_ps_fog_mode fog;
3041 unsigned char sRGB_write;
3042 unsigned char emul_clipplanes;
3043 unsigned char texcoords_initialized;
3044 unsigned char color_key_enabled : 1;
3045 unsigned char pointsprite : 1;
3046 unsigned char flatshading : 1;
3047 unsigned char alpha_test_func : 3;
3048 unsigned char padding : 2;
3051 struct ffp_frag_desc
3053 struct wine_rb_entry entry;
3054 struct ffp_frag_settings settings;
3057 int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3058 int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3060 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
3062 void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
3063 struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
3064 const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
3065 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
3066 void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
3067 void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
3069 enum wined3d_ffp_vs_fog_mode
3071 WINED3D_FFP_VS_FOG_OFF = 0,
3072 WINED3D_FFP_VS_FOG_FOGCOORD = 1,
3073 WINED3D_FFP_VS_FOG_DEPTH = 2,
3074 WINED3D_FFP_VS_FOG_RANGE = 3,
3077 #define WINED3D_FFP_TCI_SHIFT 16
3078 #define WINED3D_FFP_TCI_MASK 0xffu
3080 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3081 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3083 struct wined3d_ffp_vs_settings
3085 DWORD point_light_count : 4;
3086 DWORD spot_light_count : 4;
3087 DWORD directional_light_count : 4;
3088 DWORD parallel_point_light_count : 4;
3089 DWORD diffuse_source : 2;
3090 DWORD emissive_source : 2;
3091 DWORD ambient_source : 2;
3092 DWORD specular_source : 2;
3093 DWORD transformed : 1;
3094 DWORD vertexblends : 2;
3095 DWORD clipping : 1;
3096 DWORD normal : 1;
3097 DWORD normalize : 1;
3098 DWORD lighting : 1;
3099 DWORD localviewer : 1;
3101 DWORD point_size : 1;
3102 DWORD per_vertex_point_size : 1;
3103 DWORD fog_mode : 2;
3104 DWORD texcoords : 8; /* WINED3D_MAX_TEXTURES */
3105 DWORD ortho_fog : 1;
3106 DWORD flatshading : 1;
3107 DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
3108 DWORD padding : 2;
3110 DWORD texgen[WINED3D_MAX_TEXTURES];
3113 struct wined3d_ffp_vs_desc
3115 struct wine_rb_entry entry;
3116 struct wined3d_ffp_vs_settings settings;
3119 void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
3120 const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) DECLSPEC_HIDDEN;
3122 struct wined3d
3124 LONG ref;
3125 unsigned int flags;
3126 unsigned int adapter_count;
3127 struct wined3d_adapter *adapters[1];
3130 BOOL wined3d_filter_messages(HWND window, BOOL filter) DECLSPEC_HIDDEN;
3131 void wined3d_hook_swapchain(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3132 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN;
3133 void wined3d_unhook_swapchain(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3134 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
3136 BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size) DECLSPEC_HIDDEN;
3138 struct wined3d_blend_state
3140 LONG refcount;
3141 struct wined3d_blend_state_desc desc;
3143 void *parent;
3144 const struct wined3d_parent_ops *parent_ops;
3146 struct wined3d_device *device;
3149 struct wined3d_rasterizer_state
3151 LONG refcount;
3152 struct wined3d_rasterizer_state_desc desc;
3154 void *parent;
3155 const struct wined3d_parent_ops *parent_ops;
3157 struct wined3d_device *device;
3158 struct wine_rb_entry entry;
3161 struct wined3d_stream_output
3163 struct wined3d_buffer *buffer;
3164 UINT offset;
3167 #define LIGHTMAP_SIZE 43
3168 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
3170 struct wined3d_light_state
3172 /* Light hashmap. Collisions are handled using linked lists. */
3173 struct list light_map[LIGHTMAP_SIZE];
3174 const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS];
3177 #define WINED3D_STATE_NO_REF 0x00000001
3178 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3180 struct wined3d_state
3182 DWORD flags;
3183 const struct wined3d_fb_state *fb;
3185 struct wined3d_vertex_declaration *vertex_declaration;
3186 struct wined3d_stream_output stream_output[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
3187 struct wined3d_stream_state streams[WINED3D_MAX_STREAMS];
3188 struct wined3d_buffer *index_buffer;
3189 enum wined3d_format_id index_format;
3190 unsigned int index_offset;
3191 int base_vertex_index;
3192 int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3193 GLenum gl_primitive_type;
3194 GLint gl_patch_vertices;
3195 struct wined3d_query *predicate;
3196 BOOL predicate_value;
3198 struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
3199 struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
3200 struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
3201 struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
3202 struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
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_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3209 struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
3210 BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
3212 struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
3213 DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
3214 DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
3216 struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3217 struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES];
3218 struct wined3d_material material;
3219 struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS];
3220 unsigned int viewport_count;
3221 RECT scissor_rects[WINED3D_MAX_VIEWPORTS];
3222 unsigned int scissor_rect_count;
3224 struct wined3d_light_state light_state;
3226 DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
3227 struct wined3d_blend_state *blend_state;
3228 struct wined3d_color blend_factor;
3229 struct wined3d_rasterizer_state *rasterizer_state;
3232 struct wined3d_dummy_textures
3234 GLuint tex_1d;
3235 GLuint tex_2d;
3236 GLuint tex_rect;
3237 GLuint tex_3d;
3238 GLuint tex_cube;
3239 GLuint tex_cube_array;
3240 GLuint tex_1d_array;
3241 GLuint tex_2d_array;
3242 GLuint tex_buffer;
3243 GLuint tex_2d_ms;
3244 GLuint tex_2d_ms_array;
3247 #define WINED3D_UNMAPPED_STAGE ~0u
3249 /* Multithreaded flag. Removed from the public header to signal that
3250 * wined3d_device_create() ignores it. */
3251 #define WINED3DCREATE_MULTITHREADED 0x00000004
3253 struct wined3d_device
3255 LONG ref;
3257 /* WineD3D Information */
3258 struct wined3d_device_parent *device_parent;
3259 struct wined3d *wined3d;
3260 struct wined3d_adapter *adapter;
3262 const struct wined3d_shader_backend_ops *shader_backend;
3263 void *shader_priv;
3264 void *fragment_priv;
3265 void *vertex_priv;
3266 struct wined3d_state_entry state_table[STATE_HIGHEST + 1];
3267 /* Array of functions for states which are handled by more than one pipeline part */
3268 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
3269 struct wined3d_blitter *blitter;
3271 BYTE bCursorVisible : 1;
3272 BYTE d3d_initialized : 1;
3273 BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3274 BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
3275 BYTE restore_screensaver : 1;
3276 BYTE padding : 3;
3278 unsigned char surface_alignment; /* Line Alignment of surfaces */
3280 WORD padding2 : 16;
3282 enum wined3d_feature_level feature_level;
3284 struct wined3d_state state;
3286 /* Internal use fields */
3287 struct wined3d_device_creation_parameters create_parms;
3288 HWND focus_window;
3290 struct wined3d_rendertarget_view *back_buffer_view;
3291 struct wined3d_swapchain **swapchains;
3292 UINT swapchain_count;
3293 unsigned int max_frame_latency;
3295 struct list resources; /* a linked list to track resources created by the device */
3296 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
3297 struct wine_rb_tree samplers, rasterizer_states;
3299 /* Render Target Support */
3300 struct wined3d_fb_state fb;
3301 struct wined3d_rendertarget_view *auto_depth_stencil_view;
3303 /* Cursor management */
3304 UINT xHotSpot;
3305 UINT yHotSpot;
3306 UINT xScreenSpace;
3307 UINT yScreenSpace;
3308 UINT cursorWidth, cursorHeight;
3309 struct wined3d_texture *cursor_texture;
3310 HCURSOR hardwareCursor;
3312 /* The Wine logo texture */
3313 struct wined3d_texture *logo_texture;
3315 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3316 struct wined3d_sampler *default_sampler;
3317 struct wined3d_sampler *null_sampler;
3319 /* Command stream */
3320 struct wined3d_cs *cs;
3322 /* Context management */
3323 struct wined3d_context **contexts;
3324 UINT context_count;
3325 struct wined3d_blend_state *blend_state_atoc_enabled;
3328 void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN;
3329 void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb,
3330 UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags,
3331 const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
3332 BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3333 void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3334 void wined3d_device_create_default_samplers(struct wined3d_device *device,
3335 struct wined3d_context *context) DECLSPEC_HIDDEN;
3336 void wined3d_device_create_primary_opengl_context_cs(void *object) DECLSPEC_HIDDEN;
3337 void wined3d_device_delete_opengl_contexts_cs(void *object) DECLSPEC_HIDDEN;
3338 void wined3d_device_destroy_default_samplers(struct wined3d_device *device,
3339 struct wined3d_context *context) DECLSPEC_HIDDEN;
3340 HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d,
3341 unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3342 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3343 struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3344 LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
3345 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
3346 void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3347 void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3348 void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
3349 HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device,
3350 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3351 void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN;
3353 struct wined3d_device_no3d
3355 struct wined3d_device d;
3357 struct wined3d_context context_no3d;
3360 static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_device *device)
3362 return CONTAINING_RECORD(device, struct wined3d_device_no3d, d);
3365 struct wined3d_device_gl
3367 struct wined3d_device d;
3369 /* Textures for when no other textures are bound. */
3370 struct wined3d_dummy_textures dummy_textures;
3373 static inline struct wined3d_device_gl *wined3d_device_gl(struct wined3d_device *device)
3375 return CONTAINING_RECORD(device, struct wined3d_device_gl, d);
3378 struct wined3d_device_vk
3380 struct wined3d_device d;
3382 struct wined3d_context_vk context_vk;
3384 VkDevice vk_device;
3385 VkQueue vk_queue;
3386 uint32_t vk_queue_family_index;
3388 struct wined3d_vk_info vk_info;
3391 static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
3393 return CONTAINING_RECORD(device, struct wined3d_device_vk, d);
3396 static inline BOOL isStateDirty(const struct wined3d_context *context, unsigned int state_id)
3398 unsigned int idx = state_id / (sizeof(*context->dirty_graphics_states) * CHAR_BIT);
3399 unsigned int shift = state_id & ((sizeof(*context->dirty_graphics_states) * CHAR_BIT) - 1);
3400 return context->dirty_graphics_states[idx] & (1u << shift);
3403 static inline float wined3d_alpha_ref(const struct wined3d_state *state)
3405 return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
3408 const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
3409 const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN;
3410 const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d,
3411 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3412 const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
3414 static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
3416 return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
3419 struct wined3d_resource_ops
3421 ULONG (*resource_incref)(struct wined3d_resource *resource);
3422 ULONG (*resource_decref)(struct wined3d_resource *resource);
3423 void (*resource_preload)(struct wined3d_resource *resource);
3424 void (*resource_unload)(struct wined3d_resource *resource);
3425 HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
3426 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
3427 HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
3430 struct wined3d_resource
3432 LONG ref;
3433 LONG bind_count;
3434 LONG srv_bind_count_device;
3435 LONG map_count;
3436 LONG access_count;
3437 struct wined3d_device *device;
3438 enum wined3d_resource_type type;
3439 enum wined3d_gl_resource_type gl_type;
3440 const struct wined3d_format *format;
3441 unsigned int format_flags;
3442 enum wined3d_multisample_type multisample_type;
3443 UINT multisample_quality;
3444 DWORD usage;
3445 unsigned int bind_flags;
3446 unsigned int access;
3447 WORD draw_binding;
3448 WORD map_binding;
3449 UINT width;
3450 UINT height;
3451 UINT depth;
3452 UINT size;
3453 DWORD priority;
3454 void *heap_memory;
3456 void *parent;
3457 const struct wined3d_parent_ops *parent_ops;
3458 const struct wined3d_resource_ops *resource_ops;
3460 struct list resource_list_entry;
3463 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
3465 return resource->resource_ops->resource_incref(resource);
3468 static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
3470 return resource->resource_ops->resource_decref(resource);
3473 static inline void wined3d_resource_acquire(struct wined3d_resource *resource)
3475 InterlockedIncrement(&resource->access_count);
3478 static inline void wined3d_resource_release(struct wined3d_resource *resource)
3480 InterlockedDecrement(&resource->access_count);
3483 void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3484 HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
3485 enum wined3d_resource_type type, const struct wined3d_format *format,
3486 enum wined3d_multisample_type multisample_type, unsigned int multisample_quality, unsigned int usage,
3487 unsigned int bind_flags, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
3488 unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
3489 const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
3490 void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3491 void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3492 const struct wined3d_format *wined3d_resource_get_decompress_format(
3493 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3494 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3495 GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3496 GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3497 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3498 BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3499 void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3501 /* Tests show that the start address of resources is 32 byte aligned */
3502 #define RESOURCE_ALIGNMENT 16
3503 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3505 #define WINED3D_LOCATION_DISCARDED 0x00000001
3506 #define WINED3D_LOCATION_SYSMEM 0x00000002
3507 #define WINED3D_LOCATION_USER_MEMORY 0x00000004
3508 #define WINED3D_LOCATION_BUFFER 0x00000008
3509 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3510 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3511 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3512 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3513 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3515 const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN;
3517 struct wined3d_blt_info
3519 GLenum bind_target;
3520 struct wined3d_vec3 texcoords[4];
3523 struct wined3d_texture_ops
3525 BOOL (*texture_prepare_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3526 struct wined3d_context *context, unsigned int location);
3527 BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3528 struct wined3d_context *context, unsigned int location);
3529 void (*texture_unload_location)(struct wined3d_texture *texture,
3530 struct wined3d_context *context, unsigned int location);
3531 void (*texture_upload_data)(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr,
3532 const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch,
3533 unsigned int src_slice_pitch, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3534 unsigned int dst_location, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z);
3535 void (*texture_download_data)(struct wined3d_context *context, struct wined3d_texture *src_texture,
3536 unsigned int src_sub_resource_idx, unsigned int src_location, const struct wined3d_box *src_box,
3537 const struct wined3d_bo_address *dst_bo_addr, const struct wined3d_format *dst_format,
3538 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z,
3539 unsigned int dst_row_pitch, unsigned int dst_slice_pitch);
3542 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3543 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3544 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3545 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3546 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3547 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3548 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3549 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3550 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3551 #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
3552 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3553 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3554 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3555 #define WINED3D_TEXTURE_DISCARD 0x00002000
3556 #define WINED3D_TEXTURE_GET_DC 0x00004000
3557 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3558 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3560 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3562 struct wined3d_texture
3564 struct wined3d_resource resource;
3565 const struct wined3d_texture_ops *texture_ops;
3566 struct wined3d_swapchain *swapchain;
3567 unsigned int pow2_width;
3568 unsigned int pow2_height;
3569 UINT layer_count;
3570 UINT level_count;
3571 unsigned int download_count;
3572 unsigned int sysmem_count;
3573 float pow2_matrix[16];
3574 UINT lod;
3575 DWORD sampler;
3576 DWORD flags;
3577 DWORD update_map_binding;
3579 void *user_memory;
3580 unsigned int row_pitch;
3581 unsigned int slice_pitch;
3583 /* May only be accessed from the command stream worker thread. */
3584 struct wined3d_texture_async
3586 DWORD flags;
3588 /* Color keys for DDraw */
3589 struct wined3d_color_key dst_blt_color_key;
3590 struct wined3d_color_key src_blt_color_key;
3591 struct wined3d_color_key dst_overlay_color_key;
3592 struct wined3d_color_key src_overlay_color_key;
3593 struct wined3d_color_key gl_color_key;
3594 DWORD color_key_flags;
3595 } async;
3597 struct wined3d_dirty_regions
3599 struct wined3d_box *boxes;
3600 SIZE_T boxes_size;
3601 unsigned int box_count;
3602 } *dirty_regions;
3604 struct wined3d_overlay_info
3606 struct list entry;
3607 struct list overlays;
3608 struct wined3d_texture *dst_texture;
3609 unsigned int dst_sub_resource_idx;
3610 RECT src_rect;
3611 RECT dst_rect;
3612 } *overlay_info;
3614 struct wined3d_dc_info
3616 HBITMAP bitmap;
3617 HDC dc;
3618 } *dc_info;
3620 struct wined3d_texture_sub_resource
3622 void *parent;
3623 const struct wined3d_parent_ops *parent_ops;
3625 unsigned int offset;
3626 unsigned int size;
3628 unsigned int map_count;
3629 uint32_t map_flags;
3630 DWORD locations;
3631 uintptr_t buffer_object;
3632 } *sub_resources;
3635 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s, SIZE_T level_count, SIZE_T layer_count)
3637 struct wined3d_texture *t;
3639 if (level_count > ((~(SIZE_T)0 - s) / sizeof(*t->sub_resources)) / layer_count)
3640 return NULL;
3642 return heap_alloc_zero(s + level_count * layer_count * sizeof(*t->sub_resources));
3645 static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
3647 return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
3650 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture,
3651 unsigned int level)
3653 return max(1, texture->resource.width >> level);
3656 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture,
3657 unsigned int level)
3659 return max(1, texture->resource.height >> level);
3662 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture,
3663 unsigned int level)
3665 return max(1, texture->resource.depth >> level);
3668 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
3669 unsigned int level)
3671 return max(1, texture->pow2_width >> level);
3674 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
3675 unsigned int level)
3677 return max(1, texture->pow2_height >> level);
3680 static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture,
3681 unsigned int level, struct wined3d_box *box)
3683 wined3d_box_set(box, 0, 0,
3684 wined3d_texture_get_level_width(texture, level),
3685 wined3d_texture_get_level_height(texture, level),
3686 0, wined3d_texture_get_level_depth(texture, level));
3689 HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3690 const struct wined3d_box *dst_box, struct wined3d_texture *src_texture,
3691 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
3692 const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
3693 void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *context,
3694 enum wined3d_texture_filter_type filter, struct wined3d_texture *src_texture,
3695 unsigned int src_sub_resource_idx, DWORD src_location, const RECT *src_rect,
3696 struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, DWORD dst_location,
3697 const RECT *dst_rect) DECLSPEC_HIDDEN;
3698 void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
3699 const RECT *rect, struct wined3d_blt_info *info) DECLSPEC_HIDDEN;
3700 void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
3701 BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN;
3702 void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3703 struct wined3d_context *context, DWORD src_location, DWORD dst_location) DECLSPEC_HIDDEN;
3705 HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
3706 unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
3707 void wined3d_texture_cleanup(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3708 void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3709 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN;
3710 GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3711 void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3712 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
3713 void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
3714 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
3715 void wined3d_texture_load(struct wined3d_texture *texture,
3716 struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
3717 BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
3718 unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3719 BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3720 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3721 void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN;
3722 void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
3723 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3724 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3725 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
3726 HWND window, RECT *rect) DECLSPEC_HIDDEN;
3727 void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3728 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture,
3729 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
3730 void wined3d_texture_validate_location(struct wined3d_texture *texture,
3731 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
3732 void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3734 HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device,
3735 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
3736 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3738 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
3740 struct gl_texture
3742 struct wined3d_sampler_desc sampler_desc;
3743 unsigned int base_level;
3744 GLuint name;
3747 struct wined3d_texture_gl
3749 struct wined3d_texture t;
3751 struct gl_texture texture_rgb, texture_srgb;
3753 GLenum target;
3755 GLuint rb_multisample;
3756 GLuint rb_resolved;
3758 struct list renderbuffers;
3759 const struct wined3d_renderbuffer_entry *current_renderbuffer;
3762 static inline struct wined3d_texture_gl *wined3d_texture_gl(struct wined3d_texture *texture)
3764 return CONTAINING_RECORD(texture, struct wined3d_texture_gl, t);
3767 static inline struct gl_texture *wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl *texture_gl,
3768 BOOL srgb)
3770 return srgb ? &texture_gl->texture_srgb : &texture_gl->texture_rgb;
3773 static inline GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl,
3774 unsigned int sub_resource_idx)
3776 static const GLenum cube_targets[] =
3778 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
3779 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
3780 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
3781 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
3782 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
3783 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
3786 return texture_gl->t.resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP
3787 ? cube_targets[sub_resource_idx / texture_gl->t.level_count] : texture_gl->target;
3790 static inline BOOL wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl *texture_gl,
3791 DWORD location)
3793 if (location == WINED3D_LOCATION_RB_MULTISAMPLE)
3794 return TRUE;
3795 if (location != WINED3D_LOCATION_TEXTURE_RGB && location != WINED3D_LOCATION_TEXTURE_SRGB)
3796 return FALSE;
3797 return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
3800 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl,
3801 const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
3802 void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
3803 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
3804 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
3805 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
3806 HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, struct wined3d_device *device,
3807 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
3808 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3809 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
3810 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
3811 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl,
3812 struct wined3d_context_gl *context_gl, unsigned int level,
3813 const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;
3815 struct wined3d_texture_vk
3817 struct wined3d_texture t;
3820 static inline struct wined3d_texture_vk *wined3d_texture_vk(struct wined3d_texture *texture)
3822 return CONTAINING_RECORD(texture, struct wined3d_texture_vk, t);
3825 HRESULT wined3d_texture_vk_init(struct wined3d_texture_vk *texture_vk, struct wined3d_device *device,
3826 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
3827 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3829 struct wined3d_renderbuffer_entry
3831 struct list entry;
3832 GLuint id;
3833 UINT width;
3834 UINT height;
3837 struct wined3d_fbo_resource
3839 GLuint object;
3840 GLenum target;
3841 GLuint level, layer;
3844 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
3845 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
3846 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
3848 struct fbo_entry
3850 struct list entry;
3851 DWORD flags;
3852 DWORD rt_mask;
3853 GLuint id;
3854 struct wined3d_fbo_entry_key
3856 DWORD rb_namespace;
3857 struct wined3d_fbo_resource objects[MAX_RENDER_TARGET_VIEWS + 1];
3858 } key;
3861 struct wined3d_sampler
3863 struct wine_rb_entry entry;
3864 LONG refcount;
3865 struct wined3d_device *device;
3866 void *parent;
3867 const struct wined3d_parent_ops *parent_ops;
3868 struct wined3d_sampler_desc desc;
3871 struct wined3d_sampler_gl
3873 struct wined3d_sampler s;
3875 GLuint name;
3878 static inline struct wined3d_sampler_gl *wined3d_sampler_gl(struct wined3d_sampler *sampler)
3880 return CONTAINING_RECORD(sampler, struct wined3d_sampler_gl, s);
3883 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl *sampler_gl, unsigned int unit,
3884 struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
3885 void wined3d_sampler_gl_init(struct wined3d_sampler_gl *sampler_gl,
3886 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3887 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3889 void wined3d_sampler_vk_init(struct wined3d_sampler *sampler_vk,
3890 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3891 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
3893 struct wined3d_vertex_declaration_element
3895 const struct wined3d_format *format;
3896 BOOL ffp_valid;
3897 unsigned int input_slot;
3898 unsigned int offset;
3899 unsigned int output_slot;
3900 enum wined3d_input_classification input_slot_class;
3901 unsigned int instance_data_step_rate;
3902 BYTE method;
3903 BYTE usage;
3904 BYTE usage_idx;
3907 struct wined3d_vertex_declaration
3909 LONG ref;
3910 void *parent;
3911 const struct wined3d_parent_ops *parent_ops;
3912 struct wined3d_device *device;
3914 struct wined3d_vertex_declaration_element *elements;
3915 unsigned int element_count;
3917 BOOL position_transformed;
3920 struct wined3d_saved_states
3922 DWORD vs_consts_f[WINED3D_MAX_VS_CONSTS_F >> 5];
3923 WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
3924 WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
3925 DWORD ps_consts_f[WINED3D_MAX_PS_CONSTS_F >> 5];
3926 WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
3927 WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
3928 DWORD transform[(WINED3D_HIGHEST_TRANSFORM_STATE >> 5) + 1];
3929 WORD streamSource; /* WINED3D_MAX_STREAMS, 16 */
3930 WORD streamFreq; /* WINED3D_MAX_STREAMS, 16 */
3931 DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
3932 DWORD textureState[WINED3D_MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
3933 WORD samplerState[WINED3D_MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
3934 DWORD clipplane; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
3935 DWORD textures : 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
3936 DWORD indices : 1;
3937 DWORD material : 1;
3938 DWORD viewport : 1;
3939 DWORD vertexDecl : 1;
3940 DWORD pixelShader : 1;
3941 DWORD vertexShader : 1;
3942 DWORD scissorRect : 1;
3943 DWORD store_stream_offset : 1;
3944 DWORD blend_state : 1;
3945 DWORD lights : 1;
3946 DWORD transforms : 1;
3947 DWORD padding : 1;
3950 struct StageState {
3951 DWORD stage;
3952 DWORD state;
3955 struct wined3d_stateblock
3957 LONG ref; /* Note: Ref counting not required */
3958 struct wined3d_device *device;
3960 /* Array indicating whether things have been set or changed */
3961 struct wined3d_saved_states changed;
3963 struct wined3d_stateblock_state stateblock_state;
3964 struct wined3d_light_state light_state;
3966 /* Contained state management */
3967 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
3968 unsigned int num_contained_render_states;
3969 DWORD contained_transform_states[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3970 unsigned int num_contained_transform_states;
3971 struct StageState contained_tss_states[WINED3D_MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
3972 unsigned int num_contained_tss_states;
3973 struct StageState contained_sampler_states[WINED3D_MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
3974 unsigned int num_contained_sampler_states;
3977 void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
3978 const struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
3979 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
3981 void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
3982 struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
3983 struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
3984 unsigned int idx) DECLSPEC_HIDDEN;
3985 HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
3986 const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
3988 void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
3989 void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
3990 const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN;
3991 void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
3993 enum wined3d_cs_queue_id
3995 WINED3D_CS_QUEUE_DEFAULT = 0,
3996 WINED3D_CS_QUEUE_MAP,
3997 WINED3D_CS_QUEUE_COUNT,
4000 enum wined3d_push_constants
4002 WINED3D_PUSH_CONSTANTS_VS_F,
4003 WINED3D_PUSH_CONSTANTS_PS_F,
4004 WINED3D_PUSH_CONSTANTS_VS_I,
4005 WINED3D_PUSH_CONSTANTS_PS_I,
4006 WINED3D_PUSH_CONSTANTS_VS_B,
4007 WINED3D_PUSH_CONSTANTS_PS_B,
4010 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
4011 #define WINED3D_CS_QUEUE_SIZE 0x100000u
4012 #define WINED3D_CS_SPIN_COUNT 10000000u
4014 struct wined3d_cs_queue
4016 LONG head, tail;
4017 BYTE data[WINED3D_CS_QUEUE_SIZE];
4020 struct wined3d_cs_ops
4022 void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
4023 void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
4024 void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
4025 void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p,
4026 unsigned int start_idx, unsigned int count, const void *constants);
4029 struct wined3d_cs
4031 const struct wined3d_cs_ops *ops;
4032 struct wined3d_device *device;
4033 struct wined3d_fb_state fb;
4034 struct wined3d_state state;
4035 HMODULE wined3d_module;
4036 HANDLE thread;
4037 DWORD thread_id;
4039 struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
4040 size_t data_size, start, end;
4041 void *data;
4042 struct list query_poll_list;
4043 BOOL queries_flushed;
4045 HANDLE event;
4046 BOOL waiting_for_event;
4047 LONG pending_presents;
4050 struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN;
4051 void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4052 void wined3d_cs_destroy_object(struct wined3d_cs *cs,
4053 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4054 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
4055 struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
4056 void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
4057 unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
4058 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
4059 const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4060 void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
4061 DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4062 void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined3d_rendertarget_view *view,
4063 const RECT *rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4064 void wined3d_cs_emit_clear_unordered_access_view_uint(struct wined3d_cs *cs,
4065 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value) DECLSPEC_HIDDEN;
4066 void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buffer *dst_buffer,
4067 unsigned int offset, struct wined3d_unordered_access_view *uav) DECLSPEC_HIDDEN;
4068 void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
4069 unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) DECLSPEC_HIDDEN;
4070 void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs,
4071 struct wined3d_buffer *buffer, unsigned int offset) DECLSPEC_HIDDEN;
4072 void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
4073 int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
4074 unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
4075 void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
4076 struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) DECLSPEC_HIDDEN;
4077 void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4078 void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4079 void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4080 void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
4081 const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags) DECLSPEC_HIDDEN;
4082 void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN;
4083 void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4084 void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state,
4085 const struct wined3d_color *blend_factor) DECLSPEC_HIDDEN;
4086 void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
4087 const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
4088 void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
4089 WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
4090 void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
4091 UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4092 void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
4093 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4094 void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
4095 enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN;
4096 void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light_info *light) DECLSPEC_HIDDEN;
4097 void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) DECLSPEC_HIDDEN;
4098 void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
4099 void wined3d_cs_emit_set_predication(struct wined3d_cs *cs,
4100 struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
4101 void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs,
4102 struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN;
4103 void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
4104 enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
4105 void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx,
4106 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4107 void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
4108 UINT view_idx, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4109 void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type,
4110 UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
4111 void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx,
4112 enum wined3d_sampler_state state, DWORD value) DECLSPEC_HIDDEN;
4113 void wined3d_cs_emit_set_scissor_rects(struct wined3d_cs *cs, unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN;
4114 void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type,
4115 struct wined3d_shader *shader) DECLSPEC_HIDDEN;
4116 void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx,
4117 struct wined3d_buffer *buffer, UINT offset) DECLSPEC_HIDDEN;
4118 void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx,
4119 struct wined3d_buffer *buffer, UINT offset, UINT stride) DECLSPEC_HIDDEN;
4120 void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx,
4121 UINT frequency, UINT flags) DECLSPEC_HIDDEN;
4122 void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4123 void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage,
4124 enum wined3d_texture_stage_state state, DWORD value) DECLSPEC_HIDDEN;
4125 void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
4126 const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
4127 void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
4128 unsigned int view_idx, struct wined3d_unordered_access_view *view,
4129 unsigned int initial_count) DECLSPEC_HIDDEN;
4130 void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
4131 struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
4132 void wined3d_cs_emit_set_viewports(struct wined3d_cs *cs, unsigned int viewport_count, const struct wined3d_viewport *viewports) DECLSPEC_HIDDEN;
4133 void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4134 void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource,
4135 unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
4136 unsigned int slice_pitch) DECLSPEC_HIDDEN;
4137 void wined3d_cs_init_object(struct wined3d_cs *cs,
4138 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4139 HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
4140 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
4141 HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource,
4142 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
4144 static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
4146 cs->ops->finish(cs, queue_id);
4149 static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
4150 unsigned int start_idx, unsigned int count, const void *constants)
4152 cs->ops->push_constants(cs, p, start_idx, count, constants);
4155 static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
4157 const struct wined3d_cs *cs = resource->device->cs;
4159 if (!cs->thread || cs->thread_id == GetCurrentThreadId())
4160 return;
4162 while (InterlockedCompareExchange(&resource->access_count, 0, 0))
4163 wined3d_pause();
4166 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
4167 * fixed function semantics as D3DCOLOR or FLOAT16 */
4168 enum wined3d_buffer_conversion_type
4170 CONV_NONE,
4171 CONV_D3DCOLOR,
4172 CONV_POSITIONT,
4175 struct wined3d_buffer_ops
4177 BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer,
4178 struct wined3d_context *context, unsigned int location);
4179 void (*buffer_unload_location)(struct wined3d_buffer *buffer,
4180 struct wined3d_context *context, unsigned int location);
4181 void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
4182 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
4183 void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
4184 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
4187 struct wined3d_buffer
4189 struct wined3d_resource resource;
4190 const struct wined3d_buffer_ops *buffer_ops;
4192 unsigned int structure_byte_stride;
4193 DWORD flags;
4194 DWORD locations;
4195 void *map_ptr;
4196 uintptr_t buffer_object;
4198 struct wined3d_range *maps;
4199 SIZE_T maps_size, modified_areas;
4200 struct wined3d_fence *fence;
4202 /* conversion stuff */
4203 UINT decl_change_count, full_conversion_count;
4204 UINT draw_count;
4205 UINT stride; /* 0 if no conversion */
4206 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
4207 UINT conversion_stride; /* 0 if no shifted conversion */
4210 static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
4212 return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
4215 void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4216 DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer,
4217 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4218 void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
4219 void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
4220 const struct wined3d_state *state) DECLSPEC_HIDDEN;
4221 BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
4222 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4223 BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
4224 void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
4225 struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
4226 void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
4227 const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
4229 HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device,
4230 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4231 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4233 struct wined3d_buffer_gl
4235 struct wined3d_buffer b;
4237 GLenum buffer_object_usage;
4238 GLenum buffer_type_hint;
4241 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
4243 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
4246 GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info,
4247 uint32_t bind_flags) DECLSPEC_HIDDEN;
4248 HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device,
4249 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4250 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4252 struct wined3d_buffer_vk
4254 struct wined3d_buffer b;
4256 struct wined3d_bo_vk bo;
4259 static inline struct wined3d_buffer_vk *wined3d_buffer_vk(struct wined3d_buffer *buffer)
4261 return CONTAINING_RECORD(buffer, struct wined3d_buffer_vk, b);
4264 HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device,
4265 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4266 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4268 struct wined3d_rendertarget_view
4270 LONG refcount;
4272 struct wined3d_resource *resource;
4273 void *parent;
4274 const struct wined3d_parent_ops *parent_ops;
4276 const struct wined3d_format *format;
4277 unsigned int format_flags;
4278 unsigned int sub_resource_idx;
4279 unsigned int layer_count;
4281 unsigned int width;
4282 unsigned int height;
4284 struct wined3d_view_desc desc;
4287 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4288 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
4289 const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
4290 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
4291 DWORD location) DECLSPEC_HIDDEN;
4292 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
4293 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4294 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,
4295 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4296 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
4297 DWORD location) DECLSPEC_HIDDEN;
4299 HRESULT wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view *view_no3d,
4300 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4301 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4303 struct wined3d_rendertarget_view_gl
4305 struct wined3d_rendertarget_view v;
4306 struct wined3d_gl_view gl_view;
4309 static inline struct wined3d_rendertarget_view_gl *wined3d_rendertarget_view_gl(
4310 struct wined3d_rendertarget_view *view)
4312 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_gl, v);
4315 HRESULT wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl *view_gl,
4316 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4317 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4319 struct wined3d_rendertarget_view_vk
4321 struct wined3d_rendertarget_view v;
4324 static inline struct wined3d_rendertarget_view_vk *wined3d_rendertarget_view_vk(
4325 struct wined3d_rendertarget_view *view)
4327 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_vk, v);
4330 HRESULT wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk *view_vk,
4331 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4332 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4334 struct wined3d_shader_resource_view
4336 LONG refcount;
4338 struct wined3d_resource *resource;
4339 void *parent;
4340 const struct wined3d_parent_ops *parent_ops;
4342 const struct wined3d_format *format;
4344 struct wined3d_view_desc desc;
4347 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4348 void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4350 struct wined3d_shader_resource_view_gl
4352 struct wined3d_shader_resource_view v;
4353 struct wined3d_gl_view gl_view;
4356 static inline struct wined3d_shader_resource_view_gl *wined3d_shader_resource_view_gl(
4357 struct wined3d_shader_resource_view *view)
4359 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_gl, v);
4362 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit,
4363 struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4364 HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl *view_gl,
4365 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4366 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4368 struct wined3d_shader_resource_view_vk
4370 struct wined3d_shader_resource_view v;
4373 static inline struct wined3d_shader_resource_view_vk *wined3d_shader_resource_view_vk(
4374 struct wined3d_shader_resource_view *view)
4376 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_vk, v);
4379 HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk *view_vk,
4380 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4381 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4383 struct wined3d_unordered_access_view
4385 LONG refcount;
4387 struct wined3d_resource *resource;
4388 void *parent;
4389 const struct wined3d_parent_ops *parent_ops;
4391 const struct wined3d_format *format;
4393 struct wined3d_view_desc desc;
4396 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
4397 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
4398 struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
4399 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
4400 DWORD location) DECLSPEC_HIDDEN;
4401 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
4402 unsigned int value) DECLSPEC_HIDDEN;
4404 struct wined3d_unordered_access_view_gl
4406 struct wined3d_unordered_access_view v;
4407 struct wined3d_gl_view gl_view;
4408 GLuint counter_bo;
4411 static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_view_gl(
4412 struct wined3d_unordered_access_view *view)
4414 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_gl, v);
4417 void wined3d_unordered_access_view_gl_clear_uint(struct wined3d_unordered_access_view_gl *view_gl,
4418 const struct wined3d_uvec4 *clear_value, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4419 HRESULT wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl *view_gl,
4420 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4421 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4423 struct wined3d_unordered_access_view_vk
4425 struct wined3d_unordered_access_view v;
4428 static inline struct wined3d_unordered_access_view_vk *wined3d_unordered_access_view_vk(
4429 struct wined3d_unordered_access_view *view)
4431 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_vk, v);
4434 HRESULT wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk *view_vk,
4435 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4436 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4438 struct wined3d_swapchain_state
4440 struct wined3d_swapchain_desc desc;
4442 struct wined3d_display_mode original_mode, d3d_mode;
4443 RECT original_window_rect;
4445 /* Window styles to restore when switching fullscreen mode. */
4446 LONG style;
4447 LONG exstyle;
4448 HWND device_window;
4451 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
4452 HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
4453 HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
4454 HWND window, unsigned int w, unsigned int h) DECLSPEC_HIDDEN;
4456 struct wined3d_swapchain_ops
4458 void (*swapchain_present)(struct wined3d_swapchain *swapchain,
4459 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, DWORD flags);
4460 void (*swapchain_frontbuffer_updated)(struct wined3d_swapchain *swapchain);
4463 struct wined3d_swapchain
4465 LONG ref;
4466 void *parent;
4467 const struct wined3d_parent_ops *parent_ops;
4468 const struct wined3d_swapchain_ops *swapchain_ops;
4469 struct wined3d_device *device;
4471 struct wined3d_texture **back_buffers;
4472 struct wined3d_texture *front_buffer;
4473 struct wined3d_gamma_ramp orig_gamma;
4474 BOOL render_to_fbo, reapply_mode;
4475 const struct wined3d_format *ds_format;
4476 struct wined3d_palette *palette;
4477 RECT front_buffer_update;
4478 unsigned int swap_interval;
4479 unsigned int max_frame_latency;
4481 LONG prev_time, frames; /* Performance tracking */
4483 struct wined3d_swapchain_state state;
4484 HWND win_handle;
4487 void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
4488 void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4489 struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4490 void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4491 void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain,
4492 const struct wined3d_device *device) DECLSPEC_HIDDEN;
4494 HRESULT wined3d_swapchain_no3d_init(struct wined3d_swapchain *swapchain_no3d,
4495 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4496 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4498 struct wined3d_swapchain_gl
4500 struct wined3d_swapchain s;
4502 struct wined3d_context_gl **contexts;
4503 SIZE_T contexts_size;
4504 SIZE_T context_count;
4506 HDC backup_dc;
4507 HWND backup_wnd;
4510 static inline struct wined3d_swapchain_gl *wined3d_swapchain_gl(struct wined3d_swapchain *swapchain)
4512 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_gl, s);
4515 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4516 void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4517 HDC wined3d_swapchain_gl_get_backup_dc(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4518 struct wined3d_context_gl *wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4519 HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl,
4520 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4521 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4523 HRESULT wined3d_swapchain_vk_init(struct wined3d_swapchain *swapchain_vk,
4524 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4525 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4527 /*****************************************************************************
4528 * Utility function prototypes
4531 /* Trace routines */
4532 const char *debug_bo_address(const struct wined3d_bo_address *address) DECLSPEC_HIDDEN;
4533 const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
4534 const char *debug_color(const struct wined3d_color *color) DECLSPEC_HIDDEN;
4535 const char *debug_const_bo_address(const struct wined3d_const_bo_address *address) DECLSPEC_HIDDEN;
4536 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
4537 const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
4538 const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
4539 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) DECLSPEC_HIDDEN;
4540 const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
4541 const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
4542 const char *debug_d3ddeclmethod(enum wined3d_decl_method method) DECLSPEC_HIDDEN;
4543 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
4544 const char *debug_d3dinput_classification(enum wined3d_input_classification classification) DECLSPEC_HIDDEN;
4545 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
4546 const char *debug_d3drenderstate(enum wined3d_render_state state) DECLSPEC_HIDDEN;
4547 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HIDDEN;
4548 const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
4549 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
4550 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
4551 const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
4552 const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
4553 const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
4554 const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
4555 const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
4556 const char *debug_ivec4(const struct wined3d_ivec4 *v) DECLSPEC_HIDDEN;
4557 const char *debug_uvec4(const struct wined3d_uvec4 *v) DECLSPEC_HIDDEN;
4558 const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
4559 const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
4560 const char *wined3d_debug_feature_level(enum wined3d_feature_level level) DECLSPEC_HIDDEN;
4561 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4563 BOOL is_invalid_op(const struct wined3d_state *state, int stage,
4564 enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
4565 void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
4566 BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
4567 INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
4568 void texture_activate_dimensions(struct wined3d_texture *texture,
4569 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
4570 void sampler_texdim(struct wined3d_context *context,
4571 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4572 void tex_alphaop(struct wined3d_context *context,
4573 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4574 void apply_pixelshader(struct wined3d_context *context,
4575 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4576 void state_alpha_test(struct wined3d_context *context,
4577 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4578 void state_fogcolor(struct wined3d_context *context,
4579 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4580 void state_fogdensity(struct wined3d_context *context,
4581 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4582 void state_fogstartend(struct wined3d_context *context,
4583 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4584 void state_fog_fragpart(struct wined3d_context *context,
4585 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4586 void state_nop(struct wined3d_context *context,
4587 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4588 void state_srgbwrite(struct wined3d_context *context,
4589 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4591 void state_clipping(struct wined3d_context *context,
4592 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4593 void clipplane(struct wined3d_context *context,
4594 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4595 void state_pointsprite_w(struct wined3d_context *context,
4596 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4597 void state_pointsprite(struct wined3d_context *context,
4598 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4599 void state_shademode(struct wined3d_context *context,
4600 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4602 GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
4603 enum wined3d_primitive_type d3d_primitive_type_from_gl(GLenum primitive_type) DECLSPEC_HIDDEN;
4605 /* Math utils */
4606 void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
4607 const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
4609 void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
4611 struct wined3d_shader_lconst
4613 struct list entry;
4614 unsigned int idx;
4615 DWORD value[4];
4618 struct wined3d_shader_limits
4620 unsigned int sampler;
4621 unsigned int constant_int;
4622 unsigned int constant_float;
4623 unsigned int constant_bool;
4624 unsigned int packed_output;
4625 unsigned int packed_input;
4628 #ifdef __GNUC__
4629 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
4630 #else
4631 #define PRINTF_ATTR(fmt,args)
4632 #endif
4634 struct wined3d_string_buffer_list
4636 struct list list;
4639 struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4640 void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN;
4641 void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4642 void string_buffer_list_init(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4643 void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4645 int shader_addline(struct wined3d_string_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
4646 BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc) DECLSPEC_HIDDEN;
4647 int shader_vaddline(struct wined3d_string_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
4649 struct wined3d_shader_phase
4651 const DWORD *start;
4652 const DWORD *end;
4653 unsigned int instance_count;
4654 unsigned int temporary_count;
4657 struct wined3d_vertex_shader
4659 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
4662 struct wined3d_hull_shader
4664 struct
4666 struct wined3d_shader_phase *control_point;
4667 unsigned int fork_count;
4668 unsigned int join_count;
4669 struct wined3d_shader_phase *fork;
4670 SIZE_T fork_size;
4671 struct wined3d_shader_phase *join;
4672 SIZE_T join_size;
4673 } phases;
4674 unsigned int output_vertex_count;
4675 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
4676 enum wined3d_tessellator_partitioning tessellator_partitioning;
4679 struct wined3d_domain_shader
4681 enum wined3d_tessellator_domain tessellator_domain;
4684 struct wined3d_geometry_shader
4686 enum wined3d_primitive_type input_type;
4687 enum wined3d_primitive_type output_type;
4688 unsigned int vertices_out;
4689 unsigned int instance_count;
4691 struct wined3d_stream_output_desc so_desc;
4694 struct wined3d_pixel_shader
4696 /* Pixel shader input semantics */
4697 DWORD input_reg_map[MAX_REG_INPUT];
4698 DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
4699 unsigned int declared_in_count;
4701 /* Some information about the shader behavior */
4702 BOOL color0_mov;
4703 DWORD color0_reg;
4705 BOOL force_early_depth_stencil;
4706 enum wined3d_shader_register_type depth_output;
4707 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
4710 struct wined3d_compute_shader
4712 struct wined3d_shader_thread_group_size thread_group_size;
4715 struct wined3d_shader
4717 LONG ref;
4718 const struct wined3d_shader_limits *limits;
4719 const DWORD *function;
4720 unsigned int functionLength;
4721 void *byte_code;
4722 unsigned int byte_code_size;
4723 BOOL load_local_constsF;
4724 const struct wined3d_shader_frontend *frontend;
4725 void *frontend_data;
4726 void *backend_data;
4728 void *parent;
4729 const struct wined3d_parent_ops *parent_ops;
4731 /* Programs this shader is linked with */
4732 struct list linked_programs;
4734 /* Immediate constants (override global ones) */
4735 struct list constantsB;
4736 struct list constantsF;
4737 struct list constantsI;
4738 struct wined3d_shader_reg_maps reg_maps;
4739 BOOL lconst_inf_or_nan;
4741 struct wined3d_shader_signature input_signature;
4742 struct wined3d_shader_signature output_signature;
4743 struct wined3d_shader_signature patch_constant_signature;
4745 /* Pointer to the parent device */
4746 struct wined3d_device *device;
4747 struct list shader_list_entry;
4749 union
4751 struct wined3d_vertex_shader vs;
4752 struct wined3d_hull_shader hs;
4753 struct wined3d_domain_shader ds;
4754 struct wined3d_geometry_shader gs;
4755 struct wined3d_pixel_shader ps;
4756 struct wined3d_compute_shader cs;
4757 } u;
4760 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
4761 unsigned int resource_idx, DWORD tex_types) DECLSPEC_HIDDEN;
4762 void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4763 BOOL position_transformed, struct ps_compile_args *args,
4764 const struct wined3d_context *context) DECLSPEC_HIDDEN;
4766 BOOL vshader_get_input(const struct wined3d_shader *shader,
4767 BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
4768 void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4769 WORD swizzle_map, struct vs_compile_args *args,
4770 const struct wined3d_context *context) DECLSPEC_HIDDEN;
4772 void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4773 struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
4775 void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4776 struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
4778 void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4779 BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4780 void string_buffer_free(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4781 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
4782 unsigned int max) DECLSPEC_HIDDEN;
4783 HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
4784 const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
4785 const DWORD *start, const DWORD *end) DECLSPEC_HIDDEN;
4786 BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
4788 static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
4790 switch (reg->type)
4792 case WINED3DSPR_RASTOUT:
4793 /* oFog & oPts */
4794 if (reg->idx[0].offset)
4795 return TRUE;
4796 /* oPos */
4797 return FALSE;
4799 case WINED3DSPR_CONSTBOOL: /* b# */
4800 case WINED3DSPR_DEPTHOUT: /* oDepth */
4801 case WINED3DSPR_DEPTHOUTGE:
4802 case WINED3DSPR_DEPTHOUTLE:
4803 case WINED3DSPR_LOOP: /* aL */
4804 case WINED3DSPR_OUTPOINTID:
4805 case WINED3DSPR_PREDICATE: /* p0 */
4806 case WINED3DSPR_PRIMID: /* primID */
4807 case WINED3DSPR_COVERAGE: /* vCoverage */
4808 case WINED3DSPR_SAMPLEMASK: /* oMask */
4809 return TRUE;
4811 case WINED3DSPR_MISCTYPE:
4812 switch (reg->idx[0].offset)
4814 case 0: /* vPos */
4815 return FALSE;
4816 case 1: /* vFace */
4817 return TRUE;
4818 default:
4819 return FALSE;
4822 case WINED3DSPR_IMMCONST:
4823 return reg->immconst_type == WINED3D_IMMCONST_SCALAR;
4825 default:
4826 return FALSE;
4830 static inline void shader_get_position_fixup(const struct wined3d_context *context,
4831 const struct wined3d_state *state, unsigned int fixup_count, float *position_fixup)
4833 float center_offset;
4834 unsigned int i;
4836 if (context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)
4837 center_offset = 63.0f / 64.0f;
4838 else
4839 center_offset = -1.0f / 64.0f;
4841 for (i = 0; i < fixup_count; ++i)
4843 position_fixup[4 * i ] = 1.0f;
4844 position_fixup[4 * i + 1] = 1.0f;
4845 position_fixup[4 * i + 2] = center_offset / state->viewports[i].width;
4846 position_fixup[4 * i + 3] = -center_offset / state->viewports[i].height;
4848 if (context->render_offscreen)
4850 position_fixup[4 * i + 1] *= -1.0f;
4851 position_fixup[4 * i + 3] *= -1.0f;
4856 static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
4858 struct wined3d_shader_lconst *lconst;
4860 if (shader->load_local_constsF)
4861 return FALSE;
4863 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
4865 if (lconst->idx == reg)
4866 return TRUE;
4869 return FALSE;
4872 void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4873 void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4874 unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4875 void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4876 struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4877 void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4878 unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4879 void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state,
4880 float *out_min, float *out_max) DECLSPEC_HIDDEN;
4881 void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
4882 float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
4883 void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
4884 float *start, float *end) DECLSPEC_HIDDEN;
4886 /* Using additional shader constants (uniforms in GLSL / program environment
4887 * or local parameters in ARB) is costly:
4888 * ARB only knows float4 parameters and GLSL compiler are not really smart
4889 * when it comes to efficiently pack float2 uniforms, so no space is wasted
4890 * (in fact most compilers map a float2 to a full float4 uniform).
4892 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
4893 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
4894 * into a single shader constant (uniform / program parameter).
4896 * This structure is shared between the GLSL and the ARB backend.*/
4897 struct ps_np2fixup_info {
4898 unsigned char idx[WINED3D_MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
4899 WORD active; /* bitfield indicating if we can apply the fixup */
4900 WORD num_consts;
4903 void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL program) DECLSPEC_HIDDEN;
4904 void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLuint program) DECLSPEC_HIDDEN;
4906 struct wined3d_palette
4908 LONG ref;
4909 struct wined3d_device *device;
4911 unsigned int size;
4912 RGBQUAD colors[256];
4913 DWORD flags;
4916 /* DirectDraw utility functions */
4917 extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
4919 /*****************************************************************************
4920 * Pixel format management
4923 /* WineD3D pixel format flags */
4924 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x00000001
4925 #define WINED3DFMT_FLAG_FILTERING 0x00000002
4926 #define WINED3DFMT_FLAG_DEPTH 0x00000004
4927 #define WINED3DFMT_FLAG_STENCIL 0x00000008
4928 #define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
4929 #define WINED3DFMT_FLAG_EXTENSION 0x00000020
4930 #define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
4931 #define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
4932 #define WINED3DFMT_FLAG_DECOMPRESS 0x00000100
4933 #define WINED3DFMT_FLAG_FLOAT 0x00000200
4934 #define WINED3DFMT_FLAG_BUMPMAP 0x00000400
4935 #define WINED3DFMT_FLAG_SRGB_READ 0x00000800
4936 #define WINED3DFMT_FLAG_SRGB_WRITE 0x00001000
4937 #define WINED3DFMT_FLAG_VTF 0x00002000
4938 #define WINED3DFMT_FLAG_SHADOW 0x00004000
4939 #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
4940 #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
4941 #define WINED3DFMT_FLAG_BLOCKS 0x00020000
4942 #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
4943 #define WINED3DFMT_FLAG_TEXTURE 0x00080000
4944 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
4945 #define WINED3DFMT_FLAG_INTEGER 0x00200000
4946 #define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
4947 #define WINED3DFMT_FLAG_NORMALISED 0x00800000
4948 #define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE 0x01000000
4949 #define WINED3DFMT_FLAG_BLIT 0x02000000
4950 #define WINED3DFMT_FLAG_MAPPABLE 0x04000000
4952 struct wined3d_rational
4954 UINT numerator;
4955 UINT denominator;
4958 struct wined3d_color_key_conversion
4960 enum wined3d_format_id dst_format;
4961 void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch,
4962 unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key);
4965 struct wined3d_format
4967 enum wined3d_format_id id;
4969 D3DDDIFORMAT ddi_format;
4970 unsigned int component_count;
4971 DWORD red_size;
4972 DWORD green_size;
4973 DWORD blue_size;
4974 DWORD alpha_size;
4975 DWORD red_offset;
4976 DWORD green_offset;
4977 DWORD blue_offset;
4978 DWORD alpha_offset;
4979 UINT byte_count;
4980 BYTE depth_size;
4981 BYTE stencil_size;
4983 UINT block_width;
4984 UINT block_height;
4985 UINT block_byte_count;
4987 enum wined3d_ffp_emit_idx emit_idx;
4989 UINT conv_byte_count;
4990 DWORD multisample_types;
4991 unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
4992 float depth_bias_scale;
4993 struct wined3d_rational height_scale;
4994 struct color_fixup_desc color_fixup;
4995 void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4996 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
4997 unsigned int width, unsigned int height, unsigned int depth);
4998 void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4999 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5000 unsigned int width, unsigned int height, unsigned int depth);
5001 void (*decompress)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5002 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5003 unsigned int width, unsigned int height, unsigned int depth);
5005 enum wined3d_format_id typeless_id;
5008 const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
5009 enum wined3d_format_id format_id, unsigned int bind_flags) DECLSPEC_HIDDEN;
5010 void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
5011 unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
5012 UINT wined3d_format_calculate_size(const struct wined3d_format *format,
5013 UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
5014 DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
5015 const struct wined3d_color *color) DECLSPEC_HIDDEN;
5016 void wined3d_format_get_float_color_key(const struct wined3d_format *format,
5017 const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
5018 BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
5019 enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
5020 const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
5021 const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
5022 BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
5023 enum wined3d_format_id format2) DECLSPEC_HIDDEN;
5025 struct wined3d_format_gl
5027 struct wined3d_format f;
5029 GLenum vtx_type;
5030 GLint vtx_format;
5032 GLint internal;
5033 GLint srgb_internal;
5034 GLint rt_internal;
5035 GLint format;
5036 GLint type;
5038 GLenum view_class;
5041 static inline const struct wined3d_format_gl *wined3d_format_gl(const struct wined3d_format *format)
5043 return CONTAINING_RECORD(format, struct wined3d_format_gl, f);
5046 struct wined3d_format_vk
5048 struct wined3d_format f;
5050 VkFormat vk_format;
5053 static inline const struct wined3d_format_vk *wined3d_format_vk(const struct wined3d_format *format)
5055 return CONTAINING_RECORD(format, struct wined3d_format_vk, f);
5058 BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
5060 static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
5062 return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
5065 static inline BOOL use_vs(const struct wined3d_state *state)
5067 /* Check state->vertex_declaration to allow this to be used before the
5068 * stream info is validated, for example in device_update_tex_unit_map(). */
5069 return state->shader[WINED3D_SHADER_TYPE_VERTEX]
5070 && (!state->vertex_declaration || !state->vertex_declaration->position_transformed);
5073 static inline BOOL use_ps(const struct wined3d_state *state)
5075 return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
5078 static inline void context_apply_state(struct wined3d_context *context,
5079 const struct wined3d_state *state, DWORD state_id)
5081 const struct wined3d_state_entry *state_table = context->state_table;
5082 unsigned int rep = state_table[state_id].representative;
5083 state_table[rep].apply(context, state, rep);
5086 static inline BOOL is_srgb_enabled(const DWORD *sampler_states)
5088 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
5089 * the behaviour of the AMD Windows driver.
5091 * Might & Magic: Heroes VI - Shades of Darkness sets
5092 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
5093 * pointer—presumably by accident—and expects sRGB decoding to be
5094 * disabled. */
5095 return sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
5098 static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
5099 const struct wined3d_texture *texture)
5101 if (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
5102 return FALSE;
5104 if (!context->d3d_info->srgb_read_control
5105 && (texture->resource.bind_flags & WINED3D_BIND_SHADER_RESOURCE)
5106 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_READ))
5107 return TRUE;
5109 if (!context->d3d_info->srgb_write_control
5110 && (texture->resource.bind_flags & WINED3D_BIND_RENDER_TARGET)
5111 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE))
5112 return TRUE;
5114 return FALSE;
5117 static inline BOOL needs_srgb_write(const struct wined3d_context *context,
5118 const struct wined3d_state *state, const struct wined3d_fb_state *fb)
5120 return (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
5121 || state->render_states[WINED3D_RS_SRGBWRITEENABLE])
5122 && fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
5125 static inline GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl,
5126 const struct wined3d_context *context, BOOL srgb)
5128 return srgb && needs_separate_srgb_gl_texture(context, &texture_gl->t)
5129 ? texture_gl->texture_srgb.name : texture_gl->texture_rgb.name;
5132 static inline BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
5134 return d3d_info->texture_swizzle && !is_complex_fixup(format->color_fixup) && !is_scaling_fixup(format->color_fixup);
5137 static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
5139 return geometry_shader
5140 && geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
5143 static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
5144 unsigned int offset, unsigned int count)
5146 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5147 const unsigned int idx = offset / word_bit_count;
5148 const unsigned int shift = offset % word_bit_count;
5149 DWORD mask = (1u << count) - 1;
5150 DWORD ret;
5152 ret = (bitstream[idx] >> shift) & mask;
5153 if (shift + count > word_bit_count)
5155 const unsigned int extracted_bit_count = word_bit_count - shift;
5156 const unsigned int remaining_bit_count = count - extracted_bit_count;
5157 mask = (1u << remaining_bit_count) - 1;
5158 ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
5160 return ret;
5163 static inline void wined3d_insert_bits(DWORD *bitstream,
5164 unsigned int offset, unsigned int count, DWORD bits)
5166 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5167 const unsigned int idx = offset / word_bit_count;
5168 const unsigned int shift = offset % word_bit_count;
5169 DWORD mask = (1u << count) - 1;
5171 bitstream[idx] |= (bits & mask) << shift;
5172 if (shift + count > word_bit_count)
5174 const unsigned int inserted_bit_count = word_bit_count - shift;
5175 const unsigned int remaining_bit_count = count - inserted_bit_count;
5176 mask = (1u << remaining_bit_count) - 1;
5177 bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
5181 static inline void wined3d_from_cs(const struct wined3d_cs *cs)
5183 if (cs->thread)
5184 assert(cs->thread_id == GetCurrentThreadId());
5187 static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
5189 assert(cs->thread_id != GetCurrentThreadId());
5192 static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map,
5193 enum wined3d_material_color_source source)
5195 if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE))
5196 return source;
5197 if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR))
5198 return source;
5199 return WINED3D_MCS_MATERIAL;
5202 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse,
5203 enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient,
5204 enum wined3d_material_color_source *specular, const struct wined3d_state *state,
5205 const struct wined3d_stream_info *si)
5207 if (!state->render_states[WINED3D_RS_LIGHTING])
5209 *diffuse = WINED3D_MCS_COLOR1;
5210 *specular = WINED3D_MCS_COLOR2;
5211 *emissive = *ambient = WINED3D_MCS_MATERIAL;
5213 return;
5216 if (!state->render_states[WINED3D_RS_COLORVERTEX])
5218 *diffuse = *emissive = *ambient = *specular = WINED3D_MCS_MATERIAL;
5220 return;
5223 *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]);
5224 *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]);
5225 *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]);
5226 *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]);
5229 static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,
5230 const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
5232 struct wined3d_vec4 tmp;
5234 tmp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31 + v->w * m->_41;
5235 tmp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32 + v->w * m->_42;
5236 tmp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33 + v->w * m->_43;
5237 tmp.w = v->x * m->_14 + v->y * m->_24 + v->z * m->_34 + v->w * m->_44;
5239 *dst = tmp;
5242 BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
5244 void compute_normal_matrix(float *normal_matrix, BOOL legacy_lighting,
5245 const struct wined3d_matrix *modelview) DECLSPEC_HIDDEN;
5247 static inline struct wined3d_context *context_acquire(struct wined3d_device *device,
5248 struct wined3d_texture *texture, unsigned int sub_resource_idx)
5250 wined3d_from_cs(device->cs);
5252 return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx);
5255 static inline void context_release(struct wined3d_context *context)
5257 context->device->adapter->adapter_ops->adapter_release_context(context);
5260 static inline float wined3d_get_float_state(const struct wined3d_state *state, enum wined3d_render_state rs)
5262 union
5264 DWORD d;
5265 float f;
5267 tmpvalue;
5269 tmpvalue.d = state->render_states[rs];
5270 return tmpvalue.f;
5273 static inline void *wined3d_context_map_bo_address(struct wined3d_context *context,
5274 const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags)
5276 return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, bind_flags, map_flags);
5279 static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context,
5280 const struct wined3d_bo_address *data, uint32_t bind_flags,
5281 unsigned int range_count, const struct wined3d_range *ranges)
5283 context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, bind_flags, range_count, ranges);
5286 static inline void wined3d_context_copy_bo_address(struct wined3d_context *context,
5287 const struct wined3d_bo_address *dst, uint32_t dst_bind_flags,
5288 const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size)
5290 context->device->adapter->adapter_ops->adapter_copy_bo_address(context,
5291 dst, dst_bind_flags, src, src_bind_flags, size);
5294 static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view *dsv,
5295 const struct wined3d_format *srv_format)
5297 return !srv_format || (srv_format->red_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_DEPTH))
5298 || (srv_format->green_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_STENCIL));
5301 static inline BOOL wined3d_resource_check_fbo_attached(const struct wined3d_state *state,
5302 const struct wined3d_resource *resource, const struct wined3d_format *srv_format)
5304 struct wined3d_rendertarget_view * const *rts = &state->fb->render_targets[0];
5305 const struct wined3d_rendertarget_view *dsv;
5306 unsigned int i;
5308 if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
5309 && (dsv = state->fb->depth_stencil) && dsv->resource == resource
5310 && wined3d_dsv_srv_conflict(dsv, srv_format))
5311 return TRUE;
5313 if (!(resource->bind_flags & WINED3D_BIND_RENDER_TARGET))
5314 return FALSE;
5316 for (i = 0; i < MAX_RENDER_TARGET_VIEWS; ++i)
5317 if (rts[i] && rts[i]->resource == resource)
5318 return TRUE;
5320 return FALSE;
5323 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
5325 *min_z = vp->min_z;
5327 /* The magic constant is derived from tests. */
5328 *max_z = max(vp->max_z, vp->min_z + 0.001f);
5331 static inline BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx)
5333 return map[idx >> 5] & (1u << (idx & 0x1f));
5336 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap, unsigned int bit_count,
5337 unsigned int start, uint32_t xor_mask)
5339 const unsigned int word_bit_count = sizeof(*bitmap) * CHAR_BIT;
5340 const uint32_t *ptr, *end_ptr;
5341 uint32_t map, mask;
5343 assert(bit_count < word_bit_count || !(bit_count % word_bit_count));
5345 ptr = bitmap + start / word_bit_count;
5346 end_ptr = bitmap + (bit_count + word_bit_count - 1) / word_bit_count;
5348 if (ptr >= end_ptr)
5349 return ~0u;
5351 mask = ~0u << start % word_bit_count;
5352 map = (*ptr ^ xor_mask) & mask;
5353 while (!map)
5355 if (++ptr == end_ptr)
5356 return ~0u;
5357 map = *ptr ^ xor_mask;
5359 return (ptr - bitmap) * word_bit_count + wined3d_bit_scan(&map);
5362 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
5364 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, 0);
5367 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
5369 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, ~0u);
5372 static inline BOOL wined3d_bitmap_get_range(const DWORD *bitmap, unsigned int bit_count,
5373 unsigned int start, struct wined3d_range *range)
5375 unsigned int range_start, range_end;
5377 range_start = wined3d_bitmap_ffs(bitmap, bit_count, start);
5378 if (range_start == ~0u)
5379 return FALSE;
5381 range_end = wined3d_bitmap_ffz(bitmap, bit_count, range_start + 1);
5382 if (range_end == ~0u)
5383 range_end = bit_count;
5385 range->offset = range_start;
5386 range->size = range_end - range_start;
5387 return TRUE;
5390 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
5391 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
5393 #endif