wined3d: Use wined3d_bit_scan() in vshader_get_input().
[wine.git] / dlls / wined3d / wined3d_private.h
blobe28fc3b880d78e796a0c8e5c71cfd906e153a6bf
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 <sys/types.h>
38 #include <math.h>
39 #include <limits.h>
40 #include "ntstatus.h"
41 #define WIN32_NO_STATUS
42 #define NONAMELESSUNION
43 #define NONAMELESSSTRUCT
44 #define COBJMACROS
45 #include "windef.h"
46 #include "winbase.h"
47 #include "winreg.h"
48 #include "wingdi.h"
49 #include "winuser.h"
50 #include "winternl.h"
51 #include "ddk/d3dkmthk.h"
52 #include "wine/debug.h"
53 #include "wine/heap.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 static inline size_t align(size_t addr, size_t alignment)
68 return (addr + (alignment - 1)) & ~(alignment - 1);
71 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
73 /* Driver quirks */
74 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
75 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
76 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
77 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
78 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
79 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
80 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
81 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
82 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
83 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
85 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
87 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
88 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
90 #define WINED3D_BITMAP_SIZE(x) (((x) + 31) >> 5)
92 struct wined3d_fragment_pipe_ops;
93 struct wined3d_adapter;
94 struct wined3d_buffer_vk;
95 struct wined3d_context;
96 struct wined3d_context_vk;
97 struct wined3d_gl_info;
98 struct wined3d_state;
99 struct wined3d_swapchain_gl;
100 struct wined3d_texture_gl;
101 struct wined3d_vertex_pipe_ops;
103 enum wined3d_ffp_idx
105 WINED3D_FFP_POSITION = 0,
106 WINED3D_FFP_BLENDWEIGHT = 1,
107 WINED3D_FFP_BLENDINDICES = 2,
108 WINED3D_FFP_NORMAL = 3,
109 WINED3D_FFP_PSIZE = 4,
110 WINED3D_FFP_DIFFUSE = 5,
111 WINED3D_FFP_SPECULAR = 6,
112 WINED3D_FFP_TEXCOORD0 = 7,
113 WINED3D_FFP_TEXCOORD1 = 8,
114 WINED3D_FFP_TEXCOORD2 = 9,
115 WINED3D_FFP_TEXCOORD3 = 10,
116 WINED3D_FFP_TEXCOORD4 = 11,
117 WINED3D_FFP_TEXCOORD5 = 12,
118 WINED3D_FFP_TEXCOORD6 = 13,
119 WINED3D_FFP_TEXCOORD7 = 14,
120 WINED3D_FFP_ATTRIBS_COUNT = 15,
123 enum wined3d_ffp_emit_idx
125 WINED3D_FFP_EMIT_FLOAT1,
126 WINED3D_FFP_EMIT_FLOAT2,
127 WINED3D_FFP_EMIT_FLOAT3,
128 WINED3D_FFP_EMIT_FLOAT4,
129 WINED3D_FFP_EMIT_D3DCOLOR,
130 WINED3D_FFP_EMIT_UBYTE4,
131 WINED3D_FFP_EMIT_SHORT2,
132 WINED3D_FFP_EMIT_SHORT4,
133 WINED3D_FFP_EMIT_UBYTE4N,
134 WINED3D_FFP_EMIT_SHORT2N,
135 WINED3D_FFP_EMIT_SHORT4N,
136 WINED3D_FFP_EMIT_USHORT2N,
137 WINED3D_FFP_EMIT_USHORT4N,
138 WINED3D_FFP_EMIT_UDEC3,
139 WINED3D_FFP_EMIT_DEC3N,
140 WINED3D_FFP_EMIT_FLOAT16_2,
141 WINED3D_FFP_EMIT_FLOAT16_4,
142 WINED3D_FFP_EMIT_INVALID,
143 WINED3D_FFP_EMIT_COUNT,
146 /* Texture format fixups */
148 enum fixup_channel_source
150 CHANNEL_SOURCE_ZERO = 0,
151 CHANNEL_SOURCE_ONE = 1,
152 CHANNEL_SOURCE_X = 2,
153 CHANNEL_SOURCE_Y = 3,
154 CHANNEL_SOURCE_Z = 4,
155 CHANNEL_SOURCE_W = 5,
156 CHANNEL_SOURCE_COMPLEX0 = 6,
157 CHANNEL_SOURCE_COMPLEX1 = 7,
160 enum complex_fixup
162 COMPLEX_FIXUP_NONE = 0,
163 COMPLEX_FIXUP_YUY2 = 1,
164 COMPLEX_FIXUP_UYVY = 2,
165 COMPLEX_FIXUP_YV12 = 3,
166 COMPLEX_FIXUP_P8 = 4,
167 COMPLEX_FIXUP_NV12 = 5,
168 COMPLEX_FIXUP_YUV = 6,
171 #include <pshpack2.h>
172 struct color_fixup_desc
174 unsigned short x_sign_fixup : 1;
175 unsigned short x_source : 3;
176 unsigned short y_sign_fixup : 1;
177 unsigned short y_source : 3;
178 unsigned short z_sign_fixup : 1;
179 unsigned short z_source : 3;
180 unsigned short w_sign_fixup : 1;
181 unsigned short w_source : 3;
183 #include <poppack.h>
185 struct wined3d_d3d_limits
187 unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
188 DWORD vs_uniform_count;
189 DWORD ps_uniform_count;
190 unsigned int varying_count;
191 unsigned int ffp_textures;
192 unsigned int ffp_blend_stages;
193 unsigned int ffp_vertex_blend_matrices;
194 unsigned int active_light_count;
196 unsigned int max_rt_count;
197 unsigned int max_clip_distances;
198 unsigned int texture_size;
199 float pointsize_max;
202 typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
203 typedef void (WINE_GLAPI *wined3d_ffp_texcoord_func)(GLenum unit, const void *data);
204 typedef void (WINE_GLAPI *wined3d_generic_attrib_func)(GLuint idx, const void *data);
205 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
207 struct wined3d_ffp_attrib_ops
209 wined3d_ffp_attrib_func position[WINED3D_FFP_EMIT_COUNT];
210 wined3d_ffp_attrib_func diffuse[WINED3D_FFP_EMIT_COUNT];
211 wined3d_ffp_attrib_func specular[WINED3D_FFP_EMIT_COUNT];
212 wined3d_ffp_attrib_func normal[WINED3D_FFP_EMIT_COUNT];
213 wined3d_ffp_texcoord_func texcoord[WINED3D_FFP_EMIT_COUNT];
214 wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT];
217 struct wined3d_d3d_info
219 struct wined3d_d3d_limits limits;
220 struct wined3d_ffp_attrib_ops ffp_attrib_ops;
221 uint32_t wined3d_creation_flags;
222 uint32_t xyzrhw : 1;
223 uint32_t emulated_flatshading : 1;
224 uint32_t ffp_generic_attributes : 1;
225 uint32_t ffp_alpha_test : 1;
226 uint32_t vs_clipping : 1;
227 uint32_t shader_color_key : 1;
228 uint32_t shader_double_precision : 1;
229 uint32_t shader_output_interpolation : 1;
230 uint32_t frag_coord_correction : 1;
231 uint32_t viewport_array_index_any_shader : 1;
232 uint32_t texture_npot : 1;
233 uint32_t texture_npot_conditional : 1;
234 uint32_t draw_base_vertex_offset : 1;
235 uint32_t vertex_bgra : 1;
236 uint32_t texture_swizzle : 1;
237 uint32_t srgb_read_control : 1;
238 uint32_t srgb_write_control : 1;
239 uint32_t clip_control : 1;
240 uint32_t full_ffp_varyings : 1;
241 uint32_t scaled_resolve : 1;
242 uint32_t pbo : 1;
243 uint32_t subpixel_viewport : 1;
244 enum wined3d_feature_level feature_level;
246 DWORD multisample_draw_location;
248 float filling_convention_offset;
251 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
252 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
254 static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
256 struct color_fixup_desc fixup =
258 0u, complex_fixup & (1u << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
259 0u, complex_fixup & (1u << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
260 0u, complex_fixup & (1u << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
261 0u, complex_fixup & (1u << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
263 return fixup;
266 static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
268 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
271 static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
273 return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
276 static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
278 return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
281 static inline BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
283 return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
284 && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
285 && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
286 && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
289 static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
291 enum complex_fixup complex_fixup = 0;
292 if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
293 if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
294 if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
295 if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
296 return complex_fixup;
299 /* Device caps */
300 #define WINED3D_MAX_ACTIVE_LIGHTS 8
301 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
302 #define MAX_CONSTANT_BUFFERS 15
303 #define MAX_SAMPLER_OBJECTS 16
304 #define MAX_SHADER_RESOURCE_VIEWS 128
305 #define MAX_UNORDERED_ACCESS_VIEWS 8
306 #define MAX_TGSM_REGISTERS 8192
307 #define MAX_VERTEX_BLENDS 4
309 struct min_lookup
311 GLenum mip[WINED3D_TEXF_LINEAR + 1];
314 extern const struct min_lookup minMipLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
315 extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
317 static const uint32_t WINED3D_READ_ONLY_BIND_MASK = WINED3D_BIND_VERTEX_BUFFER | WINED3D_BIND_INDEX_BUFFER
318 | WINED3D_BIND_CONSTANT_BUFFER | WINED3D_BIND_SHADER_RESOURCE | WINED3D_BIND_INDIRECT_BUFFER;
320 static const VkAccessFlags WINED3D_READ_ONLY_ACCESS_FLAGS = VK_ACCESS_INDIRECT_COMMAND_READ_BIT
321 | VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT
322 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT | VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
323 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_HOST_READ_BIT
324 | VK_ACCESS_MEMORY_READ_BIT;
326 GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN;
327 VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
328 VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op) DECLSPEC_HIDDEN;
329 VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags) DECLSPEC_HIDDEN;
330 VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
331 VkShaderStageFlagBits vk_shader_stage_from_wined3d(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
332 VkAccessFlags vk_access_mask_from_buffer_usage(VkBufferUsageFlags usage) DECLSPEC_HIDDEN;
333 VkPipelineStageFlags vk_pipeline_stage_mask_from_buffer_usage(VkBufferUsageFlags usage) DECLSPEC_HIDDEN;
334 VkBufferUsageFlags vk_buffer_usage_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
335 VkMemoryPropertyFlags vk_memory_type_from_access_flags(uint32_t access, uint32_t usage) DECLSPEC_HIDDEN;
337 static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
339 if (func < WINED3D_CMP_NEVER || func > WINED3D_CMP_ALWAYS)
340 return WINED3D_CMP_ALWAYS;
341 return func;
344 static inline GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
346 return magLookup[mag_filter];
349 static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,
350 enum wined3d_texture_filter_type mip_filter)
352 return minMipLookup[min_filter].mip[mip_filter];
355 #ifdef HAVE_IEEEFP_H
356 #include <ieeefp.h>
357 #endif
359 #if !defined(HAVE_ISFINITE) && !defined(isfinite)
360 static inline int isfinite(double x) { return finite(x); }
361 #endif
363 #if !defined(HAVE_ISINF) && !defined(isinf)
364 static inline int isinf(double x) { return (!(finite(x) || isnand(x))); }
365 #endif
367 #if !defined(HAVE_ISNAN) && !defined(isnan)
368 static inline int isnan(double x) { return isnand(x); }
369 #endif
371 #ifndef INFINITY
372 static inline float __port_infinity(void)
374 static const unsigned __inf_bytes = 0x7f800000;
375 return *(const float *)&__inf_bytes;
377 #define INFINITY __port_infinity()
378 #endif
380 #ifndef NAN
381 static inline float __port_nan(void)
383 static const unsigned __nan_bytes = 0x7fc00000;
384 return *(const float *)&__nan_bytes;
386 #define NAN __port_nan()
387 #endif
389 /* float_16_to_32() and float_32_to_16() (see implementation in
390 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
391 * to standard C floats and vice versa. They do not depend on the encoding
392 * of the C float, so they are platform independent, but slow. On x86 and
393 * other IEEE 754 compliant platforms the conversion can be accelerated by
394 * bit shifting the exponent and mantissa. There are also some SSE-based
395 * assembly routines out there.
397 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
399 static inline float float_16_to_32(const unsigned short *in)
401 const unsigned short s = ((*in) & 0x8000u);
402 const unsigned short e = ((*in) & 0x7c00u) >> 10;
403 const unsigned short m = (*in) & 0x3ffu;
404 const float sgn = (s ? -1.0f : 1.0f);
406 if(e == 0) {
407 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
408 else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
409 } else if(e < 31) {
410 return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
411 } else {
412 if(m == 0) return sgn * INFINITY;
413 else return NAN;
417 static inline float float_24_to_32(DWORD in)
419 const float sgn = in & 0x800000u ? -1.0f : 1.0f;
420 const unsigned short e = (in & 0x780000u) >> 19;
421 const unsigned int m = in & 0x7ffffu;
423 if (e == 0)
425 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
426 else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
428 else if (e < 15)
430 return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
432 else
434 if (m == 0) return sgn * INFINITY;
435 else return NAN;
439 static inline unsigned int wined3d_popcount(unsigned int x)
441 #ifdef HAVE___BUILTIN_POPCOUNT
442 return __builtin_popcount(x);
443 #else
444 x -= x >> 1 & 0x55555555;
445 x = (x & 0x33333333) + (x >> 2 & 0x33333333);
446 return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
447 #endif
450 static inline int wined3d_uint32_compare(uint32_t x, uint32_t y)
452 return (x > y) - (x < y);
455 static inline int wined3d_uint64_compare(uint64_t x, uint64_t y)
457 return (x > y) - (x < y);
460 #define ORM_BACKBUFFER 0
461 #define ORM_FBO 1
463 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
464 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
466 enum wined3d_renderer
468 WINED3D_RENDERER_AUTO,
469 WINED3D_RENDERER_VULKAN,
470 WINED3D_RENDERER_OPENGL,
471 WINED3D_RENDERER_NO3D,
474 enum wined3d_shader_backend
476 WINED3D_SHADER_BACKEND_AUTO,
477 WINED3D_SHADER_BACKEND_GLSL,
478 WINED3D_SHADER_BACKEND_ARB,
479 WINED3D_SHADER_BACKEND_NONE,
482 #define WINED3D_CSMT_ENABLE 0x00000001
483 #define WINED3D_CSMT_SERIALIZE 0x00000002
485 /* NOTE: When adding fields to this structure, make sure to update the default
486 * values in wined3d_main.c as well. */
487 struct wined3d_settings
489 unsigned int cs_multithreaded;
490 DWORD max_gl_version;
491 int offscreen_rendering_mode;
492 unsigned short pci_vendor_id;
493 unsigned short pci_device_id;
494 /* Memory tracking and object counting. */
495 UINT64 emulated_textureram;
496 char *logo;
497 unsigned int multisample_textures;
498 unsigned int sample_count;
499 BOOL check_float_constants;
500 unsigned int strict_shader_math;
501 unsigned int max_sm_vs;
502 unsigned int max_sm_hs;
503 unsigned int max_sm_ds;
504 unsigned int max_sm_gs;
505 unsigned int max_sm_ps;
506 unsigned int max_sm_cs;
507 enum wined3d_renderer renderer;
508 enum wined3d_shader_backend shader_backend;
509 BOOL cb_access_map_w;
512 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
514 enum wined3d_shader_byte_code_format
516 WINED3D_SHADER_BYTE_CODE_FORMAT_SM1,
517 WINED3D_SHADER_BYTE_CODE_FORMAT_SM4,
520 enum wined3d_shader_resource_type
522 WINED3D_SHADER_RESOURCE_NONE,
523 WINED3D_SHADER_RESOURCE_BUFFER,
524 WINED3D_SHADER_RESOURCE_TEXTURE_1D,
525 WINED3D_SHADER_RESOURCE_TEXTURE_2D,
526 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
527 WINED3D_SHADER_RESOURCE_TEXTURE_3D,
528 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
529 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
530 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
531 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
532 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
535 #define WINED3D_SHADER_CONST_VS_F 0x00000001
536 #define WINED3D_SHADER_CONST_VS_I 0x00000002
537 #define WINED3D_SHADER_CONST_VS_B 0x00000004
538 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
539 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
540 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
541 #define WINED3D_SHADER_CONST_PS_F 0x00000040
542 #define WINED3D_SHADER_CONST_PS_I 0x00000080
543 #define WINED3D_SHADER_CONST_PS_B 0x00000100
544 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
545 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
546 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
547 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
548 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
549 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
550 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
551 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
552 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
553 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
554 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
555 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
556 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
557 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
559 enum wined3d_shader_register_type
561 WINED3DSPR_TEMP = 0,
562 WINED3DSPR_INPUT = 1,
563 WINED3DSPR_CONST = 2,
564 WINED3DSPR_ADDR = 3,
565 WINED3DSPR_TEXTURE = 3,
566 WINED3DSPR_RASTOUT = 4,
567 WINED3DSPR_ATTROUT = 5,
568 WINED3DSPR_TEXCRDOUT = 6,
569 WINED3DSPR_OUTPUT = 6,
570 WINED3DSPR_CONSTINT = 7,
571 WINED3DSPR_COLOROUT = 8,
572 WINED3DSPR_DEPTHOUT = 9,
573 WINED3DSPR_SAMPLER = 10,
574 WINED3DSPR_CONST2 = 11,
575 WINED3DSPR_CONST3 = 12,
576 WINED3DSPR_CONST4 = 13,
577 WINED3DSPR_CONSTBOOL = 14,
578 WINED3DSPR_LOOP = 15,
579 WINED3DSPR_TEMPFLOAT16 = 16,
580 WINED3DSPR_MISCTYPE = 17,
581 WINED3DSPR_LABEL = 18,
582 WINED3DSPR_PREDICATE = 19,
583 WINED3DSPR_IMMCONST,
584 WINED3DSPR_CONSTBUFFER,
585 WINED3DSPR_IMMCONSTBUFFER,
586 WINED3DSPR_PRIMID,
587 WINED3DSPR_NULL,
588 WINED3DSPR_RESOURCE,
589 WINED3DSPR_UAV,
590 WINED3DSPR_OUTPOINTID,
591 WINED3DSPR_FORKINSTID,
592 WINED3DSPR_JOININSTID,
593 WINED3DSPR_INCONTROLPOINT,
594 WINED3DSPR_OUTCONTROLPOINT,
595 WINED3DSPR_PATCHCONST,
596 WINED3DSPR_TESSCOORD,
597 WINED3DSPR_GROUPSHAREDMEM,
598 WINED3DSPR_THREADID,
599 WINED3DSPR_THREADGROUPID,
600 WINED3DSPR_LOCALTHREADID,
601 WINED3DSPR_LOCALTHREADINDEX,
602 WINED3DSPR_IDXTEMP,
603 WINED3DSPR_STREAM,
604 WINED3DSPR_FUNCTIONBODY,
605 WINED3DSPR_FUNCTIONPOINTER,
606 WINED3DSPR_COVERAGE,
607 WINED3DSPR_SAMPLEMASK,
608 WINED3DSPR_GSINSTID,
609 WINED3DSPR_DEPTHOUTGE,
610 WINED3DSPR_DEPTHOUTLE,
611 WINED3DSPR_RASTERIZER,
614 enum wined3d_data_type
616 WINED3D_DATA_FLOAT,
617 WINED3D_DATA_INT,
618 WINED3D_DATA_RESOURCE,
619 WINED3D_DATA_SAMPLER,
620 WINED3D_DATA_UAV,
621 WINED3D_DATA_UINT,
622 WINED3D_DATA_UNORM,
623 WINED3D_DATA_SNORM,
624 WINED3D_DATA_OPAQUE,
627 enum wined3d_immconst_type
629 WINED3D_IMMCONST_SCALAR,
630 WINED3D_IMMCONST_VEC4,
633 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
635 enum wined3d_shader_src_modifier
637 WINED3DSPSM_NONE = 0,
638 WINED3DSPSM_NEG = 1,
639 WINED3DSPSM_BIAS = 2,
640 WINED3DSPSM_BIASNEG = 3,
641 WINED3DSPSM_SIGN = 4,
642 WINED3DSPSM_SIGNNEG = 5,
643 WINED3DSPSM_COMP = 6,
644 WINED3DSPSM_X2 = 7,
645 WINED3DSPSM_X2NEG = 8,
646 WINED3DSPSM_DZ = 9,
647 WINED3DSPSM_DW = 10,
648 WINED3DSPSM_ABS = 11,
649 WINED3DSPSM_ABSNEG = 12,
650 WINED3DSPSM_NOT = 13,
653 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
654 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
655 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
656 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
657 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
659 enum wined3d_shader_dst_modifier
661 WINED3DSPDM_NONE = 0,
662 WINED3DSPDM_SATURATE = 1,
663 WINED3DSPDM_PARTIALPRECISION = 2,
664 WINED3DSPDM_MSAMPCENTROID = 4,
667 enum wined3d_shader_interpolation_mode
669 WINED3DSIM_NONE = 0,
670 WINED3DSIM_CONSTANT = 1,
671 WINED3DSIM_LINEAR = 2,
672 WINED3DSIM_LINEAR_CENTROID = 3,
673 WINED3DSIM_LINEAR_NOPERSPECTIVE = 4,
674 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
675 WINED3DSIM_LINEAR_SAMPLE = 6,
676 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
679 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
680 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
682 enum wined3d_shader_global_flags
684 WINED3DSGF_REFACTORING_ALLOWED = 0x1,
685 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4,
686 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8,
689 enum wined3d_shader_sync_flags
691 WINED3DSSF_THREAD_GROUP = 0x1,
692 WINED3DSSF_GROUP_SHARED_MEMORY = 0x2,
693 WINED3DSSF_GLOBAL_UAV = 0x8,
696 enum wined3d_shader_uav_flags
698 WINED3DSUF_GLOBALLY_COHERENT = 0x2,
699 WINED3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
702 enum wined3d_tessellator_domain
704 WINED3D_TESSELLATOR_DOMAIN_LINE = 1,
705 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
706 WINED3D_TESSELLATOR_DOMAIN_QUAD = 3,
709 enum wined3d_tessellator_output_primitive
711 WINED3D_TESSELLATOR_OUTPUT_POINT = 1,
712 WINED3D_TESSELLATOR_OUTPUT_LINE = 2,
713 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
714 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
717 enum wined3d_tessellator_partitioning
719 WINED3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
720 WINED3D_TESSELLATOR_PARTITIONING_POW2 = 2,
721 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
722 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
725 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
726 #define WINED3DSI_TEXLD_PROJECT 0x1
727 #define WINED3DSI_TEXLD_BIAS 0x2
728 #define WINED3DSI_INDEXED_DYNAMIC 0x4
729 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
730 #define WINED3DSI_RESINFO_UINT 0x2
731 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
732 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
734 #define WINED3DSI_PRECISE_X 0x100
735 #define WINED3DSI_PRECISE_Y 0x200
736 #define WINED3DSI_PRECISE_Z 0x400
737 #define WINED3DSI_PRECISE_W 0x800
738 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
739 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
740 #define WINED3DSI_PRECISE_SHIFT 8
742 enum wined3d_shader_rel_op
744 WINED3D_SHADER_REL_OP_GT = 1,
745 WINED3D_SHADER_REL_OP_EQ = 2,
746 WINED3D_SHADER_REL_OP_GE = 3,
747 WINED3D_SHADER_REL_OP_LT = 4,
748 WINED3D_SHADER_REL_OP_NE = 5,
749 WINED3D_SHADER_REL_OP_LE = 6,
752 enum wined3d_shader_conditional_op
754 WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
755 WINED3D_SHADER_CONDITIONAL_OP_Z = 1
758 #define WINED3D_SM1_VS 0xfffeu
759 #define WINED3D_SM1_PS 0xffffu
760 #define WINED3D_SM4_PS 0x0000u
761 #define WINED3D_SM4_VS 0x0001u
762 #define WINED3D_SM4_GS 0x0002u
763 #define WINED3D_SM5_HS 0x0003u
764 #define WINED3D_SM5_DS 0x0004u
765 #define WINED3D_SM5_CS 0x0005u
767 /* Shader version tokens, and shader end tokens */
768 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
769 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
771 /* Shader backends */
773 /* TODO: Make this dynamic, based on shader limits ? */
774 #define MAX_ATTRIBS 16
775 #define MAX_REG_ADDR 1
776 #define MAX_REG_TEXCRD 8
777 #define MAX_REG_INPUT 32
778 #define MAX_REG_OUTPUT 32
779 #define WINED3D_MAX_CBS 15
781 /* FIXME: This needs to go up to 2048 for
782 * Shader model 3 according to msdn (and for software shaders) */
783 #define MAX_LABELS 16
785 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
787 struct wined3d_string_buffer
789 struct list entry;
790 char *buffer;
791 unsigned int buffer_size;
792 unsigned int content_size;
795 enum WINED3D_SHADER_INSTRUCTION_HANDLER
797 WINED3DSIH_ABS,
798 WINED3DSIH_ADD,
799 WINED3DSIH_AND,
800 WINED3DSIH_ATOMIC_AND,
801 WINED3DSIH_ATOMIC_CMP_STORE,
802 WINED3DSIH_ATOMIC_IADD,
803 WINED3DSIH_ATOMIC_IMAX,
804 WINED3DSIH_ATOMIC_IMIN,
805 WINED3DSIH_ATOMIC_OR,
806 WINED3DSIH_ATOMIC_UMAX,
807 WINED3DSIH_ATOMIC_UMIN,
808 WINED3DSIH_ATOMIC_XOR,
809 WINED3DSIH_BEM,
810 WINED3DSIH_BFI,
811 WINED3DSIH_BFREV,
812 WINED3DSIH_BREAK,
813 WINED3DSIH_BREAKC,
814 WINED3DSIH_BREAKP,
815 WINED3DSIH_BUFINFO,
816 WINED3DSIH_CALL,
817 WINED3DSIH_CALLNZ,
818 WINED3DSIH_CASE,
819 WINED3DSIH_CMP,
820 WINED3DSIH_CND,
821 WINED3DSIH_CONTINUE,
822 WINED3DSIH_CONTINUEP,
823 WINED3DSIH_COUNTBITS,
824 WINED3DSIH_CRS,
825 WINED3DSIH_CUT,
826 WINED3DSIH_CUT_STREAM,
827 WINED3DSIH_DCL,
828 WINED3DSIH_DCL_CONSTANT_BUFFER,
829 WINED3DSIH_DCL_FUNCTION_BODY,
830 WINED3DSIH_DCL_FUNCTION_TABLE,
831 WINED3DSIH_DCL_GLOBAL_FLAGS,
832 WINED3DSIH_DCL_GS_INSTANCES,
833 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT,
834 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT,
835 WINED3DSIH_DCL_HS_MAX_TESSFACTOR,
836 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
837 WINED3DSIH_DCL_INDEX_RANGE,
838 WINED3DSIH_DCL_INDEXABLE_TEMP,
839 WINED3DSIH_DCL_INPUT,
840 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT,
841 WINED3DSIH_DCL_INPUT_PRIMITIVE,
842 WINED3DSIH_DCL_INPUT_PS,
843 WINED3DSIH_DCL_INPUT_PS_SGV,
844 WINED3DSIH_DCL_INPUT_PS_SIV,
845 WINED3DSIH_DCL_INPUT_SGV,
846 WINED3DSIH_DCL_INPUT_SIV,
847 WINED3DSIH_DCL_INTERFACE,
848 WINED3DSIH_DCL_OUTPUT,
849 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT,
850 WINED3DSIH_DCL_OUTPUT_SIV,
851 WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
852 WINED3DSIH_DCL_RESOURCE_RAW,
853 WINED3DSIH_DCL_RESOURCE_STRUCTURED,
854 WINED3DSIH_DCL_SAMPLER,
855 WINED3DSIH_DCL_STREAM,
856 WINED3DSIH_DCL_TEMPS,
857 WINED3DSIH_DCL_TESSELLATOR_DOMAIN,
858 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE,
859 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING,
860 WINED3DSIH_DCL_TGSM_RAW,
861 WINED3DSIH_DCL_TGSM_STRUCTURED,
862 WINED3DSIH_DCL_THREAD_GROUP,
863 WINED3DSIH_DCL_UAV_RAW,
864 WINED3DSIH_DCL_UAV_STRUCTURED,
865 WINED3DSIH_DCL_UAV_TYPED,
866 WINED3DSIH_DCL_VERTICES_OUT,
867 WINED3DSIH_DEF,
868 WINED3DSIH_DEFAULT,
869 WINED3DSIH_DEFB,
870 WINED3DSIH_DEFI,
871 WINED3DSIH_DIV,
872 WINED3DSIH_DP2,
873 WINED3DSIH_DP2ADD,
874 WINED3DSIH_DP3,
875 WINED3DSIH_DP4,
876 WINED3DSIH_DST,
877 WINED3DSIH_DSX,
878 WINED3DSIH_DSX_COARSE,
879 WINED3DSIH_DSX_FINE,
880 WINED3DSIH_DSY,
881 WINED3DSIH_DSY_COARSE,
882 WINED3DSIH_DSY_FINE,
883 WINED3DSIH_ELSE,
884 WINED3DSIH_EMIT,
885 WINED3DSIH_EMIT_STREAM,
886 WINED3DSIH_ENDIF,
887 WINED3DSIH_ENDLOOP,
888 WINED3DSIH_ENDREP,
889 WINED3DSIH_ENDSWITCH,
890 WINED3DSIH_EQ,
891 WINED3DSIH_EVAL_SAMPLE_INDEX,
892 WINED3DSIH_EXP,
893 WINED3DSIH_EXPP,
894 WINED3DSIH_F16TOF32,
895 WINED3DSIH_F32TOF16,
896 WINED3DSIH_FCALL,
897 WINED3DSIH_FIRSTBIT_HI,
898 WINED3DSIH_FIRSTBIT_LO,
899 WINED3DSIH_FIRSTBIT_SHI,
900 WINED3DSIH_FRC,
901 WINED3DSIH_FTOI,
902 WINED3DSIH_FTOU,
903 WINED3DSIH_GATHER4,
904 WINED3DSIH_GATHER4_C,
905 WINED3DSIH_GATHER4_PO,
906 WINED3DSIH_GATHER4_PO_C,
907 WINED3DSIH_GE,
908 WINED3DSIH_HS_CONTROL_POINT_PHASE,
909 WINED3DSIH_HS_DECLS,
910 WINED3DSIH_HS_FORK_PHASE,
911 WINED3DSIH_HS_JOIN_PHASE,
912 WINED3DSIH_IADD,
913 WINED3DSIH_IBFE,
914 WINED3DSIH_IEQ,
915 WINED3DSIH_IF,
916 WINED3DSIH_IFC,
917 WINED3DSIH_IGE,
918 WINED3DSIH_ILT,
919 WINED3DSIH_IMAD,
920 WINED3DSIH_IMAX,
921 WINED3DSIH_IMIN,
922 WINED3DSIH_IMM_ATOMIC_ALLOC,
923 WINED3DSIH_IMM_ATOMIC_AND,
924 WINED3DSIH_IMM_ATOMIC_CMP_EXCH,
925 WINED3DSIH_IMM_ATOMIC_CONSUME,
926 WINED3DSIH_IMM_ATOMIC_EXCH,
927 WINED3DSIH_IMM_ATOMIC_IADD,
928 WINED3DSIH_IMM_ATOMIC_IMAX,
929 WINED3DSIH_IMM_ATOMIC_IMIN,
930 WINED3DSIH_IMM_ATOMIC_OR,
931 WINED3DSIH_IMM_ATOMIC_UMAX,
932 WINED3DSIH_IMM_ATOMIC_UMIN,
933 WINED3DSIH_IMM_ATOMIC_XOR,
934 WINED3DSIH_IMUL,
935 WINED3DSIH_INE,
936 WINED3DSIH_INEG,
937 WINED3DSIH_ISHL,
938 WINED3DSIH_ISHR,
939 WINED3DSIH_ITOF,
940 WINED3DSIH_LABEL,
941 WINED3DSIH_LD,
942 WINED3DSIH_LD2DMS,
943 WINED3DSIH_LD_RAW,
944 WINED3DSIH_LD_STRUCTURED,
945 WINED3DSIH_LD_UAV_TYPED,
946 WINED3DSIH_LIT,
947 WINED3DSIH_LOD,
948 WINED3DSIH_LOG,
949 WINED3DSIH_LOGP,
950 WINED3DSIH_LOOP,
951 WINED3DSIH_LRP,
952 WINED3DSIH_LT,
953 WINED3DSIH_M3x2,
954 WINED3DSIH_M3x3,
955 WINED3DSIH_M3x4,
956 WINED3DSIH_M4x3,
957 WINED3DSIH_M4x4,
958 WINED3DSIH_MAD,
959 WINED3DSIH_MAX,
960 WINED3DSIH_MIN,
961 WINED3DSIH_MOV,
962 WINED3DSIH_MOVA,
963 WINED3DSIH_MOVC,
964 WINED3DSIH_MUL,
965 WINED3DSIH_NE,
966 WINED3DSIH_NOP,
967 WINED3DSIH_NOT,
968 WINED3DSIH_NRM,
969 WINED3DSIH_OR,
970 WINED3DSIH_PHASE,
971 WINED3DSIH_POW,
972 WINED3DSIH_RCP,
973 WINED3DSIH_REP,
974 WINED3DSIH_RESINFO,
975 WINED3DSIH_RET,
976 WINED3DSIH_RETP,
977 WINED3DSIH_ROUND_NE,
978 WINED3DSIH_ROUND_NI,
979 WINED3DSIH_ROUND_PI,
980 WINED3DSIH_ROUND_Z,
981 WINED3DSIH_RSQ,
982 WINED3DSIH_SAMPLE,
983 WINED3DSIH_SAMPLE_B,
984 WINED3DSIH_SAMPLE_C,
985 WINED3DSIH_SAMPLE_C_LZ,
986 WINED3DSIH_SAMPLE_GRAD,
987 WINED3DSIH_SAMPLE_INFO,
988 WINED3DSIH_SAMPLE_LOD,
989 WINED3DSIH_SAMPLE_POS,
990 WINED3DSIH_SETP,
991 WINED3DSIH_SGE,
992 WINED3DSIH_SGN,
993 WINED3DSIH_SINCOS,
994 WINED3DSIH_SLT,
995 WINED3DSIH_SQRT,
996 WINED3DSIH_STORE_RAW,
997 WINED3DSIH_STORE_STRUCTURED,
998 WINED3DSIH_STORE_UAV_TYPED,
999 WINED3DSIH_SUB,
1000 WINED3DSIH_SWAPC,
1001 WINED3DSIH_SWITCH,
1002 WINED3DSIH_SYNC,
1003 WINED3DSIH_TEX,
1004 WINED3DSIH_TEXBEM,
1005 WINED3DSIH_TEXBEML,
1006 WINED3DSIH_TEXCOORD,
1007 WINED3DSIH_TEXDEPTH,
1008 WINED3DSIH_TEXDP3,
1009 WINED3DSIH_TEXDP3TEX,
1010 WINED3DSIH_TEXKILL,
1011 WINED3DSIH_TEXLDD,
1012 WINED3DSIH_TEXLDL,
1013 WINED3DSIH_TEXM3x2DEPTH,
1014 WINED3DSIH_TEXM3x2PAD,
1015 WINED3DSIH_TEXM3x2TEX,
1016 WINED3DSIH_TEXM3x3,
1017 WINED3DSIH_TEXM3x3DIFF,
1018 WINED3DSIH_TEXM3x3PAD,
1019 WINED3DSIH_TEXM3x3SPEC,
1020 WINED3DSIH_TEXM3x3TEX,
1021 WINED3DSIH_TEXM3x3VSPEC,
1022 WINED3DSIH_TEXREG2AR,
1023 WINED3DSIH_TEXREG2GB,
1024 WINED3DSIH_TEXREG2RGB,
1025 WINED3DSIH_UBFE,
1026 WINED3DSIH_UDIV,
1027 WINED3DSIH_UGE,
1028 WINED3DSIH_ULT,
1029 WINED3DSIH_UMAX,
1030 WINED3DSIH_UMIN,
1031 WINED3DSIH_UMUL,
1032 WINED3DSIH_USHR,
1033 WINED3DSIH_UTOF,
1034 WINED3DSIH_XOR,
1035 WINED3DSIH_TABLE_SIZE
1038 struct wined3d_shader_version
1040 enum wined3d_shader_type type;
1041 BYTE major;
1042 BYTE minor;
1045 struct wined3d_shader_resource_info
1047 enum wined3d_shader_resource_type type;
1048 enum wined3d_data_type data_type;
1049 unsigned int flags;
1050 unsigned int stride;
1053 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1055 struct wined3d_shader_sampler_map_entry
1057 unsigned int resource_idx;
1058 unsigned int sampler_idx;
1059 unsigned int bind_idx;
1062 struct wined3d_shader_sampler_map
1064 struct wined3d_shader_sampler_map_entry *entries;
1065 size_t size;
1066 size_t count;
1069 struct wined3d_shader_immediate_constant_buffer
1071 unsigned int vec4_count;
1072 DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
1075 struct wined3d_shader_indexable_temp
1077 struct list entry;
1078 unsigned int register_idx;
1079 unsigned int register_size;
1080 unsigned int component_count;
1083 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1085 struct wined3d_shader_reg_maps
1087 struct wined3d_shader_version shader_version;
1088 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
1089 BYTE address; /* MAX_REG_ADDR, 1 */
1090 WORD labels; /* MAX_LABELS, 16 */
1091 DWORD temporary; /* 32 */
1092 unsigned int temporary_count;
1093 DWORD *constf; /* pixel, vertex */
1094 struct list indexable_temps;
1095 const struct wined3d_shader_immediate_constant_buffer *icb;
1096 union
1098 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1099 BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1100 } u;
1101 DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1102 DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1103 WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1104 WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1105 WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1106 WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1107 UINT cb_sizes[WINED3D_MAX_CBS];
1108 uint32_t cb_map; /* WINED3D_MAX_CBS, 15 */
1110 struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS];
1111 uint32_t resource_map[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS)];
1112 struct wined3d_shader_sampler_map sampler_map;
1113 DWORD sampler_comparison_mode;
1114 BYTE bumpmat; /* WINED3D_MAX_TEXTURES, 8 */
1115 BYTE luminanceparams; /* WINED3D_MAX_TEXTURES, 8 */
1116 struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
1117 DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1118 DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1120 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1121 DWORD cull_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1122 DWORD usesnrm : 1;
1123 DWORD vpos : 1;
1124 DWORD usesdsx : 1;
1125 DWORD usesdsy : 1;
1126 DWORD usestexldd : 1;
1127 DWORD usesmova : 1;
1128 DWORD usesfacing : 1;
1129 DWORD usesrelconstF : 1;
1130 DWORD fog : 1;
1131 DWORD usestexldl : 1;
1132 DWORD usesifc : 1;
1133 DWORD usescall : 1;
1134 DWORD usespow : 1;
1135 DWORD point_size : 1;
1136 DWORD vocp : 1;
1137 DWORD input_rel_addressing : 1;
1138 DWORD viewport_array : 1;
1139 DWORD sample_mask : 1;
1140 DWORD padding : 14;
1142 DWORD rt_mask; /* Used render targets, 32 max. */
1144 /* Whether or not loops are used in this shader, and nesting depth */
1145 unsigned int loop_depth;
1146 unsigned int min_rel_offset, max_rel_offset;
1148 struct wined3d_shader_tgsm *tgsm;
1149 SIZE_T tgsm_capacity;
1150 unsigned int tgsm_count;
1153 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1154 * state information between multiple instructions. */
1155 struct wined3d_shader_tex_mx
1157 unsigned int current_row;
1158 DWORD texcoord_w[2];
1161 struct wined3d_shader_parser_state
1163 unsigned int current_loop_depth;
1164 unsigned int current_loop_reg;
1165 BOOL in_subroutine;
1168 struct wined3d_shader_context
1170 const struct wined3d_shader *shader;
1171 const struct wined3d_shader_reg_maps *reg_maps;
1172 struct wined3d_string_buffer *buffer;
1173 struct wined3d_shader_tex_mx *tex_mx;
1174 struct wined3d_shader_parser_state *state;
1175 void *backend_data;
1178 struct wined3d_shader_register_index
1180 const struct wined3d_shader_src_param *rel_addr;
1181 unsigned int offset;
1184 struct wined3d_shader_register
1186 enum wined3d_shader_register_type type;
1187 enum wined3d_data_type data_type;
1188 struct wined3d_shader_register_index idx[2];
1189 enum wined3d_immconst_type immconst_type;
1190 union
1192 DWORD immconst_data[4];
1193 unsigned fp_body_idx;
1194 } u;
1197 struct wined3d_shader_dst_param
1199 struct wined3d_shader_register reg;
1200 DWORD write_mask;
1201 DWORD modifiers;
1202 DWORD shift;
1205 struct wined3d_shader_src_param
1207 struct wined3d_shader_register reg;
1208 DWORD swizzle;
1209 enum wined3d_shader_src_modifier modifiers;
1212 struct wined3d_shader_index_range
1214 struct wined3d_shader_dst_param first_register;
1215 unsigned int last_register;
1218 struct wined3d_shader_semantic
1220 enum wined3d_decl_usage usage;
1221 UINT usage_idx;
1222 enum wined3d_shader_resource_type resource_type;
1223 enum wined3d_data_type resource_data_type;
1224 struct wined3d_shader_dst_param reg;
1227 enum wined3d_shader_input_sysval_semantic
1229 WINED3D_SIV_POSITION = 1,
1230 WINED3D_SIV_CLIP_DISTANCE = 2,
1231 WINED3D_SIV_CULL_DISTANCE = 3,
1232 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
1233 WINED3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
1234 WINED3D_SIV_VERTEX_ID = 6,
1235 WINED3D_SIV_PRIMITIVE_ID = 7,
1236 WINED3D_SIV_INSTANCE_ID = 8,
1237 WINED3D_SIV_IS_FRONT_FACE = 9,
1238 WINED3D_SIV_SAMPLE_INDEX = 10,
1239 WINED3D_SIV_QUAD_U0_TESS_FACTOR = 11,
1240 WINED3D_SIV_QUAD_V0_TESS_FACTOR = 12,
1241 WINED3D_SIV_QUAD_U1_TESS_FACTOR = 13,
1242 WINED3D_SIV_QUAD_V1_TESS_FACTOR = 14,
1243 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
1244 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
1245 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
1246 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
1247 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
1248 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
1249 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
1250 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
1253 struct wined3d_shader_register_semantic
1255 struct wined3d_shader_dst_param reg;
1256 enum wined3d_shader_input_sysval_semantic sysval_semantic;
1259 struct wined3d_shader_structured_resource
1261 struct wined3d_shader_dst_param reg;
1262 unsigned int byte_stride;
1265 struct wined3d_shader_tgsm
1267 unsigned int size;
1268 unsigned int stride;
1271 struct wined3d_shader_tgsm_raw
1273 struct wined3d_shader_dst_param reg;
1274 unsigned int byte_count;
1277 struct wined3d_shader_tgsm_structured
1279 struct wined3d_shader_dst_param reg;
1280 unsigned int byte_stride;
1281 unsigned int structure_count;
1284 struct wined3d_shader_thread_group_size
1286 unsigned int x, y, z;
1289 struct wined3d_shader_function_table_pointer
1291 unsigned int index;
1292 unsigned int array_size;
1293 unsigned int body_count;
1294 unsigned int table_count;
1297 struct wined3d_shader_texel_offset
1299 signed char u, v, w;
1302 struct wined3d_shader_primitive_type
1304 enum wined3d_primitive_type type;
1305 unsigned int patch_vertex_count;
1308 struct wined3d_shader_instruction
1310 const struct wined3d_shader_context *ctx;
1311 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
1312 DWORD flags;
1313 unsigned int dst_count;
1314 unsigned int src_count;
1315 const struct wined3d_shader_dst_param *dst;
1316 const struct wined3d_shader_src_param *src;
1317 struct wined3d_shader_texel_offset texel_offset;
1318 enum wined3d_shader_resource_type resource_type;
1319 enum wined3d_data_type resource_data_type;
1320 BOOL coissue;
1321 const struct wined3d_shader_src_param *predicate;
1322 union
1324 struct wined3d_shader_semantic semantic;
1325 struct wined3d_shader_register_semantic register_semantic;
1326 struct wined3d_shader_primitive_type primitive_type;
1327 struct wined3d_shader_dst_param dst;
1328 struct wined3d_shader_src_param src;
1329 unsigned int count;
1330 unsigned int index;
1331 const struct wined3d_shader_immediate_constant_buffer *icb;
1332 struct wined3d_shader_structured_resource structured_resource;
1333 struct wined3d_shader_tgsm_raw tgsm_raw;
1334 struct wined3d_shader_tgsm_structured tgsm_structured;
1335 struct wined3d_shader_thread_group_size thread_group_size;
1336 enum wined3d_tessellator_domain tessellator_domain;
1337 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1338 enum wined3d_tessellator_partitioning tessellator_partitioning;
1339 float max_tessellation_factor;
1340 struct wined3d_shader_index_range index_range;
1341 struct wined3d_shader_indexable_temp indexable_temp;
1342 struct wined3d_shader_function_table_pointer fp;
1343 } declaration;
1346 static inline BOOL wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction *ins)
1348 return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1351 struct wined3d_shader_attribute
1353 enum wined3d_decl_usage usage;
1354 UINT usage_idx;
1357 struct wined3d_shader_loop_control
1359 unsigned int count;
1360 unsigned int start;
1361 int step;
1364 struct wined3d_shader_frontend
1366 void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1367 const struct wined3d_shader_signature *output_signature);
1368 void (*shader_free)(void *data);
1369 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1370 void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1371 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1374 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
1375 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
1377 HRESULT shader_extract_from_dxbc(struct wined3d_shader *shader,
1378 unsigned int max_shader_version, enum wined3d_shader_byte_code_format *format) DECLSPEC_HIDDEN;
1379 BOOL shader_get_stream_output_register_info(const struct wined3d_shader *shader,
1380 const struct wined3d_stream_output_element *so_element, unsigned int *register_idx,
1381 unsigned int *component_idx) DECLSPEC_HIDDEN;
1383 typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
1385 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1386 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1387 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1388 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1389 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1391 struct shader_caps
1393 unsigned int vs_version;
1394 unsigned int hs_version;
1395 unsigned int ds_version;
1396 unsigned int gs_version;
1397 unsigned int ps_version;
1398 unsigned int cs_version;
1400 unsigned int vs_uniform_count;
1401 unsigned int ps_uniform_count;
1402 float ps_1x_max_value;
1403 unsigned int varying_count;
1405 DWORD wined3d_caps;
1408 enum wined3d_gl_resource_type
1410 WINED3D_GL_RES_TYPE_TEX_1D = 0,
1411 WINED3D_GL_RES_TYPE_TEX_2D = 1,
1412 WINED3D_GL_RES_TYPE_TEX_3D = 2,
1413 WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
1414 WINED3D_GL_RES_TYPE_TEX_RECT = 4,
1415 WINED3D_GL_RES_TYPE_BUFFER = 5,
1416 WINED3D_GL_RES_TYPE_RB = 6,
1417 WINED3D_GL_RES_TYPE_COUNT = 7,
1420 enum wined3d_vertex_processing_mode
1422 WINED3D_VP_MODE_FF,
1423 WINED3D_VP_MODE_SHADER,
1424 WINED3D_VP_MODE_NONE,
1427 #define WINED3D_CONST_NUM_UNUSED ~0U
1429 enum wined3d_ffp_ps_fog_mode
1431 WINED3D_FFP_PS_FOG_OFF,
1432 WINED3D_FFP_PS_FOG_LINEAR,
1433 WINED3D_FFP_PS_FOG_EXP,
1434 WINED3D_FFP_PS_FOG_EXP2,
1437 /* Stateblock dependent parameters which have to be hardcoded
1438 * into the shader code
1441 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1442 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1443 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1444 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1445 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1447 /* Used for Shader Model 1 pixel shaders to track the bound texture
1448 * type. 2D and RECT textures are separated through NP2 fixup. */
1449 enum wined3d_shader_tex_types
1451 WINED3D_SHADER_TEX_2D = 0,
1452 WINED3D_SHADER_TEX_3D = 1,
1453 WINED3D_SHADER_TEX_CUBE = 2,
1454 WINED3D_SHADER_TEX_ERR = 3,
1457 struct ps_compile_args
1459 struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
1460 enum wined3d_vertex_processing_mode vp_mode;
1461 enum wined3d_ffp_ps_fog_mode fog;
1462 DWORD tex_types; /* ps 1 - 3, 16 textures */
1463 WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1464 WORD srgb_correction;
1465 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1466 D3D9 has a limit of 16 samplers and the fixup is superfluous
1467 in D3D10 (unconditional NP2 support mandatory). */
1468 WORD np2_fixup;
1469 WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1470 WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
1471 WORD padding_to_dword;
1472 DWORD pointsprite : 1;
1473 DWORD flatshading : 1;
1474 DWORD alpha_test_func : 3;
1475 DWORD y_correction : 1;
1476 DWORD rt_alpha_swizzle : 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1477 DWORD dual_source_blend : 1;
1478 DWORD padding : 17;
1481 enum fog_src_type
1483 VS_FOG_Z = 0,
1484 VS_FOG_COORD = 1
1487 struct vs_compile_args
1489 BYTE fog_src;
1490 BYTE clip_enabled : 1;
1491 BYTE point_size : 1;
1492 BYTE per_vertex_point_size : 1;
1493 BYTE flatshading : 1;
1494 BYTE next_shader_type : 3;
1495 BYTE padding : 1;
1496 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1497 unsigned int next_shader_input_count;
1498 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1501 struct ds_compile_args
1503 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1504 enum wined3d_tessellator_partitioning tessellator_partitioning;
1505 unsigned int output_count : 16;
1506 unsigned int next_shader_type : 3;
1507 unsigned int render_offscreen : 1;
1508 unsigned int padding : 12;
1509 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1512 struct gs_compile_args
1514 unsigned int output_count;
1515 enum wined3d_primitive_type primitive_type;
1516 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1519 struct wined3d_shader_backend_ops
1521 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1522 void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1523 void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1524 const struct wined3d_state *state);
1525 void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1526 const struct wined3d_state *state);
1527 void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1528 void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1529 void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1530 void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1531 const struct wined3d_state *state);
1532 void (*shader_destroy)(struct wined3d_shader *shader);
1533 HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1534 const struct wined3d_fragment_pipe_ops *fragment_pipe);
1535 void (*shader_free_private)(struct wined3d_device *device, struct wined3d_context *context);
1536 BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1537 void (*shader_free_context_data)(struct wined3d_context *context);
1538 void (*shader_init_context_state)(struct wined3d_context *context);
1539 void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps);
1540 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1541 BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1542 uint64_t (*shader_compile)(struct wined3d_context *context, const struct wined3d_shader_desc *shader_desc,
1543 enum wined3d_shader_type shader_type);
1546 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
1547 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
1548 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
1550 const struct wined3d_shader_backend_ops *wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN;
1551 void wined3d_spirv_shader_backend_cleanup(void) DECLSPEC_HIDDEN;
1553 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1555 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1556 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1557 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1558 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1560 static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1562 wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1563 wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1564 wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1565 wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1568 extern const struct wined3d_vec4 wined3d_srgb_const[] DECLSPEC_HIDDEN;
1570 static inline float wined3d_srgb_from_linear(float colour)
1572 if (colour < 0.0f)
1573 return 0.0f;
1574 if (colour < wined3d_srgb_const[1].x)
1575 return colour * wined3d_srgb_const[0].w;
1576 if (colour < 1.0f)
1577 return wined3d_srgb_const[0].y * powf(colour, wined3d_srgb_const[0].x) - wined3d_srgb_const[0].z;
1578 return 1.0f;
1581 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
1582 const struct wined3d_color *colour)
1584 colour_srgb->r = wined3d_srgb_from_linear(colour->r);
1585 colour_srgb->g = wined3d_srgb_from_linear(colour->g);
1586 colour_srgb->b = wined3d_srgb_from_linear(colour->b);
1587 colour_srgb->a = colour->a;
1590 void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1591 const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1593 /* Checking of API calls */
1594 /* --------------------- */
1595 #ifndef WINE_NO_DEBUG_MSGS
1596 #define checkGLcall(A) \
1597 do { \
1598 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1599 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1600 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1601 } while(0)
1602 #else
1603 #define checkGLcall(A) do {} while(0)
1604 #endif
1606 struct wined3d_bo
1608 struct list users;
1609 void *map_ptr;
1610 size_t buffer_offset;
1611 size_t memory_offset;
1612 bool coherent;
1615 struct wined3d_bo_gl
1617 struct wined3d_bo b;
1619 GLuint id;
1620 GLsizeiptr size;
1621 GLenum binding;
1622 GLenum usage;
1624 GLbitfield flags;
1625 uint64_t command_fence_id;
1628 static inline struct wined3d_bo_gl *wined3d_bo_gl(struct wined3d_bo *bo)
1630 return CONTAINING_RECORD(bo, struct wined3d_bo_gl, b);
1633 static inline GLuint wined3d_bo_gl_id(struct wined3d_bo *bo)
1635 return bo ? wined3d_bo_gl(bo)->id : 0;
1638 struct wined3d_bo_user
1640 struct list entry;
1641 bool valid;
1644 struct wined3d_bo_vk
1646 struct wined3d_bo b;
1648 VkBuffer vk_buffer;
1649 struct wined3d_allocator_block *memory;
1650 struct wined3d_bo_slab_vk *slab;
1652 VkDeviceMemory vk_memory;
1654 VkDeviceSize size;
1655 VkBufferUsageFlags usage;
1656 VkMemoryPropertyFlags memory_type;
1658 uint64_t command_buffer_id;
1659 bool host_synced;
1662 static inline struct wined3d_bo_vk *wined3d_bo_vk(struct wined3d_bo *bo)
1664 return CONTAINING_RECORD(bo, struct wined3d_bo_vk, b);
1667 struct wined3d_bo_slab_vk_key
1669 VkMemoryPropertyFlags memory_type;
1670 VkBufferUsageFlags usage;
1671 VkDeviceSize size;
1674 struct wined3d_bo_slab_vk
1676 struct wine_rb_entry entry;
1677 struct wined3d_bo_slab_vk *next;
1678 VkMemoryPropertyFlags requested_memory_type;
1679 struct wined3d_bo_vk bo;
1680 unsigned int map_count;
1681 void *map_ptr;
1682 uint32_t map;
1685 void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk *slab_vk,
1686 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
1687 void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk,
1688 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
1690 struct wined3d_bo_address
1692 struct wined3d_bo *buffer_object;
1693 BYTE *addr;
1696 struct wined3d_const_bo_address
1698 struct wined3d_bo *buffer_object;
1699 const BYTE *addr;
1702 static inline struct wined3d_const_bo_address *wined3d_const_bo_address(const struct wined3d_bo_address *data)
1704 return (struct wined3d_const_bo_address *)data;
1707 struct wined3d_image_vk
1709 VkImage vk_image;
1710 struct wined3d_allocator_block *memory;
1711 VkDeviceMemory vk_memory;
1712 uint64_t command_buffer_id;
1715 struct wined3d_stream_info_element
1717 const struct wined3d_format *format;
1718 struct wined3d_bo_address data;
1719 GLsizei stride;
1720 unsigned int stream_idx;
1721 unsigned int divisor;
1722 bool instanced;
1725 struct wined3d_stream_info
1727 struct wined3d_stream_info_element elements[MAX_ATTRIBS];
1728 DWORD position_transformed : 1;
1729 DWORD all_vbo : 1;
1730 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1731 WORD use_map; /* MAX_ATTRIBS, 16 */
1734 void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_info,
1735 const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
1737 struct wined3d_direct_dispatch_parameters
1739 unsigned int group_count_x;
1740 unsigned int group_count_y;
1741 unsigned int group_count_z;
1744 struct wined3d_indirect_dispatch_parameters
1746 struct wined3d_buffer *buffer;
1747 unsigned int offset;
1750 struct wined3d_dispatch_parameters
1752 BOOL indirect;
1753 union
1755 struct wined3d_direct_dispatch_parameters direct;
1756 struct wined3d_indirect_dispatch_parameters indirect;
1757 } u;
1760 struct wined3d_direct_draw_parameters
1762 int base_vertex_idx;
1763 unsigned int start_idx;
1764 unsigned int index_count;
1765 unsigned int start_instance;
1766 unsigned int instance_count;
1769 struct wined3d_indirect_draw_parameters
1771 struct wined3d_buffer *buffer;
1772 unsigned int offset;
1775 struct wined3d_draw_parameters
1777 BOOL indirect;
1778 union
1780 struct wined3d_direct_draw_parameters direct;
1781 struct wined3d_indirect_draw_parameters indirect;
1782 } u;
1783 BOOL indexed;
1786 void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
1787 const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
1788 void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
1789 const struct wined3d_dispatch_parameters *dispatch_parameters) DECLSPEC_HIDDEN;
1791 #define eps 1e-8f
1793 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1794 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1796 /* Routines and structures related to state management */
1798 #define STATE_RENDER(a) (a)
1799 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1801 #define STATE_TEXTURESTAGE(stage, num) \
1802 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1803 #define STATE_IS_TEXTURESTAGE(a) \
1804 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1806 /* + 1 because samplers start with 0 */
1807 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1808 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1810 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1811 #define STATE_IS_GRAPHICS_SHADER(a) \
1812 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1814 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1815 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1816 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1817 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1819 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1820 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1822 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1823 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1825 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1826 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1828 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1829 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1830 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1831 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1833 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1834 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1836 #define STATE_VIEWPORT (STATE_VDECL + 1)
1837 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1839 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1840 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1841 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1842 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1844 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1845 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1847 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1848 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1850 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1851 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1853 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1854 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1856 #define STATE_POINTSPRITECOORDORIGIN (STATE_RASTERIZER + 1)
1857 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1859 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1860 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1862 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1863 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1865 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1866 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1868 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1869 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1871 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1872 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1874 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1875 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1877 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1878 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1880 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1881 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1883 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1884 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1886 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1887 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1889 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1891 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1892 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1894 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1895 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1897 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1898 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1900 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1901 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1903 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1904 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1906 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1907 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1909 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1910 #define STATE_CONSTANT_BUFFER(a) \
1911 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1912 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1913 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1915 enum fogsource {
1916 FOGSOURCE_FFP,
1917 FOGSOURCE_VS,
1918 FOGSOURCE_COORD,
1921 union wined3d_gl_fence_object
1923 GLuint id;
1924 GLsync sync;
1927 enum wined3d_fence_result
1929 WINED3D_FENCE_OK,
1930 WINED3D_FENCE_WAITING,
1931 WINED3D_FENCE_NOT_STARTED,
1932 WINED3D_FENCE_WRONG_THREAD,
1933 WINED3D_FENCE_ERROR,
1936 struct wined3d_fence
1938 struct list entry;
1939 union wined3d_gl_fence_object object;
1940 struct wined3d_context_gl *context_gl;
1943 HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
1944 void wined3d_fence_destroy(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
1945 void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device) DECLSPEC_HIDDEN;
1946 enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
1947 struct wined3d_device *device) DECLSPEC_HIDDEN;
1948 enum wined3d_fence_result wined3d_fence_test(const struct wined3d_fence *fence,
1949 struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
1951 /* Direct3D terminology with little modifications. We do not have an issued
1952 * state because only the driver knows about it, but we have a created state
1953 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1954 enum wined3d_query_state
1956 QUERY_CREATED,
1957 QUERY_SIGNALLED,
1958 QUERY_BUILDING
1961 struct wined3d_query_ops
1963 BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
1964 BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
1965 void (*query_destroy)(struct wined3d_query *query);
1968 struct wined3d_query
1970 LONG ref;
1972 void *parent;
1973 const struct wined3d_parent_ops *parent_ops;
1974 struct wined3d_device *device;
1975 enum wined3d_query_state state;
1976 enum wined3d_query_type type;
1977 const void *data;
1978 DWORD data_size;
1979 const struct wined3d_query_ops *query_ops;
1981 LONG counter_main, counter_retrieved;
1982 struct list poll_list_entry;
1984 GLuint buffer_object;
1985 UINT64 *map_ptr;
1988 HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
1989 const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
1990 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl,
1991 struct wined3d_query *query) DECLSPEC_HIDDEN;
1993 struct wined3d_event_query
1995 struct wined3d_query query;
1997 struct wined3d_fence fence;
1998 BOOL signalled;
2001 struct wined3d_occlusion_query
2003 struct wined3d_query query;
2005 struct list entry;
2006 GLuint id;
2007 struct wined3d_context_gl *context_gl;
2008 UINT64 samples;
2009 BOOL started;
2012 struct wined3d_timestamp_query
2014 struct wined3d_query query;
2016 struct list entry;
2017 GLuint id;
2018 struct wined3d_context_gl *context_gl;
2019 UINT64 timestamp;
2022 union wined3d_gl_so_statistics_query
2024 GLuint id[2];
2025 struct
2027 GLuint written;
2028 GLuint generated;
2029 } query;
2032 struct wined3d_so_statistics_query
2034 struct wined3d_query query;
2036 struct list entry;
2037 union wined3d_gl_so_statistics_query u;
2038 struct wined3d_context_gl *context_gl;
2039 unsigned int stream_idx;
2040 struct wined3d_query_data_so_statistics statistics;
2041 BOOL started;
2044 union wined3d_gl_pipeline_statistics_query
2046 GLuint id[11];
2047 struct
2049 GLuint vertices;
2050 GLuint primitives;
2051 GLuint vertex_shader;
2052 GLuint tess_control_shader;
2053 GLuint tess_eval_shader;
2054 GLuint geometry_shader;
2055 GLuint geometry_primitives;
2056 GLuint fragment_shader;
2057 GLuint compute_shader;
2058 GLuint clipping_input;
2059 GLuint clipping_output;
2060 } query;
2063 struct wined3d_pipeline_statistics_query
2065 struct wined3d_query query;
2067 struct list entry;
2068 union wined3d_gl_pipeline_statistics_query u;
2069 struct wined3d_context_gl *context_gl;
2070 struct wined3d_query_data_pipeline_statistics statistics;
2071 BOOL started;
2074 #define WINED3D_QUERY_POOL_SIZE 256
2076 struct wined3d_query_pool_vk
2078 struct list entry;
2079 struct list completed_entry;
2081 struct list *free_list;
2082 VkQueryPool vk_query_pool;
2083 uint32_t allocated[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)];
2084 uint32_t completed[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)];
2087 bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk *pool_vk, size_t *idx) DECLSPEC_HIDDEN;
2088 void wined3d_query_pool_vk_cleanup(struct wined3d_query_pool_vk *pool_vk,
2089 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2090 void wined3d_query_pool_vk_reset(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk,
2091 VkCommandBuffer vk_command_buffer) DECLSPEC_HIDDEN;
2092 bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk,
2093 enum wined3d_query_type type, struct list *free_pools) DECLSPEC_HIDDEN;
2095 struct wined3d_query_pool_idx_vk
2097 struct wined3d_query_pool_vk *pool_vk;
2098 size_t idx;
2101 #define WINED3D_QUERY_VK_FLAG_ACTIVE 0x00000001
2102 #define WINED3D_QUERY_VK_FLAG_STARTED 0x00000002
2103 #define WINED3D_QUERY_VK_FLAG_RENDER_PASS 0x00000004
2105 struct wined3d_query_vk
2107 struct wined3d_query q;
2109 struct list entry;
2110 struct wined3d_query_pool_idx_vk pool_idx;
2111 uint8_t flags;
2112 uint64_t command_buffer_id;
2113 uint32_t control_flags;
2114 size_t pending_count;
2117 static inline struct wined3d_query_vk *wined3d_query_vk(struct wined3d_query *query)
2119 return CONTAINING_RECORD(query, struct wined3d_query_vk, q);
2122 bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk,
2123 const struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN;
2124 HRESULT wined3d_query_vk_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
2125 const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
2126 void wined3d_query_vk_resume(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2127 void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2129 struct wined3d_gl_view
2131 GLenum target;
2132 GLuint name;
2135 struct wined3d_range
2137 unsigned int offset;
2138 unsigned int size;
2141 struct wined3d_rendertarget_info
2143 struct wined3d_gl_view gl_view;
2144 struct wined3d_resource *resource;
2145 unsigned int sub_resource_idx;
2146 unsigned int layer_count;
2149 struct wined3d_fb_state
2151 struct wined3d_rendertarget_view *render_targets[WINED3D_MAX_RENDER_TARGETS];
2152 struct wined3d_rendertarget_view *depth_stencil;
2155 #define MAX_GL_FRAGMENT_SAMPLERS 32
2157 struct wined3d_context
2159 const struct wined3d_d3d_info *d3d_info;
2160 const struct wined3d_state_entry *state_table;
2161 uint32_t dirty_graphics_states[WINED3D_BITMAP_SIZE(STATE_HIGHEST)];
2162 uint32_t dirty_compute_states[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT)];
2164 struct wined3d_device *device;
2165 struct wined3d_swapchain *swapchain;
2166 struct
2168 struct wined3d_texture *texture;
2169 unsigned int sub_resource_idx;
2170 } current_rt;
2172 /* Stores some information about the context state for optimization */
2173 DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
2174 DWORD update_shader_resource_bindings : 1;
2175 DWORD update_compute_shader_resource_bindings : 1;
2176 DWORD update_unordered_access_view_bindings : 1;
2177 DWORD update_compute_unordered_access_view_bindings : 1;
2178 DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
2179 DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */
2180 DWORD last_was_pshader : 1;
2181 DWORD last_was_vshader : 1;
2182 DWORD last_was_diffuse : 1;
2183 DWORD last_was_specular : 1;
2184 DWORD last_was_normal : 1;
2186 DWORD last_was_ffp_blit : 1;
2187 DWORD last_was_blit : 1;
2188 DWORD last_was_ckey : 1;
2189 DWORD last_was_dual_source_blend : 1;
2190 DWORD texShaderBumpMap : 8; /* WINED3D_MAX_TEXTURES, 8 */
2191 DWORD lastWasPow2Texture : 8; /* WINED3D_MAX_TEXTURES, 8 */
2192 DWORD fixed_function_usage_map : 8; /* WINED3D_MAX_TEXTURES, 8 */
2193 DWORD lowest_disabled_stage : 4; /* Max WINED3D_MAX_TEXTURES, 8 */
2195 DWORD use_immediate_mode_draw : 1;
2196 DWORD uses_uavs : 1;
2197 DWORD uses_fbo_attached_resources : 1;
2198 DWORD transform_feedback_active : 1;
2199 DWORD transform_feedback_paused : 1;
2200 DWORD fog_coord : 1;
2201 DWORD render_offscreen : 1;
2202 DWORD current : 1;
2203 DWORD destroyed : 1;
2204 DWORD destroy_delayed : 1;
2205 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
2206 DWORD namedArraysLoaded : 1;
2207 DWORD padding : 13;
2209 DWORD constant_update_mask;
2210 DWORD numbered_array_mask;
2211 enum fogsource fog_source;
2213 UINT instance_count;
2215 void *shader_backend_data;
2216 void *fragment_pipe_data;
2218 struct wined3d_stream_info stream_info;
2220 unsigned int viewport_count;
2221 unsigned int scissor_rect_count;
2224 void wined3d_context_cleanup(struct wined3d_context *context) DECLSPEC_HIDDEN;
2225 void wined3d_context_init(struct wined3d_context *context, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2226 void context_preload_textures(struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2227 void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2229 HRESULT wined3d_context_no3d_init(struct wined3d_context *context_no3d,
2230 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2232 struct wined3d_command_fence_gl
2234 uint64_t id;
2235 struct wined3d_fence *fence;
2238 struct wined3d_context_gl
2240 struct wined3d_context c;
2242 const struct wined3d_gl_info *gl_info;
2244 DWORD tid; /* Thread ID which owns this context at the moment. */
2246 uint32_t dc_is_private : 1;
2247 uint32_t dc_has_format : 1; /* Only meaningful for private DCs. */
2248 uint32_t fog_enabled : 1;
2249 uint32_t diffuse_attrib_to_1 : 1;
2250 uint32_t rebind_fbo : 1;
2251 uint32_t untracked_material_count : 2; /* Max value 2 */
2252 uint32_t needs_set : 1;
2253 uint32_t valid : 1;
2254 uint32_t padding : 23;
2256 uint32_t default_attrib_value_set;
2258 GLenum tracking_parm; /* Which source is tracking current colour. */
2259 GLenum untracked_materials[2];
2260 SIZE blit_size;
2261 unsigned int active_texture;
2263 GLenum *texture_type;
2265 /* The WGL context. */
2266 unsigned int level;
2267 HGLRC restore_ctx;
2268 HDC restore_dc;
2269 int restore_pf;
2270 HWND restore_pf_win;
2271 HGLRC gl_ctx;
2272 HDC dc;
2273 int pixel_format;
2274 HWND window;
2275 GLint aux_buffers;
2277 /* FBOs. */
2278 unsigned int fbo_entry_count;
2279 struct list fbo_list;
2280 struct list fbo_destroy_list;
2281 struct fbo_entry *current_fbo;
2282 GLuint fbo_read_binding;
2283 GLuint fbo_draw_binding;
2284 struct wined3d_rendertarget_info blit_targets[WINED3D_MAX_RENDER_TARGETS];
2285 uint32_t draw_buffers_mask; /* Enabled draw buffers, 31 max. */
2287 /* Queries. */
2288 struct list occlusion_queries;
2289 struct list fences;
2290 struct list timestamp_queries;
2291 struct list so_statistics_queries;
2292 struct list pipeline_statistics_queries;
2294 GLuint *free_occlusion_queries;
2295 SIZE_T free_occlusion_query_size;
2296 unsigned int free_occlusion_query_count;
2298 union wined3d_gl_fence_object *free_fences;
2299 SIZE_T free_fence_size;
2300 unsigned int free_fence_count;
2302 GLuint *free_timestamp_queries;
2303 SIZE_T free_timestamp_query_size;
2304 unsigned int free_timestamp_query_count;
2306 union wined3d_gl_so_statistics_query *free_so_statistics_queries;
2307 SIZE_T free_so_statistics_query_size;
2308 unsigned int free_so_statistics_query_count;
2310 union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
2311 SIZE_T free_pipeline_statistics_query_size;
2312 unsigned int free_pipeline_statistics_query_count;
2314 GLuint blit_vbo;
2316 unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
2317 unsigned int rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS];
2319 /* Extension emulation. */
2320 GLint gl_fog_source;
2321 GLfloat fog_coord_value;
2322 GLfloat colour[4], fog_start, fog_end, fog_colour[4];
2324 GLuint dummy_arbfp_prog;
2326 struct
2328 struct wined3d_command_fence_gl *fences;
2329 SIZE_T fences_size;
2330 SIZE_T fence_count;
2331 } submitted;
2334 static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_context *context)
2336 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2339 static inline const struct wined3d_context_gl *wined3d_context_gl_const(const struct wined3d_context *context)
2341 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2344 struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
2345 struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2346 void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
2347 const struct wined3d_gl_info *gl_info, unsigned int unit) DECLSPEC_HIDDEN;
2348 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
2349 struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2350 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
2351 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2352 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
2353 struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2354 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
2355 struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2356 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
2357 struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2358 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
2359 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2360 BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, const struct wined3d_state *state,
2361 unsigned int rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2362 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl *context_gl, GLenum target,
2363 struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
2364 struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
2365 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
2366 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2367 void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
2368 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2369 void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
2370 GLenum target, GLuint name) DECLSPEC_HIDDEN;
2371 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
2372 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
2373 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
2374 bool wined3d_context_gl_create_bo(struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding,
2375 GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
2376 void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2377 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo) DECLSPEC_HIDDEN;
2378 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
2379 unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2380 enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2381 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl,
2382 struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
2383 const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2384 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t mask) DECLSPEC_HIDDEN;
2385 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2386 void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl *context_gl,
2387 const struct wined3d_const_bo_address *data, size_t size) DECLSPEC_HIDDEN;
2388 void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2389 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2390 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2391 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2392 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2393 struct wined3d_context_gl *wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN;
2394 GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2395 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
2396 const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2397 HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
2398 struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
2399 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
2400 const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2401 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
2402 const struct wined3d_bo_address *data, size_t size, uint32_t flags) DECLSPEC_HIDDEN;
2403 struct wined3d_context_gl *wined3d_context_gl_reacquire(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2404 void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2405 BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2406 void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN;
2407 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2408 void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
2409 const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
2410 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2411 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data,
2412 unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN;
2413 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl,
2414 const struct wined3d_state *state) DECLSPEC_HIDDEN;
2415 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl *context_gl, uint64_t id) DECLSPEC_HIDDEN;
2417 struct wined3d_command_buffer_vk
2419 uint64_t id;
2420 VkCommandBuffer vk_command_buffer;
2421 VkFence vk_fence;
2424 enum wined3d_retired_object_type_vk
2426 WINED3D_RETIRED_FREE_VK,
2427 WINED3D_RETIRED_FRAMEBUFFER_VK,
2428 WINED3D_RETIRED_DESCRIPTOR_POOL_VK,
2429 WINED3D_RETIRED_MEMORY_VK,
2430 WINED3D_RETIRED_ALLOCATOR_BLOCK_VK,
2431 WINED3D_RETIRED_BO_SLAB_SLICE_VK,
2432 WINED3D_RETIRED_BUFFER_VK,
2433 WINED3D_RETIRED_IMAGE_VK,
2434 WINED3D_RETIRED_BUFFER_VIEW_VK,
2435 WINED3D_RETIRED_IMAGE_VIEW_VK,
2436 WINED3D_RETIRED_SAMPLER_VK,
2439 struct wined3d_retired_object_vk
2441 enum wined3d_retired_object_type_vk type;
2442 union
2444 struct wined3d_retired_object_vk *next;
2445 VkFramebuffer vk_framebuffer;
2446 VkDescriptorPool vk_descriptor_pool;
2447 VkDeviceMemory vk_memory;
2448 struct wined3d_allocator_block *block;
2449 struct
2451 struct wined3d_bo_slab_vk *slab;
2452 size_t idx;
2453 } slice;
2454 VkBuffer vk_buffer;
2455 VkImage vk_image;
2456 VkBufferView vk_buffer_view;
2457 VkImageView vk_image_view;
2458 VkSampler vk_sampler;
2459 } u;
2460 uint64_t command_buffer_id;
2463 struct wined3d_retired_objects_vk
2465 struct wined3d_retired_object_vk *objects;
2466 struct wined3d_retired_object_vk *free;
2467 SIZE_T size;
2468 SIZE_T count;
2471 struct wined3d_render_pass_attachment_vk
2473 VkFormat vk_format;
2474 VkSampleCountFlagBits vk_samples;
2475 VkImageLayout vk_layout;
2478 struct wined3d_render_pass_key_vk
2480 struct wined3d_render_pass_attachment_vk rt[WINED3D_MAX_RENDER_TARGETS];
2481 struct wined3d_render_pass_attachment_vk ds;
2482 uint32_t rt_mask;
2483 uint32_t clear_flags;
2486 struct wined3d_render_pass_vk
2488 struct wine_rb_entry entry;
2489 struct wined3d_render_pass_key_vk key;
2490 VkRenderPass vk_render_pass;
2493 struct wined3d_pipeline_layout_key_vk
2495 VkDescriptorSetLayoutBinding *bindings;
2496 SIZE_T binding_count;
2499 struct wined3d_pipeline_layout_vk
2501 struct wine_rb_entry entry;
2502 struct wined3d_pipeline_layout_key_vk key;
2503 VkPipelineLayout vk_pipeline_layout;
2504 VkDescriptorSetLayout vk_set_layout;
2507 struct wined3d_graphics_pipeline_key_vk
2509 VkPipelineShaderStageCreateInfo stages[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
2510 VkVertexInputBindingDivisorDescriptionEXT divisors[MAX_ATTRIBS];
2511 VkVertexInputAttributeDescription attributes[MAX_ATTRIBS];
2512 VkVertexInputBindingDescription bindings[MAX_ATTRIBS];
2513 VkViewport viewport;
2514 VkRect2D scissor;
2515 VkSampleMask sample_mask;
2516 VkPipelineColorBlendAttachmentState blend_attachments[WINED3D_MAX_RENDER_TARGETS];
2518 VkPipelineVertexInputDivisorStateCreateInfoEXT divisor_desc;
2519 VkPipelineVertexInputStateCreateInfo input_desc;
2520 VkPipelineInputAssemblyStateCreateInfo ia_desc;
2521 VkPipelineTessellationStateCreateInfo ts_desc;
2522 VkPipelineViewportStateCreateInfo vp_desc;
2523 VkPipelineRasterizationStateCreateInfo rs_desc;
2524 VkPipelineMultisampleStateCreateInfo ms_desc;
2525 VkPipelineDepthStencilStateCreateInfo ds_desc;
2526 VkPipelineColorBlendStateCreateInfo blend_desc;
2527 VkPipelineDynamicStateCreateInfo dynamic_desc;
2529 VkGraphicsPipelineCreateInfo pipeline_desc;
2532 struct wined3d_graphics_pipeline_vk
2534 struct wine_rb_entry entry;
2535 struct wined3d_graphics_pipeline_key_vk key;
2536 VkPipeline vk_pipeline;
2539 enum wined3d_shader_descriptor_type
2541 WINED3D_SHADER_DESCRIPTOR_TYPE_CBV,
2542 WINED3D_SHADER_DESCRIPTOR_TYPE_SRV,
2543 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV,
2544 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER,
2545 WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER,
2548 struct wined3d_shader_resource_binding
2550 enum wined3d_shader_type shader_type;
2551 enum wined3d_shader_descriptor_type shader_descriptor_type;
2552 size_t resource_idx;
2553 enum wined3d_shader_resource_type resource_type;
2554 enum wined3d_data_type resource_data_type;
2555 size_t binding_idx;
2558 struct wined3d_shader_resource_bindings
2560 struct wined3d_shader_resource_binding *bindings;
2561 SIZE_T size, count;
2564 struct wined3d_shader_descriptor_writes_vk
2566 VkWriteDescriptorSet *writes;
2567 SIZE_T size, count;
2570 struct wined3d_pending_query_vk
2572 struct wined3d_query_vk *query_vk;
2573 struct wined3d_query_pool_idx_vk pool_idx;
2576 struct wined3d_pending_queries_vk
2578 struct wined3d_pending_query_vk *queries;
2579 SIZE_T free_idx;
2580 SIZE_T size;
2581 SIZE_T count;
2584 struct wined3d_context_vk
2586 struct wined3d_context c;
2588 const struct wined3d_vk_info *vk_info;
2590 uint32_t update_compute_pipeline : 1;
2591 uint32_t update_stream_output : 1;
2592 uint32_t padding : 30;
2594 struct
2596 VkShaderModule vk_modules[WINED3D_SHADER_TYPE_GRAPHICS_COUNT];
2597 struct wined3d_graphics_pipeline_key_vk pipeline_key_vk;
2598 VkPipeline vk_pipeline;
2599 VkPipelineLayout vk_pipeline_layout;
2600 VkDescriptorSetLayout vk_set_layout;
2601 struct wined3d_shader_resource_bindings bindings;
2602 } graphics;
2604 struct
2606 VkPipeline vk_pipeline;
2607 VkPipelineLayout vk_pipeline_layout;
2608 VkDescriptorSetLayout vk_set_layout;
2609 struct wined3d_shader_resource_bindings bindings;
2610 } compute;
2612 VkCommandPool vk_command_pool;
2613 struct wined3d_command_buffer_vk current_command_buffer;
2614 uint64_t completed_command_buffer_id;
2615 VkDeviceSize retired_bo_size;
2617 struct
2619 struct wined3d_command_buffer_vk *buffers;
2620 SIZE_T buffers_size;
2621 SIZE_T buffer_count;
2622 } submitted;
2624 struct wined3d_shader_descriptor_writes_vk descriptor_writes;
2626 VkFramebuffer vk_framebuffer;
2627 VkRenderPass vk_render_pass;
2628 VkDescriptorPool vk_descriptor_pool;
2630 VkSampleCountFlagBits sample_count;
2631 unsigned int rt_count;
2633 VkBuffer vk_so_counters[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
2634 VkDeviceSize vk_so_offsets[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
2635 struct wined3d_bo_vk vk_so_counter_bo;
2637 struct list render_pass_queries;
2638 struct list active_queries;
2639 struct wined3d_pending_queries_vk pending_queries;
2640 struct list completed_query_pools;
2641 struct list free_occlusion_query_pools;
2642 struct list free_timestamp_query_pools;
2643 struct list free_pipeline_statistics_query_pools;
2644 struct list free_stream_output_statistics_query_pools;
2646 struct wined3d_retired_objects_vk retired;
2647 struct wine_rb_tree render_passes;
2648 struct wine_rb_tree pipeline_layouts;
2649 struct wine_rb_tree graphics_pipelines;
2650 struct wine_rb_tree bo_slab_available;
2653 static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
2655 return CONTAINING_RECORD(context, struct wined3d_context_vk, c);
2658 void wined3d_context_vk_accumulate_pending_queries(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2659 void wined3d_context_vk_add_pending_query(struct wined3d_context_vk *context_vk,
2660 struct wined3d_query_vk *query_vk) DECLSPEC_HIDDEN;
2661 bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk,
2662 enum wined3d_query_type type, struct wined3d_query_pool_idx_vk *pool_idx) DECLSPEC_HIDDEN;
2663 VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_context_vk *context_vk,
2664 unsigned int pool, size_t size) DECLSPEC_HIDDEN;
2665 VkCommandBuffer wined3d_context_vk_apply_compute_state(struct wined3d_context_vk *context_vk,
2666 const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk) DECLSPEC_HIDDEN;
2667 VkCommandBuffer wined3d_context_vk_apply_draw_state(struct wined3d_context_vk *context_vk,
2668 const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk, bool indexed) DECLSPEC_HIDDEN;
2669 void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2670 BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
2671 VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2672 BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type,
2673 VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth,
2674 unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags,
2675 struct wined3d_image_vk *image) DECLSPEC_HIDDEN;
2676 void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *context_vk,
2677 struct wined3d_allocator_block *block, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2678 void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk,
2679 const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2680 void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk,
2681 struct wined3d_image_vk *image_vk) DECLSPEC_HIDDEN;
2682 void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk,
2683 VkBufferView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2684 void wined3d_context_vk_destroy_vk_framebuffer(struct wined3d_context_vk *context_vk,
2685 VkFramebuffer vk_framebuffer, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2686 void wined3d_context_vk_destroy_vk_image(struct wined3d_context_vk *context_vk,
2687 VkImage vk_image, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2688 void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk,
2689 VkImageView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2690 void wined3d_context_vk_destroy_vk_memory(struct wined3d_context_vk *context_vk,
2691 VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2692 void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk *context_vk,
2693 VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2694 void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2695 VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2696 struct wined3d_pipeline_layout_vk *wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk,
2697 VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count) DECLSPEC_HIDDEN;
2698 VkRenderPass wined3d_context_vk_get_render_pass(struct wined3d_context_vk *context_vk,
2699 const struct wined3d_fb_state *fb, unsigned int rt_count,
2700 bool depth_stencil, uint32_t clear_flags) DECLSPEC_HIDDEN;
2701 void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk,
2702 VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask,
2703 VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout,
2704 VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range) DECLSPEC_HIDDEN;
2705 HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
2706 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2707 void wined3d_context_vk_poll_command_buffers(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2708 void wined3d_context_vk_remove_pending_queries(struct wined3d_context_vk *context_vk,
2709 struct wined3d_query_vk *query_vk) DECLSPEC_HIDDEN;
2710 void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk,
2711 unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages,
2712 unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores) DECLSPEC_HIDDEN;
2713 void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id) DECLSPEC_HIDDEN;
2714 VkResult wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk,
2715 VkDescriptorSetLayout vk_set_layout, VkDescriptorSet *vk_descriptor_set) DECLSPEC_HIDDEN;
2717 typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2719 struct wined3d_state_entry
2721 unsigned int representative;
2722 APPLYSTATEFUNC apply;
2725 struct wined3d_state_entry_template
2727 DWORD state;
2728 struct wined3d_state_entry content;
2729 unsigned int extension;
2732 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2733 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2734 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2736 struct fragment_caps
2738 DWORD wined3d_caps;
2739 DWORD PrimitiveMiscCaps;
2740 DWORD TextureOpCaps;
2741 DWORD MaxTextureBlendStages;
2742 DWORD MaxSimultaneousTextures;
2745 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2746 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2748 struct wined3d_fragment_pipe_ops
2750 void (*fp_enable)(const struct wined3d_context *context, BOOL enable);
2751 void (*get_caps)(const struct wined3d_adapter *adapter, struct fragment_caps *caps);
2752 DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2753 void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2754 void (*free_private)(struct wined3d_device *device, struct wined3d_context *context);
2755 BOOL (*allocate_context_data)(struct wined3d_context *context);
2756 void (*free_context_data)(struct wined3d_context *context);
2757 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2758 const struct wined3d_state_entry_template *states;
2761 struct wined3d_vertex_caps
2763 BOOL xyzrhw;
2764 BOOL emulated_flatshading;
2765 BOOL ffp_generic_attributes;
2766 DWORD max_active_lights;
2767 DWORD max_vertex_blend_matrices;
2768 DWORD max_vertex_blend_matrix_index;
2769 DWORD vertex_processing_caps;
2770 DWORD fvf_caps;
2771 DWORD max_user_clip_planes;
2772 DWORD raster_caps;
2775 struct wined3d_vertex_pipe_ops
2777 void (*vp_enable)(const struct wined3d_context *context, BOOL enable);
2778 void (*vp_get_caps)(const struct wined3d_adapter *adapter, struct wined3d_vertex_caps *caps);
2779 DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2780 void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2781 void (*vp_free)(struct wined3d_device *device, struct wined3d_context *context);
2782 const struct wined3d_state_entry_template *vp_states;
2785 extern const struct wined3d_state_entry_template misc_state_template_gl[] DECLSPEC_HIDDEN;
2786 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN;
2787 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN;
2788 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN;
2789 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN;
2790 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN;
2791 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN;
2792 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN;
2794 const struct wined3d_fragment_pipe_ops *wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN;
2796 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN;
2797 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN;
2798 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN;
2800 const struct wined3d_vertex_pipe_ops *wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN;
2802 /* "Base" state table */
2803 HRESULT compile_state_table(struct wined3d_state_entry *state_table, APPLYSTATEFUNC **dev_multistate_funcs,
2804 const struct wined3d_d3d_info *d3d_info, const BOOL *supported_extensions,
2805 const struct wined3d_vertex_pipe_ops *vertex, const struct wined3d_fragment_pipe_ops *fragment,
2806 const struct wined3d_state_entry_template *misc) DECLSPEC_HIDDEN;
2808 enum wined3d_blit_op
2810 WINED3D_BLIT_OP_COLOR_BLIT,
2811 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST,
2812 WINED3D_BLIT_OP_COLOR_BLIT_CKEY,
2813 WINED3D_BLIT_OP_DEPTH_BLIT,
2814 WINED3D_BLIT_OP_RAW_BLIT,
2817 struct wined3d_blitter
2819 const struct wined3d_blitter_ops *ops;
2820 struct wined3d_blitter *next;
2823 struct wined3d_blitter_ops
2825 void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2826 void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2827 unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2828 const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2829 DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2830 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
2831 const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
2832 DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
2833 enum wined3d_texture_filter_type filter, const struct wined3d_format *resolve_format);
2836 void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
2837 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2838 struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
2839 void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
2840 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2841 void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
2842 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2843 struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next,
2844 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2845 void wined3d_raw_blitter_create(struct wined3d_blitter **next,
2846 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2847 void wined3d_vk_blitter_create(struct wined3d_blitter **next) DECLSPEC_HIDDEN;
2849 BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
2851 HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2852 DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
2853 void context_gl_resource_released(struct wined3d_device *device,
2854 GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2855 void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2856 void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2857 void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
2858 void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
2859 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2860 void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
2861 void context_state_drawbuf(struct wined3d_context *context,
2862 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2863 void context_state_fb(struct wined3d_context *context,
2864 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2866 /*****************************************************************************
2867 * Internal representation of a light
2869 struct wined3d_light_info
2871 struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2872 DWORD OriginalIndex;
2873 LONG glIndex;
2874 BOOL enabled;
2876 /* Converted parms to speed up swapping lights */
2877 struct wined3d_vec4 position;
2878 struct wined3d_vec4 direction;
2879 float exponent;
2880 float cutoff;
2882 struct list entry;
2885 /* The default light parameters */
2886 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
2888 struct wined3d_pixel_format
2890 int iPixelFormat; /* WGL pixel format */
2891 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2892 int redSize, greenSize, blueSize, alphaSize, colorSize;
2893 int depthSize, stencilSize;
2894 BOOL windowDrawable;
2895 BOOL doubleBuffer;
2896 int auxBuffers;
2897 int numSamples;
2898 int swap_method;
2901 enum wined3d_pci_vendor
2903 HW_VENDOR_SOFTWARE = 0x0000,
2904 HW_VENDOR_AMD = 0x1002,
2905 HW_VENDOR_NVIDIA = 0x10de,
2906 HW_VENDOR_VMWARE = 0x15ad,
2907 HW_VENDOR_REDHAT = 0x1af4,
2908 HW_VENDOR_INTEL = 0x8086,
2911 enum wined3d_pci_device
2913 CARD_WINE = 0x0000,
2915 CARD_AMD_RAGE_128PRO = 0x5246,
2916 CARD_AMD_RADEON_7200 = 0x5144,
2917 CARD_AMD_RADEON_8500 = 0x514c,
2918 CARD_AMD_RADEON_9500 = 0x4144,
2919 CARD_AMD_RADEON_XPRESS_200M = 0x5955,
2920 CARD_AMD_RADEON_X700 = 0x5e4c,
2921 CARD_AMD_RADEON_X1600 = 0x71c2,
2922 CARD_AMD_RADEON_HD2350 = 0x94c7,
2923 CARD_AMD_RADEON_HD2600 = 0x9581,
2924 CARD_AMD_RADEON_HD2900 = 0x9400,
2925 CARD_AMD_RADEON_HD3200 = 0x9620,
2926 CARD_AMD_RADEON_HD3850 = 0x9515,
2927 CARD_AMD_RADEON_HD4200M = 0x9712,
2928 CARD_AMD_RADEON_HD4350 = 0x954f,
2929 CARD_AMD_RADEON_HD4600 = 0x9495,
2930 CARD_AMD_RADEON_HD4700 = 0x944e,
2931 CARD_AMD_RADEON_HD4800 = 0x944c,
2932 CARD_AMD_RADEON_HD5400 = 0x68f9,
2933 CARD_AMD_RADEON_HD5600 = 0x68d8,
2934 CARD_AMD_RADEON_HD5700 = 0x68be,
2935 CARD_AMD_RADEON_HD5800 = 0x6898,
2936 CARD_AMD_RADEON_HD5900 = 0x689c,
2937 CARD_AMD_RADEON_HD6300 = 0x9803,
2938 CARD_AMD_RADEON_HD6400 = 0x6770,
2939 CARD_AMD_RADEON_HD6490M = 0x6760,
2940 CARD_AMD_RADEON_HD6410D = 0x9644,
2941 CARD_AMD_RADEON_HD6480G = 0x9648,
2942 CARD_AMD_RADEON_HD6550D = 0x9640,
2943 CARD_AMD_RADEON_HD6600 = 0x6758,
2944 CARD_AMD_RADEON_HD6600M = 0x6741,
2945 CARD_AMD_RADEON_HD6700 = 0x68ba,
2946 CARD_AMD_RADEON_HD6800 = 0x6739,
2947 CARD_AMD_RADEON_HD6900 = 0x6719,
2948 CARD_AMD_RADEON_HD7660D = 0x9901,
2949 CARD_AMD_RADEON_HD7700 = 0x683d,
2950 CARD_AMD_RADEON_HD7800 = 0x6819,
2951 CARD_AMD_RADEON_HD7870 = 0x6818,
2952 CARD_AMD_RADEON_HD7900 = 0x679a,
2953 CARD_AMD_RADEON_HD8600M = 0x6660,
2954 CARD_AMD_RADEON_HD8670 = 0x6610,
2955 CARD_AMD_RADEON_HD8770 = 0x665c,
2956 CARD_AMD_RADEON_R3 = 0x9830,
2957 CARD_AMD_RADEON_R7 = 0x130f,
2958 CARD_AMD_RADEON_R9_285 = 0x6939,
2959 CARD_AMD_RADEON_R9_290 = 0x67b1,
2960 CARD_AMD_RADEON_R9_290X = 0x67b0,
2961 CARD_AMD_RADEON_R9_FURY = 0x7300,
2962 CARD_AMD_RADEON_R9_M370X = 0x6821,
2963 CARD_AMD_RADEON_R9_M380 = 0x6647,
2964 CARD_AMD_RADEON_R9_M395X = 0x6920,
2965 CARD_AMD_RADEON_RX_460 = 0x67ef,
2966 CARD_AMD_RADEON_RX_480 = 0x67df,
2967 CARD_AMD_RADEON_RX_VEGA_10 = 0x687f,
2968 CARD_AMD_RADEON_RX_VEGA_12 = 0x69af,
2969 CARD_AMD_RADEON_RAVEN = 0x15dd,
2970 CARD_AMD_RADEON_RX_VEGA_20 = 0x66af,
2971 CARD_AMD_RADEON_RX_NAVI_10 = 0x731f,
2972 CARD_AMD_RADEON_RX_NAVI_14 = 0x7340,
2973 CARD_AMD_RADEON_RX_NAVI_21 = 0x73bf,
2974 CARD_AMD_VANGOGH = 0x163f,
2976 CARD_NVIDIA_RIVA_128 = 0x0018,
2977 CARD_NVIDIA_RIVA_TNT = 0x0020,
2978 CARD_NVIDIA_RIVA_TNT2 = 0x0028,
2979 CARD_NVIDIA_GEFORCE = 0x0100,
2980 CARD_NVIDIA_GEFORCE2_MX = 0x0110,
2981 CARD_NVIDIA_GEFORCE2 = 0x0150,
2982 CARD_NVIDIA_GEFORCE3 = 0x0200,
2983 CARD_NVIDIA_GEFORCE4_MX = 0x0170,
2984 CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
2985 CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
2986 CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
2987 CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
2988 CARD_NVIDIA_GEFORCE_6200 = 0x014f,
2989 CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
2990 CARD_NVIDIA_GEFORCE_6800 = 0x0041,
2991 CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2992 CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
2993 CARD_NVIDIA_GEFORCE_7600 = 0x0391,
2994 CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
2995 CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2996 CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
2997 CARD_NVIDIA_GEFORCE_8400GS = 0x0404,
2998 CARD_NVIDIA_GEFORCE_8500GT = 0x0421,
2999 CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
3000 CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
3001 CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
3002 CARD_NVIDIA_GEFORCE_8800GTX = 0x0191,
3003 CARD_NVIDIA_GEFORCE_9200 = 0x086d,
3004 CARD_NVIDIA_GEFORCE_9300 = 0x086c,
3005 CARD_NVIDIA_GEFORCE_9400M = 0x0863,
3006 CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
3007 CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
3008 CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
3009 CARD_NVIDIA_GEFORCE_9700MGT = 0x064a,
3010 CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
3011 CARD_NVIDIA_GEFORCE_210 = 0x0a23,
3012 CARD_NVIDIA_GEFORCE_GT220 = 0x0a20,
3013 CARD_NVIDIA_GEFORCE_GT240 = 0x0ca3,
3014 CARD_NVIDIA_GEFORCE_GTS250 = 0x0615,
3015 CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
3016 CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
3017 CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
3018 CARD_NVIDIA_GEFORCE_315M = 0x0a7a,
3019 CARD_NVIDIA_GEFORCE_320M = 0x08a3,
3020 CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
3021 CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
3022 CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
3023 CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
3024 CARD_NVIDIA_GEFORCE_410M = 0x1055,
3025 CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
3026 CARD_NVIDIA_GEFORCE_GT425M = 0x0df0,
3027 CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
3028 CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
3029 CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
3030 CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
3031 CARD_NVIDIA_GEFORCE_GTX460M = 0x0dd1,
3032 CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
3033 CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
3034 CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
3035 CARD_NVIDIA_GEFORCE_GT520 = 0x1040,
3036 CARD_NVIDIA_GEFORCE_GT525M = 0x0dec,
3037 CARD_NVIDIA_GEFORCE_GT540M = 0x0df4,
3038 CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
3039 CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
3040 CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
3041 CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
3042 CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
3043 CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
3044 CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
3045 CARD_NVIDIA_GEFORCE_GT610 = 0x104a,
3046 CARD_NVIDIA_GEFORCE_GT630 = 0x0f00,
3047 CARD_NVIDIA_GEFORCE_GT630M = 0x0de9,
3048 CARD_NVIDIA_GEFORCE_GT640 = 0x0fc1,
3049 CARD_NVIDIA_GEFORCE_GT640M = 0x0fd2,
3050 CARD_NVIDIA_GEFORCE_GT650M = 0x0fd1,
3051 CARD_NVIDIA_GEFORCE_GTX650 = 0x0fc6,
3052 CARD_NVIDIA_GEFORCE_GTX650TI = 0x11c6,
3053 CARD_NVIDIA_GEFORCE_GTX660 = 0x11c0,
3054 CARD_NVIDIA_GEFORCE_GTX660M = 0x0fd4,
3055 CARD_NVIDIA_GEFORCE_GTX660TI = 0x1183,
3056 CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
3057 CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
3058 CARD_NVIDIA_GEFORCE_GTX675MX_1 = 0x11a7,
3059 CARD_NVIDIA_GEFORCE_GTX675MX_2 = 0x11a2,
3060 CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
3061 CARD_NVIDIA_GEFORCE_GTX690 = 0x1188,
3062 CARD_NVIDIA_GEFORCE_GT720 = 0x128b,
3063 CARD_NVIDIA_GEFORCE_GT730 = 0x1287,
3064 CARD_NVIDIA_GEFORCE_GT730M = 0x0fe1,
3065 CARD_NVIDIA_GEFORCE_GT740M = 0x1292,
3066 CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
3067 CARD_NVIDIA_GEFORCE_GT755M = 0x0fcd,
3068 CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
3069 CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
3070 CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
3071 CARD_NVIDIA_GEFORCE_GTX760TI = 0x1193,
3072 CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2,
3073 CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0,
3074 CARD_NVIDIA_GEFORCE_GTX770 = 0x1184,
3075 CARD_NVIDIA_GEFORCE_GTX775M = 0x119d,
3076 CARD_NVIDIA_GEFORCE_GTX780 = 0x1004,
3077 CARD_NVIDIA_GEFORCE_GTX780M = 0x119e,
3078 CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a,
3079 CARD_NVIDIA_GEFORCE_GTXTITAN = 0x1005,
3080 CARD_NVIDIA_GEFORCE_GTXTITANB = 0x100c,
3081 CARD_NVIDIA_GEFORCE_GTXTITANX = 0x17c2,
3082 CARD_NVIDIA_GEFORCE_GTXTITANZ = 0x1001,
3083 CARD_NVIDIA_GEFORCE_820M = 0x0fed,
3084 CARD_NVIDIA_GEFORCE_830M = 0x1340,
3085 CARD_NVIDIA_GEFORCE_840M = 0x1341,
3086 CARD_NVIDIA_GEFORCE_845M = 0x1344,
3087 CARD_NVIDIA_GEFORCE_GTX850M = 0x1391,
3088 CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
3089 CARD_NVIDIA_GEFORCE_GTX870M = 0x1199,
3090 CARD_NVIDIA_GEFORCE_GTX880M = 0x1198,
3091 CARD_NVIDIA_GEFORCE_940M = 0x1347,
3092 CARD_NVIDIA_GEFORCE_GTX950 = 0x1402,
3093 CARD_NVIDIA_GEFORCE_GTX950M = 0x139a,
3094 CARD_NVIDIA_GEFORCE_GTX960 = 0x1401,
3095 CARD_NVIDIA_GEFORCE_GTX960M = 0x139b,
3096 CARD_NVIDIA_GEFORCE_GTX970 = 0x13c2,
3097 CARD_NVIDIA_GEFORCE_GTX970M = 0x13d8,
3098 CARD_NVIDIA_GEFORCE_GTX980 = 0x13c0,
3099 CARD_NVIDIA_GEFORCE_GTX980TI = 0x17c8,
3100 CARD_NVIDIA_GEFORCE_GT1030 = 0x1d01,
3101 CARD_NVIDIA_GEFORCE_GTX1050 = 0x1c81,
3102 CARD_NVIDIA_GEFORCE_GTX1050TI = 0x1c82,
3103 CARD_NVIDIA_GEFORCE_GTX1060_3GB = 0x1c02,
3104 CARD_NVIDIA_GEFORCE_GTX1060 = 0x1c03,
3105 CARD_NVIDIA_GEFORCE_GTX1060M = 0x1c20,
3106 CARD_NVIDIA_GEFORCE_GTX1070 = 0x1b81,
3107 CARD_NVIDIA_GEFORCE_GTX1080 = 0x1b80,
3108 CARD_NVIDIA_GEFORCE_GTX1080M = 0x1be0,
3109 CARD_NVIDIA_GEFORCE_GTX1080TI = 0x1b06,
3110 CARD_NVIDIA_TITANX_PASCAL = 0x1b00,
3111 CARD_NVIDIA_TITANV = 0x1d81,
3112 CARD_NVIDIA_GEFORCE_GTX1650SUPER= 0x2187,
3113 CARD_NVIDIA_GEFORCE_GTX1660SUPER= 0x21c4,
3114 CARD_NVIDIA_GEFORCE_GTX1660TI = 0x2182,
3115 CARD_NVIDIA_GEFORCE_RTX2060 = 0x1f08,
3116 CARD_NVIDIA_GEFORCE_RTX2070 = 0x1f07,
3117 CARD_NVIDIA_GEFORCE_RTX2080 = 0x1e87,
3118 CARD_NVIDIA_GEFORCE_RTX2080TI = 0x1e07,
3120 CARD_REDHAT_VIRGL = 0x1010,
3122 CARD_VMWARE_SVGA3D = 0x0405,
3124 CARD_INTEL_830M = 0x3577,
3125 CARD_INTEL_855GM = 0x3582,
3126 CARD_INTEL_845G = 0x2562,
3127 CARD_INTEL_865G = 0x2572,
3128 CARD_INTEL_915G = 0x2582,
3129 CARD_INTEL_E7221G = 0x258a,
3130 CARD_INTEL_915GM = 0x2592,
3131 CARD_INTEL_945G = 0x2772,
3132 CARD_INTEL_945GM = 0x27a2,
3133 CARD_INTEL_945GME = 0x27ae,
3134 CARD_INTEL_Q35 = 0x29b2,
3135 CARD_INTEL_G33 = 0x29c2,
3136 CARD_INTEL_Q33 = 0x29d2,
3137 CARD_INTEL_PNVG = 0xa001,
3138 CARD_INTEL_PNVM = 0xa011,
3139 CARD_INTEL_965Q = 0x2992,
3140 CARD_INTEL_965G = 0x2982,
3141 CARD_INTEL_946GZ = 0x2972,
3142 CARD_INTEL_965GM = 0x2a02,
3143 CARD_INTEL_965GME = 0x2a12,
3144 CARD_INTEL_GM45 = 0x2a42,
3145 CARD_INTEL_IGD = 0x2e02,
3146 CARD_INTEL_Q45 = 0x2e12,
3147 CARD_INTEL_G45 = 0x2e22,
3148 CARD_INTEL_G41 = 0x2e32,
3149 CARD_INTEL_B43 = 0x2e92,
3150 CARD_INTEL_ILKD = 0x0042,
3151 CARD_INTEL_ILKM = 0x0046,
3152 CARD_INTEL_SNBD = 0x0122,
3153 CARD_INTEL_SNBM = 0x0126,
3154 CARD_INTEL_SNBS = 0x010a,
3155 CARD_INTEL_IVBD = 0x0162,
3156 CARD_INTEL_IVBM = 0x0166,
3157 CARD_INTEL_IVBS = 0x015a,
3158 CARD_INTEL_HWD = 0x0412,
3159 CARD_INTEL_HWM = 0x0416,
3160 CARD_INTEL_HD5000_1 = 0x0a26,
3161 CARD_INTEL_HD5000_2 = 0x0422,
3162 CARD_INTEL_I5100_1 = 0x0a22,
3163 CARD_INTEL_I5100_2 = 0x0a2a,
3164 CARD_INTEL_I5100_3 = 0x0a2b,
3165 CARD_INTEL_I5100_4 = 0x0a2e,
3166 CARD_INTEL_IP5200_1 = 0x0d22,
3167 CARD_INTEL_IP5200_2 = 0x0d26,
3168 CARD_INTEL_IP5200_3 = 0x0d2a,
3169 CARD_INTEL_IP5200_4 = 0x0d2b,
3170 CARD_INTEL_IP5200_5 = 0x0d2e,
3171 CARD_INTEL_IP5200_6 = 0x0c22,
3172 CARD_INTEL_HD5300 = 0x161e,
3173 CARD_INTEL_HD5500 = 0x1616,
3174 CARD_INTEL_HD5600 = 0x1612,
3175 CARD_INTEL_HD6000 = 0x1626,
3176 CARD_INTEL_I6100 = 0x162b,
3177 CARD_INTEL_IP6200 = 0x1622,
3178 CARD_INTEL_IPP6300 = 0x162a,
3179 CARD_INTEL_HD510_1 = 0x1902,
3180 CARD_INTEL_HD510_2 = 0x1906,
3181 CARD_INTEL_HD510_3 = 0x190b,
3182 CARD_INTEL_HD515 = 0x191e,
3183 CARD_INTEL_HD520_1 = 0x1916,
3184 CARD_INTEL_HD520_2 = 0x1921,
3185 CARD_INTEL_HD530_1 = 0x1912,
3186 CARD_INTEL_HD530_2 = 0x191b,
3187 CARD_INTEL_HDP530 = 0x191d,
3188 CARD_INTEL_I540 = 0x1926,
3189 CARD_INTEL_I550 = 0x1927,
3190 CARD_INTEL_I555 = 0x192b,
3191 CARD_INTEL_IP555 = 0x192d,
3192 CARD_INTEL_IP580_1 = 0x1932,
3193 CARD_INTEL_IP580_2 = 0x193b,
3194 CARD_INTEL_IPP580_1 = 0x193a,
3195 CARD_INTEL_IPP580_2 = 0x193d,
3196 CARD_INTEL_UHD617 = 0x87c0,
3197 CARD_INTEL_UHD620 = 0x3ea0,
3198 CARD_INTEL_HD615 = 0x591e,
3199 CARD_INTEL_HD620 = 0x5916,
3200 CARD_INTEL_HD630_1 = 0x5912,
3201 CARD_INTEL_HD630_2 = 0x591b,
3202 CARD_INTEL_UHD630 = 0x3e9b,
3205 struct wined3d_fbo_ops
3207 GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
3208 void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
3209 void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
3210 void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
3211 void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
3212 GLsizei width, GLsizei height);
3213 void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
3214 GLenum internalformat, GLsizei width, GLsizei height);
3215 void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
3216 GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
3217 void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
3218 void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
3219 void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
3220 GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
3221 void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
3222 GLuint texture, GLint level);
3223 void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
3224 GLenum textarget, GLuint texture, GLint level);
3225 void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
3226 GLenum textarget, GLuint texture, GLint level);
3227 void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
3228 GLenum textarget, GLuint texture, GLint level, GLint layer);
3229 void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
3230 GLuint texture, GLint level, GLint layer);
3231 void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
3232 GLenum renderbuffertarget, GLuint renderbuffer);
3233 void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
3234 GLenum pname, GLint *params);
3235 void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
3236 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
3237 void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
3240 struct wined3d_gl_limits
3242 UINT buffers;
3243 UINT lights;
3244 UINT textures;
3245 UINT texture_coords;
3246 unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
3247 unsigned int samplers[WINED3D_SHADER_TYPE_COUNT];
3248 unsigned int graphics_samplers;
3249 unsigned int combined_samplers;
3250 UINT general_combiners;
3251 UINT user_clip_distances;
3252 unsigned int texture_size;
3253 UINT texture3d_size;
3254 UINT anisotropy;
3255 float shininess;
3256 UINT samples;
3257 UINT vertex_attribs;
3259 unsigned int texture_buffer_offset_alignment;
3261 unsigned int framebuffer_width;
3262 unsigned int framebuffer_height;
3263 unsigned int viewport_subpixel_bits;
3265 UINT glsl_varyings;
3266 UINT glsl_vs_float_constants;
3267 UINT glsl_ps_float_constants;
3269 UINT arb_vs_float_constants;
3270 UINT arb_vs_native_constants;
3271 UINT arb_vs_instructions;
3272 UINT arb_vs_temps;
3273 UINT arb_ps_float_constants;
3274 UINT arb_ps_local_constants;
3275 UINT arb_ps_native_constants;
3276 UINT arb_ps_instructions;
3277 UINT arb_ps_temps;
3280 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
3281 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
3282 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits,
3283 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
3285 struct wined3d_gl_info
3287 DWORD selected_gl_version;
3288 DWORD glsl_version;
3289 struct wined3d_gl_limits limits;
3290 DWORD reserved_glsl_constants, reserved_arb_constants;
3291 DWORD quirks;
3292 BOOL supported[WINED3D_GL_EXT_COUNT];
3293 GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
3294 float filling_convention_offset;
3296 HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
3297 struct opengl_funcs gl_ops;
3298 struct wined3d_fbo_ops fbo_ops;
3300 void (WINE_GLAPI *p_glDisableWINE)(GLenum cap);
3301 void (WINE_GLAPI *p_glEnableWINE)(GLenum cap);
3304 /* The driver names reflect the lowest GPU supported
3305 * by a certain driver, so DRIVER_AMD_R300 supports
3306 * R3xx, R4xx and R5xx GPUs. */
3307 enum wined3d_display_driver
3309 DRIVER_AMD_RAGE_128PRO,
3310 DRIVER_AMD_R100,
3311 DRIVER_AMD_R300,
3312 DRIVER_AMD_R600,
3313 DRIVER_AMD_RX,
3314 DRIVER_INTEL_GMA800,
3315 DRIVER_INTEL_GMA900,
3316 DRIVER_INTEL_GMA950,
3317 DRIVER_INTEL_GMA3000,
3318 DRIVER_INTEL_HD4000,
3319 DRIVER_NVIDIA_TNT,
3320 DRIVER_NVIDIA_GEFORCE2MX,
3321 DRIVER_NVIDIA_GEFORCEFX,
3322 DRIVER_NVIDIA_GEFORCE6,
3323 DRIVER_NVIDIA_GEFORCE8,
3324 DRIVER_NVIDIA_FERMI,
3325 DRIVER_NVIDIA_KEPLER,
3326 DRIVER_REDHAT_VIRGL,
3327 DRIVER_VMWARE,
3328 DRIVER_WINE,
3329 DRIVER_UNKNOWN,
3332 struct wined3d_gpu_description
3334 enum wined3d_pci_vendor vendor;
3335 enum wined3d_pci_device device;
3336 const char *description;
3337 enum wined3d_display_driver driver;
3338 unsigned int vidmem;
3341 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
3342 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
3343 const struct wined3d_gpu_description *wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor,
3344 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
3345 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
3346 enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
3348 /* 512 in Direct3D 8/9, 128 in DXGI. */
3349 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
3351 struct wined3d_driver_info
3353 enum wined3d_pci_vendor vendor;
3354 enum wined3d_pci_device device;
3355 const char *name;
3356 char description[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH];
3357 UINT64 vram_bytes;
3358 UINT64 sysmem_bytes;
3359 DWORD version_high;
3360 DWORD version_low;
3363 bool wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
3364 const struct wined3d_gpu_description *gpu_description, enum wined3d_feature_level feature_level,
3365 UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
3367 #define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
3368 #define UPLOAD_BO_RENAME_ON_UNMAP 0x2
3370 struct upload_bo
3372 struct wined3d_const_bo_address addr;
3373 uint32_t flags;
3376 struct wined3d_adapter_ops
3378 void (*adapter_destroy)(struct wined3d_adapter *adapter);
3379 HRESULT (*adapter_create_device)(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
3380 enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3381 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3382 struct wined3d_device_parent *device_parent, struct wined3d_device **device);
3383 void (*adapter_destroy_device)(struct wined3d_device *device);
3384 struct wined3d_context *(*adapter_acquire_context)(struct wined3d_device *device,
3385 struct wined3d_texture *texture, unsigned int sub_resource_idx);
3386 void (*adapter_release_context)(struct wined3d_context *context);
3387 void (*adapter_get_wined3d_caps)(const struct wined3d_adapter *adapter, struct wined3d_caps *caps);
3388 BOOL (*adapter_check_format)(const struct wined3d_adapter *adapter,
3389 const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
3390 const struct wined3d_format *ds_format);
3391 HRESULT (*adapter_init_3d)(struct wined3d_device *device);
3392 void (*adapter_uninit_3d)(struct wined3d_device *device);
3393 void *(*adapter_map_bo_address)(struct wined3d_context *context,
3394 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags);
3395 void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data,
3396 unsigned int range_count, const struct wined3d_range *ranges);
3397 void (*adapter_copy_bo_address)(struct wined3d_context *context,
3398 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size);
3399 void (*adapter_flush_bo_address)(struct wined3d_context *context,
3400 const struct wined3d_const_bo_address *data, size_t size);
3401 bool (*adapter_alloc_bo)(struct wined3d_device *device, struct wined3d_resource *resource,
3402 unsigned int sub_resource_idx, struct wined3d_bo_address *addr);
3403 void (*adapter_destroy_bo)(struct wined3d_context *context, struct wined3d_bo *bo);
3404 HRESULT (*adapter_create_swapchain)(struct wined3d_device *device,
3405 struct wined3d_swapchain_desc *desc,
3406 struct wined3d_swapchain_state_parent *state_parent, void *parent,
3407 const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
3408 void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain);
3409 HRESULT (*adapter_create_buffer)(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
3410 const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
3411 struct wined3d_buffer **buffer);
3412 void (*adapter_destroy_buffer)(struct wined3d_buffer *buffer);
3413 HRESULT (*adapter_create_texture)(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
3414 unsigned int layer_count, unsigned int level_count, uint32_t flags, void *parent,
3415 const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
3416 void (*adapter_destroy_texture)(struct wined3d_texture *texture);
3417 HRESULT (*adapter_create_rendertarget_view)(const struct wined3d_view_desc *desc,
3418 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3419 struct wined3d_rendertarget_view **view);
3420 void (*adapter_destroy_rendertarget_view)(struct wined3d_rendertarget_view *view);
3421 HRESULT (*adapter_create_shader_resource_view)(const struct wined3d_view_desc *desc,
3422 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3423 struct wined3d_shader_resource_view **view);
3424 void (*adapter_destroy_shader_resource_view)(struct wined3d_shader_resource_view *view);
3425 HRESULT (*adapter_create_unordered_access_view)(const struct wined3d_view_desc *desc,
3426 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3427 struct wined3d_unordered_access_view **view);
3428 void (*adapter_destroy_unordered_access_view)(struct wined3d_unordered_access_view *view);
3429 HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3430 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
3431 void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
3432 HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
3433 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
3434 void (*adapter_destroy_query)(struct wined3d_query *query);
3435 void (*adapter_flush_context)(struct wined3d_context *context);
3436 void (*adapter_draw_primitive)(struct wined3d_device *device, const struct wined3d_state *state,
3437 const struct wined3d_draw_parameters *parameters);
3438 void (*adapter_dispatch_compute)(struct wined3d_device *device, const struct wined3d_state *state,
3439 const struct wined3d_dispatch_parameters *parameters);
3440 void (*adapter_clear_uav)(struct wined3d_context *context,
3441 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value, bool fp);
3442 void (*adapter_generate_mipmap)(struct wined3d_context *context, struct wined3d_shader_resource_view *view);
3445 struct wined3d_output
3447 unsigned int ordinal;
3448 WCHAR device_name[CCHDEVICENAME];
3449 struct wined3d_adapter *adapter;
3450 enum wined3d_format_id screen_format;
3452 D3DKMT_HANDLE kmt_adapter;
3453 D3DKMT_HANDLE kmt_device;
3454 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id;
3457 HRESULT wined3d_output_get_gamma_ramp(struct wined3d_output *output, struct wined3d_gamma_ramp *ramp) DECLSPEC_HIDDEN;
3459 /* The adapter structure */
3460 struct wined3d_adapter
3462 unsigned int ordinal;
3464 struct wined3d_gl_info gl_info;
3465 struct wined3d_d3d_info d3d_info;
3466 struct wined3d_driver_info driver_info;
3467 struct wined3d_output *outputs;
3468 unsigned int output_count;
3469 UINT64 vram_bytes_used;
3470 GUID driver_uuid;
3471 GUID device_uuid;
3472 LUID luid;
3474 void *formats;
3475 size_t format_size;
3477 const struct wined3d_vertex_pipe_ops *vertex_pipe;
3478 const struct wined3d_fragment_pipe_ops *fragment_pipe;
3479 const struct wined3d_state_entry_template *misc_state_template;
3480 const struct wined3d_shader_backend_ops *shader_backend;
3481 const struct wined3d_adapter_ops *adapter_ops;
3484 BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal, const LUID *luid,
3485 const struct wined3d_adapter_ops *adapter_ops) DECLSPEC_HIDDEN;
3486 void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
3487 BOOL wined3d_get_primary_adapter_luid(LUID *luid) DECLSPEC_HIDDEN;
3489 struct wined3d_adapter_gl
3491 struct wined3d_adapter a;
3493 struct wined3d_pixel_format *pixel_formats;
3494 unsigned int pixel_format_count;
3497 static inline struct wined3d_adapter_gl *wined3d_adapter_gl(struct wined3d_adapter *adapter)
3499 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
3502 static inline const struct wined3d_adapter_gl *wined3d_adapter_gl_const(const struct wined3d_adapter *adapter)
3504 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
3507 struct wined3d_adapter *wined3d_adapter_gl_create(unsigned int ordinal,
3508 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
3510 struct wined3d_adapter_vk
3512 struct wined3d_adapter a;
3514 struct wined3d_vk_info vk_info;
3515 unsigned int device_extension_count;
3516 const char **device_extensions;
3517 VkPhysicalDevice physical_device;
3519 VkPhysicalDeviceLimits device_limits;
3520 VkPhysicalDeviceMemoryProperties memory_properties;
3523 static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter)
3525 return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a);
3528 struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
3529 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
3530 unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
3531 uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
3532 void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst,
3533 const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
3535 struct wined3d_caps_gl_ctx
3537 HDC dc;
3538 HWND wnd;
3539 HGLRC gl_ctx;
3540 HDC restore_dc;
3541 HGLRC restore_gl_ctx;
3543 const struct wined3d_gl_info *gl_info;
3544 GLuint test_vbo;
3545 GLuint test_program_id;
3547 const struct wined3d_gpu_description *gpu_description;
3548 UINT64 vram_bytes;
3551 BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
3552 struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3553 BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
3554 BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk,
3555 const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN;
3556 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
3558 BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3559 bool wined3d_caps_gl_ctx_test_filling_convention(struct wined3d_caps_gl_ctx *ctx, float offset) DECLSPEC_HIDDEN;
3561 void install_gl_compat_wrapper(struct wined3d_gl_info *gl_info, enum wined3d_gl_extension ext) DECLSPEC_HIDDEN;
3563 enum wined3d_projection_type
3565 WINED3D_PROJECTION_NONE = 0,
3566 WINED3D_PROJECTION_COUNT3 = 1,
3567 WINED3D_PROJECTION_COUNT4 = 2
3570 /*****************************************************************************
3571 * Fixed function pipeline replacements
3573 #define ARG_UNUSED 0xff
3574 struct texture_stage_op
3576 unsigned cop : 8;
3577 unsigned carg1 : 8;
3578 unsigned carg2 : 8;
3579 unsigned carg0 : 8;
3581 unsigned aop : 8;
3582 unsigned aarg1 : 8;
3583 unsigned aarg2 : 8;
3584 unsigned aarg0 : 8;
3586 struct color_fixup_desc color_fixup;
3587 unsigned tex_type : 3;
3588 unsigned tmp_dst : 1;
3589 unsigned projected : 2;
3590 unsigned padding : 10;
3593 struct ffp_frag_settings
3595 struct texture_stage_op op[WINED3D_MAX_TEXTURES];
3596 enum wined3d_ffp_ps_fog_mode fog;
3597 unsigned char sRGB_write;
3598 unsigned char emul_clipplanes;
3599 unsigned char texcoords_initialized;
3600 unsigned char color_key_enabled : 1;
3601 unsigned char pointsprite : 1;
3602 unsigned char flatshading : 1;
3603 unsigned char alpha_test_func : 3;
3604 unsigned char padding : 2;
3607 struct ffp_frag_desc
3609 struct wine_rb_entry entry;
3610 struct ffp_frag_settings settings;
3613 int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3614 int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3616 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
3618 void wined3d_ffp_get_fs_settings(const struct wined3d_context *context, const struct wined3d_state *state,
3619 struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
3620 const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
3621 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
3622 void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
3623 void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
3625 enum wined3d_ffp_vs_fog_mode
3627 WINED3D_FFP_VS_FOG_OFF = 0,
3628 WINED3D_FFP_VS_FOG_FOGCOORD = 1,
3629 WINED3D_FFP_VS_FOG_DEPTH = 2,
3630 WINED3D_FFP_VS_FOG_RANGE = 3,
3633 #define WINED3D_FFP_TCI_SHIFT 16
3634 #define WINED3D_FFP_TCI_MASK 0xffu
3636 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3637 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3639 struct wined3d_ffp_vs_settings
3641 DWORD point_light_count : 4;
3642 DWORD spot_light_count : 4;
3643 DWORD directional_light_count : 4;
3644 DWORD parallel_point_light_count : 4;
3645 DWORD diffuse_source : 2;
3646 DWORD emissive_source : 2;
3647 DWORD ambient_source : 2;
3648 DWORD specular_source : 2;
3649 DWORD transformed : 1;
3650 DWORD vertexblends : 2;
3651 DWORD clipping : 1;
3652 DWORD normal : 1;
3653 DWORD normalize : 1;
3654 DWORD lighting : 1;
3655 DWORD localviewer : 1;
3657 DWORD point_size : 1;
3658 DWORD per_vertex_point_size : 1;
3659 DWORD fog_mode : 2;
3660 DWORD texcoords : 8; /* WINED3D_MAX_TEXTURES */
3661 DWORD ortho_fog : 1;
3662 DWORD flatshading : 1;
3663 DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
3664 DWORD padding : 2;
3666 DWORD texgen[WINED3D_MAX_TEXTURES];
3669 struct wined3d_ffp_vs_desc
3671 struct wine_rb_entry entry;
3672 struct wined3d_ffp_vs_settings settings;
3675 void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
3676 const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) DECLSPEC_HIDDEN;
3678 struct wined3d
3680 LONG ref;
3681 unsigned int flags;
3682 unsigned int adapter_count;
3683 struct wined3d_adapter *adapters[1];
3686 BOOL wined3d_filter_messages(HWND window, BOOL filter) DECLSPEC_HIDDEN;
3687 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN;
3688 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
3690 BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size) DECLSPEC_HIDDEN;
3692 struct wined3d_blend_state
3694 LONG refcount;
3695 struct wined3d_blend_state_desc desc;
3696 BOOL dual_source;
3698 void *parent;
3699 const struct wined3d_parent_ops *parent_ops;
3701 struct wined3d_device *device;
3702 struct wine_rb_entry entry;
3705 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state *state,
3706 unsigned int index)
3708 if (!state)
3709 return 0xf;
3710 if (!state->desc.independent)
3711 index = 0;
3712 return state->desc.rt[index].writemask;
3715 struct wined3d_depth_stencil_state
3717 LONG refcount;
3718 struct wined3d_depth_stencil_state_desc desc;
3720 void *parent;
3721 const struct wined3d_parent_ops *parent_ops;
3723 struct wined3d_device *device;
3724 struct wine_rb_entry entry;
3727 struct wined3d_rasterizer_state
3729 LONG refcount;
3730 struct wined3d_rasterizer_state_desc desc;
3732 void *parent;
3733 const struct wined3d_parent_ops *parent_ops;
3735 struct wined3d_device *device;
3736 struct wine_rb_entry entry;
3739 #define LIGHTMAP_SIZE 43
3740 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
3742 struct wined3d_light_state
3744 /* Light hashmap. Collisions are handled using linked lists. */
3745 struct list light_map[LIGHTMAP_SIZE];
3746 const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS];
3749 #define WINED3D_STATE_NO_REF 0x00000001
3750 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3752 struct wined3d_state
3754 enum wined3d_feature_level feature_level;
3755 uint32_t flags;
3756 struct wined3d_fb_state fb;
3758 struct wined3d_vertex_declaration *vertex_declaration;
3759 struct wined3d_stream_output stream_output[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
3760 struct wined3d_stream_state streams[WINED3D_MAX_STREAMS];
3761 struct wined3d_buffer *index_buffer;
3762 enum wined3d_format_id index_format;
3763 unsigned int index_offset;
3764 int base_vertex_index;
3765 int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3766 enum wined3d_primitive_type primitive_type;
3767 unsigned int patch_vertex_count;
3768 struct wined3d_query *predicate;
3769 BOOL predicate_value;
3771 struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
3772 struct wined3d_constant_buffer_state cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
3773 struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
3774 struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
3775 struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
3777 struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3778 struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
3779 BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
3781 struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3782 struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
3783 BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
3785 struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
3786 DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
3787 DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
3789 struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3790 struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES];
3791 struct wined3d_material material;
3792 struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS];
3793 unsigned int viewport_count;
3794 RECT scissor_rects[WINED3D_MAX_VIEWPORTS];
3795 unsigned int scissor_rect_count;
3797 struct wined3d_light_state light_state;
3799 DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
3800 struct wined3d_blend_state *blend_state;
3801 struct wined3d_color blend_factor;
3802 unsigned int sample_mask;
3803 struct wined3d_depth_stencil_state *depth_stencil_state;
3804 unsigned int stencil_ref;
3805 struct wined3d_rasterizer_state *rasterizer_state;
3808 void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
3809 void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info,
3810 uint32_t flags, enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
3811 void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
3813 static inline void wined3d_state_reset(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info)
3815 enum wined3d_feature_level feature_level = state->feature_level;
3816 uint32_t flags = state->flags;
3818 memset(state, 0, sizeof(*state));
3819 state_init(state, d3d_info, flags, feature_level);
3822 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state)
3824 if (!state->depth_stencil_state)
3825 return true;
3826 return state->depth_stencil_state->desc.depth || state->depth_stencil_state->desc.depth_write
3827 || state->depth_stencil_state->desc.stencil;
3830 struct wined3d_dummy_textures
3832 GLuint tex_1d;
3833 GLuint tex_2d;
3834 GLuint tex_rect;
3835 GLuint tex_3d;
3836 GLuint tex_cube;
3837 GLuint tex_cube_array;
3838 GLuint tex_1d_array;
3839 GLuint tex_2d_array;
3840 GLuint tex_buffer;
3841 GLuint tex_2d_ms;
3842 GLuint tex_2d_ms_array;
3845 #define WINED3D_UNMAPPED_STAGE ~0u
3847 /* Multithreaded flag. Removed from the public header to signal that
3848 * wined3d_device_create() ignores it. */
3849 #define WINED3DCREATE_MULTITHREADED 0x00000004
3851 struct wined3d_so_desc_entry
3853 struct wine_rb_entry entry;
3854 struct wined3d_stream_output_desc desc;
3855 struct wined3d_stream_output_element elements[1];
3858 struct wined3d_device
3860 LONG ref;
3862 /* WineD3D Information */
3863 struct wined3d_device_parent *device_parent;
3864 struct wined3d *wined3d;
3865 struct wined3d_adapter *adapter;
3867 const struct wined3d_shader_backend_ops *shader_backend;
3868 void *shader_priv;
3869 void *fragment_priv;
3870 void *vertex_priv;
3871 struct wined3d_state_entry state_table[STATE_HIGHEST + 1];
3872 /* Array of functions for states which are handled by more than one pipeline part */
3873 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
3874 struct wined3d_blitter *blitter;
3876 BYTE bCursorVisible : 1;
3877 BYTE d3d_initialized : 1;
3878 BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3879 BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
3880 BYTE restore_screensaver : 1;
3881 BYTE padding : 3;
3883 unsigned char surface_alignment; /* Line Alignment of surfaces */
3885 WORD padding2 : 16;
3887 /* Internal use fields */
3888 struct wined3d_device_creation_parameters create_parms;
3889 HWND focus_window;
3891 struct wined3d_rendertarget_view *back_buffer_view;
3892 struct wined3d_swapchain **swapchains;
3893 UINT swapchain_count;
3894 unsigned int max_frame_latency;
3896 struct list resources; /* a linked list to track resources created by the device */
3897 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
3898 struct wine_rb_tree so_descs;
3899 struct wine_rb_tree samplers, rasterizer_states, blend_states, depth_stencil_states;
3901 /* Render Target Support */
3902 struct wined3d_rendertarget_view *auto_depth_stencil_view;
3904 /* Cursor management */
3905 UINT xHotSpot;
3906 UINT yHotSpot;
3907 UINT xScreenSpace;
3908 UINT yScreenSpace;
3909 UINT cursorWidth, cursorHeight;
3910 struct wined3d_texture *cursor_texture;
3911 HCURSOR hardwareCursor;
3913 /* The Wine logo texture */
3914 struct wined3d_texture *logo_texture;
3916 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3917 struct wined3d_sampler *default_sampler;
3918 struct wined3d_sampler *null_sampler;
3920 /* Command stream */
3921 struct wined3d_cs *cs;
3923 /* Context management */
3924 struct wined3d_context **contexts;
3925 UINT context_count;
3928 void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN;
3929 BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3930 void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3931 void wined3d_device_create_default_samplers(struct wined3d_device *device,
3932 struct wined3d_context *context) DECLSPEC_HIDDEN;
3933 void wined3d_device_destroy_default_samplers(struct wined3d_device *device) DECLSPEC_HIDDEN;
3934 HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d,
3935 unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3936 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3937 const BOOL *supported_extensions, struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3938 LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
3939 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
3940 void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3941 void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3942 void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
3943 HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device,
3944 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3945 void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN;
3947 struct wined3d_device_no3d
3949 struct wined3d_device d;
3951 struct wined3d_context context_no3d;
3954 static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_device *device)
3956 return CONTAINING_RECORD(device, struct wined3d_device_no3d, d);
3959 struct wined3d_device_gl
3961 struct wined3d_device d;
3963 /* Textures for when no other textures are bound. */
3964 struct wined3d_dummy_textures dummy_textures;
3966 uint64_t completed_fence_id;
3967 uint64_t current_fence_id;
3970 static inline struct wined3d_device_gl *wined3d_device_gl(struct wined3d_device *device)
3972 return CONTAINING_RECORD(device, struct wined3d_device_gl, d);
3975 void wined3d_device_gl_create_primary_opengl_context_cs(void *object) DECLSPEC_HIDDEN;
3976 void wined3d_device_gl_delete_opengl_contexts_cs(void *object) DECLSPEC_HIDDEN;
3978 struct wined3d_null_resources_vk
3980 struct wined3d_bo_vk bo;
3981 VkDescriptorBufferInfo buffer_info;
3983 struct wined3d_image_vk image_1d;
3984 struct wined3d_image_vk image_2d;
3985 struct wined3d_image_vk image_2dms;
3986 struct wined3d_image_vk image_3d;
3989 struct wined3d_null_views_vk
3991 VkBufferView vk_view_buffer_uint;
3992 VkBufferView vk_view_buffer_float;
3994 VkDescriptorImageInfo vk_info_1d;
3995 VkDescriptorImageInfo vk_info_2d;
3996 VkDescriptorImageInfo vk_info_2dms;
3997 VkDescriptorImageInfo vk_info_3d;
3998 VkDescriptorImageInfo vk_info_cube;
3999 VkDescriptorImageInfo vk_info_1d_array;
4000 VkDescriptorImageInfo vk_info_2d_array;
4001 VkDescriptorImageInfo vk_info_2dms_array;
4002 VkDescriptorImageInfo vk_info_cube_array;
4005 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
4006 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
4007 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
4008 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
4009 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
4011 struct wined3d_allocator_chunk
4013 struct list entry;
4014 struct list available[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT];
4015 struct wined3d_allocator *allocator;
4016 unsigned int map_count;
4017 void *map_ptr;
4020 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk *chunk) DECLSPEC_HIDDEN;
4021 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk *chunk,
4022 struct wined3d_allocator *allocator) DECLSPEC_HIDDEN;
4024 struct wined3d_allocator_chunk_vk
4026 struct wined3d_allocator_chunk c;
4027 VkDeviceMemory vk_memory;
4030 static inline struct wined3d_allocator_chunk_vk *wined3d_allocator_chunk_vk(struct wined3d_allocator_chunk *chunk)
4032 return CONTAINING_RECORD(chunk, struct wined3d_allocator_chunk_vk, c);
4035 void *wined3d_allocator_chunk_vk_map(struct wined3d_allocator_chunk_vk *chunk_vk,
4036 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4037 void wined3d_allocator_chunk_vk_unmap(struct wined3d_allocator_chunk_vk *chunk_vk,
4038 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4040 struct wined3d_allocator_block
4042 struct list entry;
4043 struct wined3d_allocator_chunk *chunk;
4044 struct wined3d_allocator_block *parent, *sibling;
4045 unsigned int order;
4046 size_t offset;
4047 bool free;
4050 void wined3d_allocator_block_free(struct wined3d_allocator_block *block) DECLSPEC_HIDDEN;
4052 struct wined3d_allocator_pool
4054 struct list chunks;
4057 struct wined3d_allocator_ops
4059 struct wined3d_allocator_chunk *(*allocator_create_chunk)(struct wined3d_allocator *allocator,
4060 struct wined3d_context *context, unsigned int memory_type, size_t chunk_size);
4061 void (*allocator_destroy_chunk)(struct wined3d_allocator_chunk *chunk);
4064 struct wined3d_allocator
4066 const struct wined3d_allocator_ops *ops;
4067 struct wined3d_allocator_pool *pools;
4068 size_t pool_count;
4069 struct wined3d_allocator_block *free;
4072 struct wined3d_allocator_block *wined3d_allocator_allocate(struct wined3d_allocator *allocator,
4073 struct wined3d_context *context, unsigned int memory_type, size_t size) DECLSPEC_HIDDEN;
4074 void wined3d_allocator_cleanup(struct wined3d_allocator *allocator) DECLSPEC_HIDDEN;
4075 bool wined3d_allocator_init(struct wined3d_allocator *allocator,
4076 size_t pool_count, const struct wined3d_allocator_ops *allocator_ops) DECLSPEC_HIDDEN;
4078 struct wined3d_uav_clear_pipelines_vk
4080 VkPipeline buffer;
4081 VkPipeline image_1d;
4082 VkPipeline image_1d_array;
4083 VkPipeline image_2d;
4084 VkPipeline image_2d_array;
4085 VkPipeline image_3d;
4088 struct wined3d_uav_clear_state_vk
4090 struct wined3d_uav_clear_pipelines_vk float_pipelines;
4091 struct wined3d_uav_clear_pipelines_vk uint_pipelines;
4093 struct wined3d_shader_thread_group_size buffer_group_size;
4094 struct wined3d_shader_thread_group_size image_1d_group_size;
4095 struct wined3d_shader_thread_group_size image_1d_array_group_size;
4096 struct wined3d_shader_thread_group_size image_2d_group_size;
4097 struct wined3d_shader_thread_group_size image_2d_array_group_size;
4098 struct wined3d_shader_thread_group_size image_3d_group_size;
4100 struct wined3d_pipeline_layout_vk *image_layout;
4101 struct wined3d_pipeline_layout_vk *buffer_layout;
4104 struct wined3d_device_vk
4106 struct wined3d_device d;
4108 struct wined3d_context_vk context_vk;
4110 VkDevice vk_device;
4111 VkQueue vk_queue;
4112 uint32_t vk_queue_family_index;
4113 uint32_t timestamp_bits;
4115 struct wined3d_vk_info vk_info;
4117 struct wined3d_null_resources_vk null_resources_vk;
4118 struct wined3d_null_views_vk null_views_vk;
4120 CRITICAL_SECTION allocator_cs;
4121 struct wined3d_allocator allocator;
4123 struct wined3d_uav_clear_state_vk uav_clear_state;
4126 static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
4128 return CONTAINING_RECORD(device, struct wined3d_device_vk, d);
4131 static inline struct wined3d_device_vk *wined3d_device_vk_from_allocator(struct wined3d_allocator *allocator)
4133 return CONTAINING_RECORD(allocator, struct wined3d_device_vk, allocator);
4136 static inline void wined3d_device_vk_allocator_lock(struct wined3d_device_vk *device_vk)
4138 EnterCriticalSection(&device_vk->allocator_cs);
4141 static inline void wined3d_device_vk_allocator_unlock(struct wined3d_device_vk *device_vk)
4143 LeaveCriticalSection(&device_vk->allocator_cs);
4146 bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk,
4147 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4148 bool wined3d_device_vk_create_null_views(struct wined3d_device_vk *device_vk,
4149 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4150 void wined3d_device_vk_destroy_null_resources(struct wined3d_device_vk *device_vk,
4151 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4152 void wined3d_device_vk_destroy_null_views(struct wined3d_device_vk *device_vk,
4153 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4155 void wined3d_device_vk_uav_clear_state_init(struct wined3d_device_vk *device_vk) DECLSPEC_HIDDEN;
4156 void wined3d_device_vk_uav_clear_state_cleanup(struct wined3d_device_vk *device_vk) DECLSPEC_HIDDEN;
4158 static inline float wined3d_alpha_ref(const struct wined3d_state *state)
4160 return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
4163 const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
4164 const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN;
4165 const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d,
4166 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4167 const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
4169 static inline ULONG wined3d_atomic_decrement_mutex_lock(volatile LONG *refcount)
4171 ULONG count, old_count = *refcount;
4174 if ((count = old_count) == 1)
4176 wined3d_mutex_lock();
4177 count = InterlockedDecrement(refcount);
4178 if (count) wined3d_mutex_unlock();
4179 return count;
4182 old_count = InterlockedCompareExchange(refcount, count - 1, count);
4184 while (old_count != count);
4186 return count - 1;
4189 struct wined3d_client_resource
4191 /* The resource's persistently mapped address, which we may use to perform
4192 * NOOVERWRITE maps from the client thread. */
4193 struct wined3d_bo_address addr;
4195 /* The currently mapped upload BO, if applicable, and box. */
4196 struct upload_bo mapped_upload;
4197 struct wined3d_box mapped_box;
4200 static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
4202 return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
4205 struct wined3d_resource_ops
4207 ULONG (*resource_incref)(struct wined3d_resource *resource);
4208 ULONG (*resource_decref)(struct wined3d_resource *resource);
4209 void (*resource_preload)(struct wined3d_resource *resource);
4210 void (*resource_unload)(struct wined3d_resource *resource);
4211 HRESULT (*resource_sub_resource_get_desc)(struct wined3d_resource *resource,
4212 unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc);
4213 void (*resource_sub_resource_get_map_pitch)(struct wined3d_resource *resource,
4214 unsigned int sub_resource_idx, unsigned int *row_pitch, unsigned int *slice_pitch);
4215 HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
4216 void **map_ptr, const struct wined3d_box *box, DWORD flags);
4217 HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
4220 struct wined3d_resource
4222 LONG ref;
4223 LONG bind_count;
4224 LONG map_count;
4225 LONG access_count;
4226 struct wined3d_device *device;
4227 enum wined3d_resource_type type;
4228 enum wined3d_gl_resource_type gl_type;
4229 const struct wined3d_format *format;
4230 unsigned int format_flags;
4231 enum wined3d_multisample_type multisample_type;
4232 UINT multisample_quality;
4233 DWORD usage;
4234 unsigned int bind_flags;
4235 unsigned int access;
4236 WORD draw_binding;
4237 WORD map_binding;
4238 UINT width;
4239 UINT height;
4240 UINT depth;
4241 UINT size;
4242 DWORD priority;
4243 void *heap_memory;
4245 struct wined3d_client_resource client;
4247 void *parent;
4248 const struct wined3d_parent_ops *parent_ops;
4249 const struct wined3d_resource_ops *resource_ops;
4251 struct list resource_list_entry;
4253 int32_t srv_bind_count_device;
4254 int32_t rtv_bind_count_device;
4257 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
4259 return resource->resource_ops->resource_incref(resource);
4262 static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
4264 return resource->resource_ops->resource_decref(resource);
4267 static inline void wined3d_resource_acquire(struct wined3d_resource *resource)
4269 InterlockedIncrement(&resource->access_count);
4272 static inline void wined3d_resource_release(struct wined3d_resource *resource)
4274 LONG refcount = InterlockedDecrement(&resource->access_count);
4275 assert(refcount >= 0);
4278 static inline HRESULT wined3d_resource_get_sub_resource_desc(struct wined3d_resource *resource,
4279 unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc)
4281 return resource->resource_ops->resource_sub_resource_get_desc(resource, sub_resource_idx, desc);
4284 static inline void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource *resource,
4285 unsigned int sub_resource_idx, unsigned int *row_pitch, unsigned int *slice_pitch)
4287 resource->resource_ops->resource_sub_resource_get_map_pitch(resource, sub_resource_idx, row_pitch, slice_pitch);
4290 void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4291 HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
4292 enum wined3d_resource_type type, const struct wined3d_format *format,
4293 enum wined3d_multisample_type multisample_type, unsigned int multisample_quality, unsigned int usage,
4294 unsigned int bind_flags, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
4295 unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
4296 const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
4297 void *resource_offset_map_pointer(struct wined3d_resource *resource, unsigned int sub_resource_idx,
4298 uint8_t *base_memory, const struct wined3d_box *box) DECLSPEC_HIDDEN;
4299 void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4300 HRESULT wined3d_resource_check_box_dimensions(struct wined3d_resource *resource,
4301 unsigned int sub_resource_idx, const struct wined3d_box *box) DECLSPEC_HIDDEN;
4302 void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4303 const struct wined3d_format *wined3d_resource_get_decompress_format(
4304 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4305 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4306 GLbitfield wined3d_resource_gl_map_flags(const struct wined3d_bo_gl *bo, DWORD d3d_flags) DECLSPEC_HIDDEN;
4307 GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
4308 GLbitfield wined3d_resource_gl_storage_flags(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4309 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4310 BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4311 void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4313 /* Tests show that the start address of resources is 32 byte aligned */
4314 #define RESOURCE_ALIGNMENT 16
4315 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
4317 #define WINED3D_LOCATION_DISCARDED 0x00000001
4318 #define WINED3D_LOCATION_SYSMEM 0x00000002
4319 #define WINED3D_LOCATION_BUFFER 0x00000008
4320 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
4321 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
4322 #define WINED3D_LOCATION_DRAWABLE 0x00000040
4323 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
4324 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
4326 const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN;
4328 struct wined3d_blt_info
4330 GLenum bind_target;
4331 struct wined3d_vec3 texcoords[4];
4334 struct wined3d_texture_ops
4336 BOOL (*texture_prepare_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4337 struct wined3d_context *context, unsigned int location);
4338 BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4339 struct wined3d_context *context, unsigned int location);
4340 void (*texture_unload_location)(struct wined3d_texture *texture,
4341 struct wined3d_context *context, unsigned int location);
4342 void (*texture_upload_data)(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr,
4343 const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch,
4344 unsigned int src_slice_pitch, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4345 unsigned int dst_location, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z);
4346 void (*texture_download_data)(struct wined3d_context *context, struct wined3d_texture *src_texture,
4347 unsigned int src_sub_resource_idx, unsigned int src_location, const struct wined3d_box *src_box,
4348 const struct wined3d_bo_address *dst_bo_addr, const struct wined3d_format *dst_format,
4349 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z,
4350 unsigned int dst_row_pitch, unsigned int dst_slice_pitch);
4353 #define WINED3D_TEXTURE_COND_NP2 0x00000001
4354 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
4355 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
4356 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
4357 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
4358 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
4359 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
4360 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
4361 #define WINED3D_TEXTURE_CONVERTED 0x00000100
4362 #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
4363 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
4364 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
4365 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
4366 #define WINED3D_TEXTURE_DISCARD 0x00002000
4367 #define WINED3D_TEXTURE_GET_DC 0x00004000
4368 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
4369 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
4371 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
4373 struct wined3d_texture
4375 struct wined3d_resource resource;
4376 const struct wined3d_texture_ops *texture_ops;
4377 struct wined3d_swapchain *swapchain;
4378 unsigned int pow2_width;
4379 unsigned int pow2_height;
4380 UINT layer_count;
4381 UINT level_count;
4382 unsigned int download_count;
4383 unsigned int sysmem_count;
4384 float pow2_matrix[16];
4385 UINT lod;
4386 DWORD sampler;
4387 DWORD flags;
4388 DWORD update_map_binding;
4390 unsigned int row_pitch;
4391 unsigned int slice_pitch;
4393 /* May only be accessed from the command stream worker thread. */
4394 struct wined3d_texture_async
4396 DWORD flags;
4398 /* Color keys for DDraw */
4399 struct wined3d_color_key dst_blt_color_key;
4400 struct wined3d_color_key src_blt_color_key;
4401 struct wined3d_color_key dst_overlay_color_key;
4402 struct wined3d_color_key src_overlay_color_key;
4403 struct wined3d_color_key gl_color_key;
4404 DWORD color_key_flags;
4405 } async;
4407 struct wined3d_dirty_regions
4409 struct wined3d_box *boxes;
4410 SIZE_T boxes_size;
4411 unsigned int box_count;
4412 } *dirty_regions;
4414 struct wined3d_overlay_info
4416 struct list entry;
4417 struct list overlays;
4418 struct wined3d_texture *dst_texture;
4419 unsigned int dst_sub_resource_idx;
4420 RECT src_rect;
4421 RECT dst_rect;
4422 } *overlay_info;
4424 struct wined3d_dc_info
4426 HBITMAP bitmap;
4427 HDC dc;
4428 } *dc_info;
4430 struct wined3d_texture_sub_resource
4432 void *parent;
4433 const struct wined3d_parent_ops *parent_ops;
4435 unsigned int offset;
4436 unsigned int size;
4438 unsigned int map_count;
4439 uint32_t map_flags;
4440 DWORD locations;
4441 union
4443 struct wined3d_bo b;
4444 struct wined3d_bo_gl gl;
4445 struct wined3d_bo_vk vk;
4446 } bo;
4448 void *user_memory;
4449 } *sub_resources;
4452 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s, SIZE_T level_count, SIZE_T layer_count)
4454 struct wined3d_texture *t;
4456 if (level_count > ((~(SIZE_T)0 - s) / sizeof(*t->sub_resources)) / layer_count)
4457 return NULL;
4459 return heap_alloc_zero(s + level_count * layer_count * sizeof(*t->sub_resources));
4462 static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
4464 return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
4467 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture,
4468 unsigned int level)
4470 return max(1, texture->resource.width >> level);
4473 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture,
4474 unsigned int level)
4476 return max(1, texture->resource.height >> level);
4479 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture,
4480 unsigned int level)
4482 return max(1, texture->resource.depth >> level);
4485 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
4486 unsigned int level)
4488 return max(1, texture->pow2_width >> level);
4491 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
4492 unsigned int level)
4494 return max(1, texture->pow2_height >> level);
4497 static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture,
4498 unsigned int level, struct wined3d_box *box)
4500 wined3d_box_set(box, 0, 0,
4501 wined3d_texture_get_level_width(texture, level),
4502 wined3d_texture_get_level_height(texture, level),
4503 0, wined3d_texture_get_level_depth(texture, level));
4506 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture *texture,
4507 unsigned int level, const RECT *r)
4509 unsigned int t;
4511 t = wined3d_texture_get_level_width(texture, level);
4512 if ((r->left && r->right) || abs(r->right - r->left) != t)
4513 return false;
4514 t = wined3d_texture_get_level_height(texture, level);
4515 if ((r->top && r->bottom) || abs(r->bottom - r->top) != t)
4516 return false;
4517 return true;
4520 HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4521 const struct wined3d_box *dst_box, struct wined3d_texture *src_texture,
4522 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
4523 const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4524 void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
4525 const RECT *rect, struct wined3d_blt_info *info) DECLSPEC_HIDDEN;
4526 void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
4527 BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN;
4528 void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4529 struct wined3d_context *context, DWORD src_location, DWORD dst_location) DECLSPEC_HIDDEN;
4531 void wined3d_texture_cleanup(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4532 void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4533 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN;
4534 GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4535 void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4536 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4537 void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
4538 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
4539 void wined3d_texture_load(struct wined3d_texture *texture,
4540 struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
4541 BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
4542 unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4543 BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4544 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4545 void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
4546 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4547 BOOL wined3d_texture_can_use_pbo(const struct wined3d_texture *texture, const struct wined3d_d3d_info *d3d_info)
4548 DECLSPEC_HIDDEN;
4549 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4550 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
4551 HWND window, RECT *rect) DECLSPEC_HIDDEN;
4552 void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4553 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture,
4554 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
4555 void wined3d_texture_validate_location(struct wined3d_texture *texture,
4556 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
4557 void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4559 HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device,
4560 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4561 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4563 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4564 void wined3d_vk_swizzle_from_color_fixup(VkComponentMapping *mapping, struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4566 struct gl_texture
4568 struct wined3d_sampler_desc sampler_desc;
4569 unsigned int base_level;
4570 GLuint name;
4573 struct wined3d_texture_gl
4575 struct wined3d_texture t;
4577 struct gl_texture texture_rgb, texture_srgb;
4579 GLenum target;
4581 GLuint rb_multisample;
4582 GLuint rb_resolved;
4584 struct list renderbuffers;
4585 const struct wined3d_renderbuffer_entry *current_renderbuffer;
4588 static inline struct wined3d_texture_gl *wined3d_texture_gl(struct wined3d_texture *texture)
4590 return CONTAINING_RECORD(texture, struct wined3d_texture_gl, t);
4593 static inline struct gl_texture *wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl *texture_gl,
4594 BOOL srgb)
4596 return srgb ? &texture_gl->texture_srgb : &texture_gl->texture_rgb;
4599 static inline GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl,
4600 unsigned int sub_resource_idx)
4602 static const GLenum cube_targets[] =
4604 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
4605 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
4606 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
4607 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
4608 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
4609 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
4612 return texture_gl->t.resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP
4613 ? cube_targets[sub_resource_idx / texture_gl->t.level_count] : texture_gl->target;
4616 static inline BOOL wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl *texture_gl,
4617 DWORD location)
4619 if (location == WINED3D_LOCATION_RB_MULTISAMPLE)
4620 return TRUE;
4621 if (location != WINED3D_LOCATION_TEXTURE_RGB && location != WINED3D_LOCATION_TEXTURE_SRGB)
4622 return FALSE;
4623 return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
4626 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl,
4627 const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4628 void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
4629 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4630 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
4631 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4632 HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, struct wined3d_device *device,
4633 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4634 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4635 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
4636 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4637 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl,
4638 struct wined3d_context_gl *context_gl, unsigned int level,
4639 const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;
4641 struct wined3d_texture_vk
4643 struct wined3d_texture t;
4645 struct wined3d_image_vk image;
4646 enum VkImageLayout layout;
4647 uint32_t bind_mask;
4649 VkDescriptorImageInfo default_image_info;
4652 static inline struct wined3d_texture_vk *wined3d_texture_vk(struct wined3d_texture *texture)
4654 return CONTAINING_RECORD(texture, struct wined3d_texture_vk, t);
4657 void wined3d_texture_vk_barrier(struct wined3d_texture_vk *texture_vk,
4658 struct wined3d_context_vk *context_vk, uint32_t bind_mask) DECLSPEC_HIDDEN;
4659 const VkDescriptorImageInfo *wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk *texture_vk,
4660 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4661 HRESULT wined3d_texture_vk_init(struct wined3d_texture_vk *texture_vk, struct wined3d_device *device,
4662 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4663 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4664 BOOL wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk *texture_vk,
4665 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4667 struct wined3d_renderbuffer_entry
4669 struct list entry;
4670 GLuint id;
4671 UINT width;
4672 UINT height;
4675 struct wined3d_fbo_resource
4677 GLuint object;
4678 GLenum target;
4679 GLuint level, layer;
4682 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
4683 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
4684 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
4686 struct fbo_entry
4688 struct list entry;
4689 DWORD flags;
4690 DWORD rt_mask;
4691 GLuint id;
4692 struct wined3d_fbo_entry_key
4694 DWORD rb_namespace;
4695 struct wined3d_fbo_resource objects[WINED3D_MAX_RENDER_TARGETS + 1];
4696 } key;
4699 struct wined3d_sampler
4701 struct wine_rb_entry entry;
4702 LONG refcount;
4703 struct wined3d_device *device;
4704 void *parent;
4705 const struct wined3d_parent_ops *parent_ops;
4706 struct wined3d_sampler_desc desc;
4709 struct wined3d_sampler_gl
4711 struct wined3d_sampler s;
4713 GLuint name;
4716 static inline struct wined3d_sampler_gl *wined3d_sampler_gl(struct wined3d_sampler *sampler)
4718 return CONTAINING_RECORD(sampler, struct wined3d_sampler_gl, s);
4721 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl *sampler_gl, unsigned int unit,
4722 struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4723 void wined3d_sampler_gl_init(struct wined3d_sampler_gl *sampler_gl,
4724 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
4725 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4727 struct wined3d_sampler_vk
4729 struct wined3d_sampler s;
4731 VkDescriptorImageInfo vk_image_info;
4732 uint64_t command_buffer_id;
4735 static inline struct wined3d_sampler_vk *wined3d_sampler_vk(struct wined3d_sampler *sampler)
4737 return CONTAINING_RECORD(sampler, struct wined3d_sampler_vk, s);
4740 void wined3d_sampler_vk_init(struct wined3d_sampler_vk *sampler_vk,
4741 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
4742 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4744 struct wined3d_vertex_declaration_element
4746 const struct wined3d_format *format;
4747 BOOL ffp_valid;
4748 unsigned int input_slot;
4749 unsigned int offset;
4750 unsigned int output_slot;
4751 enum wined3d_input_classification input_slot_class;
4752 unsigned int instance_data_step_rate;
4753 BYTE method;
4754 BYTE usage;
4755 BYTE usage_idx;
4758 struct wined3d_vertex_declaration
4760 LONG ref;
4761 void *parent;
4762 const struct wined3d_parent_ops *parent_ops;
4763 struct wined3d_device *device;
4765 struct wined3d_vertex_declaration_element *elements;
4766 unsigned int element_count;
4768 BOOL position_transformed;
4771 struct wined3d_saved_states
4773 uint32_t vs_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F)];
4774 WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
4775 WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
4776 uint32_t ps_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F)];
4777 WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
4778 WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
4779 uint32_t transform[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE + 1)];
4780 WORD streamSource; /* WINED3D_MAX_STREAMS, 16 */
4781 WORD streamFreq; /* WINED3D_MAX_STREAMS, 16 */
4782 uint32_t renderState[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE + 1)];
4783 DWORD textureState[WINED3D_MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
4784 WORD samplerState[WINED3D_MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
4785 DWORD clipplane; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
4786 DWORD textures : 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
4787 DWORD indices : 1;
4788 DWORD material : 1;
4789 DWORD viewport : 1;
4790 DWORD vertexDecl : 1;
4791 DWORD pixelShader : 1;
4792 DWORD vertexShader : 1;
4793 DWORD scissorRect : 1;
4794 DWORD store_stream_offset : 1;
4795 DWORD alpha_to_coverage : 1;
4796 DWORD lights : 1;
4797 DWORD transforms : 1;
4798 DWORD padding : 1;
4801 struct StageState {
4802 DWORD stage;
4803 DWORD state;
4806 struct wined3d_stateblock
4808 LONG ref; /* Note: Ref counting not required */
4809 struct wined3d_device *device;
4811 /* Array indicating whether things have been set or changed */
4812 struct wined3d_saved_states changed;
4814 struct wined3d_stateblock_state stateblock_state;
4815 struct wined3d_light_state light_state;
4817 /* Contained state management */
4818 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
4819 unsigned int num_contained_render_states;
4820 DWORD contained_transform_states[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
4821 unsigned int num_contained_transform_states;
4822 struct StageState contained_tss_states[WINED3D_MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
4823 unsigned int num_contained_tss_states;
4824 struct StageState contained_sampler_states[WINED3D_MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
4825 unsigned int num_contained_sampler_states;
4828 void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
4829 const struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
4830 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
4832 void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
4833 struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
4834 struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
4835 unsigned int idx) DECLSPEC_HIDDEN;
4836 HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
4837 const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
4839 enum wined3d_cs_queue_id
4841 WINED3D_CS_QUEUE_DEFAULT = 0,
4842 WINED3D_CS_QUEUE_MAP,
4843 WINED3D_CS_QUEUE_COUNT,
4846 enum wined3d_push_constants
4848 WINED3D_PUSH_CONSTANTS_VS_F,
4849 WINED3D_PUSH_CONSTANTS_PS_F,
4850 WINED3D_PUSH_CONSTANTS_VS_I,
4851 WINED3D_PUSH_CONSTANTS_PS_I,
4852 WINED3D_PUSH_CONSTANTS_VS_B,
4853 WINED3D_PUSH_CONSTANTS_PS_B,
4856 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
4857 #define WINED3D_CS_QUEUE_SIZE 0x100000u
4858 #define WINED3D_CS_SPIN_COUNT 10000000u
4860 struct wined3d_cs_queue
4862 LONG head, tail;
4863 BYTE data[WINED3D_CS_QUEUE_SIZE];
4866 struct wined3d_device_context_ops
4868 void *(*require_space)(struct wined3d_device_context *context, size_t size, enum wined3d_cs_queue_id queue_id);
4869 void (*submit)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
4870 void (*finish)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id);
4871 void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p,
4872 unsigned int start_idx, unsigned int count, const void *constants);
4873 bool (*map_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
4874 unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc,
4875 const struct wined3d_box *box, uint32_t flags);
4876 bool (*unmap_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
4877 unsigned int sub_resource_idx, struct wined3d_box *box, struct upload_bo *upload_bo);
4878 void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags);
4879 void (*flush)(struct wined3d_device_context *context);
4880 void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource);
4881 void (*acquire_command_list)(struct wined3d_device_context *context, struct wined3d_command_list *list);
4884 struct wined3d_device_context
4886 const struct wined3d_device_context_ops *ops;
4887 struct wined3d_device *device;
4888 struct wined3d_state *state;
4891 struct wined3d_cs
4893 struct wined3d_device_context c;
4895 struct wined3d_state state;
4896 HMODULE wined3d_module;
4897 HANDLE thread;
4898 DWORD thread_id;
4899 BOOL serialize_commands;
4901 struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
4902 size_t data_size, start, end;
4903 void *data;
4904 struct list query_poll_list;
4905 BOOL queries_flushed;
4907 HANDLE event;
4908 BOOL waiting_for_event;
4909 LONG pending_presents;
4912 static inline void wined3d_device_context_lock(struct wined3d_device_context *context)
4914 if (context == &context->device->cs->c)
4915 wined3d_mutex_lock();
4918 static inline void wined3d_device_context_unlock(struct wined3d_device_context *context)
4920 if (context == &context->device->cs->c)
4921 wined3d_mutex_unlock();
4924 struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device,
4925 const enum wined3d_feature_level *levels, unsigned int level_count) DECLSPEC_HIDDEN;
4926 void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4927 void wined3d_cs_destroy_object(struct wined3d_cs *cs,
4928 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4929 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
4930 struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
4931 void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
4932 DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4933 void wined3d_device_context_emit_clear_uav(struct wined3d_device_context *context,
4934 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value, bool fp) DECLSPEC_HIDDEN;
4935 void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4936 void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
4937 const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags) DECLSPEC_HIDDEN;
4938 void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
4939 WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
4940 void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
4941 enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
4942 void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4943 void wined3d_cs_init_object(struct wined3d_cs *cs,
4944 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4946 static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
4948 cs->c.ops->finish(&cs->c, queue_id);
4951 static inline void wined3d_device_context_push_constants(struct wined3d_device_context *context,
4952 enum wined3d_push_constants p, unsigned int start_idx, unsigned int count, const void *constants)
4954 context->ops->push_constants(context, p, start_idx, count, constants);
4957 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context *context,
4958 struct wined3d_resource *dst_resource, unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box,
4959 struct wined3d_resource *src_resource, unsigned int src_sub_resource_idx, const struct wined3d_box *src_box,
4960 unsigned int flags, const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4961 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context *context,
4962 struct wined3d_rendertarget_view *view, const RECT *rect, unsigned int flags,
4963 const struct wined3d_color *color, float depth, unsigned int stencil) DECLSPEC_HIDDEN;
4964 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context *context,
4965 struct wined3d_buffer *dst_buffer, unsigned int offset,
4966 struct wined3d_unordered_access_view *uav) DECLSPEC_HIDDEN;
4967 void wined3d_device_context_emit_draw(struct wined3d_device_context *context,
4968 enum wined3d_primitive_type primitive_type, unsigned int patch_vertex_count, int base_vertex_idx,
4969 unsigned int start_idx, unsigned int index_count, unsigned int start_instance, unsigned int instance_count,
4970 bool indexed) DECLSPEC_HIDDEN;
4971 void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context *context,
4972 struct wined3d_command_list *list, bool restore_state) DECLSPEC_HIDDEN;
4973 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context,
4974 struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4975 HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
4976 struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc,
4977 const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
4978 void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate) DECLSPEC_HIDDEN;
4979 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context,
4980 struct wined3d_blend_state *state, const struct wined3d_color *blend_factor,
4981 unsigned int sample_mask) DECLSPEC_HIDDEN;
4982 void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context *context, unsigned int plane_idx,
4983 const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
4984 void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context *context,
4985 enum wined3d_shader_type type, unsigned int start_idx, unsigned int count,
4986 const struct wined3d_constant_buffer_state *buffers) DECLSPEC_HIDDEN;
4987 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context *context,
4988 struct wined3d_depth_stencil_state *state, unsigned int stencil_ref) DECLSPEC_HIDDEN;
4989 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context *context,
4990 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4991 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context *context,
4992 enum wined3d_feature_level level) DECLSPEC_HIDDEN;
4993 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context *context, struct wined3d_buffer *buffer,
4994 enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN;
4995 void wined3d_device_context_emit_set_light(struct wined3d_device_context *context,
4996 const struct wined3d_light_info *light) DECLSPEC_HIDDEN;
4997 void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context *context, unsigned int idx,
4998 BOOL enable) DECLSPEC_HIDDEN;
4999 void wined3d_device_context_emit_set_material(struct wined3d_device_context *context,
5000 const struct wined3d_material *material) DECLSPEC_HIDDEN;
5001 void wined3d_device_context_emit_set_predication(struct wined3d_device_context *context,
5002 struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
5003 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context *context,
5004 struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN;
5005 void wined3d_device_context_emit_set_render_state(struct wined3d_device_context *context,
5006 enum wined3d_render_state state, unsigned int value) DECLSPEC_HIDDEN;
5007 void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context *context, unsigned int start_idx,
5008 unsigned int count, struct wined3d_rendertarget_view *const *views) DECLSPEC_HIDDEN;
5009 void wined3d_device_context_emit_set_samplers(struct wined3d_device_context *context, enum wined3d_shader_type type,
5010 unsigned int start_idx, unsigned int count, struct wined3d_sampler *const *samplers) DECLSPEC_HIDDEN;
5011 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context *context, unsigned int sampler_idx,
5012 enum wined3d_sampler_state state, unsigned int value) DECLSPEC_HIDDEN;
5013 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context *context,
5014 unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN;
5015 void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type,
5016 struct wined3d_shader *shader) DECLSPEC_HIDDEN;
5017 void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context *context,
5018 enum wined3d_shader_type type, unsigned int start_idx, unsigned int count,
5019 struct wined3d_shader_resource_view *const *views) DECLSPEC_HIDDEN;
5020 void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context *context,
5021 const struct wined3d_stream_output outputs[WINED3D_MAX_STREAM_OUTPUT_BUFFERS]) DECLSPEC_HIDDEN;
5022 void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context *context,
5023 unsigned int start_idx, unsigned int count, const struct wined3d_stream_state *streams) DECLSPEC_HIDDEN;
5024 void wined3d_device_context_emit_set_texture(struct wined3d_device_context *context, unsigned int stage,
5025 struct wined3d_texture *texture) DECLSPEC_HIDDEN;
5026 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context *context, unsigned int stage,
5027 enum wined3d_texture_stage_state state, unsigned int value) DECLSPEC_HIDDEN;
5028 void wined3d_device_context_emit_set_transform(struct wined3d_device_context *context,
5029 enum wined3d_transform_state state, const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
5030 void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context *context,
5031 enum wined3d_pipeline pipeline, unsigned int start_idx, unsigned int count,
5032 struct wined3d_unordered_access_view *const *views, const unsigned int *initial_count) DECLSPEC_HIDDEN;
5033 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context *context,
5034 struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
5035 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count,
5036 const struct wined3d_viewport *viewports) DECLSPEC_HIDDEN;
5037 void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context,
5038 struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
5039 const void *data, unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN;
5040 HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context,
5041 struct wined3d_resource *resource, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
5043 static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
5045 const struct wined3d_cs *cs = resource->device->cs;
5047 if (!cs->thread || cs->thread_id == GetCurrentThreadId())
5048 return;
5050 while (InterlockedCompareExchange(&resource->access_count, 0, 0))
5051 YieldProcessor();
5054 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
5055 * fixed function semantics as D3DCOLOR or FLOAT16 */
5056 enum wined3d_buffer_conversion_type
5058 CONV_NONE,
5059 CONV_D3DCOLOR,
5060 CONV_POSITIONT,
5063 struct wined3d_buffer_ops
5065 BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer,
5066 struct wined3d_context *context, unsigned int location);
5067 void (*buffer_unload_location)(struct wined3d_buffer *buffer,
5068 struct wined3d_context *context, unsigned int location);
5069 void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
5070 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
5071 void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
5072 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
5075 struct wined3d_buffer
5077 struct wined3d_resource resource;
5078 const struct wined3d_buffer_ops *buffer_ops;
5080 unsigned int structure_byte_stride;
5081 DWORD flags;
5082 DWORD locations;
5083 void *map_ptr;
5084 struct wined3d_bo *buffer_object;
5085 struct wined3d_bo_user bo_user;
5087 struct wined3d_range *maps;
5088 SIZE_T maps_size, modified_areas;
5090 /* conversion stuff */
5091 UINT decl_change_count, full_conversion_count;
5092 UINT draw_count;
5093 UINT stride; /* 0 if no conversion */
5094 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
5095 UINT conversion_stride; /* 0 if no shifted conversion */
5098 static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
5100 return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
5103 void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
5104 void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
5105 struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
5106 void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wined3d_context *context,
5107 unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size) DECLSPEC_HIDDEN;
5108 DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *context,
5109 struct wined3d_bo_address *data) DECLSPEC_HIDDEN;
5110 void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
5111 void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
5112 const struct wined3d_state *state) DECLSPEC_HIDDEN;
5113 BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
5114 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
5115 BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
5116 BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
5117 struct wined3d_context *context, unsigned int location) DECLSPEC_HIDDEN;
5118 void wined3d_buffer_update_sub_resource(struct wined3d_buffer *buffer, struct wined3d_context *context,
5119 const struct upload_bo *upload_bo, unsigned int offset, unsigned int size) DECLSPEC_HIDDEN;
5121 HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device,
5122 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
5123 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5125 struct wined3d_buffer_gl
5127 struct wined3d_buffer b;
5130 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
5132 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
5135 static inline const struct wined3d_buffer_gl *wined3d_buffer_gl_const(const struct wined3d_buffer *buffer)
5137 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
5140 HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device,
5141 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
5142 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5144 struct wined3d_buffer_vk
5146 struct wined3d_buffer b;
5148 VkDescriptorBufferInfo buffer_info;
5149 uint32_t bind_mask;
5152 static inline struct wined3d_buffer_vk *wined3d_buffer_vk(struct wined3d_buffer *buffer)
5154 return CONTAINING_RECORD(buffer, struct wined3d_buffer_vk, b);
5157 void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk,
5158 struct wined3d_context_vk *context_vk, uint32_t bind_mask) DECLSPEC_HIDDEN;
5159 const VkDescriptorBufferInfo *wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk *buffer_vk) DECLSPEC_HIDDEN;
5160 HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device,
5161 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
5162 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5164 static inline void wined3d_resource_vk_barrier(struct wined3d_resource *resource,
5165 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5167 if (resource->type == WINED3D_RTYPE_BUFFER)
5168 wined3d_buffer_vk_barrier(wined3d_buffer_vk(buffer_from_resource(resource)), context_vk, bind_mask);
5169 else
5170 wined3d_texture_vk_barrier(wined3d_texture_vk(texture_from_resource(resource)), context_vk, bind_mask);
5173 struct wined3d_rendertarget_view
5175 LONG refcount;
5177 struct wined3d_resource *resource;
5178 void *parent;
5179 const struct wined3d_parent_ops *parent_ops;
5181 const struct wined3d_format *format;
5182 unsigned int format_flags;
5183 unsigned int sub_resource_idx;
5184 unsigned int layer_count;
5186 unsigned int width;
5187 unsigned int height;
5189 struct wined3d_view_desc desc;
5192 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
5193 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
5194 const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
5195 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
5196 DWORD location) DECLSPEC_HIDDEN;
5197 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
5198 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
5199 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,
5200 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
5201 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
5202 DWORD location) DECLSPEC_HIDDEN;
5204 HRESULT wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view *view_no3d,
5205 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5206 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5208 struct wined3d_rendertarget_view_gl
5210 struct wined3d_rendertarget_view v;
5211 struct wined3d_gl_view gl_view;
5214 static inline struct wined3d_rendertarget_view_gl *wined3d_rendertarget_view_gl(
5215 struct wined3d_rendertarget_view *view)
5217 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_gl, v);
5220 HRESULT wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl *view_gl,
5221 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5222 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5224 struct wined3d_rendertarget_view_vk
5226 struct wined3d_rendertarget_view v;
5228 VkImageView vk_image_view;
5229 uint64_t command_buffer_id;
5232 static inline struct wined3d_rendertarget_view_vk *wined3d_rendertarget_view_vk(
5233 struct wined3d_rendertarget_view *view)
5235 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_vk, v);
5238 static inline void wined3d_rendertarget_view_vk_barrier(struct wined3d_rendertarget_view_vk *rtv_vk,
5239 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5241 wined3d_resource_vk_barrier(rtv_vk->v.resource, context_vk, bind_mask);
5244 static inline VkImageView wined3d_rendertarget_view_vk_get_image_view(struct wined3d_rendertarget_view_vk *rtv_vk,
5245 struct wined3d_context_vk *context_vk)
5247 struct wined3d_texture_vk *texture_vk;
5249 if (rtv_vk->vk_image_view)
5250 return rtv_vk->vk_image_view;
5252 texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(rtv_vk->v.resource));
5253 return wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)->imageView;
5256 HRESULT wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk *view_vk,
5257 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5258 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5260 struct wined3d_shader_resource_view
5262 LONG refcount;
5264 struct wined3d_resource *resource;
5265 void *parent;
5266 const struct wined3d_parent_ops *parent_ops;
5268 const struct wined3d_format *format;
5270 struct wined3d_view_desc desc;
5273 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
5275 struct wined3d_shader_resource_view_gl
5277 struct wined3d_shader_resource_view v;
5278 struct wined3d_bo_user bo_user;
5279 struct wined3d_gl_view gl_view;
5282 static inline struct wined3d_shader_resource_view_gl *wined3d_shader_resource_view_gl(
5283 struct wined3d_shader_resource_view *view)
5285 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_gl, v);
5288 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit,
5289 struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5290 void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl *srv_gl,
5291 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5292 HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl *view_gl,
5293 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5294 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5295 void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl *srv_gl,
5296 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5298 struct wined3d_view_vk
5300 struct wined3d_bo_user bo_user;
5301 union
5303 VkBufferView vk_buffer_view;
5304 VkDescriptorImageInfo vk_image_info;
5305 } u;
5306 uint64_t command_buffer_id;
5309 struct wined3d_shader_resource_view_vk
5311 struct wined3d_shader_resource_view v;
5312 struct wined3d_view_vk view_vk;
5315 static inline struct wined3d_shader_resource_view_vk *wined3d_shader_resource_view_vk(
5316 struct wined3d_shader_resource_view *view)
5318 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_vk, v);
5321 static inline void wined3d_shader_resource_view_vk_barrier(struct wined3d_shader_resource_view_vk *srv_vk,
5322 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5324 wined3d_resource_vk_barrier(srv_vk->v.resource, context_vk, bind_mask);
5327 void wined3d_shader_resource_view_vk_generate_mipmap(struct wined3d_shader_resource_view_vk *srv_vk,
5328 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5329 HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk *view_vk,
5330 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5331 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5332 void wined3d_shader_resource_view_vk_update(struct wined3d_shader_resource_view_vk *view_vk,
5333 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5335 struct wined3d_unordered_access_view
5337 LONG refcount;
5339 struct wined3d_resource *resource;
5340 void *parent;
5341 const struct wined3d_parent_ops *parent_ops;
5343 const struct wined3d_format *format;
5345 struct wined3d_view_desc desc;
5346 struct wined3d_bo *counter_bo;
5349 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
5350 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
5351 struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
5352 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
5353 DWORD location) DECLSPEC_HIDDEN;
5354 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
5355 unsigned int value) DECLSPEC_HIDDEN;
5357 struct wined3d_unordered_access_view_gl
5359 struct wined3d_unordered_access_view v;
5360 struct wined3d_bo_user bo_user;
5361 struct wined3d_gl_view gl_view;
5362 struct wined3d_bo_gl counter_bo;
5365 static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_view_gl(
5366 struct wined3d_unordered_access_view *view)
5368 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_gl, v);
5371 void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view_gl *view_gl,
5372 const struct wined3d_uvec4 *clear_value, struct wined3d_context_gl *context_gl, bool fp) DECLSPEC_HIDDEN;
5373 HRESULT wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl *view_gl,
5374 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5375 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5376 void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl *uav_gl,
5377 struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
5379 struct wined3d_unordered_access_view_vk
5381 struct wined3d_unordered_access_view v;
5382 struct wined3d_view_vk view_vk;
5384 VkBufferView vk_counter_view;
5385 struct wined3d_bo_vk counter_bo;
5388 static inline struct wined3d_unordered_access_view_vk *wined3d_unordered_access_view_vk(
5389 struct wined3d_unordered_access_view *view)
5391 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_vk, v);
5394 static inline void wined3d_unordered_access_view_vk_barrier(struct wined3d_unordered_access_view_vk *uav_vk,
5395 struct wined3d_context_vk *context_vk, uint32_t bind_mask)
5397 wined3d_resource_vk_barrier(uav_vk->v.resource, context_vk, bind_mask);
5400 void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view_vk *view_vk,
5401 const struct wined3d_uvec4 *clear_value, struct wined3d_context_vk *context_vk, bool fp) DECLSPEC_HIDDEN;
5402 HRESULT wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk *view_vk,
5403 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
5404 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5405 void wined3d_unordered_access_view_vk_update(struct wined3d_unordered_access_view_vk *view_vk,
5406 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
5408 struct wined3d_swapchain_state
5410 struct wined3d *wined3d;
5411 struct wined3d_swapchain_desc desc;
5412 struct wined3d_swapchain_state_parent *parent;
5414 struct wined3d_display_mode original_mode, d3d_mode;
5415 RECT original_window_rect;
5417 /* Window styles to restore when switching fullscreen mode. */
5418 LONG style;
5419 LONG exstyle;
5420 HWND device_window;
5423 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state *state) DECLSPEC_HIDDEN;
5424 void wined3d_swapchain_state_register(struct wined3d_swapchain_state *state) DECLSPEC_HIDDEN;
5425 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
5426 HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
5427 HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
5428 HWND window, int x, int y, int width, int height) DECLSPEC_HIDDEN;
5430 struct wined3d_swapchain_ops
5432 void (*swapchain_present)(struct wined3d_swapchain *swapchain,
5433 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, DWORD flags);
5434 void (*swapchain_frontbuffer_updated)(struct wined3d_swapchain *swapchain);
5437 struct wined3d_swapchain
5439 LONG ref;
5440 void *parent;
5441 const struct wined3d_parent_ops *parent_ops;
5442 const struct wined3d_swapchain_ops *swapchain_ops;
5443 struct wined3d_device *device;
5445 struct wined3d_texture **back_buffers;
5446 struct wined3d_texture *front_buffer;
5447 struct wined3d_gamma_ramp orig_gamma;
5448 bool reapply_mode;
5449 const struct wined3d_format *ds_format;
5450 struct wined3d_palette *palette;
5451 RECT front_buffer_update;
5452 unsigned int swap_interval;
5453 unsigned int max_frame_latency;
5455 LONG prev_time, frames; /* Performance tracking */
5457 struct wined3d_swapchain_state state;
5458 HWND win_handle;
5461 void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
5462 void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
5463 struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
5464 void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
5465 void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain,
5466 const struct wined3d_device *device) DECLSPEC_HIDDEN;
5468 HRESULT wined3d_swapchain_no3d_init(struct wined3d_swapchain *swapchain_no3d,
5469 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
5470 struct wined3d_swapchain_state_parent *state_parent, void *parent,
5471 const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5473 struct wined3d_swapchain_gl
5475 struct wined3d_swapchain s;
5477 struct wined3d_context_gl **contexts;
5478 SIZE_T contexts_size;
5479 SIZE_T context_count;
5481 HDC backup_dc;
5482 HWND backup_wnd;
5485 static inline struct wined3d_swapchain_gl *wined3d_swapchain_gl(struct wined3d_swapchain *swapchain)
5487 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_gl, s);
5490 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5491 void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5492 HDC wined3d_swapchain_gl_get_backup_dc(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5493 struct wined3d_context_gl *wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
5494 HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl,
5495 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
5496 struct wined3d_swapchain_state_parent *state_parent, void *parent,
5497 const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5499 struct wined3d_swapchain_vk
5501 struct wined3d_swapchain s;
5503 VkSwapchainKHR vk_swapchain;
5504 VkSurfaceKHR vk_surface;
5505 VkImage *vk_images;
5506 struct
5508 VkSemaphore available;
5509 VkSemaphore presentable;
5510 uint64_t command_buffer_id;
5511 } *vk_semaphores;
5512 unsigned int current, image_count;
5513 unsigned int width, height;
5516 static inline struct wined3d_swapchain_vk *wined3d_swapchain_vk(struct wined3d_swapchain *swapchain)
5518 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_vk, s);
5521 void wined3d_swapchain_vk_cleanup(struct wined3d_swapchain_vk *swapchain_vk) DECLSPEC_HIDDEN;
5522 HRESULT wined3d_swapchain_vk_init(struct wined3d_swapchain_vk *swapchain_vk,
5523 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
5524 struct wined3d_swapchain_state_parent *state_parent, void *parent,
5525 const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
5527 /*****************************************************************************
5528 * Utility function prototypes
5531 /* Trace routines */
5532 const char *debug_bo_address(const struct wined3d_bo_address *address) DECLSPEC_HIDDEN;
5533 const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
5534 const char *debug_color(const struct wined3d_color *color) DECLSPEC_HIDDEN;
5535 const char *debug_const_bo_address(const struct wined3d_const_bo_address *address) DECLSPEC_HIDDEN;
5536 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
5537 const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
5538 const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
5539 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) DECLSPEC_HIDDEN;
5540 const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
5541 const char *debug_d3ddeclmethod(enum wined3d_decl_method method) DECLSPEC_HIDDEN;
5542 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
5543 const char *debug_d3dinput_classification(enum wined3d_input_classification classification) DECLSPEC_HIDDEN;
5544 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
5545 const char *debug_d3drenderstate(enum wined3d_render_state state) DECLSPEC_HIDDEN;
5546 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HIDDEN;
5547 const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
5548 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
5549 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
5550 const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
5551 const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
5552 const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
5553 const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
5554 const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
5555 const char *debug_ivec4(const struct wined3d_ivec4 *v) DECLSPEC_HIDDEN;
5556 const char *debug_uvec4(const struct wined3d_uvec4 *v) DECLSPEC_HIDDEN;
5557 const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
5558 const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
5559 const char *wined3d_debug_feature_level(enum wined3d_feature_level level) DECLSPEC_HIDDEN;
5560 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
5562 BOOL is_invalid_op(const struct wined3d_state *state, int stage,
5563 enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
5564 void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
5565 BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
5566 INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
5567 void texture_activate_dimensions(struct wined3d_texture *texture,
5568 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
5569 void sampler_texdim(struct wined3d_context *context,
5570 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5571 void tex_alphaop(struct wined3d_context *context,
5572 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5573 void apply_pixelshader(struct wined3d_context *context,
5574 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5575 void state_alpha_test(struct wined3d_context *context,
5576 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5577 void state_fogcolor(struct wined3d_context *context,
5578 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5579 void state_fogdensity(struct wined3d_context *context,
5580 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5581 void state_fogstartend(struct wined3d_context *context,
5582 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5583 void state_fog_fragpart(struct wined3d_context *context,
5584 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5585 void state_nop(struct wined3d_context *context,
5586 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5587 void state_srgbwrite(struct wined3d_context *context,
5588 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5590 void state_clipping(struct wined3d_context *context,
5591 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5592 void clipplane(struct wined3d_context *context,
5593 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5594 void state_pointsprite_w(struct wined3d_context *context,
5595 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5596 void state_pointsprite(struct wined3d_context *context,
5597 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5598 void state_shademode(struct wined3d_context *context,
5599 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
5601 /* Math utils */
5602 void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
5603 const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
5605 void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
5607 struct wined3d_shader_lconst
5609 struct list entry;
5610 unsigned int idx;
5611 DWORD value[4];
5614 struct wined3d_shader_limits
5616 unsigned int sampler;
5617 unsigned int constant_int;
5618 unsigned int constant_float;
5619 unsigned int constant_bool;
5620 unsigned int packed_output;
5621 unsigned int packed_input;
5624 #ifdef __GNUC__
5625 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
5626 #else
5627 #define PRINTF_ATTR(fmt,args)
5628 #endif
5630 struct wined3d_string_buffer_list
5632 struct list list;
5635 struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5636 void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN;
5637 void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5638 void string_buffer_list_init(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5639 void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5641 int shader_addline(struct wined3d_string_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
5642 BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc) DECLSPEC_HIDDEN;
5643 int shader_vaddline(struct wined3d_string_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
5645 struct wined3d_shader_phase
5647 const DWORD *start;
5648 const DWORD *end;
5649 unsigned int instance_count;
5650 unsigned int temporary_count;
5653 struct wined3d_vertex_shader
5655 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
5658 struct wined3d_hull_shader
5660 struct
5662 struct wined3d_shader_phase *control_point;
5663 unsigned int fork_count;
5664 unsigned int join_count;
5665 struct wined3d_shader_phase *fork;
5666 SIZE_T fork_size;
5667 struct wined3d_shader_phase *join;
5668 SIZE_T join_size;
5669 } phases;
5670 unsigned int output_vertex_count;
5671 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
5672 enum wined3d_tessellator_partitioning tessellator_partitioning;
5675 struct wined3d_domain_shader
5677 enum wined3d_tessellator_domain tessellator_domain;
5680 struct wined3d_geometry_shader
5682 enum wined3d_primitive_type input_type;
5683 enum wined3d_primitive_type output_type;
5684 unsigned int vertices_out;
5685 unsigned int instance_count;
5687 const struct wined3d_stream_output_desc *so_desc;
5690 struct wined3d_pixel_shader
5692 /* Pixel shader input semantics */
5693 DWORD input_reg_map[MAX_REG_INPUT];
5694 DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
5695 unsigned int declared_in_count;
5697 /* Some information about the shader behavior */
5698 BOOL color0_mov;
5699 DWORD color0_reg;
5701 BOOL force_early_depth_stencil;
5702 enum wined3d_shader_register_type depth_output;
5703 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
5706 struct wined3d_compute_shader
5708 struct wined3d_shader_thread_group_size thread_group_size;
5711 struct wined3d_shader
5713 LONG ref;
5714 const struct wined3d_shader_limits *limits;
5715 const DWORD *function;
5716 unsigned int functionLength;
5717 void *byte_code;
5718 unsigned int byte_code_size;
5719 BOOL load_local_constsF;
5720 const struct wined3d_shader_frontend *frontend;
5721 void *frontend_data;
5722 void *backend_data;
5724 void *parent;
5725 const struct wined3d_parent_ops *parent_ops;
5727 /* Programs this shader is linked with */
5728 struct list linked_programs;
5730 /* Immediate constants (override global ones) */
5731 struct list constantsB;
5732 struct list constantsF;
5733 struct list constantsI;
5734 struct wined3d_shader_reg_maps reg_maps;
5735 BOOL lconst_inf_or_nan;
5737 struct wined3d_shader_signature input_signature;
5738 struct wined3d_shader_signature output_signature;
5739 struct wined3d_shader_signature patch_constant_signature;
5741 /* Pointer to the parent device */
5742 struct wined3d_device *device;
5743 struct list shader_list_entry;
5745 union
5747 struct wined3d_vertex_shader vs;
5748 struct wined3d_hull_shader hs;
5749 struct wined3d_domain_shader ds;
5750 struct wined3d_geometry_shader gs;
5751 struct wined3d_pixel_shader ps;
5752 struct wined3d_compute_shader cs;
5753 } u;
5756 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
5757 unsigned int resource_idx, DWORD tex_types) DECLSPEC_HIDDEN;
5758 void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5759 BOOL position_transformed, struct ps_compile_args *args,
5760 const struct wined3d_context *context) DECLSPEC_HIDDEN;
5762 bool vshader_get_input(const struct wined3d_shader *shader,
5763 uint8_t usage_req, uint8_t usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
5764 void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5765 struct vs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5767 void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5768 struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5770 void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5771 struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5773 void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5774 BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5775 void string_buffer_free(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5776 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
5777 unsigned int max) DECLSPEC_HIDDEN;
5778 HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
5779 const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
5780 const DWORD *start, const DWORD *end) DECLSPEC_HIDDEN;
5781 BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
5783 static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
5785 switch (reg->type)
5787 case WINED3DSPR_RASTOUT:
5788 /* oFog & oPts */
5789 if (reg->idx[0].offset)
5790 return TRUE;
5791 /* oPos */
5792 return FALSE;
5794 case WINED3DSPR_CONSTBOOL: /* b# */
5795 case WINED3DSPR_DEPTHOUT: /* oDepth */
5796 case WINED3DSPR_DEPTHOUTGE:
5797 case WINED3DSPR_DEPTHOUTLE:
5798 case WINED3DSPR_LOOP: /* aL */
5799 case WINED3DSPR_OUTPOINTID:
5800 case WINED3DSPR_PREDICATE: /* p0 */
5801 case WINED3DSPR_PRIMID: /* primID */
5802 case WINED3DSPR_COVERAGE: /* vCoverage */
5803 case WINED3DSPR_SAMPLEMASK: /* oMask */
5804 return TRUE;
5806 case WINED3DSPR_MISCTYPE:
5807 switch (reg->idx[0].offset)
5809 case 0: /* vPos */
5810 return FALSE;
5811 case 1: /* vFace */
5812 return TRUE;
5813 default:
5814 return FALSE;
5817 case WINED3DSPR_IMMCONST:
5818 return reg->immconst_type == WINED3D_IMMCONST_SCALAR;
5820 default:
5821 return FALSE;
5825 static inline void shader_get_position_fixup(const struct wined3d_context *context,
5826 const struct wined3d_state *state, unsigned int fixup_count, float *position_fixup)
5828 float center_offset, x = 0.0f, y = 0.0f;
5829 unsigned int i;
5831 /* See get_projection_matrix() in utils.c for a discussion of the position fixup.
5832 * This function here also applies to d3d10+ which does not need adjustment for
5833 * integer pixel centers, but it may need the filling convention offset. */
5834 if (context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)
5835 center_offset = 1.0f;
5836 else
5837 center_offset = 0.0f;
5839 center_offset += context->d3d_info->filling_convention_offset;
5841 for (i = 0; i < fixup_count; ++i)
5843 position_fixup[4 * i ] = 1.0f;
5844 position_fixup[4 * i + 1] = 1.0f;
5845 if (!context->d3d_info->subpixel_viewport)
5847 double dummy;
5848 x = modf(state->viewports[i].x, &dummy) * 2.0f;
5849 y = modf(state->viewports[i].y, &dummy) * 2.0f;
5851 position_fixup[4 * i + 2] = (center_offset + x) / state->viewports[i].width;
5852 position_fixup[4 * i + 3] = -(center_offset + y) / state->viewports[i].height;
5854 if (context->render_offscreen)
5856 position_fixup[4 * i + 1] *= -1.0f;
5857 position_fixup[4 * i + 3] *= -1.0f;
5862 static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
5864 struct wined3d_shader_lconst *lconst;
5866 if (shader->load_local_constsF)
5867 return FALSE;
5869 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
5871 if (lconst->idx == reg)
5872 return TRUE;
5875 return FALSE;
5878 void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5879 void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5880 unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5881 void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5882 struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5883 void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5884 unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5885 void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state,
5886 float *out_min, float *out_max) DECLSPEC_HIDDEN;
5887 void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
5888 float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
5889 void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
5890 float *start, float *end) DECLSPEC_HIDDEN;
5892 /* Using additional shader constants (uniforms in GLSL / program environment
5893 * or local parameters in ARB) is costly:
5894 * ARB only knows float4 parameters and GLSL compiler are not really smart
5895 * when it comes to efficiently pack float2 uniforms, so no space is wasted
5896 * (in fact most compilers map a float2 to a full float4 uniform).
5898 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
5899 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
5900 * into a single shader constant (uniform / program parameter).
5902 * This structure is shared between the GLSL and the ARB backend.*/
5903 struct ps_np2fixup_info {
5904 unsigned char idx[WINED3D_MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
5905 WORD active; /* bitfield indicating if we can apply the fixup */
5906 WORD num_consts;
5909 void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL program) DECLSPEC_HIDDEN;
5910 void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLuint program) DECLSPEC_HIDDEN;
5912 struct wined3d_palette
5914 LONG ref;
5915 struct wined3d_device *device;
5917 unsigned int size;
5918 RGBQUAD colors[256];
5919 DWORD flags;
5922 /* DirectDraw utility functions */
5923 extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
5925 /*****************************************************************************
5926 * Pixel format management
5929 /* WineD3D pixel format flags */
5930 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x00000001
5931 #define WINED3DFMT_FLAG_FILTERING 0x00000002
5932 #define WINED3DFMT_FLAG_UNORDERED_ACCESS 0x00000004
5933 #define WINED3DFMT_FLAG_DEPTH_STENCIL 0x00000008
5934 #define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
5935 #define WINED3DFMT_FLAG_EXTENSION 0x00000020
5936 #define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
5937 #define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
5938 #define WINED3DFMT_FLAG_DECOMPRESS 0x00000100
5939 #define WINED3DFMT_FLAG_FLOAT 0x00000200
5940 #define WINED3DFMT_FLAG_BUMPMAP 0x00000400
5941 #define WINED3DFMT_FLAG_SRGB_READ 0x00000800
5942 #define WINED3DFMT_FLAG_SRGB_WRITE 0x00001000
5943 #define WINED3DFMT_FLAG_VTF 0x00002000
5944 #define WINED3DFMT_FLAG_SHADOW 0x00004000
5945 #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
5946 #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
5947 #define WINED3DFMT_FLAG_BLOCKS 0x00020000
5948 #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
5949 #define WINED3DFMT_FLAG_TEXTURE 0x00080000
5950 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
5951 #define WINED3DFMT_FLAG_INTEGER 0x00200000
5952 #define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
5953 #define WINED3DFMT_FLAG_NORMALISED 0x00800000
5954 #define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE 0x01000000
5955 #define WINED3DFMT_FLAG_BLIT 0x02000000
5956 #define WINED3DFMT_FLAG_MAPPABLE 0x04000000
5957 #define WINED3DFMT_FLAG_CAST_TO_BLOCK 0x08000000
5958 #define WINED3DFMT_FLAG_INDEX_BUFFER 0x10000000
5960 struct wined3d_rational
5962 UINT numerator;
5963 UINT denominator;
5966 struct wined3d_color_key_conversion
5968 enum wined3d_format_id dst_format;
5969 void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch,
5970 unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key);
5973 enum wined3d_channel_type
5975 WINED3D_CHANNEL_TYPE_NONE,
5976 WINED3D_CHANNEL_TYPE_UNORM,
5977 WINED3D_CHANNEL_TYPE_SNORM,
5978 WINED3D_CHANNEL_TYPE_UINT,
5979 WINED3D_CHANNEL_TYPE_SINT,
5980 WINED3D_CHANNEL_TYPE_FLOAT,
5981 WINED3D_CHANNEL_TYPE_DEPTH,
5982 WINED3D_CHANNEL_TYPE_STENCIL,
5983 WINED3D_CHANNEL_TYPE_UNUSED,
5986 struct wined3d_format
5988 enum wined3d_format_id id;
5990 D3DDDIFORMAT ddi_format;
5991 unsigned int component_count;
5992 DWORD red_size;
5993 DWORD green_size;
5994 DWORD blue_size;
5995 DWORD alpha_size;
5996 DWORD red_offset;
5997 DWORD green_offset;
5998 DWORD blue_offset;
5999 DWORD alpha_offset;
6000 UINT byte_count;
6001 BYTE depth_size;
6002 BYTE stencil_size;
6004 UINT block_width;
6005 UINT block_height;
6006 UINT block_byte_count;
6008 enum wined3d_ffp_emit_idx emit_idx;
6010 UINT conv_byte_count;
6011 DWORD multisample_types;
6012 unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
6013 float depth_bias_scale;
6014 struct wined3d_rational height_scale;
6015 struct color_fixup_desc color_fixup;
6016 void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
6017 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
6018 unsigned int width, unsigned int height, unsigned int depth);
6019 void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
6020 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
6021 unsigned int width, unsigned int height, unsigned int depth);
6022 void (*decompress)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
6023 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
6024 unsigned int width, unsigned int height, unsigned int depth);
6026 enum wined3d_format_id typeless_id;
6029 const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
6030 enum wined3d_format_id format_id, unsigned int bind_flags) DECLSPEC_HIDDEN;
6031 enum wined3d_format_id wined3d_get_typed_format_id(const struct wined3d_adapter *adapter,
6032 const struct wined3d_format *format, enum wined3d_channel_type channel_type) DECLSPEC_HIDDEN;
6033 void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
6034 unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
6035 UINT wined3d_format_calculate_size(const struct wined3d_format *format,
6036 UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
6037 DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
6038 const struct wined3d_color *color) DECLSPEC_HIDDEN;
6039 void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src,
6040 unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
6041 unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d) DECLSPEC_HIDDEN;
6042 void wined3d_format_get_float_color_key(const struct wined3d_format *format,
6043 const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
6044 BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
6045 enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
6046 const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
6047 const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
6048 uint32_t wined3d_format_pack(const struct wined3d_format *format, const struct wined3d_uvec4 *value) DECLSPEC_HIDDEN;
6049 BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
6050 enum wined3d_format_id format2) DECLSPEC_HIDDEN;
6052 struct wined3d_format_gl
6054 struct wined3d_format f;
6056 GLenum vtx_type;
6057 GLint vtx_format;
6059 GLint internal;
6060 GLint srgb_internal;
6061 GLint rt_internal;
6062 GLint format;
6063 GLint type;
6065 GLenum view_class;
6068 static inline const struct wined3d_format_gl *wined3d_format_gl(const struct wined3d_format *format)
6070 return CONTAINING_RECORD(format, struct wined3d_format_gl, f);
6073 struct wined3d_format_vk
6075 struct wined3d_format f;
6077 VkFormat vk_format;
6080 static inline const struct wined3d_format_vk *wined3d_format_vk(const struct wined3d_format *format)
6082 return CONTAINING_RECORD(format, struct wined3d_format_vk, f);
6085 BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
6087 static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
6089 return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
6092 static inline BOOL use_vs(const struct wined3d_state *state)
6094 /* Check state->vertex_declaration to allow this to be used before the
6095 * stream info is validated, for example in device_update_tex_unit_map(). */
6096 return state->shader[WINED3D_SHADER_TYPE_VERTEX]
6097 && (!state->vertex_declaration || !state->vertex_declaration->position_transformed);
6100 static inline BOOL use_ps(const struct wined3d_state *state)
6102 return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
6105 static inline BOOL use_transform_feedback(const struct wined3d_state *state)
6107 const struct wined3d_shader *shader;
6109 if (!(shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]))
6110 return FALSE;
6111 return !!shader->u.gs.so_desc;
6114 static inline void context_apply_state(struct wined3d_context *context,
6115 const struct wined3d_state *state, DWORD state_id)
6117 const struct wined3d_state_entry *state_table = context->state_table;
6118 unsigned int rep = state_table[state_id].representative;
6119 state_table[rep].apply(context, state, rep);
6122 static inline BOOL is_srgb_enabled(const DWORD *sampler_states)
6124 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
6125 * the behaviour of the AMD Windows driver.
6127 * Might & Magic: Heroes VI - Shades of Darkness sets
6128 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
6129 * pointer—presumably by accident—and expects sRGB decoding to be
6130 * disabled. */
6131 return sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
6134 static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
6135 const struct wined3d_texture *texture)
6137 if (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
6138 return FALSE;
6140 if (!context->d3d_info->srgb_read_control
6141 && (texture->resource.bind_flags & WINED3D_BIND_SHADER_RESOURCE)
6142 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_READ))
6143 return TRUE;
6145 if (!context->d3d_info->srgb_write_control
6146 && (texture->resource.bind_flags & WINED3D_BIND_RENDER_TARGET)
6147 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE))
6148 return TRUE;
6150 return FALSE;
6153 static inline BOOL needs_srgb_write(const struct wined3d_d3d_info *d3d_info,
6154 const struct wined3d_state *state, const struct wined3d_fb_state *fb)
6156 return (!(d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
6157 || state->render_states[WINED3D_RS_SRGBWRITEENABLE])
6158 && fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
6161 static inline GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl,
6162 const struct wined3d_context *context, BOOL srgb)
6164 return srgb && needs_separate_srgb_gl_texture(context, &texture_gl->t)
6165 ? texture_gl->texture_srgb.name : texture_gl->texture_rgb.name;
6168 static inline GLuint wined3d_gl_get_internal_format(struct wined3d_resource *resource,
6169 const struct wined3d_format_gl *format_gl, bool srgb)
6171 if (srgb)
6172 return format_gl->srgb_internal;
6173 else if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET && wined3d_resource_is_offscreen(resource))
6174 return format_gl->rt_internal;
6175 else
6176 return format_gl->internal;
6179 static inline BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
6181 return d3d_info->texture_swizzle && !is_complex_fixup(format->color_fixup) && !is_scaling_fixup(format->color_fixup);
6184 static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
6186 return geometry_shader && geometry_shader->u.gs.so_desc
6187 && geometry_shader->u.gs.so_desc->rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
6190 static inline uint32_t wined3d_mask_from_size(unsigned int size)
6192 return size < 32 ? (1u << size) - 1 : ~0u;
6195 static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
6196 unsigned int offset, unsigned int count)
6198 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
6199 const unsigned int idx = offset / word_bit_count;
6200 const unsigned int shift = offset % word_bit_count;
6201 DWORD mask = (1u << count) - 1;
6202 DWORD ret;
6204 ret = (bitstream[idx] >> shift) & mask;
6205 if (shift + count > word_bit_count)
6207 const unsigned int extracted_bit_count = word_bit_count - shift;
6208 const unsigned int remaining_bit_count = count - extracted_bit_count;
6209 mask = (1u << remaining_bit_count) - 1;
6210 ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
6212 return ret;
6215 static inline void wined3d_insert_bits(DWORD *bitstream,
6216 unsigned int offset, unsigned int count, DWORD bits)
6218 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
6219 const unsigned int idx = offset / word_bit_count;
6220 const unsigned int shift = offset % word_bit_count;
6221 DWORD mask = (1u << count) - 1;
6223 bitstream[idx] |= (bits & mask) << shift;
6224 if (shift + count > word_bit_count)
6226 const unsigned int inserted_bit_count = word_bit_count - shift;
6227 const unsigned int remaining_bit_count = count - inserted_bit_count;
6228 mask = (1u << remaining_bit_count) - 1;
6229 bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
6233 static inline void wined3d_from_cs(const struct wined3d_cs *cs)
6235 if (cs->thread)
6236 assert(cs->thread_id == GetCurrentThreadId());
6239 static inline void wined3d_not_from_cs(const struct wined3d_cs *cs)
6241 assert(cs->thread_id != GetCurrentThreadId());
6244 static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map,
6245 enum wined3d_material_color_source source)
6247 if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE))
6248 return source;
6249 if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR))
6250 return source;
6251 return WINED3D_MCS_MATERIAL;
6254 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse,
6255 enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient,
6256 enum wined3d_material_color_source *specular, const struct wined3d_state *state,
6257 const struct wined3d_stream_info *si)
6259 if (!state->render_states[WINED3D_RS_LIGHTING])
6261 *diffuse = WINED3D_MCS_COLOR1;
6262 *specular = WINED3D_MCS_COLOR2;
6263 *emissive = *ambient = WINED3D_MCS_MATERIAL;
6265 return;
6268 if (!state->render_states[WINED3D_RS_COLORVERTEX])
6270 *diffuse = *emissive = *ambient = *specular = WINED3D_MCS_MATERIAL;
6272 return;
6275 *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]);
6276 *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]);
6277 *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]);
6278 *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]);
6281 static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,
6282 const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
6284 struct wined3d_vec4 tmp;
6286 tmp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31 + v->w * m->_41;
6287 tmp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32 + v->w * m->_42;
6288 tmp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33 + v->w * m->_43;
6289 tmp.w = v->x * m->_14 + v->y * m->_24 + v->z * m->_34 + v->w * m->_44;
6291 *dst = tmp;
6294 BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
6296 void compute_normal_matrix(float *normal_matrix, BOOL legacy_lighting,
6297 const struct wined3d_matrix *modelview) DECLSPEC_HIDDEN;
6299 static inline struct wined3d_context *context_acquire(struct wined3d_device *device,
6300 struct wined3d_texture *texture, unsigned int sub_resource_idx)
6302 wined3d_from_cs(device->cs);
6304 return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx);
6307 static inline void context_release(struct wined3d_context *context)
6309 context->device->adapter->adapter_ops->adapter_release_context(context);
6312 static inline float wined3d_get_float_state(const struct wined3d_state *state, enum wined3d_render_state rs)
6314 union
6316 DWORD d;
6317 float f;
6319 tmpvalue;
6321 tmpvalue.d = state->render_states[rs];
6322 return tmpvalue.f;
6325 static inline void *wined3d_context_map_bo_address(struct wined3d_context *context,
6326 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags)
6328 return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, map_flags);
6331 static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context,
6332 const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
6334 context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, range_count, ranges);
6337 static inline void wined3d_context_copy_bo_address(struct wined3d_context *context,
6338 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
6340 context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, size);
6343 static inline void wined3d_context_flush_bo_address(struct wined3d_context *context,
6344 const struct wined3d_const_bo_address *data, size_t size)
6346 context->device->adapter->adapter_ops->adapter_flush_bo_address(context, data, size);
6349 static inline void wined3d_context_destroy_bo(struct wined3d_context *context, struct wined3d_bo *bo)
6351 context->device->adapter->adapter_ops->adapter_destroy_bo(context, bo);
6354 static inline void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk,
6355 struct wined3d_bo_vk *bo)
6357 bo->command_buffer_id = context_vk->current_command_buffer.id;
6360 static inline void wined3d_context_vk_reference_image(const struct wined3d_context_vk *context_vk,
6361 struct wined3d_image_vk *image)
6363 image->command_buffer_id = context_vk->current_command_buffer.id;
6366 static inline void wined3d_context_vk_reference_texture(const struct wined3d_context_vk *context_vk,
6367 struct wined3d_texture_vk *texture_vk)
6369 wined3d_context_vk_reference_image(context_vk, &texture_vk->image);
6372 static inline void wined3d_context_vk_reference_resource(const struct wined3d_context_vk *context_vk,
6373 struct wined3d_resource *resource)
6375 if (resource->type == WINED3D_RTYPE_BUFFER)
6376 wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer_from_resource(resource)->buffer_object));
6377 else
6378 wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource)));
6381 static inline void wined3d_context_vk_reference_query(const struct wined3d_context_vk *context_vk,
6382 struct wined3d_query_vk *query_vk)
6384 query_vk->command_buffer_id = context_vk->current_command_buffer.id;
6387 static inline void wined3d_context_vk_reference_sampler(const struct wined3d_context_vk *context_vk,
6388 struct wined3d_sampler_vk *sampler_vk)
6390 sampler_vk->command_buffer_id = context_vk->current_command_buffer.id;
6393 static inline void wined3d_context_vk_reference_rendertarget_view(const struct wined3d_context_vk *context_vk,
6394 struct wined3d_rendertarget_view_vk *rtv_vk)
6396 wined3d_context_vk_reference_resource(context_vk, rtv_vk->v.resource);
6397 rtv_vk->command_buffer_id = context_vk->current_command_buffer.id;
6400 static inline void wined3d_context_vk_reference_shader_resource_view(const struct wined3d_context_vk *context_vk,
6401 struct wined3d_shader_resource_view_vk *srv_vk)
6403 wined3d_context_vk_reference_resource(context_vk, srv_vk->v.resource);
6404 srv_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
6407 static inline void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk *context_vk,
6408 struct wined3d_unordered_access_view_vk *uav_vk)
6410 wined3d_context_vk_reference_resource(context_vk, uav_vk->v.resource);
6411 uav_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
6414 static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view *dsv,
6415 const struct wined3d_format *srv_format)
6417 return !srv_format || (srv_format->red_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_DEPTH))
6418 || (srv_format->green_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_STENCIL));
6421 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture *texture)
6423 return texture->resource.type == WINED3D_RTYPE_TEXTURE_3D ? texture->resource.depth : texture->layer_count;
6426 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view *srv)
6428 struct wined3d_texture *texture;
6430 if (srv->resource->type == WINED3D_RTYPE_BUFFER)
6431 return TRUE;
6433 if (srv->desc.u.texture.layer_idx || srv->desc.u.texture.level_idx)
6434 return FALSE;
6436 texture = texture_from_resource(srv->resource);
6437 return srv->desc.u.texture.level_count == texture->level_count
6438 && srv->desc.u.texture.layer_count == wined3d_bind_layer_count(texture);
6441 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view *rtv)
6443 struct wined3d_texture *texture;
6445 if (rtv->resource->type == WINED3D_RTYPE_BUFFER)
6446 return TRUE;
6448 if (rtv->sub_resource_idx)
6449 return FALSE;
6451 texture = texture_from_resource(rtv->resource);
6452 return texture->level_count == 1 && rtv->layer_count == wined3d_bind_layer_count(texture);
6455 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view *srv)
6457 InterlockedIncrement(&srv->resource->srv_bind_count_device);
6460 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view *srv)
6462 InterlockedDecrement(&srv->resource->srv_bind_count_device);
6465 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view *rtv)
6467 InterlockedIncrement(&rtv->resource->rtv_bind_count_device);
6470 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view *rtv)
6472 InterlockedDecrement(&rtv->resource->rtv_bind_count_device);
6475 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view *rtv,
6476 const struct wined3d_shader_resource_view *srv)
6478 if (rtv->resource != srv->resource)
6479 return false;
6481 if (wined3d_srv_all_subresources(srv) || wined3d_rtv_all_subresources(rtv))
6482 return true;
6484 return rtv->sub_resource_idx >= srv->desc.u.texture.level_idx
6485 && rtv->sub_resource_idx < srv->desc.u.texture.level_idx + srv->desc.u.texture.level_count
6486 && rtv->layer_count >= srv->desc.u.texture.layer_idx;
6489 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_state *state,
6490 const struct wined3d_shader_resource_view *srv)
6492 unsigned int i;
6494 if (!srv->resource->rtv_bind_count_device)
6495 return false;
6497 for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
6499 const struct wined3d_rendertarget_view *rtv;
6501 if ((rtv = state->fb.render_targets[i]) && wined3d_rtv_overlaps_srv(rtv, srv))
6502 return true;
6505 return false;
6508 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
6510 *min_z = vp->min_z;
6512 /* The magic constant is derived from tests. */
6513 *max_z = max(vp->max_z, vp->min_z + 0.001f);
6516 static inline BOOL wined3d_bitmap_clear(uint32_t *map, unsigned int idx)
6518 return map[idx >> 5] &= ~(1u << (idx & 0x1f));
6521 static inline BOOL wined3d_bitmap_set(uint32_t *map, unsigned int idx)
6523 return map[idx >> 5] |= (1u << (idx & 0x1f));
6526 static inline BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx)
6528 return map[idx >> 5] & (1u << (idx & 0x1f));
6531 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap, unsigned int bit_count,
6532 unsigned int start, uint32_t xor_mask)
6534 const unsigned int word_bit_count = sizeof(*bitmap) * CHAR_BIT;
6535 const uint32_t *ptr, *end_ptr;
6536 uint32_t map, mask;
6538 assert(bit_count < word_bit_count || !(bit_count % word_bit_count));
6540 ptr = bitmap + start / word_bit_count;
6541 end_ptr = bitmap + (bit_count + word_bit_count - 1) / word_bit_count;
6543 if (ptr >= end_ptr)
6544 return ~0u;
6546 mask = ~0u << start % word_bit_count;
6547 map = (*ptr ^ xor_mask) & mask;
6548 while (!map)
6550 if (++ptr == end_ptr)
6551 return ~0u;
6552 map = *ptr ^ xor_mask;
6554 return (ptr - bitmap) * word_bit_count + wined3d_bit_scan(&map);
6557 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
6559 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, 0);
6562 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
6564 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, ~0u);
6567 static inline BOOL wined3d_bitmap_get_range(const DWORD *bitmap, unsigned int bit_count,
6568 unsigned int start, struct wined3d_range *range)
6570 unsigned int range_start, range_end;
6572 range_start = wined3d_bitmap_ffs(bitmap, bit_count, start);
6573 if (range_start == ~0u)
6574 return FALSE;
6576 range_end = wined3d_bitmap_ffz(bitmap, bit_count, range_start + 1);
6577 if (range_end == ~0u)
6578 range_end = bit_count;
6580 range->offset = range_start;
6581 range->size = range_end - range_start;
6582 return TRUE;
6585 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context *context, unsigned int state_id)
6587 return wined3d_bitmap_is_set(context->dirty_graphics_states, state_id);
6590 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context *context, unsigned int state_id)
6592 return wined3d_bitmap_is_set(context->dirty_compute_states, state_id - STATE_COMPUTE_OFFSET);
6595 static inline bool isStateDirty(const struct wined3d_context *context, unsigned int state_id)
6597 return wined3d_context_is_graphics_state_dirty(context, state_id);
6600 static inline VkImageAspectFlags vk_aspect_mask_from_format(const struct wined3d_format *format)
6602 VkImageAspectFlags mask = 0;
6604 if (format->depth_size)
6605 mask |= VK_IMAGE_ASPECT_DEPTH_BIT;
6606 if (format->stencil_size)
6607 mask |= VK_IMAGE_ASPECT_STENCIL_BIT;
6608 if (!mask || format->red_size || format->green_size || format->blue_size || format->alpha_size)
6609 mask |= VK_IMAGE_ASPECT_COLOR_BIT;
6611 return mask;
6614 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t)
6616 return t == WINED3D_PT_POINTLIST
6617 || t == WINED3D_PT_LINELIST
6618 || t == WINED3D_PT_TRIANGLELIST
6619 || t == WINED3D_PT_LINELIST_ADJ
6620 || t == WINED3D_PT_TRIANGLELIST_ADJ
6621 || t == WINED3D_PT_PATCH;
6624 static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo_gl)
6626 struct wined3d_device_gl *device_gl = wined3d_device_gl(context_gl->c.device);
6628 bo_gl->command_fence_id = device_gl->current_fence_id;
6631 static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl *context_gl,
6632 struct wined3d_buffer *buffer)
6634 wined3d_context_gl_reference_bo(context_gl, wined3d_bo_gl(buffer->buffer_object));
6637 static inline bool wined3d_map_persistent(void)
6639 return sizeof(void *) >= sizeof(uint64_t);
6642 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
6643 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
6645 extern CRITICAL_SECTION wined3d_command_cs;
6647 #endif