wined3d: Implement Vulkan NULL 1D image shader resource view descriptors.
[wine.git] / dlls / wined3d / wined3d_private.h
blob6124eabe18595facaec6934e3f3af68ca0074f2d
1 /*
2 * Direct3D wine internal private include file
4 * Copyright 2002-2003 The wine-d3d team
5 * Copyright 2002-2003 Raphael Junqueira
6 * Copyright 2002-2003, 2004 Jason Edmeades
7 * Copyright 2005 Oliver Stieber
8 * Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #ifndef __WINE_WINED3D_PRIVATE_H
26 #define __WINE_WINED3D_PRIVATE_H
28 #ifdef USE_WIN32_OPENGL
29 #define WINE_GLAPI __stdcall
30 #else
31 #define WINE_GLAPI
32 #endif
34 #include <assert.h>
35 #include <stdarg.h>
36 #include <stdbool.h>
37 #include <math.h>
38 #include <limits.h>
39 #include "ntstatus.h"
40 #define WIN32_NO_STATUS
41 #define NONAMELESSUNION
42 #define NONAMELESSSTRUCT
43 #define COBJMACROS
44 #include "windef.h"
45 #include "winbase.h"
46 #include "winreg.h"
47 #include "wingdi.h"
48 #include "winuser.h"
49 #include "winternl.h"
50 #include "ddk/d3dkmthk.h"
51 #include "wine/debug.h"
52 #include "wine/heap.h"
53 #include "wine/unicode.h"
55 #include "objbase.h"
56 #include "wine/wined3d.h"
57 #include "wined3d_gl.h"
58 #include "wined3d_vk.h"
59 #include "wine/list.h"
60 #include "wine/rbtree.h"
61 #include "wine/wgl_driver.h"
63 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
65 /* Driver quirks */
66 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
67 #define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
68 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
69 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
70 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
71 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
72 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
73 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
74 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
75 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
76 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
78 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
80 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
81 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
83 #define WINED3D_BITMAP_SIZE(x) (((x) + 31) >> 5)
85 struct wined3d_fragment_pipe_ops;
86 struct wined3d_adapter;
87 struct wined3d_buffer_vk;
88 struct wined3d_context;
89 struct wined3d_gl_info;
90 struct wined3d_state;
91 struct wined3d_swapchain_gl;
92 struct wined3d_texture_gl;
93 struct wined3d_vertex_pipe_ops;
95 enum wined3d_ffp_idx
97 WINED3D_FFP_POSITION = 0,
98 WINED3D_FFP_BLENDWEIGHT = 1,
99 WINED3D_FFP_BLENDINDICES = 2,
100 WINED3D_FFP_NORMAL = 3,
101 WINED3D_FFP_PSIZE = 4,
102 WINED3D_FFP_DIFFUSE = 5,
103 WINED3D_FFP_SPECULAR = 6,
104 WINED3D_FFP_TEXCOORD0 = 7,
105 WINED3D_FFP_TEXCOORD1 = 8,
106 WINED3D_FFP_TEXCOORD2 = 9,
107 WINED3D_FFP_TEXCOORD3 = 10,
108 WINED3D_FFP_TEXCOORD4 = 11,
109 WINED3D_FFP_TEXCOORD5 = 12,
110 WINED3D_FFP_TEXCOORD6 = 13,
111 WINED3D_FFP_TEXCOORD7 = 14,
112 WINED3D_FFP_ATTRIBS_COUNT = 15,
115 enum wined3d_ffp_emit_idx
117 WINED3D_FFP_EMIT_FLOAT1,
118 WINED3D_FFP_EMIT_FLOAT2,
119 WINED3D_FFP_EMIT_FLOAT3,
120 WINED3D_FFP_EMIT_FLOAT4,
121 WINED3D_FFP_EMIT_D3DCOLOR,
122 WINED3D_FFP_EMIT_UBYTE4,
123 WINED3D_FFP_EMIT_SHORT2,
124 WINED3D_FFP_EMIT_SHORT4,
125 WINED3D_FFP_EMIT_UBYTE4N,
126 WINED3D_FFP_EMIT_SHORT2N,
127 WINED3D_FFP_EMIT_SHORT4N,
128 WINED3D_FFP_EMIT_USHORT2N,
129 WINED3D_FFP_EMIT_USHORT4N,
130 WINED3D_FFP_EMIT_UDEC3,
131 WINED3D_FFP_EMIT_DEC3N,
132 WINED3D_FFP_EMIT_FLOAT16_2,
133 WINED3D_FFP_EMIT_FLOAT16_4,
134 WINED3D_FFP_EMIT_INVALID,
135 WINED3D_FFP_EMIT_COUNT,
138 /* Texture format fixups */
140 enum fixup_channel_source
142 CHANNEL_SOURCE_ZERO = 0,
143 CHANNEL_SOURCE_ONE = 1,
144 CHANNEL_SOURCE_X = 2,
145 CHANNEL_SOURCE_Y = 3,
146 CHANNEL_SOURCE_Z = 4,
147 CHANNEL_SOURCE_W = 5,
148 CHANNEL_SOURCE_COMPLEX0 = 6,
149 CHANNEL_SOURCE_COMPLEX1 = 7,
152 enum complex_fixup
154 COMPLEX_FIXUP_NONE = 0,
155 COMPLEX_FIXUP_YUY2 = 1,
156 COMPLEX_FIXUP_UYVY = 2,
157 COMPLEX_FIXUP_YV12 = 3,
158 COMPLEX_FIXUP_P8 = 4,
159 COMPLEX_FIXUP_NV12 = 5,
160 COMPLEX_FIXUP_YUV = 6,
163 #include <pshpack2.h>
164 struct color_fixup_desc
166 unsigned short x_sign_fixup : 1;
167 unsigned short x_source : 3;
168 unsigned short y_sign_fixup : 1;
169 unsigned short y_source : 3;
170 unsigned short z_sign_fixup : 1;
171 unsigned short z_source : 3;
172 unsigned short w_sign_fixup : 1;
173 unsigned short w_source : 3;
175 #include <poppack.h>
177 struct wined3d_d3d_limits
179 unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
180 DWORD vs_uniform_count;
181 DWORD ps_uniform_count;
182 unsigned int varying_count;
183 unsigned int ffp_textures;
184 unsigned int ffp_blend_stages;
185 unsigned int ffp_vertex_blend_matrices;
186 unsigned int active_light_count;
188 unsigned int max_rt_count;
189 unsigned int max_clip_distances;
190 unsigned int texture_size;
191 float pointsize_max;
194 typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
195 typedef void (WINE_GLAPI *wined3d_ffp_texcoord_func)(GLenum unit, const void *data);
196 typedef void (WINE_GLAPI *wined3d_generic_attrib_func)(GLuint idx, const void *data);
197 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
199 struct wined3d_ffp_attrib_ops
201 wined3d_ffp_attrib_func position[WINED3D_FFP_EMIT_COUNT];
202 wined3d_ffp_attrib_func diffuse[WINED3D_FFP_EMIT_COUNT];
203 wined3d_ffp_attrib_func specular[WINED3D_FFP_EMIT_COUNT];
204 wined3d_ffp_attrib_func normal[WINED3D_FFP_EMIT_COUNT];
205 wined3d_ffp_texcoord_func texcoord[WINED3D_FFP_EMIT_COUNT];
206 wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT];
209 struct wined3d_d3d_info
211 struct wined3d_d3d_limits limits;
212 struct wined3d_ffp_attrib_ops ffp_attrib_ops;
213 uint32_t wined3d_creation_flags;
214 uint32_t xyzrhw : 1;
215 uint32_t emulated_flatshading : 1;
216 uint32_t ffp_generic_attributes : 1;
217 uint32_t ffp_alpha_test : 1;
218 uint32_t vs_clipping : 1;
219 uint32_t shader_color_key : 1;
220 uint32_t shader_double_precision : 1;
221 uint32_t shader_output_interpolation : 1;
222 uint32_t viewport_array_index_any_shader : 1;
223 uint32_t texture_npot : 1;
224 uint32_t texture_npot_conditional : 1;
225 uint32_t draw_base_vertex_offset : 1;
226 uint32_t vertex_bgra : 1;
227 uint32_t texture_swizzle : 1;
228 uint32_t srgb_read_control : 1;
229 uint32_t srgb_write_control : 1;
230 uint32_t clip_control : 1;
231 uint32_t full_ffp_varyings : 1;
232 uint32_t scaled_resolve : 1;
233 enum wined3d_feature_level feature_level;
235 DWORD multisample_draw_location;
238 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
239 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
241 static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
243 struct color_fixup_desc fixup =
245 0u, complex_fixup & (1u << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
246 0u, complex_fixup & (1u << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
247 0u, complex_fixup & (1u << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
248 0u, complex_fixup & (1u << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
250 return fixup;
253 static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
255 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
258 static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
260 return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
263 static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
265 return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
268 static inline BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
270 return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
271 && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
272 && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
273 && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
276 static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
278 enum complex_fixup complex_fixup = 0;
279 if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
280 if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
281 if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
282 if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
283 return complex_fixup;
286 /* Device caps */
287 #define WINED3D_MAX_ACTIVE_LIGHTS 8
288 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
289 #define MAX_CONSTANT_BUFFERS 15
290 #define MAX_SAMPLER_OBJECTS 16
291 #define MAX_SHADER_RESOURCE_VIEWS 128
292 #define MAX_UNORDERED_ACCESS_VIEWS 8
293 #define MAX_TGSM_REGISTERS 8192
294 #define MAX_VERTEX_BLENDS 4
296 struct min_lookup
298 GLenum mip[WINED3D_TEXF_LINEAR + 1];
301 extern const struct min_lookup minMipLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
302 extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
304 GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN;
305 VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags) DECLSPEC_HIDDEN;
306 VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op) DECLSPEC_HIDDEN;
307 VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags) DECLSPEC_HIDDEN;
308 VkShaderStageFlagBits vk_shader_stage_from_wined3d(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
310 static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
312 if (func < WINED3D_CMP_NEVER || func > WINED3D_CMP_ALWAYS)
313 return WINED3D_CMP_ALWAYS;
314 return func;
317 static inline GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
319 return magLookup[mag_filter];
322 static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,
323 enum wined3d_texture_filter_type mip_filter)
325 return minMipLookup[min_filter].mip[mip_filter];
328 /* float_16_to_32() and float_32_to_16() (see implementation in
329 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
330 * to standard C floats and vice versa. They do not depend on the encoding
331 * of the C float, so they are platform independent, but slow. On x86 and
332 * other IEEE 754 compliant platforms the conversion can be accelerated by
333 * bit shifting the exponent and mantissa. There are also some SSE-based
334 * assembly routines out there.
336 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
338 static inline float float_16_to_32(const unsigned short *in)
340 const unsigned short s = ((*in) & 0x8000u);
341 const unsigned short e = ((*in) & 0x7c00u) >> 10;
342 const unsigned short m = (*in) & 0x3ffu;
343 const float sgn = (s ? -1.0f : 1.0f);
345 if(e == 0) {
346 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
347 else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
348 } else if(e < 31) {
349 return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
350 } else {
351 if(m == 0) return sgn * INFINITY;
352 else return NAN;
356 static inline float float_24_to_32(DWORD in)
358 const float sgn = in & 0x800000u ? -1.0f : 1.0f;
359 const unsigned short e = (in & 0x780000u) >> 19;
360 const unsigned int m = in & 0x7ffffu;
362 if (e == 0)
364 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
365 else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
367 else if (e < 15)
369 return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
371 else
373 if (m == 0) return sgn * INFINITY;
374 else return NAN;
378 static inline unsigned int wined3d_popcount(unsigned int x)
380 #ifdef HAVE___BUILTIN_POPCOUNT
381 return __builtin_popcount(x);
382 #else
383 x -= x >> 1 & 0x55555555;
384 x = (x & 0x33333333) + (x >> 2 & 0x33333333);
385 return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
386 #endif
389 static inline void wined3d_pause(void)
391 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
392 __asm__ __volatile__( "rep;nop" : : : "memory" );
393 #endif
396 #define ORM_BACKBUFFER 0
397 #define ORM_FBO 1
399 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
400 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
402 enum wined3d_renderer
404 WINED3D_RENDERER_AUTO,
405 WINED3D_RENDERER_VULKAN,
406 WINED3D_RENDERER_OPENGL,
407 WINED3D_RENDERER_NO3D,
410 enum wined3d_shader_backend
412 WINED3D_SHADER_BACKEND_AUTO,
413 WINED3D_SHADER_BACKEND_GLSL,
414 WINED3D_SHADER_BACKEND_ARB,
415 WINED3D_SHADER_BACKEND_NONE,
418 /* NOTE: When adding fields to this structure, make sure to update the default
419 * values in wined3d_main.c as well. */
420 struct wined3d_settings
422 unsigned int cs_multithreaded;
423 DWORD max_gl_version;
424 int offscreen_rendering_mode;
425 unsigned short pci_vendor_id;
426 unsigned short pci_device_id;
427 /* Memory tracking and object counting. */
428 UINT64 emulated_textureram;
429 char *logo;
430 unsigned int multisample_textures;
431 unsigned int sample_count;
432 BOOL check_float_constants;
433 unsigned int strict_shader_math;
434 unsigned int max_sm_vs;
435 unsigned int max_sm_hs;
436 unsigned int max_sm_ds;
437 unsigned int max_sm_gs;
438 unsigned int max_sm_ps;
439 unsigned int max_sm_cs;
440 enum wined3d_renderer renderer;
441 enum wined3d_shader_backend shader_backend;
444 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
446 enum wined3d_shader_byte_code_format
448 WINED3D_SHADER_BYTE_CODE_FORMAT_SM1,
449 WINED3D_SHADER_BYTE_CODE_FORMAT_SM4,
452 enum wined3d_shader_resource_type
454 WINED3D_SHADER_RESOURCE_NONE,
455 WINED3D_SHADER_RESOURCE_BUFFER,
456 WINED3D_SHADER_RESOURCE_TEXTURE_1D,
457 WINED3D_SHADER_RESOURCE_TEXTURE_2D,
458 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
459 WINED3D_SHADER_RESOURCE_TEXTURE_3D,
460 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
461 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
462 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
463 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
464 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
467 #define WINED3D_SHADER_CONST_VS_F 0x00000001
468 #define WINED3D_SHADER_CONST_VS_I 0x00000002
469 #define WINED3D_SHADER_CONST_VS_B 0x00000004
470 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
471 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
472 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
473 #define WINED3D_SHADER_CONST_PS_F 0x00000040
474 #define WINED3D_SHADER_CONST_PS_I 0x00000080
475 #define WINED3D_SHADER_CONST_PS_B 0x00000100
476 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
477 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
478 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
479 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
480 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
481 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
482 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
483 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
484 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
485 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
486 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
487 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
488 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
489 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
491 enum wined3d_shader_register_type
493 WINED3DSPR_TEMP = 0,
494 WINED3DSPR_INPUT = 1,
495 WINED3DSPR_CONST = 2,
496 WINED3DSPR_ADDR = 3,
497 WINED3DSPR_TEXTURE = 3,
498 WINED3DSPR_RASTOUT = 4,
499 WINED3DSPR_ATTROUT = 5,
500 WINED3DSPR_TEXCRDOUT = 6,
501 WINED3DSPR_OUTPUT = 6,
502 WINED3DSPR_CONSTINT = 7,
503 WINED3DSPR_COLOROUT = 8,
504 WINED3DSPR_DEPTHOUT = 9,
505 WINED3DSPR_SAMPLER = 10,
506 WINED3DSPR_CONST2 = 11,
507 WINED3DSPR_CONST3 = 12,
508 WINED3DSPR_CONST4 = 13,
509 WINED3DSPR_CONSTBOOL = 14,
510 WINED3DSPR_LOOP = 15,
511 WINED3DSPR_TEMPFLOAT16 = 16,
512 WINED3DSPR_MISCTYPE = 17,
513 WINED3DSPR_LABEL = 18,
514 WINED3DSPR_PREDICATE = 19,
515 WINED3DSPR_IMMCONST,
516 WINED3DSPR_CONSTBUFFER,
517 WINED3DSPR_IMMCONSTBUFFER,
518 WINED3DSPR_PRIMID,
519 WINED3DSPR_NULL,
520 WINED3DSPR_RESOURCE,
521 WINED3DSPR_UAV,
522 WINED3DSPR_OUTPOINTID,
523 WINED3DSPR_FORKINSTID,
524 WINED3DSPR_JOININSTID,
525 WINED3DSPR_INCONTROLPOINT,
526 WINED3DSPR_OUTCONTROLPOINT,
527 WINED3DSPR_PATCHCONST,
528 WINED3DSPR_TESSCOORD,
529 WINED3DSPR_GROUPSHAREDMEM,
530 WINED3DSPR_THREADID,
531 WINED3DSPR_THREADGROUPID,
532 WINED3DSPR_LOCALTHREADID,
533 WINED3DSPR_LOCALTHREADINDEX,
534 WINED3DSPR_IDXTEMP,
535 WINED3DSPR_STREAM,
536 WINED3DSPR_FUNCTIONBODY,
537 WINED3DSPR_FUNCTIONPOINTER,
538 WINED3DSPR_COVERAGE,
539 WINED3DSPR_SAMPLEMASK,
540 WINED3DSPR_GSINSTID,
541 WINED3DSPR_DEPTHOUTGE,
542 WINED3DSPR_DEPTHOUTLE,
543 WINED3DSPR_RASTERIZER,
546 enum wined3d_data_type
548 WINED3D_DATA_FLOAT,
549 WINED3D_DATA_INT,
550 WINED3D_DATA_RESOURCE,
551 WINED3D_DATA_SAMPLER,
552 WINED3D_DATA_UAV,
553 WINED3D_DATA_UINT,
554 WINED3D_DATA_UNORM,
555 WINED3D_DATA_SNORM,
556 WINED3D_DATA_OPAQUE,
559 enum wined3d_immconst_type
561 WINED3D_IMMCONST_SCALAR,
562 WINED3D_IMMCONST_VEC4,
565 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
567 enum wined3d_shader_src_modifier
569 WINED3DSPSM_NONE = 0,
570 WINED3DSPSM_NEG = 1,
571 WINED3DSPSM_BIAS = 2,
572 WINED3DSPSM_BIASNEG = 3,
573 WINED3DSPSM_SIGN = 4,
574 WINED3DSPSM_SIGNNEG = 5,
575 WINED3DSPSM_COMP = 6,
576 WINED3DSPSM_X2 = 7,
577 WINED3DSPSM_X2NEG = 8,
578 WINED3DSPSM_DZ = 9,
579 WINED3DSPSM_DW = 10,
580 WINED3DSPSM_ABS = 11,
581 WINED3DSPSM_ABSNEG = 12,
582 WINED3DSPSM_NOT = 13,
585 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
586 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
587 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
588 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
589 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
591 enum wined3d_shader_dst_modifier
593 WINED3DSPDM_NONE = 0,
594 WINED3DSPDM_SATURATE = 1,
595 WINED3DSPDM_PARTIALPRECISION = 2,
596 WINED3DSPDM_MSAMPCENTROID = 4,
599 enum wined3d_shader_interpolation_mode
601 WINED3DSIM_NONE = 0,
602 WINED3DSIM_CONSTANT = 1,
603 WINED3DSIM_LINEAR = 2,
604 WINED3DSIM_LINEAR_CENTROID = 3,
605 WINED3DSIM_LINEAR_NOPERSPECTIVE = 4,
606 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
607 WINED3DSIM_LINEAR_SAMPLE = 6,
608 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
611 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
612 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
614 enum wined3d_shader_global_flags
616 WINED3DSGF_REFACTORING_ALLOWED = 0x1,
617 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4,
618 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8,
621 enum wined3d_shader_sync_flags
623 WINED3DSSF_THREAD_GROUP = 0x1,
624 WINED3DSSF_GROUP_SHARED_MEMORY = 0x2,
627 enum wined3d_shader_uav_flags
629 WINED3DSUF_GLOBALLY_COHERENT = 0x2,
630 WINED3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
633 enum wined3d_tessellator_domain
635 WINED3D_TESSELLATOR_DOMAIN_LINE = 1,
636 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
637 WINED3D_TESSELLATOR_DOMAIN_QUAD = 3,
640 enum wined3d_tessellator_output_primitive
642 WINED3D_TESSELLATOR_OUTPUT_POINT = 1,
643 WINED3D_TESSELLATOR_OUTPUT_LINE = 2,
644 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
645 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
648 enum wined3d_tessellator_partitioning
650 WINED3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
651 WINED3D_TESSELLATOR_PARTITIONING_POW2 = 2,
652 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
653 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
656 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
657 #define WINED3DSI_TEXLD_PROJECT 0x1
658 #define WINED3DSI_TEXLD_BIAS 0x2
659 #define WINED3DSI_INDEXED_DYNAMIC 0x4
660 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
661 #define WINED3DSI_RESINFO_UINT 0x2
662 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
663 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
665 #define WINED3DSI_PRECISE_X 0x100
666 #define WINED3DSI_PRECISE_Y 0x200
667 #define WINED3DSI_PRECISE_Z 0x400
668 #define WINED3DSI_PRECISE_W 0x800
669 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
670 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
671 #define WINED3DSI_PRECISE_SHIFT 8
673 enum wined3d_shader_rel_op
675 WINED3D_SHADER_REL_OP_GT = 1,
676 WINED3D_SHADER_REL_OP_EQ = 2,
677 WINED3D_SHADER_REL_OP_GE = 3,
678 WINED3D_SHADER_REL_OP_LT = 4,
679 WINED3D_SHADER_REL_OP_NE = 5,
680 WINED3D_SHADER_REL_OP_LE = 6,
683 enum wined3d_shader_conditional_op
685 WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
686 WINED3D_SHADER_CONDITIONAL_OP_Z = 1
689 #define WINED3D_SM1_VS 0xfffeu
690 #define WINED3D_SM1_PS 0xffffu
691 #define WINED3D_SM4_PS 0x0000u
692 #define WINED3D_SM4_VS 0x0001u
693 #define WINED3D_SM4_GS 0x0002u
694 #define WINED3D_SM5_HS 0x0003u
695 #define WINED3D_SM5_DS 0x0004u
696 #define WINED3D_SM5_CS 0x0005u
698 /* Shader version tokens, and shader end tokens */
699 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
700 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
702 /* Shader backends */
704 /* TODO: Make this dynamic, based on shader limits ? */
705 #define MAX_ATTRIBS 16
706 #define MAX_REG_ADDR 1
707 #define MAX_REG_TEXCRD 8
708 #define MAX_REG_INPUT 32
709 #define MAX_REG_OUTPUT 32
710 #define WINED3D_MAX_CBS 15
712 /* FIXME: This needs to go up to 2048 for
713 * Shader model 3 according to msdn (and for software shaders) */
714 #define MAX_LABELS 16
716 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
718 struct wined3d_string_buffer
720 struct list entry;
721 char *buffer;
722 unsigned int buffer_size;
723 unsigned int content_size;
726 enum WINED3D_SHADER_INSTRUCTION_HANDLER
728 WINED3DSIH_ABS,
729 WINED3DSIH_ADD,
730 WINED3DSIH_AND,
731 WINED3DSIH_ATOMIC_AND,
732 WINED3DSIH_ATOMIC_CMP_STORE,
733 WINED3DSIH_ATOMIC_IADD,
734 WINED3DSIH_ATOMIC_IMAX,
735 WINED3DSIH_ATOMIC_IMIN,
736 WINED3DSIH_ATOMIC_OR,
737 WINED3DSIH_ATOMIC_UMAX,
738 WINED3DSIH_ATOMIC_UMIN,
739 WINED3DSIH_ATOMIC_XOR,
740 WINED3DSIH_BEM,
741 WINED3DSIH_BFI,
742 WINED3DSIH_BFREV,
743 WINED3DSIH_BREAK,
744 WINED3DSIH_BREAKC,
745 WINED3DSIH_BREAKP,
746 WINED3DSIH_BUFINFO,
747 WINED3DSIH_CALL,
748 WINED3DSIH_CALLNZ,
749 WINED3DSIH_CASE,
750 WINED3DSIH_CMP,
751 WINED3DSIH_CND,
752 WINED3DSIH_CONTINUE,
753 WINED3DSIH_CONTINUEP,
754 WINED3DSIH_COUNTBITS,
755 WINED3DSIH_CRS,
756 WINED3DSIH_CUT,
757 WINED3DSIH_CUT_STREAM,
758 WINED3DSIH_DCL,
759 WINED3DSIH_DCL_CONSTANT_BUFFER,
760 WINED3DSIH_DCL_FUNCTION_BODY,
761 WINED3DSIH_DCL_FUNCTION_TABLE,
762 WINED3DSIH_DCL_GLOBAL_FLAGS,
763 WINED3DSIH_DCL_GS_INSTANCES,
764 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT,
765 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT,
766 WINED3DSIH_DCL_HS_MAX_TESSFACTOR,
767 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
768 WINED3DSIH_DCL_INDEX_RANGE,
769 WINED3DSIH_DCL_INDEXABLE_TEMP,
770 WINED3DSIH_DCL_INPUT,
771 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT,
772 WINED3DSIH_DCL_INPUT_PRIMITIVE,
773 WINED3DSIH_DCL_INPUT_PS,
774 WINED3DSIH_DCL_INPUT_PS_SGV,
775 WINED3DSIH_DCL_INPUT_PS_SIV,
776 WINED3DSIH_DCL_INPUT_SGV,
777 WINED3DSIH_DCL_INPUT_SIV,
778 WINED3DSIH_DCL_INTERFACE,
779 WINED3DSIH_DCL_OUTPUT,
780 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT,
781 WINED3DSIH_DCL_OUTPUT_SIV,
782 WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
783 WINED3DSIH_DCL_RESOURCE_RAW,
784 WINED3DSIH_DCL_RESOURCE_STRUCTURED,
785 WINED3DSIH_DCL_SAMPLER,
786 WINED3DSIH_DCL_STREAM,
787 WINED3DSIH_DCL_TEMPS,
788 WINED3DSIH_DCL_TESSELLATOR_DOMAIN,
789 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE,
790 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING,
791 WINED3DSIH_DCL_TGSM_RAW,
792 WINED3DSIH_DCL_TGSM_STRUCTURED,
793 WINED3DSIH_DCL_THREAD_GROUP,
794 WINED3DSIH_DCL_UAV_RAW,
795 WINED3DSIH_DCL_UAV_STRUCTURED,
796 WINED3DSIH_DCL_UAV_TYPED,
797 WINED3DSIH_DCL_VERTICES_OUT,
798 WINED3DSIH_DEF,
799 WINED3DSIH_DEFAULT,
800 WINED3DSIH_DEFB,
801 WINED3DSIH_DEFI,
802 WINED3DSIH_DIV,
803 WINED3DSIH_DP2,
804 WINED3DSIH_DP2ADD,
805 WINED3DSIH_DP3,
806 WINED3DSIH_DP4,
807 WINED3DSIH_DST,
808 WINED3DSIH_DSX,
809 WINED3DSIH_DSX_COARSE,
810 WINED3DSIH_DSX_FINE,
811 WINED3DSIH_DSY,
812 WINED3DSIH_DSY_COARSE,
813 WINED3DSIH_DSY_FINE,
814 WINED3DSIH_ELSE,
815 WINED3DSIH_EMIT,
816 WINED3DSIH_EMIT_STREAM,
817 WINED3DSIH_ENDIF,
818 WINED3DSIH_ENDLOOP,
819 WINED3DSIH_ENDREP,
820 WINED3DSIH_ENDSWITCH,
821 WINED3DSIH_EQ,
822 WINED3DSIH_EVAL_SAMPLE_INDEX,
823 WINED3DSIH_EXP,
824 WINED3DSIH_EXPP,
825 WINED3DSIH_F16TOF32,
826 WINED3DSIH_F32TOF16,
827 WINED3DSIH_FCALL,
828 WINED3DSIH_FIRSTBIT_HI,
829 WINED3DSIH_FIRSTBIT_LO,
830 WINED3DSIH_FIRSTBIT_SHI,
831 WINED3DSIH_FRC,
832 WINED3DSIH_FTOI,
833 WINED3DSIH_FTOU,
834 WINED3DSIH_GATHER4,
835 WINED3DSIH_GATHER4_C,
836 WINED3DSIH_GATHER4_PO,
837 WINED3DSIH_GATHER4_PO_C,
838 WINED3DSIH_GE,
839 WINED3DSIH_HS_CONTROL_POINT_PHASE,
840 WINED3DSIH_HS_DECLS,
841 WINED3DSIH_HS_FORK_PHASE,
842 WINED3DSIH_HS_JOIN_PHASE,
843 WINED3DSIH_IADD,
844 WINED3DSIH_IBFE,
845 WINED3DSIH_IEQ,
846 WINED3DSIH_IF,
847 WINED3DSIH_IFC,
848 WINED3DSIH_IGE,
849 WINED3DSIH_ILT,
850 WINED3DSIH_IMAD,
851 WINED3DSIH_IMAX,
852 WINED3DSIH_IMIN,
853 WINED3DSIH_IMM_ATOMIC_ALLOC,
854 WINED3DSIH_IMM_ATOMIC_AND,
855 WINED3DSIH_IMM_ATOMIC_CMP_EXCH,
856 WINED3DSIH_IMM_ATOMIC_CONSUME,
857 WINED3DSIH_IMM_ATOMIC_EXCH,
858 WINED3DSIH_IMM_ATOMIC_IADD,
859 WINED3DSIH_IMM_ATOMIC_IMAX,
860 WINED3DSIH_IMM_ATOMIC_IMIN,
861 WINED3DSIH_IMM_ATOMIC_OR,
862 WINED3DSIH_IMM_ATOMIC_UMAX,
863 WINED3DSIH_IMM_ATOMIC_UMIN,
864 WINED3DSIH_IMM_ATOMIC_XOR,
865 WINED3DSIH_IMUL,
866 WINED3DSIH_INE,
867 WINED3DSIH_INEG,
868 WINED3DSIH_ISHL,
869 WINED3DSIH_ISHR,
870 WINED3DSIH_ITOF,
871 WINED3DSIH_LABEL,
872 WINED3DSIH_LD,
873 WINED3DSIH_LD2DMS,
874 WINED3DSIH_LD_RAW,
875 WINED3DSIH_LD_STRUCTURED,
876 WINED3DSIH_LD_UAV_TYPED,
877 WINED3DSIH_LIT,
878 WINED3DSIH_LOD,
879 WINED3DSIH_LOG,
880 WINED3DSIH_LOGP,
881 WINED3DSIH_LOOP,
882 WINED3DSIH_LRP,
883 WINED3DSIH_LT,
884 WINED3DSIH_M3x2,
885 WINED3DSIH_M3x3,
886 WINED3DSIH_M3x4,
887 WINED3DSIH_M4x3,
888 WINED3DSIH_M4x4,
889 WINED3DSIH_MAD,
890 WINED3DSIH_MAX,
891 WINED3DSIH_MIN,
892 WINED3DSIH_MOV,
893 WINED3DSIH_MOVA,
894 WINED3DSIH_MOVC,
895 WINED3DSIH_MUL,
896 WINED3DSIH_NE,
897 WINED3DSIH_NOP,
898 WINED3DSIH_NOT,
899 WINED3DSIH_NRM,
900 WINED3DSIH_OR,
901 WINED3DSIH_PHASE,
902 WINED3DSIH_POW,
903 WINED3DSIH_RCP,
904 WINED3DSIH_REP,
905 WINED3DSIH_RESINFO,
906 WINED3DSIH_RET,
907 WINED3DSIH_RETP,
908 WINED3DSIH_ROUND_NE,
909 WINED3DSIH_ROUND_NI,
910 WINED3DSIH_ROUND_PI,
911 WINED3DSIH_ROUND_Z,
912 WINED3DSIH_RSQ,
913 WINED3DSIH_SAMPLE,
914 WINED3DSIH_SAMPLE_B,
915 WINED3DSIH_SAMPLE_C,
916 WINED3DSIH_SAMPLE_C_LZ,
917 WINED3DSIH_SAMPLE_GRAD,
918 WINED3DSIH_SAMPLE_INFO,
919 WINED3DSIH_SAMPLE_LOD,
920 WINED3DSIH_SAMPLE_POS,
921 WINED3DSIH_SETP,
922 WINED3DSIH_SGE,
923 WINED3DSIH_SGN,
924 WINED3DSIH_SINCOS,
925 WINED3DSIH_SLT,
926 WINED3DSIH_SQRT,
927 WINED3DSIH_STORE_RAW,
928 WINED3DSIH_STORE_STRUCTURED,
929 WINED3DSIH_STORE_UAV_TYPED,
930 WINED3DSIH_SUB,
931 WINED3DSIH_SWAPC,
932 WINED3DSIH_SWITCH,
933 WINED3DSIH_SYNC,
934 WINED3DSIH_TEX,
935 WINED3DSIH_TEXBEM,
936 WINED3DSIH_TEXBEML,
937 WINED3DSIH_TEXCOORD,
938 WINED3DSIH_TEXDEPTH,
939 WINED3DSIH_TEXDP3,
940 WINED3DSIH_TEXDP3TEX,
941 WINED3DSIH_TEXKILL,
942 WINED3DSIH_TEXLDD,
943 WINED3DSIH_TEXLDL,
944 WINED3DSIH_TEXM3x2DEPTH,
945 WINED3DSIH_TEXM3x2PAD,
946 WINED3DSIH_TEXM3x2TEX,
947 WINED3DSIH_TEXM3x3,
948 WINED3DSIH_TEXM3x3DIFF,
949 WINED3DSIH_TEXM3x3PAD,
950 WINED3DSIH_TEXM3x3SPEC,
951 WINED3DSIH_TEXM3x3TEX,
952 WINED3DSIH_TEXM3x3VSPEC,
953 WINED3DSIH_TEXREG2AR,
954 WINED3DSIH_TEXREG2GB,
955 WINED3DSIH_TEXREG2RGB,
956 WINED3DSIH_UBFE,
957 WINED3DSIH_UDIV,
958 WINED3DSIH_UGE,
959 WINED3DSIH_ULT,
960 WINED3DSIH_UMAX,
961 WINED3DSIH_UMIN,
962 WINED3DSIH_UMUL,
963 WINED3DSIH_USHR,
964 WINED3DSIH_UTOF,
965 WINED3DSIH_XOR,
966 WINED3DSIH_TABLE_SIZE
969 struct wined3d_shader_version
971 enum wined3d_shader_type type;
972 BYTE major;
973 BYTE minor;
976 struct wined3d_shader_resource_info
978 enum wined3d_shader_resource_type type;
979 enum wined3d_data_type data_type;
980 unsigned int flags;
981 unsigned int stride;
984 #define WINED3D_SAMPLER_DEFAULT ~0x0u
986 struct wined3d_shader_sampler_map_entry
988 unsigned int resource_idx;
989 unsigned int sampler_idx;
990 unsigned int bind_idx;
993 struct wined3d_shader_sampler_map
995 struct wined3d_shader_sampler_map_entry *entries;
996 size_t size;
997 size_t count;
1000 struct wined3d_shader_immediate_constant_buffer
1002 unsigned int vec4_count;
1003 DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
1006 struct wined3d_shader_indexable_temp
1008 struct list entry;
1009 unsigned int register_idx;
1010 unsigned int register_size;
1011 unsigned int component_count;
1014 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1016 struct wined3d_shader_reg_maps
1018 struct wined3d_shader_version shader_version;
1019 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
1020 BYTE address; /* MAX_REG_ADDR, 1 */
1021 WORD labels; /* MAX_LABELS, 16 */
1022 DWORD temporary; /* 32 */
1023 unsigned int temporary_count;
1024 DWORD *constf; /* pixel, vertex */
1025 struct list indexable_temps;
1026 const struct wined3d_shader_immediate_constant_buffer *icb;
1027 union
1029 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1030 BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1031 } u;
1032 DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1033 DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1034 WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1035 WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1036 WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1037 WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1038 UINT cb_sizes[WINED3D_MAX_CBS];
1039 uint32_t cb_map; /* WINED3D_MAX_CBS, 15 */
1041 struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS];
1042 uint32_t resource_map[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS)];
1043 struct wined3d_shader_sampler_map sampler_map;
1044 DWORD sampler_comparison_mode;
1045 BYTE bumpmat; /* WINED3D_MAX_TEXTURES, 8 */
1046 BYTE luminanceparams; /* WINED3D_MAX_TEXTURES, 8 */
1047 struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
1048 DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1049 DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1051 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1052 DWORD cull_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1053 DWORD usesnrm : 1;
1054 DWORD vpos : 1;
1055 DWORD usesdsx : 1;
1056 DWORD usesdsy : 1;
1057 DWORD usestexldd : 1;
1058 DWORD usesmova : 1;
1059 DWORD usesfacing : 1;
1060 DWORD usesrelconstF : 1;
1061 DWORD fog : 1;
1062 DWORD usestexldl : 1;
1063 DWORD usesifc : 1;
1064 DWORD usescall : 1;
1065 DWORD usespow : 1;
1066 DWORD point_size : 1;
1067 DWORD vocp : 1;
1068 DWORD input_rel_addressing : 1;
1069 DWORD viewport_array : 1;
1070 DWORD sample_mask : 1;
1071 DWORD padding : 14;
1073 DWORD rt_mask; /* Used render targets, 32 max. */
1075 /* Whether or not loops are used in this shader, and nesting depth */
1076 unsigned int loop_depth;
1077 unsigned int min_rel_offset, max_rel_offset;
1079 struct wined3d_shader_tgsm *tgsm;
1080 SIZE_T tgsm_capacity;
1081 unsigned int tgsm_count;
1084 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1085 * state information between multiple instructions. */
1086 struct wined3d_shader_tex_mx
1088 unsigned int current_row;
1089 DWORD texcoord_w[2];
1092 struct wined3d_shader_parser_state
1094 unsigned int current_loop_depth;
1095 unsigned int current_loop_reg;
1096 BOOL in_subroutine;
1099 struct wined3d_shader_context
1101 const struct wined3d_shader *shader;
1102 const struct wined3d_shader_reg_maps *reg_maps;
1103 struct wined3d_string_buffer *buffer;
1104 struct wined3d_shader_tex_mx *tex_mx;
1105 struct wined3d_shader_parser_state *state;
1106 void *backend_data;
1109 struct wined3d_shader_register_index
1111 const struct wined3d_shader_src_param *rel_addr;
1112 unsigned int offset;
1115 struct wined3d_shader_register
1117 enum wined3d_shader_register_type type;
1118 enum wined3d_data_type data_type;
1119 struct wined3d_shader_register_index idx[2];
1120 enum wined3d_immconst_type immconst_type;
1121 union
1123 DWORD immconst_data[4];
1124 unsigned fp_body_idx;
1125 } u;
1128 struct wined3d_shader_dst_param
1130 struct wined3d_shader_register reg;
1131 DWORD write_mask;
1132 DWORD modifiers;
1133 DWORD shift;
1136 struct wined3d_shader_src_param
1138 struct wined3d_shader_register reg;
1139 DWORD swizzle;
1140 enum wined3d_shader_src_modifier modifiers;
1143 struct wined3d_shader_index_range
1145 struct wined3d_shader_dst_param first_register;
1146 unsigned int last_register;
1149 struct wined3d_shader_semantic
1151 enum wined3d_decl_usage usage;
1152 UINT usage_idx;
1153 enum wined3d_shader_resource_type resource_type;
1154 enum wined3d_data_type resource_data_type;
1155 struct wined3d_shader_dst_param reg;
1158 enum wined3d_shader_input_sysval_semantic
1160 WINED3D_SIV_POSITION = 1,
1161 WINED3D_SIV_CLIP_DISTANCE = 2,
1162 WINED3D_SIV_CULL_DISTANCE = 3,
1163 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
1164 WINED3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
1165 WINED3D_SIV_VERTEX_ID = 6,
1166 WINED3D_SIV_PRIMITIVE_ID = 7,
1167 WINED3D_SIV_INSTANCE_ID = 8,
1168 WINED3D_SIV_IS_FRONT_FACE = 9,
1169 WINED3D_SIV_SAMPLE_INDEX = 10,
1170 WINED3D_SIV_QUAD_U0_TESS_FACTOR = 11,
1171 WINED3D_SIV_QUAD_V0_TESS_FACTOR = 12,
1172 WINED3D_SIV_QUAD_U1_TESS_FACTOR = 13,
1173 WINED3D_SIV_QUAD_V1_TESS_FACTOR = 14,
1174 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
1175 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
1176 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
1177 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
1178 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
1179 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
1180 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
1181 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
1184 struct wined3d_shader_register_semantic
1186 struct wined3d_shader_dst_param reg;
1187 enum wined3d_shader_input_sysval_semantic sysval_semantic;
1190 struct wined3d_shader_structured_resource
1192 struct wined3d_shader_dst_param reg;
1193 unsigned int byte_stride;
1196 struct wined3d_shader_tgsm
1198 unsigned int size;
1199 unsigned int stride;
1202 struct wined3d_shader_tgsm_raw
1204 struct wined3d_shader_dst_param reg;
1205 unsigned int byte_count;
1208 struct wined3d_shader_tgsm_structured
1210 struct wined3d_shader_dst_param reg;
1211 unsigned int byte_stride;
1212 unsigned int structure_count;
1215 struct wined3d_shader_thread_group_size
1217 unsigned int x, y, z;
1220 struct wined3d_shader_function_table_pointer
1222 unsigned int index;
1223 unsigned int array_size;
1224 unsigned int body_count;
1225 unsigned int table_count;
1228 struct wined3d_shader_texel_offset
1230 signed char u, v, w;
1233 struct wined3d_shader_primitive_type
1235 enum wined3d_primitive_type type;
1236 unsigned int patch_vertex_count;
1239 struct wined3d_shader_instruction
1241 const struct wined3d_shader_context *ctx;
1242 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
1243 DWORD flags;
1244 unsigned int dst_count;
1245 unsigned int src_count;
1246 const struct wined3d_shader_dst_param *dst;
1247 const struct wined3d_shader_src_param *src;
1248 struct wined3d_shader_texel_offset texel_offset;
1249 BOOL coissue;
1250 const struct wined3d_shader_src_param *predicate;
1251 union
1253 struct wined3d_shader_semantic semantic;
1254 struct wined3d_shader_register_semantic register_semantic;
1255 struct wined3d_shader_primitive_type primitive_type;
1256 struct wined3d_shader_dst_param dst;
1257 struct wined3d_shader_src_param src;
1258 unsigned int count;
1259 unsigned int index;
1260 const struct wined3d_shader_immediate_constant_buffer *icb;
1261 struct wined3d_shader_structured_resource structured_resource;
1262 struct wined3d_shader_tgsm_raw tgsm_raw;
1263 struct wined3d_shader_tgsm_structured tgsm_structured;
1264 struct wined3d_shader_thread_group_size thread_group_size;
1265 enum wined3d_tessellator_domain tessellator_domain;
1266 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1267 enum wined3d_tessellator_partitioning tessellator_partitioning;
1268 float max_tessellation_factor;
1269 struct wined3d_shader_index_range index_range;
1270 struct wined3d_shader_indexable_temp indexable_temp;
1271 struct wined3d_shader_function_table_pointer fp;
1272 } declaration;
1275 static inline BOOL wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction *ins)
1277 return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1280 struct wined3d_shader_attribute
1282 enum wined3d_decl_usage usage;
1283 UINT usage_idx;
1286 struct wined3d_shader_loop_control
1288 unsigned int count;
1289 unsigned int start;
1290 int step;
1293 struct wined3d_shader_frontend
1295 void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1296 const struct wined3d_shader_signature *output_signature);
1297 void (*shader_free)(void *data);
1298 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1299 void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1300 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1303 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
1304 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
1306 HRESULT shader_extract_from_dxbc(struct wined3d_shader *shader,
1307 unsigned int max_shader_version, enum wined3d_shader_byte_code_format *format) DECLSPEC_HIDDEN;
1308 BOOL shader_get_stream_output_register_info(const struct wined3d_shader *shader,
1309 const struct wined3d_stream_output_element *so_element, unsigned int *register_idx,
1310 unsigned int *component_idx) DECLSPEC_HIDDEN;
1312 typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
1314 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1315 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1316 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1317 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1318 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1320 struct shader_caps
1322 unsigned int vs_version;
1323 unsigned int hs_version;
1324 unsigned int ds_version;
1325 unsigned int gs_version;
1326 unsigned int ps_version;
1327 unsigned int cs_version;
1329 unsigned int vs_uniform_count;
1330 unsigned int ps_uniform_count;
1331 float ps_1x_max_value;
1332 unsigned int varying_count;
1334 DWORD wined3d_caps;
1337 enum wined3d_gl_resource_type
1339 WINED3D_GL_RES_TYPE_TEX_1D = 0,
1340 WINED3D_GL_RES_TYPE_TEX_2D = 1,
1341 WINED3D_GL_RES_TYPE_TEX_3D = 2,
1342 WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
1343 WINED3D_GL_RES_TYPE_TEX_RECT = 4,
1344 WINED3D_GL_RES_TYPE_BUFFER = 5,
1345 WINED3D_GL_RES_TYPE_RB = 6,
1346 WINED3D_GL_RES_TYPE_COUNT = 7,
1349 enum wined3d_vertex_processing_mode
1351 WINED3D_VP_MODE_FF,
1352 WINED3D_VP_MODE_SHADER,
1353 WINED3D_VP_MODE_NONE,
1356 #define WINED3D_CONST_NUM_UNUSED ~0U
1358 enum wined3d_ffp_ps_fog_mode
1360 WINED3D_FFP_PS_FOG_OFF,
1361 WINED3D_FFP_PS_FOG_LINEAR,
1362 WINED3D_FFP_PS_FOG_EXP,
1363 WINED3D_FFP_PS_FOG_EXP2,
1366 /* Stateblock dependent parameters which have to be hardcoded
1367 * into the shader code
1370 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1371 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1372 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1373 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1374 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1376 /* Used for Shader Model 1 pixel shaders to track the bound texture
1377 * type. 2D and RECT textures are separated through NP2 fixup. */
1378 enum wined3d_shader_tex_types
1380 WINED3D_SHADER_TEX_2D = 0,
1381 WINED3D_SHADER_TEX_3D = 1,
1382 WINED3D_SHADER_TEX_CUBE = 2,
1383 WINED3D_SHADER_TEX_ERR = 3,
1386 struct ps_compile_args
1388 struct color_fixup_desc color_fixup[WINED3D_MAX_FRAGMENT_SAMPLERS];
1389 enum wined3d_vertex_processing_mode vp_mode;
1390 enum wined3d_ffp_ps_fog_mode fog;
1391 DWORD tex_types; /* ps 1 - 3, 16 textures */
1392 WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1393 WORD srgb_correction;
1394 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1395 D3D9 has a limit of 16 samplers and the fixup is superfluous
1396 in D3D10 (unconditional NP2 support mandatory). */
1397 WORD np2_fixup;
1398 WORD shadow; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1399 WORD texcoords_initialized; /* WINED3D_MAX_TEXTURES, 8 */
1400 WORD padding_to_dword;
1401 DWORD pointsprite : 1;
1402 DWORD flatshading : 1;
1403 DWORD alpha_test_func : 3;
1404 DWORD render_offscreen : 1;
1405 DWORD rt_alpha_swizzle : 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1406 DWORD dual_source_blend : 1;
1407 DWORD padding : 17;
1410 enum fog_src_type
1412 VS_FOG_Z = 0,
1413 VS_FOG_COORD = 1
1416 struct vs_compile_args
1418 BYTE fog_src;
1419 BYTE clip_enabled : 1;
1420 BYTE point_size : 1;
1421 BYTE per_vertex_point_size : 1;
1422 BYTE flatshading : 1;
1423 BYTE next_shader_type : 3;
1424 BYTE padding : 1;
1425 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1426 unsigned int next_shader_input_count;
1427 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1430 struct ds_compile_args
1432 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1433 enum wined3d_tessellator_partitioning tessellator_partitioning;
1434 unsigned int output_count : 16;
1435 unsigned int next_shader_type : 3;
1436 unsigned int render_offscreen : 1;
1437 unsigned int padding : 12;
1438 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1441 struct gs_compile_args
1443 unsigned int output_count;
1444 enum wined3d_primitive_type primitive_type;
1445 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1448 struct wined3d_shader_backend_ops
1450 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1451 void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1452 void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1453 const struct wined3d_state *state);
1454 void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1455 const struct wined3d_state *state);
1456 void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1457 void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1458 void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1459 void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1460 const struct wined3d_state *state);
1461 void (*shader_destroy)(struct wined3d_shader *shader);
1462 HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1463 const struct wined3d_fragment_pipe_ops *fragment_pipe);
1464 void (*shader_free_private)(struct wined3d_device *device, struct wined3d_context *context);
1465 BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1466 void (*shader_free_context_data)(struct wined3d_context *context);
1467 void (*shader_init_context_state)(struct wined3d_context *context);
1468 void (*shader_get_caps)(const struct wined3d_adapter *adapter, struct shader_caps *caps);
1469 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1470 BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1473 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
1474 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
1475 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
1477 const struct wined3d_shader_backend_ops *wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN;
1479 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1481 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1482 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1483 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1484 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1486 static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1488 wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1489 wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1490 wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1491 wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1494 extern const struct wined3d_vec4 wined3d_srgb_const[] DECLSPEC_HIDDEN;
1496 static inline float wined3d_srgb_from_linear(float colour)
1498 if (colour < 0.0f)
1499 return 0.0f;
1500 if (colour < wined3d_srgb_const[1].x)
1501 return colour * wined3d_srgb_const[0].w;
1502 if (colour < 1.0f)
1503 return wined3d_srgb_const[0].y * powf(colour, wined3d_srgb_const[0].x) - wined3d_srgb_const[0].z;
1504 return 1.0f;
1507 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color *colour_srgb,
1508 const struct wined3d_color *colour)
1510 colour_srgb->r = wined3d_srgb_from_linear(colour->r);
1511 colour_srgb->g = wined3d_srgb_from_linear(colour->g);
1512 colour_srgb->b = wined3d_srgb_from_linear(colour->b);
1513 colour_srgb->a = colour->a;
1516 void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1517 const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1519 /* Checking of API calls */
1520 /* --------------------- */
1521 #ifndef WINE_NO_DEBUG_MSGS
1522 #define checkGLcall(A) \
1523 do { \
1524 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1525 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1526 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1527 } while(0)
1528 #else
1529 #define checkGLcall(A) do {} while(0)
1530 #endif
1532 struct wined3d_bo_gl
1534 GLuint id;
1535 GLenum binding;
1538 static inline GLuint wined3d_bo_gl_id(uintptr_t bo)
1540 return bo ? ((struct wined3d_bo_gl *)bo)->id : 0;
1543 struct wined3d_bo_user_vk
1545 struct list entry;
1546 bool valid;
1549 struct wined3d_bo_vk
1551 VkBuffer vk_buffer;
1552 struct wined3d_allocator_block *memory;
1553 struct wined3d_bo_slab_vk *slab;
1555 VkDeviceMemory vk_memory;
1557 VkDeviceSize buffer_offset;
1558 VkDeviceSize memory_offset;
1559 VkDeviceSize size;
1560 VkBufferUsageFlags usage;
1561 VkMemoryPropertyFlags memory_type;
1563 struct list users;
1564 uint64_t command_buffer_id;
1567 struct wined3d_bo_slab_vk_key
1569 VkMemoryPropertyFlags memory_type;
1570 VkBufferUsageFlags usage;
1571 VkDeviceSize size;
1574 struct wined3d_bo_slab_vk
1576 struct wine_rb_entry entry;
1577 struct wined3d_bo_slab_vk *next;
1578 struct wined3d_bo_vk bo;
1579 unsigned int map_count;
1580 void *map_ptr;
1581 uint32_t map;
1584 struct wined3d_bo_address
1586 UINT_PTR buffer_object;
1587 BYTE *addr;
1590 struct wined3d_const_bo_address
1592 UINT_PTR buffer_object;
1593 const BYTE *addr;
1596 static inline struct wined3d_const_bo_address *wined3d_const_bo_address(struct wined3d_bo_address *data)
1598 return (struct wined3d_const_bo_address *)data;
1601 struct wined3d_stream_info_element
1603 const struct wined3d_format *format;
1604 struct wined3d_bo_address data;
1605 GLsizei stride;
1606 unsigned int stream_idx;
1607 unsigned int divisor;
1610 struct wined3d_stream_info
1612 struct wined3d_stream_info_element elements[MAX_ATTRIBS];
1613 DWORD position_transformed : 1;
1614 DWORD all_vbo : 1;
1615 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1616 WORD use_map; /* MAX_ATTRIBS, 16 */
1619 void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_info,
1620 const struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
1622 struct wined3d_direct_dispatch_parameters
1624 unsigned int group_count_x;
1625 unsigned int group_count_y;
1626 unsigned int group_count_z;
1629 struct wined3d_indirect_dispatch_parameters
1631 struct wined3d_buffer *buffer;
1632 unsigned int offset;
1635 struct wined3d_dispatch_parameters
1637 BOOL indirect;
1638 union
1640 struct wined3d_direct_dispatch_parameters direct;
1641 struct wined3d_indirect_dispatch_parameters indirect;
1642 } u;
1645 struct wined3d_direct_draw_parameters
1647 int base_vertex_idx;
1648 unsigned int start_idx;
1649 unsigned int index_count;
1650 unsigned int start_instance;
1651 unsigned int instance_count;
1654 struct wined3d_indirect_draw_parameters
1656 struct wined3d_buffer *buffer;
1657 unsigned int offset;
1660 struct wined3d_draw_parameters
1662 BOOL indirect;
1663 union
1665 struct wined3d_direct_draw_parameters direct;
1666 struct wined3d_indirect_draw_parameters indirect;
1667 } u;
1668 BOOL indexed;
1671 void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
1672 const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
1673 void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
1674 const struct wined3d_dispatch_parameters *dispatch_parameters) DECLSPEC_HIDDEN;
1676 #define eps 1e-8f
1678 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1679 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1681 enum wined3d_pipeline
1683 WINED3D_PIPELINE_GRAPHICS,
1684 WINED3D_PIPELINE_COMPUTE,
1685 WINED3D_PIPELINE_COUNT,
1688 /* Routines and structures related to state management */
1690 #define STATE_RENDER(a) (a)
1691 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1693 #define STATE_TEXTURESTAGE(stage, num) \
1694 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1695 #define STATE_IS_TEXTURESTAGE(a) \
1696 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1698 /* + 1 because samplers start with 0 */
1699 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1700 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1702 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1703 #define STATE_IS_GRAPHICS_SHADER(a) \
1704 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1706 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1707 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1708 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1709 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1711 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1712 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1714 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1715 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1717 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1718 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1720 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1721 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1722 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1723 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1725 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1726 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1728 #define STATE_VIEWPORT (STATE_VDECL + 1)
1729 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1731 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1732 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1733 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1734 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1736 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1737 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1739 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1740 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1742 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1743 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1745 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1746 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1748 #define STATE_POINTSPRITECOORDORIGIN (STATE_RASTERIZER + 1)
1749 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1751 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1752 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1754 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1755 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1757 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1758 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1760 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1761 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1763 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1764 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1766 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1767 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1769 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1770 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1772 #define STATE_COMPUTE_OFFSET (STATE_BLEND_FACTOR + 1)
1774 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1775 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1777 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1778 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1780 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1781 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1783 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1784 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1786 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1787 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1789 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1790 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1792 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1793 #define STATE_CONSTANT_BUFFER(a) \
1794 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1795 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1796 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1798 enum fogsource {
1799 FOGSOURCE_FFP,
1800 FOGSOURCE_VS,
1801 FOGSOURCE_COORD,
1804 union wined3d_gl_fence_object
1806 GLuint id;
1807 GLsync sync;
1810 enum wined3d_fence_result
1812 WINED3D_FENCE_OK,
1813 WINED3D_FENCE_WAITING,
1814 WINED3D_FENCE_NOT_STARTED,
1815 WINED3D_FENCE_WRONG_THREAD,
1816 WINED3D_FENCE_ERROR,
1819 struct wined3d_fence
1821 struct list entry;
1822 union wined3d_gl_fence_object object;
1823 struct wined3d_context_gl *context_gl;
1826 HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
1827 void wined3d_fence_destroy(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
1828 void wined3d_fence_issue(struct wined3d_fence *fence, struct wined3d_device *device) DECLSPEC_HIDDEN;
1829 enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
1830 struct wined3d_device *device) DECLSPEC_HIDDEN;
1832 /* Direct3D terminology with little modifications. We do not have an issued
1833 * state because only the driver knows about it, but we have a created state
1834 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1835 enum wined3d_query_state
1837 QUERY_CREATED,
1838 QUERY_SIGNALLED,
1839 QUERY_BUILDING
1842 struct wined3d_query_ops
1844 BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
1845 BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
1846 void (*query_destroy)(struct wined3d_query *query);
1849 struct wined3d_query
1851 LONG ref;
1853 void *parent;
1854 const struct wined3d_parent_ops *parent_ops;
1855 struct wined3d_device *device;
1856 enum wined3d_query_state state;
1857 enum wined3d_query_type type;
1858 const void *data;
1859 DWORD data_size;
1860 const struct wined3d_query_ops *query_ops;
1862 LONG counter_main, counter_retrieved;
1863 struct list poll_list_entry;
1865 GLuint buffer_object;
1866 UINT64 *map_ptr;
1869 HRESULT wined3d_query_gl_create(struct wined3d_device *device, enum wined3d_query_type type, void *parent,
1870 const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query) DECLSPEC_HIDDEN;
1871 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl *context_gl,
1872 struct wined3d_query *query) DECLSPEC_HIDDEN;
1874 struct wined3d_event_query
1876 struct wined3d_query query;
1878 struct wined3d_fence fence;
1879 BOOL signalled;
1882 struct wined3d_occlusion_query
1884 struct wined3d_query query;
1886 struct list entry;
1887 GLuint id;
1888 struct wined3d_context_gl *context_gl;
1889 UINT64 samples;
1890 BOOL started;
1893 struct wined3d_timestamp_query
1895 struct wined3d_query query;
1897 struct list entry;
1898 GLuint id;
1899 struct wined3d_context_gl *context_gl;
1900 UINT64 timestamp;
1903 union wined3d_gl_so_statistics_query
1905 GLuint id[2];
1906 struct
1908 GLuint written;
1909 GLuint generated;
1910 } query;
1913 struct wined3d_so_statistics_query
1915 struct wined3d_query query;
1917 struct list entry;
1918 union wined3d_gl_so_statistics_query u;
1919 struct wined3d_context_gl *context_gl;
1920 unsigned int stream_idx;
1921 struct wined3d_query_data_so_statistics statistics;
1922 BOOL started;
1925 union wined3d_gl_pipeline_statistics_query
1927 GLuint id[11];
1928 struct
1930 GLuint vertices;
1931 GLuint primitives;
1932 GLuint vertex_shader;
1933 GLuint tess_control_shader;
1934 GLuint tess_eval_shader;
1935 GLuint geometry_shader;
1936 GLuint geometry_primitives;
1937 GLuint fragment_shader;
1938 GLuint compute_shader;
1939 GLuint clipping_input;
1940 GLuint clipping_output;
1941 } query;
1944 struct wined3d_pipeline_statistics_query
1946 struct wined3d_query query;
1948 struct list entry;
1949 union wined3d_gl_pipeline_statistics_query u;
1950 struct wined3d_context_gl *context_gl;
1951 struct wined3d_query_data_pipeline_statistics statistics;
1952 BOOL started;
1955 struct wined3d_gl_view
1957 GLenum target;
1958 GLuint name;
1961 struct wined3d_range
1963 unsigned int offset;
1964 unsigned int size;
1967 struct wined3d_rendertarget_info
1969 struct wined3d_gl_view gl_view;
1970 struct wined3d_resource *resource;
1971 unsigned int sub_resource_idx;
1972 unsigned int layer_count;
1975 struct wined3d_fb_state
1977 struct wined3d_rendertarget_view *render_targets[WINED3D_MAX_RENDER_TARGETS];
1978 struct wined3d_rendertarget_view *depth_stencil;
1981 #define MAX_GL_FRAGMENT_SAMPLERS 32
1983 struct wined3d_context
1985 const struct wined3d_d3d_info *d3d_info;
1986 const struct wined3d_state_entry *state_table;
1987 uint32_t dirty_graphics_states[WINED3D_BITMAP_SIZE(STATE_HIGHEST)];
1988 uint32_t dirty_compute_states[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT)];
1990 struct wined3d_device *device;
1991 struct wined3d_swapchain *swapchain;
1992 struct
1994 struct wined3d_texture *texture;
1995 unsigned int sub_resource_idx;
1996 } current_rt;
1998 /* Stores some information about the context state for optimization */
1999 DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
2000 DWORD update_shader_resource_bindings : 1;
2001 DWORD update_compute_shader_resource_bindings : 1;
2002 DWORD update_unordered_access_view_bindings : 1;
2003 DWORD update_compute_unordered_access_view_bindings : 1;
2004 DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
2005 DWORD last_was_rhw : 1; /* True iff last draw_primitive was in xyzrhw mode. */
2006 DWORD last_was_pshader : 1;
2007 DWORD last_was_vshader : 1;
2008 DWORD last_was_diffuse : 1;
2009 DWORD last_was_specular : 1;
2010 DWORD last_was_normal : 1;
2012 DWORD last_was_ffp_blit : 1;
2013 DWORD last_was_blit : 1;
2014 DWORD last_was_ckey : 1;
2015 DWORD last_was_dual_source_blend : 1;
2016 DWORD texShaderBumpMap : 8; /* WINED3D_MAX_TEXTURES, 8 */
2017 DWORD lastWasPow2Texture : 8; /* WINED3D_MAX_TEXTURES, 8 */
2018 DWORD fixed_function_usage_map : 8; /* WINED3D_MAX_TEXTURES, 8 */
2019 DWORD lowest_disabled_stage : 4; /* Max WINED3D_MAX_TEXTURES, 8 */
2021 DWORD use_immediate_mode_draw : 1;
2022 DWORD uses_uavs : 1;
2023 DWORD uses_fbo_attached_resources : 1;
2024 DWORD transform_feedback_active : 1;
2025 DWORD transform_feedback_paused : 1;
2026 DWORD fog_coord : 1;
2027 DWORD render_offscreen : 1;
2028 DWORD current : 1;
2029 DWORD destroyed : 1;
2030 DWORD destroy_delayed : 1;
2031 DWORD clip_distance_mask : 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
2032 DWORD namedArraysLoaded : 1;
2033 DWORD padding : 13;
2035 DWORD constant_update_mask;
2036 DWORD numbered_array_mask;
2037 enum fogsource fog_source;
2039 UINT instance_count;
2041 void *shader_backend_data;
2042 void *fragment_pipe_data;
2044 struct wined3d_stream_info stream_info;
2046 /* Fences for GL_APPLE_flush_buffer_range */
2047 struct wined3d_fence *buffer_fences[MAX_ATTRIBS];
2048 unsigned int buffer_fence_count;
2050 unsigned int viewport_count;
2051 unsigned int scissor_rect_count;
2054 void wined3d_context_cleanup(struct wined3d_context *context) DECLSPEC_HIDDEN;
2055 void wined3d_context_init(struct wined3d_context *context, struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2056 void context_load_shader_resources(struct wined3d_context *context,
2057 const struct wined3d_state *state, unsigned int shader_mask) DECLSPEC_HIDDEN;
2058 void context_load_stream_output_buffers(struct wined3d_context *context,
2059 const struct wined3d_state *state) DECLSPEC_HIDDEN;
2060 void context_load_unordered_access_resources(struct wined3d_context *context,
2061 const struct wined3d_shader *shader, struct wined3d_unordered_access_view * const *views) DECLSPEC_HIDDEN;
2062 void context_preload_textures(struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2063 void context_update_stream_info(struct wined3d_context *context, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2065 HRESULT wined3d_context_no3d_init(struct wined3d_context *context_no3d,
2066 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2068 struct wined3d_context_gl
2070 struct wined3d_context c;
2072 const struct wined3d_gl_info *gl_info;
2074 DWORD tid; /* Thread ID which owns this context at the moment. */
2076 uint32_t dc_is_private : 1;
2077 uint32_t dc_has_format : 1; /* Only meaningful for private DCs. */
2078 uint32_t fog_enabled : 1;
2079 uint32_t diffuse_attrib_to_1 : 1;
2080 uint32_t rebind_fbo : 1;
2081 uint32_t untracked_material_count : 2; /* Max value 2 */
2082 uint32_t needs_set : 1;
2083 uint32_t valid : 1;
2084 uint32_t padding : 23;
2086 uint32_t default_attrib_value_set;
2088 GLenum tracking_parm; /* Which source is tracking current colour. */
2089 GLenum untracked_materials[2];
2090 SIZE blit_size;
2091 unsigned int active_texture;
2093 GLenum *texture_type;
2095 /* The WGL context. */
2096 unsigned int level;
2097 HGLRC restore_ctx;
2098 HDC restore_dc;
2099 int restore_pf;
2100 HWND restore_pf_win;
2101 HGLRC gl_ctx;
2102 HDC dc;
2103 int pixel_format;
2104 HWND window;
2105 GLint aux_buffers;
2107 /* FBOs. */
2108 unsigned int fbo_entry_count;
2109 struct list fbo_list;
2110 struct list fbo_destroy_list;
2111 struct fbo_entry *current_fbo;
2112 GLuint fbo_read_binding;
2113 GLuint fbo_draw_binding;
2114 struct wined3d_rendertarget_info blit_targets[WINED3D_MAX_RENDER_TARGETS];
2115 uint32_t draw_buffers_mask; /* Enabled draw buffers, 31 max. */
2117 /* Queries. */
2118 struct list occlusion_queries;
2119 struct list fences;
2120 struct list timestamp_queries;
2121 struct list so_statistics_queries;
2122 struct list pipeline_statistics_queries;
2124 GLuint *free_occlusion_queries;
2125 SIZE_T free_occlusion_query_size;
2126 unsigned int free_occlusion_query_count;
2128 union wined3d_gl_fence_object *free_fences;
2129 SIZE_T free_fence_size;
2130 unsigned int free_fence_count;
2132 GLuint *free_timestamp_queries;
2133 SIZE_T free_timestamp_query_size;
2134 unsigned int free_timestamp_query_count;
2136 union wined3d_gl_so_statistics_query *free_so_statistics_queries;
2137 SIZE_T free_so_statistics_query_size;
2138 unsigned int free_so_statistics_query_count;
2140 union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
2141 SIZE_T free_pipeline_statistics_query_size;
2142 unsigned int free_pipeline_statistics_query_count;
2144 GLuint blit_vbo;
2146 unsigned int tex_unit_map[WINED3D_MAX_COMBINED_SAMPLERS];
2147 unsigned int rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + WINED3D_MAX_VERTEX_SAMPLERS];
2149 /* Extension emulation. */
2150 GLint gl_fog_source;
2151 GLfloat fog_coord_value;
2152 GLfloat colour[4], fog_start, fog_end, fog_colour[4];
2154 GLuint dummy_arbfp_prog;
2157 static inline struct wined3d_context_gl *wined3d_context_gl(struct wined3d_context *context)
2159 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2162 static inline const struct wined3d_context_gl *wined3d_context_gl_const(const struct wined3d_context *context)
2164 return CONTAINING_RECORD(context, struct wined3d_context_gl, c);
2167 struct wined3d_context *wined3d_context_gl_acquire(const struct wined3d_device *device,
2168 struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2169 void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl,
2170 const struct wined3d_gl_info *gl_info, unsigned int unit) DECLSPEC_HIDDEN;
2171 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl *context_gl,
2172 struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2173 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl *context_gl,
2174 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2175 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl *context_gl,
2176 struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2177 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl *context_gl,
2178 struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2179 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl *context_gl,
2180 struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2181 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
2182 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2183 BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl, const struct wined3d_state *state,
2184 unsigned int rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2185 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl *context_gl, GLenum target,
2186 struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
2187 struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
2188 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl *context_gl,
2189 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2190 void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
2191 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2192 void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl,
2193 GLenum target, GLuint name) DECLSPEC_HIDDEN;
2194 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl *context_gl, GLenum target) DECLSPEC_HIDDEN;
2195 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl,
2196 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size) DECLSPEC_HIDDEN;
2197 void wined3d_context_gl_destroy(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2198 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl *context_gl, struct wined3d_texture_gl *texture_gl,
2199 unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2200 enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2201 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl *context_gl,
2202 struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
2203 const RECT *src_rect, const RECT *dst_rect, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
2204 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl *context_gl, uint32_t mask) DECLSPEC_HIDDEN;
2205 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2206 void wined3d_context_gl_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2207 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2208 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
2209 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
2210 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
2211 struct wined3d_context_gl *wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN;
2212 GLenum wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2213 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl *context_gl,
2214 const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2215 HRESULT wined3d_context_gl_init(struct wined3d_context_gl *context_gl,
2216 struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
2217 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl *context_gl,
2218 const struct wined3d_stream_info *si, GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2219 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl,
2220 const struct wined3d_bo_address *data, size_t size, uint32_t flags) DECLSPEC_HIDDEN;
2221 struct wined3d_context_gl *wined3d_context_gl_reacquire(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2222 void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2223 BOOL wined3d_context_gl_set_current(struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2224 void wined3d_context_gl_set_draw_buffer(struct wined3d_context_gl *context_gl, GLenum buffer) DECLSPEC_HIDDEN;
2225 void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl,
2226 const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN;
2227 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
2228 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data,
2229 unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN;
2230 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl,
2231 const struct wined3d_state *state) DECLSPEC_HIDDEN;
2233 struct wined3d_command_buffer_vk
2235 uint64_t id;
2236 VkCommandBuffer vk_command_buffer;
2237 VkFence vk_fence;
2240 enum wined3d_retired_object_type_vk
2242 WINED3D_RETIRED_FREE_VK,
2243 WINED3D_RETIRED_FRAMEBUFFER_VK,
2244 WINED3D_RETIRED_DESCRIPTOR_POOL_VK,
2245 WINED3D_RETIRED_MEMORY_VK,
2246 WINED3D_RETIRED_ALLOCATOR_BLOCK_VK,
2247 WINED3D_RETIRED_BO_SLAB_SLICE_VK,
2248 WINED3D_RETIRED_BUFFER_VK,
2249 WINED3D_RETIRED_IMAGE_VK,
2250 WINED3D_RETIRED_BUFFER_VIEW_VK,
2251 WINED3D_RETIRED_IMAGE_VIEW_VK,
2252 WINED3D_RETIRED_SAMPLER_VK,
2255 struct wined3d_retired_object_vk
2257 enum wined3d_retired_object_type_vk type;
2258 union
2260 struct wined3d_retired_object_vk *next;
2261 VkFramebuffer vk_framebuffer;
2262 VkDescriptorPool vk_descriptor_pool;
2263 VkDeviceMemory vk_memory;
2264 struct wined3d_allocator_block *block;
2265 struct
2267 struct wined3d_bo_slab_vk *slab;
2268 size_t idx;
2269 } slice;
2270 VkBuffer vk_buffer;
2271 VkImage vk_image;
2272 VkBufferView vk_buffer_view;
2273 VkImageView vk_image_view;
2274 VkSampler vk_sampler;
2275 } u;
2276 uint64_t command_buffer_id;
2279 struct wined3d_retired_objects_vk
2281 struct wined3d_retired_object_vk *objects;
2282 struct wined3d_retired_object_vk *free;
2283 SIZE_T size;
2284 SIZE_T count;
2287 struct wined3d_render_pass_attachment_vk
2289 VkFormat vk_format;
2290 VkSampleCountFlagBits vk_samples;
2291 VkImageLayout vk_layout;
2294 struct wined3d_render_pass_key_vk
2296 struct wined3d_render_pass_attachment_vk rt[WINED3D_MAX_RENDER_TARGETS];
2297 struct wined3d_render_pass_attachment_vk ds;
2298 uint32_t rt_mask;
2299 uint32_t clear_flags;
2302 struct wined3d_render_pass_vk
2304 struct wine_rb_entry entry;
2305 struct wined3d_render_pass_key_vk key;
2306 VkRenderPass vk_render_pass;
2309 struct wined3d_pipeline_layout_key_vk
2311 VkDescriptorSetLayoutBinding *bindings;
2312 SIZE_T binding_count;
2315 struct wined3d_pipeline_layout_vk
2317 struct wine_rb_entry entry;
2318 struct wined3d_pipeline_layout_key_vk key;
2319 VkPipelineLayout vk_pipeline_layout;
2320 VkDescriptorSetLayout vk_set_layout;
2323 enum wined3d_shader_descriptor_type
2325 WINED3D_SHADER_DESCRIPTOR_TYPE_CBV,
2326 WINED3D_SHADER_DESCRIPTOR_TYPE_SRV,
2327 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV,
2328 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER,
2329 WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER,
2332 struct wined3d_shader_resource_binding
2334 enum wined3d_shader_type shader_type;
2335 enum wined3d_shader_descriptor_type shader_descriptor_type;
2336 size_t resource_idx;
2337 enum wined3d_shader_resource_type resource_type;
2338 enum wined3d_data_type resource_data_type;
2339 size_t binding_idx;
2342 struct wined3d_shader_resource_bindings
2344 struct wined3d_shader_resource_binding *bindings;
2345 SIZE_T size, count;
2348 struct wined3d_shader_descriptor_writes_vk
2350 VkWriteDescriptorSet *writes;
2351 SIZE_T size, count;
2354 struct wined3d_context_vk
2356 struct wined3d_context c;
2358 const struct wined3d_vk_info *vk_info;
2360 uint32_t update_compute_pipeline : 1;
2361 uint32_t padding : 31;
2363 struct
2365 VkPipeline vk_pipeline;
2366 VkPipelineLayout vk_pipeline_layout;
2367 VkDescriptorSetLayout vk_set_layout;
2368 struct wined3d_shader_resource_bindings bindings;
2369 } compute;
2371 VkCommandPool vk_command_pool;
2372 struct wined3d_command_buffer_vk current_command_buffer;
2373 uint64_t completed_command_buffer_id;
2375 struct
2377 struct wined3d_command_buffer_vk *buffers;
2378 SIZE_T buffers_size;
2379 SIZE_T buffer_count;
2380 } submitted;
2382 struct wined3d_shader_descriptor_writes_vk descriptor_writes;
2384 VkDescriptorPool vk_descriptor_pool;
2386 struct wined3d_retired_objects_vk retired;
2387 struct wine_rb_tree render_passes;
2388 struct wine_rb_tree pipeline_layouts;
2389 struct wine_rb_tree bo_slab_available;
2392 static inline struct wined3d_context_vk *wined3d_context_vk(struct wined3d_context *context)
2394 return CONTAINING_RECORD(context, struct wined3d_context_vk, c);
2397 struct wined3d_allocator_block *wined3d_context_vk_allocate_memory(struct wined3d_context_vk *context_vk,
2398 unsigned int memory_type, VkDeviceSize size, VkDeviceMemory *vk_memory) DECLSPEC_HIDDEN;
2399 VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_context_vk *context_vk,
2400 unsigned int pool, size_t size) DECLSPEC_HIDDEN;
2401 VkCommandBuffer wined3d_context_vk_apply_compute_state(struct wined3d_context_vk *context_vk,
2402 const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk) DECLSPEC_HIDDEN;
2403 void wined3d_context_vk_cleanup(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2404 BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size,
2405 VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2406 void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *context_vk,
2407 struct wined3d_allocator_block *block, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2408 void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk,
2409 const struct wined3d_bo_vk *bo) DECLSPEC_HIDDEN;
2410 void wined3d_context_vk_destroy_buffer_view(struct wined3d_context_vk *context_vk,
2411 VkBufferView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2412 void wined3d_context_vk_destroy_framebuffer(struct wined3d_context_vk *context_vk,
2413 VkFramebuffer vk_framebuffer, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2414 void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk,
2415 VkImage vk_image, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2416 void wined3d_context_vk_destroy_image_view(struct wined3d_context_vk *context_vk,
2417 VkImageView vk_view, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2418 void wined3d_context_vk_destroy_memory(struct wined3d_context_vk *context_vk,
2419 VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2420 void wined3d_context_vk_destroy_sampler(struct wined3d_context_vk *context_vk,
2421 VkSampler vk_sampler, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
2422 VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
2423 struct wined3d_pipeline_layout_vk *wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk,
2424 VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count) DECLSPEC_HIDDEN;
2425 VkRenderPass wined3d_context_vk_get_render_pass(struct wined3d_context_vk *context_vk,
2426 const struct wined3d_fb_state *fb, unsigned int rt_count,
2427 bool depth_stencil, uint32_t clear_flags) DECLSPEC_HIDDEN;
2428 void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk,
2429 VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask,
2430 VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout,
2431 VkImageLayout new_layout, VkImage image, VkImageAspectFlags aspect_mask) DECLSPEC_HIDDEN;
2432 HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
2433 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
2434 void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk,
2435 unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages,
2436 unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores) DECLSPEC_HIDDEN;
2437 void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id) DECLSPEC_HIDDEN;
2439 typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2441 struct wined3d_state_entry
2443 unsigned int representative;
2444 APPLYSTATEFUNC apply;
2447 struct wined3d_state_entry_template
2449 DWORD state;
2450 struct wined3d_state_entry content;
2451 unsigned int extension;
2454 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2455 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2456 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2458 struct fragment_caps
2460 DWORD wined3d_caps;
2461 DWORD PrimitiveMiscCaps;
2462 DWORD TextureOpCaps;
2463 DWORD MaxTextureBlendStages;
2464 DWORD MaxSimultaneousTextures;
2467 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2468 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2470 struct wined3d_fragment_pipe_ops
2472 void (*fp_enable)(const struct wined3d_context *context, BOOL enable);
2473 void (*get_caps)(const struct wined3d_adapter *adapter, struct fragment_caps *caps);
2474 DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2475 void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2476 void (*free_private)(struct wined3d_device *device, struct wined3d_context *context);
2477 BOOL (*allocate_context_data)(struct wined3d_context *context);
2478 void (*free_context_data)(struct wined3d_context *context);
2479 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2480 const struct wined3d_state_entry_template *states;
2483 struct wined3d_vertex_caps
2485 BOOL xyzrhw;
2486 BOOL emulated_flatshading;
2487 BOOL ffp_generic_attributes;
2488 DWORD max_active_lights;
2489 DWORD max_vertex_blend_matrices;
2490 DWORD max_vertex_blend_matrix_index;
2491 DWORD vertex_processing_caps;
2492 DWORD fvf_caps;
2493 DWORD max_user_clip_planes;
2494 DWORD raster_caps;
2497 struct wined3d_vertex_pipe_ops
2499 void (*vp_enable)(const struct wined3d_context *context, BOOL enable);
2500 void (*vp_get_caps)(const struct wined3d_adapter *adapter, struct wined3d_vertex_caps *caps);
2501 DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2502 void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2503 void (*vp_free)(struct wined3d_device *device, struct wined3d_context *context);
2504 const struct wined3d_state_entry_template *vp_states;
2507 extern const struct wined3d_state_entry_template misc_state_template_gl[] DECLSPEC_HIDDEN;
2508 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN;
2509 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN;
2510 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN;
2511 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN;
2512 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN;
2513 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN;
2514 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN;
2516 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN;
2517 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN;
2518 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN;
2520 /* "Base" state table */
2521 HRESULT compile_state_table(struct wined3d_state_entry *state_table, APPLYSTATEFUNC **dev_multistate_funcs,
2522 const struct wined3d_d3d_info *d3d_info, const BOOL *supported_extensions,
2523 const struct wined3d_vertex_pipe_ops *vertex, const struct wined3d_fragment_pipe_ops *fragment,
2524 const struct wined3d_state_entry_template *misc) DECLSPEC_HIDDEN;
2526 enum wined3d_blit_op
2528 WINED3D_BLIT_OP_COLOR_BLIT,
2529 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST,
2530 WINED3D_BLIT_OP_COLOR_BLIT_CKEY,
2531 WINED3D_BLIT_OP_DEPTH_BLIT,
2532 WINED3D_BLIT_OP_RAW_BLIT,
2535 struct wined3d_blitter
2537 const struct wined3d_blitter_ops *ops;
2538 struct wined3d_blitter *next;
2541 struct wined3d_blitter_ops
2543 void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2544 void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2545 unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2546 const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2547 DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2548 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
2549 const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
2550 DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
2551 enum wined3d_texture_filter_type filter);
2554 void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
2555 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2556 struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
2557 void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
2558 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2559 void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
2560 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2561 struct wined3d_blitter *wined3d_glsl_blitter_create(struct wined3d_blitter **next,
2562 const struct wined3d_device *device) DECLSPEC_HIDDEN;
2563 void wined3d_raw_blitter_create(struct wined3d_blitter **next,
2564 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2565 void wined3d_vk_blitter_create(struct wined3d_blitter **next) DECLSPEC_HIDDEN;
2567 BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
2569 HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2570 DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
2571 void context_gl_resource_released(struct wined3d_device *device,
2572 GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2573 void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2574 void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2575 void context_resource_released(const struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
2576 void context_restore(struct wined3d_context *context, struct wined3d_texture *texture,
2577 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2578 void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
2579 void context_state_drawbuf(struct wined3d_context *context,
2580 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2581 void context_state_fb(struct wined3d_context *context,
2582 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2584 /*****************************************************************************
2585 * Internal representation of a light
2587 struct wined3d_light_info
2589 struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2590 DWORD OriginalIndex;
2591 LONG glIndex;
2592 BOOL enabled;
2594 /* Converted parms to speed up swapping lights */
2595 struct wined3d_vec4 position;
2596 struct wined3d_vec4 direction;
2597 float exponent;
2598 float cutoff;
2600 struct list entry;
2603 /* The default light parameters */
2604 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
2606 struct wined3d_pixel_format
2608 int iPixelFormat; /* WGL pixel format */
2609 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2610 int redSize, greenSize, blueSize, alphaSize, colorSize;
2611 int depthSize, stencilSize;
2612 BOOL windowDrawable;
2613 BOOL doubleBuffer;
2614 int auxBuffers;
2615 int numSamples;
2618 enum wined3d_pci_vendor
2620 HW_VENDOR_SOFTWARE = 0x0000,
2621 HW_VENDOR_AMD = 0x1002,
2622 HW_VENDOR_NVIDIA = 0x10de,
2623 HW_VENDOR_VMWARE = 0x15ad,
2624 HW_VENDOR_REDHAT = 0x1af4,
2625 HW_VENDOR_INTEL = 0x8086,
2628 enum wined3d_pci_device
2630 CARD_WINE = 0x0000,
2632 CARD_AMD_RAGE_128PRO = 0x5246,
2633 CARD_AMD_RADEON_7200 = 0x5144,
2634 CARD_AMD_RADEON_8500 = 0x514c,
2635 CARD_AMD_RADEON_9500 = 0x4144,
2636 CARD_AMD_RADEON_XPRESS_200M = 0x5955,
2637 CARD_AMD_RADEON_X700 = 0x5e4c,
2638 CARD_AMD_RADEON_X1600 = 0x71c2,
2639 CARD_AMD_RADEON_HD2350 = 0x94c7,
2640 CARD_AMD_RADEON_HD2600 = 0x9581,
2641 CARD_AMD_RADEON_HD2900 = 0x9400,
2642 CARD_AMD_RADEON_HD3200 = 0x9620,
2643 CARD_AMD_RADEON_HD3850 = 0x9515,
2644 CARD_AMD_RADEON_HD4200M = 0x9712,
2645 CARD_AMD_RADEON_HD4350 = 0x954f,
2646 CARD_AMD_RADEON_HD4600 = 0x9495,
2647 CARD_AMD_RADEON_HD4700 = 0x944e,
2648 CARD_AMD_RADEON_HD4800 = 0x944c,
2649 CARD_AMD_RADEON_HD5400 = 0x68f9,
2650 CARD_AMD_RADEON_HD5600 = 0x68d8,
2651 CARD_AMD_RADEON_HD5700 = 0x68be,
2652 CARD_AMD_RADEON_HD5800 = 0x6898,
2653 CARD_AMD_RADEON_HD5900 = 0x689c,
2654 CARD_AMD_RADEON_HD6300 = 0x9803,
2655 CARD_AMD_RADEON_HD6400 = 0x6770,
2656 CARD_AMD_RADEON_HD6490M = 0x6760,
2657 CARD_AMD_RADEON_HD6410D = 0x9644,
2658 CARD_AMD_RADEON_HD6480G = 0x9648,
2659 CARD_AMD_RADEON_HD6550D = 0x9640,
2660 CARD_AMD_RADEON_HD6600 = 0x6758,
2661 CARD_AMD_RADEON_HD6600M = 0x6741,
2662 CARD_AMD_RADEON_HD6700 = 0x68ba,
2663 CARD_AMD_RADEON_HD6800 = 0x6739,
2664 CARD_AMD_RADEON_HD6900 = 0x6719,
2665 CARD_AMD_RADEON_HD7660D = 0x9901,
2666 CARD_AMD_RADEON_HD7700 = 0x683d,
2667 CARD_AMD_RADEON_HD7800 = 0x6819,
2668 CARD_AMD_RADEON_HD7870 = 0x6818,
2669 CARD_AMD_RADEON_HD7900 = 0x679a,
2670 CARD_AMD_RADEON_HD8600M = 0x6660,
2671 CARD_AMD_RADEON_HD8670 = 0x6610,
2672 CARD_AMD_RADEON_HD8770 = 0x665c,
2673 CARD_AMD_RADEON_R3 = 0x9830,
2674 CARD_AMD_RADEON_R7 = 0x130f,
2675 CARD_AMD_RADEON_R9_285 = 0x6939,
2676 CARD_AMD_RADEON_R9_290 = 0x67b1,
2677 CARD_AMD_RADEON_R9_290X = 0x67b0,
2678 CARD_AMD_RADEON_R9_FURY = 0x7300,
2679 CARD_AMD_RADEON_R9_M370X = 0x6821,
2680 CARD_AMD_RADEON_R9_M380 = 0x6647,
2681 CARD_AMD_RADEON_R9_M395X = 0x6920,
2682 CARD_AMD_RADEON_RX_460 = 0x67ef,
2683 CARD_AMD_RADEON_RX_480 = 0x67df,
2684 CARD_AMD_RADEON_RX_VEGA_10 = 0x687f,
2685 CARD_AMD_RADEON_RX_VEGA_12 = 0x69af,
2686 CARD_AMD_RADEON_RX_VEGA_20 = 0x66af,
2687 CARD_AMD_RADEON_RX_NAVI_10 = 0x731f,
2689 CARD_NVIDIA_RIVA_128 = 0x0018,
2690 CARD_NVIDIA_RIVA_TNT = 0x0020,
2691 CARD_NVIDIA_RIVA_TNT2 = 0x0028,
2692 CARD_NVIDIA_GEFORCE = 0x0100,
2693 CARD_NVIDIA_GEFORCE2_MX = 0x0110,
2694 CARD_NVIDIA_GEFORCE2 = 0x0150,
2695 CARD_NVIDIA_GEFORCE3 = 0x0200,
2696 CARD_NVIDIA_GEFORCE4_MX = 0x0170,
2697 CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
2698 CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
2699 CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
2700 CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
2701 CARD_NVIDIA_GEFORCE_6200 = 0x014f,
2702 CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
2703 CARD_NVIDIA_GEFORCE_6800 = 0x0041,
2704 CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2705 CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
2706 CARD_NVIDIA_GEFORCE_7600 = 0x0391,
2707 CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
2708 CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2709 CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
2710 CARD_NVIDIA_GEFORCE_8400GS = 0x0404,
2711 CARD_NVIDIA_GEFORCE_8500GT = 0x0421,
2712 CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
2713 CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
2714 CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
2715 CARD_NVIDIA_GEFORCE_8800GTX = 0x0191,
2716 CARD_NVIDIA_GEFORCE_9200 = 0x086d,
2717 CARD_NVIDIA_GEFORCE_9300 = 0x086c,
2718 CARD_NVIDIA_GEFORCE_9400M = 0x0863,
2719 CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
2720 CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
2721 CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
2722 CARD_NVIDIA_GEFORCE_9700MGT = 0x064a,
2723 CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
2724 CARD_NVIDIA_GEFORCE_210 = 0x0a23,
2725 CARD_NVIDIA_GEFORCE_GT220 = 0x0a20,
2726 CARD_NVIDIA_GEFORCE_GT240 = 0x0ca3,
2727 CARD_NVIDIA_GEFORCE_GTS250 = 0x0615,
2728 CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
2729 CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
2730 CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
2731 CARD_NVIDIA_GEFORCE_315M = 0x0a7a,
2732 CARD_NVIDIA_GEFORCE_320M = 0x08a3,
2733 CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
2734 CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
2735 CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
2736 CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
2737 CARD_NVIDIA_GEFORCE_410M = 0x1055,
2738 CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
2739 CARD_NVIDIA_GEFORCE_GT425M = 0x0df0,
2740 CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
2741 CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
2742 CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
2743 CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
2744 CARD_NVIDIA_GEFORCE_GTX460M = 0x0dd1,
2745 CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
2746 CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
2747 CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
2748 CARD_NVIDIA_GEFORCE_GT520 = 0x1040,
2749 CARD_NVIDIA_GEFORCE_GT525M = 0x0dec,
2750 CARD_NVIDIA_GEFORCE_GT540M = 0x0df4,
2751 CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
2752 CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
2753 CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
2754 CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
2755 CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
2756 CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
2757 CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
2758 CARD_NVIDIA_GEFORCE_GT610 = 0x104a,
2759 CARD_NVIDIA_GEFORCE_GT630 = 0x0f00,
2760 CARD_NVIDIA_GEFORCE_GT630M = 0x0de9,
2761 CARD_NVIDIA_GEFORCE_GT640 = 0x0fc1,
2762 CARD_NVIDIA_GEFORCE_GT640M = 0x0fd2,
2763 CARD_NVIDIA_GEFORCE_GT650M = 0x0fd1,
2764 CARD_NVIDIA_GEFORCE_GTX650 = 0x0fc6,
2765 CARD_NVIDIA_GEFORCE_GTX650TI = 0x11c6,
2766 CARD_NVIDIA_GEFORCE_GTX660 = 0x11c0,
2767 CARD_NVIDIA_GEFORCE_GTX660M = 0x0fd4,
2768 CARD_NVIDIA_GEFORCE_GTX660TI = 0x1183,
2769 CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
2770 CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
2771 CARD_NVIDIA_GEFORCE_GTX675MX_1 = 0x11a7,
2772 CARD_NVIDIA_GEFORCE_GTX675MX_2 = 0x11a2,
2773 CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
2774 CARD_NVIDIA_GEFORCE_GTX690 = 0x1188,
2775 CARD_NVIDIA_GEFORCE_GT720 = 0x128b,
2776 CARD_NVIDIA_GEFORCE_GT730 = 0x1287,
2777 CARD_NVIDIA_GEFORCE_GT730M = 0x0fe1,
2778 CARD_NVIDIA_GEFORCE_GT740M = 0x1292,
2779 CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
2780 CARD_NVIDIA_GEFORCE_GT755M = 0x0fcd,
2781 CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
2782 CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
2783 CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
2784 CARD_NVIDIA_GEFORCE_GTX760TI = 0x1193,
2785 CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2,
2786 CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0,
2787 CARD_NVIDIA_GEFORCE_GTX770 = 0x1184,
2788 CARD_NVIDIA_GEFORCE_GTX775M = 0x119d,
2789 CARD_NVIDIA_GEFORCE_GTX780 = 0x1004,
2790 CARD_NVIDIA_GEFORCE_GTX780M = 0x119e,
2791 CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a,
2792 CARD_NVIDIA_GEFORCE_GTXTITAN = 0x1005,
2793 CARD_NVIDIA_GEFORCE_GTXTITANB = 0x100c,
2794 CARD_NVIDIA_GEFORCE_GTXTITANX = 0x17c2,
2795 CARD_NVIDIA_GEFORCE_GTXTITANZ = 0x1001,
2796 CARD_NVIDIA_GEFORCE_820M = 0x0fed,
2797 CARD_NVIDIA_GEFORCE_830M = 0x1340,
2798 CARD_NVIDIA_GEFORCE_840M = 0x1341,
2799 CARD_NVIDIA_GEFORCE_845M = 0x1344,
2800 CARD_NVIDIA_GEFORCE_GTX850M = 0x1391,
2801 CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
2802 CARD_NVIDIA_GEFORCE_GTX870M = 0x1199,
2803 CARD_NVIDIA_GEFORCE_GTX880M = 0x1198,
2804 CARD_NVIDIA_GEFORCE_940M = 0x1347,
2805 CARD_NVIDIA_GEFORCE_GTX950 = 0x1402,
2806 CARD_NVIDIA_GEFORCE_GTX950M = 0x139a,
2807 CARD_NVIDIA_GEFORCE_GTX960 = 0x1401,
2808 CARD_NVIDIA_GEFORCE_GTX960M = 0x139b,
2809 CARD_NVIDIA_GEFORCE_GTX970 = 0x13c2,
2810 CARD_NVIDIA_GEFORCE_GTX970M = 0x13d8,
2811 CARD_NVIDIA_GEFORCE_GTX980 = 0x13c0,
2812 CARD_NVIDIA_GEFORCE_GTX980TI = 0x17c8,
2813 CARD_NVIDIA_GEFORCE_GTX1050 = 0x1c81,
2814 CARD_NVIDIA_GEFORCE_GTX1050TI = 0x1c82,
2815 CARD_NVIDIA_GEFORCE_GTX1060_3GB = 0x1c02,
2816 CARD_NVIDIA_GEFORCE_GTX1060 = 0x1c03,
2817 CARD_NVIDIA_GEFORCE_GTX1070 = 0x1b81,
2818 CARD_NVIDIA_GEFORCE_GTX1080 = 0x1b80,
2819 CARD_NVIDIA_GEFORCE_GTX1080TI = 0x1b06,
2820 CARD_NVIDIA_TITANX_PASCAL = 0x1b00,
2821 CARD_NVIDIA_TITANV = 0x1d81,
2822 CARD_NVIDIA_GEFORCE_GTX1650SUPER= 0x2187,
2823 CARD_NVIDIA_GEFORCE_GTX1660SUPER= 0x21c4,
2824 CARD_NVIDIA_GEFORCE_GTX1660TI = 0x2182,
2825 CARD_NVIDIA_GEFORCE_RTX2060 = 0x1f08,
2826 CARD_NVIDIA_GEFORCE_RTX2070 = 0x1f07,
2827 CARD_NVIDIA_GEFORCE_RTX2080 = 0x1e87,
2828 CARD_NVIDIA_GEFORCE_RTX2080TI = 0x1e07,
2830 CARD_REDHAT_VIRGL = 0x1010,
2832 CARD_VMWARE_SVGA3D = 0x0405,
2834 CARD_INTEL_830M = 0x3577,
2835 CARD_INTEL_855GM = 0x3582,
2836 CARD_INTEL_845G = 0x2562,
2837 CARD_INTEL_865G = 0x2572,
2838 CARD_INTEL_915G = 0x2582,
2839 CARD_INTEL_E7221G = 0x258a,
2840 CARD_INTEL_915GM = 0x2592,
2841 CARD_INTEL_945G = 0x2772,
2842 CARD_INTEL_945GM = 0x27a2,
2843 CARD_INTEL_945GME = 0x27ae,
2844 CARD_INTEL_Q35 = 0x29b2,
2845 CARD_INTEL_G33 = 0x29c2,
2846 CARD_INTEL_Q33 = 0x29d2,
2847 CARD_INTEL_PNVG = 0xa001,
2848 CARD_INTEL_PNVM = 0xa011,
2849 CARD_INTEL_965Q = 0x2992,
2850 CARD_INTEL_965G = 0x2982,
2851 CARD_INTEL_946GZ = 0x2972,
2852 CARD_INTEL_965GM = 0x2a02,
2853 CARD_INTEL_965GME = 0x2a12,
2854 CARD_INTEL_GM45 = 0x2a42,
2855 CARD_INTEL_IGD = 0x2e02,
2856 CARD_INTEL_Q45 = 0x2e12,
2857 CARD_INTEL_G45 = 0x2e22,
2858 CARD_INTEL_G41 = 0x2e32,
2859 CARD_INTEL_B43 = 0x2e92,
2860 CARD_INTEL_ILKD = 0x0042,
2861 CARD_INTEL_ILKM = 0x0046,
2862 CARD_INTEL_SNBD = 0x0122,
2863 CARD_INTEL_SNBM = 0x0126,
2864 CARD_INTEL_SNBS = 0x010a,
2865 CARD_INTEL_IVBD = 0x0162,
2866 CARD_INTEL_IVBM = 0x0166,
2867 CARD_INTEL_IVBS = 0x015a,
2868 CARD_INTEL_HWD = 0x0412,
2869 CARD_INTEL_HWM = 0x0416,
2870 CARD_INTEL_HD5000_1 = 0x0a26,
2871 CARD_INTEL_HD5000_2 = 0x0422,
2872 CARD_INTEL_I5100_1 = 0x0a22,
2873 CARD_INTEL_I5100_2 = 0x0a2a,
2874 CARD_INTEL_I5100_3 = 0x0a2b,
2875 CARD_INTEL_I5100_4 = 0x0a2e,
2876 CARD_INTEL_IP5200_1 = 0x0d22,
2877 CARD_INTEL_IP5200_2 = 0x0d26,
2878 CARD_INTEL_IP5200_3 = 0x0d2a,
2879 CARD_INTEL_IP5200_4 = 0x0d2b,
2880 CARD_INTEL_IP5200_5 = 0x0d2e,
2881 CARD_INTEL_IP5200_6 = 0x0c22,
2882 CARD_INTEL_HD5300 = 0x161e,
2883 CARD_INTEL_HD5500 = 0x1616,
2884 CARD_INTEL_HD5600 = 0x1612,
2885 CARD_INTEL_HD6000 = 0x1626,
2886 CARD_INTEL_I6100 = 0x162b,
2887 CARD_INTEL_IP6200 = 0x1622,
2888 CARD_INTEL_IPP6300 = 0x162a,
2889 CARD_INTEL_HD510_1 = 0x1902,
2890 CARD_INTEL_HD510_2 = 0x1906,
2891 CARD_INTEL_HD510_3 = 0x190b,
2892 CARD_INTEL_HD515 = 0x191e,
2893 CARD_INTEL_HD520_1 = 0x1916,
2894 CARD_INTEL_HD520_2 = 0x1921,
2895 CARD_INTEL_HD530_1 = 0x1912,
2896 CARD_INTEL_HD530_2 = 0x191b,
2897 CARD_INTEL_HDP530 = 0x191d,
2898 CARD_INTEL_I540 = 0x1926,
2899 CARD_INTEL_I550 = 0x1927,
2900 CARD_INTEL_I555 = 0x192b,
2901 CARD_INTEL_IP555 = 0x192d,
2902 CARD_INTEL_IP580_1 = 0x1932,
2903 CARD_INTEL_IP580_2 = 0x193b,
2904 CARD_INTEL_IPP580_1 = 0x193a,
2905 CARD_INTEL_IPP580_2 = 0x193d,
2906 CARD_INTEL_UHD617 = 0x87c0,
2907 CARD_INTEL_UHD620 = 0x3ea0,
2908 CARD_INTEL_HD615 = 0x591e,
2909 CARD_INTEL_HD620 = 0x5916,
2910 CARD_INTEL_HD630_1 = 0x5912,
2911 CARD_INTEL_HD630_2 = 0x591b,
2914 struct wined3d_fbo_ops
2916 GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
2917 void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
2918 void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
2919 void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
2920 void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
2921 GLsizei width, GLsizei height);
2922 void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
2923 GLenum internalformat, GLsizei width, GLsizei height);
2924 void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
2925 GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
2926 void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
2927 void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
2928 void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
2929 GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
2930 void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
2931 GLuint texture, GLint level);
2932 void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
2933 GLenum textarget, GLuint texture, GLint level);
2934 void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
2935 GLenum textarget, GLuint texture, GLint level);
2936 void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
2937 GLenum textarget, GLuint texture, GLint level, GLint layer);
2938 void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
2939 GLuint texture, GLint level, GLint layer);
2940 void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
2941 GLenum renderbuffertarget, GLuint renderbuffer);
2942 void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
2943 GLenum pname, GLint *params);
2944 void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2945 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2946 void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
2949 struct wined3d_gl_limits
2951 UINT buffers;
2952 UINT lights;
2953 UINT textures;
2954 UINT texture_coords;
2955 unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
2956 unsigned int samplers[WINED3D_SHADER_TYPE_COUNT];
2957 unsigned int graphics_samplers;
2958 unsigned int combined_samplers;
2959 UINT general_combiners;
2960 UINT user_clip_distances;
2961 unsigned int texture_size;
2962 UINT texture3d_size;
2963 UINT anisotropy;
2964 float shininess;
2965 UINT samples;
2966 UINT vertex_attribs;
2968 unsigned int texture_buffer_offset_alignment;
2970 unsigned int framebuffer_width;
2971 unsigned int framebuffer_height;
2973 UINT glsl_varyings;
2974 UINT glsl_vs_float_constants;
2975 UINT glsl_ps_float_constants;
2977 UINT arb_vs_float_constants;
2978 UINT arb_vs_native_constants;
2979 UINT arb_vs_instructions;
2980 UINT arb_vs_temps;
2981 UINT arb_ps_float_constants;
2982 UINT arb_ps_local_constants;
2983 UINT arb_ps_native_constants;
2984 UINT arb_ps_instructions;
2985 UINT arb_ps_temps;
2988 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
2989 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2990 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits,
2991 enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2993 struct wined3d_gl_info
2995 DWORD selected_gl_version;
2996 DWORD glsl_version;
2997 struct wined3d_gl_limits limits;
2998 DWORD reserved_glsl_constants, reserved_arb_constants;
2999 DWORD quirks;
3000 BOOL supported[WINED3D_GL_EXT_COUNT];
3001 GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
3003 HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
3004 struct opengl_funcs gl_ops;
3005 struct wined3d_fbo_ops fbo_ops;
3007 void (WINE_GLAPI *p_glDisableWINE)(GLenum cap);
3008 void (WINE_GLAPI *p_glEnableWINE)(GLenum cap);
3011 /* The driver names reflect the lowest GPU supported
3012 * by a certain driver, so DRIVER_AMD_R300 supports
3013 * R3xx, R4xx and R5xx GPUs. */
3014 enum wined3d_display_driver
3016 DRIVER_AMD_RAGE_128PRO,
3017 DRIVER_AMD_R100,
3018 DRIVER_AMD_R300,
3019 DRIVER_AMD_R600,
3020 DRIVER_AMD_RX,
3021 DRIVER_INTEL_GMA800,
3022 DRIVER_INTEL_GMA900,
3023 DRIVER_INTEL_GMA950,
3024 DRIVER_INTEL_GMA3000,
3025 DRIVER_INTEL_HD4000,
3026 DRIVER_NVIDIA_TNT,
3027 DRIVER_NVIDIA_GEFORCE2MX,
3028 DRIVER_NVIDIA_GEFORCEFX,
3029 DRIVER_NVIDIA_GEFORCE6,
3030 DRIVER_NVIDIA_GEFORCE8,
3031 DRIVER_REDHAT_VIRGL,
3032 DRIVER_VMWARE,
3033 DRIVER_WINE,
3034 DRIVER_UNKNOWN,
3037 struct wined3d_gpu_description
3039 enum wined3d_pci_vendor vendor;
3040 enum wined3d_pci_device device;
3041 const char *description;
3042 enum wined3d_display_driver driver;
3043 unsigned int vidmem;
3046 const struct wined3d_gpu_description *wined3d_get_gpu_description(enum wined3d_pci_vendor vendor,
3047 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
3048 const struct wined3d_gpu_description *wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor,
3049 enum wined3d_pci_device device) DECLSPEC_HIDDEN;
3050 enum wined3d_pci_device wined3d_gpu_from_feature_level(enum wined3d_pci_vendor *vendor,
3051 enum wined3d_feature_level feature_level) DECLSPEC_HIDDEN;
3053 /* 512 in Direct3D 8/9, 128 in DXGI. */
3054 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
3056 struct wined3d_driver_info
3058 enum wined3d_pci_vendor vendor;
3059 enum wined3d_pci_device device;
3060 const char *name;
3061 char description[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH];
3062 UINT64 vram_bytes;
3063 UINT64 sysmem_bytes;
3064 DWORD version_high;
3065 DWORD version_low;
3068 void wined3d_driver_info_init(struct wined3d_driver_info *driver_info,
3069 const struct wined3d_gpu_description *gpu_description,
3070 UINT64 vram_bytes, UINT64 sysmem_bytes) DECLSPEC_HIDDEN;
3072 struct wined3d_adapter_ops
3074 void (*adapter_destroy)(struct wined3d_adapter *adapter);
3075 HRESULT (*adapter_create_device)(struct wined3d *wined3d, const struct wined3d_adapter *adapter,
3076 enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3077 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3078 struct wined3d_device_parent *device_parent, struct wined3d_device **device);
3079 void (*adapter_destroy_device)(struct wined3d_device *device);
3080 struct wined3d_context *(*adapter_acquire_context)(struct wined3d_device *device,
3081 struct wined3d_texture *texture, unsigned int sub_resource_idx);
3082 void (*adapter_release_context)(struct wined3d_context *context);
3083 void (*adapter_get_wined3d_caps)(const struct wined3d_adapter *adapter, struct wined3d_caps *caps);
3084 BOOL (*adapter_check_format)(const struct wined3d_adapter *adapter,
3085 const struct wined3d_format *adapter_format, const struct wined3d_format *rt_format,
3086 const struct wined3d_format *ds_format);
3087 HRESULT (*adapter_init_3d)(struct wined3d_device *device);
3088 void (*adapter_uninit_3d)(struct wined3d_device *device);
3089 void *(*adapter_map_bo_address)(struct wined3d_context *context,
3090 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags);
3091 void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data,
3092 unsigned int range_count, const struct wined3d_range *ranges);
3093 void (*adapter_copy_bo_address)(struct wined3d_context *context,
3094 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size);
3095 HRESULT (*adapter_create_swapchain)(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
3096 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
3097 void (*adapter_destroy_swapchain)(struct wined3d_swapchain *swapchain);
3098 HRESULT (*adapter_create_buffer)(struct wined3d_device *device, const struct wined3d_buffer_desc *desc,
3099 const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops,
3100 struct wined3d_buffer **buffer);
3101 void (*adapter_destroy_buffer)(struct wined3d_buffer *buffer);
3102 HRESULT (*adapter_create_texture)(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
3103 unsigned int layer_count, unsigned int level_count, uint32_t flags, void *parent,
3104 const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
3105 void (*adapter_destroy_texture)(struct wined3d_texture *texture);
3106 HRESULT (*adapter_create_rendertarget_view)(const struct wined3d_view_desc *desc,
3107 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3108 struct wined3d_rendertarget_view **view);
3109 void (*adapter_destroy_rendertarget_view)(struct wined3d_rendertarget_view *view);
3110 HRESULT (*adapter_create_shader_resource_view)(const struct wined3d_view_desc *desc,
3111 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3112 struct wined3d_shader_resource_view **view);
3113 void (*adapter_destroy_shader_resource_view)(struct wined3d_shader_resource_view *view);
3114 HRESULT (*adapter_create_unordered_access_view)(const struct wined3d_view_desc *desc,
3115 struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops,
3116 struct wined3d_unordered_access_view **view);
3117 void (*adapter_destroy_unordered_access_view)(struct wined3d_unordered_access_view *view);
3118 HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
3119 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler);
3120 void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler);
3121 HRESULT (*adapter_create_query)(struct wined3d_device *device, enum wined3d_query_type type,
3122 void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query);
3123 void (*adapter_destroy_query)(struct wined3d_query *query);
3124 void (*adapter_flush_context)(struct wined3d_context *context);
3125 void (*adapter_draw_primitive)(struct wined3d_device *device, const struct wined3d_state *state,
3126 const struct wined3d_draw_parameters *parameters);
3127 void (*adapter_dispatch_compute)(struct wined3d_device *device, const struct wined3d_state *state,
3128 const struct wined3d_dispatch_parameters *parameters);
3129 void (*adapter_clear_uav)(struct wined3d_context *context,
3130 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value);
3133 struct wined3d_output
3135 unsigned int ordinal;
3136 WCHAR device_name[CCHDEVICENAME];
3137 struct wined3d_adapter *adapter;
3138 enum wined3d_format_id screen_format;
3140 D3DKMT_HANDLE kmt_adapter;
3141 D3DKMT_HANDLE kmt_device;
3142 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id;
3145 /* The adapter structure */
3146 struct wined3d_adapter
3148 unsigned int ordinal;
3150 struct wined3d_gl_info gl_info;
3151 struct wined3d_d3d_info d3d_info;
3152 struct wined3d_driver_info driver_info;
3153 struct wined3d_output *outputs;
3154 unsigned int output_count;
3155 UINT64 vram_bytes_used;
3156 GUID driver_uuid;
3157 GUID device_uuid;
3158 LUID luid;
3160 WCHAR device_name[CCHDEVICENAME]; /* for use with e.g. ChangeDisplaySettings() */
3162 void *formats;
3163 size_t format_size;
3165 const struct wined3d_vertex_pipe_ops *vertex_pipe;
3166 const struct wined3d_fragment_pipe_ops *fragment_pipe;
3167 const struct wined3d_state_entry_template *misc_state_template;
3168 const struct wined3d_shader_backend_ops *shader_backend;
3169 const struct wined3d_adapter_ops *adapter_ops;
3172 BOOL wined3d_adapter_init(struct wined3d_adapter *adapter, unsigned int ordinal,
3173 const struct wined3d_adapter_ops *adapter_ops) DECLSPEC_HIDDEN;
3174 void wined3d_adapter_cleanup(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
3176 struct wined3d_adapter_gl
3178 struct wined3d_adapter a;
3180 struct wined3d_pixel_format *pixel_formats;
3181 unsigned int pixel_format_count;
3184 static inline struct wined3d_adapter_gl *wined3d_adapter_gl(struct wined3d_adapter *adapter)
3186 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
3189 static inline const struct wined3d_adapter_gl *wined3d_adapter_gl_const(const struct wined3d_adapter *adapter)
3191 return CONTAINING_RECORD(adapter, struct wined3d_adapter_gl, a);
3194 struct wined3d_adapter *wined3d_adapter_gl_create(unsigned int ordinal,
3195 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
3197 struct wined3d_adapter_vk
3199 struct wined3d_adapter a;
3201 struct wined3d_vk_info vk_info;
3202 VkPhysicalDevice physical_device;
3204 VkPhysicalDeviceLimits device_limits;
3205 VkPhysicalDeviceMemoryProperties memory_properties;
3208 static inline struct wined3d_adapter_vk *wined3d_adapter_vk(struct wined3d_adapter *adapter)
3210 return CONTAINING_RECORD(adapter, struct wined3d_adapter_vk, a);
3213 struct wined3d_adapter *wined3d_adapter_vk_create(unsigned int ordinal,
3214 unsigned int wined3d_creation_flags) DECLSPEC_HIDDEN;
3215 unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk,
3216 uint32_t memory_type_mask, VkMemoryPropertyFlags flags) DECLSPEC_HIDDEN;
3218 struct wined3d_caps_gl_ctx
3220 HDC dc;
3221 HWND wnd;
3222 HGLRC gl_ctx;
3223 HDC restore_dc;
3224 HGLRC restore_gl_ctx;
3226 const struct wined3d_gl_info *gl_info;
3227 GLuint test_vbo;
3228 GLuint test_program_id;
3231 BOOL wined3d_adapter_gl_init_format_info(struct wined3d_adapter *adapter,
3232 struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3233 BOOL wined3d_adapter_no3d_init_format_info(struct wined3d_adapter *adapter) DECLSPEC_HIDDEN;
3234 BOOL wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk *adapter_vk,
3235 const struct wined3d_vk_info *vk_info) DECLSPEC_HIDDEN;
3236 UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
3238 BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
3240 void install_gl_compat_wrapper(struct wined3d_gl_info *gl_info, enum wined3d_gl_extension ext) DECLSPEC_HIDDEN;
3242 enum wined3d_projection_type
3244 WINED3D_PROJECTION_NONE = 0,
3245 WINED3D_PROJECTION_COUNT3 = 1,
3246 WINED3D_PROJECTION_COUNT4 = 2
3249 /*****************************************************************************
3250 * Fixed function pipeline replacements
3252 #define ARG_UNUSED 0xff
3253 struct texture_stage_op
3255 unsigned cop : 8;
3256 unsigned carg1 : 8;
3257 unsigned carg2 : 8;
3258 unsigned carg0 : 8;
3260 unsigned aop : 8;
3261 unsigned aarg1 : 8;
3262 unsigned aarg2 : 8;
3263 unsigned aarg0 : 8;
3265 struct color_fixup_desc color_fixup;
3266 unsigned tex_type : 3;
3267 unsigned tmp_dst : 1;
3268 unsigned projected : 2;
3269 unsigned padding : 10;
3272 struct ffp_frag_settings
3274 struct texture_stage_op op[WINED3D_MAX_TEXTURES];
3275 enum wined3d_ffp_ps_fog_mode fog;
3276 unsigned char sRGB_write;
3277 unsigned char emul_clipplanes;
3278 unsigned char texcoords_initialized;
3279 unsigned char color_key_enabled : 1;
3280 unsigned char pointsprite : 1;
3281 unsigned char flatshading : 1;
3282 unsigned char alpha_test_func : 3;
3283 unsigned char padding : 2;
3286 struct ffp_frag_desc
3288 struct wine_rb_entry entry;
3289 struct ffp_frag_settings settings;
3292 int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3293 int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
3295 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
3297 void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
3298 struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
3299 const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
3300 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
3301 void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
3302 void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
3304 enum wined3d_ffp_vs_fog_mode
3306 WINED3D_FFP_VS_FOG_OFF = 0,
3307 WINED3D_FFP_VS_FOG_FOGCOORD = 1,
3308 WINED3D_FFP_VS_FOG_DEPTH = 2,
3309 WINED3D_FFP_VS_FOG_RANGE = 3,
3312 #define WINED3D_FFP_TCI_SHIFT 16
3313 #define WINED3D_FFP_TCI_MASK 0xffu
3315 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3316 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3318 struct wined3d_ffp_vs_settings
3320 DWORD point_light_count : 4;
3321 DWORD spot_light_count : 4;
3322 DWORD directional_light_count : 4;
3323 DWORD parallel_point_light_count : 4;
3324 DWORD diffuse_source : 2;
3325 DWORD emissive_source : 2;
3326 DWORD ambient_source : 2;
3327 DWORD specular_source : 2;
3328 DWORD transformed : 1;
3329 DWORD vertexblends : 2;
3330 DWORD clipping : 1;
3331 DWORD normal : 1;
3332 DWORD normalize : 1;
3333 DWORD lighting : 1;
3334 DWORD localviewer : 1;
3336 DWORD point_size : 1;
3337 DWORD per_vertex_point_size : 1;
3338 DWORD fog_mode : 2;
3339 DWORD texcoords : 8; /* WINED3D_MAX_TEXTURES */
3340 DWORD ortho_fog : 1;
3341 DWORD flatshading : 1;
3342 DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
3343 DWORD padding : 2;
3345 DWORD texgen[WINED3D_MAX_TEXTURES];
3348 struct wined3d_ffp_vs_desc
3350 struct wine_rb_entry entry;
3351 struct wined3d_ffp_vs_settings settings;
3354 void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
3355 const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) DECLSPEC_HIDDEN;
3357 struct wined3d
3359 LONG ref;
3360 unsigned int flags;
3361 unsigned int adapter_count;
3362 struct wined3d_adapter *adapters[1];
3365 BOOL wined3d_filter_messages(HWND window, BOOL filter) DECLSPEC_HIDDEN;
3366 void wined3d_hook_swapchain(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3367 HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN;
3368 void wined3d_unhook_swapchain(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3369 void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
3371 BOOL wined3d_get_app_name(char *app_name, unsigned int app_name_size) DECLSPEC_HIDDEN;
3373 struct wined3d_blend_state
3375 LONG refcount;
3376 struct wined3d_blend_state_desc desc;
3377 BOOL dual_source;
3379 void *parent;
3380 const struct wined3d_parent_ops *parent_ops;
3382 struct wined3d_device *device;
3383 struct wine_rb_entry entry;
3386 struct wined3d_rasterizer_state
3388 LONG refcount;
3389 struct wined3d_rasterizer_state_desc desc;
3391 void *parent;
3392 const struct wined3d_parent_ops *parent_ops;
3394 struct wined3d_device *device;
3395 struct wine_rb_entry entry;
3398 struct wined3d_stream_output
3400 struct wined3d_buffer *buffer;
3401 UINT offset;
3404 #define LIGHTMAP_SIZE 43
3405 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
3407 struct wined3d_light_state
3409 /* Light hashmap. Collisions are handled using linked lists. */
3410 struct list light_map[LIGHTMAP_SIZE];
3411 const struct wined3d_light_info *lights[WINED3D_MAX_ACTIVE_LIGHTS];
3414 #define WINED3D_STATE_NO_REF 0x00000001
3415 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3417 struct wined3d_state
3419 DWORD flags;
3420 struct wined3d_fb_state fb;
3422 struct wined3d_vertex_declaration *vertex_declaration;
3423 struct wined3d_stream_output stream_output[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
3424 struct wined3d_stream_state streams[WINED3D_MAX_STREAMS];
3425 struct wined3d_buffer *index_buffer;
3426 enum wined3d_format_id index_format;
3427 unsigned int index_offset;
3428 int base_vertex_index;
3429 int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3430 GLenum gl_primitive_type;
3431 GLint gl_patch_vertices;
3432 struct wined3d_query *predicate;
3433 BOOL predicate_value;
3435 struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
3436 struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
3437 struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
3438 struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
3439 struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
3441 struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3442 struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
3443 BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
3445 struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3446 struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
3447 BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
3449 struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS];
3450 DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
3451 DWORD texture_states[WINED3D_MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
3453 struct wined3d_matrix transforms[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
3454 struct wined3d_vec4 clip_planes[WINED3D_MAX_CLIP_DISTANCES];
3455 struct wined3d_material material;
3456 struct wined3d_viewport viewports[WINED3D_MAX_VIEWPORTS];
3457 unsigned int viewport_count;
3458 RECT scissor_rects[WINED3D_MAX_VIEWPORTS];
3459 unsigned int scissor_rect_count;
3461 struct wined3d_light_state light_state;
3463 DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
3464 struct wined3d_blend_state *blend_state;
3465 struct wined3d_color blend_factor;
3466 struct wined3d_rasterizer_state *rasterizer_state;
3469 struct wined3d_dummy_textures
3471 GLuint tex_1d;
3472 GLuint tex_2d;
3473 GLuint tex_rect;
3474 GLuint tex_3d;
3475 GLuint tex_cube;
3476 GLuint tex_cube_array;
3477 GLuint tex_1d_array;
3478 GLuint tex_2d_array;
3479 GLuint tex_buffer;
3480 GLuint tex_2d_ms;
3481 GLuint tex_2d_ms_array;
3484 #define WINED3D_UNMAPPED_STAGE ~0u
3486 /* Multithreaded flag. Removed from the public header to signal that
3487 * wined3d_device_create() ignores it. */
3488 #define WINED3DCREATE_MULTITHREADED 0x00000004
3490 struct wined3d_device
3492 LONG ref;
3494 /* WineD3D Information */
3495 struct wined3d_device_parent *device_parent;
3496 struct wined3d *wined3d;
3497 struct wined3d_adapter *adapter;
3499 const struct wined3d_shader_backend_ops *shader_backend;
3500 void *shader_priv;
3501 void *fragment_priv;
3502 void *vertex_priv;
3503 struct wined3d_state_entry state_table[STATE_HIGHEST + 1];
3504 /* Array of functions for states which are handled by more than one pipeline part */
3505 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
3506 struct wined3d_blitter *blitter;
3508 BYTE bCursorVisible : 1;
3509 BYTE d3d_initialized : 1;
3510 BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3511 BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
3512 BYTE restore_screensaver : 1;
3513 BYTE padding : 3;
3515 unsigned char surface_alignment; /* Line Alignment of surfaces */
3517 WORD padding2 : 16;
3519 enum wined3d_feature_level feature_level;
3521 struct wined3d_state state;
3523 /* Internal use fields */
3524 struct wined3d_device_creation_parameters create_parms;
3525 HWND focus_window;
3527 struct wined3d_rendertarget_view *back_buffer_view;
3528 struct wined3d_swapchain **swapchains;
3529 UINT swapchain_count;
3530 unsigned int max_frame_latency;
3532 struct list resources; /* a linked list to track resources created by the device */
3533 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
3534 struct wine_rb_tree samplers, rasterizer_states, blend_states;
3536 /* Render Target Support */
3537 struct wined3d_rendertarget_view *auto_depth_stencil_view;
3539 /* Cursor management */
3540 UINT xHotSpot;
3541 UINT yHotSpot;
3542 UINT xScreenSpace;
3543 UINT yScreenSpace;
3544 UINT cursorWidth, cursorHeight;
3545 struct wined3d_texture *cursor_texture;
3546 HCURSOR hardwareCursor;
3548 /* The Wine logo texture */
3549 struct wined3d_texture *logo_texture;
3551 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3552 struct wined3d_sampler *default_sampler;
3553 struct wined3d_sampler *null_sampler;
3555 /* Command stream */
3556 struct wined3d_cs *cs;
3558 /* Context management */
3559 struct wined3d_context **contexts;
3560 UINT context_count;
3563 void wined3d_device_cleanup(struct wined3d_device *device) DECLSPEC_HIDDEN;
3564 BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3565 void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3566 void wined3d_device_create_default_samplers(struct wined3d_device *device,
3567 struct wined3d_context *context) DECLSPEC_HIDDEN;
3568 void wined3d_device_create_primary_opengl_context_cs(void *object) DECLSPEC_HIDDEN;
3569 void wined3d_device_delete_opengl_contexts_cs(void *object) DECLSPEC_HIDDEN;
3570 void wined3d_device_destroy_default_samplers(struct wined3d_device *device,
3571 struct wined3d_context *context) DECLSPEC_HIDDEN;
3572 HRESULT wined3d_device_init(struct wined3d_device *device, struct wined3d *wined3d,
3573 unsigned int adapter_idx, enum wined3d_device_type device_type, HWND focus_window, unsigned int flags,
3574 BYTE surface_alignment, const enum wined3d_feature_level *levels, unsigned int level_count,
3575 struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3576 LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
3577 UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
3578 void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3579 void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3580 void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
3581 HRESULT wined3d_device_set_implicit_swapchain(struct wined3d_device *device,
3582 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3583 void wined3d_device_uninit_3d(struct wined3d_device *device) DECLSPEC_HIDDEN;
3585 struct wined3d_device_no3d
3587 struct wined3d_device d;
3589 struct wined3d_context context_no3d;
3592 static inline struct wined3d_device_no3d *wined3d_device_no3d(struct wined3d_device *device)
3594 return CONTAINING_RECORD(device, struct wined3d_device_no3d, d);
3597 struct wined3d_device_gl
3599 struct wined3d_device d;
3601 /* Textures for when no other textures are bound. */
3602 struct wined3d_dummy_textures dummy_textures;
3605 static inline struct wined3d_device_gl *wined3d_device_gl(struct wined3d_device *device)
3607 return CONTAINING_RECORD(device, struct wined3d_device_gl, d);
3610 struct wined3d_null_image_vk
3612 VkImage vk_image;
3613 struct wined3d_allocator_block *memory;
3614 VkDeviceMemory vk_memory;
3617 struct wined3d_null_resources_vk
3619 struct wined3d_bo_vk bo;
3620 struct wined3d_null_image_vk image_1d;
3623 struct wined3d_null_views_vk
3625 VkBufferView vk_view_buffer_uint;
3626 VkBufferView vk_view_buffer_float;
3628 VkDescriptorImageInfo vk_info_1d;
3631 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
3632 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
3633 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
3634 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
3636 struct wined3d_allocator_chunk
3638 struct list entry;
3639 struct list available[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT];
3640 struct wined3d_allocator *allocator;
3641 unsigned int map_count;
3642 void *map_ptr;
3645 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk *chunk) DECLSPEC_HIDDEN;
3646 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk *chunk,
3647 struct wined3d_allocator *allocator) DECLSPEC_HIDDEN;
3649 struct wined3d_allocator_chunk_vk
3651 struct wined3d_allocator_chunk c;
3652 VkDeviceMemory vk_memory;
3655 static inline struct wined3d_allocator_chunk_vk *wined3d_allocator_chunk_vk(struct wined3d_allocator_chunk *chunk)
3657 return CONTAINING_RECORD(chunk, struct wined3d_allocator_chunk_vk, c);
3660 void *wined3d_allocator_chunk_vk_map(struct wined3d_allocator_chunk_vk *chunk_vk,
3661 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3662 void wined3d_allocator_chunk_vk_unmap(struct wined3d_allocator_chunk_vk *chunk_vk,
3663 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3665 struct wined3d_allocator_block
3667 struct list entry;
3668 struct wined3d_allocator_chunk *chunk;
3669 struct wined3d_allocator_block *parent, *sibling;
3670 unsigned int order;
3671 size_t offset;
3672 bool free;
3675 void wined3d_allocator_block_free(struct wined3d_allocator_block *block) DECLSPEC_HIDDEN;
3677 struct wined3d_allocator_pool
3679 struct list chunks;
3682 struct wined3d_allocator_ops
3684 struct wined3d_allocator_chunk *(*allocator_create_chunk)(struct wined3d_allocator *allocator,
3685 struct wined3d_context *context, unsigned int memory_type, size_t chunk_size);
3686 void (*allocator_destroy_chunk)(struct wined3d_allocator_chunk *chunk);
3689 struct wined3d_allocator
3691 const struct wined3d_allocator_ops *ops;
3692 struct wined3d_allocator_pool *pools;
3693 size_t pool_count;
3694 struct wined3d_allocator_block *free;
3697 struct wined3d_allocator_block *wined3d_allocator_allocate(struct wined3d_allocator *allocator,
3698 struct wined3d_context *context, unsigned int memory_type, size_t size) DECLSPEC_HIDDEN;
3699 void wined3d_allocator_cleanup(struct wined3d_allocator *allocator) DECLSPEC_HIDDEN;
3700 bool wined3d_allocator_init(struct wined3d_allocator *allocator,
3701 size_t pool_count, const struct wined3d_allocator_ops *allocator_ops) DECLSPEC_HIDDEN;
3703 struct wined3d_device_vk
3705 struct wined3d_device d;
3707 struct wined3d_context_vk context_vk;
3709 VkDevice vk_device;
3710 VkQueue vk_queue;
3711 uint32_t vk_queue_family_index;
3713 struct wined3d_vk_info vk_info;
3715 struct wined3d_null_resources_vk null_resources_vk;
3716 struct wined3d_null_views_vk null_views_vk;
3718 struct wined3d_allocator allocator;
3721 static inline struct wined3d_device_vk *wined3d_device_vk(struct wined3d_device *device)
3723 return CONTAINING_RECORD(device, struct wined3d_device_vk, d);
3726 bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk *device_vk,
3727 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3728 bool wined3d_device_vk_create_null_views(struct wined3d_device_vk *device_vk,
3729 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3730 void wined3d_device_vk_destroy_null_resources(struct wined3d_device_vk *device_vk,
3731 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3732 void wined3d_device_vk_destroy_null_views(struct wined3d_device_vk *device_vk,
3733 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
3735 static inline float wined3d_alpha_ref(const struct wined3d_state *state)
3737 return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f;
3740 const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
3741 const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN;
3742 const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d,
3743 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3744 const char *wined3d_debug_vkresult(VkResult vr) DECLSPEC_HIDDEN;
3746 static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
3748 return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
3751 struct wined3d_resource_ops
3753 ULONG (*resource_incref)(struct wined3d_resource *resource);
3754 ULONG (*resource_decref)(struct wined3d_resource *resource);
3755 void (*resource_preload)(struct wined3d_resource *resource);
3756 void (*resource_unload)(struct wined3d_resource *resource);
3757 HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
3758 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
3759 HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
3762 struct wined3d_resource
3764 LONG ref;
3765 LONG bind_count;
3766 LONG srv_bind_count_device;
3767 LONG map_count;
3768 LONG access_count;
3769 struct wined3d_device *device;
3770 enum wined3d_resource_type type;
3771 enum wined3d_gl_resource_type gl_type;
3772 const struct wined3d_format *format;
3773 unsigned int format_flags;
3774 enum wined3d_multisample_type multisample_type;
3775 UINT multisample_quality;
3776 DWORD usage;
3777 unsigned int bind_flags;
3778 unsigned int access;
3779 WORD draw_binding;
3780 WORD map_binding;
3781 UINT width;
3782 UINT height;
3783 UINT depth;
3784 UINT size;
3785 DWORD priority;
3786 void *heap_memory;
3788 void *parent;
3789 const struct wined3d_parent_ops *parent_ops;
3790 const struct wined3d_resource_ops *resource_ops;
3792 struct list resource_list_entry;
3795 static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
3797 return resource->resource_ops->resource_incref(resource);
3800 static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
3802 return resource->resource_ops->resource_decref(resource);
3805 static inline void wined3d_resource_acquire(struct wined3d_resource *resource)
3807 InterlockedIncrement(&resource->access_count);
3810 static inline void wined3d_resource_release(struct wined3d_resource *resource)
3812 InterlockedDecrement(&resource->access_count);
3815 void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3816 HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
3817 enum wined3d_resource_type type, const struct wined3d_format *format,
3818 enum wined3d_multisample_type multisample_type, unsigned int multisample_quality, unsigned int usage,
3819 unsigned int bind_flags, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
3820 unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
3821 const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
3822 void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3823 void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3824 const struct wined3d_format *wined3d_resource_get_decompress_format(
3825 const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3826 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3827 GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3828 GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3829 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3830 BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3831 void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3833 /* Tests show that the start address of resources is 32 byte aligned */
3834 #define RESOURCE_ALIGNMENT 16
3835 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3837 #define WINED3D_LOCATION_DISCARDED 0x00000001
3838 #define WINED3D_LOCATION_SYSMEM 0x00000002
3839 #define WINED3D_LOCATION_USER_MEMORY 0x00000004
3840 #define WINED3D_LOCATION_BUFFER 0x00000008
3841 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3842 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3843 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3844 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3845 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3847 const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN;
3849 struct wined3d_blt_info
3851 GLenum bind_target;
3852 struct wined3d_vec3 texcoords[4];
3855 struct wined3d_texture_ops
3857 BOOL (*texture_prepare_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3858 struct wined3d_context *context, unsigned int location);
3859 BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3860 struct wined3d_context *context, unsigned int location);
3861 void (*texture_unload_location)(struct wined3d_texture *texture,
3862 struct wined3d_context *context, unsigned int location);
3863 void (*texture_upload_data)(struct wined3d_context *context, const struct wined3d_const_bo_address *src_bo_addr,
3864 const struct wined3d_format *src_format, const struct wined3d_box *src_box, unsigned int src_row_pitch,
3865 unsigned int src_slice_pitch, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
3866 unsigned int dst_location, unsigned int dst_x, unsigned int dst_y, unsigned int dst_z);
3867 void (*texture_download_data)(struct wined3d_context *context, struct wined3d_texture *src_texture,
3868 unsigned int src_sub_resource_idx, unsigned int src_location, const struct wined3d_box *src_box,
3869 const struct wined3d_bo_address *dst_bo_addr, const struct wined3d_format *dst_format,
3870 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z,
3871 unsigned int dst_row_pitch, unsigned int dst_slice_pitch);
3874 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3875 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3876 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3877 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3878 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3879 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3880 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3881 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3882 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3883 #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
3884 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3885 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3886 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3887 #define WINED3D_TEXTURE_DISCARD 0x00002000
3888 #define WINED3D_TEXTURE_GET_DC 0x00004000
3889 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3890 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3892 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3894 struct wined3d_texture
3896 struct wined3d_resource resource;
3897 const struct wined3d_texture_ops *texture_ops;
3898 struct wined3d_swapchain *swapchain;
3899 unsigned int pow2_width;
3900 unsigned int pow2_height;
3901 UINT layer_count;
3902 UINT level_count;
3903 unsigned int download_count;
3904 unsigned int sysmem_count;
3905 float pow2_matrix[16];
3906 UINT lod;
3907 DWORD sampler;
3908 DWORD flags;
3909 DWORD update_map_binding;
3911 void *user_memory;
3912 unsigned int row_pitch;
3913 unsigned int slice_pitch;
3915 /* May only be accessed from the command stream worker thread. */
3916 struct wined3d_texture_async
3918 DWORD flags;
3920 /* Color keys for DDraw */
3921 struct wined3d_color_key dst_blt_color_key;
3922 struct wined3d_color_key src_blt_color_key;
3923 struct wined3d_color_key dst_overlay_color_key;
3924 struct wined3d_color_key src_overlay_color_key;
3925 struct wined3d_color_key gl_color_key;
3926 DWORD color_key_flags;
3927 } async;
3929 struct wined3d_dirty_regions
3931 struct wined3d_box *boxes;
3932 SIZE_T boxes_size;
3933 unsigned int box_count;
3934 } *dirty_regions;
3936 struct wined3d_overlay_info
3938 struct list entry;
3939 struct list overlays;
3940 struct wined3d_texture *dst_texture;
3941 unsigned int dst_sub_resource_idx;
3942 RECT src_rect;
3943 RECT dst_rect;
3944 } *overlay_info;
3946 struct wined3d_dc_info
3948 HBITMAP bitmap;
3949 HDC dc;
3950 } *dc_info;
3952 struct wined3d_texture_sub_resource
3954 void *parent;
3955 const struct wined3d_parent_ops *parent_ops;
3957 unsigned int offset;
3958 unsigned int size;
3960 unsigned int map_count;
3961 uint32_t map_flags;
3962 DWORD locations;
3963 struct wined3d_bo_gl bo;
3964 } *sub_resources;
3967 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s, SIZE_T level_count, SIZE_T layer_count)
3969 struct wined3d_texture *t;
3971 if (level_count > ((~(SIZE_T)0 - s) / sizeof(*t->sub_resources)) / layer_count)
3972 return NULL;
3974 return heap_alloc_zero(s + level_count * layer_count * sizeof(*t->sub_resources));
3977 static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
3979 return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
3982 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture,
3983 unsigned int level)
3985 return max(1, texture->resource.width >> level);
3988 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture,
3989 unsigned int level)
3991 return max(1, texture->resource.height >> level);
3994 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture,
3995 unsigned int level)
3997 return max(1, texture->resource.depth >> level);
4000 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
4001 unsigned int level)
4003 return max(1, texture->pow2_width >> level);
4006 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
4007 unsigned int level)
4009 return max(1, texture->pow2_height >> level);
4012 static inline void wined3d_texture_get_level_box(const struct wined3d_texture *texture,
4013 unsigned int level, struct wined3d_box *box)
4015 wined3d_box_set(box, 0, 0,
4016 wined3d_texture_get_level_width(texture, level),
4017 wined3d_texture_get_level_height(texture, level),
4018 0, wined3d_texture_get_level_depth(texture, level));
4021 HRESULT texture2d_blt(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4022 const struct wined3d_box *dst_box, struct wined3d_texture *src_texture,
4023 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
4024 const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4025 void texture2d_get_blt_info(const struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
4026 const RECT *rect, struct wined3d_blt_info *info) DECLSPEC_HIDDEN;
4027 void texture2d_load_fb_texture(struct wined3d_texture_gl *texture_gl, unsigned int sub_resource_idx,
4028 BOOL srgb, struct wined3d_context *context) DECLSPEC_HIDDEN;
4029 void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4030 struct wined3d_context *context, DWORD src_location, DWORD dst_location) DECLSPEC_HIDDEN;
4032 HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
4033 unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
4034 void wined3d_texture_cleanup(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4035 void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4036 struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN;
4037 GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4038 void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4039 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4040 void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
4041 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
4042 void wined3d_texture_load(struct wined3d_texture *texture,
4043 struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
4044 BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
4045 unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4046 BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
4047 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4048 void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN;
4049 void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
4050 struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4051 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4052 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture *texture,
4053 HWND window, RECT *rect) DECLSPEC_HIDDEN;
4054 void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
4055 unsigned int dst_x, unsigned int dst_y, unsigned int dst_z, struct wined3d_texture *src_texture,
4056 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box) DECLSPEC_HIDDEN;
4057 void wined3d_texture_validate_location(struct wined3d_texture *texture,
4058 unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
4059 void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4061 HRESULT wined3d_texture_no3d_init(struct wined3d_texture *texture_no3d, struct wined3d_device *device,
4062 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4063 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4065 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4066 void wined3d_vk_swizzle_from_color_fixup(VkComponentMapping *mapping, struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4068 struct gl_texture
4070 struct wined3d_sampler_desc sampler_desc;
4071 unsigned int base_level;
4072 GLuint name;
4075 struct wined3d_texture_gl
4077 struct wined3d_texture t;
4079 struct gl_texture texture_rgb, texture_srgb;
4081 GLenum target;
4083 GLuint rb_multisample;
4084 GLuint rb_resolved;
4086 struct list renderbuffers;
4087 const struct wined3d_renderbuffer_entry *current_renderbuffer;
4090 static inline struct wined3d_texture_gl *wined3d_texture_gl(struct wined3d_texture *texture)
4092 return CONTAINING_RECORD(texture, struct wined3d_texture_gl, t);
4095 static inline struct gl_texture *wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl *texture_gl,
4096 BOOL srgb)
4098 return srgb ? &texture_gl->texture_srgb : &texture_gl->texture_rgb;
4101 static inline GLenum wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl *texture_gl,
4102 unsigned int sub_resource_idx)
4104 static const GLenum cube_targets[] =
4106 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
4107 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
4108 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
4109 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
4110 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
4111 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
4114 return texture_gl->t.resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP
4115 ? cube_targets[sub_resource_idx / texture_gl->t.level_count] : texture_gl->target;
4118 static inline BOOL wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl *texture_gl,
4119 DWORD location)
4121 if (location == WINED3D_LOCATION_RB_MULTISAMPLE)
4122 return TRUE;
4123 if (location != WINED3D_LOCATION_TEXTURE_RGB && location != WINED3D_LOCATION_TEXTURE_SRGB)
4124 return FALSE;
4125 return texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE || texture_gl->target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
4128 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl,
4129 const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4130 void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl,
4131 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4132 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl,
4133 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4134 HRESULT wined3d_texture_gl_init(struct wined3d_texture_gl *texture_gl, struct wined3d_device *device,
4135 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4136 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4137 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl,
4138 struct wined3d_context_gl *context_gl, BOOL srgb) DECLSPEC_HIDDEN;
4139 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *texture_gl,
4140 struct wined3d_context_gl *context_gl, unsigned int level,
4141 const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;
4143 struct wined3d_texture_vk
4145 struct wined3d_texture t;
4147 VkImage vk_image;
4148 struct wined3d_allocator_block *memory;
4149 VkDeviceMemory vk_memory;
4150 enum VkImageLayout layout;
4151 uint64_t command_buffer_id;
4153 VkDescriptorImageInfo default_image_info;
4156 static inline struct wined3d_texture_vk *wined3d_texture_vk(struct wined3d_texture *texture)
4158 return CONTAINING_RECORD(texture, struct wined3d_texture_vk, t);
4161 const VkDescriptorImageInfo *wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk *texture_vk,
4162 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4163 HRESULT wined3d_texture_vk_init(struct wined3d_texture_vk *texture_vk, struct wined3d_device *device,
4164 const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count,
4165 uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4166 BOOL wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk *texture_vk,
4167 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4169 struct wined3d_renderbuffer_entry
4171 struct list entry;
4172 GLuint id;
4173 UINT width;
4174 UINT height;
4177 struct wined3d_fbo_resource
4179 GLuint object;
4180 GLenum target;
4181 GLuint level, layer;
4184 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
4185 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
4186 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
4188 struct fbo_entry
4190 struct list entry;
4191 DWORD flags;
4192 DWORD rt_mask;
4193 GLuint id;
4194 struct wined3d_fbo_entry_key
4196 DWORD rb_namespace;
4197 struct wined3d_fbo_resource objects[WINED3D_MAX_RENDER_TARGETS + 1];
4198 } key;
4201 struct wined3d_sampler
4203 struct wine_rb_entry entry;
4204 LONG refcount;
4205 struct wined3d_device *device;
4206 void *parent;
4207 const struct wined3d_parent_ops *parent_ops;
4208 struct wined3d_sampler_desc desc;
4211 struct wined3d_sampler_gl
4213 struct wined3d_sampler s;
4215 GLuint name;
4218 static inline struct wined3d_sampler_gl *wined3d_sampler_gl(struct wined3d_sampler *sampler)
4220 return CONTAINING_RECORD(sampler, struct wined3d_sampler_gl, s);
4223 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl *sampler_gl, unsigned int unit,
4224 struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4225 void wined3d_sampler_gl_init(struct wined3d_sampler_gl *sampler_gl,
4226 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
4227 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4229 struct wined3d_sampler_vk
4231 struct wined3d_sampler s;
4233 VkDescriptorImageInfo vk_image_info;
4234 uint64_t command_buffer_id;
4237 static inline struct wined3d_sampler_vk *wined3d_sampler_vk(struct wined3d_sampler *sampler)
4239 return CONTAINING_RECORD(sampler, struct wined3d_sampler_vk, s);
4242 void wined3d_sampler_vk_init(struct wined3d_sampler_vk *sampler_vk,
4243 struct wined3d_device *device, const struct wined3d_sampler_desc *desc,
4244 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4246 struct wined3d_vertex_declaration_element
4248 const struct wined3d_format *format;
4249 BOOL ffp_valid;
4250 unsigned int input_slot;
4251 unsigned int offset;
4252 unsigned int output_slot;
4253 enum wined3d_input_classification input_slot_class;
4254 unsigned int instance_data_step_rate;
4255 BYTE method;
4256 BYTE usage;
4257 BYTE usage_idx;
4260 struct wined3d_vertex_declaration
4262 LONG ref;
4263 void *parent;
4264 const struct wined3d_parent_ops *parent_ops;
4265 struct wined3d_device *device;
4267 struct wined3d_vertex_declaration_element *elements;
4268 unsigned int element_count;
4270 BOOL position_transformed;
4273 struct wined3d_saved_states
4275 uint32_t vs_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F)];
4276 WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
4277 WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
4278 uint32_t ps_consts_f[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F)];
4279 WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
4280 WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
4281 uint32_t transform[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE + 1)];
4282 WORD streamSource; /* WINED3D_MAX_STREAMS, 16 */
4283 WORD streamFreq; /* WINED3D_MAX_STREAMS, 16 */
4284 uint32_t renderState[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE + 1)];
4285 DWORD textureState[WINED3D_MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
4286 WORD samplerState[WINED3D_MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
4287 DWORD clipplane; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
4288 DWORD textures : 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
4289 DWORD indices : 1;
4290 DWORD material : 1;
4291 DWORD viewport : 1;
4292 DWORD vertexDecl : 1;
4293 DWORD pixelShader : 1;
4294 DWORD vertexShader : 1;
4295 DWORD scissorRect : 1;
4296 DWORD store_stream_offset : 1;
4297 DWORD alpha_to_coverage : 1;
4298 DWORD lights : 1;
4299 DWORD transforms : 1;
4300 DWORD padding : 1;
4303 struct StageState {
4304 DWORD stage;
4305 DWORD state;
4308 struct wined3d_stateblock
4310 LONG ref; /* Note: Ref counting not required */
4311 struct wined3d_device *device;
4313 /* Array indicating whether things have been set or changed */
4314 struct wined3d_saved_states changed;
4316 struct wined3d_stateblock_state stateblock_state;
4317 struct wined3d_light_state light_state;
4319 /* Contained state management */
4320 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
4321 unsigned int num_contained_render_states;
4322 DWORD contained_transform_states[WINED3D_HIGHEST_TRANSFORM_STATE + 1];
4323 unsigned int num_contained_transform_states;
4324 struct StageState contained_tss_states[WINED3D_MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
4325 unsigned int num_contained_tss_states;
4326 struct StageState contained_sampler_states[WINED3D_MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
4327 unsigned int num_contained_sampler_states;
4330 void wined3d_stateblock_state_init(struct wined3d_stateblock_state *state,
4331 const struct wined3d_device *device, DWORD flags) DECLSPEC_HIDDEN;
4332 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state *state) DECLSPEC_HIDDEN;
4334 void wined3d_light_state_enable_light(struct wined3d_light_state *state, const struct wined3d_d3d_info *d3d_info,
4335 struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
4336 struct wined3d_light_info *wined3d_light_state_get_light(const struct wined3d_light_state *state,
4337 unsigned int idx) DECLSPEC_HIDDEN;
4338 HRESULT wined3d_light_state_set_light(struct wined3d_light_state *state, DWORD light_idx,
4339 const struct wined3d_light *params, struct wined3d_light_info **light_info) DECLSPEC_HIDDEN;
4341 void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
4342 void state_init(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info, DWORD flags) DECLSPEC_HIDDEN;
4343 void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
4345 enum wined3d_cs_queue_id
4347 WINED3D_CS_QUEUE_DEFAULT = 0,
4348 WINED3D_CS_QUEUE_MAP,
4349 WINED3D_CS_QUEUE_COUNT,
4352 enum wined3d_push_constants
4354 WINED3D_PUSH_CONSTANTS_VS_F,
4355 WINED3D_PUSH_CONSTANTS_PS_F,
4356 WINED3D_PUSH_CONSTANTS_VS_I,
4357 WINED3D_PUSH_CONSTANTS_PS_I,
4358 WINED3D_PUSH_CONSTANTS_VS_B,
4359 WINED3D_PUSH_CONSTANTS_PS_B,
4362 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
4363 #define WINED3D_CS_QUEUE_SIZE 0x100000u
4364 #define WINED3D_CS_SPIN_COUNT 10000000u
4366 struct wined3d_cs_queue
4368 LONG head, tail;
4369 BYTE data[WINED3D_CS_QUEUE_SIZE];
4372 struct wined3d_cs_ops
4374 void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
4375 void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
4376 void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
4377 void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p,
4378 unsigned int start_idx, unsigned int count, const void *constants);
4381 struct wined3d_cs
4383 const struct wined3d_cs_ops *ops;
4384 struct wined3d_device *device;
4385 struct wined3d_state state;
4386 HMODULE wined3d_module;
4387 HANDLE thread;
4388 DWORD thread_id;
4390 struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
4391 size_t data_size, start, end;
4392 void *data;
4393 struct list query_poll_list;
4394 BOOL queries_flushed;
4396 HANDLE event;
4397 BOOL waiting_for_event;
4398 LONG pending_presents;
4401 struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN;
4402 void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4403 void wined3d_cs_destroy_object(struct wined3d_cs *cs,
4404 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4405 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
4406 struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
4407 void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
4408 unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
4409 unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
4410 const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
4411 void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
4412 DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4413 void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined3d_rendertarget_view *view,
4414 const RECT *rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
4415 void wined3d_cs_emit_clear_unordered_access_view_uint(struct wined3d_cs *cs,
4416 struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value) DECLSPEC_HIDDEN;
4417 void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buffer *dst_buffer,
4418 unsigned int offset, struct wined3d_unordered_access_view *uav) DECLSPEC_HIDDEN;
4419 void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
4420 unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) DECLSPEC_HIDDEN;
4421 void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs,
4422 struct wined3d_buffer *buffer, unsigned int offset) DECLSPEC_HIDDEN;
4423 void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
4424 int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
4425 unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
4426 void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
4427 struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) DECLSPEC_HIDDEN;
4428 void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4429 void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4430 void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4431 void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
4432 const RECT *dst_rect, HWND dst_window_override, unsigned int swap_interval, DWORD flags) DECLSPEC_HIDDEN;
4433 void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN;
4434 void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
4435 void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state,
4436 const struct wined3d_color *blend_factor) DECLSPEC_HIDDEN;
4437 void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
4438 const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
4439 void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
4440 WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
4441 void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
4442 UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4443 void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
4444 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4445 void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
4446 enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN;
4447 void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light_info *light) DECLSPEC_HIDDEN;
4448 void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) DECLSPEC_HIDDEN;
4449 void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
4450 void wined3d_cs_emit_set_predication(struct wined3d_cs *cs,
4451 struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
4452 void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs,
4453 struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN;
4454 void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
4455 enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
4456 void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx,
4457 struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4458 void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
4459 UINT view_idx, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4460 void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type,
4461 UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
4462 void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx,
4463 enum wined3d_sampler_state state, DWORD value) DECLSPEC_HIDDEN;
4464 void wined3d_cs_emit_set_scissor_rects(struct wined3d_cs *cs, unsigned int rect_count, const RECT *rects) DECLSPEC_HIDDEN;
4465 void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type,
4466 struct wined3d_shader *shader) DECLSPEC_HIDDEN;
4467 void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx,
4468 struct wined3d_buffer *buffer, UINT offset) DECLSPEC_HIDDEN;
4469 void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx,
4470 struct wined3d_buffer *buffer, UINT offset, UINT stride) DECLSPEC_HIDDEN;
4471 void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx,
4472 UINT frequency, UINT flags) DECLSPEC_HIDDEN;
4473 void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined3d_texture *texture) DECLSPEC_HIDDEN;
4474 void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage,
4475 enum wined3d_texture_stage_state state, DWORD value) DECLSPEC_HIDDEN;
4476 void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
4477 const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
4478 void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
4479 unsigned int view_idx, struct wined3d_unordered_access_view *view,
4480 unsigned int initial_count) DECLSPEC_HIDDEN;
4481 void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
4482 struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
4483 void wined3d_cs_emit_set_viewports(struct wined3d_cs *cs, unsigned int viewport_count, const struct wined3d_viewport *viewports) DECLSPEC_HIDDEN;
4484 void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
4485 void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource,
4486 unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
4487 unsigned int slice_pitch) DECLSPEC_HIDDEN;
4488 void wined3d_cs_init_object(struct wined3d_cs *cs,
4489 void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
4490 HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
4491 struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
4492 HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource,
4493 unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
4495 static inline void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
4497 cs->ops->finish(cs, queue_id);
4500 static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
4501 unsigned int start_idx, unsigned int count, const void *constants)
4503 cs->ops->push_constants(cs, p, start_idx, count, constants);
4506 static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
4508 const struct wined3d_cs *cs = resource->device->cs;
4510 if (!cs->thread || cs->thread_id == GetCurrentThreadId())
4511 return;
4513 while (InterlockedCompareExchange(&resource->access_count, 0, 0))
4514 wined3d_pause();
4517 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
4518 * fixed function semantics as D3DCOLOR or FLOAT16 */
4519 enum wined3d_buffer_conversion_type
4521 CONV_NONE,
4522 CONV_D3DCOLOR,
4523 CONV_POSITIONT,
4526 struct wined3d_buffer_ops
4528 BOOL (*buffer_prepare_location)(struct wined3d_buffer *buffer,
4529 struct wined3d_context *context, unsigned int location);
4530 void (*buffer_unload_location)(struct wined3d_buffer *buffer,
4531 struct wined3d_context *context, unsigned int location);
4532 void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data,
4533 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
4534 void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data,
4535 unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges);
4538 struct wined3d_buffer
4540 struct wined3d_resource resource;
4541 const struct wined3d_buffer_ops *buffer_ops;
4543 unsigned int structure_byte_stride;
4544 DWORD flags;
4545 DWORD locations;
4546 void *map_ptr;
4547 uintptr_t buffer_object;
4549 struct wined3d_range *maps;
4550 SIZE_T maps_size, modified_areas;
4551 struct wined3d_fence *fence;
4553 /* conversion stuff */
4554 UINT decl_change_count, full_conversion_count;
4555 UINT draw_count;
4556 UINT stride; /* 0 if no conversion */
4557 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
4558 UINT conversion_stride; /* 0 if no shifted conversion */
4561 static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
4563 return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
4566 void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
4567 void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
4568 struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
4569 DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer,
4570 struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
4571 void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
4572 void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
4573 const struct wined3d_state *state) DECLSPEC_HIDDEN;
4574 BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
4575 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4576 BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
4577 BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
4578 struct wined3d_context *context, unsigned int location) DECLSPEC_HIDDEN;
4579 void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
4580 const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
4582 HRESULT wined3d_buffer_no3d_init(struct wined3d_buffer *buffer_no3d, struct wined3d_device *device,
4583 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4584 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4586 struct wined3d_buffer_gl
4588 struct wined3d_buffer b;
4590 struct wined3d_bo_gl bo;
4591 GLenum buffer_object_usage;
4594 static inline struct wined3d_buffer_gl *wined3d_buffer_gl(struct wined3d_buffer *buffer)
4596 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
4599 static inline const struct wined3d_buffer_gl *wined3d_buffer_gl_const(const struct wined3d_buffer *buffer)
4601 return CONTAINING_RECORD(buffer, struct wined3d_buffer_gl, b);
4604 GLenum wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info *gl_info,
4605 uint32_t bind_flags) DECLSPEC_HIDDEN;
4606 HRESULT wined3d_buffer_gl_init(struct wined3d_buffer_gl *buffer_gl, struct wined3d_device *device,
4607 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4608 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4610 struct wined3d_buffer_vk
4612 struct wined3d_buffer b;
4614 struct wined3d_bo_vk bo;
4615 struct wined3d_bo_user_vk bo_user;
4616 VkDescriptorBufferInfo buffer_info;
4619 static inline struct wined3d_buffer_vk *wined3d_buffer_vk(struct wined3d_buffer *buffer)
4621 return CONTAINING_RECORD(buffer, struct wined3d_buffer_vk, b);
4624 const VkDescriptorBufferInfo *wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk *buffer_vk) DECLSPEC_HIDDEN;
4625 HRESULT wined3d_buffer_vk_init(struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device,
4626 const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data,
4627 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4629 struct wined3d_rendertarget_view
4631 LONG refcount;
4633 struct wined3d_resource *resource;
4634 void *parent;
4635 const struct wined3d_parent_ops *parent_ops;
4637 const struct wined3d_format *format;
4638 unsigned int format_flags;
4639 unsigned int sub_resource_idx;
4640 unsigned int layer_count;
4642 unsigned int width;
4643 unsigned int height;
4645 struct wined3d_view_desc desc;
4648 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
4649 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
4650 const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
4651 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
4652 DWORD location) DECLSPEC_HIDDEN;
4653 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
4654 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4655 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,
4656 struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
4657 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
4658 DWORD location) DECLSPEC_HIDDEN;
4660 HRESULT wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view *view_no3d,
4661 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4662 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4664 struct wined3d_rendertarget_view_gl
4666 struct wined3d_rendertarget_view v;
4667 struct wined3d_gl_view gl_view;
4670 static inline struct wined3d_rendertarget_view_gl *wined3d_rendertarget_view_gl(
4671 struct wined3d_rendertarget_view *view)
4673 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_gl, v);
4676 HRESULT wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl *view_gl,
4677 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4678 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4680 struct wined3d_rendertarget_view_vk
4682 struct wined3d_rendertarget_view v;
4684 VkImageView vk_image_view;
4685 uint64_t command_buffer_id;
4688 static inline struct wined3d_rendertarget_view_vk *wined3d_rendertarget_view_vk(
4689 struct wined3d_rendertarget_view *view)
4691 return CONTAINING_RECORD(view, struct wined3d_rendertarget_view_vk, v);
4694 HRESULT wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk *view_vk,
4695 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4696 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4698 struct wined3d_shader_resource_view
4700 LONG refcount;
4702 struct wined3d_resource *resource;
4703 void *parent;
4704 const struct wined3d_parent_ops *parent_ops;
4706 const struct wined3d_format *format;
4708 struct wined3d_view_desc desc;
4711 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4712 void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
4714 struct wined3d_shader_resource_view_gl
4716 struct wined3d_shader_resource_view v;
4717 struct wined3d_gl_view gl_view;
4720 static inline struct wined3d_shader_resource_view_gl *wined3d_shader_resource_view_gl(
4721 struct wined3d_shader_resource_view *view)
4723 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_gl, v);
4726 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit,
4727 struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4728 HRESULT wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl *view_gl,
4729 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4730 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4732 struct wined3d_view_vk
4734 struct wined3d_bo_user_vk bo_user;
4735 union
4737 VkBufferView vk_buffer_view;
4738 VkDescriptorImageInfo vk_image_info;
4739 } u;
4740 uint64_t command_buffer_id;
4743 struct wined3d_shader_resource_view_vk
4745 struct wined3d_shader_resource_view v;
4746 struct wined3d_view_vk view_vk;
4749 static inline struct wined3d_shader_resource_view_vk *wined3d_shader_resource_view_vk(
4750 struct wined3d_shader_resource_view *view)
4752 return CONTAINING_RECORD(view, struct wined3d_shader_resource_view_vk, v);
4755 HRESULT wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk *view_vk,
4756 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4757 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4758 void wined3d_shader_resource_view_vk_update(struct wined3d_shader_resource_view_vk *view_vk,
4759 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4761 struct wined3d_unordered_access_view
4763 LONG refcount;
4765 struct wined3d_resource *resource;
4766 void *parent;
4767 const struct wined3d_parent_ops *parent_ops;
4769 const struct wined3d_format *format;
4771 struct wined3d_view_desc desc;
4772 uintptr_t counter_bo;
4775 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view *view) DECLSPEC_HIDDEN;
4776 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
4777 struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
4778 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
4779 DWORD location) DECLSPEC_HIDDEN;
4780 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
4781 unsigned int value) DECLSPEC_HIDDEN;
4783 struct wined3d_unordered_access_view_gl
4785 struct wined3d_unordered_access_view v;
4786 struct wined3d_gl_view gl_view;
4787 struct wined3d_bo_gl counter_bo;
4790 static inline struct wined3d_unordered_access_view_gl *wined3d_unordered_access_view_gl(
4791 struct wined3d_unordered_access_view *view)
4793 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_gl, v);
4796 void wined3d_unordered_access_view_gl_clear_uint(struct wined3d_unordered_access_view_gl *view_gl,
4797 const struct wined3d_uvec4 *clear_value, struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
4798 HRESULT wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl *view_gl,
4799 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4800 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4802 struct wined3d_unordered_access_view_vk
4804 struct wined3d_unordered_access_view v;
4805 struct wined3d_view_vk view_vk;
4807 VkBufferView vk_counter_view;
4808 struct wined3d_bo_vk counter_bo;
4811 static inline struct wined3d_unordered_access_view_vk *wined3d_unordered_access_view_vk(
4812 struct wined3d_unordered_access_view *view)
4814 return CONTAINING_RECORD(view, struct wined3d_unordered_access_view_vk, v);
4817 HRESULT wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk *view_vk,
4818 const struct wined3d_view_desc *desc, struct wined3d_resource *resource,
4819 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4820 void wined3d_unordered_access_view_vk_update(struct wined3d_unordered_access_view_vk *view_vk,
4821 struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
4823 struct wined3d_swapchain_state
4825 struct wined3d_swapchain_desc desc;
4827 struct wined3d_display_mode original_mode, d3d_mode;
4828 RECT original_window_rect;
4830 /* Window styles to restore when switching fullscreen mode. */
4831 LONG style;
4832 LONG exstyle;
4833 HWND device_window;
4836 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state *state,
4837 HWND window, const RECT *window_rect) DECLSPEC_HIDDEN;
4838 HRESULT wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state *state,
4839 HWND window, int x, int y, int width, int height) DECLSPEC_HIDDEN;
4841 struct wined3d_swapchain_ops
4843 void (*swapchain_present)(struct wined3d_swapchain *swapchain,
4844 const RECT *src_rect, const RECT *dst_rect, unsigned int swap_interval, DWORD flags);
4845 void (*swapchain_frontbuffer_updated)(struct wined3d_swapchain *swapchain);
4848 struct wined3d_swapchain
4850 LONG ref;
4851 void *parent;
4852 const struct wined3d_parent_ops *parent_ops;
4853 const struct wined3d_swapchain_ops *swapchain_ops;
4854 struct wined3d_device *device;
4856 struct wined3d_texture **back_buffers;
4857 struct wined3d_texture *front_buffer;
4858 struct wined3d_gamma_ramp orig_gamma;
4859 BOOL render_to_fbo, reapply_mode;
4860 const struct wined3d_format *ds_format;
4861 struct wined3d_palette *palette;
4862 RECT front_buffer_update;
4863 unsigned int swap_interval;
4864 unsigned int max_frame_latency;
4866 LONG prev_time, frames; /* Performance tracking */
4868 struct wined3d_swapchain_state state;
4869 HWND win_handle;
4872 void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
4873 void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4874 struct wined3d_output * wined3d_swapchain_get_output(const struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4875 void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
4876 void swapchain_set_max_frame_latency(struct wined3d_swapchain *swapchain,
4877 const struct wined3d_device *device) DECLSPEC_HIDDEN;
4879 HRESULT wined3d_swapchain_no3d_init(struct wined3d_swapchain *swapchain_no3d,
4880 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4881 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4883 struct wined3d_swapchain_gl
4885 struct wined3d_swapchain s;
4887 struct wined3d_context_gl **contexts;
4888 SIZE_T contexts_size;
4889 SIZE_T context_count;
4891 HDC backup_dc;
4892 HWND backup_wnd;
4895 static inline struct wined3d_swapchain_gl *wined3d_swapchain_gl(struct wined3d_swapchain *swapchain)
4897 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_gl, s);
4900 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4901 void wined3d_swapchain_gl_destroy_contexts(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4902 HDC wined3d_swapchain_gl_get_backup_dc(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4903 struct wined3d_context_gl *wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl *swapchain_gl) DECLSPEC_HIDDEN;
4904 HRESULT wined3d_swapchain_gl_init(struct wined3d_swapchain_gl *swapchain_gl,
4905 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4906 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4908 HRESULT wined3d_swapchain_vk_init(struct wined3d_swapchain *swapchain_vk,
4909 struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
4910 void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
4912 /*****************************************************************************
4913 * Utility function prototypes
4916 /* Trace routines */
4917 const char *debug_bo_address(const struct wined3d_bo_address *address) DECLSPEC_HIDDEN;
4918 const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
4919 const char *debug_color(const struct wined3d_color *color) DECLSPEC_HIDDEN;
4920 const char *debug_const_bo_address(const struct wined3d_const_bo_address *address) DECLSPEC_HIDDEN;
4921 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
4922 const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
4923 const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
4924 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) DECLSPEC_HIDDEN;
4925 const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
4926 const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
4927 const char *debug_d3ddeclmethod(enum wined3d_decl_method method) DECLSPEC_HIDDEN;
4928 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
4929 const char *debug_d3dinput_classification(enum wined3d_input_classification classification) DECLSPEC_HIDDEN;
4930 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
4931 const char *debug_d3drenderstate(enum wined3d_render_state state) DECLSPEC_HIDDEN;
4932 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HIDDEN;
4933 const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
4934 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
4935 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
4936 const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
4937 const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
4938 const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
4939 const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
4940 const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
4941 const char *debug_ivec4(const struct wined3d_ivec4 *v) DECLSPEC_HIDDEN;
4942 const char *debug_uvec4(const struct wined3d_uvec4 *v) DECLSPEC_HIDDEN;
4943 const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
4944 const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
4945 const char *wined3d_debug_feature_level(enum wined3d_feature_level level) DECLSPEC_HIDDEN;
4946 void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
4948 BOOL is_invalid_op(const struct wined3d_state *state, int stage,
4949 enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
4950 void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
4951 BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
4952 INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
4953 void texture_activate_dimensions(struct wined3d_texture *texture,
4954 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
4955 void sampler_texdim(struct wined3d_context *context,
4956 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4957 void tex_alphaop(struct wined3d_context *context,
4958 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4959 void apply_pixelshader(struct wined3d_context *context,
4960 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4961 void state_alpha_test(struct wined3d_context *context,
4962 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4963 void state_fogcolor(struct wined3d_context *context,
4964 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4965 void state_fogdensity(struct wined3d_context *context,
4966 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4967 void state_fogstartend(struct wined3d_context *context,
4968 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4969 void state_fog_fragpart(struct wined3d_context *context,
4970 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4971 void state_nop(struct wined3d_context *context,
4972 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4973 void state_srgbwrite(struct wined3d_context *context,
4974 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4976 void state_clipping(struct wined3d_context *context,
4977 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4978 void clipplane(struct wined3d_context *context,
4979 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4980 void state_pointsprite_w(struct wined3d_context *context,
4981 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4982 void state_pointsprite(struct wined3d_context *context,
4983 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4984 void state_shademode(struct wined3d_context *context,
4985 const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
4987 GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
4988 enum wined3d_primitive_type d3d_primitive_type_from_gl(GLenum primitive_type) DECLSPEC_HIDDEN;
4990 /* Math utils */
4991 void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
4992 const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
4994 void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
4996 struct wined3d_shader_lconst
4998 struct list entry;
4999 unsigned int idx;
5000 DWORD value[4];
5003 struct wined3d_shader_limits
5005 unsigned int sampler;
5006 unsigned int constant_int;
5007 unsigned int constant_float;
5008 unsigned int constant_bool;
5009 unsigned int packed_output;
5010 unsigned int packed_input;
5013 #ifdef __GNUC__
5014 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
5015 #else
5016 #define PRINTF_ATTR(fmt,args)
5017 #endif
5019 struct wined3d_string_buffer_list
5021 struct list list;
5024 struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5025 void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN;
5026 void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5027 void string_buffer_list_init(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5028 void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
5030 int shader_addline(struct wined3d_string_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
5031 BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc) DECLSPEC_HIDDEN;
5032 int shader_vaddline(struct wined3d_string_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
5034 struct wined3d_shader_phase
5036 const DWORD *start;
5037 const DWORD *end;
5038 unsigned int instance_count;
5039 unsigned int temporary_count;
5042 struct wined3d_vertex_shader
5044 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
5047 struct wined3d_hull_shader
5049 struct
5051 struct wined3d_shader_phase *control_point;
5052 unsigned int fork_count;
5053 unsigned int join_count;
5054 struct wined3d_shader_phase *fork;
5055 SIZE_T fork_size;
5056 struct wined3d_shader_phase *join;
5057 SIZE_T join_size;
5058 } phases;
5059 unsigned int output_vertex_count;
5060 enum wined3d_tessellator_output_primitive tessellator_output_primitive;
5061 enum wined3d_tessellator_partitioning tessellator_partitioning;
5064 struct wined3d_domain_shader
5066 enum wined3d_tessellator_domain tessellator_domain;
5069 struct wined3d_geometry_shader
5071 enum wined3d_primitive_type input_type;
5072 enum wined3d_primitive_type output_type;
5073 unsigned int vertices_out;
5074 unsigned int instance_count;
5076 struct wined3d_stream_output_desc so_desc;
5079 struct wined3d_pixel_shader
5081 /* Pixel shader input semantics */
5082 DWORD input_reg_map[MAX_REG_INPUT];
5083 DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
5084 unsigned int declared_in_count;
5086 /* Some information about the shader behavior */
5087 BOOL color0_mov;
5088 DWORD color0_reg;
5090 BOOL force_early_depth_stencil;
5091 enum wined3d_shader_register_type depth_output;
5092 DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
5095 struct wined3d_compute_shader
5097 struct wined3d_shader_thread_group_size thread_group_size;
5100 struct wined3d_shader
5102 LONG ref;
5103 const struct wined3d_shader_limits *limits;
5104 const DWORD *function;
5105 unsigned int functionLength;
5106 void *byte_code;
5107 unsigned int byte_code_size;
5108 BOOL load_local_constsF;
5109 const struct wined3d_shader_frontend *frontend;
5110 void *frontend_data;
5111 void *backend_data;
5113 void *parent;
5114 const struct wined3d_parent_ops *parent_ops;
5116 /* Programs this shader is linked with */
5117 struct list linked_programs;
5119 /* Immediate constants (override global ones) */
5120 struct list constantsB;
5121 struct list constantsF;
5122 struct list constantsI;
5123 struct wined3d_shader_reg_maps reg_maps;
5124 BOOL lconst_inf_or_nan;
5126 struct wined3d_shader_signature input_signature;
5127 struct wined3d_shader_signature output_signature;
5128 struct wined3d_shader_signature patch_constant_signature;
5130 /* Pointer to the parent device */
5131 struct wined3d_device *device;
5132 struct list shader_list_entry;
5134 union
5136 struct wined3d_vertex_shader vs;
5137 struct wined3d_hull_shader hs;
5138 struct wined3d_domain_shader ds;
5139 struct wined3d_geometry_shader gs;
5140 struct wined3d_pixel_shader ps;
5141 struct wined3d_compute_shader cs;
5142 } u;
5145 enum wined3d_shader_resource_type pixelshader_get_resource_type(const struct wined3d_shader_reg_maps *reg_maps,
5146 unsigned int resource_idx, DWORD tex_types) DECLSPEC_HIDDEN;
5147 void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5148 BOOL position_transformed, struct ps_compile_args *args,
5149 const struct wined3d_context *context) DECLSPEC_HIDDEN;
5151 BOOL vshader_get_input(const struct wined3d_shader *shader,
5152 BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
5153 void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5154 WORD swizzle_map, struct vs_compile_args *args,
5155 const struct wined3d_context *context) DECLSPEC_HIDDEN;
5157 void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5158 struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5160 void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
5161 struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
5163 void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5164 BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5165 void string_buffer_free(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
5166 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
5167 unsigned int max) DECLSPEC_HIDDEN;
5168 HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
5169 const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
5170 const DWORD *start, const DWORD *end) DECLSPEC_HIDDEN;
5171 BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
5173 static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
5175 switch (reg->type)
5177 case WINED3DSPR_RASTOUT:
5178 /* oFog & oPts */
5179 if (reg->idx[0].offset)
5180 return TRUE;
5181 /* oPos */
5182 return FALSE;
5184 case WINED3DSPR_CONSTBOOL: /* b# */
5185 case WINED3DSPR_DEPTHOUT: /* oDepth */
5186 case WINED3DSPR_DEPTHOUTGE:
5187 case WINED3DSPR_DEPTHOUTLE:
5188 case WINED3DSPR_LOOP: /* aL */
5189 case WINED3DSPR_OUTPOINTID:
5190 case WINED3DSPR_PREDICATE: /* p0 */
5191 case WINED3DSPR_PRIMID: /* primID */
5192 case WINED3DSPR_COVERAGE: /* vCoverage */
5193 case WINED3DSPR_SAMPLEMASK: /* oMask */
5194 return TRUE;
5196 case WINED3DSPR_MISCTYPE:
5197 switch (reg->idx[0].offset)
5199 case 0: /* vPos */
5200 return FALSE;
5201 case 1: /* vFace */
5202 return TRUE;
5203 default:
5204 return FALSE;
5207 case WINED3DSPR_IMMCONST:
5208 return reg->immconst_type == WINED3D_IMMCONST_SCALAR;
5210 default:
5211 return FALSE;
5215 static inline void shader_get_position_fixup(const struct wined3d_context *context,
5216 const struct wined3d_state *state, unsigned int fixup_count, float *position_fixup)
5218 float center_offset;
5219 unsigned int i;
5221 if (context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)
5222 center_offset = 63.0f / 64.0f;
5223 else
5224 center_offset = -1.0f / 64.0f;
5226 for (i = 0; i < fixup_count; ++i)
5228 position_fixup[4 * i ] = 1.0f;
5229 position_fixup[4 * i + 1] = 1.0f;
5230 position_fixup[4 * i + 2] = center_offset / state->viewports[i].width;
5231 position_fixup[4 * i + 3] = -center_offset / state->viewports[i].height;
5233 if (context->render_offscreen)
5235 position_fixup[4 * i + 1] *= -1.0f;
5236 position_fixup[4 * i + 3] *= -1.0f;
5241 static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
5243 struct wined3d_shader_lconst *lconst;
5245 if (shader->load_local_constsF)
5246 return FALSE;
5248 LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
5250 if (lconst->idx == reg)
5251 return TRUE;
5254 return FALSE;
5257 void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5258 void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5259 unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5260 void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5261 struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5262 void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
5263 unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
5264 void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state,
5265 float *out_min, float *out_max) DECLSPEC_HIDDEN;
5266 void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
5267 float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
5268 void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
5269 float *start, float *end) DECLSPEC_HIDDEN;
5271 /* Using additional shader constants (uniforms in GLSL / program environment
5272 * or local parameters in ARB) is costly:
5273 * ARB only knows float4 parameters and GLSL compiler are not really smart
5274 * when it comes to efficiently pack float2 uniforms, so no space is wasted
5275 * (in fact most compilers map a float2 to a full float4 uniform).
5277 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
5278 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
5279 * into a single shader constant (uniform / program parameter).
5281 * This structure is shared between the GLSL and the ARB backend.*/
5282 struct ps_np2fixup_info {
5283 unsigned char idx[WINED3D_MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
5284 WORD active; /* bitfield indicating if we can apply the fixup */
5285 WORD num_consts;
5288 void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL program) DECLSPEC_HIDDEN;
5289 void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLuint program) DECLSPEC_HIDDEN;
5291 struct wined3d_palette
5293 LONG ref;
5294 struct wined3d_device *device;
5296 unsigned int size;
5297 RGBQUAD colors[256];
5298 DWORD flags;
5301 /* DirectDraw utility functions */
5302 extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
5304 /*****************************************************************************
5305 * Pixel format management
5308 /* WineD3D pixel format flags */
5309 #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x00000001
5310 #define WINED3DFMT_FLAG_FILTERING 0x00000002
5311 #define WINED3DFMT_FLAG_DEPTH 0x00000004
5312 #define WINED3DFMT_FLAG_STENCIL 0x00000008
5313 #define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
5314 #define WINED3DFMT_FLAG_EXTENSION 0x00000020
5315 #define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
5316 #define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
5317 #define WINED3DFMT_FLAG_DECOMPRESS 0x00000100
5318 #define WINED3DFMT_FLAG_FLOAT 0x00000200
5319 #define WINED3DFMT_FLAG_BUMPMAP 0x00000400
5320 #define WINED3DFMT_FLAG_SRGB_READ 0x00000800
5321 #define WINED3DFMT_FLAG_SRGB_WRITE 0x00001000
5322 #define WINED3DFMT_FLAG_VTF 0x00002000
5323 #define WINED3DFMT_FLAG_SHADOW 0x00004000
5324 #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
5325 #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
5326 #define WINED3DFMT_FLAG_BLOCKS 0x00020000
5327 #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
5328 #define WINED3DFMT_FLAG_TEXTURE 0x00080000
5329 #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
5330 #define WINED3DFMT_FLAG_INTEGER 0x00200000
5331 #define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
5332 #define WINED3DFMT_FLAG_NORMALISED 0x00800000
5333 #define WINED3DFMT_FLAG_VERTEX_ATTRIBUTE 0x01000000
5334 #define WINED3DFMT_FLAG_BLIT 0x02000000
5335 #define WINED3DFMT_FLAG_MAPPABLE 0x04000000
5337 struct wined3d_rational
5339 UINT numerator;
5340 UINT denominator;
5343 struct wined3d_color_key_conversion
5345 enum wined3d_format_id dst_format;
5346 void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch,
5347 unsigned int width, unsigned int height, const struct wined3d_color_key *colour_key);
5350 struct wined3d_format
5352 enum wined3d_format_id id;
5354 D3DDDIFORMAT ddi_format;
5355 unsigned int component_count;
5356 DWORD red_size;
5357 DWORD green_size;
5358 DWORD blue_size;
5359 DWORD alpha_size;
5360 DWORD red_offset;
5361 DWORD green_offset;
5362 DWORD blue_offset;
5363 DWORD alpha_offset;
5364 UINT byte_count;
5365 BYTE depth_size;
5366 BYTE stencil_size;
5368 UINT block_width;
5369 UINT block_height;
5370 UINT block_byte_count;
5372 enum wined3d_ffp_emit_idx emit_idx;
5374 UINT conv_byte_count;
5375 DWORD multisample_types;
5376 unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
5377 float depth_bias_scale;
5378 struct wined3d_rational height_scale;
5379 struct color_fixup_desc color_fixup;
5380 void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5381 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5382 unsigned int width, unsigned int height, unsigned int depth);
5383 void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5384 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5385 unsigned int width, unsigned int height, unsigned int depth);
5386 void (*decompress)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
5387 unsigned int dst_row_pitch, unsigned dst_slice_pitch,
5388 unsigned int width, unsigned int height, unsigned int depth);
5390 enum wined3d_format_id typeless_id;
5393 const struct wined3d_format *wined3d_get_format(const struct wined3d_adapter *adapter,
5394 enum wined3d_format_id format_id, unsigned int bind_flags) DECLSPEC_HIDDEN;
5395 void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
5396 unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
5397 UINT wined3d_format_calculate_size(const struct wined3d_format *format,
5398 UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
5399 DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
5400 const struct wined3d_color *color) DECLSPEC_HIDDEN;
5401 void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src,
5402 unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
5403 unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d) DECLSPEC_HIDDEN;
5404 void wined3d_format_get_float_color_key(const struct wined3d_format *format,
5405 const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
5406 BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
5407 enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
5408 const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
5409 const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
5410 BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
5411 enum wined3d_format_id format2) DECLSPEC_HIDDEN;
5413 struct wined3d_format_gl
5415 struct wined3d_format f;
5417 GLenum vtx_type;
5418 GLint vtx_format;
5420 GLint internal;
5421 GLint srgb_internal;
5422 GLint rt_internal;
5423 GLint format;
5424 GLint type;
5426 GLenum view_class;
5429 static inline const struct wined3d_format_gl *wined3d_format_gl(const struct wined3d_format *format)
5431 return CONTAINING_RECORD(format, struct wined3d_format_gl, f);
5434 struct wined3d_format_vk
5436 struct wined3d_format f;
5438 VkFormat vk_format;
5441 static inline const struct wined3d_format_vk *wined3d_format_vk(const struct wined3d_format *format)
5443 return CONTAINING_RECORD(format, struct wined3d_format_vk, f);
5446 BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
5448 static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
5450 return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
5453 static inline BOOL use_vs(const struct wined3d_state *state)
5455 /* Check state->vertex_declaration to allow this to be used before the
5456 * stream info is validated, for example in device_update_tex_unit_map(). */
5457 return state->shader[WINED3D_SHADER_TYPE_VERTEX]
5458 && (!state->vertex_declaration || !state->vertex_declaration->position_transformed);
5461 static inline BOOL use_ps(const struct wined3d_state *state)
5463 return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
5466 static inline BOOL use_transform_feedback(const struct wined3d_state *state)
5468 const struct wined3d_shader *shader;
5470 if (!(shader = state->shader[WINED3D_SHADER_TYPE_GEOMETRY]))
5471 return FALSE;
5472 return shader->u.gs.so_desc.element_count;
5475 static inline void context_apply_state(struct wined3d_context *context,
5476 const struct wined3d_state *state, DWORD state_id)
5478 const struct wined3d_state_entry *state_table = context->state_table;
5479 unsigned int rep = state_table[state_id].representative;
5480 state_table[rep].apply(context, state, rep);
5483 static inline BOOL is_srgb_enabled(const DWORD *sampler_states)
5485 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
5486 * the behaviour of the AMD Windows driver.
5488 * Might & Magic: Heroes VI - Shades of Darkness sets
5489 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
5490 * pointer—presumably by accident—and expects sRGB decoding to be
5491 * disabled. */
5492 return sampler_states[WINED3D_SAMP_SRGB_TEXTURE] & 0x1;
5495 static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
5496 const struct wined3d_texture *texture)
5498 if (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL))
5499 return FALSE;
5501 if (!context->d3d_info->srgb_read_control
5502 && (texture->resource.bind_flags & WINED3D_BIND_SHADER_RESOURCE)
5503 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_READ))
5504 return TRUE;
5506 if (!context->d3d_info->srgb_write_control
5507 && (texture->resource.bind_flags & WINED3D_BIND_RENDER_TARGET)
5508 && (texture->resource.format_flags & WINED3DFMT_FLAG_SRGB_WRITE))
5509 return TRUE;
5511 return FALSE;
5514 static inline BOOL needs_srgb_write(const struct wined3d_d3d_info *d3d_info,
5515 const struct wined3d_state *state, const struct wined3d_fb_state *fb)
5517 return (!(d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
5518 || state->render_states[WINED3D_RS_SRGBWRITEENABLE])
5519 && fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
5522 static inline GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl,
5523 const struct wined3d_context *context, BOOL srgb)
5525 return srgb && needs_separate_srgb_gl_texture(context, &texture_gl->t)
5526 ? texture_gl->texture_srgb.name : texture_gl->texture_rgb.name;
5529 static inline BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
5531 return d3d_info->texture_swizzle && !is_complex_fixup(format->color_fixup) && !is_scaling_fixup(format->color_fixup);
5534 static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
5536 return geometry_shader
5537 && geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
5540 static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
5541 unsigned int offset, unsigned int count)
5543 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5544 const unsigned int idx = offset / word_bit_count;
5545 const unsigned int shift = offset % word_bit_count;
5546 DWORD mask = (1u << count) - 1;
5547 DWORD ret;
5549 ret = (bitstream[idx] >> shift) & mask;
5550 if (shift + count > word_bit_count)
5552 const unsigned int extracted_bit_count = word_bit_count - shift;
5553 const unsigned int remaining_bit_count = count - extracted_bit_count;
5554 mask = (1u << remaining_bit_count) - 1;
5555 ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
5557 return ret;
5560 static inline void wined3d_insert_bits(DWORD *bitstream,
5561 unsigned int offset, unsigned int count, DWORD bits)
5563 const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
5564 const unsigned int idx = offset / word_bit_count;
5565 const unsigned int shift = offset % word_bit_count;
5566 DWORD mask = (1u << count) - 1;
5568 bitstream[idx] |= (bits & mask) << shift;
5569 if (shift + count > word_bit_count)
5571 const unsigned int inserted_bit_count = word_bit_count - shift;
5572 const unsigned int remaining_bit_count = count - inserted_bit_count;
5573 mask = (1u << remaining_bit_count) - 1;
5574 bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
5578 static inline void wined3d_from_cs(const struct wined3d_cs *cs)
5580 if (cs->thread)
5581 assert(cs->thread_id == GetCurrentThreadId());
5584 static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
5586 assert(cs->thread_id != GetCurrentThreadId());
5589 static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map,
5590 enum wined3d_material_color_source source)
5592 if (source == WINED3D_MCS_COLOR1 && use_map & (1u << WINED3D_FFP_DIFFUSE))
5593 return source;
5594 if (source == WINED3D_MCS_COLOR2 && use_map & (1u << WINED3D_FFP_SPECULAR))
5595 return source;
5596 return WINED3D_MCS_MATERIAL;
5599 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source *diffuse,
5600 enum wined3d_material_color_source *emissive, enum wined3d_material_color_source *ambient,
5601 enum wined3d_material_color_source *specular, const struct wined3d_state *state,
5602 const struct wined3d_stream_info *si)
5604 if (!state->render_states[WINED3D_RS_LIGHTING])
5606 *diffuse = WINED3D_MCS_COLOR1;
5607 *specular = WINED3D_MCS_COLOR2;
5608 *emissive = *ambient = WINED3D_MCS_MATERIAL;
5610 return;
5613 if (!state->render_states[WINED3D_RS_COLORVERTEX])
5615 *diffuse = *emissive = *ambient = *specular = WINED3D_MCS_MATERIAL;
5617 return;
5620 *diffuse = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_DIFFUSEMATERIALSOURCE]);
5621 *emissive = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_EMISSIVEMATERIALSOURCE]);
5622 *ambient = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_AMBIENTMATERIALSOURCE]);
5623 *specular = validate_material_colour_source(si->use_map, state->render_states[WINED3D_RS_SPECULARMATERIALSOURCE]);
5626 static inline void wined3d_vec4_transform(struct wined3d_vec4 *dst,
5627 const struct wined3d_vec4 *v, const struct wined3d_matrix *m)
5629 struct wined3d_vec4 tmp;
5631 tmp.x = v->x * m->_11 + v->y * m->_21 + v->z * m->_31 + v->w * m->_41;
5632 tmp.y = v->x * m->_12 + v->y * m->_22 + v->z * m->_32 + v->w * m->_42;
5633 tmp.z = v->x * m->_13 + v->y * m->_23 + v->z * m->_33 + v->w * m->_43;
5634 tmp.w = v->x * m->_14 + v->y * m->_24 + v->z * m->_34 + v->w * m->_44;
5636 *dst = tmp;
5639 BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
5641 void compute_normal_matrix(float *normal_matrix, BOOL legacy_lighting,
5642 const struct wined3d_matrix *modelview) DECLSPEC_HIDDEN;
5644 static inline struct wined3d_context *context_acquire(struct wined3d_device *device,
5645 struct wined3d_texture *texture, unsigned int sub_resource_idx)
5647 wined3d_from_cs(device->cs);
5649 return device->adapter->adapter_ops->adapter_acquire_context(device, texture, sub_resource_idx);
5652 static inline void context_release(struct wined3d_context *context)
5654 context->device->adapter->adapter_ops->adapter_release_context(context);
5657 static inline float wined3d_get_float_state(const struct wined3d_state *state, enum wined3d_render_state rs)
5659 union
5661 DWORD d;
5662 float f;
5664 tmpvalue;
5666 tmpvalue.d = state->render_states[rs];
5667 return tmpvalue.f;
5670 static inline void *wined3d_context_map_bo_address(struct wined3d_context *context,
5671 const struct wined3d_bo_address *data, size_t size, uint32_t map_flags)
5673 return context->device->adapter->adapter_ops->adapter_map_bo_address(context, data, size, map_flags);
5676 static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context,
5677 const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
5679 context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, range_count, ranges);
5682 static inline void wined3d_context_copy_bo_address(struct wined3d_context *context,
5683 const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, size_t size)
5685 context->device->adapter->adapter_ops->adapter_copy_bo_address(context, dst, src, size);
5688 static inline void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk,
5689 struct wined3d_bo_vk *bo)
5691 bo->command_buffer_id = context_vk->current_command_buffer.id;
5694 static inline void wined3d_context_vk_reference_texture(const struct wined3d_context_vk *context_vk,
5695 struct wined3d_texture_vk *texture_vk)
5697 texture_vk->command_buffer_id = context_vk->current_command_buffer.id;
5700 static inline void wined3d_context_vk_reference_sampler(const struct wined3d_context_vk *context_vk,
5701 struct wined3d_sampler_vk *sampler_vk)
5703 sampler_vk->command_buffer_id = context_vk->current_command_buffer.id;
5706 static inline void wined3d_context_vk_reference_rendertarget_view(const struct wined3d_context_vk *context_vk,
5707 struct wined3d_rendertarget_view_vk *rtv_vk)
5709 struct wined3d_resource *resource = rtv_vk->v.resource;
5711 if (resource->type == WINED3D_RTYPE_BUFFER)
5712 wined3d_context_vk_reference_bo(context_vk, &wined3d_buffer_vk(buffer_from_resource(resource))->bo);
5713 else
5714 wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource)));
5715 rtv_vk->command_buffer_id = context_vk->current_command_buffer.id;
5718 static inline void wined3d_context_vk_reference_shader_resource_view(const struct wined3d_context_vk *context_vk,
5719 struct wined3d_shader_resource_view_vk *srv_vk)
5721 struct wined3d_resource *resource = srv_vk->v.resource;
5723 if (resource->type == WINED3D_RTYPE_BUFFER)
5724 wined3d_context_vk_reference_bo(context_vk, &wined3d_buffer_vk(buffer_from_resource(resource))->bo);
5725 else
5726 wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource)));
5727 srv_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
5730 static inline void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk *context_vk,
5731 struct wined3d_unordered_access_view_vk *uav_vk)
5733 struct wined3d_resource *resource = uav_vk->v.resource;
5735 if (resource->type == WINED3D_RTYPE_BUFFER)
5736 wined3d_context_vk_reference_bo(context_vk, &wined3d_buffer_vk(buffer_from_resource(resource))->bo);
5737 else
5738 wined3d_context_vk_reference_texture(context_vk, wined3d_texture_vk(texture_from_resource(resource)));
5739 uav_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
5742 static inline BOOL wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view *dsv,
5743 const struct wined3d_format *srv_format)
5745 return !srv_format || (srv_format->red_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_DEPTH))
5746 || (srv_format->green_size && !(dsv->desc.flags & WINED3D_VIEW_READ_ONLY_STENCIL));
5749 static inline BOOL wined3d_resource_check_fbo_attached(const struct wined3d_state *state,
5750 const struct wined3d_resource *resource, const struct wined3d_format *srv_format)
5752 struct wined3d_rendertarget_view * const *rts = &state->fb.render_targets[0];
5753 const struct wined3d_rendertarget_view *dsv;
5754 unsigned int i;
5756 if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
5757 && (dsv = state->fb.depth_stencil) && dsv->resource == resource
5758 && wined3d_dsv_srv_conflict(dsv, srv_format))
5759 return TRUE;
5761 if (!(resource->bind_flags & WINED3D_BIND_RENDER_TARGET))
5762 return FALSE;
5764 for (i = 0; i < WINED3D_MAX_RENDER_TARGETS; ++i)
5765 if (rts[i] && rts[i]->resource == resource)
5766 return TRUE;
5768 return FALSE;
5771 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport *vp, float *min_z, float *max_z)
5773 *min_z = vp->min_z;
5775 /* The magic constant is derived from tests. */
5776 *max_z = max(vp->max_z, vp->min_z + 0.001f);
5779 static inline BOOL wined3d_bitmap_set(uint32_t *map, unsigned int idx)
5781 return map[idx >> 5] |= (1u << (idx & 0x1f));
5784 static inline BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx)
5786 return map[idx >> 5] & (1u << (idx & 0x1f));
5789 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap, unsigned int bit_count,
5790 unsigned int start, uint32_t xor_mask)
5792 const unsigned int word_bit_count = sizeof(*bitmap) * CHAR_BIT;
5793 const uint32_t *ptr, *end_ptr;
5794 uint32_t map, mask;
5796 assert(bit_count < word_bit_count || !(bit_count % word_bit_count));
5798 ptr = bitmap + start / word_bit_count;
5799 end_ptr = bitmap + (bit_count + word_bit_count - 1) / word_bit_count;
5801 if (ptr >= end_ptr)
5802 return ~0u;
5804 mask = ~0u << start % word_bit_count;
5805 map = (*ptr ^ xor_mask) & mask;
5806 while (!map)
5808 if (++ptr == end_ptr)
5809 return ~0u;
5810 map = *ptr ^ xor_mask;
5812 return (ptr - bitmap) * word_bit_count + wined3d_bit_scan(&map);
5815 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
5817 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, 0);
5820 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
5822 return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, ~0u);
5825 static inline BOOL wined3d_bitmap_get_range(const DWORD *bitmap, unsigned int bit_count,
5826 unsigned int start, struct wined3d_range *range)
5828 unsigned int range_start, range_end;
5830 range_start = wined3d_bitmap_ffs(bitmap, bit_count, start);
5831 if (range_start == ~0u)
5832 return FALSE;
5834 range_end = wined3d_bitmap_ffz(bitmap, bit_count, range_start + 1);
5835 if (range_end == ~0u)
5836 range_end = bit_count;
5838 range->offset = range_start;
5839 range->size = range_end - range_start;
5840 return TRUE;
5843 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context *context, unsigned int state_id)
5845 return wined3d_bitmap_is_set(context->dirty_graphics_states, state_id);
5848 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context *context, unsigned int state_id)
5850 return wined3d_bitmap_is_set(context->dirty_compute_states, state_id - STATE_COMPUTE_OFFSET);
5853 static inline bool isStateDirty(const struct wined3d_context *context, unsigned int state_id)
5855 return wined3d_context_is_graphics_state_dirty(context, state_id);
5858 static inline VkImageAspectFlags vk_aspect_mask_from_format(const struct wined3d_format *format)
5860 VkImageAspectFlags mask = 0;
5862 if (format->depth_size)
5863 mask |= VK_IMAGE_ASPECT_DEPTH_BIT;
5864 if (format->stencil_size)
5865 mask |= VK_IMAGE_ASPECT_STENCIL_BIT;
5866 if (!mask || format->red_size || format->green_size || format->blue_size || format->alpha_size)
5867 mask |= VK_IMAGE_ASPECT_COLOR_BIT;
5869 return mask;
5872 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
5873 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
5875 #endif