ws2_32: Add support for hints in GetAddrInfoExW.
[wine.git] / dlls / wined3d / wined3d_private.h
blobc752be692fc132c879d8686eb889d1e5a1cd6f0d
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 <stdbool.h>
37 #include <math.h>
38 #include <limits.h>
39 #include "ntstatus.h"
40 #define WIN32_NO_STATUS
41 #define NONAMELESSUNION
42 #define NONAMELESSSTRUCT
43 #define COBJMACROS
44 #include "windef.h"
45 #include "winbase.h"
46 #include "winreg.h"
47 #include "wingdi.h"
48 #include "winuser.h"
49 #include "winternl.h"
50 #include "ddk/d3dkmthk.h"
51 #include "wine/debug.h"
52 #include "wine/heap.h"
53 #include "wine/unicode.h"
54 #ifdef HAVE_FLOAT_H
55 # include <float.h>
56 #endif
58 #include "objbase.h"
59 #include "wine/wined3d.h"
60 #include "wined3d_gl.h"
61 #include "wined3d_vk.h"
62 #include "wine/list.h"
63 #include "wine/rbtree.h"
64 #include "wine/wgl_driver.h"
66 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
68 /* Driver quirks */
69 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
70 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
71 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
72 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
73 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
74 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
75 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
76 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
77 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
78 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
80 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
82 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
83 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
85 #define WINED3D_BITMAP_SIZE(x) (((x) + 31) >> 5)
87 struct wined3d_fragment_pipe_ops;
88 struct wined3d_adapter;
89 struct wined3d_buffer_vk;
90 struct wined3d_context;
91 struct wined3d_context_vk;
92 struct wined3d_gl_info;
93 struct wined3d_state;
94 struct wined3d_swapchain_gl;
95 struct wined3d_texture_gl;
96 struct wined3d_vertex_pipe_ops;
98 enum wined3d_ffp_idx
100 WINED3D_FFP_POSITION = 0,
101 WINED3D_FFP_BLENDWEIGHT = 1,
102 WINED3D_FFP_BLENDINDICES = 2,
103 WINED3D_FFP_NORMAL = 3,
104 WINED3D_FFP_PSIZE = 4,
105 WINED3D_FFP_DIFFUSE = 5,
106 WINED3D_FFP_SPECULAR = 6,
107 WINED3D_FFP_TEXCOORD0 = 7,
108 WINED3D_FFP_TEXCOORD1 = 8,
109 WINED3D_FFP_TEXCOORD2 = 9,
110 WINED3D_FFP_TEXCOORD3 = 10,
111 WINED3D_FFP_TEXCOORD4 = 11,
112 WINED3D_FFP_TEXCOORD5 = 12,
113 WINED3D_FFP_TEXCOORD6 = 13,
114 WINED3D_FFP_TEXCOORD7 = 14,
115 WINED3D_FFP_ATTRIBS_COUNT = 15,
118 enum wined3d_ffp_emit_idx
120 WINED3D_FFP_EMIT_FLOAT1,
121 WINED3D_FFP_EMIT_FLOAT2,
122 WINED3D_FFP_EMIT_FLOAT3,
123 WINED3D_FFP_EMIT_FLOAT4,
124 WINED3D_FFP_EMIT_D3DCOLOR,
125 WINED3D_FFP_EMIT_UBYTE4,
126 WINED3D_FFP_EMIT_SHORT2,
127 WINED3D_FFP_EMIT_SHORT4,
128 WINED3D_FFP_EMIT_UBYTE4N,
129 WINED3D_FFP_EMIT_SHORT2N,
130 WINED3D_FFP_EMIT_SHORT4N,
131 WINED3D_FFP_EMIT_USHORT2N,
132 WINED3D_FFP_EMIT_USHORT4N,
133 WINED3D_FFP_EMIT_UDEC3,
134 WINED3D_FFP_EMIT_DEC3N,
135 WINED3D_FFP_EMIT_FLOAT16_2,
136 WINED3D_FFP_EMIT_FLOAT16_4,
137 WINED3D_FFP_EMIT_INVALID,
138 WINED3D_FFP_EMIT_COUNT,
141 /* Texture format fixups */
143 enum fixup_channel_source
145 CHANNEL_SOURCE_ZERO = 0,
146 CHANNEL_SOURCE_ONE = 1,
147 CHANNEL_SOURCE_X = 2,
148 CHANNEL_SOURCE_Y = 3,
149 CHANNEL_SOURCE_Z = 4,
150 CHANNEL_SOURCE_W = 5,
151 CHANNEL_SOURCE_COMPLEX0 = 6,
152 CHANNEL_SOURCE_COMPLEX1 = 7,
155 enum complex_fixup
157 COMPLEX_FIXUP_NONE = 0,
158 COMPLEX_FIXUP_YUY2 = 1,
159 COMPLEX_FIXUP_UYVY = 2,
160 COMPLEX_FIXUP_YV12 = 3,
161 COMPLEX_FIXUP_P8 = 4,
162 COMPLEX_FIXUP_NV12 = 5,
163 COMPLEX_FIXUP_YUV = 6,
166 #include <pshpack2.h>
167 struct color_fixup_desc
169 unsigned short x_sign_fixup : 1;
170 unsigned short x_source : 3;
171 unsigned short y_sign_fixup : 1;
172 unsigned short y_source : 3;
173 unsigned short z_sign_fixup : 1;
174 unsigned short z_source : 3;
175 unsigned short w_sign_fixup : 1;
176 unsigned short w_source : 3;
178 #include <poppack.h>
180 struct wined3d_d3d_limits
182 unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
183 DWORD vs_uniform_count;
184 DWORD ps_uniform_count;
185 unsigned int varying_count;
186 unsigned int ffp_textures;
187 unsigned int ffp_blend_stages;
188 unsigned int ffp_vertex_blend_matrices;
189 unsigned int active_light_count;
191 unsigned int max_rt_count;
192 unsigned int max_clip_distances;
193 unsigned int texture_size;
194 float pointsize_max;
197 typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
198 typedef void (WINE_GLAPI *wined3d_ffp_texcoord_func)(GLenum unit, const void *data);
199 typedef void (WINE_GLAPI *wined3d_generic_attrib_func)(GLuint idx, const void *data);
200 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
202 struct wined3d_ffp_attrib_ops
204 wined3d_ffp_attrib_func position[WINED3D_FFP_EMIT_COUNT];
205 wined3d_ffp_attrib_func diffuse[WINED3D_FFP_EMIT_COUNT];
206 wined3d_ffp_attrib_func specular[WINED3D_FFP_EMIT_COUNT];
207 wined3d_ffp_attrib_func normal[WINED3D_FFP_EMIT_COUNT];
208 wined3d_ffp_texcoord_func texcoord[WINED3D_FFP_EMIT_COUNT];
209 wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT];
212 struct wined3d_d3d_info
214 struct wined3d_d3d_limits limits;
215 struct wined3d_ffp_attrib_ops ffp_attrib_ops;
216 uint32_t wined3d_creation_flags;
217 uint32_t xyzrhw : 1;
218 uint32_t emulated_flatshading : 1;
219 uint32_t ffp_generic_attributes : 1;
220 uint32_t ffp_alpha_test : 1;
221 uint32_t vs_clipping : 1;
222 uint32_t shader_color_key : 1;
223 uint32_t shader_double_precision : 1;
224 uint32_t shader_output_interpolation : 1;
225 uint32_t viewport_array_index_any_shader : 1;
226 uint32_t texture_npot : 1;
227 uint32_t texture_npot_conditional : 1;
228 uint32_t draw_base_vertex_offset : 1;
229 uint32_t vertex_bgra : 1;
230 uint32_t texture_swizzle : 1;
231 uint32_t srgb_read_control : 1;
232 uint32_t srgb_write_control : 1;
233 uint32_t clip_control : 1;
234 uint32_t full_ffp_varyings : 1;
235 uint32_t scaled_resolve : 1;
236 enum wined3d_feature_level feature_level;
238 DWORD multisample_draw_location;
241 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
242 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
244 static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
246 struct color_fixup_desc fixup =
248 0u, complex_fixup & (1u << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
249 0u, complex_fixup & (1u << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
250 0u, complex_fixup & (1u << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
251 0u, complex_fixup & (1u << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
253 return fixup;
256 static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
258 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
261 static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
263 return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
266 static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
268 return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
271 static inline BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
273 return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
274 && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
275 && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
276 && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
279 static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
281 enum complex_fixup complex_fixup = 0;
282 if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
283 if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
284 if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
285 if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
286 return complex_fixup;
289 /* Device caps */
290 #define WINED3D_MAX_ACTIVE_LIGHTS 8
291 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
292 #define MAX_CONSTANT_BUFFERS 15
293 #define MAX_SAMPLER_OBJECTS 16
294 #define MAX_SHADER_RESOURCE_VIEWS 128
295 #define MAX_UNORDERED_ACCESS_VIEWS 8
296 #define MAX_TGSM_REGISTERS 8192
297 #define MAX_VERTEX_BLENDS 4
299 struct min_lookup
301 GLenum mip[WINED3D_TEXF_LINEAR + 1];
304 extern const struct min_lookup minMipLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
305 extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
307 GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN;
308 VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
309 VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op) DECLSPEC_HIDDEN;
310 VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags) DECLSPEC_HIDDEN;
311 VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
312 VkShaderStageFlagBits vk_shader_stage_from_wined3d(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
314 static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
316 if (func < WINED3D_CMP_NEVER || func > WINED3D_CMP_ALWAYS)
317 return WINED3D_CMP_ALWAYS;
318 return func;
321 static inline GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
323 return magLookup[mag_filter];
326 static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,
327 enum wined3d_texture_filter_type mip_filter)
329 return minMipLookup[min_filter].mip[mip_filter];
332 #ifdef HAVE_IEEEFP_H
333 #include <ieeefp.h>
334 #endif
336 #if !defined(HAVE_ISFINITE) && !defined(isfinite)
337 static inline int isfinite(double x) { return finite(x); }
338 #endif
340 #if !defined(HAVE_ISINF) && !defined(isinf)
341 static inline int isinf(double x) { return (!(finite(x) || isnand(x))); }
342 #endif
344 #if !defined(HAVE_ISNAN) && !defined(isnan)
345 static inline int isnan(double x) { return isnand(x); }
346 #endif
348 #ifndef INFINITY
349 static inline float __port_infinity(void)
351 static const unsigned __inf_bytes = 0x7f800000;
352 return *(const float *)&__inf_bytes;
354 #define INFINITY __port_infinity()
355 #endif
357 #ifndef NAN
358 static inline float __port_nan(void)
360 static const unsigned __nan_bytes = 0x7fc00000;
361 return *(const float *)&__nan_bytes;
363 #define NAN __port_nan()
364 #endif
366 /* float_16_to_32() and float_32_to_16() (see implementation in
367 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
368 * to standard C floats and vice versa. They do not depend on the encoding
369 * of the C float, so they are platform independent, but slow. On x86 and
370 * other IEEE 754 compliant platforms the conversion can be accelerated by
371 * bit shifting the exponent and mantissa. There are also some SSE-based
372 * assembly routines out there.
374 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
376 static inline float float_16_to_32(const unsigned short *in)
378 const unsigned short s = ((*in) & 0x8000u);
379 const unsigned short e = ((*in) & 0x7c00u) >> 10;
380 const unsigned short m = (*in) & 0x3ffu;
381 const float sgn = (s ? -1.0f : 1.0f);
383 if(e == 0) {
384 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
385 else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
386 } else if(e < 31) {
387 return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
388 } else {
389 if(m == 0) return sgn * INFINITY;
390 else return NAN;
394 static inline float float_24_to_32(DWORD in)
396 const float sgn = in & 0x800000u ? -1.0f : 1.0f;
397 const unsigned short e = (in & 0x780000u) >> 19;
398 const unsigned int m = in & 0x7ffffu;
400 if (e == 0)
402 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
403 else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
405 else if (e < 15)
407 return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
409 else
411 if (m == 0) return sgn * INFINITY;
412 else return NAN;
416 static inline unsigned int wined3d_popcount(unsigned int x)
418 #ifdef HAVE___BUILTIN_POPCOUNT
419 return __builtin_popcount(x);
420 #else
421 x -= x >> 1 & 0x55555555;
422 x = (x & 0x33333333) + (x >> 2 & 0x33333333);
423 return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
424 #endif
427 #define ORM_BACKBUFFER 0
428 #define ORM_FBO 1
430 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
431 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
433 enum wined3d_renderer
435 WINED3D_RENDERER_AUTO,
436 WINED3D_RENDERER_VULKAN,
437 WINED3D_RENDERER_OPENGL,
438 WINED3D_RENDERER_NO3D,
441 enum wined3d_shader_backend
443 WINED3D_SHADER_BACKEND_AUTO,
444 WINED3D_SHADER_BACKEND_GLSL,
445 WINED3D_SHADER_BACKEND_ARB,
446 WINED3D_SHADER_BACKEND_NONE,
449 #define WINED3D_CSMT_ENABLE 0x00000001
450 #define WINED3D_CSMT_SERIALIZE 0x00000002
452 /* NOTE: When adding fields to this structure, make sure to update the default
453 * values in wined3d_main.c as well. */
454 struct wined3d_settings
456 unsigned int cs_multithreaded;
457 DWORD max_gl_version;
458 int offscreen_rendering_mode;
459 unsigned short pci_vendor_id;
460 unsigned short pci_device_id;
461 /* Memory tracking and object counting. */
462 UINT64 emulated_textureram;
463 char *logo;
464 unsigned int multisample_textures;
465 unsigned int sample_count;
466 BOOL check_float_constants;
467 unsigned int strict_shader_math;
468 unsigned int max_sm_vs;
469 unsigned int max_sm_hs;
470 unsigned int max_sm_ds;
471 unsigned int max_sm_gs;
472 unsigned int max_sm_ps;
473 unsigned int max_sm_cs;
474 enum wined3d_renderer renderer;
475 enum wined3d_shader_backend shader_backend;
478 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
480 enum wined3d_shader_byte_code_format
482 WINED3D_SHADER_BYTE_CODE_FORMAT_SM1,
483 WINED3D_SHADER_BYTE_CODE_FORMAT_SM4,
486 enum wined3d_shader_resource_type
488 WINED3D_SHADER_RESOURCE_NONE,
489 WINED3D_SHADER_RESOURCE_BUFFER,
490 WINED3D_SHADER_RESOURCE_TEXTURE_1D,
491 WINED3D_SHADER_RESOURCE_TEXTURE_2D,
492 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
493 WINED3D_SHADER_RESOURCE_TEXTURE_3D,
494 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
495 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
496 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
497 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
498 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
501 #define WINED3D_SHADER_CONST_VS_F 0x00000001
502 #define WINED3D_SHADER_CONST_VS_I 0x00000002
503 #define WINED3D_SHADER_CONST_VS_B 0x00000004
504 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
505 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
506 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
507 #define WINED3D_SHADER_CONST_PS_F 0x00000040
508 #define WINED3D_SHADER_CONST_PS_I 0x00000080
509 #define WINED3D_SHADER_CONST_PS_B 0x00000100
510 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
511 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
512 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
513 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
514 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
515 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
516 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
517 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
518 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
519 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
520 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
521 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
522 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
523 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
525 enum wined3d_shader_register_type
527 WINED3DSPR_TEMP = 0,
528 WINED3DSPR_INPUT = 1,
529 WINED3DSPR_CONST = 2,
530 WINED3DSPR_ADDR = 3,
531 WINED3DSPR_TEXTURE = 3,
532 WINED3DSPR_RASTOUT = 4,
533 WINED3DSPR_ATTROUT = 5,
534 WINED3DSPR_TEXCRDOUT = 6,
535 WINED3DSPR_OUTPUT = 6,
536 WINED3DSPR_CONSTINT = 7,
537 WINED3DSPR_COLOROUT = 8,
538 WINED3DSPR_DEPTHOUT = 9,
539 WINED3DSPR_SAMPLER = 10,
540 WINED3DSPR_CONST2 = 11,
541 WINED3DSPR_CONST3 = 12,
542 WINED3DSPR_CONST4 = 13,
543 WINED3DSPR_CONSTBOOL = 14,
544 WINED3DSPR_LOOP = 15,
545 WINED3DSPR_TEMPFLOAT16 = 16,
546 WINED3DSPR_MISCTYPE = 17,
547 WINED3DSPR_LABEL = 18,
548 WINED3DSPR_PREDICATE = 19,
549 WINED3DSPR_IMMCONST,
550 WINED3DSPR_CONSTBUFFER,
551 WINED3DSPR_IMMCONSTBUFFER,
552 WINED3DSPR_PRIMID,
553 WINED3DSPR_NULL,
554 WINED3DSPR_RESOURCE,
555 WINED3DSPR_UAV,
556 WINED3DSPR_OUTPOINTID,
557 WINED3DSPR_FORKINSTID,
558 WINED3DSPR_JOININSTID,
559 WINED3DSPR_INCONTROLPOINT,
560 WINED3DSPR_OUTCONTROLPOINT,
561 WINED3DSPR_PATCHCONST,
562 WINED3DSPR_TESSCOORD,
563 WINED3DSPR_GROUPSHAREDMEM,
564 WINED3DSPR_THREADID,
565 WINED3DSPR_THREADGROUPID,
566 WINED3DSPR_LOCALTHREADID,
567 WINED3DSPR_LOCALTHREADINDEX,
568 WINED3DSPR_IDXTEMP,
569 WINED3DSPR_STREAM,
570 WINED3DSPR_FUNCTIONBODY,
571 WINED3DSPR_FUNCTIONPOINTER,
572 WINED3DSPR_COVERAGE,
573 WINED3DSPR_SAMPLEMASK,
574 WINED3DSPR_GSINSTID,
575 WINED3DSPR_DEPTHOUTGE,
576 WINED3DSPR_DEPTHOUTLE,
577 WINED3DSPR_RASTERIZER,
580 enum wined3d_data_type
582 WINED3D_DATA_FLOAT,
583 WINED3D_DATA_INT,
584 WINED3D_DATA_RESOURCE,
585 WINED3D_DATA_SAMPLER,
586 WINED3D_DATA_UAV,
587 WINED3D_DATA_UINT,
588 WINED3D_DATA_UNORM,
589 WINED3D_DATA_SNORM,
590 WINED3D_DATA_OPAQUE,
593 enum wined3d_immconst_type
595 WINED3D_IMMCONST_SCALAR,
596 WINED3D_IMMCONST_VEC4,
599 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
601 enum wined3d_shader_src_modifier
603 WINED3DSPSM_NONE = 0,
604 WINED3DSPSM_NEG = 1,
605 WINED3DSPSM_BIAS = 2,
606 WINED3DSPSM_BIASNEG = 3,
607 WINED3DSPSM_SIGN = 4,
608 WINED3DSPSM_SIGNNEG = 5,
609 WINED3DSPSM_COMP = 6,
610 WINED3DSPSM_X2 = 7,
611 WINED3DSPSM_X2NEG = 8,
612 WINED3DSPSM_DZ = 9,
613 WINED3DSPSM_DW = 10,
614 WINED3DSPSM_ABS = 11,
615 WINED3DSPSM_ABSNEG = 12,
616 WINED3DSPSM_NOT = 13,
619 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
620 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
621 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
622 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
623 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
625 enum wined3d_shader_dst_modifier
627 WINED3DSPDM_NONE = 0,
628 WINED3DSPDM_SATURATE = 1,
629 WINED3DSPDM_PARTIALPRECISION = 2,
630 WINED3DSPDM_MSAMPCENTROID = 4,
633 enum wined3d_shader_interpolation_mode
635 WINED3DSIM_NONE = 0,
636 WINED3DSIM_CONSTANT = 1,
637 WINED3DSIM_LINEAR = 2,
638 WINED3DSIM_LINEAR_CENTROID = 3,
639 WINED3DSIM_LINEAR_NOPERSPECTIVE = 4,
640 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
641 WINED3DSIM_LINEAR_SAMPLE = 6,
642 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
645 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
646 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
648 enum wined3d_shader_global_flags
650 WINED3DSGF_REFACTORING_ALLOWED = 0x1,
651 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4,
652 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8,
655 enum wined3d_shader_sync_flags
657 WINED3DSSF_THREAD_GROUP = 0x1,
658 WINED3DSSF_GROUP_SHARED_MEMORY = 0x2,
659 WINED3DSSF_GLOBAL_UAV = 0x8,
662 enum wined3d_shader_uav_flags
664 WINED3DSUF_GLOBALLY_COHERENT = 0x2,
665 WINED3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
668 enum wined3d_tessellator_domain
670 WINED3D_TESSELLATOR_DOMAIN_LINE = 1,
671 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
672 WINED3D_TESSELLATOR_DOMAIN_QUAD = 3,
675 enum wined3d_tessellator_output_primitive
677 WINED3D_TESSELLATOR_OUTPUT_POINT = 1,
678 WINED3D_TESSELLATOR_OUTPUT_LINE = 2,
679 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
680 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
683 enum wined3d_tessellator_partitioning
685 WINED3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
686 WINED3D_TESSELLATOR_PARTITIONING_POW2 = 2,
687 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
688 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
691 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
692 #define WINED3DSI_TEXLD_PROJECT 0x1
693 #define WINED3DSI_TEXLD_BIAS 0x2
694 #define WINED3DSI_INDEXED_DYNAMIC 0x4
695 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
696 #define WINED3DSI_RESINFO_UINT 0x2
697 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
698 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
700 #define WINED3DSI_PRECISE_X 0x100
701 #define WINED3DSI_PRECISE_Y 0x200
702 #define WINED3DSI_PRECISE_Z 0x400
703 #define WINED3DSI_PRECISE_W 0x800
704 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
705 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
706 #define WINED3DSI_PRECISE_SHIFT 8
708 enum wined3d_shader_rel_op
710 WINED3D_SHADER_REL_OP_GT = 1,
711 WINED3D_SHADER_REL_OP_EQ = 2,
712 WINED3D_SHADER_REL_OP_GE = 3,
713 WINED3D_SHADER_REL_OP_LT = 4,
714 WINED3D_SHADER_REL_OP_NE = 5,
715 WINED3D_SHADER_REL_OP_LE = 6,
718 enum wined3d_shader_conditional_op
720 WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
721 WINED3D_SHADER_CONDITIONAL_OP_Z = 1
724 #define WINED3D_SM1_VS 0xfffeu
725 #define WINED3D_SM1_PS 0xffffu
726 #define WINED3D_SM4_PS 0x0000u
727 #define WINED3D_SM4_VS 0x0001u
728 #define WINED3D_SM4_GS 0x0002u
729 #define WINED3D_SM5_HS 0x0003u
730 #define WINED3D_SM5_DS 0x0004u
731 #define WINED3D_SM5_CS 0x0005u
733 /* Shader version tokens, and shader end tokens */
734 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
735 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
737 /* Shader backends */
739 /* TODO: Make this dynamic, based on shader limits ? */
740 #define MAX_ATTRIBS 16
741 #define MAX_REG_ADDR 1
742 #define MAX_REG_TEXCRD 8
743 #define MAX_REG_INPUT 32
744 #define MAX_REG_OUTPUT 32
745 #define WINED3D_MAX_CBS 15
747 /* FIXME: This needs to go up to 2048 for
748 * Shader model 3 according to msdn (and for software shaders) */
749 #define MAX_LABELS 16
751 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
753 struct wined3d_string_buffer
755 struct list entry;
756 char *buffer;
757 unsigned int buffer_size;
758 unsigned int content_size;
761 enum WINED3D_SHADER_INSTRUCTION_HANDLER
763 WINED3DSIH_ABS,
764 WINED3DSIH_ADD,
765 WINED3DSIH_AND,
766 WINED3DSIH_ATOMIC_AND,
767 WINED3DSIH_ATOMIC_CMP_STORE,
768 WINED3DSIH_ATOMIC_IADD,
769 WINED3DSIH_ATOMIC_IMAX,
770 WINED3DSIH_ATOMIC_IMIN,
771 WINED3DSIH_ATOMIC_OR,
772 WINED3DSIH_ATOMIC_UMAX,
773 WINED3DSIH_ATOMIC_UMIN,
774 WINED3DSIH_ATOMIC_XOR,
775 WINED3DSIH_BEM,
776 WINED3DSIH_BFI,
777 WINED3DSIH_BFREV,
778 WINED3DSIH_BREAK,
779 WINED3DSIH_BREAKC,
780 WINED3DSIH_BREAKP,
781 WINED3DSIH_BUFINFO,
782 WINED3DSIH_CALL,
783 WINED3DSIH_CALLNZ,
784 WINED3DSIH_CASE,
785 WINED3DSIH_CMP,
786 WINED3DSIH_CND,
787 WINED3DSIH_CONTINUE,
788 WINED3DSIH_CONTINUEP,
789 WINED3DSIH_COUNTBITS,
790 WINED3DSIH_CRS,
791 WINED3DSIH_CUT,
792 WINED3DSIH_CUT_STREAM,
793 WINED3DSIH_DCL,
794 WINED3DSIH_DCL_CONSTANT_BUFFER,
795 WINED3DSIH_DCL_FUNCTION_BODY,
796 WINED3DSIH_DCL_FUNCTION_TABLE,
797 WINED3DSIH_DCL_GLOBAL_FLAGS,
798 WINED3DSIH_DCL_GS_INSTANCES,
799 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT,
800 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT,
801 WINED3DSIH_DCL_HS_MAX_TESSFACTOR,
802 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
803 WINED3DSIH_DCL_INDEX_RANGE,
804 WINED3DSIH_DCL_INDEXABLE_TEMP,
805 WINED3DSIH_DCL_INPUT,
806 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT,
807 WINED3DSIH_DCL_INPUT_PRIMITIVE,
808 WINED3DSIH_DCL_INPUT_PS,
809 WINED3DSIH_DCL_INPUT_PS_SGV,
810 WINED3DSIH_DCL_INPUT_PS_SIV,
811 WINED3DSIH_DCL_INPUT_SGV,
812 WINED3DSIH_DCL_INPUT_SIV,
813 WINED3DSIH_DCL_INTERFACE,
814 WINED3DSIH_DCL_OUTPUT,
815 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT,
816 WINED3DSIH_DCL_OUTPUT_SIV,
817 WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
818 WINED3DSIH_DCL_RESOURCE_RAW,
819 WINED3DSIH_DCL_RESOURCE_STRUCTURED,
820 WINED3DSIH_DCL_SAMPLER,
821 WINED3DSIH_DCL_STREAM,
822 WINED3DSIH_DCL_TEMPS,
823 WINED3DSIH_DCL_TESSELLATOR_DOMAIN,
824 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE,
825 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING,
826 WINED3DSIH_DCL_TGSM_RAW,
827 WINED3DSIH_DCL_TGSM_STRUCTURED,
828 WINED3DSIH_DCL_THREAD_GROUP,
829 WINED3DSIH_DCL_UAV_RAW,
830 WINED3DSIH_DCL_UAV_STRUCTURED,
831 WINED3DSIH_DCL_UAV_TYPED,
832 WINED3DSIH_DCL_VERTICES_OUT,
833 WINED3DSIH_DEF,
834 WINED3DSIH_DEFAULT,
835 WINED3DSIH_DEFB,
836 WINED3DSIH_DEFI,
837 WINED3DSIH_DIV,
838 WINED3DSIH_DP2,
839 WINED3DSIH_DP2ADD,
840 WINED3DSIH_DP3,
841 WINED3DSIH_DP4,
842 WINED3DSIH_DST,
843 WINED3DSIH_DSX,
844 WINED3DSIH_DSX_COARSE,
845 WINED3DSIH_DSX_FINE,
846 WINED3DSIH_DSY,
847 WINED3DSIH_DSY_COARSE,
848 WINED3DSIH_DSY_FINE,
849 WINED3DSIH_ELSE,
850 WINED3DSIH_EMIT,
851 WINED3DSIH_EMIT_STREAM,
852 WINED3DSIH_ENDIF,
853 WINED3DSIH_ENDLOOP,
854 WINED3DSIH_ENDREP,
855 WINED3DSIH_ENDSWITCH,
856 WINED3DSIH_EQ,
857 WINED3DSIH_EVAL_SAMPLE_INDEX,
858 WINED3DSIH_EXP,
859 WINED3DSIH_EXPP,
860 WINED3DSIH_F16TOF32,
861 WINED3DSIH_F32TOF16,
862 WINED3DSIH_FCALL,
863 WINED3DSIH_FIRSTBIT_HI,
864 WINED3DSIH_FIRSTBIT_LO,
865 WINED3DSIH_FIRSTBIT_SHI,
866 WINED3DSIH_FRC,
867 WINED3DSIH_FTOI,
868 WINED3DSIH_FTOU,
869 WINED3DSIH_GATHER4,
870 WINED3DSIH_GATHER4_C,
871 WINED3DSIH_GATHER4_PO,
872 WINED3DSIH_GATHER4_PO_C,
873 WINED3DSIH_GE,
874 WINED3DSIH_HS_CONTROL_POINT_PHASE,
875 WINED3DSIH_HS_DECLS,
876 WINED3DSIH_HS_FORK_PHASE,
877 WINED3DSIH_HS_JOIN_PHASE,
878 WINED3DSIH_IADD,
879 WINED3DSIH_IBFE,
880 WINED3DSIH_IEQ,
881 WINED3DSIH_IF,
882 WINED3DSIH_IFC,
883 WINED3DSIH_IGE,
884 WINED3DSIH_ILT,
885 WINED3DSIH_IMAD,
886 WINED3DSIH_IMAX,
887 WINED3DSIH_IMIN,
888 WINED3DSIH_IMM_ATOMIC_ALLOC,
889 WINED3DSIH_IMM_ATOMIC_AND,
890 WINED3DSIH_IMM_ATOMIC_CMP_EXCH,
891 WINED3DSIH_IMM_ATOMIC_CONSUME,
892 WINED3DSIH_IMM_ATOMIC_EXCH,
893 WINED3DSIH_IMM_ATOMIC_IADD,
894 WINED3DSIH_IMM_ATOMIC_IMAX,
895 WINED3DSIH_IMM_ATOMIC_IMIN,
896 WINED3DSIH_IMM_ATOMIC_OR,
897 WINED3DSIH_IMM_ATOMIC_UMAX,
898 WINED3DSIH_IMM_ATOMIC_UMIN,
899 WINED3DSIH_IMM_ATOMIC_XOR,
900 WINED3DSIH_IMUL,
901 WINED3DSIH_INE,
902 WINED3DSIH_INEG,
903 WINED3DSIH_ISHL,
904 WINED3DSIH_ISHR,
905 WINED3DSIH_ITOF,
906 WINED3DSIH_LABEL,
907 WINED3DSIH_LD,
908 WINED3DSIH_LD2DMS,
909 WINED3DSIH_LD_RAW,
910 WINED3DSIH_LD_STRUCTURED,
911 WINED3DSIH_LD_UAV_TYPED,
912 WINED3DSIH_LIT,
913 WINED3DSIH_LOD,
914 WINED3DSIH_LOG,
915 WINED3DSIH_LOGP,
916 WINED3DSIH_LOOP,
917 WINED3DSIH_LRP,
918 WINED3DSIH_LT,
919 WINED3DSIH_M3x2,
920 WINED3DSIH_M3x3,
921 WINED3DSIH_M3x4,
922 WINED3DSIH_M4x3,
923 WINED3DSIH_M4x4,
924 WINED3DSIH_MAD,
925 WINED3DSIH_MAX,
926 WINED3DSIH_MIN,
927 WINED3DSIH_MOV,
928 WINED3DSIH_MOVA,
929 WINED3DSIH_MOVC,
930 WINED3DSIH_MUL,
931 WINED3DSIH_NE,
932 WINED3DSIH_NOP,
933 WINED3DSIH_NOT,
934 WINED3DSIH_NRM,
935 WINED3DSIH_OR,
936 WINED3DSIH_PHASE,
937 WINED3DSIH_POW,
938 WINED3DSIH_RCP,
939 WINED3DSIH_REP,
940 WINED3DSIH_RESINFO,
941 WINED3DSIH_RET,
942 WINED3DSIH_RETP,
943 WINED3DSIH_ROUND_NE,
944 WINED3DSIH_ROUND_NI,
945 WINED3DSIH_ROUND_PI,
946 WINED3DSIH_ROUND_Z,
947 WINED3DSIH_RSQ,
948 WINED3DSIH_SAMPLE,
949 WINED3DSIH_SAMPLE_B,
950 WINED3DSIH_SAMPLE_C,
951 WINED3DSIH_SAMPLE_C_LZ,
952 WINED3DSIH_SAMPLE_GRAD,
953 WINED3DSIH_SAMPLE_INFO,
954 WINED3DSIH_SAMPLE_LOD,
955 WINED3DSIH_SAMPLE_POS,
956 WINED3DSIH_SETP,
957 WINED3DSIH_SGE,
958 WINED3DSIH_SGN,
959 WINED3DSIH_SINCOS,
960 WINED3DSIH_SLT,
961 WINED3DSIH_SQRT,
962 WINED3DSIH_STORE_RAW,
963 WINED3DSIH_STORE_STRUCTURED,
964 WINED3DSIH_STORE_UAV_TYPED,
965 WINED3DSIH_SUB,
966 WINED3DSIH_SWAPC,
967 WINED3DSIH_SWITCH,
968 WINED3DSIH_SYNC,
969 WINED3DSIH_TEX,
970 WINED3DSIH_TEXBEM,
971 WINED3DSIH_TEXBEML,
972 WINED3DSIH_TEXCOORD,
973 WINED3DSIH_TEXDEPTH,
974 WINED3DSIH_TEXDP3,
975 WINED3DSIH_TEXDP3TEX,
976 WINED3DSIH_TEXKILL,
977 WINED3DSIH_TEXLDD,
978 WINED3DSIH_TEXLDL,
979 WINED3DSIH_TEXM3x2DEPTH,
980 WINED3DSIH_TEXM3x2PAD,
981 WINED3DSIH_TEXM3x2TEX,
982 WINED3DSIH_TEXM3x3,
983 WINED3DSIH_TEXM3x3DIFF,
984 WINED3DSIH_TEXM3x3PAD,
985 WINED3DSIH_TEXM3x3SPEC,
986 WINED3DSIH_TEXM3x3TEX,
987 WINED3DSIH_TEXM3x3VSPEC,
988 WINED3DSIH_TEXREG2AR,
989 WINED3DSIH_TEXREG2GB,
990 WINED3DSIH_TEXREG2RGB,
991 WINED3DSIH_UBFE,
992 WINED3DSIH_UDIV,
993 WINED3DSIH_UGE,
994 WINED3DSIH_ULT,
995 WINED3DSIH_UMAX,
996 WINED3DSIH_UMIN,
997 WINED3DSIH_UMUL,
998 WINED3DSIH_USHR,
999 WINED3DSIH_UTOF,
1000 WINED3DSIH_XOR,
1001 WINED3DSIH_TABLE_SIZE
1004 struct wined3d_shader_version
1006 enum wined3d_shader_type type;
1007 BYTE major;
1008 BYTE minor;
1011 struct wined3d_shader_resource_info
1013 enum wined3d_shader_resource_type type;
1014 enum wined3d_data_type data_type;
1015 unsigned int flags;
1016 unsigned int stride;
1019 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1021 struct wined3d_shader_sampler_map_entry
1023 unsigned int resource_idx;
1024 unsigned int sampler_idx;
1025 unsigned int bind_idx;
1028 struct wined3d_shader_sampler_map
1030 struct wined3d_shader_sampler_map_entry *entries;
1031 size_t size;
1032 size_t count;
1035 struct wined3d_shader_immediate_constant_buffer
1037 unsigned int vec4_count;
1038 DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
1041 struct wined3d_shader_indexable_temp
1043 struct list entry;
1044 unsigned int register_idx;
1045 unsigned int register_size;
1046 unsigned int component_count;
1049 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1051 struct wined3d_shader_reg_maps
1053 struct wined3d_shader_version shader_version;
1054 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
1055 BYTE address; /* MAX_REG_ADDR, 1 */
1056 WORD labels; /* MAX_LABELS, 16 */
1057 DWORD temporary; /* 32 */
1058 unsigned int temporary_count;
1059 DWORD *constf; /* pixel, vertex */
1060 struct list indexable_temps;
1061 const struct wined3d_shader_immediate_constant_buffer *icb;
1062 union
1064 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1065 BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1066 } u;
1067 DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1068 DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1069 WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1070 WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1071 WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1072 WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1073 UINT cb_sizes[WINED3D_MAX_CBS];
1074 uint32_t cb_map; /* WINED3D_MAX_CBS, 15 */
1076 struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS];
1077 uint32_t resource_map[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS)];
1078 struct wined3d_shader_sampler_map sampler_map;
1079 DWORD sampler_comparison_mode;
1080 BYTE bumpmat; /* WINED3D_MAX_TEXTURES, 8 */
1081 BYTE luminanceparams; /* WINED3D_MAX_TEXTURES, 8 */
1082 struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
1083 DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1084 DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1086 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1087 DWORD cull_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1088 DWORD usesnrm : 1;
1089 DWORD vpos : 1;
1090 DWORD usesdsx : 1;
1091 DWORD usesdsy : 1;
1092 DWORD usestexldd : 1;
1093 DWORD usesmova : 1;
1094 DWORD usesfacing : 1;
1095 DWORD usesrelconstF : 1;
1096 DWORD fog : 1;
1097 DWORD usestexldl : 1;
1098 DWORD usesifc : 1;
1099 DWORD usescall : 1;
1100 DWORD usespow : 1;
1101 DWORD point_size : 1;
1102 DWORD vocp : 1;
1103 DWORD input_rel_addressing : 1;
1104 DWORD viewport_array : 1;
1105 DWORD sample_mask : 1;
1106 DWORD padding : 14;
1108 DWORD rt_mask; /* Used render targets, 32 max. */
1110 /* Whether or not loops are used in this shader, and nesting depth */
1111 unsigned int loop_depth;
1112 unsigned int min_rel_offset, max_rel_offset;
1114 struct wined3d_shader_tgsm *tgsm;
1115 SIZE_T tgsm_capacity;
1116 unsigned int tgsm_count;
1119 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1120 * state information between multiple instructions. */
1121 struct wined3d_shader_tex_mx
1123 unsigned int current_row;
1124 DWORD texcoord_w[2];
1127 struct wined3d_shader_parser_state
1129 unsigned int current_loop_depth;
1130 unsigned int current_loop_reg;
1131 BOOL in_subroutine;
1134 struct wined3d_shader_context
1136 const struct wined3d_shader *shader;
1137 const struct wined3d_shader_reg_maps *reg_maps;
1138 struct wined3d_string_buffer *buffer;
1139 struct wined3d_shader_tex_mx *tex_mx;
1140 struct wined3d_shader_parser_state *state;
1141 void *backend_data;
1144 struct wined3d_shader_register_index
1146 const struct wined3d_shader_src_param *rel_addr;
1147 unsigned int offset;
1150 struct wined3d_shader_register
1152 enum wined3d_shader_register_type type;
1153 enum wined3d_data_type data_type;
1154 struct wined3d_shader_register_index idx[2];
1155 enum wined3d_immconst_type immconst_type;
1156 union
1158 DWORD immconst_data[4];
1159 unsigned fp_body_idx;
1160 } u;
1163 struct wined3d_shader_dst_param
1165 struct wined3d_shader_register reg;
1166 DWORD write_mask;
1167 DWORD modifiers;
1168 DWORD shift;
1171 struct wined3d_shader_src_param
1173 struct wined3d_shader_register reg;
1174 DWORD swizzle;
1175 enum wined3d_shader_src_modifier modifiers;
1178 struct wined3d_shader_index_range
1180 struct wined3d_shader_dst_param first_register;
1181 unsigned int last_register;
1184 struct wined3d_shader_semantic
1186 enum wined3d_decl_usage usage;
1187 UINT usage_idx;
1188 enum wined3d_shader_resource_type resource_type;
1189 enum wined3d_data_type resource_data_type;
1190 struct wined3d_shader_dst_param reg;
1193 enum wined3d_shader_input_sysval_semantic
1195 WINED3D_SIV_POSITION = 1,
1196 WINED3D_SIV_CLIP_DISTANCE = 2,
1197 WINED3D_SIV_CULL_DISTANCE = 3,
1198 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
1199 WINED3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
1200 WINED3D_SIV_VERTEX_ID = 6,
1201 WINED3D_SIV_PRIMITIVE_ID = 7,
1202 WINED3D_SIV_INSTANCE_ID = 8,
1203 WINED3D_SIV_IS_FRONT_FACE = 9,
1204 WINED3D_SIV_SAMPLE_INDEX = 10,
1205 WINED3D_SIV_QUAD_U0_TESS_FACTOR = 11,
1206 WINED3D_SIV_QUAD_V0_TESS_FACTOR = 12,
1207 WINED3D_SIV_QUAD_U1_TESS_FACTOR = 13,
1208 WINED3D_SIV_QUAD_V1_TESS_FACTOR = 14,
1209 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
1210 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
1211 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
1212 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
1213 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
1214 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
1215 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
1216 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
1219 struct wined3d_shader_register_semantic
1221 struct wined3d_shader_dst_param reg;
1222 enum wined3d_shader_input_sysval_semantic sysval_semantic;
1225 struct wined3d_shader_structured_resource
1227 struct wined3d_shader_dst_param reg;
1228 unsigned int byte_stride;
1231 struct wined3d_shader_tgsm
1233 unsigned int size;
1234 unsigned int stride;
1237 struct wined3d_shader_tgsm_raw
1239 struct wined3d_shader_dst_param reg;
1240 unsigned int byte_count;
1243 struct wined3d_shader_tgsm_structured
1245 struct wined3d_shader_dst_param reg;
1246 unsigned int byte_stride;
1247 unsigned int structure_count;
1250 struct wined3d_shader_thread_group_size
1252 unsigned int x, y, z;
1255 struct wined3d_shader_function_table_pointer
1257 unsigned int index;
1258 unsigned int array_size;
1259 unsigned int body_count;
1260 unsigned int table_count;
1263 struct wined3d_shader_texel_offset
1265 signed char u, v, w;
1268 struct wined3d_shader_primitive_type
1270 enum wined3d_primitive_type type;
1271 unsigned int patch_vertex_count;
1274 struct wined3d_shader_instruction
1276 const struct wined3d_shader_context *ctx;
1277 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
1278 DWORD flags;
1279 unsigned int dst_count;
1280 unsigned int src_count;
1281 const struct wined3d_shader_dst_param *dst;
1282 const struct wined3d_shader_src_param *src;
1283 struct wined3d_shader_texel_offset texel_offset;
1284 enum wined3d_shader_resource_type resource_type;
1285 enum wined3d_data_type resource_data_type;
1286 BOOL coissue;
1287 const struct wined3d_shader_src_param *predicate;
1288 union
1290 struct wined3d_shader_semantic semantic;
1291 struct wined3d_shader_register_semantic register_semantic;
1292 struct wined3d_shader_primitive_type primitive_type;
1293 struct wined3d_shader_dst_param dst;
1294 struct wined3d_shader_src_param src;
1295 unsigned int count;
1296 unsigned int index;
1297 const struct wined3d_shader_immediate_constant_buffer *icb;
1298 struct wined3d_shader_structured_resource structured_resource;
1299 struct wined3d_shader_tgsm_raw tgsm_raw;
1300 struct wined3d_shader_tgsm_structured tgsm_structured;
1301 struct wined3d_shader_thread_group_size thread_group_size;
1302 enum wined3d_tessellator_domain tessellator_domain;
1303 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1304 enum wined3d_tessellator_partitioning tessellator_partitioning;
1305 float max_tessellation_factor;
1306 struct wined3d_shader_index_range index_range;
1307 struct wined3d_shader_indexable_temp indexable_temp;
1308 struct wined3d_shader_function_table_pointer fp;
1309 } declaration;
1312 static inline BOOL wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction *ins)
1314 return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1317 struct wined3d_shader_attribute
1319 enum wined3d_decl_usage usage;
1320 UINT usage_idx;
1323 struct wined3d_shader_loop_control
1325 unsigned int count;
1326 unsigned int start;
1327 int step;
1330 struct wined3d_shader_frontend
1332 void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1333 const struct wined3d_shader_signature *output_signature);
1334 void (*shader_free)(void *data);
1335 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1336 void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1337 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1340 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
1341 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
1343 HRESULT shader_extract_from_dxbc(struct wined3d_shader *shader,
1344 unsigned int max_shader_version, enum wined3d_shader_byte_code_format *format) DECLSPEC_HIDDEN;
1345 BOOL shader_get_stream_output_register_info(const struct wined3d_shader *shader,
1346 const struct wined3d_stream_output_element *so_element, unsigned int *register_idx,
1347 unsigned int *component_idx) DECLSPEC_HIDDEN;
1349 typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
1351 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1352 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1353 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1354 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1355 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1357 struct shader_caps
1359 unsigned int vs_version;
1360 unsigned int hs_version;
1361 unsigned int ds_version;
1362 unsigned int gs_version;
1363 unsigned int ps_version;
1364 unsigned int cs_version;
1366 unsigned int vs_uniform_count;
1367 unsigned int ps_uniform_count;
1368 float ps_1x_max_value;
1369 unsigned int varying_count;
1371 DWORD wined3d_caps;
1374 enum wined3d_gl_resource_type
1376 WINED3D_GL_RES_TYPE_TEX_1D = 0,
1377 WINED3D_GL_RES_TYPE_TEX_2D = 1,
1378 WINED3D_GL_RES_TYPE_TEX_3D = 2,
1379 WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
1380 WINED3D_GL_RES_TYPE_TEX_RECT = 4,
1381 WINED3D_GL_RES_TYPE_BUFFER = 5,
1382 WINED3D_GL_RES_TYPE_RB = 6,
1383 WINED3D_GL_RES_TYPE_COUNT = 7,
1386 enum wined3d_vertex_processing_mode
1388 WINED3D_VP_MODE_FF,
1389 WINED3D_VP_MODE_SHADER,
1390 WINED3D_VP_MODE_NONE,
1393 #define WINED3D_CONST_NUM_UNUSED ~0U
1395 enum wined3d_ffp_ps_fog_mode
1397 WINED3D_FFP_PS_FOG_OFF,
1398 WINED3D_FFP_PS_FOG_LINEAR,
1399 WINED3D_FFP_PS_FOG_EXP,
1400 WINED3D_FFP_PS_FOG_EXP2,
1403 /* Stateblock dependent parameters which have to be hardcoded
1404 * into the shader code
1407 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1408 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1409 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1410 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1411 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1413 /* Used for Shader Model 1 pixel shaders to track the bound texture
1414 * type. 2D and RECT textures are separated through NP2 fixup. */
1415 enum wined3d_shader_tex_types
1417 WINED3D_SHADER_TEX_2D = 0,
1418 WINED3D_SHADER_TEX_3D = 1,
1419 WINED3D_SHADER_TEX_CUBE = 2,
1420 WINED3D_SHADER_TEX_ERR = 3,
1423 struct ps_compile_args
1425 struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
1426 enum wined3d_vertex_processing_mode vp_mode;
1427 enum wined3d_ffp_ps_fog_mode fog;
1428 DWORD tex_types; /* ps 1 - 3, 16 textures */
1429 WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1430 WORD srgb_correction;
1431 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1432 D3D9 has a limit of 16 samplers and the fixup is superfluous
1433 in D3D10 (unconditional NP2 support mandatory). */
1434 WORD np2_fixup;
1435 WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1436 WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
1437 WORD padding_to_dword;
1438 DWORD pointsprite : 1;
1439 DWORD flatshading : 1;
1440 DWORD alpha_test_func : 3;
1441 DWORD render_offscreen : 1;
1442 DWORD rt_alpha_swizzle : 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1443 DWORD dual_source_blend : 1;
1444 DWORD padding : 17;
1447 enum fog_src_type
1449 VS_FOG_Z = 0,
1450 VS_FOG_COORD = 1
1453 struct vs_compile_args
1455 BYTE fog_src;
1456 BYTE clip_enabled : 1;
1457 BYTE point_size : 1;
1458 BYTE per_vertex_point_size : 1;
1459 BYTE flatshading : 1;
1460 BYTE next_shader_type : 3;
1461 BYTE padding : 1;
1462 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1463 unsigned int next_shader_input_count;
1464 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1467 struct ds_compile_args
1469 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1470 enum wined3d_tessellator_partitioning tessellator_partitioning;
1471 unsigned int output_count : 16;
1472 unsigned int next_shader_type : 3;
1473 unsigned int render_offscreen : 1;
1474 unsigned int padding : 12;
1475 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1478 struct gs_compile_args
1480 unsigned int output_count;
1481 enum wined3d_primitive_type primitive_type;
1482 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1485 struct wined3d_shader_backend_ops
1487 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1488 void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1489 void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1490 const struct wined3d_state *state);
1491 void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1492 const struct wined3d_state *state);
1493 void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1494 void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1495 void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1496 void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1497 const struct wined3d_state *state);
1498 void (*shader_destroy)(struct wined3d_shader *shader);
1499 HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1500 const struct wined3d_fragment_pipe_ops *fragment_pipe);
1501 void (*shader_free_private)(struct wined3d_device *device, struct wined3d_context *context);
1502 BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1503 void (*shader_free_context_data)(struct wined3d_context *context);
1504 void (*shader_init_context_state)(struct wined3d_context *context);
1505 void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps);
1506 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1507 BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1510 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
1511 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
1512 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
1514 const struct wined3d_shader_backend_ops *wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN;
1515 void wined3d_spirv_shader_backend_cleanup(void) DECLSPEC_HIDDEN;
1517 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1519 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1520 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1521 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1522 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1524 static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1526 wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1527 wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1528 wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1529 wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1532 extern const struct wined3d_vec4 wined3d_srgb_const[] DECLSPEC_HIDDEN;
1534 static inline float wined3d_srgb_from_linear(float colour)
1536 if (colour < 0.0f)
1537 return 0.0f;
1538 if (colour < wined3d_srgb_const[1].x)
1539 return colour * wined3d_srgb_const[0].w;
1540 if (colour < 1.0f)
1541 return wined3d_srgb_const[0].y * powf(colour, wined3d_srgb_const[0].x) - wined3d_srgb_const[0].z;
1542 return 1.0f;
1545 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
1546 const struct wined3d_color *colour)
1548 colour_srgb->r = wined3d_srgb_from_linear(colour->r);
1549 colour_srgb->g = wined3d_srgb_from_linear(colour->g);
1550 colour_srgb->b = wined3d_srgb_from_linear(colour->b);
1551 colour_srgb->a = colour->a;
1554 void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1555 const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1557 /* Checking of API calls */
1558 /* --------------------- */
1559 #ifndef WINE_NO_DEBUG_MSGS
1560 #define checkGLcall(A) \
1561 do { \
1562 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1563 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1564 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1565 } while(0)
1566 #else
1567 #define checkGLcall(A) do {} while(0)
1568 #endif
1570 struct wined3d_bo_gl
1572 GLuint id;
1573 GLsizeiptr size;
1574 GLenum binding;
1575 GLenum usage;
1577 GLbitfield flags;
1578 bool coherent;
1579 struct list users;
1580 uint64_t command_fence_id;
1583 static inline GLuint wined3d_bo_gl_id(uintptr_t bo)
1585 return bo ? ((struct wined3d_bo_gl *)bo)->id : 0;
1588 struct wined3d_bo_user
1590 struct list entry;
1591 bool valid;
1594 struct wined3d_bo_vk
1596 VkBuffer vk_buffer;
1597 struct wined3d_allocator_block *memory;
1598 struct wined3d_bo_slab_vk *slab;
1600 VkDeviceMemory vk_memory;
1601 void *map_ptr;
1603 VkDeviceSize buffer_offset;
1604 VkDeviceSize memory_offset;
1605 VkDeviceSize size;
1606 VkBufferUsageFlags usage;
1607 VkMemoryPropertyFlags memory_type;
1609 struct list users;
1610 uint64_t command_buffer_id;
1613 struct wined3d_bo_slab_vk_key
1615 VkMemoryPropertyFlags memory_type;
1616 VkBufferUsageFlags usage;
1617 VkDeviceSize size;
1620 struct wined3d_bo_slab_vk
1622 struct wine_rb_entry entry;
1623 struct wined3d_bo_slab_vk *next;
1624 VkMemoryPropertyFlags requested_memory_type;
1625 struct wined3d_bo_vk bo;
1626 unsigned int map_count;
1627 void *map_ptr;
1628 uint32_t map;
1631 void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk,
1632 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
1633 void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk,
1634 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
1636 struct wined3d_bo_address
1638 UINT_PTR buffer_object;
1639 BYTE *addr;
1642 struct wined3d_const_bo_address
1644 UINT_PTR buffer_object;
1645 const BYTE *addr;
1648 static inline struct wined3d_const_bo_address *wined3d_const_bo_address(struct wined3d_bo_address *data)
1650 return (struct wined3d_const_bo_address *)data;
1653 struct wined3d_image_vk
1655 VkImage vk_image;
1656 struct wined3d_allocator_block *memory;
1657 VkDeviceMemory vk_memory;
1658 uint64_t command_buffer_id;
1661 struct wined3d_stream_info_element
1663 const struct wined3d_format *format;
1664 struct wined3d_bo_address data;
1665 GLsizei stride;
1666 unsigned int stream_idx;
1667 unsigned int divisor;
1668 bool instanced;
1671 struct wined3d_stream_info
1673 struct wined3d_stream_info_element elements[MAX_ATTRIBS];
1674 DWORD position_transformed : 1;
1675 DWORD all_vbo : 1;
1676 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1677 WORD use_map; /* MAX_ATTRIBS, 16 */
1680 void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_info,
1681 const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
1683 struct wined3d_direct_dispatch_parameters
1685 unsigned int group_count_x;
1686 unsigned int group_count_y;
1687 unsigned int group_count_z;
1690 struct wined3d_indirect_dispatch_parameters
1692 struct wined3d_buffer *buffer;
1693 unsigned int offset;
1696 struct wined3d_dispatch_parameters
1698 BOOL indirect;
1699 union
1701 struct wined3d_direct_dispatch_parameters direct;
1702 struct wined3d_indirect_dispatch_parameters indirect;
1703 } u;
1706 struct wined3d_direct_draw_parameters
1708 int base_vertex_idx;
1709 unsigned int start_idx;
1710 unsigned int index_count;
1711 unsigned int start_instance;
1712 unsigned int instance_count;
1715 struct wined3d_indirect_draw_parameters
1717 struct wined3d_buffer *buffer;
1718 unsigned int offset;
1721 struct wined3d_draw_parameters
1723 BOOL indirect;
1724 union
1726 struct wined3d_direct_draw_parameters direct;
1727 struct wined3d_indirect_draw_parameters indirect;
1728 } u;
1729 BOOL indexed;
1732 void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
1733 const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
1734 void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
1735 const struct wined3d_dispatch_parameters *dispatch_parameters) DECLSPEC_HIDDEN;
1737 #define eps 1e-8f
1739 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1740 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1742 /* Routines and structures related to state management */
1744 #define STATE_RENDER(a) (a)
1745 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1747 #define STATE_TEXTURESTAGE(stage, num) \
1748 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1749 #define STATE_IS_TEXTURESTAGE(a) \
1750 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1752 /* + 1 because samplers start with 0 */
1753 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1754 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1756 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1757 #define STATE_IS_GRAPHICS_SHADER(a) \
1758 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1760 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1761 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1762 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1763 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1765 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1766 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1768 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1769 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1771 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1772 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1774 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1775 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1776 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1777 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1779 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1780 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1782 #define STATE_VIEWPORT (STATE_VDECL + 1)
1783 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1785 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1786 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1787 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1788 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1790 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1791 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1793 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1794 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1796 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1797 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1799 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1800 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1802 #define STATE_POINTSPRITECOORDORIGIN (STATE_RASTERIZER + 1)
1803 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1805 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1806 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1808 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1809 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1811 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1812 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1814 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1815 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1817 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1818 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1820 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1821 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1823 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1824 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1826 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1827 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1829 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1830 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1832 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1833 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1835 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1837 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1838 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1840 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1841 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1843 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1844 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1846 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1847 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1849 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1850 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1852 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1853 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1855 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1856 #define STATE_CONSTANT_BUFFER(a) \
1857 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1858 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1859 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1861 enum fogsource {
1862 FOGSOURCE_FFP,
1863 FOGSOURCE_VS,
1864 FOGSOURCE_COORD,
1867 union wined3d_gl_fence_object
1869 GLuint id;
1870 GLsync sync;
1873 enum wined3d_fence_result
1875 WINED3D_FENCE_OK,
1876 WINED3D_FENCE_WAITING,
1877 WINED3D_FENCE_NOT_STARTED,
1878 WINED3D_FENCE_WRONG_THREAD,
1879 WINED3D_FENCE_ERROR,
1882 struct wined3d_fence
1884 struct list entry;
1885 union wined3d_gl_fence_object object;
1886 struct wined3d_context_gl *context_gl;
1889 HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
1890 void wined3d_fence_destroy(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
1891 void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device) DECLSPEC_HIDDEN;
1892 enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
1893 struct wined3d_device *device) DECLSPEC_HIDDEN;
1894 enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *fence,
1895 struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
1897 /* Direct3D terminology with little modifications. We do not have an issued
1898 * state because only the driver knows about it, but we have a created state
1899 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1900 enum wined3d_query_state
1902 QUERY_CREATED,
1903 QUERY_SIGNALLED,
1904 QUERY_BUILDING
1907 struct wined3d_query_ops
1909 BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
1910 BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
1911 void (*query_destroy)(struct wined3d_query *query);
1914 struct wined3d_query
1916 LONG ref;
1918 void *parent;
1919 const struct wined3d_parent_ops *parent_ops;
1920 struct wined3d_device *device;
1921 enum wined3d_query_state state;
1922 enum wined3d_query_type type;
1923 const void *data;
1924 DWORD data_size;
1925 const struct wined3d_query_ops *query_ops;
1927 LONG counter_main, counter_retrieved;
1928 struct list poll_list_entry;
1930 GLuint buffer_object;
1931 UINT64 *map_ptr;
1934 HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
1935 const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
1936 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl,
1937 struct wined3d_query *query) DECLSPEC_HIDDEN;
1939 struct wined3d_event_query
1941 struct wined3d_query query;
1943 struct wined3d_fence fence;
1944 BOOL signalled;
1947 struct wined3d_occlusion_query
1949 struct wined3d_query query;
1951 struct list entry;
1952 GLuint id;
1953 struct wined3d_context_gl *context_gl;
1954 UINT64 samples;
1955 BOOL started;
1958 struct wined3d_timestamp_query
1960 struct wined3d_query query;
1962 struct list entry;
1963 GLuint id;
1964 struct wined3d_context_gl *context_gl;
1965 UINT64 timestamp;
1968 union wined3d_gl_so_statistics_query
1970 GLuint id[2];
1971 struct
1973 GLuint written;
1974 GLuint generated;
1975 } query;
1978 struct wined3d_so_statistics_query
1980 struct wined3d_query query;
1982 struct list entry;
1983 union wined3d_gl_so_statistics_query u;
1984 struct wined3d_context_gl *context_gl;
1985 unsigned int stream_idx;
1986 struct wined3d_query_data_so_statistics statistics;
1987 BOOL started;
1990 union wined3d_gl_pipeline_statistics_query
1992 GLuint id[11];
1993 struct
1995 GLuint vertices;
1996 GLuint primitives;
1997 GLuint vertex_shader;
1998 GLuint tess_control_shader;
1999 GLuint tess_eval_shader;
2000 GLuint geometry_shader;
2001 GLuint geometry_primitives;
2002 GLuint fragment_shader;
2003 GLuint compute_shader;
2004 GLuint clipping_input;
2005 GLuint clipping_output;
2006 } query;
2009 struct wined3d_pipeline_statistics_query
2011 struct wined3d_query query;
2013 struct list entry;
2014 union wined3d_gl_pipeline_statistics_query u;
2015 struct wined3d_context_gl *context_gl;
2016 struct wined3d_query_data_pipeline_statistics statistics;
2017 BOOL started;
2020 #define WINED3D_QUERY_POOL_SIZE 256
2022 struct wined3d_query_pool_vk
2024 struct list entry;
2026 struct list *free_list;
2027 VkQueryPool vk_query_pool;
2028 uint32_t allocated[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)];
2031 bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk *pool_vk, size_t *idx) DECLSPEC_HIDDEN;
2032 void wined3d_query_pool_vk_cleanup(struct wined3d_query_pool_vk *pool_vk,
2033 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2034 void wined3d_query_pool_vk_free_query(struct wined3d_query_pool_vk *pool_vk, size_t idx) DECLSPEC_HIDDEN;
2035 bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk,
2036 enum wined3d_query_type type, struct list *free_pools) DECLSPEC_HIDDEN;
2038 struct wined3d_query_pool_idx_vk
2040 struct wined3d_query_pool_vk *pool_vk;
2041 size_t idx;
2044 struct wined3d_query_vk
2046 struct wined3d_query q;
2048 struct list entry;
2049 struct wined3d_query_pool_idx_vk pool_idx;
2050 bool started;
2051 uint64_t command_buffer_id;
2052 uint32_t control_flags;
2053 size_t pending_count;
2056 static inline struct wined3d_query_vk *wined3d_query_vk(struct wined3d_query *query)
2058 return CONTAINING_RECORD(query, struct wined3d_query_vk, q);
2061 bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk,
2062 const struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN;
2063 HRESULT wined3d_query_vk_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
2064 const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
2065 void wined3d_query_vk_resume(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2066 void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2068 struct wined3d_gl_view
2070 GLenum target;
2071 GLuint name;
2074 struct wined3d_range
2076 unsigned int offset;
2077 unsigned int size;
2080 struct wined3d_rendertarget_info
2082 struct wined3d_gl_view gl_view;
2083 struct wined3d_resource *resource;
2084 unsigned int sub_resource_idx;
2085 unsigned int layer_count;
2088 struct wined3d_fb_state
2090 struct wined3d_rendertarget_view *render_targets[WINED3D_MAX_RENDER_TARGETS];
2091 struct wined3d_rendertarget_view *depth_stencil;
2094 #define MAX_GL_FRAGMENT_SAMPLERS 32
2096 struct wined3d_context
2098 const struct wined3d_d3d_info *d3d_info;
2099 const struct wined3d_state_entry *state_table;
2100 uint32_t dirty_graphics_states[WINED3D_BITMAP_SIZE(STATE_HIGHEST)];
2101 uint32_t dirty_compute_states[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT)];
2103 struct wined3d_device *device;
2104 struct wined3d_swapchain *swapchain;
2105 struct
2107 struct wined3d_texture *texture;
2108 unsigned int sub_resource_idx;
2109 } current_rt;
2111 /* Stores some information about the context state for optimization */
2112 DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
2113 DWORD update_shader_resource_bindings : 1;
2114 DWORD update_compute_shader_resource_bindings : 1;
2115 DWORD update_unordered_access_view_bindings : 1;
2116 DWORD update_compute_unordered_access_view_bindings : 1;
2117 DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
2118 DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */
2119 DWORD last_was_pshader : 1;
2120 DWORD last_was_vshader : 1;
2121 DWORD last_was_diffuse : 1;
2122 DWORD last_was_specular : 1;
2123 DWORD last_was_normal : 1;
2125 DWORD last_was_ffp_blit : 1;
2126 DWORD last_was_blit : 1;
2127 DWORD last_was_ckey : 1;
2128 DWORD last_was_dual_source_blend : 1;
2129 DWORD texShaderBumpMap : 8; /* WINED3D_MAX_TEXTURES, 8 */
2130 DWORD lastWasPow2Texture : 8; /* WINED3D_MAX_TEXTURES, 8 */
2131 DWORD fixed_function_usage_map : 8; /* WINED3D_MAX_TEXTURES, 8 */
2132 DWORD lowest_disabled_stage : 4; /* Max WINED3D_MAX_TEXTURES, 8 */
2134 DWORD use_immediate_mode_draw : 1;
2135 DWORD uses_uavs : 1;
2136 DWORD uses_fbo_attached_resources : 1;
2137 DWORD transform_feedback_active : 1;
2138 DWORD transform_feedback_paused : 1;
2139 DWORD fog_coord : 1;
2140 DWORD render_offscreen : 1;
2141 DWORD current : 1;
2142 DWORD destroyed : 1;
2143 DWORD destroy_delayed : 1;
2144 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
2145 DWORD namedArraysLoaded : 1;
2146 DWORD padding : 13;
2148 DWORD constant_update_mask;
2149 DWORD numbered_array_mask;
2150 enum fogsource fog_source;
2152 UINT instance_count;
2154 void *shader_backend_data;
2155 void *fragment_pipe_data;
2157 struct wined3d_stream_info stream_info;
2159 unsigned int viewport_count;
2160 unsigned int scissor_rect_count;
2163 void wined3d_context_cleanup(struct wined3d_context *context) DECLSPEC_HIDDEN;
2164 void wined3d_context_init(struct wined3d_context *context, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2165 void context_preload_textures(struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2166 void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2168 HRESULT wined3d_context_no3d_init(struct wined3d_context *context_no3d,
2169 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2171 struct wined3d_command_fence_gl
2173 uint64_t id;
2174 struct wined3d_fence *fence;
2177 struct wined3d_context_gl
2179 struct wined3d_context c;
2181 const struct wined3d_gl_info *gl_info;
2183 DWORD tid; /* Thread ID which owns this context at the moment. */
2185 uint32_t dc_is_private : 1;
2186 uint32_t dc_has_format : 1; /* Only meaningful for private DCs. */
2187 uint32_t fog_enabled : 1;
2188 uint32_t diffuse_attrib_to_1 : 1;
2189 uint32_t rebind_fbo : 1;
2190 uint32_t untracked_material_count : 2; /* Max value 2 */
2191 uint32_t needs_set : 1;
2192 uint32_t valid : 1;
2193 uint32_t padding : 23;
2195 uint32_t default_attrib_value_set;
2197 GLenum tracking_parm; /* Which source is tracking current colour. */
2198 GLenum untracked_materials[2];
2199 SIZE blit_size;
2200 unsigned int active_texture;
2202 GLenum *texture_type;
2204 /* The WGL context. */
2205 unsigned int level;
2206 HGLRC restore_ctx;
2207 HDC restore_dc;
2208 int restore_pf;
2209 HWND restore_pf_win;
2210 HGLRC gl_ctx;
2211 HDC dc;
2212 int pixel_format;
2213 HWND window;
2214 GLint aux_buffers;
2216 /* FBOs. */
2217 unsigned int fbo_entry_count;
2218 struct list fbo_list;
2219 struct list fbo_destroy_list;
2220 struct fbo_entry *current_fbo;
2221 GLuint fbo_read_binding;
2222 GLuint fbo_draw_binding;
2223 struct wined3d_rendertarget_info blit_targets[WINED3D_MAX_RENDER_TARGETS];
2224 uint32_t draw_buffers_mask; /* Enabled draw buffers, 31 max. */
2226 /* Queries. */
2227 struct list occlusion_queries;
2228 struct list fences;
2229 struct list timestamp_queries;
2230 struct list so_statistics_queries;
2231 struct list pipeline_statistics_queries;
2233 GLuint *free_occlusion_queries;
2234 SIZE_T free_occlusion_query_size;
2235 unsigned int free_occlusion_query_count;
2237 union wined3d_gl_fence_object *free_fences;
2238 SIZE_T free_fence_size;
2239 unsigned int free_fence_count;
2241 GLuint *free_timestamp_queries;
2242 SIZE_T free_timestamp_query_size;
2243 unsigned int free_timestamp_query_count;
2245 union wined3d_gl_so_statistics_query *free_so_statistics_queries;
2246 SIZE_T free_so_statistics_query_size;
2247 unsigned int free_so_statistics_query_count;
2249 union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
2250 SIZE_T free_pipeline_statistics_query_size;
2251 unsigned int free_pipeline_statistics_query_count;
2253 GLuint blit_vbo;
2255 unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
2256 unsigned int rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS];
2258 /* Extension emulation. */
2259 GLint gl_fog_source;
2260 GLfloat fog_coord_value;
2261 GLfloat colour[4], fog_start, fog_end, fog_colour[4];
2263 GLuint dummy_arbfp_prog;
2265 struct
2267 struct wined3d_command_fence_gl *fences;
2268 SIZE_T fences_size;
2269 SIZE_T fence_count;
2270 } submitted;
2273 static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_context *context)
2275 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2278 static inline const struct wined3d_context_gl *wined3d_context_gl_const(const struct wined3d_context *context)
2280 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2283 struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
2284 struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2285 void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
2286 const struct wined3d_gl_info *gl_info, unsigned int unit) DECLSPEC_HIDDEN;
2287 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
2288 struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2289 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
2290 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2291 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
2292 struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2293 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
2294 struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2295 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
2296 struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2297 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
2298 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2299 BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, const struct wined3d_state *state,
2300 unsigned int rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2301 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl *context_gl, GLenum target,
2302 struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
2303 struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
2304 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
2305 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2306 void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
2307 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2308 void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
2309 GLenum target, GLuint name) DECLSPEC_HIDDEN;
2310 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
2311 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
2312 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
2313 bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding,
2314 GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
2315 void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2316 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
2317 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
2318 unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2319 enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2320 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl,
2321 struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
2322 const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2323 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t mask) DECLSPEC_HIDDEN;
2324 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2325 void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2326 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2327 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2328 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2329 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2330 struct wined3d_context_gl *wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN;
2331 GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2332 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
2333 const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2334 HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
2335 struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
2336 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
2337 const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2338 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
2339 const struct wined3d_bo_address *data, size_t size, uint32_t flags) DECLSPEC_HIDDEN;
2340 struct wined3d_context_gl *wined3d_context_gl_reacquire(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2341 void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2342 BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2343 void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN;
2344 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2345 void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
2346 const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
2347 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2348 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data,
2349 unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN;
2350 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl,
2351 const struct wined3d_state *state) DECLSPEC_HIDDEN;
2352 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl, uint64_t id) DECLSPEC_HIDDEN;
2354 struct wined3d_command_buffer_vk
2356 uint64_t id;
2357 VkCommandBuffer vk_command_buffer;
2358 VkFence vk_fence;
2361 enum wined3d_retired_object_type_vk
2363 WINED3D_RETIRED_FREE_VK,
2364 WINED3D_RETIRED_FRAMEBUFFER_VK,
2365 WINED3D_RETIRED_DESCRIPTOR_POOL_VK,
2366 WINED3D_RETIRED_MEMORY_VK,
2367 WINED3D_RETIRED_ALLOCATOR_BLOCK_VK,
2368 WINED3D_RETIRED_BO_SLAB_SLICE_VK,
2369 WINED3D_RETIRED_BUFFER_VK,
2370 WINED3D_RETIRED_IMAGE_VK,
2371 WINED3D_RETIRED_BUFFER_VIEW_VK,
2372 WINED3D_RETIRED_IMAGE_VIEW_VK,
2373 WINED3D_RETIRED_SAMPLER_VK,
2376 struct wined3d_retired_object_vk
2378 enum wined3d_retired_object_type_vk type;
2379 union
2381 struct wined3d_retired_object_vk *next;
2382 VkFramebuffer vk_framebuffer;
2383 VkDescriptorPool vk_descriptor_pool;
2384 VkDeviceMemory vk_memory;
2385 struct wined3d_allocator_block *block;
2386 struct
2388 struct wined3d_bo_slab_vk *slab;
2389 size_t idx;
2390 } slice;
2391 VkBuffer vk_buffer;
2392 VkImage vk_image;
2393 VkBufferView vk_buffer_view;
2394 VkImageView vk_image_view;
2395 VkSampler vk_sampler;
2396 } u;
2397 uint64_t command_buffer_id;
2400 struct wined3d_retired_objects_vk
2402 struct wined3d_retired_object_vk *objects;
2403 struct wined3d_retired_object_vk *free;
2404 SIZE_T size;
2405 SIZE_T count;
2408 struct wined3d_render_pass_attachment_vk
2410 VkFormat vk_format;
2411 VkSampleCountFlagBits vk_samples;
2412 VkImageLayout vk_layout;
2415 struct wined3d_render_pass_key_vk
2417 struct wined3d_render_pass_attachment_vk rt[WINED3D_MAX_RENDER_TARGETS];
2418 struct wined3d_render_pass_attachment_vk ds;
2419 uint32_t rt_mask;
2420 uint32_t clear_flags;
2423 struct wined3d_render_pass_vk
2425 struct wine_rb_entry entry;
2426 struct wined3d_render_pass_key_vk key;
2427 VkRenderPass vk_render_pass;
2430 struct wined3d_pipeline_layout_key_vk
2432 VkDescriptorSetLayoutBinding *bindings;
2433 SIZE_T binding_count;
2436 struct wined3d_pipeline_layout_vk
2438 struct wine_rb_entry entry;
2439 struct wined3d_pipeline_layout_key_vk key;
2440 VkPipelineLayout vk_pipeline_layout;
2441 VkDescriptorSetLayout vk_set_layout;
2444 struct wined3d_graphics_pipeline_key_vk
2446 VkPipelineShaderStageCreateInfo stages[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
2447 VkVertexInputBindingDivisorDescriptionEXT divisors[MAX_ATTRIBS];
2448 VkVertexInputAttributeDescription attributes[MAX_ATTRIBS];
2449 VkVertexInputBindingDescription bindings[MAX_ATTRIBS];
2450 VkViewport viewport;
2451 VkRect2D scissor;
2452 VkSampleMask sample_mask;
2453 VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS];
2455 VkPipelineVertexInputDivisorStateCreateInfoEXT divisor_desc;
2456 VkPipelineVertexInputStateCreateInfo input_desc;
2457 VkPipelineInputAssemblyStateCreateInfo ia_desc;
2458 VkPipelineTessellationStateCreateInfo ts_desc;
2459 VkPipelineViewportStateCreateInfo vp_desc;
2460 VkPipelineRasterizationStateCreateInfo rs_desc;
2461 VkPipelineMultisampleStateCreateInfo ms_desc;
2462 VkPipelineDepthStencilStateCreateInfo ds_desc;
2463 VkPipelineColorBlendStateCreateInfo blend_desc;
2464 VkPipelineDynamicStateCreateInfo dynamic_desc;
2466 VkGraphicsPipelineCreateInfo pipeline_desc;
2469 struct wined3d_graphics_pipeline_vk
2471 struct wine_rb_entry entry;
2472 struct wined3d_graphics_pipeline_key_vk key;
2473 VkPipeline vk_pipeline;
2476 enum wined3d_shader_descriptor_type
2478 WINED3D_SHADER_DESCRIPTOR_TYPE_CBV,
2479 WINED3D_SHADER_DESCRIPTOR_TYPE_SRV,
2480 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV,
2481 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER,
2482 WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER,
2485 struct wined3d_shader_resource_binding
2487 enum wined3d_shader_type shader_type;
2488 enum wined3d_shader_descriptor_type shader_descriptor_type;
2489 size_t resource_idx;
2490 enum wined3d_shader_resource_type resource_type;
2491 enum wined3d_data_type resource_data_type;
2492 size_t binding_idx;
2495 struct wined3d_shader_resource_bindings
2497 struct wined3d_shader_resource_binding *bindings;
2498 SIZE_T size, count;
2501 struct wined3d_shader_descriptor_writes_vk
2503 VkWriteDescriptorSet *writes;
2504 SIZE_T size, count;
2507 struct wined3d_pending_query_vk
2509 struct wined3d_query_vk *query_vk;
2510 struct wined3d_query_pool_idx_vk pool_idx;
2513 struct wined3d_pending_queries_vk
2515 struct wined3d_pending_query_vk *queries;
2516 SIZE_T free_idx;
2517 SIZE_T size;
2518 SIZE_T count;
2521 struct wined3d_context_vk
2523 struct wined3d_context c;
2525 const struct wined3d_vk_info *vk_info;
2527 uint32_t update_compute_pipeline : 1;
2528 uint32_t update_stream_output : 1;
2529 uint32_t padding : 30;
2531 struct
2533 VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
2534 struct wined3d_graphics_pipeline_key_vk pipeline_key_vk;
2535 VkPipeline vk_pipeline;
2536 VkPipelineLayout vk_pipeline_layout;
2537 VkDescriptorSetLayout vk_set_layout;
2538 struct wined3d_shader_resource_bindings bindings;
2539 } graphics;
2541 struct
2543 VkPipeline vk_pipeline;
2544 VkPipelineLayout vk_pipeline_layout;
2545 VkDescriptorSetLayout vk_set_layout;
2546 struct wined3d_shader_resource_bindings bindings;
2547 } compute;
2549 VkCommandPool vk_command_pool;
2550 struct wined3d_command_buffer_vk current_command_buffer;
2551 uint64_t completed_command_buffer_id;
2552 VkDeviceSize retired_bo_size;
2554 struct
2556 struct wined3d_command_buffer_vk *buffers;
2557 SIZE_T buffers_size;
2558 SIZE_T buffer_count;
2559 } submitted;
2561 struct wined3d_shader_descriptor_writes_vk descriptor_writes;
2563 VkFramebuffer vk_framebuffer;
2564 VkRenderPass vk_render_pass;
2565 VkDescriptorPool vk_descriptor_pool;
2567 VkSampleCountFlagBits sample_count;
2568 unsigned int rt_count;
2570 VkBuffer vk_so_counters[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
2571 VkDeviceSize vk_so_offsets[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
2572 struct wined3d_bo_vk vk_so_counter_bo;
2574 struct list active_queries;
2575 struct wined3d_pending_queries_vk pending_queries;
2576 struct list free_occlusion_query_pools;
2577 struct list free_timestamp_query_pools;
2578 struct list free_pipeline_statistics_query_pools;
2579 struct list free_stream_output_statistics_query_pools;
2581 struct wined3d_retired_objects_vk retired;
2582 struct wine_rb_tree render_passes;
2583 struct wine_rb_tree pipeline_layouts;
2584 struct wine_rb_tree graphics_pipelines;
2585 struct wine_rb_tree bo_slab_available;
2588 static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
2590 return CONTAINING_RECORD(context, struct wined3d_context_vk, c);
2593 void wined3d_context_vk_accumulate_pending_queries(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2594 void wined3d_context_vk_add_pending_query(struct wined3d_context_vk *context_vk,
2595 struct wined3d_query_vk *query_vk) DECLSPEC_HIDDEN;
2596 struct wined3d_allocator_block *wined3d_context_vk_allocate_memory(struct wined3d_context_vk *context_vk,
2597 unsigned int memory_type, VkDeviceSize size, VkDeviceMemory *vk_memory) DECLSPEC_HIDDEN;
2598 bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk,
2599 enum wined3d_query_type type, struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN;
2600 VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_context_vk *context_vk,
2601 unsigned int pool, size_t size) DECLSPEC_HIDDEN;
2602 VkCommandBuffer wined3d_context_vk_apply_compute_state(struct wined3d_context_vk *context_vk,
2603 const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk) DECLSPEC_HIDDEN;
2604 VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *context_vk,
2605 const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk, bool indexed) DECLSPEC_HIDDEN;
2606 void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2607 BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
2608 VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2609 BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type,
2610 VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth,
2611 unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags,
2612 struct wined3d_image_vk *image) DECLSPEC_HIDDEN;
2613 void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *context_vk,
2614 struct wined3d_allocator_block *block, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2615 void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk,
2616 const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2617 void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk,
2618 struct wined3d_image_vk *image_vk) DECLSPEC_HIDDEN;
2619 void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk,
2620 VkBufferView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2621 void wined3d_context_vk_destroy_vk_framebuffer(struct wined3d_context_vk *context_vk,
2622 VkFramebuffer vk_framebuffer, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2623 void wined3d_context_vk_destroy_vk_image(struct wined3d_context_vk *context_vk,
2624 VkImage vk_image, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2625 void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk,
2626 VkImageView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2627 void wined3d_context_vk_destroy_vk_memory(struct wined3d_context_vk *context_vk,
2628 VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2629 void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk *context_vk,
2630 VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2631 void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2632 VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2633 struct wined3d_pipeline_layout_vk *wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk,
2634 VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count) DECLSPEC_HIDDEN;
2635 VkRenderPass wined3d_context_vk_get_render_pass(struct wined3d_context_vk *context_vk,
2636 const struct wined3d_fb_state *fb, unsigned int rt_count,
2637 bool depth_stencil, uint32_t clear_flags) DECLSPEC_HIDDEN;
2638 void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk,
2639 VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask,
2640 VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout,
2641 VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range) DECLSPEC_HIDDEN;
2642 HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
2643 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2644 void wined3d_context_vk_poll_command_buffers(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2645 void wined3d_context_vk_remove_pending_queries(struct wined3d_context_vk *context_vk,
2646 struct wined3d_query_vk *query_vk) DECLSPEC_HIDDEN;
2647 void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk,
2648 unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages,
2649 unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores) DECLSPEC_HIDDEN;
2650 void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id) DECLSPEC_HIDDEN;
2652 typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2654 struct wined3d_state_entry
2656 unsigned int representative;
2657 APPLYSTATEFUNC apply;
2660 struct wined3d_state_entry_template
2662 DWORD state;
2663 struct wined3d_state_entry content;
2664 unsigned int extension;
2667 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2668 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2669 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2671 struct fragment_caps
2673 DWORD wined3d_caps;
2674 DWORD PrimitiveMiscCaps;
2675 DWORD TextureOpCaps;
2676 DWORD MaxTextureBlendStages;
2677 DWORD MaxSimultaneousTextures;
2680 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2681 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2683 struct wined3d_fragment_pipe_ops
2685 void (*fp_enable)(const struct wined3d_context *context, BOOL enable);
2686 void (*get_caps)(const struct wined3d_adapter *adapter, struct fragment_caps *caps);
2687 DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2688 void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2689 void (*free_private)(struct wined3d_device *device, struct wined3d_context *context);
2690 BOOL (*allocate_context_data)(struct wined3d_context *context);
2691 void (*free_context_data)(struct wined3d_context *context);
2692 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2693 const struct wined3d_state_entry_template *states;
2696 struct wined3d_vertex_caps
2698 BOOL xyzrhw;
2699 BOOL emulated_flatshading;
2700 BOOL ffp_generic_attributes;
2701 DWORD max_active_lights;
2702 DWORD max_vertex_blend_matrices;
2703 DWORD max_vertex_blend_matrix_index;
2704 DWORD vertex_processing_caps;
2705 DWORD fvf_caps;
2706 DWORD max_user_clip_planes;
2707 DWORD raster_caps;
2710 struct wined3d_vertex_pipe_ops
2712 void (*vp_enable)(const struct wined3d_context *context, BOOL enable);
2713 void (*vp_get_caps)(const struct wined3d_adapter *adapter, struct wined3d_vertex_caps *caps);
2714 DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2715 void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2716 void (*vp_free)(struct wined3d_device *device, struct wined3d_context *context);
2717 const struct wined3d_state_entry_template *vp_states;
2720 extern const struct wined3d_state_entry_template misc_state_template_gl[] DECLSPEC_HIDDEN;
2721 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN;
2722 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN;
2723 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN;
2724 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN;
2725 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN;
2726 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN;
2727 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN;
2729 const struct wined3d_fragment_pipe_ops *wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN;
2731 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN;
2732 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN;
2733 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN;
2735 const struct wined3d_vertex_pipe_ops *wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN;
2737 /* "Base" state table */
2738 HRESULT compile_state_table(struct wined3d_state_entry *state_table, APPLYSTATEFUNC **dev_multistate_funcs,
2739 const struct wined3d_d3d_info *d3d_info, const BOOL *supported_extensions,
2740 const struct wined3d_vertex_pipe_ops *vertex, const struct wined3d_fragment_pipe_ops *fragment,
2741 const struct wined3d_state_entry_template *misc) DECLSPEC_HIDDEN;
2743 enum wined3d_blit_op
2745 WINED3D_BLIT_OP_COLOR_BLIT,
2746 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST,
2747 WINED3D_BLIT_OP_COLOR_BLIT_CKEY,
2748 WINED3D_BLIT_OP_DEPTH_BLIT,
2749 WINED3D_BLIT_OP_RAW_BLIT,
2752 struct wined3d_blitter
2754 const struct wined3d_blitter_ops *ops;
2755 struct wined3d_blitter *next;
2758 struct wined3d_blitter_ops
2760 void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2761 void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2762 unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2763 const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2764 DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2765 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
2766 const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
2767 DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
2768 enum wined3d_texture_filter_type filter, const struct wined3d_format *resolve_format);
2771 void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
2772 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2773 struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
2774 void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
2775 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2776 void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
2777 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2778 struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next,
2779 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2780 void wined3d_raw_blitter_create(struct wined3d_blitter **next,
2781 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2782 void wined3d_vk_blitter_create(struct wined3d_blitter **next) DECLSPEC_HIDDEN;
2784 BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
2786 HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2787 DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
2788 void context_gl_resource_released(struct wined3d_device *device,
2789 GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2790 void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2791 void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2792 void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
2793 void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
2794 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2795 void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
2796 void context_state_drawbuf(struct wined3d_context *context,
2797 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2798 void context_state_fb(struct wined3d_context *context,
2799 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2801 /*****************************************************************************
2802 * Internal representation of a light
2804 struct wined3d_light_info
2806 struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2807 DWORD OriginalIndex;
2808 LONG glIndex;
2809 BOOL enabled;
2811 /* Converted parms to speed up swapping lights */
2812 struct wined3d_vec4 position;
2813 struct wined3d_vec4 direction;
2814 float exponent;
2815 float cutoff;
2817 struct list entry;
2820 /* The default light parameters */
2821 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
2823 struct wined3d_pixel_format
2825 int iPixelFormat; /* WGL pixel format */
2826 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2827 int redSize, greenSize, blueSize, alphaSize, colorSize;
2828 int depthSize, stencilSize;
2829 BOOL windowDrawable;
2830 BOOL doubleBuffer;
2831 int auxBuffers;
2832 int numSamples;
2835 enum wined3d_pci_vendor
2837 HW_VENDOR_SOFTWARE = 0x0000,
2838 HW_VENDOR_AMD = 0x1002,
2839 HW_VENDOR_NVIDIA = 0x10de,
2840 HW_VENDOR_VMWARE = 0x15ad,
2841 HW_VENDOR_REDHAT = 0x1af4,
2842 HW_VENDOR_INTEL = 0x8086,
2845 enum wined3d_pci_device
2847 CARD_WINE = 0x0000,
2849 CARD_AMD_RAGE_128PRO = 0x5246,
2850 CARD_AMD_RADEON_7200 = 0x5144,
2851 CARD_AMD_RADEON_8500 = 0x514c,
2852 CARD_AMD_RADEON_9500 = 0x4144,
2853 CARD_AMD_RADEON_XPRESS_200M = 0x5955,
2854 CARD_AMD_RADEON_X700 = 0x5e4c,
2855 CARD_AMD_RADEON_X1600 = 0x71c2,
2856 CARD_AMD_RADEON_HD2350 = 0x94c7,
2857 CARD_AMD_RADEON_HD2600 = 0x9581,
2858 CARD_AMD_RADEON_HD2900 = 0x9400,
2859 CARD_AMD_RADEON_HD3200 = 0x9620,
2860 CARD_AMD_RADEON_HD3850 = 0x9515,
2861 CARD_AMD_RADEON_HD4200M = 0x9712,
2862 CARD_AMD_RADEON_HD4350 = 0x954f,
2863 CARD_AMD_RADEON_HD4600 = 0x9495,
2864 CARD_AMD_RADEON_HD4700 = 0x944e,
2865 CARD_AMD_RADEON_HD4800 = 0x944c,
2866 CARD_AMD_RADEON_HD5400 = 0x68f9,
2867 CARD_AMD_RADEON_HD5600 = 0x68d8,
2868 CARD_AMD_RADEON_HD5700 = 0x68be,
2869 CARD_AMD_RADEON_HD5800 = 0x6898,
2870 CARD_AMD_RADEON_HD5900 = 0x689c,
2871 CARD_AMD_RADEON_HD6300 = 0x9803,
2872 CARD_AMD_RADEON_HD6400 = 0x6770,
2873 CARD_AMD_RADEON_HD6490M = 0x6760,
2874 CARD_AMD_RADEON_HD6410D = 0x9644,
2875 CARD_AMD_RADEON_HD6480G = 0x9648,
2876 CARD_AMD_RADEON_HD6550D = 0x9640,
2877 CARD_AMD_RADEON_HD6600 = 0x6758,
2878 CARD_AMD_RADEON_HD6600M = 0x6741,
2879 CARD_AMD_RADEON_HD6700 = 0x68ba,
2880 CARD_AMD_RADEON_HD6800 = 0x6739,
2881 CARD_AMD_RADEON_HD6900 = 0x6719,
2882 CARD_AMD_RADEON_HD7660D = 0x9901,
2883 CARD_AMD_RADEON_HD7700 = 0x683d,
2884 CARD_AMD_RADEON_HD7800 = 0x6819,
2885 CARD_AMD_RADEON_HD7870 = 0x6818,
2886 CARD_AMD_RADEON_HD7900 = 0x679a,
2887 CARD_AMD_RADEON_HD8600M = 0x6660,
2888 CARD_AMD_RADEON_HD8670 = 0x6610,
2889 CARD_AMD_RADEON_HD8770 = 0x665c,
2890 CARD_AMD_RADEON_R3 = 0x9830,
2891 CARD_AMD_RADEON_R7 = 0x130f,
2892 CARD_AMD_RADEON_R9_285 = 0x6939,
2893 CARD_AMD_RADEON_R9_290 = 0x67b1,
2894 CARD_AMD_RADEON_R9_290X = 0x67b0,
2895 CARD_AMD_RADEON_R9_FURY = 0x7300,
2896 CARD_AMD_RADEON_R9_M370X = 0x6821,
2897 CARD_AMD_RADEON_R9_M380 = 0x6647,
2898 CARD_AMD_RADEON_R9_M395X = 0x6920,
2899 CARD_AMD_RADEON_RX_460 = 0x67ef,
2900 CARD_AMD_RADEON_RX_480 = 0x67df,
2901 CARD_AMD_RADEON_RX_VEGA_10 = 0x687f,
2902 CARD_AMD_RADEON_RX_VEGA_12 = 0x69af,
2903 CARD_AMD_RADEON_RAVEN = 0x15dd,
2904 CARD_AMD_RADEON_RX_VEGA_20 = 0x66af,
2905 CARD_AMD_RADEON_RX_NAVI_10 = 0x731f,
2906 CARD_AMD_RADEON_RX_NAVI_14 = 0x7340,
2907 CARD_AMD_RADEON_RX_NAVI_21 = 0x73bf,
2909 CARD_NVIDIA_RIVA_128 = 0x0018,
2910 CARD_NVIDIA_RIVA_TNT = 0x0020,
2911 CARD_NVIDIA_RIVA_TNT2 = 0x0028,
2912 CARD_NVIDIA_GEFORCE = 0x0100,
2913 CARD_NVIDIA_GEFORCE2_MX = 0x0110,
2914 CARD_NVIDIA_GEFORCE2 = 0x0150,
2915 CARD_NVIDIA_GEFORCE3 = 0x0200,
2916 CARD_NVIDIA_GEFORCE4_MX = 0x0170,
2917 CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
2918 CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
2919 CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
2920 CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
2921 CARD_NVIDIA_GEFORCE_6200 = 0x014f,
2922 CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
2923 CARD_NVIDIA_GEFORCE_6800 = 0x0041,
2924 CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2925 CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
2926 CARD_NVIDIA_GEFORCE_7600 = 0x0391,
2927 CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
2928 CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2929 CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
2930 CARD_NVIDIA_GEFORCE_8400GS = 0x0404,
2931 CARD_NVIDIA_GEFORCE_8500GT = 0x0421,
2932 CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
2933 CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
2934 CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
2935 CARD_NVIDIA_GEFORCE_8800GTX = 0x0191,
2936 CARD_NVIDIA_GEFORCE_9200 = 0x086d,
2937 CARD_NVIDIA_GEFORCE_9300 = 0x086c,
2938 CARD_NVIDIA_GEFORCE_9400M = 0x0863,
2939 CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
2940 CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
2941 CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
2942 CARD_NVIDIA_GEFORCE_9700MGT = 0x064a,
2943 CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
2944 CARD_NVIDIA_GEFORCE_210 = 0x0a23,
2945 CARD_NVIDIA_GEFORCE_GT220 = 0x0a20,
2946 CARD_NVIDIA_GEFORCE_GT240 = 0x0ca3,
2947 CARD_NVIDIA_GEFORCE_GTS250 = 0x0615,
2948 CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
2949 CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
2950 CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
2951 CARD_NVIDIA_GEFORCE_315M = 0x0a7a,
2952 CARD_NVIDIA_GEFORCE_320M = 0x08a3,
2953 CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
2954 CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
2955 CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
2956 CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
2957 CARD_NVIDIA_GEFORCE_410M = 0x1055,
2958 CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
2959 CARD_NVIDIA_GEFORCE_GT425M = 0x0df0,
2960 CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
2961 CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
2962 CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
2963 CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
2964 CARD_NVIDIA_GEFORCE_GTX460M = 0x0dd1,
2965 CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
2966 CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
2967 CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
2968 CARD_NVIDIA_GEFORCE_GT520 = 0x1040,
2969 CARD_NVIDIA_GEFORCE_GT525M = 0x0dec,
2970 CARD_NVIDIA_GEFORCE_GT540M = 0x0df4,
2971 CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
2972 CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
2973 CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
2974 CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
2975 CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
2976 CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
2977 CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
2978 CARD_NVIDIA_GEFORCE_GT610 = 0x104a,
2979 CARD_NVIDIA_GEFORCE_GT630 = 0x0f00,
2980 CARD_NVIDIA_GEFORCE_GT630M = 0x0de9,
2981 CARD_NVIDIA_GEFORCE_GT640 = 0x0fc1,
2982 CARD_NVIDIA_GEFORCE_GT640M = 0x0fd2,
2983 CARD_NVIDIA_GEFORCE_GT650M = 0x0fd1,
2984 CARD_NVIDIA_GEFORCE_GTX650 = 0x0fc6,
2985 CARD_NVIDIA_GEFORCE_GTX650TI = 0x11c6,
2986 CARD_NVIDIA_GEFORCE_GTX660 = 0x11c0,
2987 CARD_NVIDIA_GEFORCE_GTX660M = 0x0fd4,
2988 CARD_NVIDIA_GEFORCE_GTX660TI = 0x1183,
2989 CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
2990 CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
2991 CARD_NVIDIA_GEFORCE_GTX675MX_1 = 0x11a7,
2992 CARD_NVIDIA_GEFORCE_GTX675MX_2 = 0x11a2,
2993 CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
2994 CARD_NVIDIA_GEFORCE_GTX690 = 0x1188,
2995 CARD_NVIDIA_GEFORCE_GT720 = 0x128b,
2996 CARD_NVIDIA_GEFORCE_GT730 = 0x1287,
2997 CARD_NVIDIA_GEFORCE_GT730M = 0x0fe1,
2998 CARD_NVIDIA_GEFORCE_GT740M = 0x1292,
2999 CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
3000 CARD_NVIDIA_GEFORCE_GT755M = 0x0fcd,
3001 CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
3002 CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
3003 CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
3004 CARD_NVIDIA_GEFORCE_GTX760TI = 0x1193,
3005 CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2,
3006 CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0,
3007 CARD_NVIDIA_GEFORCE_GTX770 = 0x1184,
3008 CARD_NVIDIA_GEFORCE_GTX775M = 0x119d,
3009 CARD_NVIDIA_GEFORCE_GTX780 = 0x1004,
3010 CARD_NVIDIA_GEFORCE_GTX780M = 0x119e,
3011 CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a,
3012 CARD_NVIDIA_GEFORCE_GTXTITAN = 0x1005,
3013 CARD_NVIDIA_GEFORCE_GTXTITANB = 0x100c,
3014 CARD_NVIDIA_GEFORCE_GTXTITANX = 0x17c2,
3015 CARD_NVIDIA_GEFORCE_GTXTITANZ = 0x1001,
3016 CARD_NVIDIA_GEFORCE_820M = 0x0fed,
3017 CARD_NVIDIA_GEFORCE_830M = 0x1340,
3018 CARD_NVIDIA_GEFORCE_840M = 0x1341,
3019 CARD_NVIDIA_GEFORCE_845M = 0x1344,
3020 CARD_NVIDIA_GEFORCE_GTX850M = 0x1391,
3021 CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
3022 CARD_NVIDIA_GEFORCE_GTX870M = 0x1199,
3023 CARD_NVIDIA_GEFORCE_GTX880M = 0x1198,
3024 CARD_NVIDIA_GEFORCE_940M = 0x1347,
3025 CARD_NVIDIA_GEFORCE_GTX950 = 0x1402,
3026 CARD_NVIDIA_GEFORCE_GTX950M = 0x139a,
3027 CARD_NVIDIA_GEFORCE_GTX960 = 0x1401,
3028 CARD_NVIDIA_GEFORCE_GTX960M = 0x139b,
3029 CARD_NVIDIA_GEFORCE_GTX970 = 0x13c2,
3030 CARD_NVIDIA_GEFORCE_GTX970M = 0x13d8,
3031 CARD_NVIDIA_GEFORCE_GTX980 = 0x13c0,
3032 CARD_NVIDIA_GEFORCE_GTX980TI = 0x17c8,
3033 CARD_NVIDIA_GEFORCE_GTX1050 = 0x1c81,
3034 CARD_NVIDIA_GEFORCE_GTX1050TI = 0x1c82,
3035 CARD_NVIDIA_GEFORCE_GTX1060_3GB = 0x1c02,
3036 CARD_NVIDIA_GEFORCE_GTX1060 = 0x1c03,
3037 CARD_NVIDIA_GEFORCE_GTX1060M = 0x1c20,
3038 CARD_NVIDIA_GEFORCE_GTX1070 = 0x1b81,
3039 CARD_NVIDIA_GEFORCE_GTX1080 = 0x1b80,
3040 CARD_NVIDIA_GEFORCE_GTX1080M = 0x1be0,
3041 CARD_NVIDIA_GEFORCE_GTX1080TI = 0x1b06,
3042 CARD_NVIDIA_TITANX_PASCAL = 0x1b00,
3043 CARD_NVIDIA_TITANV = 0x1d81,
3044 CARD_NVIDIA_GEFORCE_GTX1650SUPER= 0x2187,
3045 CARD_NVIDIA_GEFORCE_GTX1660SUPER= 0x21c4,
3046 CARD_NVIDIA_GEFORCE_GTX1660TI = 0x2182,
3047 CARD_NVIDIA_GEFORCE_RTX2060 = 0x1f08,
3048 CARD_NVIDIA_GEFORCE_RTX2070 = 0x1f07,
3049 CARD_NVIDIA_GEFORCE_RTX2080 = 0x1e87,
3050 CARD_NVIDIA_GEFORCE_RTX2080TI = 0x1e07,
3052 CARD_REDHAT_VIRGL = 0x1010,
3054 CARD_VMWARE_SVGA3D = 0x0405,
3056 CARD_INTEL_830M = 0x3577,
3057 CARD_INTEL_855GM = 0x3582,
3058 CARD_INTEL_845G = 0x2562,
3059 CARD_INTEL_865G = 0x2572,
3060 CARD_INTEL_915G = 0x2582,
3061 CARD_INTEL_E7221G = 0x258a,
3062 CARD_INTEL_915GM = 0x2592,
3063 CARD_INTEL_945G = 0x2772,
3064 CARD_INTEL_945GM = 0x27a2,
3065 CARD_INTEL_945GME = 0x27ae,
3066 CARD_INTEL_Q35 = 0x29b2,
3067 CARD_INTEL_G33 = 0x29c2,
3068 CARD_INTEL_Q33 = 0x29d2,
3069 CARD_INTEL_PNVG = 0xa001,
3070 CARD_INTEL_PNVM = 0xa011,
3071 CARD_INTEL_965Q = 0x2992,
3072 CARD_INTEL_965G = 0x2982,
3073 CARD_INTEL_946GZ = 0x2972,
3074 CARD_INTEL_965GM = 0x2a02,
3075 CARD_INTEL_965GME = 0x2a12,
3076 CARD_INTEL_GM45 = 0x2a42,
3077 CARD_INTEL_IGD = 0x2e02,
3078 CARD_INTEL_Q45 = 0x2e12,
3079 CARD_INTEL_G45 = 0x2e22,
3080 CARD_INTEL_G41 = 0x2e32,
3081 CARD_INTEL_B43 = 0x2e92,
3082 CARD_INTEL_ILKD = 0x0042,
3083 CARD_INTEL_ILKM = 0x0046,
3084 CARD_INTEL_SNBD = 0x0122,
3085 CARD_INTEL_SNBM = 0x0126,
3086 CARD_INTEL_SNBS = 0x010a,
3087 CARD_INTEL_IVBD = 0x0162,
3088 CARD_INTEL_IVBM = 0x0166,
3089 CARD_INTEL_IVBS = 0x015a,
3090 CARD_INTEL_HWD = 0x0412,
3091 CARD_INTEL_HWM = 0x0416,
3092 CARD_INTEL_HD5000_1 = 0x0a26,
3093 CARD_INTEL_HD5000_2 = 0x0422,
3094 CARD_INTEL_I5100_1 = 0x0a22,
3095 CARD_INTEL_I5100_2 = 0x0a2a,
3096 CARD_INTEL_I5100_3 = 0x0a2b,
3097 CARD_INTEL_I5100_4 = 0x0a2e,
3098 CARD_INTEL_IP5200_1 = 0x0d22,
3099 CARD_INTEL_IP5200_2 = 0x0d26,
3100 CARD_INTEL_IP5200_3 = 0x0d2a,
3101 CARD_INTEL_IP5200_4 = 0x0d2b,
3102 CARD_INTEL_IP5200_5 = 0x0d2e,
3103 CARD_INTEL_IP5200_6 = 0x0c22,
3104 CARD_INTEL_HD5300 = 0x161e,
3105 CARD_INTEL_HD5500 = 0x1616,
3106 CARD_INTEL_HD5600 = 0x1612,
3107 CARD_INTEL_HD6000 = 0x1626,
3108 CARD_INTEL_I6100 = 0x162b,
3109 CARD_INTEL_IP6200 = 0x1622,
3110 CARD_INTEL_IPP6300 = 0x162a,
3111 CARD_INTEL_HD510_1 = 0x1902,
3112 CARD_INTEL_HD510_2 = 0x1906,
3113 CARD_INTEL_HD510_3 = 0x190b,
3114 CARD_INTEL_HD515 = 0x191e,
3115 CARD_INTEL_HD520_1 = 0x1916,
3116 CARD_INTEL_HD520_2 = 0x1921,
3117 CARD_INTEL_HD530_1 = 0x1912,
3118 CARD_INTEL_HD530_2 = 0x191b,
3119 CARD_INTEL_HDP530 = 0x191d,
3120 CARD_INTEL_I540 = 0x1926,
3121 CARD_INTEL_I550 = 0x1927,
3122 CARD_INTEL_I555 = 0x192b,
3123 CARD_INTEL_IP555 = 0x192d,
3124 CARD_INTEL_IP580_1 = 0x1932,
3125 CARD_INTEL_IP580_2 = 0x193b,
3126 CARD_INTEL_IPP580_1 = 0x193a,
3127 CARD_INTEL_IPP580_2 = 0x193d,
3128 CARD_INTEL_UHD617 = 0x87c0,
3129 CARD_INTEL_UHD620 = 0x3ea0,
3130 CARD_INTEL_HD615 = 0x591e,
3131 CARD_INTEL_HD620 = 0x5916,
3132 CARD_INTEL_HD630_1 = 0x5912,
3133 CARD_INTEL_HD630_2 = 0x591b,
3136 struct wined3d_fbo_ops
3138 GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
3139 void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
3140 void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
3141 void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
3142 void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
3143 GLsizei width, GLsizei height);
3144 void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
3145 GLenum internalformat, GLsizei width, GLsizei height);
3146 void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
3147 GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
3148 void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
3149 void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
3150 void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
3151 GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
3152 void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
3153 GLuint texture, GLint level);
3154 void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
3155 GLenum textarget, GLuint texture, GLint level);
3156 void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
3157 GLenum textarget, GLuint texture, GLint level);
3158 void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
3159 GLenum textarget, GLuint texture, GLint level, GLint layer);
3160 void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
3161 GLuint texture, GLint level, GLint layer);
3162 void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
3163 GLenum renderbuffertarget, GLuint renderbuffer);
3164 void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
3165 GLenum pname, GLint *params);
3166 void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
3167 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
3168 void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
3171 struct wined3d_gl_limits
3173 UINT buffers;
3174 UINT lights;
3175 UINT textures;
3176 UINT texture_coords;
3177 unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
3178 unsigned int samplers[WINED3D_SHADER_TYPE_COUNT];
3179 unsigned int graphics_samplers;
3180 unsigned int combined_samplers;
3181 UINT general_combiners;
3182 UINT user_clip_distances;
3183 unsigned int texture_size;
3184 UINT texture3d_size;
3185 UINT anisotropy;
3186 float shininess;
3187 UINT samples;
3188 UINT vertex_attribs;
3190 unsigned int texture_buffer_offset_alignment;
3192 unsigned int framebuffer_width;
3193 unsigned int framebuffer_height;
3195 UINT glsl_varyings;
3196 UINT glsl_vs_float_constants;
3197 UINT glsl_ps_float_constants;
3199 UINT arb_vs_float_constants;
3200 UINT arb_vs_native_constants;
3201 UINT arb_vs_instructions;
3202 UINT arb_vs_temps;
3203 UINT arb_ps_float_constants;
3204 UINT arb_ps_local_constants;
3205 UINT arb_ps_native_constants;
3206 UINT arb_ps_instructions;
3207 UINT arb_ps_temps;
3210 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
3211 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
3212 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits,
3213 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
3215 struct wined3d_gl_info
3217 DWORD selected_gl_version;
3218 DWORD glsl_version;
3219 struct wined3d_gl_limits limits;
3220 DWORD reserved_glsl_constants, reserved_arb_constants;
3221 DWORD quirks;
3222 BOOL supported[WINED3D_GL_EXT_COUNT];
3223 GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
3225 HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
3226 struct opengl_funcs gl_ops;
3227 struct wined3d_fbo_ops fbo_ops;
3229 void (WINE_GLAPI *p_glDisableWINE)(GLenum cap);
3230 void (WINE_GLAPI *p_glEnableWINE)(GLenum cap);
3233 /* The driver names reflect the lowest GPU supported
3234 * by a certain driver, so DRIVER_AMD_R300 supports
3235 * R3xx, R4xx and R5xx GPUs. */
3236 enum wined3d_display_driver
3238 DRIVER_AMD_RAGE_128PRO,
3239 DRIVER_AMD_R100,
3240 DRIVER_AMD_R300,
3241 DRIVER_AMD_R600,
3242 DRIVER_AMD_RX,
3243 DRIVER_INTEL_GMA800,
3244 DRIVER_INTEL_GMA900,
3245 DRIVER_INTEL_GMA950,
3246 DRIVER_INTEL_GMA3000,
3247 DRIVER_INTEL_HD4000,
3248 DRIVER_NVIDIA_TNT,
3249 DRIVER_NVIDIA_GEFORCE2MX,
3250 DRIVER_NVIDIA_GEFORCEFX,
3251 DRIVER_NVIDIA_GEFORCE6,
3252 DRIVER_NVIDIA_GEFORCE8,
3253 DRIVER_NVIDIA_FERMI,
3254 DRIVER_NVIDIA_KEPLER,
3255 DRIVER_REDHAT_VIRGL,
3256 DRIVER_VMWARE,
3257 DRIVER_WINE,
3258 DRIVER_UNKNOWN,
3261 struct wined3d_gpu_description
3263 enum wined3d_pci_vendor vendor;
3264 enum wined3d_pci_device device;
3265 const char *description;
3266 enum wined3d_display_driver driver;
3267 unsigned int vidmem;
3270 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
3271 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
3272 const struct wined3d_gpu_description *wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor,
3273 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
3274 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
3275 enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
3277 /* 512 in Direct3D 8/9, 128 in DXGI. */
3278 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
3280 struct wined3d_driver_info
3282 enum wined3d_pci_vendor vendor;
3283 enum wined3d_pci_device device;
3284 const char *name;
3285 char description[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH];
3286 UINT64 vram_bytes;
3287 UINT64 sysmem_bytes;
3288 DWORD version_high;
3289 DWORD version_low;
3292 bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
3293 const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level,
3294 UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
3296 struct wined3d_adapter_ops
3298 void (*adapter_destroy)(struct wined3d_adapter *adapter);
3299 HRESULT (*adapter_create_device)(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
3300 enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3301 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3302 struct wined3d_device_parent *device_parent, struct wined3d_device **device);
3303 void (*adapter_destroy_device)(struct wined3d_device *device);
3304 struct wined3d_context *(*adapter_acquire_context)(struct wined3d_device *device,
3305 struct wined3d_texture *texture, unsigned int sub_resource_idx);
3306 void (*adapter_release_context)(struct wined3d_context *context);
3307 void (*adapter_get_wined3d_caps)(const struct wined3d_adapter *adapter, struct wined3d_caps *caps);
3308 BOOL (*adapter_check_format)(const struct wined3d_adapter *adapter,
3309 const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
3310 const struct wined3d_format *ds_format);
3311 HRESULT (*adapter_init_3d)(struct wined3d_device *device);
3312 void (*adapter_uninit_3d)(struct wined3d_device *device);
3313 void *(*adapter_map_bo_address)(struct wined3d_context *context,
3314 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags);
3315 void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data,
3316 unsigned int range_count, const struct wined3d_range *ranges);
3317 void (*adapter_copy_bo_address)(struct wined3d_context *context,
3318 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size);
3319 HRESULT (*adapter_create_swapchain)(struct wined3d_device *device,
3320 struct wined3d_swapchain_desc *desc,
3321 struct wined3d_swapchain_state_parent *state_parent, void *parent,
3322 const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
3323 void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain);
3324 HRESULT (*adapter_create_buffer)(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
3325 const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
3326 struct wined3d_buffer **buffer);
3327 void (*adapter_destroy_buffer)(struct wined3d_buffer *buffer);
3328 HRESULT (*adapter_create_texture)(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
3329 unsigned int layer_count, unsigned int level_count, uint32_t flags, void *parent,
3330 const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
3331 void (*adapter_destroy_texture)(struct wined3d_texture *texture);
3332 HRESULT (*adapter_create_rendertarget_view)(const struct wined3d_view_desc *desc,
3333 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3334 struct wined3d_rendertarget_view **view);
3335 void (*adapter_destroy_rendertarget_view)(struct wined3d_rendertarget_view *view);
3336 HRESULT (*adapter_create_shader_resource_view)(const struct wined3d_view_desc *desc,
3337 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3338 struct wined3d_shader_resource_view **view);
3339 void (*adapter_destroy_shader_resource_view)(struct wined3d_shader_resource_view *view);
3340 HRESULT (*adapter_create_unordered_access_view)(const struct wined3d_view_desc *desc,
3341 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3342 struct wined3d_unordered_access_view **view);
3343 void (*adapter_destroy_unordered_access_view)(struct wined3d_unordered_access_view *view);
3344 HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3345 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
3346 void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
3347 HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
3348 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
3349 void (*adapter_destroy_query)(struct wined3d_query *query);
3350 void (*adapter_flush_context)(struct wined3d_context *context);
3351 void (*adapter_draw_primitive)(struct wined3d_device *device, const struct wined3d_state *state,
3352 const struct wined3d_draw_parameters *parameters);
3353 void (*adapter_dispatch_compute)(struct wined3d_device *device, const struct wined3d_state *state,
3354 const struct wined3d_dispatch_parameters *parameters);
3355 void (*adapter_clear_uav)(struct wined3d_context *context,
3356 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value);
3357 void (*adapter_generate_mipmap)(struct wined3d_context *context, struct wined3d_shader_resource_view *view);
3360 struct wined3d_output
3362 unsigned int ordinal;
3363 WCHAR device_name[CCHDEVICENAME];
3364 struct wined3d_adapter *adapter;
3365 enum wined3d_format_id screen_format;
3367 D3DKMT_HANDLE kmt_adapter;
3368 D3DKMT_HANDLE kmt_device;
3369 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id;
3372 HRESULT wined3d_output_get_gamma_ramp(struct wined3d_output *output, struct wined3d_gamma_ramp *ramp) DECLSPEC_HIDDEN;
3374 /* The adapter structure */
3375 struct wined3d_adapter
3377 unsigned int ordinal;
3379 struct wined3d_gl_info gl_info;
3380 struct wined3d_d3d_info d3d_info;
3381 struct wined3d_driver_info driver_info;
3382 struct wined3d_output *outputs;
3383 unsigned int output_count;
3384 UINT64 vram_bytes_used;
3385 GUID driver_uuid;
3386 GUID device_uuid;
3387 LUID luid;
3389 void *formats;
3390 size_t format_size;
3392 const struct wined3d_vertex_pipe_ops *vertex_pipe;
3393 const struct wined3d_fragment_pipe_ops *fragment_pipe;
3394 const struct wined3d_state_entry_template *misc_state_template;
3395 const struct wined3d_shader_backend_ops *shader_backend;
3396 const struct wined3d_adapter_ops *adapter_ops;
3399 BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal, const LUID *luid,
3400 const struct wined3d_adapter_ops *adapter_ops) DECLSPEC_HIDDEN;
3401 void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
3402 BOOL wined3d_get_primary_adapter_luid(LUID *luid) DECLSPEC_HIDDEN;
3404 struct wined3d_adapter_gl
3406 struct wined3d_adapter a;
3408 struct wined3d_pixel_format *pixel_formats;
3409 unsigned int pixel_format_count;
3412 static inline struct wined3d_adapter_gl *wined3d_adapter_gl(struct wined3d_adapter *adapter)
3414 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
3417 static inline const struct wined3d_adapter_gl *wined3d_adapter_gl_const(const struct wined3d_adapter *adapter)
3419 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
3422 struct wined3d_adapter *wined3d_adapter_gl_create(unsigned int ordinal,
3423 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
3425 struct wined3d_adapter_vk
3427 struct wined3d_adapter a;
3429 struct wined3d_vk_info vk_info;
3430 unsigned int device_extension_count;
3431 const char **device_extensions;
3432 VkPhysicalDevice physical_device;
3434 VkPhysicalDeviceLimits device_limits;
3435 VkPhysicalDeviceMemoryProperties memory_properties;
3438 static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter)
3440 return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a);
3443 struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
3444 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
3445 unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
3446 uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
3448 struct wined3d_caps_gl_ctx
3450 HDC dc;
3451 HWND wnd;
3452 HGLRC gl_ctx;
3453 HDC restore_dc;
3454 HGLRC restore_gl_ctx;
3456 const struct wined3d_gl_info *gl_info;
3457 GLuint test_vbo;
3458 GLuint test_program_id;
3460 const struct wined3d_gpu_description *gpu_description;
3461 UINT64 vram_bytes;
3464 BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
3465 struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3466 BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
3467 BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk,
3468 const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN;
3469 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
3471 BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3473 void install_gl_compat_wrapper(struct wined3d_gl_info *gl_info, enum wined3d_gl_extension ext) DECLSPEC_HIDDEN;
3475 enum wined3d_projection_type
3477 WINED3D_PROJECTION_NONE = 0,
3478 WINED3D_PROJECTION_COUNT3 = 1,
3479 WINED3D_PROJECTION_COUNT4 = 2
3482 /*****************************************************************************
3483 * Fixed function pipeline replacements
3485 #define ARG_UNUSED 0xff
3486 struct texture_stage_op
3488 unsigned cop : 8;
3489 unsigned carg1 : 8;
3490 unsigned carg2 : 8;
3491 unsigned carg0 : 8;
3493 unsigned aop : 8;
3494 unsigned aarg1 : 8;
3495 unsigned aarg2 : 8;
3496 unsigned aarg0 : 8;
3498 struct color_fixup_desc color_fixup;
3499 unsigned tex_type : 3;
3500 unsigned tmp_dst : 1;
3501 unsigned projected : 2;
3502 unsigned padding : 10;
3505 struct ffp_frag_settings
3507 struct texture_stage_op op[WINED3D_MAX_TEXTURES];
3508 enum wined3d_ffp_ps_fog_mode fog;
3509 unsigned char sRGB_write;
3510 unsigned char emul_clipplanes;
3511 unsigned char texcoords_initialized;
3512 unsigned char color_key_enabled : 1;
3513 unsigned char pointsprite : 1;
3514 unsigned char flatshading : 1;
3515 unsigned char alpha_test_func : 3;
3516 unsigned char padding : 2;
3519 struct ffp_frag_desc
3521 struct wine_rb_entry entry;
3522 struct ffp_frag_settings settings;
3525 int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3526 int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3528 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
3530 void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
3531 struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
3532 const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
3533 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
3534 void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
3535 void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
3537 enum wined3d_ffp_vs_fog_mode
3539 WINED3D_FFP_VS_FOG_OFF = 0,
3540 WINED3D_FFP_VS_FOG_FOGCOORD = 1,
3541 WINED3D_FFP_VS_FOG_DEPTH = 2,
3542 WINED3D_FFP_VS_FOG_RANGE = 3,
3545 #define WINED3D_FFP_TCI_SHIFT 16
3546 #define WINED3D_FFP_TCI_MASK 0xffu
3548 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3549 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3551 struct wined3d_ffp_vs_settings
3553 DWORD point_light_count : 4;
3554 DWORD spot_light_count : 4;
3555 DWORD directional_light_count : 4;
3556 DWORD parallel_point_light_count : 4;
3557 DWORD diffuse_source : 2;
3558 DWORD emissive_source : 2;
3559 DWORD ambient_source : 2;
3560 DWORD specular_source : 2;
3561 DWORD transformed : 1;
3562 DWORD vertexblends : 2;
3563 DWORD clipping : 1;
3564 DWORD normal : 1;
3565 DWORD normalize : 1;
3566 DWORD lighting : 1;
3567 DWORD localviewer : 1;
3569 DWORD point_size : 1;
3570 DWORD per_vertex_point_size : 1;
3571 DWORD fog_mode : 2;
3572 DWORD texcoords : 8; /* WINED3D_MAX_TEXTURES */
3573 DWORD ortho_fog : 1;
3574 DWORD flatshading : 1;
3575 DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
3576 DWORD padding : 2;
3578 DWORD texgen[WINED3D_MAX_TEXTURES];
3581 struct wined3d_ffp_vs_desc
3583 struct wine_rb_entry entry;
3584 struct wined3d_ffp_vs_settings settings;
3587 void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
3588 const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) DECLSPEC_HIDDEN;
3590 struct wined3d
3592 LONG ref;
3593 unsigned int flags;
3594 unsigned int adapter_count;
3595 struct wined3d_adapter *adapters[1];
3598 BOOL wined3d_filter_messages(HWND window, BOOL filter) DECLSPEC_HIDDEN;
3599 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN;
3600 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
3602 BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size) DECLSPEC_HIDDEN;
3604 struct wined3d_blend_state
3606 LONG refcount;
3607 struct wined3d_blend_state_desc desc;
3608 BOOL dual_source;
3610 void *parent;
3611 const struct wined3d_parent_ops *parent_ops;
3613 struct wined3d_device *device;
3614 struct wine_rb_entry entry;
3617 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state *state,
3618 unsigned int index)
3620 if (!state)
3621 return 0xf;
3622 if (!state->desc.independent)
3623 index = 0;
3624 return state->desc.rt[index].writemask;
3627 struct wined3d_depth_stencil_state
3629 LONG refcount;
3630 struct wined3d_depth_stencil_state_desc desc;
3632 void *parent;
3633 const struct wined3d_parent_ops *parent_ops;
3635 struct wined3d_device *device;
3636 struct wine_rb_entry entry;
3639 struct wined3d_rasterizer_state
3641 LONG refcount;
3642 struct wined3d_rasterizer_state_desc desc;
3644 void *parent;
3645 const struct wined3d_parent_ops *parent_ops;
3647 struct wined3d_device *device;
3648 struct wine_rb_entry entry;
3651 struct wined3d_stream_output
3653 struct wined3d_buffer *buffer;
3654 UINT offset;
3657 #define LIGHTMAP_SIZE 43
3658 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
3660 struct wined3d_light_state
3662 /* Light hashmap. Collisions are handled using linked lists. */
3663 struct list light_map[LIGHTMAP_SIZE];
3664 const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS];
3667 #define WINED3D_STATE_NO_REF 0x00000001
3668 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3670 struct wined3d_state
3672 enum wined3d_feature_level feature_level;
3673 uint32_t flags;
3674 struct wined3d_fb_state fb;
3676 struct wined3d_vertex_declaration *vertex_declaration;
3677 struct wined3d_stream_output stream_output[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
3678 struct wined3d_stream_state streams[WINED3D_MAX_STREAMS];
3679 struct wined3d_buffer *index_buffer;
3680 enum wined3d_format_id index_format;
3681 unsigned int index_offset;
3682 int base_vertex_index;
3683 int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3684 enum wined3d_primitive_type primitive_type;
3685 unsigned int patch_vertex_count;
3686 struct wined3d_query *predicate;
3687 BOOL predicate_value;
3689 struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
3690 struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
3691 struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
3692 struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
3693 struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
3695 struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3696 struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
3697 BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
3699 struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3700 struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
3701 BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
3703 struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
3704 DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
3705 DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
3707 struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3708 struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES];
3709 struct wined3d_material material;
3710 struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS];
3711 unsigned int viewport_count;
3712 RECT scissor_rects[WINED3D_MAX_VIEWPORTS];
3713 unsigned int scissor_rect_count;
3715 struct wined3d_light_state light_state;
3717 DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
3718 struct wined3d_blend_state *blend_state;
3719 struct wined3d_color blend_factor;
3720 unsigned int sample_mask;
3721 struct wined3d_depth_stencil_state *depth_stencil_state;
3722 unsigned int stencil_ref;
3723 struct wined3d_rasterizer_state *rasterizer_state;
3726 void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
3727 void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info,
3728 uint32_t flags, enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
3729 void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
3731 static inline void wined3d_state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
3733 enum wined3d_feature_level feature_level = state->feature_level;
3734 uint32_t flags = state->flags;
3736 memset(state, 0, sizeof(*state));
3737 state_init(state, d3d_info, flags, feature_level);
3740 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state)
3742 if (!state->depth_stencil_state)
3743 return true;
3744 return state->depth_stencil_state->desc.depth || state->depth_stencil_state->desc.depth_write
3745 || state->depth_stencil_state->desc.stencil;
3748 struct wined3d_dummy_textures
3750 GLuint tex_1d;
3751 GLuint tex_2d;
3752 GLuint tex_rect;
3753 GLuint tex_3d;
3754 GLuint tex_cube;
3755 GLuint tex_cube_array;
3756 GLuint tex_1d_array;
3757 GLuint tex_2d_array;
3758 GLuint tex_buffer;
3759 GLuint tex_2d_ms;
3760 GLuint tex_2d_ms_array;
3763 #define WINED3D_UNMAPPED_STAGE ~0u
3765 /* Multithreaded flag. Removed from the public header to signal that
3766 * wined3d_device_create() ignores it. */
3767 #define WINED3DCREATE_MULTITHREADED 0x00000004
3769 struct wined3d_so_desc_entry
3771 struct wine_rb_entry entry;
3772 struct wined3d_stream_output_desc desc;
3773 struct wined3d_stream_output_element elements[1];
3776 struct wined3d_device
3778 LONG ref;
3780 /* WineD3D Information */
3781 struct wined3d_device_parent *device_parent;
3782 struct wined3d *wined3d;
3783 struct wined3d_adapter *adapter;
3785 const struct wined3d_shader_backend_ops *shader_backend;
3786 void *shader_priv;
3787 void *fragment_priv;
3788 void *vertex_priv;
3789 struct wined3d_state_entry state_table[STATE_HIGHEST + 1];
3790 /* Array of functions for states which are handled by more than one pipeline part */
3791 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
3792 struct wined3d_blitter *blitter;
3794 BYTE bCursorVisible : 1;
3795 BYTE d3d_initialized : 1;
3796 BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3797 BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
3798 BYTE restore_screensaver : 1;
3799 BYTE padding : 3;
3801 unsigned char surface_alignment; /* Line Alignment of surfaces */
3803 WORD padding2 : 16;
3805 /* Internal use fields */
3806 struct wined3d_device_creation_parameters create_parms;
3807 HWND focus_window;
3809 struct wined3d_rendertarget_view *back_buffer_view;
3810 struct wined3d_swapchain **swapchains;
3811 UINT swapchain_count;
3812 unsigned int max_frame_latency;
3814 struct list resources; /* a linked list to track resources created by the device */
3815 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
3816 struct wine_rb_tree so_descs;
3817 struct wine_rb_tree samplers, rasterizer_states, blend_states, depth_stencil_states;
3819 /* Render Target Support */
3820 struct wined3d_rendertarget_view *auto_depth_stencil_view;
3822 /* Cursor management */
3823 UINT xHotSpot;
3824 UINT yHotSpot;
3825 UINT xScreenSpace;
3826 UINT yScreenSpace;
3827 UINT cursorWidth, cursorHeight;
3828 struct wined3d_texture *cursor_texture;
3829 HCURSOR hardwareCursor;
3831 /* The Wine logo texture */
3832 struct wined3d_texture *logo_texture;
3834 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3835 struct wined3d_sampler *default_sampler;
3836 struct wined3d_sampler *null_sampler;
3838 /* Command stream */
3839 struct wined3d_cs *cs;
3841 /* Context management */
3842 struct wined3d_context **contexts;
3843 UINT context_count;
3846 void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN;
3847 BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3848 void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3849 void wined3d_device_create_default_samplers(struct wined3d_device *device,
3850 struct wined3d_context *context) DECLSPEC_HIDDEN;
3851 void wined3d_device_create_primary_opengl_context_cs(void *object) DECLSPEC_HIDDEN;
3852 void wined3d_device_delete_opengl_contexts_cs(void *object) DECLSPEC_HIDDEN;
3853 void wined3d_device_destroy_default_samplers(struct wined3d_device *device,
3854 struct wined3d_context *context) DECLSPEC_HIDDEN;
3855 HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d,
3856 unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3857 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3858 const BOOL *supported_extensions, struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3859 LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
3860 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
3861 void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3862 void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3863 void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
3864 HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device,
3865 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3866 void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN;
3868 struct wined3d_device_no3d
3870 struct wined3d_device d;
3872 struct wined3d_context context_no3d;
3875 static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_device *device)
3877 return CONTAINING_RECORD(device, struct wined3d_device_no3d, d);
3880 struct wined3d_device_gl
3882 struct wined3d_device d;
3884 /* Textures for when no other textures are bound. */
3885 struct wined3d_dummy_textures dummy_textures;
3887 uint64_t completed_fence_id;
3888 uint64_t current_fence_id;
3891 static inline struct wined3d_device_gl *wined3d_device_gl(struct wined3d_device *device)
3893 return CONTAINING_RECORD(device, struct wined3d_device_gl, d);
3896 struct wined3d_null_resources_vk
3898 struct wined3d_bo_vk bo;
3899 VkDescriptorBufferInfo buffer_info;
3901 struct wined3d_image_vk image_1d;
3902 struct wined3d_image_vk image_2d;
3903 struct wined3d_image_vk image_2dms;
3904 struct wined3d_image_vk image_3d;
3907 struct wined3d_null_views_vk
3909 VkBufferView vk_view_buffer_uint;
3910 VkBufferView vk_view_buffer_float;
3912 VkDescriptorImageInfo vk_info_1d;
3913 VkDescriptorImageInfo vk_info_2d;
3914 VkDescriptorImageInfo vk_info_2dms;
3915 VkDescriptorImageInfo vk_info_3d;
3916 VkDescriptorImageInfo vk_info_cube;
3917 VkDescriptorImageInfo vk_info_1d_array;
3918 VkDescriptorImageInfo vk_info_2d_array;
3919 VkDescriptorImageInfo vk_info_2dms_array;
3922 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
3923 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
3924 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
3925 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
3926 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
3928 struct wined3d_allocator_chunk
3930 struct list entry;
3931 struct list available[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT];
3932 struct wined3d_allocator *allocator;
3933 unsigned int map_count;
3934 void *map_ptr;
3937 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk *chunk) DECLSPEC_HIDDEN;
3938 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk *chunk,
3939 struct wined3d_allocator *allocator) DECLSPEC_HIDDEN;
3941 struct wined3d_allocator_chunk_vk
3943 struct wined3d_allocator_chunk c;
3944 VkDeviceMemory vk_memory;
3947 static inline struct wined3d_allocator_chunk_vk *wined3d_allocator_chunk_vk(struct wined3d_allocator_chunk *chunk)
3949 return CONTAINING_RECORD(chunk, struct wined3d_allocator_chunk_vk, c);
3952 void *wined3d_allocator_chunk_vk_map(struct wined3d_allocator_chunk_vk *chunk_vk,
3953 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3954 void wined3d_allocator_chunk_vk_unmap(struct wined3d_allocator_chunk_vk *chunk_vk,
3955 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3957 struct wined3d_allocator_block
3959 struct list entry;
3960 struct wined3d_allocator_chunk *chunk;
3961 struct wined3d_allocator_block *parent, *sibling;
3962 unsigned int order;
3963 size_t offset;
3964 bool free;
3967 void wined3d_allocator_block_free(struct wined3d_allocator_block *block) DECLSPEC_HIDDEN;
3969 struct wined3d_allocator_pool
3971 struct list chunks;
3974 struct wined3d_allocator_ops
3976 struct wined3d_allocator_chunk *(*allocator_create_chunk)(struct wined3d_allocator *allocator,
3977 struct wined3d_context *context, unsigned int memory_type, size_t chunk_size);
3978 void (*allocator_destroy_chunk)(struct wined3d_allocator_chunk *chunk);
3981 struct wined3d_allocator
3983 const struct wined3d_allocator_ops *ops;
3984 struct wined3d_allocator_pool *pools;
3985 size_t pool_count;
3986 struct wined3d_allocator_block *free;
3989 struct wined3d_allocator_block *wined3d_allocator_allocate(struct wined3d_allocator *allocator,
3990 struct wined3d_context *context, unsigned int memory_type, size_t size) DECLSPEC_HIDDEN;
3991 void wined3d_allocator_cleanup(struct wined3d_allocator *allocator) DECLSPEC_HIDDEN;
3992 bool wined3d_allocator_init(struct wined3d_allocator *allocator,
3993 size_t pool_count, const struct wined3d_allocator_ops *allocator_ops) DECLSPEC_HIDDEN;
3995 struct wined3d_device_vk
3997 struct wined3d_device d;
3999 struct wined3d_context_vk context_vk;
4001 VkDevice vk_device;
4002 VkQueue vk_queue;
4003 uint32_t vk_queue_family_index;
4004 uint32_t timestamp_bits;
4006 struct wined3d_vk_info vk_info;
4008 struct wined3d_null_resources_vk null_resources_vk;
4009 struct wined3d_null_views_vk null_views_vk;
4011 struct wined3d_allocator allocator;
4014 static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
4016 return CONTAINING_RECORD(device, struct wined3d_device_vk, d);
4019 bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk,
4020 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4021 bool wined3d_device_vk_create_null_views(struct wined3d_device_vk *device_vk,
4022 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4023 void wined3d_device_vk_destroy_null_resources(struct wined3d_device_vk *device_vk,
4024 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4025 void wined3d_device_vk_destroy_null_views(struct wined3d_device_vk *device_vk,
4026 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4028 static inline float wined3d_alpha_ref(const struct wined3d_state *state)
4030 return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
4033 const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
4034 const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN;
4035 const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d,
4036 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4037 const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
4039 static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
4041 return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
4044 struct wined3d_resource_ops
4046 ULONG (*resource_incref)(struct wined3d_resource *resource);
4047 ULONG (*resource_decref)(struct wined3d_resource *resource);
4048 void (*resource_preload)(struct wined3d_resource *resource);
4049 void (*resource_unload)(struct wined3d_resource *resource);
4050 HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
4051 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
4052 HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
4055 struct wined3d_resource
4057 LONG ref;
4058 LONG bind_count;
4059 LONG map_count;
4060 LONG access_count;
4061 struct wined3d_device *device;
4062 enum wined3d_resource_type type;
4063 enum wined3d_gl_resource_type gl_type;
4064 const struct wined3d_format *format;
4065 unsigned int format_flags;
4066 enum wined3d_multisample_type multisample_type;
4067 UINT multisample_quality;
4068 DWORD usage;
4069 unsigned int bind_flags;
4070 unsigned int access;
4071 WORD draw_binding;
4072 WORD map_binding;
4073 UINT width;
4074 UINT height;
4075 UINT depth;
4076 UINT size;
4077 DWORD priority;
4078 void *heap_memory;
4080 void *parent;
4081 const struct wined3d_parent_ops *parent_ops;
4082 const struct wined3d_resource_ops *resource_ops;
4084 struct list resource_list_entry;
4086 struct
4088 uint32_t srv;
4089 uint32_t rtv;
4091 *sub_resource_bind_counts_device;
4092 uint32_t srv_full_bind_count_device;
4093 uint32_t rtv_full_bind_count_device;
4094 uint32_t srv_partial_bind_count_device;
4095 uint32_t rtv_partial_bind_count_device;
4098 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
4100 return resource->resource_ops->resource_incref(resource);
4103 static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
4105 return resource->resource_ops->resource_decref(resource);
4108 static inline void wined3d_resource_acquire(struct wined3d_resource *resource)
4110 InterlockedIncrement(&resource->access_count);
4113 static inline void wined3d_resource_release(struct wined3d_resource *resource)
4115 InterlockedDecrement(&resource->access_count);
4118 void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4119 HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
4120 enum wined3d_resource_type type, const struct wined3d_format *format,
4121 enum wined3d_multisample_type multisample_type, unsigned int multisample_quality, unsigned int usage,
4122 unsigned int bind_flags, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
4123 unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
4124 const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
4125 void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4126 void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4127 const struct wined3d_format *wined3d_resource_get_decompress_format(
4128 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4129 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4130 GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
4131 GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
4132 GLbitfield wined3d_resource_gl_storage_flags(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4133 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4134 BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4135 void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4137 /* Tests show that the start address of resources is 32 byte aligned */
4138 #define RESOURCE_ALIGNMENT 16
4139 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
4141 #define WINED3D_LOCATION_DISCARDED 0x00000001
4142 #define WINED3D_LOCATION_SYSMEM 0x00000002
4143 #define WINED3D_LOCATION_BUFFER 0x00000008
4144 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
4145 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
4146 #define WINED3D_LOCATION_DRAWABLE 0x00000040
4147 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
4148 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
4150 const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN;
4152 struct wined3d_blt_info
4154 GLenum bind_target;
4155 struct wined3d_vec3 texcoords[4];
4158 struct wined3d_texture_ops
4160 BOOL (*texture_prepare_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4161 struct wined3d_context *context, unsigned int location);
4162 BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4163 struct wined3d_context *context, unsigned int location);
4164 void (*texture_unload_location)(struct wined3d_texture *texture,
4165 struct wined3d_context *context, unsigned int location);
4166 void (*texture_upload_data)(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr,
4167 const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch,
4168 unsigned int src_slice_pitch, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4169 unsigned int dst_location, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z);
4170 void (*texture_download_data)(struct wined3d_context *context, struct wined3d_texture *src_texture,
4171 unsigned int src_sub_resource_idx, unsigned int src_location, const struct wined3d_box *src_box,
4172 const struct wined3d_bo_address *dst_bo_addr, const struct wined3d_format *dst_format,
4173 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z,
4174 unsigned int dst_row_pitch, unsigned int dst_slice_pitch);
4177 #define WINED3D_TEXTURE_COND_NP2 0x00000001
4178 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
4179 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
4180 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
4181 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
4182 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
4183 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
4184 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
4185 #define WINED3D_TEXTURE_CONVERTED 0x00000100
4186 #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
4187 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
4188 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
4189 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
4190 #define WINED3D_TEXTURE_DISCARD 0x00002000
4191 #define WINED3D_TEXTURE_GET_DC 0x00004000
4192 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
4193 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
4195 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
4197 struct wined3d_texture
4199 struct wined3d_resource resource;
4200 const struct wined3d_texture_ops *texture_ops;
4201 struct wined3d_swapchain *swapchain;
4202 unsigned int pow2_width;
4203 unsigned int pow2_height;
4204 UINT layer_count;
4205 UINT level_count;
4206 unsigned int download_count;
4207 unsigned int sysmem_count;
4208 float pow2_matrix[16];
4209 UINT lod;
4210 DWORD sampler;
4211 DWORD flags;
4212 DWORD update_map_binding;
4214 unsigned int row_pitch;
4215 unsigned int slice_pitch;
4217 /* May only be accessed from the command stream worker thread. */
4218 struct wined3d_texture_async
4220 DWORD flags;
4222 /* Color keys for DDraw */
4223 struct wined3d_color_key dst_blt_color_key;
4224 struct wined3d_color_key src_blt_color_key;
4225 struct wined3d_color_key dst_overlay_color_key;
4226 struct wined3d_color_key src_overlay_color_key;
4227 struct wined3d_color_key gl_color_key;
4228 DWORD color_key_flags;
4229 } async;
4231 struct wined3d_dirty_regions
4233 struct wined3d_box *boxes;
4234 SIZE_T boxes_size;
4235 unsigned int box_count;
4236 } *dirty_regions;
4238 struct wined3d_overlay_info
4240 struct list entry;
4241 struct list overlays;
4242 struct wined3d_texture *dst_texture;
4243 unsigned int dst_sub_resource_idx;
4244 RECT src_rect;
4245 RECT dst_rect;
4246 } *overlay_info;
4248 struct wined3d_dc_info
4250 HBITMAP bitmap;
4251 HDC dc;
4252 } *dc_info;
4254 struct wined3d_texture_sub_resource
4256 void *parent;
4257 const struct wined3d_parent_ops *parent_ops;
4259 unsigned int offset;
4260 unsigned int size;
4262 unsigned int map_count;
4263 uint32_t map_flags;
4264 DWORD locations;
4265 struct wined3d_bo_gl bo;
4267 void *user_memory;
4268 } *sub_resources;
4271 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s, SIZE_T level_count, SIZE_T layer_count)
4273 struct wined3d_texture *t;
4275 if (level_count > ((~(SIZE_T)0 - s) / sizeof(*t->sub_resources)) / layer_count)
4276 return NULL;
4278 return heap_alloc_zero(s + level_count * layer_count * sizeof(*t->sub_resources));
4281 static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
4283 return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
4286 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture,
4287 unsigned int level)
4289 return max(1, texture->resource.width >> level);
4292 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture,
4293 unsigned int level)
4295 return max(1, texture->resource.height >> level);
4298 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture,
4299 unsigned int level)
4301 return max(1, texture->resource.depth >> level);
4304 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
4305 unsigned int level)
4307 return max(1, texture->pow2_width >> level);
4310 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
4311 unsigned int level)
4313 return max(1, texture->pow2_height >> level);
4316 static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture,
4317 unsigned int level, struct wined3d_box *box)
4319 wined3d_box_set(box, 0, 0,
4320 wined3d_texture_get_level_width(texture, level),
4321 wined3d_texture_get_level_height(texture, level),
4322 0, wined3d_texture_get_level_depth(texture, level));
4325 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture *texture,
4326 unsigned int level, const RECT *r)
4328 unsigned int t;
4330 t = wined3d_texture_get_level_width(texture, level);
4331 if ((r->left && r->right) || abs(r->right - r->left) != t)
4332 return false;
4333 t = wined3d_texture_get_level_height(texture, level);
4334 if ((r->top && r->bottom) || abs(r->bottom - r->top) != t)
4335 return false;
4336 return true;
4339 HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4340 const struct wined3d_box *dst_box, struct wined3d_texture *src_texture,
4341 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
4342 const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4343 void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
4344 const RECT *rect, struct wined3d_blt_info *info) DECLSPEC_HIDDEN;
4345 void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
4346 BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN;
4347 void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4348 struct wined3d_context *context, DWORD src_location, DWORD dst_location) DECLSPEC_HIDDEN;
4350 HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
4351 unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
4352 void wined3d_texture_cleanup(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4353 void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4354 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN;
4355 GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4356 void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4357 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4358 void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
4359 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
4360 void wined3d_texture_load(struct wined3d_texture *texture,
4361 struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
4362 BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
4363 unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4364 BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4365 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4366 void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN;
4367 void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
4368 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4369 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4370 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
4371 HWND window, RECT *rect) DECLSPEC_HIDDEN;
4372 void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4373 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture,
4374 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
4375 void wined3d_texture_validate_location(struct wined3d_texture *texture,
4376 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
4377 void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4379 HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device,
4380 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4381 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4383 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4384 void wined3d_vk_swizzle_from_color_fixup(VkComponentMapping *mapping, struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4386 struct gl_texture
4388 struct wined3d_sampler_desc sampler_desc;
4389 unsigned int base_level;
4390 GLuint name;
4393 struct wined3d_texture_gl
4395 struct wined3d_texture t;
4397 struct gl_texture texture_rgb, texture_srgb;
4399 GLenum target;
4401 GLuint rb_multisample;
4402 GLuint rb_resolved;
4404 struct list renderbuffers;
4405 const struct wined3d_renderbuffer_entry *current_renderbuffer;
4408 static inline struct wined3d_texture_gl *wined3d_texture_gl(struct wined3d_texture *texture)
4410 return CONTAINING_RECORD(texture, struct wined3d_texture_gl, t);
4413 static inline struct gl_texture *wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl *texture_gl,
4414 BOOL srgb)
4416 return srgb ? &texture_gl->texture_srgb : &texture_gl->texture_rgb;
4419 static inline GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl,
4420 unsigned int sub_resource_idx)
4422 static const GLenum cube_targets[] =
4424 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
4425 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
4426 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
4427 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
4428 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
4429 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
4432 return texture_gl->t.resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP
4433 ? cube_targets[sub_resource_idx / texture_gl->t.level_count] : texture_gl->target;
4436 static inline BOOL wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl *texture_gl,
4437 DWORD location)
4439 if (location == WINED3D_LOCATION_RB_MULTISAMPLE)
4440 return TRUE;
4441 if (location != WINED3D_LOCATION_TEXTURE_RGB && location != WINED3D_LOCATION_TEXTURE_SRGB)
4442 return FALSE;
4443 return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
4446 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl,
4447 const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4448 void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
4449 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4450 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
4451 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4452 HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, struct wined3d_device *device,
4453 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4454 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4455 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
4456 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4457 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl,
4458 struct wined3d_context_gl *context_gl, unsigned int level,
4459 const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;
4461 struct wined3d_texture_vk
4463 struct wined3d_texture t;
4465 struct wined3d_image_vk image;
4466 enum VkImageLayout layout;
4467 uint32_t bind_mask;
4469 VkDescriptorImageInfo default_image_info;
4472 static inline struct wined3d_texture_vk *wined3d_texture_vk(struct wined3d_texture *texture)
4474 return CONTAINING_RECORD(texture, struct wined3d_texture_vk, t);
4477 void wined3d_texture_vk_barrier(struct wined3d_texture_vk *texture_vk,
4478 struct wined3d_context_vk *context_vk, uint32_t bind_mask) DECLSPEC_HIDDEN;
4479 const VkDescriptorImageInfo *wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk *texture_vk,
4480 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4481 HRESULT wined3d_texture_vk_init(struct wined3d_texture_vk *texture_vk, struct wined3d_device *device,
4482 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4483 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4484 BOOL wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk *texture_vk,
4485 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4487 struct wined3d_renderbuffer_entry
4489 struct list entry;
4490 GLuint id;
4491 UINT width;
4492 UINT height;
4495 struct wined3d_fbo_resource
4497 GLuint object;
4498 GLenum target;
4499 GLuint level, layer;
4502 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
4503 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
4504 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
4506 struct fbo_entry
4508 struct list entry;
4509 DWORD flags;
4510 DWORD rt_mask;
4511 GLuint id;
4512 struct wined3d_fbo_entry_key
4514 DWORD rb_namespace;
4515 struct wined3d_fbo_resource objects[WINED3D_MAX_RENDER_TARGETS + 1];
4516 } key;
4519 struct wined3d_sampler
4521 struct wine_rb_entry entry;
4522 LONG refcount;
4523 struct wined3d_device *device;
4524 void *parent;
4525 const struct wined3d_parent_ops *parent_ops;
4526 struct wined3d_sampler_desc desc;
4529 struct wined3d_sampler_gl
4531 struct wined3d_sampler s;
4533 GLuint name;
4536 static inline struct wined3d_sampler_gl *wined3d_sampler_gl(struct wined3d_sampler *sampler)
4538 return CONTAINING_RECORD(sampler, struct wined3d_sampler_gl, s);
4541 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl *sampler_gl, unsigned int unit,
4542 struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4543 void wined3d_sampler_gl_init(struct wined3d_sampler_gl *sampler_gl,
4544 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
4545 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4547 struct wined3d_sampler_vk
4549 struct wined3d_sampler s;
4551 VkDescriptorImageInfo vk_image_info;
4552 uint64_t command_buffer_id;
4555 static inline struct wined3d_sampler_vk *wined3d_sampler_vk(struct wined3d_sampler *sampler)
4557 return CONTAINING_RECORD(sampler, struct wined3d_sampler_vk, s);
4560 void wined3d_sampler_vk_init(struct wined3d_sampler_vk *sampler_vk,
4561 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
4562 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4564 struct wined3d_vertex_declaration_element
4566 const struct wined3d_format *format;
4567 BOOL ffp_valid;
4568 unsigned int input_slot;
4569 unsigned int offset;
4570 unsigned int output_slot;
4571 enum wined3d_input_classification input_slot_class;
4572 unsigned int instance_data_step_rate;
4573 BYTE method;
4574 BYTE usage;
4575 BYTE usage_idx;
4578 struct wined3d_vertex_declaration
4580 LONG ref;
4581 void *parent;
4582 const struct wined3d_parent_ops *parent_ops;
4583 struct wined3d_device *device;
4585 struct wined3d_vertex_declaration_element *elements;
4586 unsigned int element_count;
4588 BOOL position_transformed;
4591 struct wined3d_saved_states
4593 uint32_t vs_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F)];
4594 WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
4595 WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
4596 uint32_t ps_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F)];
4597 WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
4598 WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
4599 uint32_t transform[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE + 1)];
4600 WORD streamSource; /* WINED3D_MAX_STREAMS, 16 */
4601 WORD streamFreq; /* WINED3D_MAX_STREAMS, 16 */
4602 uint32_t renderState[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE + 1)];
4603 DWORD textureState[WINED3D_MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
4604 WORD samplerState[WINED3D_MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
4605 DWORD clipplane; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
4606 DWORD textures : 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
4607 DWORD indices : 1;
4608 DWORD material : 1;
4609 DWORD viewport : 1;
4610 DWORD vertexDecl : 1;
4611 DWORD pixelShader : 1;
4612 DWORD vertexShader : 1;
4613 DWORD scissorRect : 1;
4614 DWORD store_stream_offset : 1;
4615 DWORD alpha_to_coverage : 1;
4616 DWORD lights : 1;
4617 DWORD transforms : 1;
4618 DWORD padding : 1;
4621 struct StageState {
4622 DWORD stage;
4623 DWORD state;
4626 struct wined3d_stateblock
4628 LONG ref; /* Note: Ref counting not required */
4629 struct wined3d_device *device;
4631 /* Array indicating whether things have been set or changed */
4632 struct wined3d_saved_states changed;
4634 struct wined3d_stateblock_state stateblock_state;
4635 struct wined3d_light_state light_state;
4637 /* Contained state management */
4638 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
4639 unsigned int num_contained_render_states;
4640 DWORD contained_transform_states[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
4641 unsigned int num_contained_transform_states;
4642 struct StageState contained_tss_states[WINED3D_MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
4643 unsigned int num_contained_tss_states;
4644 struct StageState contained_sampler_states[WINED3D_MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
4645 unsigned int num_contained_sampler_states;
4648 void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
4649 const struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
4650 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
4652 void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
4653 struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
4654 struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
4655 unsigned int idx) DECLSPEC_HIDDEN;
4656 HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
4657 const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
4659 enum wined3d_cs_queue_id
4661 WINED3D_CS_QUEUE_DEFAULT = 0,
4662 WINED3D_CS_QUEUE_MAP,
4663 WINED3D_CS_QUEUE_COUNT,
4666 enum wined3d_push_constants
4668 WINED3D_PUSH_CONSTANTS_VS_F,
4669 WINED3D_PUSH_CONSTANTS_PS_F,
4670 WINED3D_PUSH_CONSTANTS_VS_I,
4671 WINED3D_PUSH_CONSTANTS_PS_I,
4672 WINED3D_PUSH_CONSTANTS_VS_B,
4673 WINED3D_PUSH_CONSTANTS_PS_B,
4676 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
4677 #define WINED3D_CS_QUEUE_SIZE 0x100000u
4678 #define WINED3D_CS_SPIN_COUNT 10000000u
4680 struct wined3d_cs_queue
4682 LONG head, tail;
4683 BYTE data[WINED3D_CS_QUEUE_SIZE];
4686 struct wined3d_device_context_ops
4688 void *(*require_space)(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id);
4689 void (*submit)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
4690 void (*finish)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
4691 void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p,
4692 unsigned int start_idx, unsigned int count, const void *constants);
4693 HRESULT (*map)(struct wined3d_device_context *context, struct wined3d_resource *resource,
4694 unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box,
4695 unsigned int flags);
4696 HRESULT (*unmap)(struct wined3d_device_context *context, struct wined3d_resource *resource,
4697 unsigned int sub_resource_idx);
4698 void (*update_sub_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource,
4699 unsigned int sub_resource_idx, const struct wined3d_box *box,
4700 const void *data, unsigned int row_pitch, unsigned int slice_pitch);
4701 void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags);
4702 void (*flush)(struct wined3d_device_context *context);
4703 void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource);
4706 struct wined3d_device_context
4708 const struct wined3d_device_context_ops *ops;
4709 struct wined3d_device *device;
4710 struct wined3d_state *state;
4713 struct wined3d_cs
4715 struct wined3d_device_context c;
4717 struct wined3d_state state;
4718 HMODULE wined3d_module;
4719 HANDLE thread;
4720 DWORD thread_id;
4721 BOOL serialize_commands;
4723 struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
4724 size_t data_size, start, end;
4725 void *data;
4726 struct list query_poll_list;
4727 BOOL queries_flushed;
4729 HANDLE event;
4730 BOOL waiting_for_event;
4731 LONG pending_presents;
4734 struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device,
4735 const enum wined3d_feature_level *levels, unsigned int level_count) DECLSPEC_HIDDEN;
4736 void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4737 void wined3d_cs_destroy_object(struct wined3d_cs *cs,
4738 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4739 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
4740 struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
4741 void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
4742 DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4743 void wined3d_device_context_emit_clear_uav_uint(struct wined3d_device_context *context,
4744 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value) DECLSPEC_HIDDEN;
4745 void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4746 void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
4747 const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags) DECLSPEC_HIDDEN;
4748 void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4749 void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
4750 const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
4751 void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
4752 WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
4753 void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light_info *light) DECLSPEC_HIDDEN;
4754 void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) DECLSPEC_HIDDEN;
4755 void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
4756 void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
4757 enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
4758 void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx,
4759 UINT frequency, UINT flags) DECLSPEC_HIDDEN;
4760 void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
4761 const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
4762 void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4763 void wined3d_cs_init_object(struct wined3d_cs *cs,
4764 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4766 static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
4768 cs->c.ops->finish(&cs->c, queue_id);
4771 static inline void wined3d_device_context_push_constants(struct wined3d_device_context *context,
4772 enum wined3d_push_constants p, unsigned int start_idx, unsigned int count, const void *constants)
4774 context->ops->push_constants(context, p, start_idx, count, constants);
4777 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context *context,
4778 struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box,
4779 struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box,
4780 unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4781 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context *context,
4782 struct wined3d_rendertarget_view *view, const RECT *rect, unsigned int flags,
4783 const struct wined3d_color *color, float depth, unsigned int stencil) DECLSPEC_HIDDEN;
4784 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context *context,
4785 struct wined3d_buffer *dst_buffer, unsigned int offset,
4786 struct wined3d_unordered_access_view *uav) DECLSPEC_HIDDEN;
4787 void wined3d_device_context_emit_draw(struct wined3d_device_context *context,
4788 enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count, int base_vertex_idx,
4789 unsigned int start_idx, unsigned int index_count, unsigned int start_instance, unsigned int instance_count,
4790 bool indexed) DECLSPEC_HIDDEN;
4791 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context,
4792 struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4793 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context,
4794 struct wined3d_blend_state *state, const struct wined3d_color *blend_factor,
4795 unsigned int sample_mask) DECLSPEC_HIDDEN;
4796 void wined3d_device_context_emit_set_constant_buffer(struct wined3d_device_context *context,
4797 enum wined3d_shader_type type, UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4798 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context *context,
4799 struct wined3d_depth_stencil_state *state, unsigned int stencil_ref) DECLSPEC_HIDDEN;
4800 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context,
4801 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4802 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context *context,
4803 enum wined3d_feature_level level) DECLSPEC_HIDDEN;
4804 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer,
4805 enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN;
4806 void wined3d_device_context_emit_set_predication(struct wined3d_device_context *context,
4807 struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
4808 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context *context,
4809 struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN;
4810 void wined3d_device_context_emit_set_rendertarget_view(struct wined3d_device_context *context, unsigned int view_idx,
4811 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4812 void wined3d_device_context_emit_set_sampler(struct wined3d_device_context *context, enum wined3d_shader_type type,
4813 unsigned int sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
4814 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context *context, unsigned int sampler_idx,
4815 enum wined3d_sampler_state state, unsigned int value) DECLSPEC_HIDDEN;
4816 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context *context,
4817 unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN;
4818 void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type,
4819 struct wined3d_shader *shader) DECLSPEC_HIDDEN;
4820 void wined3d_device_context_emit_set_shader_resource_view(struct wined3d_device_context *context,
4821 enum wined3d_shader_type type, unsigned int view_idx,
4822 struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4823 void wined3d_device_context_emit_set_stream_output(struct wined3d_device_context *context, unsigned int stream_idx,
4824 struct wined3d_buffer *buffer, unsigned int offset) DECLSPEC_HIDDEN;
4825 void wined3d_device_context_emit_set_stream_source(struct wined3d_device_context *context, unsigned int stream_idx,
4826 struct wined3d_buffer *buffer, unsigned int offset, unsigned int stride) DECLSPEC_HIDDEN;
4827 void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, unsigned int stage,
4828 struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4829 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context *context, unsigned int stage,
4830 enum wined3d_texture_stage_state state, unsigned int value) DECLSPEC_HIDDEN;
4831 void wined3d_device_context_emit_set_unordered_access_view(struct wined3d_device_context *context,
4832 enum wined3d_pipeline pipeline, unsigned int view_idx, struct wined3d_unordered_access_view *view,
4833 unsigned int initial_count) DECLSPEC_HIDDEN;
4834 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context *context,
4835 struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
4836 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count,
4837 const struct wined3d_viewport *viewports) DECLSPEC_HIDDEN;
4839 static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
4841 const struct wined3d_cs *cs = resource->device->cs;
4843 if (!cs->thread || cs->thread_id == GetCurrentThreadId())
4844 return;
4846 while (InterlockedCompareExchange(&resource->access_count, 0, 0))
4847 YieldProcessor();
4850 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
4851 * fixed function semantics as D3DCOLOR or FLOAT16 */
4852 enum wined3d_buffer_conversion_type
4854 CONV_NONE,
4855 CONV_D3DCOLOR,
4856 CONV_POSITIONT,
4859 struct wined3d_buffer_ops
4861 BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer,
4862 struct wined3d_context *context, unsigned int location);
4863 void (*buffer_unload_location)(struct wined3d_buffer *buffer,
4864 struct wined3d_context *context, unsigned int location);
4865 void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
4866 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
4867 void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
4868 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
4871 struct wined3d_buffer
4873 struct wined3d_resource resource;
4874 const struct wined3d_buffer_ops *buffer_ops;
4876 unsigned int structure_byte_stride;
4877 DWORD flags;
4878 DWORD locations;
4879 void *map_ptr;
4880 uintptr_t buffer_object;
4882 struct wined3d_range *maps;
4883 SIZE_T maps_size, modified_areas;
4885 /* conversion stuff */
4886 UINT decl_change_count, full_conversion_count;
4887 UINT draw_count;
4888 UINT stride; /* 0 if no conversion */
4889 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
4890 UINT conversion_stride; /* 0 if no shifted conversion */
4893 static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
4895 return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
4898 void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4899 void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
4900 struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
4901 DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer,
4902 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4903 void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
4904 void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
4905 const struct wined3d_state *state) DECLSPEC_HIDDEN;
4906 BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
4907 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4908 BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
4909 BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
4910 struct wined3d_context *context, unsigned int location) DECLSPEC_HIDDEN;
4911 void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
4912 const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
4914 HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device,
4915 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4916 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4918 struct wined3d_buffer_gl
4920 struct wined3d_buffer b;
4922 struct wined3d_bo_gl bo;
4923 struct wined3d_bo_user bo_user;
4926 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
4928 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
4931 static inline const struct wined3d_buffer_gl *wined3d_buffer_gl_const(const struct wined3d_buffer *buffer)
4933 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
4936 GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info,
4937 uint32_t bind_flags) DECLSPEC_HIDDEN;
4938 HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device,
4939 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4940 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4942 struct wined3d_buffer_vk
4944 struct wined3d_buffer b;
4946 struct wined3d_bo_vk bo;
4947 struct wined3d_bo_user bo_user;
4948 VkDescriptorBufferInfo buffer_info;
4949 uint32_t bind_mask;
4952 static inline struct wined3d_buffer_vk *wined3d_buffer_vk(struct wined3d_buffer *buffer)
4954 return CONTAINING_RECORD(buffer, struct wined3d_buffer_vk, b);
4957 void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk,
4958 struct wined3d_context_vk *context_vk, uint32_t bind_mask) DECLSPEC_HIDDEN;
4959 const VkDescriptorBufferInfo *wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk *buffer_vk) DECLSPEC_HIDDEN;
4960 HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device,
4961 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4962 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4964 static inline void wined3d_resource_vk_barrier(struct wined3d_resource *resource,
4965 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
4967 if (resource->type == WINED3D_RTYPE_BUFFER)
4968 wined3d_buffer_vk_barrier(wined3d_buffer_vk(buffer_from_resource(resource)), context_vk, bind_mask);
4969 else
4970 wined3d_texture_vk_barrier(wined3d_texture_vk(texture_from_resource(resource)), context_vk, bind_mask);
4973 struct wined3d_rendertarget_view
4975 LONG refcount;
4977 struct wined3d_resource *resource;
4978 void *parent;
4979 const struct wined3d_parent_ops *parent_ops;
4981 const struct wined3d_format *format;
4982 unsigned int format_flags;
4983 unsigned int sub_resource_idx;
4984 unsigned int layer_count;
4986 unsigned int width;
4987 unsigned int height;
4989 struct wined3d_view_desc desc;
4992 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4993 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
4994 const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
4995 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
4996 DWORD location) DECLSPEC_HIDDEN;
4997 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
4998 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4999 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,
5000 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
5001 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
5002 DWORD location) DECLSPEC_HIDDEN;
5004 HRESULT wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view *view_no3d,
5005 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5006 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5008 struct wined3d_rendertarget_view_gl
5010 struct wined3d_rendertarget_view v;
5011 struct wined3d_gl_view gl_view;
5014 static inline struct wined3d_rendertarget_view_gl *wined3d_rendertarget_view_gl(
5015 struct wined3d_rendertarget_view *view)
5017 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_gl, v);
5020 HRESULT wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl *view_gl,
5021 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5022 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5024 struct wined3d_rendertarget_view_vk
5026 struct wined3d_rendertarget_view v;
5028 VkImageView vk_image_view;
5029 uint64_t command_buffer_id;
5032 static inline struct wined3d_rendertarget_view_vk *wined3d_rendertarget_view_vk(
5033 struct wined3d_rendertarget_view *view)
5035 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_vk, v);
5038 static inline void wined3d_rendertarget_view_vk_barrier(struct wined3d_rendertarget_view_vk *rtv_vk,
5039 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5041 wined3d_resource_vk_barrier(rtv_vk->v.resource, context_vk, bind_mask);
5044 static inline VkImageView wined3d_rendertarget_view_vk_get_image_view(struct wined3d_rendertarget_view_vk *rtv_vk,
5045 struct wined3d_context_vk *context_vk)
5047 struct wined3d_texture_vk *texture_vk;
5049 if (rtv_vk->vk_image_view)
5050 return rtv_vk->vk_image_view;
5052 texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(rtv_vk->v.resource));
5053 return wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)->imageView;
5056 HRESULT wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk *view_vk,
5057 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5058 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5060 struct wined3d_shader_resource_view
5062 LONG refcount;
5064 struct wined3d_resource *resource;
5065 void *parent;
5066 const struct wined3d_parent_ops *parent_ops;
5068 const struct wined3d_format *format;
5070 struct wined3d_view_desc desc;
5073 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
5075 struct wined3d_shader_resource_view_gl
5077 struct wined3d_shader_resource_view v;
5078 struct wined3d_bo_user bo_user;
5079 struct wined3d_gl_view gl_view;
5082 static inline struct wined3d_shader_resource_view_gl *wined3d_shader_resource_view_gl(
5083 struct wined3d_shader_resource_view *view)
5085 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_gl, v);
5088 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit,
5089 struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5090 void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl *srv_gl,
5091 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5092 HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl *view_gl,
5093 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5094 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5095 void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl *srv_gl,
5096 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5098 struct wined3d_view_vk
5100 struct wined3d_bo_user bo_user;
5101 union
5103 VkBufferView vk_buffer_view;
5104 VkDescriptorImageInfo vk_image_info;
5105 } u;
5106 uint64_t command_buffer_id;
5109 struct wined3d_shader_resource_view_vk
5111 struct wined3d_shader_resource_view v;
5112 struct wined3d_view_vk view_vk;
5115 static inline struct wined3d_shader_resource_view_vk *wined3d_shader_resource_view_vk(
5116 struct wined3d_shader_resource_view *view)
5118 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_vk, v);
5121 static inline void wined3d_shader_resource_view_vk_barrier(struct wined3d_shader_resource_view_vk *srv_vk,
5122 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5124 wined3d_resource_vk_barrier(srv_vk->v.resource, context_vk, bind_mask);
5127 void wined3d_shader_resource_view_vk_generate_mipmap(struct wined3d_shader_resource_view_vk *srv_vk,
5128 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5129 HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk *view_vk,
5130 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5131 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5132 void wined3d_shader_resource_view_vk_update(struct wined3d_shader_resource_view_vk *view_vk,
5133 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5135 struct wined3d_unordered_access_view
5137 LONG refcount;
5139 struct wined3d_resource *resource;
5140 void *parent;
5141 const struct wined3d_parent_ops *parent_ops;
5143 const struct wined3d_format *format;
5145 struct wined3d_view_desc desc;
5146 uintptr_t counter_bo;
5149 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
5150 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
5151 struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
5152 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
5153 DWORD location) DECLSPEC_HIDDEN;
5154 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
5155 unsigned int value) DECLSPEC_HIDDEN;
5157 struct wined3d_unordered_access_view_gl
5159 struct wined3d_unordered_access_view v;
5160 struct wined3d_bo_user bo_user;
5161 struct wined3d_gl_view gl_view;
5162 struct wined3d_bo_gl counter_bo;
5165 static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_view_gl(
5166 struct wined3d_unordered_access_view *view)
5168 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_gl, v);
5171 void wined3d_unordered_access_view_gl_clear_uint(struct wined3d_unordered_access_view_gl *view_gl,
5172 const struct wined3d_uvec4 *clear_value, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5173 HRESULT wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl *view_gl,
5174 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5175 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5176 void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl *uav_gl,
5177 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5179 struct wined3d_unordered_access_view_vk
5181 struct wined3d_unordered_access_view v;
5182 struct wined3d_view_vk view_vk;
5184 VkBufferView vk_counter_view;
5185 struct wined3d_bo_vk counter_bo;
5188 static inline struct wined3d_unordered_access_view_vk *wined3d_unordered_access_view_vk(
5189 struct wined3d_unordered_access_view *view)
5191 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_vk, v);
5194 static inline void wined3d_unordered_access_view_vk_barrier(struct wined3d_unordered_access_view_vk *uav_vk,
5195 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5197 wined3d_resource_vk_barrier(uav_vk->v.resource, context_vk, bind_mask);
5200 void wined3d_unordered_access_view_vk_clear_uint(struct wined3d_unordered_access_view_vk *view_vk,
5201 const struct wined3d_uvec4 *clear_value, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5202 HRESULT wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk *view_vk,
5203 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5204 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5205 void wined3d_unordered_access_view_vk_update(struct wined3d_unordered_access_view_vk *view_vk,
5206 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5208 struct wined3d_swapchain_state
5210 struct wined3d *wined3d;
5211 struct wined3d_swapchain_desc desc;
5212 struct wined3d_swapchain_state_parent *parent;
5214 struct wined3d_display_mode original_mode, d3d_mode;
5215 RECT original_window_rect;
5217 /* Window styles to restore when switching fullscreen mode. */
5218 LONG style;
5219 LONG exstyle;
5220 HWND device_window;
5223 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state *state) DECLSPEC_HIDDEN;
5224 void wined3d_swapchain_state_register(struct wined3d_swapchain_state *state) DECLSPEC_HIDDEN;
5225 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
5226 HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
5227 HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
5228 HWND window, int x, int y, int width, int height) DECLSPEC_HIDDEN;
5230 struct wined3d_swapchain_ops
5232 void (*swapchain_present)(struct wined3d_swapchain *swapchain,
5233 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, DWORD flags);
5234 void (*swapchain_frontbuffer_updated)(struct wined3d_swapchain *swapchain);
5237 struct wined3d_swapchain
5239 LONG ref;
5240 void *parent;
5241 const struct wined3d_parent_ops *parent_ops;
5242 const struct wined3d_swapchain_ops *swapchain_ops;
5243 struct wined3d_device *device;
5245 struct wined3d_texture **back_buffers;
5246 struct wined3d_texture *front_buffer;
5247 struct wined3d_gamma_ramp orig_gamma;
5248 BOOL render_to_fbo, reapply_mode;
5249 const struct wined3d_format *ds_format;
5250 struct wined3d_palette *palette;
5251 RECT front_buffer_update;
5252 unsigned int swap_interval;
5253 unsigned int max_frame_latency;
5255 LONG prev_time, frames; /* Performance tracking */
5257 struct wined3d_swapchain_state state;
5258 HWND win_handle;
5261 void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
5262 void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
5263 struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
5264 void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
5265 void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain,
5266 const struct wined3d_device *device) DECLSPEC_HIDDEN;
5268 HRESULT wined3d_swapchain_no3d_init(struct wined3d_swapchain *swapchain_no3d,
5269 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
5270 struct wined3d_swapchain_state_parent *state_parent, void *parent,
5271 const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5273 struct wined3d_swapchain_gl
5275 struct wined3d_swapchain s;
5277 struct wined3d_context_gl **contexts;
5278 SIZE_T contexts_size;
5279 SIZE_T context_count;
5281 HDC backup_dc;
5282 HWND backup_wnd;
5285 static inline struct wined3d_swapchain_gl *wined3d_swapchain_gl(struct wined3d_swapchain *swapchain)
5287 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_gl, s);
5290 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5291 void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5292 HDC wined3d_swapchain_gl_get_backup_dc(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5293 struct wined3d_context_gl *wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5294 HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl,
5295 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
5296 struct wined3d_swapchain_state_parent *state_parent, void *parent,
5297 const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5299 struct wined3d_swapchain_vk
5301 struct wined3d_swapchain s;
5303 VkSwapchainKHR vk_swapchain;
5304 VkSurfaceKHR vk_surface;
5305 VkImage *vk_images;
5306 struct
5308 VkSemaphore available;
5309 VkSemaphore presentable;
5310 uint64_t command_buffer_id;
5311 } *vk_semaphores;
5312 unsigned int current, image_count;
5313 unsigned int width, height;
5316 static inline struct wined3d_swapchain_vk *wined3d_swapchain_vk(struct wined3d_swapchain *swapchain)
5318 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_vk, s);
5321 void wined3d_swapchain_vk_cleanup(struct wined3d_swapchain_vk *swapchain_vk) DECLSPEC_HIDDEN;
5322 HRESULT wined3d_swapchain_vk_init(struct wined3d_swapchain_vk *swapchain_vk,
5323 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
5324 struct wined3d_swapchain_state_parent *state_parent, void *parent,
5325 const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5327 /*****************************************************************************
5328 * Utility function prototypes
5331 /* Trace routines */
5332 const char *debug_bo_address(const struct wined3d_bo_address *address) DECLSPEC_HIDDEN;
5333 const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
5334 const char *debug_color(const struct wined3d_color *color) DECLSPEC_HIDDEN;
5335 const char *debug_const_bo_address(const struct wined3d_const_bo_address *address) DECLSPEC_HIDDEN;
5336 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
5337 const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
5338 const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
5339 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) DECLSPEC_HIDDEN;
5340 const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
5341 const char *debug_d3ddeclmethod(enum wined3d_decl_method method) DECLSPEC_HIDDEN;
5342 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
5343 const char *debug_d3dinput_classification(enum wined3d_input_classification classification) DECLSPEC_HIDDEN;
5344 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
5345 const char *debug_d3drenderstate(enum wined3d_render_state state) DECLSPEC_HIDDEN;
5346 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HIDDEN;
5347 const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
5348 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
5349 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
5350 const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
5351 const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
5352 const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
5353 const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
5354 const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
5355 const char *debug_ivec4(const struct wined3d_ivec4 *v) DECLSPEC_HIDDEN;
5356 const char *debug_uvec4(const struct wined3d_uvec4 *v) DECLSPEC_HIDDEN;
5357 const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
5358 const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
5359 const char *wined3d_debug_feature_level(enum wined3d_feature_level level) DECLSPEC_HIDDEN;
5360 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
5362 BOOL is_invalid_op(const struct wined3d_state *state, int stage,
5363 enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
5364 void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
5365 BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
5366 INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
5367 void texture_activate_dimensions(struct wined3d_texture *texture,
5368 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
5369 void sampler_texdim(struct wined3d_context *context,
5370 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5371 void tex_alphaop(struct wined3d_context *context,
5372 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5373 void apply_pixelshader(struct wined3d_context *context,
5374 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5375 void state_alpha_test(struct wined3d_context *context,
5376 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5377 void state_fogcolor(struct wined3d_context *context,
5378 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5379 void state_fogdensity(struct wined3d_context *context,
5380 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5381 void state_fogstartend(struct wined3d_context *context,
5382 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5383 void state_fog_fragpart(struct wined3d_context *context,
5384 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5385 void state_nop(struct wined3d_context *context,
5386 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5387 void state_srgbwrite(struct wined3d_context *context,
5388 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5390 void state_clipping(struct wined3d_context *context,
5391 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5392 void clipplane(struct wined3d_context *context,
5393 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5394 void state_pointsprite_w(struct wined3d_context *context,
5395 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5396 void state_pointsprite(struct wined3d_context *context,
5397 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5398 void state_shademode(struct wined3d_context *context,
5399 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5401 /* Math utils */
5402 void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
5403 const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
5405 void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
5407 struct wined3d_shader_lconst
5409 struct list entry;
5410 unsigned int idx;
5411 DWORD value[4];
5414 struct wined3d_shader_limits
5416 unsigned int sampler;
5417 unsigned int constant_int;
5418 unsigned int constant_float;
5419 unsigned int constant_bool;
5420 unsigned int packed_output;
5421 unsigned int packed_input;
5424 #ifdef __GNUC__
5425 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
5426 #else
5427 #define PRINTF_ATTR(fmt,args)
5428 #endif
5430 struct wined3d_string_buffer_list
5432 struct list list;
5435 struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5436 void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN;
5437 void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5438 void string_buffer_list_init(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5439 void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5441 int shader_addline(struct wined3d_string_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
5442 BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc) DECLSPEC_HIDDEN;
5443 int shader_vaddline(struct wined3d_string_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
5445 struct wined3d_shader_phase
5447 const DWORD *start;
5448 const DWORD *end;
5449 unsigned int instance_count;
5450 unsigned int temporary_count;
5453 struct wined3d_vertex_shader
5455 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
5458 struct wined3d_hull_shader
5460 struct
5462 struct wined3d_shader_phase *control_point;
5463 unsigned int fork_count;
5464 unsigned int join_count;
5465 struct wined3d_shader_phase *fork;
5466 SIZE_T fork_size;
5467 struct wined3d_shader_phase *join;
5468 SIZE_T join_size;
5469 } phases;
5470 unsigned int output_vertex_count;
5471 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
5472 enum wined3d_tessellator_partitioning tessellator_partitioning;
5475 struct wined3d_domain_shader
5477 enum wined3d_tessellator_domain tessellator_domain;
5480 struct wined3d_geometry_shader
5482 enum wined3d_primitive_type input_type;
5483 enum wined3d_primitive_type output_type;
5484 unsigned int vertices_out;
5485 unsigned int instance_count;
5487 const struct wined3d_stream_output_desc *so_desc;
5490 struct wined3d_pixel_shader
5492 /* Pixel shader input semantics */
5493 DWORD input_reg_map[MAX_REG_INPUT];
5494 DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
5495 unsigned int declared_in_count;
5497 /* Some information about the shader behavior */
5498 BOOL color0_mov;
5499 DWORD color0_reg;
5501 BOOL force_early_depth_stencil;
5502 enum wined3d_shader_register_type depth_output;
5503 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
5506 struct wined3d_compute_shader
5508 struct wined3d_shader_thread_group_size thread_group_size;
5511 struct wined3d_shader
5513 LONG ref;
5514 const struct wined3d_shader_limits *limits;
5515 const DWORD *function;
5516 unsigned int functionLength;
5517 void *byte_code;
5518 unsigned int byte_code_size;
5519 BOOL load_local_constsF;
5520 const struct wined3d_shader_frontend *frontend;
5521 void *frontend_data;
5522 void *backend_data;
5524 void *parent;
5525 const struct wined3d_parent_ops *parent_ops;
5527 /* Programs this shader is linked with */
5528 struct list linked_programs;
5530 /* Immediate constants (override global ones) */
5531 struct list constantsB;
5532 struct list constantsF;
5533 struct list constantsI;
5534 struct wined3d_shader_reg_maps reg_maps;
5535 BOOL lconst_inf_or_nan;
5537 struct wined3d_shader_signature input_signature;
5538 struct wined3d_shader_signature output_signature;
5539 struct wined3d_shader_signature patch_constant_signature;
5541 /* Pointer to the parent device */
5542 struct wined3d_device *device;
5543 struct list shader_list_entry;
5545 union
5547 struct wined3d_vertex_shader vs;
5548 struct wined3d_hull_shader hs;
5549 struct wined3d_domain_shader ds;
5550 struct wined3d_geometry_shader gs;
5551 struct wined3d_pixel_shader ps;
5552 struct wined3d_compute_shader cs;
5553 } u;
5556 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
5557 unsigned int resource_idx, DWORD tex_types) DECLSPEC_HIDDEN;
5558 void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5559 BOOL position_transformed, struct ps_compile_args *args,
5560 const struct wined3d_context *context) DECLSPEC_HIDDEN;
5562 BOOL vshader_get_input(const struct wined3d_shader *shader,
5563 BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
5564 void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5565 WORD swizzle_map, struct vs_compile_args *args,
5566 const struct wined3d_context *context) DECLSPEC_HIDDEN;
5568 void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5569 struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5571 void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5572 struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5574 void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5575 BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5576 void string_buffer_free(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5577 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
5578 unsigned int max) DECLSPEC_HIDDEN;
5579 HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
5580 const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
5581 const DWORD *start, const DWORD *end) DECLSPEC_HIDDEN;
5582 BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
5584 static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
5586 switch (reg->type)
5588 case WINED3DSPR_RASTOUT:
5589 /* oFog & oPts */
5590 if (reg->idx[0].offset)
5591 return TRUE;
5592 /* oPos */
5593 return FALSE;
5595 case WINED3DSPR_CONSTBOOL: /* b# */
5596 case WINED3DSPR_DEPTHOUT: /* oDepth */
5597 case WINED3DSPR_DEPTHOUTGE:
5598 case WINED3DSPR_DEPTHOUTLE:
5599 case WINED3DSPR_LOOP: /* aL */
5600 case WINED3DSPR_OUTPOINTID:
5601 case WINED3DSPR_PREDICATE: /* p0 */
5602 case WINED3DSPR_PRIMID: /* primID */
5603 case WINED3DSPR_COVERAGE: /* vCoverage */
5604 case WINED3DSPR_SAMPLEMASK: /* oMask */
5605 return TRUE;
5607 case WINED3DSPR_MISCTYPE:
5608 switch (reg->idx[0].offset)
5610 case 0: /* vPos */
5611 return FALSE;
5612 case 1: /* vFace */
5613 return TRUE;
5614 default:
5615 return FALSE;
5618 case WINED3DSPR_IMMCONST:
5619 return reg->immconst_type == WINED3D_IMMCONST_SCALAR;
5621 default:
5622 return FALSE;
5626 static inline void shader_get_position_fixup(const struct wined3d_context *context,
5627 const struct wined3d_state *state, unsigned int fixup_count, float *position_fixup)
5629 float center_offset;
5630 unsigned int i;
5632 if (context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)
5633 center_offset = 63.0f / 64.0f;
5634 else
5635 center_offset = -1.0f / 64.0f;
5637 for (i = 0; i < fixup_count; ++i)
5639 position_fixup[4 * i ] = 1.0f;
5640 position_fixup[4 * i + 1] = 1.0f;
5641 position_fixup[4 * i + 2] = center_offset / state->viewports[i].width;
5642 position_fixup[4 * i + 3] = -center_offset / state->viewports[i].height;
5644 if (context->render_offscreen)
5646 position_fixup[4 * i + 1] *= -1.0f;
5647 position_fixup[4 * i + 3] *= -1.0f;
5652 static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
5654 struct wined3d_shader_lconst *lconst;
5656 if (shader->load_local_constsF)
5657 return FALSE;
5659 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
5661 if (lconst->idx == reg)
5662 return TRUE;
5665 return FALSE;
5668 void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5669 void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5670 unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5671 void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5672 struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5673 void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5674 unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5675 void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state,
5676 float *out_min, float *out_max) DECLSPEC_HIDDEN;
5677 void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
5678 float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
5679 void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
5680 float *start, float *end) DECLSPEC_HIDDEN;
5682 /* Using additional shader constants (uniforms in GLSL / program environment
5683 * or local parameters in ARB) is costly:
5684 * ARB only knows float4 parameters and GLSL compiler are not really smart
5685 * when it comes to efficiently pack float2 uniforms, so no space is wasted
5686 * (in fact most compilers map a float2 to a full float4 uniform).
5688 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
5689 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
5690 * into a single shader constant (uniform / program parameter).
5692 * This structure is shared between the GLSL and the ARB backend.*/
5693 struct ps_np2fixup_info {
5694 unsigned char idx[WINED3D_MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
5695 WORD active; /* bitfield indicating if we can apply the fixup */
5696 WORD num_consts;
5699 void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL program) DECLSPEC_HIDDEN;
5700 void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLuint program) DECLSPEC_HIDDEN;
5702 struct wined3d_palette
5704 LONG ref;
5705 struct wined3d_device *device;
5707 unsigned int size;
5708 RGBQUAD colors[256];
5709 DWORD flags;
5712 /* DirectDraw utility functions */
5713 extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
5715 /*****************************************************************************
5716 * Pixel format management
5719 /* WineD3D pixel format flags */
5720 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x00000001
5721 #define WINED3DFMT_FLAG_FILTERING 0x00000002
5722 #define WINED3DFMT_FLAG_UNORDERED_ACCESS 0x00000004
5723 #define WINED3DFMT_FLAG_DEPTH_STENCIL 0x00000008
5724 #define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
5725 #define WINED3DFMT_FLAG_EXTENSION 0x00000020
5726 #define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
5727 #define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
5728 #define WINED3DFMT_FLAG_DECOMPRESS 0x00000100
5729 #define WINED3DFMT_FLAG_FLOAT 0x00000200
5730 #define WINED3DFMT_FLAG_BUMPMAP 0x00000400
5731 #define WINED3DFMT_FLAG_SRGB_READ 0x00000800
5732 #define WINED3DFMT_FLAG_SRGB_WRITE 0x00001000
5733 #define WINED3DFMT_FLAG_VTF 0x00002000
5734 #define WINED3DFMT_FLAG_SHADOW 0x00004000
5735 #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
5736 #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
5737 #define WINED3DFMT_FLAG_BLOCKS 0x00020000
5738 #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
5739 #define WINED3DFMT_FLAG_TEXTURE 0x00080000
5740 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
5741 #define WINED3DFMT_FLAG_INTEGER 0x00200000
5742 #define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
5743 #define WINED3DFMT_FLAG_NORMALISED 0x00800000
5744 #define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE 0x01000000
5745 #define WINED3DFMT_FLAG_BLIT 0x02000000
5746 #define WINED3DFMT_FLAG_MAPPABLE 0x04000000
5747 #define WINED3DFMT_FLAG_CAST_TO_BLOCK 0x08000000
5749 struct wined3d_rational
5751 UINT numerator;
5752 UINT denominator;
5755 struct wined3d_color_key_conversion
5757 enum wined3d_format_id dst_format;
5758 void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch,
5759 unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key);
5762 struct wined3d_format
5764 enum wined3d_format_id id;
5766 D3DDDIFORMAT ddi_format;
5767 unsigned int component_count;
5768 DWORD red_size;
5769 DWORD green_size;
5770 DWORD blue_size;
5771 DWORD alpha_size;
5772 DWORD red_offset;
5773 DWORD green_offset;
5774 DWORD blue_offset;
5775 DWORD alpha_offset;
5776 UINT byte_count;
5777 BYTE depth_size;
5778 BYTE stencil_size;
5780 UINT block_width;
5781 UINT block_height;
5782 UINT block_byte_count;
5784 enum wined3d_ffp_emit_idx emit_idx;
5786 UINT conv_byte_count;
5787 DWORD multisample_types;
5788 unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
5789 float depth_bias_scale;
5790 struct wined3d_rational height_scale;
5791 struct color_fixup_desc color_fixup;
5792 void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5793 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5794 unsigned int width, unsigned int height, unsigned int depth);
5795 void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5796 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5797 unsigned int width, unsigned int height, unsigned int depth);
5798 void (*decompress)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5799 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5800 unsigned int width, unsigned int height, unsigned int depth);
5802 enum wined3d_format_id typeless_id;
5805 const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
5806 enum wined3d_format_id format_id, unsigned int bind_flags) DECLSPEC_HIDDEN;
5807 void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
5808 unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
5809 UINT wined3d_format_calculate_size(const struct wined3d_format *format,
5810 UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
5811 DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
5812 const struct wined3d_color *color) DECLSPEC_HIDDEN;
5813 void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src,
5814 unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
5815 unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d) DECLSPEC_HIDDEN;
5816 void wined3d_format_get_float_color_key(const struct wined3d_format *format,
5817 const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
5818 BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
5819 enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
5820 const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
5821 const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
5822 BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
5823 enum wined3d_format_id format2) DECLSPEC_HIDDEN;
5825 struct wined3d_format_gl
5827 struct wined3d_format f;
5829 GLenum vtx_type;
5830 GLint vtx_format;
5832 GLint internal;
5833 GLint srgb_internal;
5834 GLint rt_internal;
5835 GLint format;
5836 GLint type;
5838 GLenum view_class;
5841 static inline const struct wined3d_format_gl *wined3d_format_gl(const struct wined3d_format *format)
5843 return CONTAINING_RECORD(format, struct wined3d_format_gl, f);
5846 struct wined3d_format_vk
5848 struct wined3d_format f;
5850 VkFormat vk_format;
5853 static inline const struct wined3d_format_vk *wined3d_format_vk(const struct wined3d_format *format)
5855 return CONTAINING_RECORD(format, struct wined3d_format_vk, f);
5858 BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
5860 static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
5862 return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
5865 static inline BOOL use_vs(const struct wined3d_state *state)
5867 /* Check state->vertex_declaration to allow this to be used before the
5868 * stream info is validated, for example in device_update_tex_unit_map(). */
5869 return state->shader[WINED3D_SHADER_TYPE_VERTEX]
5870 && (!state->vertex_declaration || !state->vertex_declaration->position_transformed);
5873 static inline BOOL use_ps(const struct wined3d_state *state)
5875 return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
5878 static inline BOOL use_transform_feedback(const struct wined3d_state *state)
5880 const struct wined3d_shader *shader;
5882 if (!(shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]))
5883 return FALSE;
5884 return !!shader->u.gs.so_desc;
5887 static inline void context_apply_state(struct wined3d_context *context,
5888 const struct wined3d_state *state, DWORD state_id)
5890 const struct wined3d_state_entry *state_table = context->state_table;
5891 unsigned int rep = state_table[state_id].representative;
5892 state_table[rep].apply(context, state, rep);
5895 static inline BOOL is_srgb_enabled(const DWORD *sampler_states)
5897 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
5898 * the behaviour of the AMD Windows driver.
5900 * Might & Magic: Heroes VI - Shades of Darkness sets
5901 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
5902 * pointer—presumably by accident—and expects sRGB decoding to be
5903 * disabled. */
5904 return sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
5907 static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
5908 const struct wined3d_texture *texture)
5910 if (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
5911 return FALSE;
5913 if (!context->d3d_info->srgb_read_control
5914 && (texture->resource.bind_flags & WINED3D_BIND_SHADER_RESOURCE)
5915 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_READ))
5916 return TRUE;
5918 if (!context->d3d_info->srgb_write_control
5919 && (texture->resource.bind_flags & WINED3D_BIND_RENDER_TARGET)
5920 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE))
5921 return TRUE;
5923 return FALSE;
5926 static inline BOOL needs_srgb_write(const struct wined3d_d3d_info *d3d_info,
5927 const struct wined3d_state *state, const struct wined3d_fb_state *fb)
5929 return (!(d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
5930 || state->render_states[WINED3D_RS_SRGBWRITEENABLE])
5931 && fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
5934 static inline GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl,
5935 const struct wined3d_context *context, BOOL srgb)
5937 return srgb && needs_separate_srgb_gl_texture(context, &texture_gl->t)
5938 ? texture_gl->texture_srgb.name : texture_gl->texture_rgb.name;
5941 static inline GLuint wined3d_gl_get_internal_format(struct wined3d_resource *resource,
5942 const struct wined3d_format_gl *format_gl, bool srgb)
5944 if (srgb)
5945 return format_gl->srgb_internal;
5946 else if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET && wined3d_resource_is_offscreen(resource))
5947 return format_gl->rt_internal;
5948 else
5949 return format_gl->internal;
5952 static inline BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
5954 return d3d_info->texture_swizzle && !is_complex_fixup(format->color_fixup) && !is_scaling_fixup(format->color_fixup);
5957 static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
5959 return geometry_shader && geometry_shader->u.gs.so_desc
5960 && geometry_shader->u.gs.so_desc->rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
5963 static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
5964 unsigned int offset, unsigned int count)
5966 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5967 const unsigned int idx = offset / word_bit_count;
5968 const unsigned int shift = offset % word_bit_count;
5969 DWORD mask = (1u << count) - 1;
5970 DWORD ret;
5972 ret = (bitstream[idx] >> shift) & mask;
5973 if (shift + count > word_bit_count)
5975 const unsigned int extracted_bit_count = word_bit_count - shift;
5976 const unsigned int remaining_bit_count = count - extracted_bit_count;
5977 mask = (1u << remaining_bit_count) - 1;
5978 ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
5980 return ret;
5983 static inline void wined3d_insert_bits(DWORD *bitstream,
5984 unsigned int offset, unsigned int count, DWORD bits)
5986 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5987 const unsigned int idx = offset / word_bit_count;
5988 const unsigned int shift = offset % word_bit_count;
5989 DWORD mask = (1u << count) - 1;
5991 bitstream[idx] |= (bits & mask) << shift;
5992 if (shift + count > word_bit_count)
5994 const unsigned int inserted_bit_count = word_bit_count - shift;
5995 const unsigned int remaining_bit_count = count - inserted_bit_count;
5996 mask = (1u << remaining_bit_count) - 1;
5997 bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
6001 static inline void wined3d_from_cs(const struct wined3d_cs *cs)
6003 if (cs->thread)
6004 assert(cs->thread_id == GetCurrentThreadId());
6007 static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
6009 assert(cs->thread_id != GetCurrentThreadId());
6012 static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map,
6013 enum wined3d_material_color_source source)
6015 if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE))
6016 return source;
6017 if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR))
6018 return source;
6019 return WINED3D_MCS_MATERIAL;
6022 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse,
6023 enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient,
6024 enum wined3d_material_color_source *specular, const struct wined3d_state *state,
6025 const struct wined3d_stream_info *si)
6027 if (!state->render_states[WINED3D_RS_LIGHTING])
6029 *diffuse = WINED3D_MCS_COLOR1;
6030 *specular = WINED3D_MCS_COLOR2;
6031 *emissive = *ambient = WINED3D_MCS_MATERIAL;
6033 return;
6036 if (!state->render_states[WINED3D_RS_COLORVERTEX])
6038 *diffuse = *emissive = *ambient = *specular = WINED3D_MCS_MATERIAL;
6040 return;
6043 *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]);
6044 *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]);
6045 *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]);
6046 *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]);
6049 static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,
6050 const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
6052 struct wined3d_vec4 tmp;
6054 tmp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31 + v->w * m->_41;
6055 tmp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32 + v->w * m->_42;
6056 tmp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33 + v->w * m->_43;
6057 tmp.w = v->x * m->_14 + v->y * m->_24 + v->z * m->_34 + v->w * m->_44;
6059 *dst = tmp;
6062 BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
6064 void compute_normal_matrix(float *normal_matrix, BOOL legacy_lighting,
6065 const struct wined3d_matrix *modelview) DECLSPEC_HIDDEN;
6067 static inline struct wined3d_context *context_acquire(struct wined3d_device *device,
6068 struct wined3d_texture *texture, unsigned int sub_resource_idx)
6070 wined3d_from_cs(device->cs);
6072 return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx);
6075 static inline void context_release(struct wined3d_context *context)
6077 context->device->adapter->adapter_ops->adapter_release_context(context);
6080 static inline float wined3d_get_float_state(const struct wined3d_state *state, enum wined3d_render_state rs)
6082 union
6084 DWORD d;
6085 float f;
6087 tmpvalue;
6089 tmpvalue.d = state->render_states[rs];
6090 return tmpvalue.f;
6093 static inline void *wined3d_context_map_bo_address(struct wined3d_context *context,
6094 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags)
6096 return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, map_flags);
6099 static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context,
6100 const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
6102 context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, range_count, ranges);
6105 static inline void wined3d_context_copy_bo_address(struct wined3d_context *context,
6106 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
6108 context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, size);
6111 static inline void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk,
6112 struct wined3d_bo_vk *bo)
6114 bo->command_buffer_id = context_vk->current_command_buffer.id;
6117 static inline void wined3d_context_vk_reference_image(const struct wined3d_context_vk *context_vk,
6118 struct wined3d_image_vk *image)
6120 image->command_buffer_id = context_vk->current_command_buffer.id;
6123 static inline void wined3d_context_vk_reference_texture(const struct wined3d_context_vk *context_vk,
6124 struct wined3d_texture_vk *texture_vk)
6126 wined3d_context_vk_reference_image(context_vk, &texture_vk->image);
6129 static inline void wined3d_context_vk_reference_resource(const struct wined3d_context_vk *context_vk,
6130 struct wined3d_resource *resource)
6132 if (resource->type == WINED3D_RTYPE_BUFFER)
6133 wined3d_context_vk_reference_bo(context_vk, &wined3d_buffer_vk(buffer_from_resource(resource))->bo);
6134 else
6135 wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource)));
6138 static inline void wined3d_context_vk_reference_query(const struct wined3d_context_vk *context_vk,
6139 struct wined3d_query_vk *query_vk)
6141 query_vk->command_buffer_id = context_vk->current_command_buffer.id;
6144 static inline void wined3d_context_vk_reference_sampler(const struct wined3d_context_vk *context_vk,
6145 struct wined3d_sampler_vk *sampler_vk)
6147 sampler_vk->command_buffer_id = context_vk->current_command_buffer.id;
6150 static inline void wined3d_context_vk_reference_rendertarget_view(const struct wined3d_context_vk *context_vk,
6151 struct wined3d_rendertarget_view_vk *rtv_vk)
6153 wined3d_context_vk_reference_resource(context_vk, rtv_vk->v.resource);
6154 rtv_vk->command_buffer_id = context_vk->current_command_buffer.id;
6157 static inline void wined3d_context_vk_reference_shader_resource_view(const struct wined3d_context_vk *context_vk,
6158 struct wined3d_shader_resource_view_vk *srv_vk)
6160 wined3d_context_vk_reference_resource(context_vk, srv_vk->v.resource);
6161 srv_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
6164 static inline void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk *context_vk,
6165 struct wined3d_unordered_access_view_vk *uav_vk)
6167 wined3d_context_vk_reference_resource(context_vk, uav_vk->v.resource);
6168 uav_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
6171 static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view *dsv,
6172 const struct wined3d_format *srv_format)
6174 return !srv_format || (srv_format->red_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_DEPTH))
6175 || (srv_format->green_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_STENCIL));
6178 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture *texture)
6180 return texture->resource.type == WINED3D_RTYPE_TEXTURE_3D ? texture->resource.depth : texture->layer_count;
6183 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view *srv)
6185 struct wined3d_texture *texture;
6187 if (srv->resource->type == WINED3D_RTYPE_BUFFER)
6188 return TRUE;
6190 if (srv->desc.u.texture.layer_idx || srv->desc.u.texture.level_idx)
6191 return FALSE;
6193 texture = texture_from_resource(srv->resource);
6194 return srv->desc.u.texture.level_count == texture->level_count
6195 && srv->desc.u.texture.layer_count == wined3d_bind_layer_count(texture);
6198 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view *rtv)
6200 struct wined3d_texture *texture;
6202 if (rtv->resource->type == WINED3D_RTYPE_BUFFER)
6203 return TRUE;
6205 if (rtv->sub_resource_idx)
6206 return FALSE;
6208 texture = texture_from_resource(rtv->resource);
6209 return texture->level_count == 1 && rtv->layer_count == wined3d_bind_layer_count(texture);
6212 static inline void wined3d_srv_bind_count_add(struct wined3d_shader_resource_view *srv, int value)
6214 struct wined3d_resource *resource = srv->resource;
6215 struct wined3d_texture *texture;
6216 unsigned int level, layer;
6218 if (wined3d_srv_all_subresources(srv))
6220 resource->srv_full_bind_count_device += value;
6221 return;
6224 resource->srv_partial_bind_count_device += value;
6226 texture = texture_from_resource(resource);
6228 if (!resource->sub_resource_bind_counts_device
6229 && !(resource->sub_resource_bind_counts_device = heap_alloc_zero(texture->level_count
6230 * wined3d_bind_layer_count(texture) * sizeof(*resource->sub_resource_bind_counts_device))))
6231 return;
6233 for (layer = 0; layer < srv->desc.u.texture.layer_count; ++layer)
6234 for (level = 0; level < srv->desc.u.texture.level_count; ++level)
6235 resource->sub_resource_bind_counts_device[(layer + srv->desc.u.texture.layer_idx)
6236 * texture->level_count + srv->desc.u.texture.level_idx + level].srv += value;
6239 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view *srv)
6241 wined3d_srv_bind_count_add(srv, 1);
6244 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv)
6246 wined3d_srv_bind_count_add(srv, -1);
6249 static inline void wined3d_rtv_bind_count_add(struct wined3d_rendertarget_view *rtv, int value)
6251 struct wined3d_resource *resource = rtv->resource;
6252 struct wined3d_texture *texture;
6253 unsigned int layer;
6255 if (wined3d_rtv_all_subresources(rtv))
6257 resource->rtv_full_bind_count_device += value;
6258 return;
6261 resource->rtv_partial_bind_count_device += value;
6263 texture = texture_from_resource(resource);
6265 if (!resource->sub_resource_bind_counts_device
6266 && !(resource->sub_resource_bind_counts_device = heap_alloc_zero(texture->level_count
6267 * wined3d_bind_layer_count(texture) * sizeof(*resource->sub_resource_bind_counts_device))))
6268 return;
6270 for (layer = 0; layer < rtv->layer_count; ++layer)
6271 resource->sub_resource_bind_counts_device[rtv->sub_resource_idx + layer * texture->level_count].rtv += value;
6274 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv)
6276 wined3d_rtv_bind_count_add(rtv, 1);
6279 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv)
6281 wined3d_rtv_bind_count_add(rtv, -1);
6284 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_shader_resource_view *srv)
6286 struct wined3d_resource *resource = srv->resource;
6287 struct wined3d_texture *texture;
6288 unsigned int level, layer;
6290 if (!(resource->rtv_full_bind_count_device + resource->rtv_partial_bind_count_device))
6291 return FALSE;
6293 if (resource->rtv_full_bind_count_device || wined3d_srv_all_subresources(srv))
6294 return TRUE;
6296 texture = texture_from_resource(resource);
6298 for (layer = 0; layer < srv->desc.u.texture.layer_count; ++layer)
6299 for (level = 0; level < srv->desc.u.texture.level_count; ++level)
6300 if (resource->sub_resource_bind_counts_device[(layer + srv->desc.u.texture.layer_idx)
6301 * texture->level_count + srv->desc.u.texture.level_idx + level].rtv)
6302 return TRUE;
6304 return FALSE;
6307 static inline bool wined3d_is_rtv_srv_bound(const struct wined3d_rendertarget_view *rtv)
6309 struct wined3d_resource *resource = rtv->resource;
6310 struct wined3d_texture *texture;
6311 unsigned int layer;
6313 if (!(resource->srv_full_bind_count_device + resource->srv_partial_bind_count_device))
6314 return FALSE;
6316 if (resource->srv_full_bind_count_device || wined3d_rtv_all_subresources(rtv))
6317 return TRUE;
6319 texture = texture_from_resource(resource);
6321 for (layer = 0; layer < rtv->layer_count; ++layer)
6322 if (resource->sub_resource_bind_counts_device[rtv->sub_resource_idx + layer * texture->level_count].srv)
6323 return TRUE;
6325 return FALSE;
6328 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
6330 *min_z = vp->min_z;
6332 /* The magic constant is derived from tests. */
6333 *max_z = max(vp->max_z, vp->min_z + 0.001f);
6336 static inline BOOL wined3d_bitmap_clear(uint32_t *map, unsigned int idx)
6338 return map[idx >> 5] &= ~(1u << (idx & 0x1f));
6341 static inline BOOL wined3d_bitmap_set(uint32_t *map, unsigned int idx)
6343 return map[idx >> 5] |= (1u << (idx & 0x1f));
6346 static inline BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx)
6348 return map[idx >> 5] & (1u << (idx & 0x1f));
6351 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap, unsigned int bit_count,
6352 unsigned int start, uint32_t xor_mask)
6354 const unsigned int word_bit_count = sizeof(*bitmap) * CHAR_BIT;
6355 const uint32_t *ptr, *end_ptr;
6356 uint32_t map, mask;
6358 assert(bit_count < word_bit_count || !(bit_count % word_bit_count));
6360 ptr = bitmap + start / word_bit_count;
6361 end_ptr = bitmap + (bit_count + word_bit_count - 1) / word_bit_count;
6363 if (ptr >= end_ptr)
6364 return ~0u;
6366 mask = ~0u << start % word_bit_count;
6367 map = (*ptr ^ xor_mask) & mask;
6368 while (!map)
6370 if (++ptr == end_ptr)
6371 return ~0u;
6372 map = *ptr ^ xor_mask;
6374 return (ptr - bitmap) * word_bit_count + wined3d_bit_scan(&map);
6377 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
6379 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, 0);
6382 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
6384 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, ~0u);
6387 static inline BOOL wined3d_bitmap_get_range(const DWORD *bitmap, unsigned int bit_count,
6388 unsigned int start, struct wined3d_range *range)
6390 unsigned int range_start, range_end;
6392 range_start = wined3d_bitmap_ffs(bitmap, bit_count, start);
6393 if (range_start == ~0u)
6394 return FALSE;
6396 range_end = wined3d_bitmap_ffz(bitmap, bit_count, range_start + 1);
6397 if (range_end == ~0u)
6398 range_end = bit_count;
6400 range->offset = range_start;
6401 range->size = range_end - range_start;
6402 return TRUE;
6405 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context *context, unsigned int state_id)
6407 return wined3d_bitmap_is_set(context->dirty_graphics_states, state_id);
6410 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context *context, unsigned int state_id)
6412 return wined3d_bitmap_is_set(context->dirty_compute_states, state_id - STATE_COMPUTE_OFFSET);
6415 static inline bool isStateDirty(const struct wined3d_context *context, unsigned int state_id)
6417 return wined3d_context_is_graphics_state_dirty(context, state_id);
6420 static inline VkImageAspectFlags vk_aspect_mask_from_format(const struct wined3d_format *format)
6422 VkImageAspectFlags mask = 0;
6424 if (format->depth_size)
6425 mask |= VK_IMAGE_ASPECT_DEPTH_BIT;
6426 if (format->stencil_size)
6427 mask |= VK_IMAGE_ASPECT_STENCIL_BIT;
6428 if (!mask || format->red_size || format->green_size || format->blue_size || format->alpha_size)
6429 mask |= VK_IMAGE_ASPECT_COLOR_BIT;
6431 return mask;
6434 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t)
6436 return t == WINED3D_PT_POINTLIST
6437 || t == WINED3D_PT_LINELIST
6438 || t == WINED3D_PT_TRIANGLELIST
6439 || t == WINED3D_PT_LINELIST_ADJ
6440 || t == WINED3D_PT_TRIANGLELIST_ADJ
6441 || t == WINED3D_PT_PATCH;
6444 static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo_gl)
6446 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
6448 bo_gl->command_fence_id = device_gl->current_fence_id;
6451 static inline bool wined3d_map_persistent(void)
6453 return sizeof(void *) >= sizeof(uint64_t);
6456 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
6457 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
6459 extern CRITICAL_SECTION wined3d_command_cs;
6461 #endif