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 #define WINE_GLAPI __stdcall
33 #include <sys/types.h>
38 #define WIN32_NO_STATUS
39 #define NONAMELESSUNION
40 #define NONAMELESSSTRUCT
48 #include "ddk/d3dkmthk.h"
49 #include "wine/debug.h"
50 #include "wine/heap.h"
53 #include "wine/wined3d.h"
54 #include "wined3d_gl.h"
55 #include "wined3d_vk.h"
56 #include "wine/list.h"
57 #include "wine/rbtree.h"
58 #include "wine/wgl_driver.h"
60 static inline size_t align(size_t addr
, size_t alignment
)
62 return (addr
+ (alignment
- 1)) & ~(alignment
- 1);
65 static inline float int_to_float(uint32_t i
)
77 static inline const char *wined3d_get_line(const char **ptr
, const char *end
)
81 if ((p
= *ptr
) >= end
)
84 if (!(q
= memchr(p
, '\n', end
- p
)))
91 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
94 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
95 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
96 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
97 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
98 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
99 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
100 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
101 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
102 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
103 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
105 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
107 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
108 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
110 #define WINED3D_BITMAP_SIZE(x) (((x) + 31) >> 5)
112 struct wined3d_fragment_pipe_ops
;
113 struct wined3d_adapter
;
114 struct wined3d_buffer_vk
;
115 struct wined3d_context
;
116 struct wined3d_context_vk
;
117 struct wined3d_gl_info
;
118 struct wined3d_state
;
119 struct wined3d_swapchain_gl
;
120 struct wined3d_texture_gl
;
121 struct wined3d_vertex_pipe_ops
;
125 WINED3D_FFP_POSITION
= 0,
126 WINED3D_FFP_BLENDWEIGHT
= 1,
127 WINED3D_FFP_BLENDINDICES
= 2,
128 WINED3D_FFP_NORMAL
= 3,
129 WINED3D_FFP_PSIZE
= 4,
130 WINED3D_FFP_DIFFUSE
= 5,
131 WINED3D_FFP_SPECULAR
= 6,
132 WINED3D_FFP_TEXCOORD0
= 7,
133 WINED3D_FFP_TEXCOORD1
= 8,
134 WINED3D_FFP_TEXCOORD2
= 9,
135 WINED3D_FFP_TEXCOORD3
= 10,
136 WINED3D_FFP_TEXCOORD4
= 11,
137 WINED3D_FFP_TEXCOORD5
= 12,
138 WINED3D_FFP_TEXCOORD6
= 13,
139 WINED3D_FFP_TEXCOORD7
= 14,
140 WINED3D_FFP_ATTRIBS_COUNT
= 15,
143 enum wined3d_ffp_emit_idx
145 WINED3D_FFP_EMIT_FLOAT1
,
146 WINED3D_FFP_EMIT_FLOAT2
,
147 WINED3D_FFP_EMIT_FLOAT3
,
148 WINED3D_FFP_EMIT_FLOAT4
,
149 WINED3D_FFP_EMIT_D3DCOLOR
,
150 WINED3D_FFP_EMIT_UBYTE4
,
151 WINED3D_FFP_EMIT_SHORT2
,
152 WINED3D_FFP_EMIT_SHORT4
,
153 WINED3D_FFP_EMIT_UBYTE4N
,
154 WINED3D_FFP_EMIT_SHORT2N
,
155 WINED3D_FFP_EMIT_SHORT4N
,
156 WINED3D_FFP_EMIT_USHORT2N
,
157 WINED3D_FFP_EMIT_USHORT4N
,
158 WINED3D_FFP_EMIT_UDEC3
,
159 WINED3D_FFP_EMIT_DEC3N
,
160 WINED3D_FFP_EMIT_FLOAT16_2
,
161 WINED3D_FFP_EMIT_FLOAT16_4
,
162 WINED3D_FFP_EMIT_INVALID
,
163 WINED3D_FFP_EMIT_COUNT
,
166 /* Texture format fixups */
168 enum fixup_channel_source
170 CHANNEL_SOURCE_ZERO
= 0,
171 CHANNEL_SOURCE_ONE
= 1,
172 CHANNEL_SOURCE_X
= 2,
173 CHANNEL_SOURCE_Y
= 3,
174 CHANNEL_SOURCE_Z
= 4,
175 CHANNEL_SOURCE_W
= 5,
176 CHANNEL_SOURCE_COMPLEX0
= 6,
177 CHANNEL_SOURCE_COMPLEX1
= 7,
182 COMPLEX_FIXUP_NONE
= 0,
183 COMPLEX_FIXUP_YUY2
= 1,
184 COMPLEX_FIXUP_UYVY
= 2,
185 COMPLEX_FIXUP_YV12
= 3,
186 COMPLEX_FIXUP_P8
= 4,
187 COMPLEX_FIXUP_NV12
= 5,
188 COMPLEX_FIXUP_YUV
= 6,
191 #include <pshpack2.h>
192 struct color_fixup_desc
194 unsigned short x_sign_fixup
: 1;
195 unsigned short x_source
: 3;
196 unsigned short y_sign_fixup
: 1;
197 unsigned short y_source
: 3;
198 unsigned short z_sign_fixup
: 1;
199 unsigned short z_source
: 3;
200 unsigned short w_sign_fixup
: 1;
201 unsigned short w_source
: 3;
205 struct wined3d_d3d_limits
207 unsigned int vs_version
, hs_version
, ds_version
, gs_version
, ps_version
, cs_version
;
208 DWORD vs_uniform_count
;
209 DWORD ps_uniform_count
;
210 unsigned int varying_count
;
211 unsigned int ffp_textures
;
212 unsigned int ffp_blend_stages
;
213 unsigned int ffp_vertex_blend_matrices
;
214 unsigned int active_light_count
;
216 unsigned int max_rt_count
;
217 unsigned int max_clip_distances
;
218 unsigned int texture_size
;
222 typedef void (WINE_GLAPI
*wined3d_ffp_attrib_func
)(const void *data
);
223 typedef void (WINE_GLAPI
*wined3d_ffp_texcoord_func
)(GLenum unit
, const void *data
);
224 typedef void (WINE_GLAPI
*wined3d_generic_attrib_func
)(GLuint idx
, const void *data
);
225 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN
;
227 struct wined3d_ffp_attrib_ops
229 wined3d_ffp_attrib_func position
[WINED3D_FFP_EMIT_COUNT
];
230 wined3d_ffp_attrib_func diffuse
[WINED3D_FFP_EMIT_COUNT
];
231 wined3d_ffp_attrib_func specular
[WINED3D_FFP_EMIT_COUNT
];
232 wined3d_ffp_attrib_func normal
[WINED3D_FFP_EMIT_COUNT
];
233 wined3d_ffp_texcoord_func texcoord
[WINED3D_FFP_EMIT_COUNT
];
234 wined3d_generic_attrib_func generic
[WINED3D_FFP_EMIT_COUNT
];
237 struct wined3d_d3d_info
239 struct wined3d_d3d_limits limits
;
240 struct wined3d_ffp_attrib_ops ffp_attrib_ops
;
241 uint32_t wined3d_creation_flags
;
243 uint32_t emulated_flatshading
: 1;
244 uint32_t ffp_generic_attributes
: 1;
245 uint32_t ffp_alpha_test
: 1;
246 uint32_t vs_clipping
: 1;
247 uint32_t shader_color_key
: 1;
248 uint32_t shader_double_precision
: 1;
249 uint32_t shader_output_interpolation
: 1;
250 uint32_t frag_coord_correction
: 1;
251 uint32_t viewport_array_index_any_shader
: 1;
252 uint32_t texture_npot
: 1;
253 uint32_t texture_npot_conditional
: 1;
254 uint32_t draw_base_vertex_offset
: 1;
255 uint32_t vertex_bgra
: 1;
256 uint32_t texture_swizzle
: 1;
257 uint32_t srgb_read_control
: 1;
258 uint32_t srgb_write_control
: 1;
259 uint32_t clip_control
: 1;
260 uint32_t full_ffp_varyings
: 1;
261 uint32_t scaled_resolve
: 1;
263 uint32_t subpixel_viewport
: 1;
265 uint32_t persistent_map
: 1;
266 enum wined3d_feature_level feature_level
;
268 DWORD multisample_draw_location
;
270 float filling_convention_offset
;
273 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
=
274 {0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_Z
, 0, CHANNEL_SOURCE_W
};
276 static inline struct color_fixup_desc
create_complex_fixup_desc(enum complex_fixup complex_fixup
)
278 struct color_fixup_desc fixup
=
280 0u, complex_fixup
& (1u << 0) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
281 0u, complex_fixup
& (1u << 1) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
282 0u, complex_fixup
& (1u << 2) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
283 0u, complex_fixup
& (1u << 3) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
288 static inline BOOL
is_identity_fixup(struct color_fixup_desc fixup
)
290 return !memcmp(&fixup
, &COLOR_FIXUP_IDENTITY
, sizeof(fixup
));
293 static inline BOOL
is_complex_fixup(struct color_fixup_desc fixup
)
295 return fixup
.x_source
== CHANNEL_SOURCE_COMPLEX0
|| fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
;
298 static inline BOOL
is_scaling_fixup(struct color_fixup_desc fixup
)
300 return fixup
.x_sign_fixup
|| fixup
.y_sign_fixup
|| fixup
.z_sign_fixup
|| fixup
.w_sign_fixup
;
303 static inline BOOL
is_same_fixup(struct color_fixup_desc f1
, struct color_fixup_desc f2
)
305 return f1
.x_sign_fixup
== f2
.x_sign_fixup
&& f1
.x_source
== f2
.x_source
306 && f1
.y_sign_fixup
== f2
.y_sign_fixup
&& f1
.y_source
== f2
.y_source
307 && f1
.z_sign_fixup
== f2
.z_sign_fixup
&& f1
.z_source
== f2
.z_source
308 && f1
.w_sign_fixup
== f2
.w_sign_fixup
&& f1
.w_source
== f2
.w_source
;
311 static inline enum complex_fixup
get_complex_fixup(struct color_fixup_desc fixup
)
313 enum complex_fixup complex_fixup
= 0;
314 if (fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 0);
315 if (fixup
.y_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 1);
316 if (fixup
.z_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 2);
317 if (fixup
.w_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 3);
318 return complex_fixup
;
322 #define WINED3D_MAX_ACTIVE_LIGHTS 8
323 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
324 #define MAX_CONSTANT_BUFFERS 15
325 #define MAX_SAMPLER_OBJECTS 16
326 #define MAX_SHADER_RESOURCE_VIEWS 128
327 #define MAX_UNORDERED_ACCESS_VIEWS 8
328 #define MAX_TGSM_REGISTERS 8192
329 #define MAX_VERTEX_BLENDS 4
333 GLenum mip
[WINED3D_TEXF_LINEAR
+ 1];
336 extern const struct min_lookup minMipLookup
[WINED3D_TEXF_LINEAR
+ 1] DECLSPEC_HIDDEN
;
337 extern const GLenum magLookup
[WINED3D_TEXF_LINEAR
+ 1] DECLSPEC_HIDDEN
;
339 static const uint32_t WINED3D_READ_ONLY_BIND_MASK
= WINED3D_BIND_VERTEX_BUFFER
| WINED3D_BIND_INDEX_BUFFER
340 | WINED3D_BIND_CONSTANT_BUFFER
| WINED3D_BIND_SHADER_RESOURCE
| WINED3D_BIND_INDIRECT_BUFFER
;
342 static const VkAccessFlags WINED3D_READ_ONLY_ACCESS_FLAGS
= VK_ACCESS_INDIRECT_COMMAND_READ_BIT
343 | VK_ACCESS_INDEX_READ_BIT
| VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
| VK_ACCESS_UNIFORM_READ_BIT
344 | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
| VK_ACCESS_SHADER_READ_BIT
| VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
345 | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
| VK_ACCESS_TRANSFER_READ_BIT
| VK_ACCESS_HOST_READ_BIT
346 | VK_ACCESS_MEMORY_READ_BIT
;
348 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
) DECLSPEC_HIDDEN
;
349 VkAccessFlags
vk_access_mask_from_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
350 VkCompareOp
vk_compare_op_from_wined3d(enum wined3d_cmp_func op
) DECLSPEC_HIDDEN
;
351 VkImageViewType
vk_image_view_type_from_wined3d(enum wined3d_resource_type type
, uint32_t flags
) DECLSPEC_HIDDEN
;
352 VkPipelineStageFlags
vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
353 VkShaderStageFlagBits
vk_shader_stage_from_wined3d(enum wined3d_shader_type shader_type
) DECLSPEC_HIDDEN
;
354 VkAccessFlags
vk_access_mask_from_buffer_usage(VkBufferUsageFlags usage
) DECLSPEC_HIDDEN
;
355 VkPipelineStageFlags
vk_pipeline_stage_mask_from_buffer_usage(VkBufferUsageFlags usage
) DECLSPEC_HIDDEN
;
356 VkBufferUsageFlags
vk_buffer_usage_from_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
357 VkMemoryPropertyFlags
vk_memory_type_from_access_flags(uint32_t access
, uint32_t usage
) DECLSPEC_HIDDEN
;
359 static inline enum wined3d_cmp_func
wined3d_sanitize_cmp_func(enum wined3d_cmp_func func
)
361 if (func
< WINED3D_CMP_NEVER
|| func
> WINED3D_CMP_ALWAYS
)
362 return WINED3D_CMP_ALWAYS
;
366 static inline GLenum
wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter
)
368 return magLookup
[mag_filter
];
371 static inline GLenum
wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter
,
372 enum wined3d_texture_filter_type mip_filter
)
374 return minMipLookup
[min_filter
].mip
[mip_filter
];
377 /* float_16_to_32() and float_32_to_16() convert 16 bit floats in the
378 * FLOAT16 data type to standard C floats and vice versa. They do not
379 * depend on the encoding of the C float, so they are platform independent,
380 * but slow. On x86 and other IEEE 754 compliant platforms the conversion
381 * can be accelerated by bit shifting the exponent and mantissa. There are
382 * also some SSE-based assembly routines out there.
384 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
386 static inline float float_16_to_32(const unsigned short *in
)
388 const unsigned short s
= ((*in
) & 0x8000u
);
389 const unsigned short e
= ((*in
) & 0x7c00u
) >> 10;
390 const unsigned short m
= (*in
) & 0x3ffu
;
391 const float sgn
= (s
? -1.0f
: 1.0f
);
394 if(m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
395 else return sgn
* powf(2, -14.0f
) * ((float)m
/ 1024.0f
);
397 return sgn
* powf(2, (float)e
- 15.0f
) * (1.0f
+ ((float)m
/ 1024.0f
));
399 if(m
== 0) return sgn
* INFINITY
;
404 static inline float float_24_to_32(DWORD in
)
406 const float sgn
= in
& 0x800000u
? -1.0f
: 1.0f
;
407 const unsigned short e
= (in
& 0x780000u
) >> 19;
408 const unsigned int m
= in
& 0x7ffffu
;
412 if (m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
413 else return sgn
* powf(2, -6.0f
) * ((float)m
/ 524288.0f
);
417 return sgn
* powf(2, (float)e
- 7.0f
) * (1.0f
+ ((float)m
/ 524288.0f
));
421 if (m
== 0) return sgn
* INFINITY
;
426 static inline unsigned short float_32_to_16(const float *in
)
429 float tmp
= fabsf(*in
);
430 unsigned int mantissa
;
433 /* Deal with special numbers */
439 return (*in
< 0.0f
? 0xfc00 : 0x7c00);
441 if (tmp
< (float)(1u << 10))
447 } while (tmp
< (float)(1u << 10));
449 else if (tmp
>= (float)(1u << 11))
455 } while (tmp
>= (float)(1u << 11));
458 mantissa
= (unsigned int)tmp
;
459 if (tmp
- mantissa
>= 0.5f
)
460 ++mantissa
; /* Round to nearest, away from zero. */
462 exp
+= 10; /* Normalize the mantissa. */
463 exp
+= 15; /* Exponent is encoded with excess 15. */
465 if (exp
> 30) /* too big */
467 ret
= 0x7c00; /* INF */
471 /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
474 mantissa
= mantissa
>> 1;
477 ret
= mantissa
& 0x3ff;
481 ret
= (exp
<< 10) | (mantissa
& 0x3ff);
484 ret
|= ((*in
< 0.0f
? 1 : 0) << 15); /* Add the sign */
488 static inline unsigned int wined3d_popcount(unsigned int x
)
490 #if defined(__MINGW32__)
491 return __builtin_popcount(x
);
493 x
-= x
>> 1 & 0x55555555;
494 x
= (x
& 0x33333333) + (x
>> 2 & 0x33333333);
495 return ((x
+ (x
>> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
499 static inline int wined3d_uint32_compare(uint32_t x
, uint32_t y
)
501 return (x
> y
) - (x
< y
);
504 static inline int wined3d_uint64_compare(uint64_t x
, uint64_t y
)
506 return (x
> y
) - (x
< y
);
509 #define ORM_BACKBUFFER 0
512 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
513 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
515 enum wined3d_renderer
517 WINED3D_RENDERER_AUTO
,
518 WINED3D_RENDERER_VULKAN
,
519 WINED3D_RENDERER_OPENGL
,
520 WINED3D_RENDERER_NO3D
,
523 enum wined3d_shader_backend
525 WINED3D_SHADER_BACKEND_AUTO
,
526 WINED3D_SHADER_BACKEND_GLSL
,
527 WINED3D_SHADER_BACKEND_ARB
,
528 WINED3D_SHADER_BACKEND_NONE
,
531 #define WINED3D_CSMT_ENABLE 0x00000001
532 #define WINED3D_CSMT_SERIALIZE 0x00000002
534 /* NOTE: When adding fields to this structure, make sure to update the default
535 * values in wined3d_main.c as well. */
536 struct wined3d_settings
538 unsigned int cs_multithreaded
;
539 unsigned int max_gl_version
;
540 int offscreen_rendering_mode
;
541 unsigned short pci_vendor_id
;
542 unsigned short pci_device_id
;
543 /* Memory tracking and object counting. */
544 UINT64 emulated_textureram
;
546 unsigned int multisample_textures
;
547 unsigned int sample_count
;
548 BOOL check_float_constants
;
549 unsigned int strict_shader_math
;
550 unsigned int max_sm_vs
;
551 unsigned int max_sm_hs
;
552 unsigned int max_sm_ds
;
553 unsigned int max_sm_gs
;
554 unsigned int max_sm_ps
;
555 unsigned int max_sm_cs
;
556 enum wined3d_renderer renderer
;
557 enum wined3d_shader_backend shader_backend
;
558 BOOL cb_access_map_w
;
561 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN
;
563 enum wined3d_shader_byte_code_format
565 WINED3D_SHADER_BYTE_CODE_FORMAT_SM1
,
566 WINED3D_SHADER_BYTE_CODE_FORMAT_SM4
,
569 enum wined3d_shader_resource_type
571 WINED3D_SHADER_RESOURCE_NONE
,
572 WINED3D_SHADER_RESOURCE_BUFFER
,
573 WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
574 WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
575 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
576 WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
577 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
578 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
579 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
580 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
581 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY
,
584 #define WINED3D_SHADER_CONST_VS_F 0x00000001
585 #define WINED3D_SHADER_CONST_VS_I 0x00000002
586 #define WINED3D_SHADER_CONST_VS_B 0x00000004
587 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
588 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
589 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
590 #define WINED3D_SHADER_CONST_PS_F 0x00000040
591 #define WINED3D_SHADER_CONST_PS_I 0x00000080
592 #define WINED3D_SHADER_CONST_PS_B 0x00000100
593 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
594 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
595 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
596 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
597 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
598 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
599 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
600 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
601 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
602 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
603 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
604 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
605 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
606 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
608 enum wined3d_shader_register_type
611 WINED3DSPR_INPUT
= 1,
612 WINED3DSPR_CONST
= 2,
614 WINED3DSPR_TEXTURE
= 3,
615 WINED3DSPR_RASTOUT
= 4,
616 WINED3DSPR_ATTROUT
= 5,
617 WINED3DSPR_TEXCRDOUT
= 6,
618 WINED3DSPR_OUTPUT
= 6,
619 WINED3DSPR_CONSTINT
= 7,
620 WINED3DSPR_COLOROUT
= 8,
621 WINED3DSPR_DEPTHOUT
= 9,
622 WINED3DSPR_SAMPLER
= 10,
623 WINED3DSPR_CONST2
= 11,
624 WINED3DSPR_CONST3
= 12,
625 WINED3DSPR_CONST4
= 13,
626 WINED3DSPR_CONSTBOOL
= 14,
627 WINED3DSPR_LOOP
= 15,
628 WINED3DSPR_TEMPFLOAT16
= 16,
629 WINED3DSPR_MISCTYPE
= 17,
630 WINED3DSPR_LABEL
= 18,
631 WINED3DSPR_PREDICATE
= 19,
633 WINED3DSPR_CONSTBUFFER
,
634 WINED3DSPR_IMMCONSTBUFFER
,
639 WINED3DSPR_OUTPOINTID
,
640 WINED3DSPR_FORKINSTID
,
641 WINED3DSPR_JOININSTID
,
642 WINED3DSPR_INCONTROLPOINT
,
643 WINED3DSPR_OUTCONTROLPOINT
,
644 WINED3DSPR_PATCHCONST
,
645 WINED3DSPR_TESSCOORD
,
646 WINED3DSPR_GROUPSHAREDMEM
,
648 WINED3DSPR_THREADGROUPID
,
649 WINED3DSPR_LOCALTHREADID
,
650 WINED3DSPR_LOCALTHREADINDEX
,
653 WINED3DSPR_FUNCTIONBODY
,
654 WINED3DSPR_FUNCTIONPOINTER
,
656 WINED3DSPR_SAMPLEMASK
,
658 WINED3DSPR_DEPTHOUTGE
,
659 WINED3DSPR_DEPTHOUTLE
,
660 WINED3DSPR_RASTERIZER
,
663 enum wined3d_data_type
667 WINED3D_DATA_RESOURCE
,
668 WINED3D_DATA_SAMPLER
,
676 enum wined3d_immconst_type
678 WINED3D_IMMCONST_SCALAR
,
679 WINED3D_IMMCONST_VEC4
,
682 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
684 enum wined3d_shader_src_modifier
686 WINED3DSPSM_NONE
= 0,
688 WINED3DSPSM_BIAS
= 2,
689 WINED3DSPSM_BIASNEG
= 3,
690 WINED3DSPSM_SIGN
= 4,
691 WINED3DSPSM_SIGNNEG
= 5,
692 WINED3DSPSM_COMP
= 6,
694 WINED3DSPSM_X2NEG
= 8,
697 WINED3DSPSM_ABS
= 11,
698 WINED3DSPSM_ABSNEG
= 12,
699 WINED3DSPSM_NOT
= 13,
702 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
703 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
704 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
705 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
706 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
708 enum wined3d_shader_dst_modifier
710 WINED3DSPDM_NONE
= 0,
711 WINED3DSPDM_SATURATE
= 1,
712 WINED3DSPDM_PARTIALPRECISION
= 2,
713 WINED3DSPDM_MSAMPCENTROID
= 4,
716 enum wined3d_shader_interpolation_mode
719 WINED3DSIM_CONSTANT
= 1,
720 WINED3DSIM_LINEAR
= 2,
721 WINED3DSIM_LINEAR_CENTROID
= 3,
722 WINED3DSIM_LINEAR_NOPERSPECTIVE
= 4,
723 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
= 5,
724 WINED3DSIM_LINEAR_SAMPLE
= 6,
725 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE
= 7,
728 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
729 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
731 enum wined3d_shader_global_flags
733 WINED3DSGF_REFACTORING_ALLOWED
= 0x1,
734 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL
= 0x4,
735 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS
= 0x8,
738 enum wined3d_shader_sync_flags
740 WINED3DSSF_THREAD_GROUP
= 0x1,
741 WINED3DSSF_GROUP_SHARED_MEMORY
= 0x2,
742 WINED3DSSF_GLOBAL_UAV
= 0x8,
745 enum wined3d_shader_uav_flags
747 WINED3DSUF_GLOBALLY_COHERENT
= 0x2,
748 WINED3DSUF_ORDER_PRESERVING_COUNTER
= 0x100,
751 enum wined3d_tessellator_domain
753 WINED3D_TESSELLATOR_DOMAIN_LINE
= 1,
754 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE
= 2,
755 WINED3D_TESSELLATOR_DOMAIN_QUAD
= 3,
758 enum wined3d_tessellator_output_primitive
760 WINED3D_TESSELLATOR_OUTPUT_POINT
= 1,
761 WINED3D_TESSELLATOR_OUTPUT_LINE
= 2,
762 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW
= 3,
763 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW
= 4,
766 enum wined3d_tessellator_partitioning
768 WINED3D_TESSELLATOR_PARTITIONING_INTEGER
= 1,
769 WINED3D_TESSELLATOR_PARTITIONING_POW2
= 2,
770 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD
= 3,
771 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
= 4,
774 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
775 #define WINED3DSI_TEXLD_PROJECT 0x1
776 #define WINED3DSI_TEXLD_BIAS 0x2
777 #define WINED3DSI_INDEXED_DYNAMIC 0x4
778 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
779 #define WINED3DSI_RESINFO_UINT 0x2
780 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
781 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
783 #define WINED3DSI_PRECISE_X 0x100
784 #define WINED3DSI_PRECISE_Y 0x200
785 #define WINED3DSI_PRECISE_Z 0x400
786 #define WINED3DSI_PRECISE_W 0x800
787 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
788 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
789 #define WINED3DSI_PRECISE_SHIFT 8
791 enum wined3d_shader_rel_op
793 WINED3D_SHADER_REL_OP_GT
= 1,
794 WINED3D_SHADER_REL_OP_EQ
= 2,
795 WINED3D_SHADER_REL_OP_GE
= 3,
796 WINED3D_SHADER_REL_OP_LT
= 4,
797 WINED3D_SHADER_REL_OP_NE
= 5,
798 WINED3D_SHADER_REL_OP_LE
= 6,
801 enum wined3d_shader_conditional_op
803 WINED3D_SHADER_CONDITIONAL_OP_NZ
= 0,
804 WINED3D_SHADER_CONDITIONAL_OP_Z
= 1
807 enum wined3d_sysval_semantic
809 WINED3D_SV_POSITION
= 0x01,
810 WINED3D_SV_CLIP_DISTANCE
= 0x02,
811 WINED3D_SV_CULL_DISTANCE
= 0x03,
812 WINED3D_SV_RENDER_TARGET_ARRAY_INDEX
= 0x04,
813 WINED3D_SV_VIEWPORT_ARRAY_INDEX
= 0x05,
814 WINED3D_SV_VERTEX_ID
= 0x06,
815 WINED3D_SV_PRIMITIVE_ID
= 0x07,
816 WINED3D_SV_INSTANCE_ID
= 0x08,
817 WINED3D_SV_IS_FRONT_FACE
= 0x09,
818 WINED3D_SV_SAMPLE_INDEX
= 0x0a,
819 WINED3D_SV_TESS_FACTOR_QUADEDGE
= 0x0b,
820 WINED3D_SV_TESS_FACTOR_QUADINT
= 0x0c,
821 WINED3D_SV_TESS_FACTOR_TRIEDGE
= 0x0d,
822 WINED3D_SV_TESS_FACTOR_TRIINT
= 0x0e,
823 WINED3D_SV_TESS_FACTOR_LINEDET
= 0x0f,
824 WINED3D_SV_TESS_FACTOR_LINEDEN
= 0x10,
827 enum wined3d_component_type
829 WINED3D_TYPE_UNKNOWN
= 0x0,
830 WINED3D_TYPE_UINT
= 0x1,
831 WINED3D_TYPE_INT
= 0x2,
832 WINED3D_TYPE_FLOAT
= 0x3,
835 struct wined3d_shader_signature_element
837 const char *semantic_name
;
838 unsigned int semantic_idx
;
839 unsigned int stream_idx
;
840 enum wined3d_sysval_semantic sysval_semantic
;
841 enum wined3d_component_type component_type
;
842 unsigned int register_idx
;
844 unsigned int min_precision
;
847 struct wined3d_shader_signature
849 unsigned int element_count
;
850 struct wined3d_shader_signature_element
*elements
;
853 #define WINED3D_SM1_VS 0xfffeu
854 #define WINED3D_SM1_PS 0xffffu
855 #define WINED3D_SM4_PS 0x0000u
856 #define WINED3D_SM4_VS 0x0001u
857 #define WINED3D_SM4_GS 0x0002u
858 #define WINED3D_SM5_HS 0x0003u
859 #define WINED3D_SM5_DS 0x0004u
860 #define WINED3D_SM5_CS 0x0005u
862 /* Shader version tokens, and shader end tokens */
863 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
864 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
866 /* Shader backends */
868 #define MAX_ATTRIBS 32
869 #define MAX_REG_ADDR 1
870 #define MAX_REG_TEXCRD 8
871 #define MAX_REG_INPUT 32
872 #define MAX_REG_OUTPUT 32
873 #define WINED3D_MAX_CBS 15
875 /* FIXME: This needs to go up to 2048 for
876 * Shader model 3 according to msdn (and for software shaders) */
877 #define MAX_LABELS 16
879 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
881 struct wined3d_string_buffer
885 unsigned int buffer_size
;
886 unsigned int content_size
;
889 enum WINED3D_SHADER_INSTRUCTION_HANDLER
894 WINED3DSIH_ATOMIC_AND
,
895 WINED3DSIH_ATOMIC_CMP_STORE
,
896 WINED3DSIH_ATOMIC_IADD
,
897 WINED3DSIH_ATOMIC_IMAX
,
898 WINED3DSIH_ATOMIC_IMIN
,
899 WINED3DSIH_ATOMIC_OR
,
900 WINED3DSIH_ATOMIC_UMAX
,
901 WINED3DSIH_ATOMIC_UMIN
,
902 WINED3DSIH_ATOMIC_XOR
,
916 WINED3DSIH_CONTINUEP
,
917 WINED3DSIH_COUNTBITS
,
920 WINED3DSIH_CUT_STREAM
,
922 WINED3DSIH_DCL_CONSTANT_BUFFER
,
923 WINED3DSIH_DCL_FUNCTION_BODY
,
924 WINED3DSIH_DCL_FUNCTION_TABLE
,
925 WINED3DSIH_DCL_GLOBAL_FLAGS
,
926 WINED3DSIH_DCL_GS_INSTANCES
,
927 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
,
928 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
,
929 WINED3DSIH_DCL_HS_MAX_TESSFACTOR
,
930 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
,
931 WINED3DSIH_DCL_INDEX_RANGE
,
932 WINED3DSIH_DCL_INDEXABLE_TEMP
,
933 WINED3DSIH_DCL_INPUT
,
934 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
,
935 WINED3DSIH_DCL_INPUT_PRIMITIVE
,
936 WINED3DSIH_DCL_INPUT_PS
,
937 WINED3DSIH_DCL_INPUT_PS_SGV
,
938 WINED3DSIH_DCL_INPUT_PS_SIV
,
939 WINED3DSIH_DCL_INPUT_SGV
,
940 WINED3DSIH_DCL_INPUT_SIV
,
941 WINED3DSIH_DCL_INTERFACE
,
942 WINED3DSIH_DCL_OUTPUT
,
943 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
,
944 WINED3DSIH_DCL_OUTPUT_SIV
,
945 WINED3DSIH_DCL_OUTPUT_TOPOLOGY
,
946 WINED3DSIH_DCL_RESOURCE_RAW
,
947 WINED3DSIH_DCL_RESOURCE_STRUCTURED
,
948 WINED3DSIH_DCL_SAMPLER
,
949 WINED3DSIH_DCL_STREAM
,
950 WINED3DSIH_DCL_TEMPS
,
951 WINED3DSIH_DCL_TESSELLATOR_DOMAIN
,
952 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
,
953 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
,
954 WINED3DSIH_DCL_TGSM_RAW
,
955 WINED3DSIH_DCL_TGSM_STRUCTURED
,
956 WINED3DSIH_DCL_THREAD_GROUP
,
957 WINED3DSIH_DCL_UAV_RAW
,
958 WINED3DSIH_DCL_UAV_STRUCTURED
,
959 WINED3DSIH_DCL_UAV_TYPED
,
960 WINED3DSIH_DCL_VERTICES_OUT
,
972 WINED3DSIH_DSX_COARSE
,
975 WINED3DSIH_DSY_COARSE
,
979 WINED3DSIH_EMIT_STREAM
,
983 WINED3DSIH_ENDSWITCH
,
985 WINED3DSIH_EVAL_CENTROID
,
986 WINED3DSIH_EVAL_SAMPLE_INDEX
,
992 WINED3DSIH_FIRSTBIT_HI
,
993 WINED3DSIH_FIRSTBIT_LO
,
994 WINED3DSIH_FIRSTBIT_SHI
,
999 WINED3DSIH_GATHER4_C
,
1000 WINED3DSIH_GATHER4_PO
,
1001 WINED3DSIH_GATHER4_PO_C
,
1003 WINED3DSIH_HS_CONTROL_POINT_PHASE
,
1004 WINED3DSIH_HS_DECLS
,
1005 WINED3DSIH_HS_FORK_PHASE
,
1006 WINED3DSIH_HS_JOIN_PHASE
,
1017 WINED3DSIH_IMM_ATOMIC_ALLOC
,
1018 WINED3DSIH_IMM_ATOMIC_AND
,
1019 WINED3DSIH_IMM_ATOMIC_CMP_EXCH
,
1020 WINED3DSIH_IMM_ATOMIC_CONSUME
,
1021 WINED3DSIH_IMM_ATOMIC_EXCH
,
1022 WINED3DSIH_IMM_ATOMIC_IADD
,
1023 WINED3DSIH_IMM_ATOMIC_IMAX
,
1024 WINED3DSIH_IMM_ATOMIC_IMIN
,
1025 WINED3DSIH_IMM_ATOMIC_OR
,
1026 WINED3DSIH_IMM_ATOMIC_UMAX
,
1027 WINED3DSIH_IMM_ATOMIC_UMIN
,
1028 WINED3DSIH_IMM_ATOMIC_XOR
,
1039 WINED3DSIH_LD_STRUCTURED
,
1040 WINED3DSIH_LD_UAV_TYPED
,
1072 WINED3DSIH_ROUND_NE
,
1073 WINED3DSIH_ROUND_NI
,
1074 WINED3DSIH_ROUND_PI
,
1078 WINED3DSIH_SAMPLE_B
,
1079 WINED3DSIH_SAMPLE_C
,
1080 WINED3DSIH_SAMPLE_C_LZ
,
1081 WINED3DSIH_SAMPLE_GRAD
,
1082 WINED3DSIH_SAMPLE_INFO
,
1083 WINED3DSIH_SAMPLE_LOD
,
1084 WINED3DSIH_SAMPLE_POS
,
1091 WINED3DSIH_STORE_RAW
,
1092 WINED3DSIH_STORE_STRUCTURED
,
1093 WINED3DSIH_STORE_UAV_TYPED
,
1101 WINED3DSIH_TEXCOORD
,
1102 WINED3DSIH_TEXDEPTH
,
1104 WINED3DSIH_TEXDP3TEX
,
1108 WINED3DSIH_TEXM3x2DEPTH
,
1109 WINED3DSIH_TEXM3x2PAD
,
1110 WINED3DSIH_TEXM3x2TEX
,
1112 WINED3DSIH_TEXM3x3DIFF
,
1113 WINED3DSIH_TEXM3x3PAD
,
1114 WINED3DSIH_TEXM3x3SPEC
,
1115 WINED3DSIH_TEXM3x3TEX
,
1116 WINED3DSIH_TEXM3x3VSPEC
,
1117 WINED3DSIH_TEXREG2AR
,
1118 WINED3DSIH_TEXREG2GB
,
1119 WINED3DSIH_TEXREG2RGB
,
1130 WINED3DSIH_TABLE_SIZE
1133 struct wined3d_shader_version
1135 enum wined3d_shader_type type
;
1140 struct wined3d_shader_resource_info
1142 enum wined3d_shader_resource_type type
;
1143 enum wined3d_data_type data_type
;
1145 unsigned int stride
;
1148 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1150 struct wined3d_shader_sampler_map_entry
1152 unsigned int resource_idx
;
1153 unsigned int sampler_idx
;
1154 unsigned int bind_idx
;
1157 struct wined3d_shader_sampler_map
1159 struct wined3d_shader_sampler_map_entry
*entries
;
1164 struct wined3d_shader_immediate_constant_buffer
1166 unsigned int vec4_count
;
1167 uint32_t data
[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
];
1170 struct wined3d_shader_indexable_temp
1173 unsigned int register_idx
;
1174 unsigned int register_size
;
1175 unsigned int component_count
;
1178 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1180 struct wined3d_shader_reg_maps
1182 struct wined3d_shader_version shader_version
;
1183 BYTE texcoord
; /* MAX_REG_TEXCRD, 8 */
1184 BYTE address
; /* MAX_REG_ADDR, 1 */
1185 WORD labels
; /* MAX_LABELS, 16 */
1186 DWORD temporary
; /* 32 */
1187 unsigned int temporary_count
;
1188 uint32_t *constf
; /* pixel, vertex */
1189 struct list indexable_temps
;
1190 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1193 DWORD texcoord_mask
[MAX_REG_TEXCRD
]; /* vertex < 3.0 */
1194 BYTE output_registers_mask
[MAX_REG_OUTPUT
]; /* vertex >= 3.0 */
1196 DWORD input_registers
; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1197 DWORD output_registers
; /* MAX_REG_OUTPUT, 32 */
1198 WORD integer_constants
; /* WINED3D_MAX_CONSTS_I, 16 */
1199 WORD boolean_constants
; /* WINED3D_MAX_CONSTS_B, 16 */
1200 WORD local_int_consts
; /* WINED3D_MAX_CONSTS_I, 16 */
1201 WORD local_bool_consts
; /* WINED3D_MAX_CONSTS_B, 16 */
1202 UINT cb_sizes
[WINED3D_MAX_CBS
];
1203 uint32_t cb_map
; /* WINED3D_MAX_CBS, 15 */
1205 struct wined3d_shader_resource_info resource_info
[MAX_SHADER_RESOURCE_VIEWS
];
1206 uint32_t resource_map
[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS
)];
1207 struct wined3d_shader_sampler_map sampler_map
;
1208 DWORD sampler_comparison_mode
;
1209 BYTE bumpmat
; /* WINED3D_MAX_TEXTURES, 8 */
1210 BYTE luminanceparams
; /* WINED3D_MAX_TEXTURES, 8 */
1211 struct wined3d_shader_resource_info uav_resource_info
[MAX_UNORDERED_ACCESS_VIEWS
];
1212 DWORD uav_read_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1213 DWORD uav_counter_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1215 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1216 DWORD cull_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1221 DWORD usestexldd
: 1;
1223 DWORD usesfacing
: 1;
1224 DWORD usesrelconstF
: 1;
1226 DWORD usestexldl
: 1;
1230 DWORD point_size
: 1;
1232 DWORD input_rel_addressing
: 1;
1233 DWORD viewport_array
: 1;
1234 DWORD sample_mask
: 1;
1237 DWORD rt_mask
; /* Used render targets, 32 max. */
1239 /* Whether or not loops are used in this shader, and nesting depth */
1240 unsigned int loop_depth
;
1241 unsigned int min_rel_offset
, max_rel_offset
;
1243 struct wined3d_shader_tgsm
*tgsm
;
1244 SIZE_T tgsm_capacity
;
1245 unsigned int tgsm_count
;
1248 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1249 * state information between multiple instructions. */
1250 struct wined3d_shader_tex_mx
1252 unsigned int current_row
;
1253 unsigned int texcoord_w
[2];
1256 struct wined3d_shader_parser_state
1258 unsigned int current_loop_depth
;
1259 unsigned int current_loop_reg
;
1263 struct wined3d_shader_context
1265 const struct wined3d_shader
*shader
;
1266 const struct wined3d_shader_reg_maps
*reg_maps
;
1267 struct wined3d_string_buffer
*buffer
;
1268 struct wined3d_shader_tex_mx
*tex_mx
;
1269 struct wined3d_shader_parser_state
*state
;
1273 struct wined3d_shader_register_index
1275 const struct wined3d_shader_src_param
*rel_addr
;
1276 unsigned int offset
;
1279 struct wined3d_shader_register
1281 enum wined3d_shader_register_type type
;
1282 enum wined3d_data_type data_type
;
1283 struct wined3d_shader_register_index idx
[2];
1284 enum wined3d_immconst_type immconst_type
;
1287 unsigned int immconst_data
[4];
1288 unsigned fp_body_idx
;
1292 struct wined3d_shader_dst_param
1294 struct wined3d_shader_register reg
;
1295 uint32_t write_mask
;
1300 struct wined3d_shader_src_param
1302 struct wined3d_shader_register reg
;
1304 enum wined3d_shader_src_modifier modifiers
;
1307 struct wined3d_shader_index_range
1309 struct wined3d_shader_dst_param first_register
;
1310 unsigned int last_register
;
1313 struct wined3d_shader_semantic
1315 enum wined3d_decl_usage usage
;
1317 enum wined3d_shader_resource_type resource_type
;
1318 enum wined3d_data_type resource_data_type
;
1319 struct wined3d_shader_dst_param reg
;
1322 enum wined3d_shader_input_sysval_semantic
1324 WINED3D_SIV_POSITION
= 1,
1325 WINED3D_SIV_CLIP_DISTANCE
= 2,
1326 WINED3D_SIV_CULL_DISTANCE
= 3,
1327 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX
= 4,
1328 WINED3D_SIV_VIEWPORT_ARRAY_INDEX
= 5,
1329 WINED3D_SIV_VERTEX_ID
= 6,
1330 WINED3D_SIV_PRIMITIVE_ID
= 7,
1331 WINED3D_SIV_INSTANCE_ID
= 8,
1332 WINED3D_SIV_IS_FRONT_FACE
= 9,
1333 WINED3D_SIV_SAMPLE_INDEX
= 10,
1334 WINED3D_SIV_QUAD_U0_TESS_FACTOR
= 11,
1335 WINED3D_SIV_QUAD_V0_TESS_FACTOR
= 12,
1336 WINED3D_SIV_QUAD_U1_TESS_FACTOR
= 13,
1337 WINED3D_SIV_QUAD_V1_TESS_FACTOR
= 14,
1338 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR
= 15,
1339 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR
= 16,
1340 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR
= 17,
1341 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR
= 18,
1342 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR
= 19,
1343 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR
= 20,
1344 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR
= 21,
1345 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR
= 22,
1348 struct wined3d_shader_register_semantic
1350 struct wined3d_shader_dst_param reg
;
1351 enum wined3d_shader_input_sysval_semantic sysval_semantic
;
1354 struct wined3d_shader_structured_resource
1356 struct wined3d_shader_dst_param reg
;
1357 unsigned int byte_stride
;
1360 struct wined3d_shader_tgsm
1363 unsigned int stride
;
1366 struct wined3d_shader_tgsm_raw
1368 struct wined3d_shader_dst_param reg
;
1369 unsigned int byte_count
;
1372 struct wined3d_shader_tgsm_structured
1374 struct wined3d_shader_dst_param reg
;
1375 unsigned int byte_stride
;
1376 unsigned int structure_count
;
1379 struct wined3d_shader_thread_group_size
1381 unsigned int x
, y
, z
;
1384 struct wined3d_shader_function_table_pointer
1387 unsigned int array_size
;
1388 unsigned int body_count
;
1389 unsigned int table_count
;
1392 struct wined3d_shader_texel_offset
1394 signed char u
, v
, w
;
1397 struct wined3d_shader_primitive_type
1399 enum wined3d_primitive_type type
;
1400 unsigned int patch_vertex_count
;
1403 struct wined3d_shader_instruction
1405 const struct wined3d_shader_context
*ctx
;
1406 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
1408 unsigned int dst_count
;
1409 unsigned int src_count
;
1410 const struct wined3d_shader_dst_param
*dst
;
1411 const struct wined3d_shader_src_param
*src
;
1412 struct wined3d_shader_texel_offset texel_offset
;
1413 enum wined3d_shader_resource_type resource_type
;
1414 enum wined3d_data_type resource_data_type
;
1416 const struct wined3d_shader_src_param
*predicate
;
1419 struct wined3d_shader_semantic semantic
;
1420 struct wined3d_shader_register_semantic register_semantic
;
1421 struct wined3d_shader_primitive_type primitive_type
;
1422 struct wined3d_shader_dst_param dst
;
1423 struct wined3d_shader_src_param src
;
1426 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1427 struct wined3d_shader_structured_resource structured_resource
;
1428 struct wined3d_shader_tgsm_raw tgsm_raw
;
1429 struct wined3d_shader_tgsm_structured tgsm_structured
;
1430 struct wined3d_shader_thread_group_size thread_group_size
;
1431 enum wined3d_tessellator_domain tessellator_domain
;
1432 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1433 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1434 float max_tessellation_factor
;
1435 struct wined3d_shader_index_range index_range
;
1436 struct wined3d_shader_indexable_temp indexable_temp
;
1437 struct wined3d_shader_function_table_pointer fp
;
1441 static inline BOOL
wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction
*ins
)
1443 return ins
->texel_offset
.u
|| ins
->texel_offset
.v
|| ins
->texel_offset
.w
;
1446 struct wined3d_shader_attribute
1448 enum wined3d_decl_usage usage
;
1452 struct wined3d_shader_loop_control
1459 struct wined3d_shader_frontend
1461 void *(*shader_init
)(const DWORD
*byte_code
, size_t byte_code_size
,
1462 const struct wined3d_shader_signature
*output_signature
);
1463 void (*shader_free
)(void *data
);
1464 void (*shader_read_header
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
);
1465 void (*shader_read_instruction
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
);
1466 BOOL (*shader_is_end
)(void *data
, const DWORD
**ptr
);
1469 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN
;
1470 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN
;
1472 HRESULT
shader_extract_from_dxbc(struct wined3d_shader
*shader
,
1473 unsigned int max_shader_version
, enum wined3d_shader_byte_code_format
*format
) DECLSPEC_HIDDEN
;
1474 BOOL
shader_get_stream_output_register_info(const struct wined3d_shader
*shader
,
1475 const struct wined3d_stream_output_element
*so_element
, unsigned int *register_idx
,
1476 unsigned int *component_idx
) DECLSPEC_HIDDEN
;
1478 typedef void (*SHADER_HANDLER
)(const struct wined3d_shader_instruction
*);
1480 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1481 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1482 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1483 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1484 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1488 unsigned int vs_version
;
1489 unsigned int hs_version
;
1490 unsigned int ds_version
;
1491 unsigned int gs_version
;
1492 unsigned int ps_version
;
1493 unsigned int cs_version
;
1495 unsigned int vs_uniform_count
;
1496 unsigned int ps_uniform_count
;
1497 float ps_1x_max_value
;
1498 unsigned int varying_count
;
1503 enum wined3d_gl_resource_type
1505 WINED3D_GL_RES_TYPE_TEX_1D
= 0,
1506 WINED3D_GL_RES_TYPE_TEX_2D
= 1,
1507 WINED3D_GL_RES_TYPE_TEX_3D
= 2,
1508 WINED3D_GL_RES_TYPE_TEX_CUBE
= 3,
1509 WINED3D_GL_RES_TYPE_TEX_RECT
= 4,
1510 WINED3D_GL_RES_TYPE_BUFFER
= 5,
1511 WINED3D_GL_RES_TYPE_RB
= 6,
1512 WINED3D_GL_RES_TYPE_COUNT
= 7,
1515 enum wined3d_vertex_processing_mode
1518 WINED3D_VP_MODE_SHADER
,
1519 WINED3D_VP_MODE_NONE
,
1522 #define WINED3D_CONST_NUM_UNUSED ~0U
1524 enum wined3d_ffp_ps_fog_mode
1526 WINED3D_FFP_PS_FOG_OFF
,
1527 WINED3D_FFP_PS_FOG_LINEAR
,
1528 WINED3D_FFP_PS_FOG_EXP
,
1529 WINED3D_FFP_PS_FOG_EXP2
,
1532 /* Stateblock dependent parameters which have to be hardcoded
1533 * into the shader code
1536 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1537 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1538 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1539 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1540 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1542 /* Used for Shader Model 1 pixel shaders to track the bound texture
1543 * type. 2D and RECT textures are separated through NP2 fixup. */
1544 enum wined3d_shader_tex_types
1546 WINED3D_SHADER_TEX_2D
= 0,
1547 WINED3D_SHADER_TEX_3D
= 1,
1548 WINED3D_SHADER_TEX_CUBE
= 2,
1549 WINED3D_SHADER_TEX_ERR
= 3,
1552 struct ps_compile_args
1554 struct color_fixup_desc color_fixup
[WINED3D_MAX_FRAGMENT_SAMPLERS
];
1555 enum wined3d_vertex_processing_mode vp_mode
;
1556 enum wined3d_ffp_ps_fog_mode fog
;
1557 DWORD tex_types
; /* ps 1 - 3, 16 textures */
1558 WORD tex_transform
; /* ps 1.0-1.3, 4 textures */
1559 WORD srgb_correction
;
1560 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1561 D3D9 has a limit of 16 samplers and the fixup is superfluous
1562 in D3D10 (unconditional NP2 support mandatory). */
1564 WORD shadow
; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1565 WORD texcoords_initialized
; /* WINED3D_MAX_TEXTURES, 8 */
1566 WORD padding_to_dword
;
1567 DWORD pointsprite
: 1;
1568 DWORD flatshading
: 1;
1569 DWORD alpha_test_func
: 3;
1570 DWORD y_correction
: 1;
1571 DWORD rt_alpha_swizzle
: 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1572 DWORD dual_source_blend
: 1;
1582 struct vs_compile_args
1584 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1585 unsigned int next_shader_input_count
;
1586 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1588 BYTE clip_enabled
: 1;
1589 BYTE point_size
: 1;
1590 BYTE per_vertex_point_size
: 1;
1591 BYTE flatshading
: 1;
1592 BYTE next_shader_type
: 3;
1596 struct ds_compile_args
1598 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1599 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1600 unsigned int output_count
: 16;
1601 unsigned int next_shader_type
: 3;
1602 unsigned int render_offscreen
: 1;
1603 unsigned int padding
: 12;
1604 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1607 struct gs_compile_args
1609 unsigned int output_count
;
1610 enum wined3d_primitive_type primitive_type
;
1611 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1614 struct wined3d_shader_backend_ops
1616 void (*shader_handle_instruction
)(const struct wined3d_shader_instruction
*);
1617 void (*shader_precompile
)(void *shader_priv
, struct wined3d_shader
*shader
);
1618 void (*shader_select
)(void *shader_priv
, struct wined3d_context
*context
,
1619 const struct wined3d_state
*state
);
1620 void (*shader_select_compute
)(void *shader_priv
, struct wined3d_context
*context
,
1621 const struct wined3d_state
*state
);
1622 void (*shader_disable
)(void *shader_priv
, struct wined3d_context
*context
);
1623 void (*shader_update_float_vertex_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1624 void (*shader_update_float_pixel_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1625 void (*shader_load_constants
)(void *shader_priv
, struct wined3d_context
*context
,
1626 const struct wined3d_state
*state
);
1627 void (*shader_destroy
)(struct wined3d_shader
*shader
);
1628 HRESULT (*shader_alloc_private
)(struct wined3d_device
*device
, const struct wined3d_vertex_pipe_ops
*vertex_pipe
,
1629 const struct wined3d_fragment_pipe_ops
*fragment_pipe
);
1630 void (*shader_free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
1631 BOOL (*shader_allocate_context_data
)(struct wined3d_context
*context
);
1632 void (*shader_free_context_data
)(struct wined3d_context
*context
);
1633 void (*shader_init_context_state
)(struct wined3d_context
*context
);
1634 void (*shader_get_caps
)(const struct wined3d_adapter
*adapter
, struct shader_caps
*caps
);
1635 BOOL (*shader_color_fixup_supported
)(struct color_fixup_desc fixup
);
1636 BOOL (*shader_has_ffp_proj_control
)(void *shader_priv
);
1637 uint64_t (*shader_compile
)(struct wined3d_context
*context
, const struct wined3d_shader_desc
*shader_desc
,
1638 enum wined3d_shader_type shader_type
);
1641 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN
;
1642 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN
;
1643 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN
;
1645 const struct wined3d_shader_backend_ops
*wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN
;
1647 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1649 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1650 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1651 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1652 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1654 static inline void wined3d_color_from_d3dcolor(struct wined3d_color
*wined3d_color
, DWORD d3d_color
)
1656 wined3d_color
->r
= D3DCOLOR_B_R(d3d_color
) / 255.0f
;
1657 wined3d_color
->g
= D3DCOLOR_B_G(d3d_color
) / 255.0f
;
1658 wined3d_color
->b
= D3DCOLOR_B_B(d3d_color
) / 255.0f
;
1659 wined3d_color
->a
= D3DCOLOR_B_A(d3d_color
) / 255.0f
;
1662 extern const struct wined3d_vec4 wined3d_srgb_const
[] DECLSPEC_HIDDEN
;
1664 static inline float wined3d_srgb_from_linear(float colour
)
1668 if (colour
< wined3d_srgb_const
[1].x
)
1669 return colour
* wined3d_srgb_const
[0].w
;
1671 return wined3d_srgb_const
[0].y
* powf(colour
, wined3d_srgb_const
[0].x
) - wined3d_srgb_const
[0].z
;
1675 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color
*colour_srgb
,
1676 const struct wined3d_color
*colour
)
1678 colour_srgb
->r
= wined3d_srgb_from_linear(colour
->r
);
1679 colour_srgb
->g
= wined3d_srgb_from_linear(colour
->g
);
1680 colour_srgb
->b
= wined3d_srgb_from_linear(colour
->b
);
1681 colour_srgb
->a
= colour
->a
;
1684 void wined3d_check_gl_call(const struct wined3d_gl_info
*gl_info
,
1685 const char *file
, unsigned int line
, const char *name
) DECLSPEC_HIDDEN
;
1687 /* Checking of API calls */
1688 /* --------------------- */
1689 #ifndef WINE_NO_DEBUG_MSGS
1690 #define checkGLcall(A) \
1692 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1693 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1694 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1697 #define checkGLcall(A) do {} while(0)
1702 /* client_map_count and map_ptr are accessed from both the client and CS
1703 * threads, and protected by wined3d_device.bo_map_lock. */
1706 size_t buffer_offset
;
1707 size_t memory_offset
;
1708 unsigned int client_map_count
;
1712 struct wined3d_bo_gl
1714 struct wined3d_bo b
;
1718 struct wined3d_allocator_block
*memory
;
1725 uint64_t command_fence_id
;
1728 static inline struct wined3d_bo_gl
*wined3d_bo_gl(struct wined3d_bo
*bo
)
1730 return CONTAINING_RECORD(bo
, struct wined3d_bo_gl
, b
);
1733 static inline GLuint
wined3d_bo_gl_id(struct wined3d_bo
*bo
)
1735 return bo
? wined3d_bo_gl(bo
)->id
: 0;
1738 struct wined3d_bo_user
1744 struct wined3d_bo_vk
1746 struct wined3d_bo b
;
1749 struct wined3d_allocator_block
*memory
;
1750 struct wined3d_bo_slab_vk
*slab
;
1752 VkDeviceMemory vk_memory
;
1755 VkBufferUsageFlags usage
;
1756 VkMemoryPropertyFlags memory_type
;
1758 uint64_t command_buffer_id
;
1762 static inline struct wined3d_bo_vk
*wined3d_bo_vk(struct wined3d_bo
*bo
)
1764 return CONTAINING_RECORD(bo
, struct wined3d_bo_vk
, b
);
1767 struct wined3d_bo_slab_vk_key
1769 VkMemoryPropertyFlags memory_type
;
1770 VkBufferUsageFlags usage
;
1774 struct wined3d_bo_slab_vk
1776 struct wine_rb_entry entry
;
1777 struct wined3d_bo_slab_vk
*next
;
1778 VkMemoryPropertyFlags requested_memory_type
;
1779 struct wined3d_bo_vk bo
;
1780 unsigned int map_count
;
1785 void *wined3d_bo_slab_vk_map(struct wined3d_bo_slab_vk
*slab_vk
,
1786 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
1787 void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk
*slab_vk
,
1788 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
1790 struct wined3d_bo_address
1792 struct wined3d_bo
*buffer_object
;
1796 struct wined3d_const_bo_address
1798 struct wined3d_bo
*buffer_object
;
1802 static inline struct wined3d_const_bo_address
*wined3d_const_bo_address(const struct wined3d_bo_address
*data
)
1804 return (struct wined3d_const_bo_address
*)data
;
1807 struct wined3d_image_vk
1810 struct wined3d_allocator_block
*memory
;
1811 VkDeviceMemory vk_memory
;
1812 uint64_t command_buffer_id
;
1815 struct wined3d_stream_info_element
1817 const struct wined3d_format
*format
;
1818 struct wined3d_bo_address data
;
1820 unsigned int stream_idx
;
1821 unsigned int divisor
;
1825 struct wined3d_stream_info
1827 struct wined3d_stream_info_element elements
[MAX_ATTRIBS
];
1828 DWORD position_transformed
: 1;
1830 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1831 DWORD use_map
; /* MAX_ATTRIBS, 32 */
1834 void wined3d_stream_info_from_declaration(struct wined3d_stream_info
*stream_info
,
1835 const struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
) DECLSPEC_HIDDEN
;
1837 struct wined3d_direct_dispatch_parameters
1839 unsigned int group_count_x
;
1840 unsigned int group_count_y
;
1841 unsigned int group_count_z
;
1844 struct wined3d_indirect_dispatch_parameters
1846 struct wined3d_buffer
*buffer
;
1847 unsigned int offset
;
1850 struct wined3d_dispatch_parameters
1855 struct wined3d_direct_dispatch_parameters direct
;
1856 struct wined3d_indirect_dispatch_parameters indirect
;
1860 struct wined3d_direct_draw_parameters
1862 int base_vertex_idx
;
1863 unsigned int start_idx
;
1864 unsigned int index_count
;
1865 unsigned int start_instance
;
1866 unsigned int instance_count
;
1869 struct wined3d_indirect_draw_parameters
1871 struct wined3d_buffer
*buffer
;
1872 unsigned int offset
;
1875 struct wined3d_draw_parameters
1880 struct wined3d_direct_draw_parameters direct
;
1881 struct wined3d_indirect_draw_parameters indirect
;
1886 void draw_primitive(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1887 const struct wined3d_draw_parameters
*draw_parameters
) DECLSPEC_HIDDEN
;
1888 void dispatch_compute(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1889 const struct wined3d_dispatch_parameters
*dispatch_parameters
) DECLSPEC_HIDDEN
;
1893 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1894 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1896 /* Routines and structures related to state management */
1898 #define STATE_RENDER(a) (a)
1899 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1901 #define STATE_TEXTURESTAGE(stage, num) \
1902 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1903 #define STATE_IS_TEXTURESTAGE(a) \
1904 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1906 /* + 1 because samplers start with 0 */
1907 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1908 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1910 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1911 #define STATE_IS_GRAPHICS_SHADER(a) \
1912 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1914 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1915 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1916 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1917 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1919 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1920 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1922 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1923 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1925 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1926 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1928 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1929 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1930 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1931 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1933 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1934 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1936 #define STATE_VIEWPORT (STATE_VDECL + 1)
1937 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1939 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1940 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1941 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1942 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1944 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1945 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1947 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1948 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1950 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1951 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1953 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1954 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1956 #define STATE_DEPTH_BOUNDS (STATE_RASTERIZER + 1)
1957 #define STATE_IS_DEPTH_BOUNDS(a) ((a) == STATE_DEPTH_BOUNDS)
1959 #define STATE_POINTSPRITECOORDORIGIN (STATE_DEPTH_BOUNDS + 1)
1960 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1962 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1963 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1965 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1966 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1968 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1969 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1971 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1972 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1974 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1975 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1977 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1978 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1980 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1981 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1983 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1984 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1986 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1987 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1989 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1990 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1992 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1994 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1995 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1997 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1998 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
2000 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
2001 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
2003 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
2004 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
2006 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
2007 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
2009 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
2010 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
2012 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
2013 #define STATE_CONSTANT_BUFFER(a) \
2014 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
2015 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
2016 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
2024 union wined3d_gl_fence_object
2030 enum wined3d_fence_result
2033 WINED3D_FENCE_WAITING
,
2034 WINED3D_FENCE_NOT_STARTED
,
2035 WINED3D_FENCE_WRONG_THREAD
,
2036 WINED3D_FENCE_ERROR
,
2039 struct wined3d_fence
2042 union wined3d_gl_fence_object object
;
2043 struct wined3d_context_gl
*context_gl
;
2046 HRESULT
wined3d_fence_create(struct wined3d_device
*device
, struct wined3d_fence
**fence
) DECLSPEC_HIDDEN
;
2047 void wined3d_fence_destroy(struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2048 void wined3d_fence_issue(struct wined3d_fence
*fence
, struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2049 enum wined3d_fence_result
wined3d_fence_wait(const struct wined3d_fence
*fence
,
2050 struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2051 enum wined3d_fence_result
wined3d_fence_test(const struct wined3d_fence
*fence
,
2052 struct wined3d_device
*device
, uint32_t flags
) DECLSPEC_HIDDEN
;
2054 /* Direct3D terminology with little modifications. We do not have an issued
2055 * state because only the driver knows about it, but we have a created state
2056 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
2057 enum wined3d_query_state
2064 struct wined3d_query_ops
2066 BOOL (*query_poll
)(struct wined3d_query
*query
, uint32_t flags
);
2067 BOOL (*query_issue
)(struct wined3d_query
*query
, uint32_t flags
);
2068 void (*query_destroy
)(struct wined3d_query
*query
);
2071 struct wined3d_query
2076 const struct wined3d_parent_ops
*parent_ops
;
2077 struct wined3d_device
*device
;
2078 enum wined3d_query_state state
;
2079 enum wined3d_query_type type
;
2082 const struct wined3d_query_ops
*query_ops
;
2084 LONG counter_main
, counter_retrieved
;
2085 struct list poll_list_entry
;
2087 GLuint buffer_object
;
2092 HRESULT
wined3d_query_gl_create(struct wined3d_device
*device
, enum wined3d_query_type type
, void *parent
,
2093 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
) DECLSPEC_HIDDEN
;
2094 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl
*context_gl
,
2095 struct wined3d_query
*query
) DECLSPEC_HIDDEN
;
2097 struct wined3d_event_query
2099 struct wined3d_query query
;
2101 struct wined3d_fence fence
;
2105 struct wined3d_occlusion_query
2107 struct wined3d_query query
;
2111 struct wined3d_context_gl
*context_gl
;
2116 struct wined3d_timestamp_query
2118 struct wined3d_query query
;
2122 struct wined3d_context_gl
*context_gl
;
2126 union wined3d_gl_so_statistics_query
2136 struct wined3d_so_statistics_query
2138 struct wined3d_query query
;
2141 union wined3d_gl_so_statistics_query u
;
2142 struct wined3d_context_gl
*context_gl
;
2143 unsigned int stream_idx
;
2144 struct wined3d_query_data_so_statistics statistics
;
2148 union wined3d_gl_pipeline_statistics_query
2155 GLuint vertex_shader
;
2156 GLuint tess_control_shader
;
2157 GLuint tess_eval_shader
;
2158 GLuint geometry_shader
;
2159 GLuint geometry_primitives
;
2160 GLuint fragment_shader
;
2161 GLuint compute_shader
;
2162 GLuint clipping_input
;
2163 GLuint clipping_output
;
2167 struct wined3d_pipeline_statistics_query
2169 struct wined3d_query query
;
2172 union wined3d_gl_pipeline_statistics_query u
;
2173 struct wined3d_context_gl
*context_gl
;
2174 struct wined3d_query_data_pipeline_statistics statistics
;
2178 #define WINED3D_QUERY_POOL_SIZE 256
2180 struct wined3d_query_pool_vk
2183 struct list completed_entry
;
2185 struct list
*free_list
;
2186 VkQueryPool vk_query_pool
;
2189 uint32_t allocated
[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE
)];
2190 uint32_t completed
[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE
)];
2193 bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk
*pool_vk
, size_t *idx
) DECLSPEC_HIDDEN
;
2194 void wined3d_query_pool_vk_mark_free(struct wined3d_context_vk
*context_vk
, struct wined3d_query_pool_vk
*pool_vk
,
2195 uint32_t start
, uint32_t count
) DECLSPEC_HIDDEN
;
2196 void wined3d_query_pool_vk_cleanup(struct wined3d_query_pool_vk
*pool_vk
,
2197 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
2198 bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk
*pool_vk
, struct wined3d_context_vk
*context_vk
,
2199 enum wined3d_query_type type
, struct list
*free_pools
) DECLSPEC_HIDDEN
;
2201 struct wined3d_query_pool_idx_vk
2203 struct wined3d_query_pool_vk
*pool_vk
;
2207 #define WINED3D_QUERY_VK_FLAG_ACTIVE 0x00000001
2208 #define WINED3D_QUERY_VK_FLAG_STARTED 0x00000002
2209 #define WINED3D_QUERY_VK_FLAG_RENDER_PASS 0x00000004
2211 struct wined3d_query_vk
2213 struct wined3d_query q
;
2216 struct wined3d_query_pool_idx_vk pool_idx
;
2218 uint64_t command_buffer_id
;
2219 uint32_t control_flags
;
2221 SIZE_T pending_count
, pending_size
;
2222 struct wined3d_query_pool_idx_vk
*pending
;
2225 static inline struct wined3d_query_vk
*wined3d_query_vk(struct wined3d_query
*query
)
2227 return CONTAINING_RECORD(query
, struct wined3d_query_vk
, q
);
2230 struct wined3d_device_vk
;
2232 bool wined3d_query_vk_accumulate_data(struct wined3d_query_vk
*query_vk
, struct wined3d_device_vk
*device_vk
,
2233 const struct wined3d_query_pool_idx_vk
*pool_idx
) DECLSPEC_HIDDEN
;
2234 HRESULT
wined3d_query_vk_create(struct wined3d_device
*device
, enum wined3d_query_type type
, void *parent
,
2235 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
) DECLSPEC_HIDDEN
;
2236 void wined3d_query_vk_resume(struct wined3d_query_vk
*query_vk
, struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
2237 void wined3d_query_vk_suspend(struct wined3d_query_vk
*query_vk
, struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
2239 struct wined3d_gl_view
2245 struct wined3d_range
2247 unsigned int offset
;
2251 struct wined3d_rendertarget_info
2253 struct wined3d_gl_view gl_view
;
2254 struct wined3d_resource
*resource
;
2255 unsigned int sub_resource_idx
;
2256 unsigned int layer_count
;
2259 struct wined3d_fb_state
2261 struct wined3d_rendertarget_view
*render_targets
[WINED3D_MAX_RENDER_TARGETS
];
2262 struct wined3d_rendertarget_view
*depth_stencil
;
2265 #define MAX_GL_FRAGMENT_SAMPLERS 32
2267 struct wined3d_context
2269 const struct wined3d_d3d_info
*d3d_info
;
2270 const struct wined3d_state_entry
*state_table
;
2271 uint32_t dirty_graphics_states
[WINED3D_BITMAP_SIZE(STATE_HIGHEST
)];
2272 uint32_t dirty_compute_states
[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT
)];
2274 struct wined3d_device
*device
;
2275 struct wined3d_swapchain
*swapchain
;
2278 struct wined3d_texture
*texture
;
2279 unsigned int sub_resource_idx
;
2282 /* Stores some information about the context state for optimization */
2283 DWORD last_swizzle_map
; /* MAX_ATTRIBS, 32 */
2285 DWORD shader_update_mask
: 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
2286 DWORD update_shader_resource_bindings
: 1;
2287 DWORD update_compute_shader_resource_bindings
: 1;
2288 DWORD update_unordered_access_view_bindings
: 1;
2289 DWORD update_compute_unordered_access_view_bindings
: 1;
2290 DWORD last_was_rhw
: 1; /* True iff last draw_primitive was in xyzrhw mode. */
2291 DWORD last_was_pshader
: 1;
2292 DWORD last_was_vshader
: 1;
2293 DWORD last_was_diffuse
: 1;
2294 DWORD last_was_specular
: 1;
2295 DWORD last_was_normal
: 1;
2296 DWORD last_was_ffp_blit
: 1;
2297 DWORD last_was_blit
: 1;
2298 DWORD last_was_ckey
: 1;
2299 DWORD last_was_dual_source_blend
: 1;
2300 DWORD texShaderBumpMap
: 8; /* WINED3D_MAX_TEXTURES, 8 */
2301 DWORD lowest_disabled_stage
: 4; /* Max WINED3D_MAX_TEXTURES, 8 */
2303 DWORD lastWasPow2Texture
: 8; /* WINED3D_MAX_TEXTURES, 8 */
2304 DWORD fixed_function_usage_map
: 8; /* WINED3D_MAX_TEXTURES, 8 */
2305 DWORD use_immediate_mode_draw
: 1;
2306 DWORD uses_uavs
: 1;
2307 DWORD uses_fbo_attached_resources
: 1;
2308 DWORD transform_feedback_active
: 1;
2309 DWORD transform_feedback_paused
: 1;
2310 DWORD fog_coord
: 1;
2311 DWORD render_offscreen
: 1;
2313 DWORD destroyed
: 1;
2314 DWORD destroy_delayed
: 1;
2315 DWORD namedArraysLoaded
: 1;
2318 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
2320 DWORD constant_update_mask
;
2321 DWORD numbered_array_mask
;
2322 enum fogsource fog_source
;
2325 void *shader_backend_data
;
2326 void *fragment_pipe_data
;
2328 struct wined3d_stream_info stream_info
;
2330 unsigned int viewport_count
;
2331 unsigned int scissor_rect_count
;
2334 void wined3d_context_cleanup(struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
2335 void wined3d_context_init(struct wined3d_context
*context
, struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
2336 void context_preload_textures(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2337 void context_update_stream_info(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2339 HRESULT
wined3d_context_no3d_init(struct wined3d_context
*context_no3d
,
2340 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
2342 struct wined3d_command_fence_gl
2345 struct wined3d_fence
*fence
;
2348 struct wined3d_context_gl
2350 struct wined3d_context c
;
2352 const struct wined3d_gl_info
*gl_info
;
2354 DWORD tid
; /* Thread ID which owns this context at the moment. */
2356 uint32_t dc_is_private
: 1;
2357 uint32_t dc_has_format
: 1; /* Only meaningful for private DCs. */
2358 uint32_t fog_enabled
: 1;
2359 uint32_t diffuse_attrib_to_1
: 1;
2360 uint32_t rebind_fbo
: 1;
2361 uint32_t untracked_material_count
: 2; /* Max value 2 */
2362 uint32_t needs_set
: 1;
2363 uint32_t internal_format_set
: 1;
2365 uint32_t padding
: 22;
2367 uint32_t default_attrib_value_set
;
2369 GLenum tracking_parm
; /* Which source is tracking current colour. */
2370 GLenum untracked_materials
[2];
2372 unsigned int active_texture
;
2374 GLenum
*texture_type
;
2376 /* The WGL context. */
2381 HWND restore_pf_win
;
2389 unsigned int fbo_entry_count
;
2390 struct list fbo_list
;
2391 struct list fbo_destroy_list
;
2392 struct fbo_entry
*current_fbo
;
2393 GLuint fbo_read_binding
;
2394 GLuint fbo_draw_binding
;
2395 struct wined3d_rendertarget_info blit_targets
[WINED3D_MAX_RENDER_TARGETS
];
2396 uint32_t draw_buffers_mask
; /* Enabled draw buffers, 31 max. */
2399 struct list occlusion_queries
;
2401 struct list timestamp_queries
;
2402 struct list so_statistics_queries
;
2403 struct list pipeline_statistics_queries
;
2405 GLuint
*free_occlusion_queries
;
2406 SIZE_T free_occlusion_query_size
;
2407 unsigned int free_occlusion_query_count
;
2409 union wined3d_gl_fence_object
*free_fences
;
2410 SIZE_T free_fence_size
;
2411 unsigned int free_fence_count
;
2413 GLuint
*free_timestamp_queries
;
2414 SIZE_T free_timestamp_query_size
;
2415 unsigned int free_timestamp_query_count
;
2417 union wined3d_gl_so_statistics_query
*free_so_statistics_queries
;
2418 SIZE_T free_so_statistics_query_size
;
2419 unsigned int free_so_statistics_query_count
;
2421 union wined3d_gl_pipeline_statistics_query
*free_pipeline_statistics_queries
;
2422 SIZE_T free_pipeline_statistics_query_size
;
2423 unsigned int free_pipeline_statistics_query_count
;
2427 unsigned int tex_unit_map
[WINED3D_MAX_COMBINED_SAMPLERS
];
2428 unsigned int rev_tex_unit_map
[MAX_GL_FRAGMENT_SAMPLERS
+ WINED3D_MAX_VERTEX_SAMPLERS
];
2430 /* Extension emulation. */
2431 GLint gl_fog_source
;
2432 GLfloat fog_coord_value
;
2433 GLfloat colour
[4], fog_start
, fog_end
, fog_colour
[4];
2435 GLuint dummy_arbfp_prog
;
2439 struct wined3d_command_fence_gl
*fences
;
2445 static inline struct wined3d_context_gl
*wined3d_context_gl(struct wined3d_context
*context
)
2447 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
2450 static inline const struct wined3d_context_gl
*wined3d_context_gl_const(const struct wined3d_context
*context
)
2452 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
2455 struct wined3d_context
*wined3d_context_gl_acquire(const struct wined3d_device
*device
,
2456 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2457 void wined3d_context_gl_active_texture(struct wined3d_context_gl
*context_gl
,
2458 const struct wined3d_gl_info
*gl_info
, unsigned int unit
) DECLSPEC_HIDDEN
;
2459 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl
*context_gl
,
2460 struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2461 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl
*context_gl
,
2462 struct wined3d_occlusion_query
*query
) DECLSPEC_HIDDEN
;
2463 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl
*context_gl
,
2464 struct wined3d_pipeline_statistics_query
*query
) DECLSPEC_HIDDEN
;
2465 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl
*context_gl
,
2466 struct wined3d_so_statistics_query
*query
) DECLSPEC_HIDDEN
;
2467 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl
*context_gl
,
2468 struct wined3d_timestamp_query
*query
) DECLSPEC_HIDDEN
;
2469 GLuint
wined3d_context_gl_allocate_vram_chunk_buffer(struct wined3d_context_gl
*context_gl
,
2470 unsigned int pool
, size_t size
) DECLSPEC_HIDDEN
;
2471 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl
*context_gl
,
2472 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2473 BOOL
wined3d_context_gl_apply_clear_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
,
2474 unsigned int rt_count
, const struct wined3d_fb_state
*fb
) DECLSPEC_HIDDEN
;
2475 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl
*context_gl
, GLenum target
,
2476 struct wined3d_resource
*rt
, unsigned int rt_sub_resource_idx
,
2477 struct wined3d_resource
*ds
, unsigned int ds_sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
2478 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl
*context_gl
,
2479 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2480 void wined3d_context_gl_bind_bo(struct wined3d_context_gl
*context_gl
, GLenum binding
, GLuint name
) DECLSPEC_HIDDEN
;
2481 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2482 void wined3d_context_gl_bind_texture(struct wined3d_context_gl
*context_gl
,
2483 GLenum target
, GLuint name
) DECLSPEC_HIDDEN
;
2484 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl
*context_gl
, GLenum target
) DECLSPEC_HIDDEN
;
2485 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl
*context_gl
,
2486 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
2487 unsigned int range_count
, const struct wined3d_range
*ranges
) DECLSPEC_HIDDEN
;
2488 void wined3d_context_gl_destroy(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2489 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo
) DECLSPEC_HIDDEN
;
2490 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl
*context_gl
, struct wined3d_texture_gl
*texture_gl
,
2491 unsigned int sub_resource_idx
, const RECT
*src_rect
, const RECT
*dst_rect
,
2492 enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
2493 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl
*context_gl
,
2494 struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
2495 const RECT
*src_rect
, const RECT
*dst_rect
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
2496 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl
*context_gl
, uint32_t mask
) DECLSPEC_HIDDEN
;
2497 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2498 void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl
*context_gl
,
2499 const struct wined3d_const_bo_address
*data
, size_t size
) DECLSPEC_HIDDEN
;
2500 void wined3d_context_gl_free_fence(struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2501 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query
*query
) DECLSPEC_HIDDEN
;
2502 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query
*query
) DECLSPEC_HIDDEN
;
2503 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query
*query
) DECLSPEC_HIDDEN
;
2504 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query
*query
) DECLSPEC_HIDDEN
;
2505 struct wined3d_context_gl
*wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN
;
2506 GLenum
wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2507 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl
*context_gl
,
2508 const struct wined3d_shader_version
*shader_version
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
2509 HRESULT
wined3d_context_gl_init(struct wined3d_context_gl
*context_gl
,
2510 struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
2511 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl
*context_gl
,
2512 const struct wined3d_stream_info
*si
, GLuint
*current_bo
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2513 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl
*context_gl
,
2514 const struct wined3d_bo_address
*data
, size_t size
, uint32_t flags
) DECLSPEC_HIDDEN
;
2515 struct wined3d_context_gl
*wined3d_context_gl_reacquire(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2516 void wined3d_context_gl_release(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2517 BOOL
wined3d_context_gl_set_current(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2518 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2519 void wined3d_context_gl_texture_update(struct wined3d_context_gl
*context_gl
,
2520 const struct wined3d_texture_gl
*texture_gl
) DECLSPEC_HIDDEN
;
2521 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2522 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl
*context_gl
, const struct wined3d_bo_address
*data
,
2523 unsigned int range_count
, const struct wined3d_range
*ranges
) DECLSPEC_HIDDEN
;
2524 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl
*context_gl
,
2525 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2526 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl
*context_gl
, uint64_t id
) DECLSPEC_HIDDEN
;
2528 struct wined3d_command_buffer_vk
2531 VkCommandBuffer vk_command_buffer
;
2535 enum wined3d_retired_object_type_vk
2537 WINED3D_RETIRED_FREE_VK
,
2538 WINED3D_RETIRED_FRAMEBUFFER_VK
,
2539 WINED3D_RETIRED_DESCRIPTOR_POOL_VK
,
2540 WINED3D_RETIRED_MEMORY_VK
,
2541 WINED3D_RETIRED_ALLOCATOR_BLOCK_VK
,
2542 WINED3D_RETIRED_BO_SLAB_SLICE_VK
,
2543 WINED3D_RETIRED_BUFFER_VK
,
2544 WINED3D_RETIRED_IMAGE_VK
,
2545 WINED3D_RETIRED_BUFFER_VIEW_VK
,
2546 WINED3D_RETIRED_IMAGE_VIEW_VK
,
2547 WINED3D_RETIRED_SAMPLER_VK
,
2548 WINED3D_RETIRED_QUERY_POOL_VK
,
2549 WINED3D_RETIRED_EVENT_VK
,
2550 WINED3D_RETIRED_PIPELINE_VK
,
2553 struct wined3d_retired_object_vk
2555 enum wined3d_retired_object_type_vk type
;
2558 struct wined3d_retired_object_vk
*next
;
2559 VkFramebuffer vk_framebuffer
;
2560 VkDescriptorPool vk_descriptor_pool
;
2561 VkDeviceMemory vk_memory
;
2562 struct wined3d_allocator_block
*block
;
2565 struct wined3d_bo_slab_vk
*slab
;
2570 VkBufferView vk_buffer_view
;
2571 VkImageView vk_image_view
;
2572 VkSampler vk_sampler
;
2574 VkPipeline vk_pipeline
;
2577 struct wined3d_query_pool_vk
*pool_vk
;
2582 uint64_t command_buffer_id
;
2585 struct wined3d_retired_objects_vk
2587 struct wined3d_retired_object_vk
*objects
;
2588 struct wined3d_retired_object_vk
*free
;
2593 #define WINED3D_FB_ATTACHMENT_FLAG_DISCARDED 1
2594 #define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_C 2
2595 #define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_S 4
2596 #define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_Z 8
2598 struct wined3d_render_pass_attachment_vk
2601 VkSampleCountFlagBits vk_samples
;
2602 VkImageLayout vk_layout
;
2606 struct wined3d_render_pass_key_vk
2608 struct wined3d_render_pass_attachment_vk rt
[WINED3D_MAX_RENDER_TARGETS
];
2609 struct wined3d_render_pass_attachment_vk ds
;
2613 struct wined3d_render_pass_vk
2615 struct wine_rb_entry entry
;
2616 struct wined3d_render_pass_key_vk key
;
2617 VkRenderPass vk_render_pass
;
2620 struct wined3d_pipeline_layout_key_vk
2622 VkDescriptorSetLayoutBinding
*bindings
;
2623 SIZE_T binding_count
;
2626 struct wined3d_pipeline_layout_vk
2628 struct wine_rb_entry entry
;
2629 struct wined3d_pipeline_layout_key_vk key
;
2630 VkPipelineLayout vk_pipeline_layout
;
2631 VkDescriptorSetLayout vk_set_layout
;
2634 struct wined3d_graphics_pipeline_key_vk
2636 VkPipelineShaderStageCreateInfo stages
[WINED3D_SHADER_TYPE_GRAPHICS_COUNT
];
2637 VkVertexInputBindingDivisorDescriptionEXT divisors
[MAX_ATTRIBS
];
2638 VkVertexInputAttributeDescription attributes
[MAX_ATTRIBS
];
2639 VkVertexInputBindingDescription bindings
[MAX_ATTRIBS
];
2640 VkViewport viewports
[WINED3D_MAX_VIEWPORTS
];
2641 VkRect2D scissors
[WINED3D_MAX_VIEWPORTS
];
2642 VkSampleMask sample_mask
;
2643 VkPipelineColorBlendAttachmentState blend_attachments
[WINED3D_MAX_RENDER_TARGETS
];
2645 VkPipelineVertexInputDivisorStateCreateInfoEXT divisor_desc
;
2646 VkPipelineVertexInputStateCreateInfo input_desc
;
2647 VkPipelineInputAssemblyStateCreateInfo ia_desc
;
2648 VkPipelineTessellationStateCreateInfo ts_desc
;
2649 VkPipelineViewportStateCreateInfo vp_desc
;
2650 VkPipelineRasterizationStateCreateInfo rs_desc
;
2651 VkPipelineMultisampleStateCreateInfo ms_desc
;
2652 VkPipelineDepthStencilStateCreateInfo ds_desc
;
2653 VkPipelineColorBlendStateCreateInfo blend_desc
;
2654 VkPipelineDynamicStateCreateInfo dynamic_desc
;
2656 VkGraphicsPipelineCreateInfo pipeline_desc
;
2659 struct wined3d_graphics_pipeline_vk
2661 struct wine_rb_entry entry
;
2662 struct wined3d_graphics_pipeline_key_vk key
;
2663 VkPipeline vk_pipeline
;
2666 enum wined3d_shader_descriptor_type
2668 WINED3D_SHADER_DESCRIPTOR_TYPE_CBV
,
2669 WINED3D_SHADER_DESCRIPTOR_TYPE_SRV
,
2670 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV
,
2671 WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER
,
2672 WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER
,
2675 struct wined3d_shader_resource_binding
2677 enum wined3d_shader_type shader_type
;
2678 enum wined3d_shader_descriptor_type shader_descriptor_type
;
2679 size_t resource_idx
;
2680 enum wined3d_shader_resource_type resource_type
;
2681 enum wined3d_data_type resource_data_type
;
2685 struct wined3d_shader_resource_bindings
2687 struct wined3d_shader_resource_binding
*bindings
;
2691 struct wined3d_shader_descriptor_writes_vk
2693 VkWriteDescriptorSet
*writes
;
2697 struct wined3d_context_vk
2699 struct wined3d_context c
;
2701 const struct wined3d_vk_info
*vk_info
;
2703 uint32_t update_compute_pipeline
: 1;
2704 uint32_t update_stream_output
: 1;
2705 uint32_t padding
: 30;
2709 VkShaderModule vk_modules
[WINED3D_SHADER_TYPE_GRAPHICS_COUNT
];
2710 struct wined3d_graphics_pipeline_key_vk pipeline_key_vk
;
2711 VkPipeline vk_pipeline
;
2712 VkPipelineLayout vk_pipeline_layout
;
2713 VkDescriptorSetLayout vk_set_layout
;
2714 struct wined3d_shader_resource_bindings bindings
;
2719 VkPipeline vk_pipeline
;
2720 VkPipelineLayout vk_pipeline_layout
;
2721 VkDescriptorSetLayout vk_set_layout
;
2722 struct wined3d_shader_resource_bindings bindings
;
2725 VkCommandPool vk_command_pool
;
2726 struct wined3d_command_buffer_vk current_command_buffer
;
2727 uint64_t completed_command_buffer_id
;
2728 VkDeviceSize retired_bo_size
;
2732 struct wined3d_command_buffer_vk
*buffers
;
2733 SIZE_T buffers_size
;
2734 SIZE_T buffer_count
;
2737 struct wined3d_shader_descriptor_writes_vk descriptor_writes
;
2739 VkFramebuffer vk_framebuffer
;
2740 VkRenderPass vk_render_pass
;
2742 SIZE_T vk_descriptor_pools_size
;
2743 SIZE_T vk_descriptor_pool_count
;
2744 VkDescriptorPool
*vk_descriptor_pools
;
2746 VkSampleCountFlagBits sample_count
;
2747 unsigned int rt_count
;
2749 VkBuffer vk_so_counters
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
2750 VkDeviceSize vk_so_offsets
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
2751 struct wined3d_bo_vk vk_so_counter_bo
;
2753 struct list render_pass_queries
;
2754 struct list active_queries
;
2755 struct list completed_query_pools
;
2756 struct list free_occlusion_query_pools
;
2757 struct list free_timestamp_query_pools
;
2758 struct list free_pipeline_statistics_query_pools
;
2759 struct list free_stream_output_statistics_query_pools
;
2761 struct wined3d_retired_objects_vk retired
;
2762 struct wine_rb_tree render_passes
;
2763 struct wine_rb_tree pipeline_layouts
;
2764 struct wine_rb_tree graphics_pipelines
;
2765 struct wine_rb_tree bo_slab_available
;
2768 static inline struct wined3d_context_vk
*wined3d_context_vk(struct wined3d_context
*context
)
2770 return CONTAINING_RECORD(context
, struct wined3d_context_vk
, c
);
2773 bool wined3d_context_vk_allocate_query(struct wined3d_context_vk
*context_vk
,
2774 enum wined3d_query_type type
, struct wined3d_query_pool_idx_vk
*pool_idx
) DECLSPEC_HIDDEN
;
2775 VkDeviceMemory
wined3d_context_vk_allocate_vram_chunk_memory(struct wined3d_context_vk
*context_vk
,
2776 unsigned int pool
, size_t size
) DECLSPEC_HIDDEN
;
2777 VkCommandBuffer
wined3d_context_vk_apply_compute_state(struct wined3d_context_vk
*context_vk
,
2778 const struct wined3d_state
*state
, struct wined3d_buffer_vk
*indirect_vk
) DECLSPEC_HIDDEN
;
2779 VkCommandBuffer
wined3d_context_vk_apply_draw_state(struct wined3d_context_vk
*context_vk
,
2780 const struct wined3d_state
*state
, struct wined3d_buffer_vk
*indirect_vk
, bool indexed
) DECLSPEC_HIDDEN
;
2781 void wined3d_context_vk_cleanup(struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
2782 BOOL
wined3d_context_vk_create_bo(struct wined3d_context_vk
*context_vk
, VkDeviceSize size
,
2783 VkBufferUsageFlags usage
, VkMemoryPropertyFlags memory_type
, struct wined3d_bo_vk
*bo
) DECLSPEC_HIDDEN
;
2784 BOOL
wined3d_context_vk_create_image(struct wined3d_context_vk
*context_vk
, VkImageType vk_image_type
,
2785 VkImageUsageFlags usage
, VkFormat vk_format
, unsigned int width
, unsigned int height
, unsigned int depth
,
2786 unsigned int sample_count
, unsigned int mip_levels
, unsigned int layer_count
, unsigned int flags
,
2787 struct wined3d_image_vk
*image
) DECLSPEC_HIDDEN
;
2788 void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk
*context_vk
,
2789 struct wined3d_allocator_block
*block
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2790 void wined3d_context_vk_destroy_bo(struct wined3d_context_vk
*context_vk
,
2791 const struct wined3d_bo_vk
*bo
) DECLSPEC_HIDDEN
;
2792 void wined3d_context_vk_destroy_image(struct wined3d_context_vk
*context_vk
,
2793 struct wined3d_image_vk
*image_vk
) DECLSPEC_HIDDEN
;
2794 void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk
*context_vk
,
2795 VkBufferView vk_view
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2796 void wined3d_context_vk_destroy_vk_framebuffer(struct wined3d_context_vk
*context_vk
,
2797 VkFramebuffer vk_framebuffer
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2798 void wined3d_context_vk_destroy_vk_image(struct wined3d_context_vk
*context_vk
,
2799 VkImage vk_image
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2800 void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk
*context_vk
,
2801 VkImageView vk_view
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2802 void wined3d_context_vk_destroy_vk_memory(struct wined3d_context_vk
*context_vk
,
2803 VkDeviceMemory vk_memory
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2804 void wined3d_context_vk_destroy_vk_sampler(struct wined3d_context_vk
*context_vk
,
2805 VkSampler vk_sampler
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2806 void wined3d_context_vk_destroy_vk_event(struct wined3d_context_vk
*context_vk
,
2807 VkEvent vk_event
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2808 void wined3d_context_vk_destroy_vk_pipeline(struct wined3d_context_vk
*context_vk
,
2809 VkPipeline vk_pipeline
, uint64_t command_buffer_id
) DECLSPEC_HIDDEN
;
2810 void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
2811 VkCommandBuffer
wined3d_context_vk_get_command_buffer(struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
2812 struct wined3d_pipeline_layout_vk
*wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk
*context_vk
,
2813 VkDescriptorSetLayoutBinding
*bindings
, SIZE_T binding_count
) DECLSPEC_HIDDEN
;
2814 VkRenderPass
wined3d_context_vk_get_render_pass(struct wined3d_context_vk
*context_vk
,
2815 const struct wined3d_fb_state
*fb
, unsigned int rt_count
,
2816 bool depth_stencil
, uint32_t clear_flags
) DECLSPEC_HIDDEN
;
2817 void wined3d_context_vk_image_barrier(struct wined3d_context_vk
*context_vk
,
2818 VkCommandBuffer vk_command_buffer
, VkPipelineStageFlags src_stage_mask
, VkPipelineStageFlags dst_stage_mask
,
2819 VkAccessFlags src_access_mask
, VkAccessFlags dst_access_mask
, VkImageLayout old_layout
,
2820 VkImageLayout new_layout
, VkImage image
, const VkImageSubresourceRange
*range
) DECLSPEC_HIDDEN
;
2821 HRESULT
wined3d_context_vk_init(struct wined3d_context_vk
*context_vk
,
2822 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
2823 void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk
*context_vk
,
2824 unsigned int wait_semaphore_count
, const VkSemaphore
*wait_semaphores
, const VkPipelineStageFlags
*wait_stages
,
2825 unsigned int signal_semaphore_count
, const VkSemaphore
*signal_semaphores
) DECLSPEC_HIDDEN
;
2826 void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk
*context_vk
, uint64_t id
) DECLSPEC_HIDDEN
;
2827 VkDescriptorSet
wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk
*context_vk
,
2828 VkDescriptorSetLayout vk_set_layout
) DECLSPEC_HIDDEN
;
2830 typedef void (*APPLYSTATEFUNC
)(struct wined3d_context
*ctx
, const struct wined3d_state
*state
, DWORD state_id
);
2832 struct wined3d_state_entry
2834 unsigned int representative
;
2835 APPLYSTATEFUNC apply
;
2838 struct wined3d_state_entry_template
2841 struct wined3d_state_entry content
;
2842 unsigned int extension
;
2845 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2846 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2847 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2849 struct fragment_caps
2852 DWORD PrimitiveMiscCaps
;
2853 DWORD TextureOpCaps
;
2854 DWORD MaxTextureBlendStages
;
2855 DWORD MaxSimultaneousTextures
;
2858 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2859 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2861 struct wined3d_fragment_pipe_ops
2863 void (*fp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2864 void (*get_caps
)(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
);
2865 unsigned int (*get_emul_mask
)(const struct wined3d_gl_info
*gl_info
);
2866 void *(*alloc_private
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2867 void (*free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2868 BOOL (*allocate_context_data
)(struct wined3d_context
*context
);
2869 void (*free_context_data
)(struct wined3d_context
*context
);
2870 BOOL (*color_fixup_supported
)(struct color_fixup_desc fixup
);
2871 const struct wined3d_state_entry_template
*states
;
2874 struct wined3d_vertex_caps
2877 BOOL emulated_flatshading
;
2878 BOOL ffp_generic_attributes
;
2879 DWORD max_active_lights
;
2880 DWORD max_vertex_blend_matrices
;
2881 DWORD max_vertex_blend_matrix_index
;
2882 DWORD vertex_processing_caps
;
2884 DWORD max_user_clip_planes
;
2888 struct wined3d_vertex_pipe_ops
2890 void (*vp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2891 void (*vp_get_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
);
2892 unsigned int (*vp_get_emul_mask
)(const struct wined3d_gl_info
*gl_info
);
2893 void *(*vp_alloc
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2894 void (*vp_free
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2895 const struct wined3d_state_entry_template
*vp_states
;
2898 extern const struct wined3d_state_entry_template misc_state_template_gl
[] DECLSPEC_HIDDEN
;
2899 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN
;
2900 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN
;
2901 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN
;
2902 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN
;
2903 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN
;
2904 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN
;
2905 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN
;
2907 const struct wined3d_fragment_pipe_ops
*wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2909 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN
;
2910 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN
;
2911 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN
;
2913 const struct wined3d_vertex_pipe_ops
*wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2915 /* "Base" state table */
2916 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
2917 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
2918 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
2919 const struct wined3d_state_entry_template
*misc
) DECLSPEC_HIDDEN
;
2921 enum wined3d_blit_op
2923 WINED3D_BLIT_OP_COLOR_BLIT
,
2924 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
,
2925 WINED3D_BLIT_OP_COLOR_BLIT_CKEY
,
2926 WINED3D_BLIT_OP_DEPTH_BLIT
,
2927 WINED3D_BLIT_OP_RAW_BLIT
,
2930 struct wined3d_blitter
2932 const struct wined3d_blitter_ops
*ops
;
2933 struct wined3d_blitter
*next
;
2936 struct wined3d_blitter_ops
2938 void (*blitter_destroy
)(struct wined3d_blitter
*blitter
, struct wined3d_context
*context
);
2939 void (*blitter_clear
)(struct wined3d_blitter
*blitter
, struct wined3d_device
*device
,
2940 unsigned int rt_count
, const struct wined3d_fb_state
*fb
, unsigned int rect_count
, const RECT
*clear_rects
,
2941 const RECT
*draw_rect
, uint32_t flags
, const struct wined3d_color
*colour
, float depth
, unsigned int stencil
);
2942 DWORD (*blitter_blit
)(struct wined3d_blitter
*blitter
, enum wined3d_blit_op op
, struct wined3d_context
*context
,
2943 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
, DWORD src_location
,
2944 const RECT
*src_rect
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
2945 DWORD dst_location
, const RECT
*dst_rect
, const struct wined3d_color_key
*colour_key
,
2946 enum wined3d_texture_filter_type filter
, const struct wined3d_format
*resolve_format
);
2949 void wined3d_arbfp_blitter_create(struct wined3d_blitter
**next
,
2950 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2951 struct wined3d_blitter
*wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN
;
2952 void wined3d_fbo_blitter_create(struct wined3d_blitter
**next
,
2953 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2954 void wined3d_ffp_blitter_create(struct wined3d_blitter
**next
,
2955 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2956 struct wined3d_blitter
*wined3d_glsl_blitter_create(struct wined3d_blitter
**next
,
2957 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2958 void wined3d_raw_blitter_create(struct wined3d_blitter
**next
,
2959 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2960 void wined3d_vk_blitter_create(struct wined3d_blitter
**next
) DECLSPEC_HIDDEN
;
2962 BOOL
wined3d_clip_blit(const RECT
*clip_rect
, RECT
*clipped
, RECT
*other
) DECLSPEC_HIDDEN
;
2964 HGLRC
context_create_wgl_attribs(const struct wined3d_gl_info
*gl_info
, HDC hdc
, HGLRC share_ctx
) DECLSPEC_HIDDEN
;
2965 DWORD
context_get_tls_idx(void) DECLSPEC_HIDDEN
;
2966 void context_gl_apply_texture_draw_state(struct wined3d_context_gl
*context_gl
,
2967 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
, unsigned int location
);
2968 void context_gl_resource_released(struct wined3d_device
*device
,
2969 GLuint name
, BOOL rb_namespace
) DECLSPEC_HIDDEN
;
2970 void context_invalidate_compute_state(struct wined3d_context
*context
, DWORD state_id
) DECLSPEC_HIDDEN
;
2971 void context_invalidate_state(struct wined3d_context
*context
, unsigned int state_id
) DECLSPEC_HIDDEN
;
2972 void context_resource_released(const struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
2973 void context_restore(struct wined3d_context
*context
, struct wined3d_texture
*texture
,
2974 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2975 void context_set_tls_idx(DWORD idx
) DECLSPEC_HIDDEN
;
2976 void context_state_drawbuf(struct wined3d_context
*context
,
2977 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2978 void context_state_fb(struct wined3d_context
*context
,
2979 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2981 /*****************************************************************************
2982 * Internal representation of a light
2984 struct wined3d_light_info
2986 struct wined3d_light OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
2987 unsigned int OriginalIndex
;
2991 /* Converted parms to speed up swapping lights */
2992 struct wined3d_vec4 position
;
2993 struct wined3d_vec4 direction
;
3000 /* The default light parameters */
3001 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN
;
3003 struct wined3d_pixel_format
3005 int iPixelFormat
; /* WGL pixel format */
3006 int iPixelType
; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
3007 int redSize
, greenSize
, blueSize
, alphaSize
, colorSize
;
3008 int depthSize
, stencilSize
;
3009 BOOL windowDrawable
;
3016 enum wined3d_pci_vendor
3018 HW_VENDOR_SOFTWARE
= 0x0000,
3019 HW_VENDOR_AMD
= 0x1002,
3020 HW_VENDOR_NVIDIA
= 0x10de,
3021 HW_VENDOR_VMWARE
= 0x15ad,
3022 HW_VENDOR_REDHAT
= 0x1af4,
3023 HW_VENDOR_INTEL
= 0x8086,
3026 enum wined3d_pci_device
3030 CARD_AMD_RAGE_128PRO
= 0x5246,
3031 CARD_AMD_RADEON_7200
= 0x5144,
3032 CARD_AMD_RADEON_8500
= 0x514c,
3033 CARD_AMD_RADEON_9500
= 0x4144,
3034 CARD_AMD_RADEON_XPRESS_200M
= 0x5955,
3035 CARD_AMD_RADEON_X700
= 0x5e4c,
3036 CARD_AMD_RADEON_X1600
= 0x71c2,
3037 CARD_AMD_RADEON_HD2350
= 0x94c7,
3038 CARD_AMD_RADEON_HD2600
= 0x9581,
3039 CARD_AMD_RADEON_HD2900
= 0x9400,
3040 CARD_AMD_RADEON_HD3200
= 0x9620,
3041 CARD_AMD_RADEON_HD3850
= 0x9515,
3042 CARD_AMD_RADEON_HD4200M
= 0x9712,
3043 CARD_AMD_RADEON_HD4350
= 0x954f,
3044 CARD_AMD_RADEON_HD4600
= 0x9495,
3045 CARD_AMD_RADEON_HD4700
= 0x944e,
3046 CARD_AMD_RADEON_HD4800
= 0x944c,
3047 CARD_AMD_RADEON_HD5400
= 0x68f9,
3048 CARD_AMD_RADEON_HD5600
= 0x68d8,
3049 CARD_AMD_RADEON_HD5700
= 0x68be,
3050 CARD_AMD_RADEON_HD5800
= 0x6898,
3051 CARD_AMD_RADEON_HD5900
= 0x689c,
3052 CARD_AMD_RADEON_HD6300
= 0x9803,
3053 CARD_AMD_RADEON_HD6400
= 0x6770,
3054 CARD_AMD_RADEON_HD6490M
= 0x6760,
3055 CARD_AMD_RADEON_HD6410D
= 0x9644,
3056 CARD_AMD_RADEON_HD6480G
= 0x9648,
3057 CARD_AMD_RADEON_HD6550D
= 0x9640,
3058 CARD_AMD_RADEON_HD6600
= 0x6758,
3059 CARD_AMD_RADEON_HD6600M
= 0x6741,
3060 CARD_AMD_RADEON_HD6700
= 0x68ba,
3061 CARD_AMD_RADEON_HD6800
= 0x6739,
3062 CARD_AMD_RADEON_HD6900
= 0x6719,
3063 CARD_AMD_RADEON_HD7660D
= 0x9901,
3064 CARD_AMD_RADEON_HD7700
= 0x683d,
3065 CARD_AMD_RADEON_HD7800
= 0x6819,
3066 CARD_AMD_RADEON_HD7870
= 0x6818,
3067 CARD_AMD_RADEON_HD7900
= 0x679a,
3068 CARD_AMD_RADEON_HD8600M
= 0x6660,
3069 CARD_AMD_RADEON_HD8670
= 0x6610,
3070 CARD_AMD_RADEON_HD8770
= 0x665c,
3071 CARD_AMD_RADEON_R3
= 0x9830,
3072 CARD_AMD_RADEON_R7
= 0x130f,
3073 CARD_AMD_RADEON_R9_285
= 0x6939,
3074 CARD_AMD_RADEON_R9_290
= 0x67b1,
3075 CARD_AMD_RADEON_R9_290X
= 0x67b0,
3076 CARD_AMD_RADEON_R9_FURY
= 0x7300,
3077 CARD_AMD_RADEON_R9_M370X
= 0x6821,
3078 CARD_AMD_RADEON_R9_M380
= 0x6647,
3079 CARD_AMD_RADEON_R9_M395X
= 0x6920,
3080 CARD_AMD_RADEON_RX_460
= 0x67ef,
3081 CARD_AMD_RADEON_RX_480
= 0x67df,
3082 CARD_AMD_RADEON_RX_VEGA_10
= 0x687f,
3083 CARD_AMD_RADEON_RX_VEGA_12
= 0x69af,
3084 CARD_AMD_RADEON_RAVEN
= 0x15dd,
3085 CARD_AMD_RADEON_RX_VEGA_20
= 0x66af,
3086 CARD_AMD_RADEON_RX_NAVI_10
= 0x731f,
3087 CARD_AMD_RADEON_RX_NAVI_14
= 0x7340,
3088 CARD_AMD_RADEON_RX_NAVI_21
= 0x73bf,
3089 CARD_AMD_RADEON_PRO_V620
= 0x73a1,
3090 CARD_AMD_RADEON_PRO_V620_VF
= 0x73ae,
3091 CARD_AMD_VANGOGH
= 0x163f,
3093 CARD_NVIDIA_RIVA_128
= 0x0018,
3094 CARD_NVIDIA_RIVA_TNT
= 0x0020,
3095 CARD_NVIDIA_RIVA_TNT2
= 0x0028,
3096 CARD_NVIDIA_GEFORCE
= 0x0100,
3097 CARD_NVIDIA_GEFORCE2_MX
= 0x0110,
3098 CARD_NVIDIA_GEFORCE2
= 0x0150,
3099 CARD_NVIDIA_GEFORCE3
= 0x0200,
3100 CARD_NVIDIA_GEFORCE4_MX
= 0x0170,
3101 CARD_NVIDIA_GEFORCE4_TI4200
= 0x0253,
3102 CARD_NVIDIA_GEFORCEFX_5200
= 0x0320,
3103 CARD_NVIDIA_GEFORCEFX_5600
= 0x0312,
3104 CARD_NVIDIA_GEFORCEFX_5800
= 0x0302,
3105 CARD_NVIDIA_GEFORCE_6200
= 0x014f,
3106 CARD_NVIDIA_GEFORCE_6600GT
= 0x0140,
3107 CARD_NVIDIA_GEFORCE_6800
= 0x0041,
3108 CARD_NVIDIA_GEFORCE_7300
= 0x01d7, /* GeForce Go 7300 */
3109 CARD_NVIDIA_GEFORCE_7400
= 0x01d8,
3110 CARD_NVIDIA_GEFORCE_7600
= 0x0391,
3111 CARD_NVIDIA_GEFORCE_7800GT
= 0x0092,
3112 CARD_NVIDIA_GEFORCE_8200
= 0x0849, /* Other PCI ID 0x084b */
3113 CARD_NVIDIA_GEFORCE_8300GS
= 0x0423,
3114 CARD_NVIDIA_GEFORCE_8400GS
= 0x0404,
3115 CARD_NVIDIA_GEFORCE_8500GT
= 0x0421,
3116 CARD_NVIDIA_GEFORCE_8600GT
= 0x0402,
3117 CARD_NVIDIA_GEFORCE_8600MGT
= 0x0407,
3118 CARD_NVIDIA_GEFORCE_8800GTS
= 0x0193,
3119 CARD_NVIDIA_GEFORCE_8800GTX
= 0x0191,
3120 CARD_NVIDIA_GEFORCE_9200
= 0x086d,
3121 CARD_NVIDIA_GEFORCE_9300
= 0x086c,
3122 CARD_NVIDIA_GEFORCE_9400M
= 0x0863,
3123 CARD_NVIDIA_GEFORCE_9400GT
= 0x042c,
3124 CARD_NVIDIA_GEFORCE_9500GT
= 0x0640,
3125 CARD_NVIDIA_GEFORCE_9600GT
= 0x0622,
3126 CARD_NVIDIA_GEFORCE_9700MGT
= 0x064a,
3127 CARD_NVIDIA_GEFORCE_9800GT
= 0x0614,
3128 CARD_NVIDIA_GEFORCE_210
= 0x0a23,
3129 CARD_NVIDIA_GEFORCE_GT220
= 0x0a20,
3130 CARD_NVIDIA_GEFORCE_GT240
= 0x0ca3,
3131 CARD_NVIDIA_GEFORCE_GTS250
= 0x0615,
3132 CARD_NVIDIA_GEFORCE_GTX260
= 0x05e2,
3133 CARD_NVIDIA_GEFORCE_GTX275
= 0x05e6,
3134 CARD_NVIDIA_GEFORCE_GTX280
= 0x05e1,
3135 CARD_NVIDIA_GEFORCE_315M
= 0x0a7a,
3136 CARD_NVIDIA_GEFORCE_320M
= 0x08a3,
3137 CARD_NVIDIA_GEFORCE_GT320M
= 0x0a2d,
3138 CARD_NVIDIA_GEFORCE_GT325M
= 0x0a35,
3139 CARD_NVIDIA_GEFORCE_GT330
= 0x0ca0,
3140 CARD_NVIDIA_GEFORCE_GTS350M
= 0x0cb0,
3141 CARD_NVIDIA_GEFORCE_410M
= 0x1055,
3142 CARD_NVIDIA_GEFORCE_GT420
= 0x0de2,
3143 CARD_NVIDIA_GEFORCE_GT425M
= 0x0df0,
3144 CARD_NVIDIA_GEFORCE_GT430
= 0x0de1,
3145 CARD_NVIDIA_GEFORCE_GT440
= 0x0de0,
3146 CARD_NVIDIA_GEFORCE_GTS450
= 0x0dc4,
3147 CARD_NVIDIA_GEFORCE_GTX460
= 0x0e22,
3148 CARD_NVIDIA_GEFORCE_GTX460M
= 0x0dd1,
3149 CARD_NVIDIA_GEFORCE_GTX465
= 0x06c4,
3150 CARD_NVIDIA_GEFORCE_GTX470
= 0x06cd,
3151 CARD_NVIDIA_GEFORCE_GTX480
= 0x06c0,
3152 CARD_NVIDIA_GEFORCE_GT520
= 0x1040,
3153 CARD_NVIDIA_GEFORCE_GT525M
= 0x0dec,
3154 CARD_NVIDIA_GEFORCE_GT540M
= 0x0df4,
3155 CARD_NVIDIA_GEFORCE_GTX550
= 0x1244,
3156 CARD_NVIDIA_GEFORCE_GT555M
= 0x04b8,
3157 CARD_NVIDIA_GEFORCE_GTX560TI
= 0x1200,
3158 CARD_NVIDIA_GEFORCE_GTX560M
= 0x1251,
3159 CARD_NVIDIA_GEFORCE_GTX560
= 0x1201,
3160 CARD_NVIDIA_GEFORCE_GTX570
= 0x1081,
3161 CARD_NVIDIA_GEFORCE_GTX580
= 0x1080,
3162 CARD_NVIDIA_GEFORCE_GT610
= 0x104a,
3163 CARD_NVIDIA_GEFORCE_GT630
= 0x0f00,
3164 CARD_NVIDIA_GEFORCE_GT630M
= 0x0de9,
3165 CARD_NVIDIA_GEFORCE_GT640
= 0x0fc1,
3166 CARD_NVIDIA_GEFORCE_GT640M
= 0x0fd2,
3167 CARD_NVIDIA_GEFORCE_GT650M
= 0x0fd1,
3168 CARD_NVIDIA_GEFORCE_GTX650
= 0x0fc6,
3169 CARD_NVIDIA_GEFORCE_GTX650TI
= 0x11c6,
3170 CARD_NVIDIA_GEFORCE_GTX660
= 0x11c0,
3171 CARD_NVIDIA_GEFORCE_GTX660M
= 0x0fd4,
3172 CARD_NVIDIA_GEFORCE_GTX660TI
= 0x1183,
3173 CARD_NVIDIA_GEFORCE_GTX670
= 0x1189,
3174 CARD_NVIDIA_GEFORCE_GTX670MX
= 0x11a1,
3175 CARD_NVIDIA_GEFORCE_GTX675MX_1
= 0x11a7,
3176 CARD_NVIDIA_GEFORCE_GTX675MX_2
= 0x11a2,
3177 CARD_NVIDIA_GEFORCE_GTX680
= 0x1180,
3178 CARD_NVIDIA_GEFORCE_GTX690
= 0x1188,
3179 CARD_NVIDIA_GEFORCE_GT720
= 0x128b,
3180 CARD_NVIDIA_GEFORCE_GT730
= 0x1287,
3181 CARD_NVIDIA_GEFORCE_GT730M
= 0x0fe1,
3182 CARD_NVIDIA_GEFORCE_GT740M
= 0x1292,
3183 CARD_NVIDIA_GEFORCE_GT750M
= 0x0fe9,
3184 CARD_NVIDIA_GEFORCE_GT755M
= 0x0fcd,
3185 CARD_NVIDIA_GEFORCE_GTX750
= 0x1381,
3186 CARD_NVIDIA_GEFORCE_GTX750TI
= 0x1380,
3187 CARD_NVIDIA_GEFORCE_GTX760
= 0x1187,
3188 CARD_NVIDIA_GEFORCE_GTX760TI
= 0x1193,
3189 CARD_NVIDIA_GEFORCE_GTX765M
= 0x11e2,
3190 CARD_NVIDIA_GEFORCE_GTX770M
= 0x11e0,
3191 CARD_NVIDIA_GEFORCE_GTX770
= 0x1184,
3192 CARD_NVIDIA_GEFORCE_GTX775M
= 0x119d,
3193 CARD_NVIDIA_GEFORCE_GTX780
= 0x1004,
3194 CARD_NVIDIA_GEFORCE_GTX780M
= 0x119e,
3195 CARD_NVIDIA_GEFORCE_GTX780TI
= 0x100a,
3196 CARD_NVIDIA_GEFORCE_GTXTITAN
= 0x1005,
3197 CARD_NVIDIA_GEFORCE_GTXTITANB
= 0x100c,
3198 CARD_NVIDIA_GEFORCE_GTXTITANX
= 0x17c2,
3199 CARD_NVIDIA_GEFORCE_GTXTITANZ
= 0x1001,
3200 CARD_NVIDIA_GEFORCE_820M
= 0x0fed,
3201 CARD_NVIDIA_GEFORCE_830M
= 0x1340,
3202 CARD_NVIDIA_GEFORCE_840M
= 0x1341,
3203 CARD_NVIDIA_GEFORCE_845M
= 0x1344,
3204 CARD_NVIDIA_GEFORCE_GTX850M
= 0x1391,
3205 CARD_NVIDIA_GEFORCE_GTX860M
= 0x1392, /* Other PCI ID 0x119a */
3206 CARD_NVIDIA_GEFORCE_GTX870M
= 0x1199,
3207 CARD_NVIDIA_GEFORCE_GTX880M
= 0x1198,
3208 CARD_NVIDIA_GEFORCE_940M
= 0x1347,
3209 CARD_NVIDIA_GEFORCE_GTX950
= 0x1402,
3210 CARD_NVIDIA_GEFORCE_GTX950M
= 0x139a,
3211 CARD_NVIDIA_GEFORCE_GTX960
= 0x1401,
3212 CARD_NVIDIA_GEFORCE_GTX960M
= 0x139b,
3213 CARD_NVIDIA_GEFORCE_GTX970
= 0x13c2,
3214 CARD_NVIDIA_GEFORCE_GTX970M
= 0x13d8,
3215 CARD_NVIDIA_GEFORCE_GTX980
= 0x13c0,
3216 CARD_NVIDIA_GEFORCE_GTX980TI
= 0x17c8,
3217 CARD_NVIDIA_GEFORCE_GT1030
= 0x1d01,
3218 CARD_NVIDIA_GEFORCE_GTX1050
= 0x1c81,
3219 CARD_NVIDIA_GEFORCE_GTX1050TI
= 0x1c82,
3220 CARD_NVIDIA_GEFORCE_GTX1060_3GB
= 0x1c02,
3221 CARD_NVIDIA_GEFORCE_GTX1060
= 0x1c03,
3222 CARD_NVIDIA_GEFORCE_GTX1060M
= 0x1c20,
3223 CARD_NVIDIA_GEFORCE_GTX1070
= 0x1b81,
3224 CARD_NVIDIA_GEFORCE_GTX1080
= 0x1b80,
3225 CARD_NVIDIA_GEFORCE_GTX1080M
= 0x1be0,
3226 CARD_NVIDIA_GEFORCE_GTX1080TI
= 0x1b06,
3227 CARD_NVIDIA_TITANX_PASCAL
= 0x1b00,
3228 CARD_NVIDIA_TITANV
= 0x1d81,
3229 CARD_NVIDIA_GEFORCE_GTX1650SUPER
= 0x2187,
3230 CARD_NVIDIA_GEFORCE_GTX1660SUPER
= 0x21c4,
3231 CARD_NVIDIA_GEFORCE_GTX1660TI
= 0x2182,
3232 CARD_NVIDIA_GEFORCE_RTX2060
= 0x1f08,
3233 CARD_NVIDIA_GEFORCE_RTX2070
= 0x1f07,
3234 CARD_NVIDIA_GEFORCE_RTX2080
= 0x1e87,
3235 CARD_NVIDIA_GEFORCE_RTX2080TI
= 0x1e07,
3236 CARD_NVIDIA_TESLA_T4
= 0x1eb8,
3237 CARD_NVIDIA_AMPERE_A10
= 0x2236,
3239 CARD_REDHAT_VIRGL
= 0x1010,
3241 CARD_VMWARE_SVGA3D
= 0x0405,
3243 CARD_INTEL_830M
= 0x3577,
3244 CARD_INTEL_855GM
= 0x3582,
3245 CARD_INTEL_845G
= 0x2562,
3246 CARD_INTEL_865G
= 0x2572,
3247 CARD_INTEL_915G
= 0x2582,
3248 CARD_INTEL_E7221G
= 0x258a,
3249 CARD_INTEL_915GM
= 0x2592,
3250 CARD_INTEL_945G
= 0x2772,
3251 CARD_INTEL_945GM
= 0x27a2,
3252 CARD_INTEL_945GME
= 0x27ae,
3253 CARD_INTEL_Q35
= 0x29b2,
3254 CARD_INTEL_G33
= 0x29c2,
3255 CARD_INTEL_Q33
= 0x29d2,
3256 CARD_INTEL_PNVG
= 0xa001,
3257 CARD_INTEL_PNVM
= 0xa011,
3258 CARD_INTEL_965Q
= 0x2992,
3259 CARD_INTEL_965G
= 0x2982,
3260 CARD_INTEL_946GZ
= 0x2972,
3261 CARD_INTEL_965GM
= 0x2a02,
3262 CARD_INTEL_965GME
= 0x2a12,
3263 CARD_INTEL_GM45
= 0x2a42,
3264 CARD_INTEL_IGD
= 0x2e02,
3265 CARD_INTEL_Q45
= 0x2e12,
3266 CARD_INTEL_G45
= 0x2e22,
3267 CARD_INTEL_G41
= 0x2e32,
3268 CARD_INTEL_B43
= 0x2e92,
3269 CARD_INTEL_ILKD
= 0x0042,
3270 CARD_INTEL_ILKM
= 0x0046,
3271 CARD_INTEL_SNBD
= 0x0122,
3272 CARD_INTEL_SNBM
= 0x0126,
3273 CARD_INTEL_SNBS
= 0x010a,
3274 CARD_INTEL_IVBD
= 0x0162,
3275 CARD_INTEL_IVBM
= 0x0166,
3276 CARD_INTEL_IVBS
= 0x015a,
3277 CARD_INTEL_HWD
= 0x0412,
3278 CARD_INTEL_HWM
= 0x0416,
3279 CARD_INTEL_HD5000_1
= 0x0a26,
3280 CARD_INTEL_HD5000_2
= 0x0422,
3281 CARD_INTEL_I5100_1
= 0x0a22,
3282 CARD_INTEL_I5100_2
= 0x0a2a,
3283 CARD_INTEL_I5100_3
= 0x0a2b,
3284 CARD_INTEL_I5100_4
= 0x0a2e,
3285 CARD_INTEL_IP5200_1
= 0x0d22,
3286 CARD_INTEL_IP5200_2
= 0x0d26,
3287 CARD_INTEL_IP5200_3
= 0x0d2a,
3288 CARD_INTEL_IP5200_4
= 0x0d2b,
3289 CARD_INTEL_IP5200_5
= 0x0d2e,
3290 CARD_INTEL_IP5200_6
= 0x0c22,
3291 CARD_INTEL_HD5300
= 0x161e,
3292 CARD_INTEL_HD5500
= 0x1616,
3293 CARD_INTEL_HD5600
= 0x1612,
3294 CARD_INTEL_HD6000
= 0x1626,
3295 CARD_INTEL_I6100
= 0x162b,
3296 CARD_INTEL_IP6200
= 0x1622,
3297 CARD_INTEL_IPP6300
= 0x162a,
3298 CARD_INTEL_HD510_1
= 0x1902,
3299 CARD_INTEL_HD510_2
= 0x1906,
3300 CARD_INTEL_HD510_3
= 0x190b,
3301 CARD_INTEL_HD515
= 0x191e,
3302 CARD_INTEL_HD520_1
= 0x1916,
3303 CARD_INTEL_HD520_2
= 0x1921,
3304 CARD_INTEL_HD530_1
= 0x1912,
3305 CARD_INTEL_HD530_2
= 0x191b,
3306 CARD_INTEL_HDP530
= 0x191d,
3307 CARD_INTEL_I540
= 0x1926,
3308 CARD_INTEL_I550
= 0x1927,
3309 CARD_INTEL_I555
= 0x192b,
3310 CARD_INTEL_IP555
= 0x192d,
3311 CARD_INTEL_IP580_1
= 0x1932,
3312 CARD_INTEL_IP580_2
= 0x193b,
3313 CARD_INTEL_IPP580_1
= 0x193a,
3314 CARD_INTEL_IPP580_2
= 0x193d,
3315 CARD_INTEL_UHD617
= 0x87c0,
3316 CARD_INTEL_UHD620
= 0x3ea0,
3317 CARD_INTEL_HD615
= 0x591e,
3318 CARD_INTEL_HD620
= 0x5916,
3319 CARD_INTEL_HD630_1
= 0x5912,
3320 CARD_INTEL_HD630_2
= 0x591b,
3321 CARD_INTEL_UHD630
= 0x3e9b,
3324 struct wined3d_fbo_ops
3326 GLboolean (WINE_GLAPI
*glIsRenderbuffer
)(GLuint renderbuffer
);
3327 void (WINE_GLAPI
*glBindRenderbuffer
)(GLenum target
, GLuint renderbuffer
);
3328 void (WINE_GLAPI
*glDeleteRenderbuffers
)(GLsizei n
, const GLuint
*renderbuffers
);
3329 void (WINE_GLAPI
*glGenRenderbuffers
)(GLsizei n
, GLuint
*renderbuffers
);
3330 void (WINE_GLAPI
*glRenderbufferStorage
)(GLenum target
, GLenum internalformat
,
3331 GLsizei width
, GLsizei height
);
3332 void (WINE_GLAPI
*glRenderbufferStorageMultisample
)(GLenum target
, GLsizei samples
,
3333 GLenum internalformat
, GLsizei width
, GLsizei height
);
3334 void (WINE_GLAPI
*glGetRenderbufferParameteriv
)(GLenum target
, GLenum pname
, GLint
*params
);
3335 GLboolean (WINE_GLAPI
*glIsFramebuffer
)(GLuint framebuffer
);
3336 void (WINE_GLAPI
*glBindFramebuffer
)(GLenum target
, GLuint framebuffer
);
3337 void (WINE_GLAPI
*glDeleteFramebuffers
)(GLsizei n
, const GLuint
*framebuffers
);
3338 void (WINE_GLAPI
*glGenFramebuffers
)(GLsizei n
, GLuint
*framebuffers
);
3339 GLenum (WINE_GLAPI
*glCheckFramebufferStatus
)(GLenum target
);
3340 void (WINE_GLAPI
*glFramebufferTexture
)(GLenum target
, GLenum attachment
,
3341 GLuint texture
, GLint level
);
3342 void (WINE_GLAPI
*glFramebufferTexture1D
)(GLenum target
, GLenum attachment
,
3343 GLenum textarget
, GLuint texture
, GLint level
);
3344 void (WINE_GLAPI
*glFramebufferTexture2D
)(GLenum target
, GLenum attachment
,
3345 GLenum textarget
, GLuint texture
, GLint level
);
3346 void (WINE_GLAPI
*glFramebufferTexture3D
)(GLenum target
, GLenum attachment
,
3347 GLenum textarget
, GLuint texture
, GLint level
, GLint layer
);
3348 void (WINE_GLAPI
*glFramebufferTextureLayer
)(GLenum target
, GLenum attachment
,
3349 GLuint texture
, GLint level
, GLint layer
);
3350 void (WINE_GLAPI
*glFramebufferRenderbuffer
)(GLenum target
, GLenum attachment
,
3351 GLenum renderbuffertarget
, GLuint renderbuffer
);
3352 void (WINE_GLAPI
*glGetFramebufferAttachmentParameteriv
)(GLenum target
, GLenum attachment
,
3353 GLenum pname
, GLint
*params
);
3354 void (WINE_GLAPI
*glBlitFramebuffer
)(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
3355 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
, GLbitfield mask
, GLenum filter
);
3356 void (WINE_GLAPI
*glGenerateMipmap
)(GLenum target
);
3359 struct wined3d_gl_limits
3364 UINT texture_coords
;
3365 unsigned int uniform_blocks
[WINED3D_SHADER_TYPE_COUNT
];
3366 unsigned int samplers
[WINED3D_SHADER_TYPE_COUNT
];
3367 unsigned int graphics_samplers
;
3368 unsigned int combined_samplers
;
3369 UINT general_combiners
;
3370 UINT user_clip_distances
;
3371 unsigned int texture_size
;
3372 UINT texture3d_size
;
3376 UINT vertex_attribs
;
3378 unsigned int texture_buffer_offset_alignment
;
3380 unsigned int framebuffer_width
;
3381 unsigned int framebuffer_height
;
3382 unsigned int viewport_subpixel_bits
;
3385 UINT glsl_vs_float_constants
;
3386 UINT glsl_ps_float_constants
;
3388 UINT arb_vs_float_constants
;
3389 UINT arb_vs_native_constants
;
3390 UINT arb_vs_instructions
;
3392 UINT arb_ps_float_constants
;
3393 UINT arb_ps_local_constants
;
3394 UINT arb_ps_native_constants
;
3395 UINT arb_ps_instructions
;
3399 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits
*gl_limits
,
3400 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
3401 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits
*gl_limits
,
3402 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
3404 struct wined3d_gl_info
3406 unsigned int selected_gl_version
;
3407 unsigned int glsl_version
;
3408 struct wined3d_gl_limits limits
;
3409 DWORD reserved_glsl_constants
, reserved_arb_constants
;
3411 BOOL supported
[WINED3D_GL_EXT_COUNT
];
3412 GLint wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
+ 1];
3413 float filling_convention_offset
;
3415 HGLRC (WINAPI
*p_wglCreateContextAttribsARB
)(HDC dc
, HGLRC share
, const GLint
*attribs
);
3416 struct opengl_funcs gl_ops
;
3417 struct wined3d_fbo_ops fbo_ops
;
3419 void (WINE_GLAPI
*p_glDisableWINE
)(GLenum cap
);
3420 void (WINE_GLAPI
*p_glEnableWINE
)(GLenum cap
);
3423 static inline BOOL
wined3d_fence_supported(const struct wined3d_gl_info
*gl_info
)
3425 return gl_info
->supported
[ARB_SYNC
] || gl_info
->supported
[NV_FENCE
] || gl_info
->supported
[APPLE_FENCE
];
3428 /* The driver names reflect the lowest GPU supported
3429 * by a certain driver, so DRIVER_AMD_R300 supports
3430 * R3xx, R4xx and R5xx GPUs. */
3431 enum wined3d_display_driver
3433 DRIVER_AMD_RAGE_128PRO
,
3438 DRIVER_INTEL_GMA800
,
3439 DRIVER_INTEL_GMA900
,
3440 DRIVER_INTEL_GMA950
,
3441 DRIVER_INTEL_GMA3000
,
3442 DRIVER_INTEL_HD4000
,
3444 DRIVER_NVIDIA_GEFORCE2MX
,
3445 DRIVER_NVIDIA_GEFORCEFX
,
3446 DRIVER_NVIDIA_GEFORCE6
,
3447 DRIVER_NVIDIA_GEFORCE8
,
3448 DRIVER_NVIDIA_FERMI
,
3449 DRIVER_NVIDIA_KEPLER
,
3450 DRIVER_REDHAT_VIRGL
,
3456 struct wined3d_gpu_description
3458 enum wined3d_pci_vendor vendor
;
3459 enum wined3d_pci_device device
;
3460 const char *description
;
3461 enum wined3d_display_driver driver
;
3462 unsigned int vidmem
;
3465 const struct wined3d_gpu_description
*wined3d_get_gpu_description(enum wined3d_pci_vendor vendor
,
3466 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
3467 const struct wined3d_gpu_description
*wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor
,
3468 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
3469 enum wined3d_pci_device
wined3d_gpu_from_feature_level(enum wined3d_pci_vendor
*vendor
,
3470 enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
3472 /* 512 in Direct3D 8/9, 128 in DXGI. */
3473 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
3475 struct wined3d_driver_info
3477 enum wined3d_pci_vendor vendor
;
3478 enum wined3d_pci_device device
;
3480 char description
[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH
];
3482 UINT64 sysmem_bytes
;
3483 unsigned int version_high
;
3484 unsigned int version_low
;
3487 bool wined3d_driver_info_init(struct wined3d_driver_info
*driver_info
,
3488 const struct wined3d_gpu_description
*gpu_description
, enum wined3d_feature_level feature_level
,
3489 UINT64 vram_bytes
, UINT64 sysmem_bytes
) DECLSPEC_HIDDEN
;
3491 #define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
3492 #define UPLOAD_BO_RENAME_ON_UNMAP 0x2
3493 #define UPLOAD_BO_FREE_ON_UNMAP 0x4
3497 struct wined3d_const_bo_address addr
;
3501 struct wined3d_adapter_ops
3503 void (*adapter_destroy
)(struct wined3d_adapter
*adapter
);
3504 HRESULT (*adapter_create_device
)(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
3505 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
3506 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
3507 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
);
3508 void (*adapter_destroy_device
)(struct wined3d_device
*device
);
3509 struct wined3d_context
*(*adapter_acquire_context
)(struct wined3d_device
*device
,
3510 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
3511 void (*adapter_release_context
)(struct wined3d_context
*context
);
3512 void (*adapter_get_wined3d_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
);
3513 BOOL (*adapter_check_format
)(const struct wined3d_adapter
*adapter
,
3514 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
3515 const struct wined3d_format
*ds_format
);
3516 HRESULT (*adapter_init_3d
)(struct wined3d_device
*device
);
3517 void (*adapter_uninit_3d
)(struct wined3d_device
*device
);
3518 void *(*adapter_map_bo_address
)(struct wined3d_context
*context
,
3519 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
);
3520 void (*adapter_unmap_bo_address
)(struct wined3d_context
*context
, const struct wined3d_bo_address
*data
,
3521 unsigned int range_count
, const struct wined3d_range
*ranges
);
3522 void (*adapter_copy_bo_address
)(struct wined3d_context
*context
,
3523 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
3524 unsigned int range_count
, const struct wined3d_range
*ranges
);
3525 void (*adapter_flush_bo_address
)(struct wined3d_context
*context
,
3526 const struct wined3d_const_bo_address
*data
, size_t size
);
3527 bool (*adapter_alloc_bo
)(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
3528 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
);
3529 void (*adapter_destroy_bo
)(struct wined3d_context
*context
, struct wined3d_bo
*bo
);
3530 HRESULT (*adapter_create_swapchain
)(struct wined3d_device
*device
,
3531 struct wined3d_swapchain_desc
*desc
,
3532 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
3533 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
);
3534 void (*adapter_destroy_swapchain
)(struct wined3d_swapchain
*swapchain
);
3535 HRESULT (*adapter_create_buffer
)(struct wined3d_device
*device
, const struct wined3d_buffer_desc
*desc
,
3536 const struct wined3d_sub_resource_data
*data
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3537 struct wined3d_buffer
**buffer
);
3538 void (*adapter_destroy_buffer
)(struct wined3d_buffer
*buffer
);
3539 HRESULT (*adapter_create_texture
)(struct wined3d_device
*device
, const struct wined3d_resource_desc
*desc
,
3540 unsigned int layer_count
, unsigned int level_count
, uint32_t flags
, void *parent
,
3541 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
);
3542 void (*adapter_destroy_texture
)(struct wined3d_texture
*texture
);
3543 HRESULT (*adapter_create_rendertarget_view
)(const struct wined3d_view_desc
*desc
,
3544 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3545 struct wined3d_rendertarget_view
**view
);
3546 void (*adapter_destroy_rendertarget_view
)(struct wined3d_rendertarget_view
*view
);
3547 HRESULT (*adapter_create_shader_resource_view
)(const struct wined3d_view_desc
*desc
,
3548 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3549 struct wined3d_shader_resource_view
**view
);
3550 void (*adapter_destroy_shader_resource_view
)(struct wined3d_shader_resource_view
*view
);
3551 HRESULT (*adapter_create_unordered_access_view
)(const struct wined3d_view_desc
*desc
,
3552 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3553 struct wined3d_unordered_access_view
**view
);
3554 void (*adapter_destroy_unordered_access_view
)(struct wined3d_unordered_access_view
*view
);
3555 HRESULT (*adapter_create_sampler
)(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
3556 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
);
3557 void (*adapter_destroy_sampler
)(struct wined3d_sampler
*sampler
);
3558 HRESULT (*adapter_create_query
)(struct wined3d_device
*device
, enum wined3d_query_type type
,
3559 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
3560 void (*adapter_destroy_query
)(struct wined3d_query
*query
);
3561 void (*adapter_flush_context
)(struct wined3d_context
*context
);
3562 void (*adapter_draw_primitive
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
3563 const struct wined3d_draw_parameters
*parameters
);
3564 void (*adapter_dispatch_compute
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
3565 const struct wined3d_dispatch_parameters
*parameters
);
3566 void (*adapter_clear_uav
)(struct wined3d_context
*context
,
3567 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
);
3568 void (*adapter_generate_mipmap
)(struct wined3d_context
*context
, struct wined3d_shader_resource_view
*view
);
3571 struct wined3d_output
3573 unsigned int ordinal
;
3574 WCHAR device_name
[CCHDEVICENAME
];
3575 struct wined3d_adapter
*adapter
;
3576 enum wined3d_format_id screen_format
;
3578 D3DKMT_HANDLE kmt_device
;
3579 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id
;
3581 struct wined3d_display_mode
*modes
;
3582 SIZE_T mode_count
, modes_size
;
3586 HRESULT
wined3d_output_get_gamma_ramp(struct wined3d_output
*output
, struct wined3d_gamma_ramp
*ramp
) DECLSPEC_HIDDEN
;
3589 #define MAX_PERSISTENT_MAPPED_BYTES I64_MAX
3591 #define MAX_PERSISTENT_MAPPED_BYTES (128 * 1024 * 1024)
3594 /* The adapter structure */
3595 struct wined3d_adapter
3597 unsigned int ordinal
;
3599 struct wined3d_gl_info gl_info
;
3600 struct wined3d_d3d_info d3d_info
;
3601 struct wined3d_driver_info driver_info
;
3602 struct wined3d_output
*outputs
;
3603 SIZE_T output_count
, outputs_size
;
3604 D3DKMT_HANDLE kmt_adapter
;
3605 UINT64 vram_bytes_used
;
3613 ssize_t mapped_size
;
3615 const struct wined3d_vertex_pipe_ops
*vertex_pipe
;
3616 const struct wined3d_fragment_pipe_ops
*fragment_pipe
;
3617 const struct wined3d_state_entry_template
*misc_state_template
;
3618 const struct wined3d_shader_backend_ops
*shader_backend
;
3619 const struct wined3d_adapter_ops
*adapter_ops
;
3622 BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, unsigned int ordinal
, const LUID
*luid
,
3623 const struct wined3d_adapter_ops
*adapter_ops
) DECLSPEC_HIDDEN
;
3624 void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
3625 BOOL
wined3d_get_primary_adapter_luid(LUID
*luid
) DECLSPEC_HIDDEN
;
3627 struct wined3d_adapter_gl
3629 struct wined3d_adapter a
;
3631 struct wined3d_pixel_format
*pixel_formats
;
3632 unsigned int pixel_format_count
;
3635 static inline struct wined3d_adapter_gl
*wined3d_adapter_gl(struct wined3d_adapter
*adapter
)
3637 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
3640 static inline const struct wined3d_adapter_gl
*wined3d_adapter_gl_const(const struct wined3d_adapter
*adapter
)
3642 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
3645 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
,
3646 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
3648 struct wined3d_adapter_vk
3650 struct wined3d_adapter a
;
3652 struct wined3d_vk_info vk_info
;
3653 unsigned int device_extension_count
;
3654 const char **device_extensions
;
3655 VkPhysicalDevice physical_device
;
3657 VkPhysicalDeviceLimits device_limits
;
3658 VkPhysicalDeviceMemoryProperties memory_properties
;
3661 static inline struct wined3d_adapter_vk
*wined3d_adapter_vk(struct wined3d_adapter
*adapter
)
3663 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_vk
, a
);
3666 struct wined3d_adapter
*wined3d_adapter_vk_create(unsigned int ordinal
,
3667 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
3668 unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk
*adapter_vk
,
3669 uint32_t memory_type_mask
, VkMemoryPropertyFlags flags
) DECLSPEC_HIDDEN
;
3670 void adapter_vk_copy_bo_address(struct wined3d_context
*context
, const struct wined3d_bo_address
*dst
,
3671 const struct wined3d_bo_address
*src
,
3672 unsigned int range_count
, const struct wined3d_range
*ranges
) DECLSPEC_HIDDEN
;
3674 struct wined3d_caps_gl_ctx
3680 HGLRC restore_gl_ctx
;
3682 const struct wined3d_gl_info
*gl_info
;
3684 GLuint test_program_id
;
3686 const struct wined3d_gpu_description
*gpu_description
;
3690 BOOL
wined3d_adapter_gl_init_format_info(struct wined3d_adapter
*adapter
,
3691 struct wined3d_caps_gl_ctx
*ctx
) DECLSPEC_HIDDEN
;
3692 BOOL
wined3d_adapter_no3d_init_format_info(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
3693 BOOL
wined3d_adapter_vk_init_format_info(struct wined3d_adapter_vk
*adapter_vk
,
3694 const struct wined3d_vk_info
*vk_info
) DECLSPEC_HIDDEN
;
3695 ssize_t
adapter_adjust_mapped_memory(struct wined3d_adapter
*adapter
, ssize_t size
) DECLSPEC_HIDDEN
;
3696 UINT64
adapter_adjust_memory(struct wined3d_adapter
*adapter
, INT64 amount
) DECLSPEC_HIDDEN
;
3698 BOOL
wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
*ctx
) DECLSPEC_HIDDEN
;
3699 bool wined3d_caps_gl_ctx_test_filling_convention(struct wined3d_caps_gl_ctx
*ctx
, float offset
) DECLSPEC_HIDDEN
;
3701 void install_gl_compat_wrapper(struct wined3d_gl_info
*gl_info
, enum wined3d_gl_extension ext
) DECLSPEC_HIDDEN
;
3703 enum wined3d_projection_type
3705 WINED3D_PROJECTION_NONE
= 0,
3706 WINED3D_PROJECTION_COUNT3
= 1,
3707 WINED3D_PROJECTION_COUNT4
= 2
3710 /*****************************************************************************
3711 * Fixed function pipeline replacements
3713 #define ARG_UNUSED 0xff
3714 struct texture_stage_op
3726 struct color_fixup_desc color_fixup
;
3727 unsigned tex_type
: 3;
3728 unsigned tmp_dst
: 1;
3729 unsigned projected
: 2;
3730 unsigned padding
: 10;
3733 struct ffp_frag_settings
3735 struct texture_stage_op op
[WINED3D_MAX_TEXTURES
];
3736 enum wined3d_ffp_ps_fog_mode fog
;
3737 unsigned char sRGB_write
;
3738 unsigned char emul_clipplanes
;
3739 unsigned char texcoords_initialized
;
3740 unsigned char color_key_enabled
: 1;
3741 unsigned char pointsprite
: 1;
3742 unsigned char flatshading
: 1;
3743 unsigned char alpha_test_func
: 3;
3744 unsigned char padding
: 2;
3747 struct ffp_frag_desc
3749 struct wine_rb_entry entry
;
3750 struct ffp_frag_settings settings
;
3753 int wined3d_ffp_frag_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
3754 int wined3d_ffp_vertex_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
3756 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN
;
3758 void wined3d_ffp_get_fs_settings(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
3759 struct ffp_frag_settings
*settings
, BOOL ignore_textype
) DECLSPEC_HIDDEN
;
3760 const struct ffp_frag_desc
*find_ffp_frag_shader(const struct wine_rb_tree
*fragment_shaders
,
3761 const struct ffp_frag_settings
*settings
) DECLSPEC_HIDDEN
;
3762 void add_ffp_frag_shader(struct wine_rb_tree
*shaders
, struct ffp_frag_desc
*desc
) DECLSPEC_HIDDEN
;
3763 void wined3d_ftoa(float value
, char *s
) DECLSPEC_HIDDEN
;
3765 enum wined3d_ffp_vs_fog_mode
3767 WINED3D_FFP_VS_FOG_OFF
= 0,
3768 WINED3D_FFP_VS_FOG_FOGCOORD
= 1,
3769 WINED3D_FFP_VS_FOG_DEPTH
= 2,
3770 WINED3D_FFP_VS_FOG_RANGE
= 3,
3773 #define WINED3D_FFP_TCI_SHIFT 16
3774 #define WINED3D_FFP_TCI_MASK 0xffu
3776 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3777 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3779 struct wined3d_ffp_vs_settings
3781 DWORD point_light_count
: 4;
3782 DWORD spot_light_count
: 4;
3783 DWORD directional_light_count
: 4;
3784 DWORD parallel_point_light_count
: 4;
3785 DWORD diffuse_source
: 2;
3786 DWORD emissive_source
: 2;
3787 DWORD ambient_source
: 2;
3788 DWORD specular_source
: 2;
3789 DWORD transformed
: 1;
3790 DWORD vertexblends
: 2;
3793 DWORD normalize
: 1;
3795 DWORD localviewer
: 1;
3797 DWORD point_size
: 1;
3798 DWORD per_vertex_point_size
: 1;
3800 DWORD texcoords
: 8; /* WINED3D_MAX_TEXTURES */
3801 DWORD ortho_fog
: 1;
3802 DWORD flatshading
: 1;
3805 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
3807 unsigned int texgen
[WINED3D_MAX_TEXTURES
];
3810 struct wined3d_ffp_vs_desc
3812 struct wine_rb_entry entry
;
3813 struct wined3d_ffp_vs_settings settings
;
3816 void wined3d_ffp_get_vs_settings(const struct wined3d_context
*context
,
3817 const struct wined3d_state
*state
, struct wined3d_ffp_vs_settings
*settings
) DECLSPEC_HIDDEN
;
3823 unsigned int adapter_count
;
3824 struct wined3d_adapter
*adapters
[1];
3827 BOOL
wined3d_filter_messages(HWND window
, BOOL filter
) DECLSPEC_HIDDEN
;
3828 HRESULT
wined3d_init(struct wined3d
*wined3d
, uint32_t flags
) DECLSPEC_HIDDEN
;
3829 void wined3d_unregister_window(HWND window
) DECLSPEC_HIDDEN
;
3831 BOOL
wined3d_get_app_name(char *app_name
, unsigned int app_name_size
) DECLSPEC_HIDDEN
;
3833 struct wined3d_blend_state
3836 struct wined3d_blend_state_desc desc
;
3840 const struct wined3d_parent_ops
*parent_ops
;
3842 struct wined3d_device
*device
;
3843 struct wine_rb_entry entry
;
3846 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state
*state
,
3851 if (!state
->desc
.independent
)
3853 return state
->desc
.rt
[index
].writemask
;
3856 struct wined3d_depth_stencil_state
3859 struct wined3d_depth_stencil_state_desc desc
;
3864 const struct wined3d_parent_ops
*parent_ops
;
3866 struct wined3d_device
*device
;
3867 struct wine_rb_entry entry
;
3870 struct wined3d_rasterizer_state
3873 struct wined3d_rasterizer_state_desc desc
;
3876 const struct wined3d_parent_ops
*parent_ops
;
3878 struct wined3d_device
*device
;
3879 struct wine_rb_entry entry
;
3882 #define LIGHTMAP_SIZE 43
3883 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
3885 struct wined3d_light_state
3887 /* Light hashmap. Collisions are handled using linked lists. */
3888 struct list light_map
[LIGHTMAP_SIZE
];
3889 const struct wined3d_light_info
*lights
[WINED3D_MAX_ACTIVE_LIGHTS
];
3892 #define WINED3D_STATE_NO_REF 0x00000001
3893 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3895 struct wined3d_state
3897 enum wined3d_feature_level feature_level
;
3899 struct wined3d_fb_state fb
;
3901 struct wined3d_vertex_declaration
*vertex_declaration
;
3902 struct wined3d_stream_output stream_output
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
3903 struct wined3d_stream_state streams
[WINED3D_MAX_STREAMS
];
3904 struct wined3d_buffer
*index_buffer
;
3905 enum wined3d_format_id index_format
;
3906 unsigned int index_offset
;
3907 int base_vertex_index
;
3908 int load_base_vertex_index
; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3909 enum wined3d_primitive_type primitive_type
;
3910 unsigned int patch_vertex_count
;
3911 struct wined3d_query
*predicate
;
3912 BOOL predicate_value
;
3914 struct wined3d_shader
*shader
[WINED3D_SHADER_TYPE_COUNT
];
3915 struct wined3d_constant_buffer_state cb
[WINED3D_SHADER_TYPE_COUNT
][MAX_CONSTANT_BUFFERS
];
3916 struct wined3d_sampler
*sampler
[WINED3D_SHADER_TYPE_COUNT
][MAX_SAMPLER_OBJECTS
];
3917 struct wined3d_shader_resource_view
*shader_resource_view
[WINED3D_SHADER_TYPE_COUNT
][MAX_SHADER_RESOURCE_VIEWS
];
3918 struct wined3d_unordered_access_view
*unordered_access_view
[WINED3D_PIPELINE_COUNT
][MAX_UNORDERED_ACCESS_VIEWS
];
3920 struct wined3d_vec4 vs_consts_f
[WINED3D_MAX_VS_CONSTS_F
];
3921 struct wined3d_ivec4 vs_consts_i
[WINED3D_MAX_CONSTS_I
];
3922 BOOL vs_consts_b
[WINED3D_MAX_CONSTS_B
];
3924 struct wined3d_vec4 ps_consts_f
[WINED3D_MAX_PS_CONSTS_F
];
3925 struct wined3d_ivec4 ps_consts_i
[WINED3D_MAX_CONSTS_I
];
3926 BOOL ps_consts_b
[WINED3D_MAX_CONSTS_B
];
3928 struct wined3d_texture
*textures
[WINED3D_MAX_COMBINED_SAMPLERS
];
3929 uint32_t sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
3930 uint32_t texture_states
[WINED3D_MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
3932 struct wined3d_matrix transforms
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
3933 struct wined3d_vec4 clip_planes
[WINED3D_MAX_CLIP_DISTANCES
];
3934 struct wined3d_material material
;
3935 struct wined3d_viewport viewports
[WINED3D_MAX_VIEWPORTS
];
3936 unsigned int viewport_count
;
3937 RECT scissor_rects
[WINED3D_MAX_VIEWPORTS
];
3938 unsigned int scissor_rect_count
;
3940 struct wined3d_light_state light_state
;
3942 unsigned int render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
3943 struct wined3d_blend_state
*blend_state
;
3944 struct wined3d_color blend_factor
;
3945 unsigned int sample_mask
;
3946 struct wined3d_depth_stencil_state
*depth_stencil_state
;
3947 unsigned int stencil_ref
;
3948 bool depth_bounds_enable
;
3949 float depth_bounds_min
, depth_bounds_max
;
3950 struct wined3d_rasterizer_state
*rasterizer_state
;
3953 void state_cleanup(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3954 void state_init(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
3955 uint32_t flags
, enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
3956 void state_unbind_resources(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3958 static inline void wined3d_state_reset(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
)
3960 enum wined3d_feature_level feature_level
= state
->feature_level
;
3961 uint32_t flags
= state
->flags
;
3963 memset(state
, 0, sizeof(*state
));
3964 state_init(state
, d3d_info
, flags
, feature_level
);
3967 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state
*state
)
3969 if (!state
->depth_stencil_state
)
3971 return state
->depth_stencil_state
->desc
.depth
|| state
->depth_stencil_state
->desc
.depth_write
3972 || state
->depth_stencil_state
->desc
.stencil
;
3975 struct wined3d_dummy_textures
3982 GLuint tex_cube_array
;
3983 GLuint tex_1d_array
;
3984 GLuint tex_2d_array
;
3987 GLuint tex_2d_ms_array
;
3990 #define WINED3D_UNMAPPED_STAGE ~0u
3992 /* Multithreaded flag. Removed from the public header to signal that
3993 * wined3d_device_create() ignores it. */
3994 #define WINED3DCREATE_MULTITHREADED 0x00000004
3996 struct wined3d_so_desc_entry
3998 struct wine_rb_entry entry
;
3999 struct wined3d_stream_output_desc desc
;
4000 struct wined3d_stream_output_element elements
[1];
4003 struct wined3d_device
4007 /* WineD3D Information */
4008 struct wined3d_device_parent
*device_parent
;
4009 struct wined3d
*wined3d
;
4010 struct wined3d_adapter
*adapter
;
4012 const struct wined3d_shader_backend_ops
*shader_backend
;
4014 void *fragment_priv
;
4016 struct wined3d_state_entry state_table
[STATE_HIGHEST
+ 1];
4017 /* Array of functions for states which are handled by more than one pipeline part */
4018 APPLYSTATEFUNC
*multistate_funcs
[STATE_HIGHEST
+ 1];
4019 struct wined3d_blitter
*blitter
;
4021 BYTE bCursorVisible
: 1;
4022 BYTE d3d_initialized
: 1;
4023 BYTE inScene
: 1; /* A flag to check for proper BeginScene / EndScene call pairs */
4024 BYTE softwareVertexProcessing
: 1; /* process vertex shaders using software or hardware */
4025 BYTE restore_screensaver
: 1;
4028 unsigned char surface_alignment
; /* Line Alignment of surfaces */
4032 /* Internal use fields */
4033 struct wined3d_device_creation_parameters create_parms
;
4036 struct wined3d_rendertarget_view
*back_buffer_view
;
4037 struct wined3d_swapchain
**swapchains
;
4038 UINT swapchain_count
;
4039 unsigned int max_frame_latency
;
4041 struct list resources
; /* a linked list to track resources created by the device */
4042 struct list shaders
; /* a linked list to track shaders (pixel and vertex) */
4043 struct wine_rb_tree so_descs
;
4044 struct wine_rb_tree samplers
, rasterizer_states
, blend_states
, depth_stencil_states
;
4046 /* Render Target Support */
4047 struct wined3d_rendertarget_view
*auto_depth_stencil_view
;
4049 /* Cursor management */
4054 UINT cursorWidth
, cursorHeight
;
4055 struct wined3d_texture
*cursor_texture
;
4056 HCURSOR hardwareCursor
;
4058 /* The Wine logo texture */
4059 struct wined3d_texture
*logo_texture
;
4061 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
4062 struct wined3d_sampler
*default_sampler
;
4063 struct wined3d_sampler
*null_sampler
;
4065 /* Command stream */
4066 struct wined3d_cs
*cs
;
4068 /* Context management */
4069 struct wined3d_context
**contexts
;
4072 CRITICAL_SECTION bo_map_lock
;
4075 void wined3d_device_cleanup(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
4076 BOOL
device_context_add(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4077 void device_context_remove(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4078 void wined3d_device_create_default_samplers(struct wined3d_device
*device
,
4079 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4080 void wined3d_device_destroy_default_samplers(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
4081 HRESULT
wined3d_device_init(struct wined3d_device
*device
, struct wined3d
*wined3d
,
4082 unsigned int adapter_idx
, enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
4083 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
4084 const BOOL
*supported_extensions
, struct wined3d_device_parent
*device_parent
) DECLSPEC_HIDDEN
;
4085 LRESULT
device_process_message(struct wined3d_device
*device
, HWND window
, BOOL unicode
,
4086 UINT message
, WPARAM wparam
, LPARAM lparam
, WNDPROC proc
) DECLSPEC_HIDDEN
;
4087 void device_resource_add(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4088 void device_resource_released(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4089 void device_invalidate_state(const struct wined3d_device
*device
, unsigned int state
) DECLSPEC_HIDDEN
;
4090 HRESULT
wined3d_device_set_implicit_swapchain(struct wined3d_device
*device
,
4091 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4092 void wined3d_device_uninit_3d(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
4094 static inline void wined3d_device_bo_map_lock(struct wined3d_device
*device
)
4096 EnterCriticalSection(&device
->bo_map_lock
);
4099 static inline void wined3d_device_bo_map_unlock(struct wined3d_device
*device
)
4101 LeaveCriticalSection(&device
->bo_map_lock
);
4104 struct wined3d_device_no3d
4106 struct wined3d_device d
;
4108 struct wined3d_context context_no3d
;
4111 static inline struct wined3d_device_no3d
*wined3d_device_no3d(struct wined3d_device
*device
)
4113 return CONTAINING_RECORD(device
, struct wined3d_device_no3d
, d
);
4116 struct wined3d_null_resources_vk
4118 struct wined3d_bo_vk bo
;
4119 VkDescriptorBufferInfo buffer_info
;
4121 struct wined3d_image_vk image_1d
;
4122 struct wined3d_image_vk image_2d
;
4123 struct wined3d_image_vk image_2dms
;
4124 struct wined3d_image_vk image_3d
;
4127 struct wined3d_null_views_vk
4129 VkBufferView vk_view_buffer_uint
;
4130 VkBufferView vk_view_buffer_float
;
4132 VkDescriptorImageInfo vk_info_1d
;
4133 VkDescriptorImageInfo vk_info_2d
;
4134 VkDescriptorImageInfo vk_info_2dms
;
4135 VkDescriptorImageInfo vk_info_3d
;
4136 VkDescriptorImageInfo vk_info_cube
;
4137 VkDescriptorImageInfo vk_info_1d_array
;
4138 VkDescriptorImageInfo vk_info_2d_array
;
4139 VkDescriptorImageInfo vk_info_2dms_array
;
4140 VkDescriptorImageInfo vk_info_cube_array
;
4143 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
4144 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
4145 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
4146 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
4147 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
4149 struct wined3d_allocator_chunk
4152 struct list available
[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT
];
4153 struct wined3d_allocator
*allocator
;
4154 unsigned int map_count
;
4158 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk
*chunk
) DECLSPEC_HIDDEN
;
4159 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk
*chunk
,
4160 struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
4162 struct wined3d_allocator_chunk_gl
4164 struct wined3d_allocator_chunk c
;
4165 unsigned int memory_type
;
4169 static inline struct wined3d_allocator_chunk_gl
*wined3d_allocator_chunk_gl(struct wined3d_allocator_chunk
*chunk
)
4171 return CONTAINING_RECORD(chunk
, struct wined3d_allocator_chunk_gl
, c
);
4174 struct wined3d_allocator_chunk_vk
4176 struct wined3d_allocator_chunk c
;
4177 VkDeviceMemory vk_memory
;
4180 static inline struct wined3d_allocator_chunk_vk
*wined3d_allocator_chunk_vk(struct wined3d_allocator_chunk
*chunk
)
4182 return CONTAINING_RECORD(chunk
, struct wined3d_allocator_chunk_vk
, c
);
4185 void *wined3d_allocator_chunk_vk_map(struct wined3d_allocator_chunk_vk
*chunk_vk
,
4186 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4187 void wined3d_allocator_chunk_vk_unmap(struct wined3d_allocator_chunk_vk
*chunk_vk
,
4188 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4190 struct wined3d_allocator_block
4193 struct wined3d_allocator_chunk
*chunk
;
4194 struct wined3d_allocator_block
*parent
, *sibling
;
4200 void wined3d_allocator_block_free(struct wined3d_allocator_block
*block
) DECLSPEC_HIDDEN
;
4202 struct wined3d_allocator_pool
4207 struct wined3d_allocator_ops
4209 struct wined3d_allocator_chunk
*(*allocator_create_chunk
)(struct wined3d_allocator
*allocator
,
4210 struct wined3d_context
*context
, unsigned int memory_type
, size_t chunk_size
);
4211 void (*allocator_destroy_chunk
)(struct wined3d_allocator_chunk
*chunk
);
4214 struct wined3d_allocator
4216 const struct wined3d_allocator_ops
*ops
;
4217 struct wined3d_allocator_pool
*pools
;
4219 struct wined3d_allocator_block
*free
;
4222 struct wined3d_allocator_block
*wined3d_allocator_allocate(struct wined3d_allocator
*allocator
,
4223 struct wined3d_context
*context
, unsigned int memory_type
, size_t size
) DECLSPEC_HIDDEN
;
4224 void wined3d_allocator_cleanup(struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
4225 bool wined3d_allocator_init(struct wined3d_allocator
*allocator
,
4226 size_t pool_count
, const struct wined3d_allocator_ops
*allocator_ops
) DECLSPEC_HIDDEN
;
4228 struct wined3d_uav_clear_pipelines_vk
4231 VkPipeline image_1d
;
4232 VkPipeline image_1d_array
;
4233 VkPipeline image_2d
;
4234 VkPipeline image_2d_array
;
4235 VkPipeline image_3d
;
4238 struct wined3d_uav_clear_state_vk
4240 struct wined3d_uav_clear_pipelines_vk float_pipelines
;
4241 struct wined3d_uav_clear_pipelines_vk uint_pipelines
;
4243 struct wined3d_shader_thread_group_size buffer_group_size
;
4244 struct wined3d_shader_thread_group_size image_1d_group_size
;
4245 struct wined3d_shader_thread_group_size image_1d_array_group_size
;
4246 struct wined3d_shader_thread_group_size image_2d_group_size
;
4247 struct wined3d_shader_thread_group_size image_2d_array_group_size
;
4248 struct wined3d_shader_thread_group_size image_3d_group_size
;
4250 struct wined3d_pipeline_layout_vk
*image_layout
;
4251 struct wined3d_pipeline_layout_vk
*buffer_layout
;
4254 struct wined3d_device_vk
4256 struct wined3d_device d
;
4258 struct wined3d_context_vk context_vk
;
4262 uint32_t vk_queue_family_index
;
4263 uint32_t timestamp_bits
;
4265 struct wined3d_vk_info vk_info
;
4267 struct wined3d_null_resources_vk null_resources_vk
;
4268 struct wined3d_null_views_vk null_views_vk
;
4270 CRITICAL_SECTION allocator_cs
;
4271 struct wined3d_allocator allocator
;
4273 struct wined3d_uav_clear_state_vk uav_clear_state
;
4276 static inline struct wined3d_device_vk
*wined3d_device_vk(struct wined3d_device
*device
)
4278 return CONTAINING_RECORD(device
, struct wined3d_device_vk
, d
);
4281 static inline struct wined3d_device_vk
*wined3d_device_vk_from_allocator(struct wined3d_allocator
*allocator
)
4283 return CONTAINING_RECORD(allocator
, struct wined3d_device_vk
, allocator
);
4286 static inline void wined3d_device_vk_allocator_lock(struct wined3d_device_vk
*device_vk
)
4288 EnterCriticalSection(&device_vk
->allocator_cs
);
4291 static inline void wined3d_device_vk_allocator_unlock(struct wined3d_device_vk
*device_vk
)
4293 LeaveCriticalSection(&device_vk
->allocator_cs
);
4296 bool wined3d_device_vk_create_null_resources(struct wined3d_device_vk
*device_vk
,
4297 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4298 bool wined3d_device_vk_create_null_views(struct wined3d_device_vk
*device_vk
,
4299 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4300 void wined3d_device_vk_destroy_null_resources(struct wined3d_device_vk
*device_vk
,
4301 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4302 void wined3d_device_vk_destroy_null_views(struct wined3d_device_vk
*device_vk
,
4303 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4305 void wined3d_device_vk_uav_clear_state_init(struct wined3d_device_vk
*device_vk
) DECLSPEC_HIDDEN
;
4306 void wined3d_device_vk_uav_clear_state_cleanup(struct wined3d_device_vk
*device_vk
) DECLSPEC_HIDDEN
;
4308 struct wined3d_device_gl
4310 struct wined3d_device d
;
4312 /* Textures for when no other textures are bound. */
4313 struct wined3d_dummy_textures dummy_textures
;
4315 CRITICAL_SECTION allocator_cs
;
4316 struct wined3d_allocator allocator
;
4317 uint64_t completed_fence_id
;
4318 uint64_t current_fence_id
;
4319 uint64_t retired_bo_size
;
4321 struct wined3d_retired_block_gl
4323 struct wined3d_allocator_block
*block
;
4326 SIZE_T retired_blocks_size
;
4327 SIZE_T retired_block_count
;
4333 static inline struct wined3d_device_gl
*wined3d_device_gl(struct wined3d_device
*device
)
4335 return CONTAINING_RECORD(device
, struct wined3d_device_gl
, d
);
4338 static inline struct wined3d_device_gl
*wined3d_device_gl_from_allocator(struct wined3d_allocator
*allocator
)
4340 return CONTAINING_RECORD(allocator
, struct wined3d_device_gl
, allocator
);
4343 static inline void wined3d_device_gl_allocator_lock(struct wined3d_device_gl
*device_gl
)
4345 EnterCriticalSection(&device_gl
->allocator_cs
);
4348 static inline void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl
*device_gl
)
4350 LeaveCriticalSection(&device_gl
->allocator_cs
);
4353 static inline void wined3d_allocator_chunk_gl_lock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
4355 wined3d_device_gl_allocator_lock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
4358 static inline void wined3d_allocator_chunk_gl_unlock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
4360 wined3d_device_gl_allocator_unlock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
4363 bool wined3d_device_gl_create_bo(struct wined3d_device_gl
*device_gl
,
4364 struct wined3d_context_gl
*context_gl
, GLsizeiptr size
, GLenum binding
,
4365 GLenum usage
, bool coherent
, GLbitfield flags
, struct wined3d_bo_gl
*bo
) DECLSPEC_HIDDEN
;
4366 void wined3d_device_gl_create_primary_opengl_context_cs(void *object
) DECLSPEC_HIDDEN
;
4367 void wined3d_device_gl_delete_opengl_contexts_cs(void *object
) DECLSPEC_HIDDEN
;
4368 HDC
wined3d_device_gl_get_backup_dc(struct wined3d_device_gl
*device_gl
) DECLSPEC_HIDDEN
;
4369 GLbitfield
wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx
) DECLSPEC_HIDDEN
;
4371 static inline float wined3d_alpha_ref(const struct wined3d_state
*state
)
4373 return (state
->render_states
[WINED3D_RS_ALPHAREF
] & 0xff) / 255.0f
;
4376 const char *wined3d_debug_resource_access(uint32_t access
) DECLSPEC_HIDDEN
;
4377 const char *wined3d_debug_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
4378 const char *wined3d_debug_view_desc(const struct wined3d_view_desc
*d
,
4379 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4380 const char *wined3d_debug_vkresult(VkResult vr
) DECLSPEC_HIDDEN
;
4382 static inline ULONG
wined3d_atomic_decrement_mutex_lock(volatile LONG
*refcount
)
4384 ULONG count
, old_count
= *refcount
;
4387 if ((count
= old_count
) == 1)
4389 wined3d_mutex_lock();
4390 count
= InterlockedDecrement(refcount
);
4391 if (count
) wined3d_mutex_unlock();
4395 old_count
= InterlockedCompareExchange(refcount
, count
- 1, count
);
4397 while (old_count
!= count
);
4402 #define CLIENT_BO_DISCARDED ((struct wined3d_bo *)~(UINT_PTR)0)
4404 struct wined3d_client_resource
4406 /* The resource's persistently mapped address, which we may use to perform
4407 * NOOVERWRITE maps from the client thread. */
4408 struct wined3d_bo_address addr
;
4410 /* The currently mapped upload BO, if applicable, and box. */
4411 struct upload_bo mapped_upload
;
4412 struct wined3d_box mapped_box
;
4415 static inline BOOL
wined3d_resource_access_is_managed(unsigned int access
)
4417 return !(~access
& (WINED3D_RESOURCE_ACCESS_GPU
| WINED3D_RESOURCE_ACCESS_CPU
));
4420 struct wined3d_resource_ops
4422 ULONG (*resource_incref
)(struct wined3d_resource
*resource
);
4423 ULONG (*resource_decref
)(struct wined3d_resource
*resource
);
4424 void (*resource_preload
)(struct wined3d_resource
*resource
);
4425 void (*resource_unload
)(struct wined3d_resource
*resource
);
4426 HRESULT (*resource_sub_resource_get_desc
)(struct wined3d_resource
*resource
,
4427 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
);
4428 void (*resource_sub_resource_get_map_pitch
)(struct wined3d_resource
*resource
,
4429 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
);
4430 HRESULT (*resource_sub_resource_map
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
4431 void **map_ptr
, const struct wined3d_box
*box
, uint32_t flags
);
4432 HRESULT (*resource_sub_resource_unmap
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
);
4435 struct wined3d_resource
4441 struct wined3d_device
*device
;
4442 enum wined3d_resource_type type
;
4443 enum wined3d_gl_resource_type gl_type
;
4444 const struct wined3d_format
*format
;
4445 unsigned int format_attrs
;
4446 unsigned int format_caps
;
4447 enum wined3d_multisample_type multisample_type
;
4448 UINT multisample_quality
;
4450 unsigned int bind_flags
;
4451 unsigned int access
;
4458 unsigned int priority
;
4461 uint32_t pin_sysmem
: 1;
4463 struct wined3d_client_resource client
;
4466 const struct wined3d_parent_ops
*parent_ops
;
4467 const struct wined3d_resource_ops
*resource_ops
;
4469 struct list resource_list_entry
;
4471 LONG srv_bind_count_device
;
4472 LONG rtv_bind_count_device
;
4475 static inline ULONG
wined3d_resource_incref(struct wined3d_resource
*resource
)
4477 return resource
->resource_ops
->resource_incref(resource
);
4480 static inline ULONG
wined3d_resource_decref(struct wined3d_resource
*resource
)
4482 return resource
->resource_ops
->resource_decref(resource
);
4485 static inline HRESULT
wined3d_resource_get_sub_resource_desc(struct wined3d_resource
*resource
,
4486 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
)
4488 return resource
->resource_ops
->resource_sub_resource_get_desc(resource
, sub_resource_idx
, desc
);
4491 static inline void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource
*resource
,
4492 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
)
4494 resource
->resource_ops
->resource_sub_resource_get_map_pitch(resource
, sub_resource_idx
, row_pitch
, slice_pitch
);
4497 void resource_cleanup(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4498 HRESULT
resource_init(struct wined3d_resource
*resource
, struct wined3d_device
*device
,
4499 enum wined3d_resource_type type
, const struct wined3d_format
*format
,
4500 enum wined3d_multisample_type multisample_type
, unsigned int multisample_quality
, unsigned int usage
,
4501 unsigned int bind_flags
, unsigned int access
, unsigned int width
, unsigned int height
, unsigned int depth
,
4502 unsigned int size
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
4503 const struct wined3d_resource_ops
*resource_ops
) DECLSPEC_HIDDEN
;
4504 void *resource_offset_map_pointer(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
4505 uint8_t *base_memory
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4506 void resource_unload(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4507 HRESULT
wined3d_resource_check_box_dimensions(struct wined3d_resource
*resource
,
4508 unsigned int sub_resource_idx
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4509 void wined3d_resource_free_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4510 const struct wined3d_format
*wined3d_resource_get_decompress_format(
4511 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4512 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4513 GLbitfield
wined3d_resource_gl_map_flags(const struct wined3d_bo_gl
*bo
, DWORD d3d_flags
) DECLSPEC_HIDDEN
;
4514 GLenum
wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags
) DECLSPEC_HIDDEN
;
4515 GLbitfield
wined3d_resource_gl_storage_flags(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4516 BOOL
wined3d_resource_is_offscreen(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4517 BOOL
wined3d_resource_prepare_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4518 void wined3d_resource_update_draw_binding(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4519 void wined3d_resource_memory_colour_fill(struct wined3d_resource
*resource
,
4520 const struct wined3d_map_desc
*map
, const struct wined3d_color
*colour
,
4521 const struct wined3d_box
*box
, bool full_subresource
) DECLSPEC_HIDDEN
;
4523 /* Tests show that the start address of resources is 32 byte aligned */
4524 #define RESOURCE_ALIGNMENT 16
4525 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
4527 #define WINED3D_LOCATION_DISCARDED 0x00000001
4528 #define WINED3D_LOCATION_SYSMEM 0x00000002
4529 #define WINED3D_LOCATION_CLEARED 0x00000004
4530 #define WINED3D_LOCATION_BUFFER 0x00000008
4531 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
4532 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
4533 #define WINED3D_LOCATION_DRAWABLE 0x00000040
4534 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
4535 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
4537 const char *wined3d_debug_location(uint32_t location
) DECLSPEC_HIDDEN
;
4539 struct wined3d_blt_info
4542 struct wined3d_vec3 texcoords
[4];
4545 struct wined3d_texture_ops
4547 BOOL (*texture_prepare_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4548 struct wined3d_context
*context
, unsigned int location
);
4549 BOOL (*texture_load_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4550 struct wined3d_context
*context
, unsigned int location
);
4551 void (*texture_unload_location
)(struct wined3d_texture
*texture
,
4552 struct wined3d_context
*context
, unsigned int location
);
4553 void (*texture_upload_data
)(struct wined3d_context
*context
, const struct wined3d_const_bo_address
*src_bo_addr
,
4554 const struct wined3d_format
*src_format
, const struct wined3d_box
*src_box
, unsigned int src_row_pitch
,
4555 unsigned int src_slice_pitch
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4556 unsigned int dst_location
, unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
);
4557 void (*texture_download_data
)(struct wined3d_context
*context
, struct wined3d_texture
*src_texture
,
4558 unsigned int src_sub_resource_idx
, unsigned int src_location
, const struct wined3d_box
*src_box
,
4559 const struct wined3d_bo_address
*dst_bo_addr
, const struct wined3d_format
*dst_format
,
4560 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
,
4561 unsigned int dst_row_pitch
, unsigned int dst_slice_pitch
);
4564 #define WINED3D_TEXTURE_COND_NP2 0x00000001
4565 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
4566 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
4567 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
4568 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
4569 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
4570 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
4571 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
4572 #define WINED3D_TEXTURE_CONVERTED 0x00000100
4573 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
4574 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
4575 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
4576 #define WINED3D_TEXTURE_DISCARD 0x00002000
4577 #define WINED3D_TEXTURE_GET_DC 0x00004000
4578 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
4579 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
4581 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
4583 struct wined3d_texture
4585 struct wined3d_resource resource
;
4586 const struct wined3d_texture_ops
*texture_ops
;
4587 struct wined3d_swapchain
*swapchain
;
4588 unsigned int pow2_width
;
4589 unsigned int pow2_height
;
4591 unsigned int level_count
;
4592 unsigned int download_count
;
4593 unsigned int sysmem_count
;
4594 float pow2_matrix
[16];
4598 DWORD update_map_binding
;
4600 unsigned int row_pitch
;
4601 unsigned int slice_pitch
;
4603 /* May only be accessed from the command stream worker thread. */
4604 struct wined3d_texture_async
4608 /* Color keys for DDraw */
4609 struct wined3d_color_key dst_blt_color_key
;
4610 struct wined3d_color_key src_blt_color_key
;
4611 struct wined3d_color_key dst_overlay_color_key
;
4612 struct wined3d_color_key src_overlay_color_key
;
4613 struct wined3d_color_key gl_color_key
;
4614 DWORD color_key_flags
;
4617 struct wined3d_dirty_regions
4619 struct wined3d_box
*boxes
;
4621 unsigned int box_count
;
4624 struct wined3d_overlay_info
4627 struct list overlays
;
4628 struct wined3d_texture
*dst_texture
;
4629 unsigned int dst_sub_resource_idx
;
4634 struct wined3d_dc_info
4640 struct wined3d_texture_sub_resource
4643 const struct wined3d_parent_ops
*parent_ops
;
4645 unsigned int offset
;
4648 unsigned int map_count
;
4651 struct wined3d_bo
*bo
;
4654 struct wined3d_color colour
;
4658 unsigned int stencil
;
4666 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s
, SIZE_T level_count
, SIZE_T layer_count
)
4668 struct wined3d_texture
*t
;
4670 if (level_count
> ((~(SIZE_T
)0 - s
) / sizeof(*t
->sub_resources
)) / layer_count
)
4673 return heap_alloc_zero(s
+ level_count
* layer_count
* sizeof(*t
->sub_resources
));
4676 static inline struct wined3d_texture
*texture_from_resource(struct wined3d_resource
*resource
)
4678 return CONTAINING_RECORD(resource
, struct wined3d_texture
, resource
);
4681 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture
*texture
,
4684 return max(1, texture
->resource
.width
>> level
);
4687 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture
*texture
,
4690 return max(1, texture
->resource
.height
>> level
);
4693 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture
*texture
,
4696 return max(1, texture
->resource
.depth
>> level
);
4699 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture
*texture
,
4702 return max(1, texture
->pow2_width
>> level
);
4705 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture
*texture
,
4708 return max(1, texture
->pow2_height
>> level
);
4711 static inline void wined3d_texture_get_level_box(const struct wined3d_texture
*texture
,
4712 unsigned int level
, struct wined3d_box
*box
)
4714 wined3d_box_set(box
, 0, 0,
4715 wined3d_texture_get_level_width(texture
, level
),
4716 wined3d_texture_get_level_height(texture
, level
),
4717 0, wined3d_texture_get_level_depth(texture
, level
));
4720 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture
*texture
,
4721 unsigned int level
, const RECT
*r
)
4725 t
= wined3d_texture_get_level_width(texture
, level
);
4726 if ((r
->left
&& r
->right
) || abs(r
->right
- r
->left
) != t
)
4728 t
= wined3d_texture_get_level_height(texture
, level
);
4729 if ((r
->top
&& r
->bottom
) || abs(r
->bottom
- r
->top
) != t
)
4734 HRESULT
texture2d_blt(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4735 const struct wined3d_box
*dst_box
, struct wined3d_texture
*src_texture
,
4736 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
, uint32_t flags
,
4737 const struct wined3d_blt_fx
*blt_fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
4738 void texture2d_get_blt_info(const struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
4739 const RECT
*rect
, struct wined3d_blt_info
*info
) DECLSPEC_HIDDEN
;
4740 void texture2d_load_fb_texture(struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
4741 BOOL srgb
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4742 void texture2d_read_from_framebuffer(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4743 struct wined3d_context
*context
, DWORD src_location
, DWORD dst_location
) DECLSPEC_HIDDEN
;
4745 void wined3d_texture_cleanup(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4746 void wined3d_texture_download_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4747 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
) DECLSPEC_HIDDEN
;
4748 void wined3d_texture_get_bo_address(const struct wined3d_texture
*texture
,
4749 unsigned int sub_resource_idx
, struct wined3d_bo_address
*data
, uint32_t location
) DECLSPEC_HIDDEN
;
4750 GLenum
wined3d_texture_get_gl_buffer(const struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4751 void wined3d_texture_invalidate_location(struct wined3d_texture
*texture
,
4752 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
4753 void wined3d_texture_load(struct wined3d_texture
*texture
,
4754 struct wined3d_context
*context
, BOOL srgb
) DECLSPEC_HIDDEN
;
4755 BOOL
wined3d_texture_load_location(struct wined3d_texture
*texture
,
4756 unsigned int sub_resource_idx
, struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4757 BOOL
wined3d_texture_prepare_location(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4758 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4759 void wined3d_texture_set_swapchain(struct wined3d_texture
*texture
,
4760 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4761 BOOL
wined3d_texture_can_use_pbo(const struct wined3d_texture
*texture
, const struct wined3d_d3d_info
*d3d_info
)
4763 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4764 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture
*texture
,
4765 HWND window
, RECT
*rect
) DECLSPEC_HIDDEN
;
4766 void wined3d_texture_update_sub_resource(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4767 struct wined3d_context
*context
, const struct upload_bo
*upload_bo
, const struct wined3d_box
*box
,
4768 unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
4769 void wined3d_texture_upload_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4770 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
, struct wined3d_texture
*src_texture
,
4771 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
) DECLSPEC_HIDDEN
;
4772 void wined3d_texture_validate_location(struct wined3d_texture
*texture
,
4773 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
4774 bool wined3d_texture_validate_sub_resource_idx(const struct wined3d_texture
*texture
,
4775 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
4776 void wined3d_texture_clear_dirty_regions(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4778 HRESULT
wined3d_texture_no3d_init(struct wined3d_texture
*texture_no3d
, struct wined3d_device
*device
,
4779 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
4780 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4782 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle
[4], struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
4783 void wined3d_vk_swizzle_from_color_fixup(VkComponentMapping
*mapping
, struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
4787 struct wined3d_sampler_desc sampler_desc
;
4788 unsigned int base_level
;
4792 struct wined3d_texture_gl
4794 struct wined3d_texture t
;
4796 struct gl_texture texture_rgb
, texture_srgb
;
4800 GLuint rb_multisample
;
4803 struct list renderbuffers
;
4804 const struct wined3d_renderbuffer_entry
*current_renderbuffer
;
4807 static inline struct wined3d_texture_gl
*wined3d_texture_gl(struct wined3d_texture
*texture
)
4809 return CONTAINING_RECORD(texture
, struct wined3d_texture_gl
, t
);
4812 static inline struct gl_texture
*wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl
*texture_gl
,
4815 return srgb
? &texture_gl
->texture_srgb
: &texture_gl
->texture_rgb
;
4818 static inline GLenum
wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl
*texture_gl
,
4819 unsigned int sub_resource_idx
)
4821 static const GLenum cube_targets
[] =
4823 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
,
4824 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
,
4825 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
,
4826 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
,
4827 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
,
4828 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
,
4831 return texture_gl
->t
.resource
.usage
& WINED3DUSAGE_LEGACY_CUBEMAP
4832 ? cube_targets
[sub_resource_idx
/ texture_gl
->t
.level_count
] : texture_gl
->target
;
4835 static inline BOOL
wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl
*texture_gl
,
4838 if (location
== WINED3D_LOCATION_RB_MULTISAMPLE
)
4840 if (location
!= WINED3D_LOCATION_TEXTURE_RGB
&& location
!= WINED3D_LOCATION_TEXTURE_SRGB
)
4842 return texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE
|| texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
;
4845 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl
*texture_gl
,
4846 const struct wined3d_sampler_desc
*sampler_desc
, const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4847 void wined3d_texture_gl_bind(struct wined3d_texture_gl
*texture_gl
,
4848 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
4849 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl
*texture_gl
,
4850 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
4851 HRESULT
wined3d_texture_gl_init(struct wined3d_texture_gl
*texture_gl
, struct wined3d_device
*device
,
4852 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
4853 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4854 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl
*texture_gl
,
4855 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
4856 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl
*texture_gl
,
4857 struct wined3d_context_gl
*context_gl
, unsigned int level
,
4858 const struct wined3d_rendertarget_info
*rt
) DECLSPEC_HIDDEN
;
4860 struct wined3d_texture_vk
4862 struct wined3d_texture t
;
4864 struct wined3d_image_vk image
;
4865 enum VkImageLayout layout
;
4868 VkDescriptorImageInfo default_image_info
;
4871 static inline struct wined3d_texture_vk
*wined3d_texture_vk(struct wined3d_texture
*texture
)
4873 return CONTAINING_RECORD(texture
, struct wined3d_texture_vk
, t
);
4876 void wined3d_texture_vk_barrier(struct wined3d_texture_vk
*texture_vk
,
4877 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
) DECLSPEC_HIDDEN
;
4878 const VkDescriptorImageInfo
*wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk
*texture_vk
,
4879 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4880 HRESULT
wined3d_texture_vk_init(struct wined3d_texture_vk
*texture_vk
, struct wined3d_device
*device
,
4881 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
4882 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4883 BOOL
wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk
*texture_vk
,
4884 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4886 struct wined3d_renderbuffer_entry
4894 struct wined3d_fbo_resource
4898 GLuint level
, layer
;
4901 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
4902 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
4903 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
4911 struct wined3d_fbo_entry_key
4914 struct wined3d_fbo_resource objects
[WINED3D_MAX_RENDER_TARGETS
+ 1];
4918 struct wined3d_sampler
4920 struct wine_rb_entry entry
;
4922 struct wined3d_device
*device
;
4924 const struct wined3d_parent_ops
*parent_ops
;
4925 struct wined3d_sampler_desc desc
;
4928 struct wined3d_sampler_gl
4930 struct wined3d_sampler s
;
4935 static inline struct wined3d_sampler_gl
*wined3d_sampler_gl(struct wined3d_sampler
*sampler
)
4937 return CONTAINING_RECORD(sampler
, struct wined3d_sampler_gl
, s
);
4940 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl
*sampler_gl
, unsigned int unit
,
4941 struct wined3d_texture_gl
*texture_gl
, const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4942 void wined3d_sampler_gl_init(struct wined3d_sampler_gl
*sampler_gl
,
4943 struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
4944 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4946 struct wined3d_sampler_vk
4948 struct wined3d_sampler s
;
4950 VkDescriptorImageInfo vk_image_info
;
4951 uint64_t command_buffer_id
;
4954 static inline struct wined3d_sampler_vk
*wined3d_sampler_vk(struct wined3d_sampler
*sampler
)
4956 return CONTAINING_RECORD(sampler
, struct wined3d_sampler_vk
, s
);
4959 void wined3d_sampler_vk_init(struct wined3d_sampler_vk
*sampler_vk
,
4960 struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
4961 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4963 struct wined3d_vertex_declaration_element
4965 const struct wined3d_format
*format
;
4967 unsigned int input_slot
;
4968 unsigned int offset
;
4969 unsigned int output_slot
;
4970 enum wined3d_input_classification input_slot_class
;
4971 unsigned int instance_data_step_rate
;
4977 struct wined3d_vertex_declaration
4981 const struct wined3d_parent_ops
*parent_ops
;
4982 struct wined3d_device
*device
;
4984 struct wined3d_vertex_declaration_element
*elements
;
4985 unsigned int element_count
;
4987 BOOL position_transformed
;
4990 struct wined3d_saved_states
4992 uint32_t vs_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F
)];
4993 WORD vertexShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
4994 WORD vertexShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
4995 uint32_t ps_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F
)];
4996 WORD pixelShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
4997 WORD pixelShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
4998 uint32_t transform
[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE
+ 1)];
4999 WORD streamSource
; /* WINED3D_MAX_STREAMS, 16 */
5000 WORD streamFreq
; /* WINED3D_MAX_STREAMS, 16 */
5001 uint32_t renderState
[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE
+ 1)];
5002 DWORD textureState
[WINED3D_MAX_TEXTURES
]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
5003 WORD samplerState
[WINED3D_MAX_COMBINED_SAMPLERS
]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
5004 DWORD clipplane
; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
5005 DWORD textures
: 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
5009 DWORD vertexDecl
: 1;
5010 DWORD pixelShader
: 1;
5011 DWORD vertexShader
: 1;
5012 DWORD scissorRect
: 1;
5013 DWORD store_stream_offset
: 1;
5014 DWORD alpha_to_coverage
: 1;
5016 DWORD transforms
: 1;
5025 struct wined3d_stateblock
5027 LONG ref
; /* Note: Ref counting not required */
5028 struct wined3d_device
*device
;
5030 /* Array indicating whether things have been set or changed */
5031 struct wined3d_saved_states changed
;
5033 struct wined3d_stateblock_state stateblock_state
;
5034 struct wined3d_light_state light_state
;
5036 /* Contained state management */
5037 DWORD contained_render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
5038 unsigned int num_contained_render_states
;
5039 DWORD contained_transform_states
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
5040 unsigned int num_contained_transform_states
;
5041 struct StageState contained_tss_states
[WINED3D_MAX_TEXTURES
* (WINED3D_HIGHEST_TEXTURE_STATE
+ 1)];
5042 unsigned int num_contained_tss_states
;
5043 struct StageState contained_sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
* WINED3D_HIGHEST_SAMPLER_STATE
];
5044 unsigned int num_contained_sampler_states
;
5047 void wined3d_stateblock_state_init(struct wined3d_stateblock_state
*state
,
5048 const struct wined3d_device
*device
, uint32_t flags
) DECLSPEC_HIDDEN
;
5049 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state
*state
) DECLSPEC_HIDDEN
;
5051 void wined3d_light_state_enable_light(struct wined3d_light_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
5052 struct wined3d_light_info
*light_info
, BOOL enable
) DECLSPEC_HIDDEN
;
5053 struct wined3d_light_info
*wined3d_light_state_get_light(const struct wined3d_light_state
*state
,
5054 unsigned int idx
) DECLSPEC_HIDDEN
;
5055 HRESULT
wined3d_light_state_set_light(struct wined3d_light_state
*state
, DWORD light_idx
,
5056 const struct wined3d_light
*params
, struct wined3d_light_info
**light_info
) DECLSPEC_HIDDEN
;
5058 enum wined3d_cs_queue_id
5060 WINED3D_CS_QUEUE_DEFAULT
= 0,
5061 WINED3D_CS_QUEUE_MAP
,
5062 WINED3D_CS_QUEUE_COUNT
,
5065 enum wined3d_push_constants
5067 WINED3D_PUSH_CONSTANTS_VS_F
,
5068 WINED3D_PUSH_CONSTANTS_PS_F
,
5069 WINED3D_PUSH_CONSTANTS_VS_I
,
5070 WINED3D_PUSH_CONSTANTS_PS_I
,
5071 WINED3D_PUSH_CONSTANTS_VS_B
,
5072 WINED3D_PUSH_CONSTANTS_PS_B
,
5075 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
5076 #define WINED3D_CS_QUEUE_SIZE 0x400000u
5077 #define WINED3D_CS_SPIN_COUNT 10000000u
5078 #define WINED3D_CS_QUEUE_MASK (WINED3D_CS_QUEUE_SIZE - 1)
5080 C_ASSERT(!(WINED3D_CS_QUEUE_SIZE
& (WINED3D_CS_QUEUE_SIZE
- 1)));
5082 struct wined3d_cs_queue
5085 BYTE data
[WINED3D_CS_QUEUE_SIZE
];
5088 struct wined3d_device_context_ops
5090 void *(*require_space
)(struct wined3d_device_context
*context
, size_t size
, enum wined3d_cs_queue_id queue_id
);
5091 void (*submit
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
5092 void (*finish
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
5093 void (*push_constants
)(struct wined3d_device_context
*context
, enum wined3d_push_constants p
,
5094 unsigned int start_idx
, unsigned int count
, const void *constants
);
5095 bool (*map_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
5096 unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
5097 const struct wined3d_box
*box
, uint32_t flags
);
5098 bool (*unmap_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
5099 unsigned int sub_resource_idx
, struct wined3d_box
*box
, struct upload_bo
*upload_bo
);
5100 void (*issue_query
)(struct wined3d_device_context
*context
, struct wined3d_query
*query
, unsigned int flags
);
5101 void (*flush
)(struct wined3d_device_context
*context
);
5102 void (*reference_resource
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
);
5103 void (*reference_command_list
)(struct wined3d_device_context
*context
, struct wined3d_command_list
*list
);
5106 struct wined3d_device_context
5108 const struct wined3d_device_context_ops
*ops
;
5109 struct wined3d_device
*device
;
5110 struct wined3d_state
*state
;
5115 struct wined3d_device_context c
;
5117 struct wined3d_state state
;
5118 HMODULE wined3d_module
;
5121 BOOL serialize_commands
;
5123 struct wined3d_cs_queue queue
[WINED3D_CS_QUEUE_COUNT
];
5124 size_t data_size
, start
, end
;
5126 struct list query_poll_list
;
5127 BOOL queries_flushed
;
5130 LONG waiting_for_event
;
5131 LONG pending_presents
;
5134 static inline void wined3d_device_context_lock(struct wined3d_device_context
*context
)
5136 if (context
== &context
->device
->cs
->c
)
5137 wined3d_mutex_lock();
5140 static inline void wined3d_device_context_unlock(struct wined3d_device_context
*context
)
5142 if (context
== &context
->device
->cs
->c
)
5143 wined3d_mutex_unlock();
5146 struct wined3d_cs
*wined3d_cs_create(struct wined3d_device
*device
,
5147 const enum wined3d_feature_level
*levels
, unsigned int level_count
) DECLSPEC_HIDDEN
;
5148 void wined3d_cs_destroy(struct wined3d_cs
*cs
) DECLSPEC_HIDDEN
;
5149 void wined3d_cs_destroy_object(struct wined3d_cs
*cs
,
5150 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
5151 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs
*cs
,
5152 struct wined3d_texture
*texture
, unsigned int layer
) DECLSPEC_HIDDEN
;
5153 void wined3d_cs_emit_clear(struct wined3d_cs
*cs
, DWORD rect_count
, const RECT
*rects
,
5154 uint32_t flags
, const struct wined3d_color
*color
, float depth
, DWORD stencil
) DECLSPEC_HIDDEN
;
5155 void wined3d_device_context_emit_clear_uav(struct wined3d_device_context
*context
,
5156 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
) DECLSPEC_HIDDEN
;
5157 void wined3d_cs_emit_preload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
5158 void wined3d_cs_emit_present(struct wined3d_cs
*cs
, struct wined3d_swapchain
*swapchain
, const RECT
*src_rect
,
5159 const RECT
*dst_rect
, HWND dst_window_override
, unsigned int swap_interval
, uint32_t flags
) DECLSPEC_HIDDEN
;
5160 void wined3d_cs_emit_set_color_key(struct wined3d_cs
*cs
, struct wined3d_texture
*texture
,
5161 WORD flags
, const struct wined3d_color_key
*color_key
) DECLSPEC_HIDDEN
;
5162 void wined3d_cs_emit_set_render_state(struct wined3d_cs
*cs
,
5163 enum wined3d_render_state state
, DWORD value
) DECLSPEC_HIDDEN
;
5164 void wined3d_cs_emit_unload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
5165 void wined3d_cs_init_object(struct wined3d_cs
*cs
,
5166 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
5167 void wined3d_cs_map_bo_address(struct wined3d_cs
*cs
,
5168 struct wined3d_bo_address
*addr
, size_t size
, unsigned int flags
) DECLSPEC_HIDDEN
;
5169 void wined3d_device_context_set_depth_bounds(struct wined3d_device_context
*context
,
5170 bool enable
, float min_depth
, float max_depth
);
5172 static inline void wined3d_cs_finish(struct wined3d_cs
*cs
, enum wined3d_cs_queue_id queue_id
)
5174 cs
->c
.ops
->finish(&cs
->c
, queue_id
);
5177 static inline void wined3d_device_context_push_constants(struct wined3d_device_context
*context
,
5178 enum wined3d_push_constants p
, unsigned int start_idx
, unsigned int count
, const void *constants
)
5180 context
->ops
->push_constants(context
, p
, start_idx
, count
, constants
);
5183 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
*context
,
5184 struct wined3d_resource
*dst_resource
, unsigned int dst_sub_resource_idx
, const struct wined3d_box
*dst_box
,
5185 struct wined3d_resource
*src_resource
, unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
,
5186 unsigned int flags
, const struct wined3d_blt_fx
*fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
5187 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context
*context
,
5188 struct wined3d_rendertarget_view
*view
, const RECT
*rect
, unsigned int flags
,
5189 const struct wined3d_color
*color
, float depth
, unsigned int stencil
) DECLSPEC_HIDDEN
;
5190 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context
*context
,
5191 struct wined3d_buffer
*dst_buffer
, unsigned int offset
,
5192 struct wined3d_unordered_access_view
*uav
) DECLSPEC_HIDDEN
;
5193 void wined3d_device_context_emit_draw(struct wined3d_device_context
*context
,
5194 enum wined3d_primitive_type primitive_type
, unsigned int patch_vertex_count
, int base_vertex_idx
,
5195 unsigned int start_idx
, unsigned int index_count
, unsigned int start_instance
, unsigned int instance_count
,
5196 bool indexed
) DECLSPEC_HIDDEN
;
5197 void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context
*context
,
5198 struct wined3d_command_list
*list
, bool restore_state
) DECLSPEC_HIDDEN
;
5199 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context
*context
,
5200 struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
5201 HRESULT
wined3d_device_context_emit_map(struct wined3d_device_context
*context
,
5202 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
5203 const struct wined3d_box
*box
, unsigned int flags
) DECLSPEC_HIDDEN
;
5204 void wined3d_device_context_emit_reset_state(struct wined3d_device_context
*context
, bool invalidate
) DECLSPEC_HIDDEN
;
5205 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context
*context
,
5206 struct wined3d_blend_state
*state
, const struct wined3d_color
*blend_factor
,
5207 unsigned int sample_mask
) DECLSPEC_HIDDEN
;
5208 void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context
*context
, unsigned int plane_idx
,
5209 const struct wined3d_vec4
*plane
) DECLSPEC_HIDDEN
;
5210 void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context
*context
,
5211 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
5212 const struct wined3d_constant_buffer_state
*buffers
) DECLSPEC_HIDDEN
;
5213 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context
*context
,
5214 struct wined3d_depth_stencil_state
*state
, unsigned int stencil_ref
) DECLSPEC_HIDDEN
;
5215 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context
*context
,
5216 struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
5217 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context
*context
,
5218 enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
5219 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context
*context
, struct wined3d_buffer
*buffer
,
5220 enum wined3d_format_id format_id
, unsigned int offset
) DECLSPEC_HIDDEN
;
5221 void wined3d_device_context_emit_set_light(struct wined3d_device_context
*context
,
5222 const struct wined3d_light_info
*light
) DECLSPEC_HIDDEN
;
5223 void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context
*context
, unsigned int idx
,
5224 BOOL enable
) DECLSPEC_HIDDEN
;
5225 void wined3d_device_context_emit_set_material(struct wined3d_device_context
*context
,
5226 const struct wined3d_material
*material
) DECLSPEC_HIDDEN
;
5227 void wined3d_device_context_emit_set_predication(struct wined3d_device_context
*context
,
5228 struct wined3d_query
*predicate
, BOOL value
) DECLSPEC_HIDDEN
;
5229 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context
*context
,
5230 struct wined3d_rasterizer_state
*rasterizer_state
) DECLSPEC_HIDDEN
;
5231 void wined3d_device_context_emit_set_render_state(struct wined3d_device_context
*context
,
5232 enum wined3d_render_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
5233 void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context
*context
, unsigned int start_idx
,
5234 unsigned int count
, struct wined3d_rendertarget_view
*const *views
) DECLSPEC_HIDDEN
;
5235 void wined3d_device_context_emit_set_samplers(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
5236 unsigned int start_idx
, unsigned int count
, struct wined3d_sampler
*const *samplers
) DECLSPEC_HIDDEN
;
5237 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context
*context
, unsigned int sampler_idx
,
5238 enum wined3d_sampler_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
5239 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context
*context
,
5240 unsigned int rect_count
, const RECT
*rects
) DECLSPEC_HIDDEN
;
5241 void wined3d_device_context_emit_set_shader(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
5242 struct wined3d_shader
*shader
) DECLSPEC_HIDDEN
;
5243 void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context
*context
,
5244 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
5245 struct wined3d_shader_resource_view
*const *views
) DECLSPEC_HIDDEN
;
5246 void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context
*context
,
5247 const struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
]) DECLSPEC_HIDDEN
;
5248 void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context
*context
,
5249 unsigned int start_idx
, unsigned int count
, const struct wined3d_stream_state
*streams
) DECLSPEC_HIDDEN
;
5250 void wined3d_device_context_emit_set_texture(struct wined3d_device_context
*context
, unsigned int stage
,
5251 struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
5252 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context
*context
, unsigned int stage
,
5253 enum wined3d_texture_stage_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
5254 void wined3d_device_context_emit_set_transform(struct wined3d_device_context
*context
,
5255 enum wined3d_transform_state state
, const struct wined3d_matrix
*matrix
) DECLSPEC_HIDDEN
;
5256 void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context
*context
,
5257 enum wined3d_pipeline pipeline
, unsigned int start_idx
, unsigned int count
,
5258 struct wined3d_unordered_access_view
*const *views
, const unsigned int *initial_count
) DECLSPEC_HIDDEN
;
5259 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context
*context
,
5260 struct wined3d_vertex_declaration
*declaration
) DECLSPEC_HIDDEN
;
5261 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context
*context
, unsigned int viewport_count
,
5262 const struct wined3d_viewport
*viewports
) DECLSPEC_HIDDEN
;
5263 void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context
*context
,
5264 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, const struct wined3d_box
*box
,
5265 const void *data
, unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
5266 HRESULT
wined3d_device_context_emit_unmap(struct wined3d_device_context
*context
,
5267 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
5269 static inline void wined3d_resource_reference(struct wined3d_resource
*resource
)
5271 const struct wined3d_cs
*cs
= resource
->device
->cs
;
5272 resource
->access_time
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
5275 static inline BOOL
wined3d_ge_wrap(ULONG x
, ULONG y
)
5277 return (x
- y
) < UINT_MAX
/ 2;
5279 C_ASSERT(WINED3D_CS_QUEUE_SIZE
< UINT_MAX
/ 4);
5281 static inline void wined3d_resource_wait_idle(const struct wined3d_resource
*resource
)
5283 const struct wined3d_cs
*cs
= resource
->device
->cs
;
5284 ULONG access_time
, tail
, head
;
5286 if (!cs
->thread
|| cs
->thread_id
== GetCurrentThreadId())
5289 access_time
= resource
->access_time
;
5290 head
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
5292 /* The basic idea is that a resource is busy if tail < access_time <= head.
5293 * But we have to be careful about wrap-around of the head and tail. The
5294 * wined3d_ge_wrap function considers x >= y if x - y is smaller than half the
5295 * UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because
5296 * otherwise the queue memory is considered full and queue_require_space
5297 * stalls. Thus wined3d_ge_wrap(head, tail) is always true. The C_ASSERT above
5298 * ensures this in case we decide to grow the queue size in the future.
5300 * It is possible that a resource has not been used for a long time and is idle, but the head and
5301 * tail wrapped around in such a way that the previously set access time falls between head and tail.
5302 * In this case we will incorrectly wait for the resource. Because we use the entire 32 bits of the
5303 * counters and not just the bits needed to address the actual queue memory, this should happen rarely.
5304 * If it turns out to be a problem we can switch to 64 bit counters or attempt to somehow mark the
5305 * access time of resources invalid. CS packets are at least 4 byte aligned, so we could use the lower
5306 * 2 bits in access_time for such a marker.
5308 * Note that the access time is set before the command is submitted, so we have to wait until the
5309 * tail is bigger than access_time, not equal. */
5311 if (!wined3d_ge_wrap(head
, access_time
))
5316 tail
= *(volatile ULONG
*)&cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].tail
;
5317 if (head
== tail
) /* Queue empty. */
5320 if (!wined3d_ge_wrap(access_time
, tail
) && access_time
!= tail
)
5327 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
5328 * fixed function semantics as D3DCOLOR or FLOAT16 */
5329 enum wined3d_buffer_conversion_type
5336 struct wined3d_buffer
5338 struct wined3d_resource resource
;
5339 const struct wined3d_buffer_ops
*buffer_ops
;
5341 unsigned int structure_byte_stride
;
5345 struct wined3d_bo
*buffer_object
;
5346 struct wined3d_bo_user bo_user
;
5348 struct wined3d_range
*maps
;
5349 SIZE_T maps_size
, modified_areas
;
5351 /* conversion stuff */
5352 UINT decl_change_count
, full_conversion_count
;
5354 UINT stride
; /* 0 if no conversion */
5355 enum wined3d_buffer_conversion_type
*conversion_map
; /* NULL if no conversion */
5356 UINT conversion_stride
; /* 0 if no shifted conversion */
5359 static inline struct wined3d_buffer
*buffer_from_resource(struct wined3d_resource
*resource
)
5361 return CONTAINING_RECORD(resource
, struct wined3d_buffer
, resource
);
5364 void wined3d_buffer_cleanup(struct wined3d_buffer
*buffer
) DECLSPEC_HIDDEN
;
5365 void wined3d_buffer_copy(struct wined3d_buffer
*dst_buffer
, unsigned int dst_offset
,
5366 struct wined3d_buffer
*src_buffer
, unsigned int src_offset
, unsigned int size
) DECLSPEC_HIDDEN
;
5367 void wined3d_buffer_copy_bo_address(struct wined3d_buffer
*dst_buffer
, struct wined3d_context
*context
,
5368 unsigned int dst_offset
, const struct wined3d_const_bo_address
*src_addr
, unsigned int size
) DECLSPEC_HIDDEN
;
5369 DWORD
wined3d_buffer_get_memory(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
5370 struct wined3d_bo_address
*data
) DECLSPEC_HIDDEN
;
5371 void wined3d_buffer_invalidate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
5372 void wined3d_buffer_load(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
5373 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
5374 BOOL
wined3d_buffer_load_location(struct wined3d_buffer
*buffer
,
5375 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
5376 BYTE
*wined3d_buffer_load_sysmem(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
5377 BOOL
wined3d_buffer_prepare_location(struct wined3d_buffer
*buffer
,
5378 struct wined3d_context
*context
, unsigned int location
) DECLSPEC_HIDDEN
;
5379 void wined3d_buffer_update_sub_resource(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
5380 const struct upload_bo
*upload_bo
, unsigned int offset
, unsigned int size
) DECLSPEC_HIDDEN
;
5382 HRESULT
wined3d_buffer_no3d_init(struct wined3d_buffer
*buffer_no3d
, struct wined3d_device
*device
,
5383 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
5384 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5386 struct wined3d_buffer_gl
5388 struct wined3d_buffer b
;
5391 static inline struct wined3d_buffer_gl
*wined3d_buffer_gl(struct wined3d_buffer
*buffer
)
5393 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
5396 static inline const struct wined3d_buffer_gl
*wined3d_buffer_gl_const(const struct wined3d_buffer
*buffer
)
5398 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
5401 GLenum
wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info
*gl_info
,
5402 uint32_t bind_flags
) DECLSPEC_HIDDEN
;
5403 HRESULT
wined3d_buffer_gl_init(struct wined3d_buffer_gl
*buffer_gl
, struct wined3d_device
*device
,
5404 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
5405 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5407 struct wined3d_buffer_vk
5409 struct wined3d_buffer b
;
5411 VkDescriptorBufferInfo buffer_info
;
5415 static inline struct wined3d_buffer_vk
*wined3d_buffer_vk(struct wined3d_buffer
*buffer
)
5417 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_vk
, b
);
5420 void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk
*buffer_vk
,
5421 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
) DECLSPEC_HIDDEN
;
5422 const VkDescriptorBufferInfo
*wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk
*buffer_vk
) DECLSPEC_HIDDEN
;
5423 HRESULT
wined3d_buffer_vk_init(struct wined3d_buffer_vk
*buffer_vk
, struct wined3d_device
*device
,
5424 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
5425 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5427 static inline void wined3d_resource_vk_barrier(struct wined3d_resource
*resource
,
5428 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
)
5430 if (resource
->type
== WINED3D_RTYPE_BUFFER
)
5431 wined3d_buffer_vk_barrier(wined3d_buffer_vk(buffer_from_resource(resource
)), context_vk
, bind_mask
);
5433 wined3d_texture_vk_barrier(wined3d_texture_vk(texture_from_resource(resource
)), context_vk
, bind_mask
);
5436 struct wined3d_rendertarget_view
5440 struct wined3d_resource
*resource
;
5442 const struct wined3d_parent_ops
*parent_ops
;
5444 const struct wined3d_format
*format
;
5445 unsigned int format_attrs
;
5446 unsigned int format_caps
;
5447 unsigned int sub_resource_idx
;
5448 unsigned int layer_count
;
5451 unsigned int height
;
5453 struct wined3d_view_desc desc
;
5456 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
5457 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view
*view
,
5458 const struct wined3d_context
*context
, unsigned int *width
, unsigned int *height
) DECLSPEC_HIDDEN
;
5459 void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view
*view
,
5460 struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
5461 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view
*view
,
5462 uint32_t location
) DECLSPEC_HIDDEN
;
5463 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view
*view
,
5464 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
5465 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view
*view
,
5466 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
5467 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view
*view
,
5468 uint32_t location
) DECLSPEC_HIDDEN
;
5469 DWORD
wined3d_rendertarget_view_get_locations(const struct wined3d_rendertarget_view
*view
)
5472 HRESULT
wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view
*view_no3d
,
5473 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5474 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5476 struct wined3d_rendertarget_view_gl
5478 struct wined3d_rendertarget_view v
;
5479 struct wined3d_gl_view gl_view
;
5482 static inline struct wined3d_rendertarget_view_gl
*wined3d_rendertarget_view_gl(
5483 struct wined3d_rendertarget_view
*view
)
5485 return CONTAINING_RECORD(view
, struct wined3d_rendertarget_view_gl
, v
);
5488 HRESULT
wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl
*view_gl
,
5489 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5490 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5492 struct wined3d_rendertarget_view_vk
5494 struct wined3d_rendertarget_view v
;
5496 VkImageView vk_image_view
;
5497 uint64_t command_buffer_id
;
5500 static inline struct wined3d_rendertarget_view_vk
*wined3d_rendertarget_view_vk(
5501 struct wined3d_rendertarget_view
*view
)
5503 return CONTAINING_RECORD(view
, struct wined3d_rendertarget_view_vk
, v
);
5506 static inline void wined3d_rendertarget_view_vk_barrier(struct wined3d_rendertarget_view_vk
*rtv_vk
,
5507 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
)
5509 wined3d_resource_vk_barrier(rtv_vk
->v
.resource
, context_vk
, bind_mask
);
5512 static inline VkImageView
wined3d_rendertarget_view_vk_get_image_view(struct wined3d_rendertarget_view_vk
*rtv_vk
,
5513 struct wined3d_context_vk
*context_vk
)
5515 struct wined3d_texture_vk
*texture_vk
;
5517 if (rtv_vk
->vk_image_view
)
5518 return rtv_vk
->vk_image_view
;
5520 texture_vk
= wined3d_texture_vk(wined3d_texture_from_resource(rtv_vk
->v
.resource
));
5521 return wined3d_texture_vk_get_default_image_info(texture_vk
, context_vk
)->imageView
;
5524 HRESULT
wined3d_rendertarget_view_vk_init(struct wined3d_rendertarget_view_vk
*view_vk
,
5525 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5526 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5528 struct wined3d_shader_resource_view
5532 struct wined3d_resource
*resource
;
5534 const struct wined3d_parent_ops
*parent_ops
;
5536 const struct wined3d_format
*format
;
5538 struct wined3d_view_desc desc
;
5541 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
5543 struct wined3d_shader_resource_view_gl
5545 struct wined3d_shader_resource_view v
;
5546 struct wined3d_bo_user bo_user
;
5547 struct wined3d_gl_view gl_view
;
5550 static inline struct wined3d_shader_resource_view_gl
*wined3d_shader_resource_view_gl(
5551 struct wined3d_shader_resource_view
*view
)
5553 return CONTAINING_RECORD(view
, struct wined3d_shader_resource_view_gl
, v
);
5556 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
*view_gl
, unsigned int unit
,
5557 struct wined3d_sampler_gl
*sampler_gl
, struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
5558 void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl
*srv_gl
,
5559 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
5560 HRESULT
wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl
*view_gl
,
5561 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5562 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5563 void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl
*srv_gl
,
5564 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
5566 struct wined3d_view_vk
5568 struct wined3d_bo_user bo_user
;
5571 VkBufferView vk_buffer_view
;
5572 VkDescriptorImageInfo vk_image_info
;
5574 uint64_t command_buffer_id
;
5577 struct wined3d_shader_resource_view_vk
5579 struct wined3d_shader_resource_view v
;
5580 struct wined3d_view_vk view_vk
;
5583 static inline struct wined3d_shader_resource_view_vk
*wined3d_shader_resource_view_vk(
5584 struct wined3d_shader_resource_view
*view
)
5586 return CONTAINING_RECORD(view
, struct wined3d_shader_resource_view_vk
, v
);
5589 static inline void wined3d_shader_resource_view_vk_barrier(struct wined3d_shader_resource_view_vk
*srv_vk
,
5590 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
)
5592 wined3d_resource_vk_barrier(srv_vk
->v
.resource
, context_vk
, bind_mask
);
5595 void wined3d_shader_resource_view_vk_generate_mipmap(struct wined3d_shader_resource_view_vk
*srv_vk
,
5596 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
5597 HRESULT
wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk
*view_vk
,
5598 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5599 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5600 void wined3d_shader_resource_view_vk_update(struct wined3d_shader_resource_view_vk
*view_vk
,
5601 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
5603 struct wined3d_unordered_access_view
5607 struct wined3d_resource
*resource
;
5609 const struct wined3d_parent_ops
*parent_ops
;
5611 const struct wined3d_format
*format
;
5613 struct wined3d_view_desc desc
;
5614 struct wined3d_bo
*counter_bo
;
5617 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view
*view
) DECLSPEC_HIDDEN
;
5618 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view
*view
,
5619 struct wined3d_buffer
*buffer
, unsigned int offset
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
5620 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view
*view
,
5621 uint32_t location
) DECLSPEC_HIDDEN
;
5622 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view
*view
,
5623 unsigned int value
) DECLSPEC_HIDDEN
;
5625 struct wined3d_unordered_access_view_gl
5627 struct wined3d_unordered_access_view v
;
5628 struct wined3d_bo_user bo_user
;
5629 struct wined3d_gl_view gl_view
;
5630 struct wined3d_bo_gl counter_bo
;
5633 static inline struct wined3d_unordered_access_view_gl
*wined3d_unordered_access_view_gl(
5634 struct wined3d_unordered_access_view
*view
)
5636 return CONTAINING_RECORD(view
, struct wined3d_unordered_access_view_gl
, v
);
5639 void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view_gl
*view_gl
,
5640 const struct wined3d_uvec4
*clear_value
, struct wined3d_context_gl
*context_gl
, bool fp
) DECLSPEC_HIDDEN
;
5641 HRESULT
wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl
*view_gl
,
5642 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5643 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5644 void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl
*uav_gl
,
5645 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
5647 struct wined3d_unordered_access_view_vk
5649 struct wined3d_unordered_access_view v
;
5650 struct wined3d_view_vk view_vk
;
5652 VkBufferView vk_counter_view
;
5653 struct wined3d_bo_vk counter_bo
;
5656 static inline struct wined3d_unordered_access_view_vk
*wined3d_unordered_access_view_vk(
5657 struct wined3d_unordered_access_view
*view
)
5659 return CONTAINING_RECORD(view
, struct wined3d_unordered_access_view_vk
, v
);
5662 static inline void wined3d_unordered_access_view_vk_barrier(struct wined3d_unordered_access_view_vk
*uav_vk
,
5663 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
)
5665 wined3d_resource_vk_barrier(uav_vk
->v
.resource
, context_vk
, bind_mask
);
5668 void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view_vk
*view_vk
,
5669 const struct wined3d_uvec4
*clear_value
, struct wined3d_context_vk
*context_vk
, bool fp
) DECLSPEC_HIDDEN
;
5670 HRESULT
wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk
*view_vk
,
5671 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
5672 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5673 void wined3d_unordered_access_view_vk_update(struct wined3d_unordered_access_view_vk
*view_vk
,
5674 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
5676 struct wined3d_swapchain_state
5678 struct wined3d
*wined3d
;
5679 struct wined3d_swapchain_desc desc
;
5680 struct wined3d_swapchain_state_parent
*parent
;
5682 struct wined3d_display_mode original_mode
, d3d_mode
;
5683 RECT original_window_rect
;
5685 /* Window styles to restore when switching fullscreen mode. */
5691 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
5692 void wined3d_swapchain_state_register(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
5693 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state
*state
,
5694 HWND window
, const RECT
*window_rect
) DECLSPEC_HIDDEN
;
5695 HRESULT
wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
*state
,
5696 HWND window
, int x
, int y
, int width
, int height
) DECLSPEC_HIDDEN
;
5698 struct wined3d_swapchain_ops
5700 void (*swapchain_present
)(struct wined3d_swapchain
*swapchain
,
5701 const RECT
*src_rect
, const RECT
*dst_rect
, unsigned int swap_interval
, uint32_t flags
);
5702 void (*swapchain_frontbuffer_updated
)(struct wined3d_swapchain
*swapchain
);
5705 struct wined3d_swapchain
5709 const struct wined3d_parent_ops
*parent_ops
;
5710 const struct wined3d_swapchain_ops
*swapchain_ops
;
5711 struct wined3d_device
*device
;
5713 struct wined3d_texture
**back_buffers
;
5714 struct wined3d_texture
*front_buffer
;
5715 struct wined3d_gamma_ramp orig_gamma
;
5717 const struct wined3d_format
*ds_format
;
5718 struct wined3d_palette
*palette
;
5719 RECT front_buffer_update
;
5720 unsigned int swap_interval
;
5721 unsigned int max_frame_latency
;
5723 LONG prev_time
, frames
; /* Performance tracking */
5725 struct wined3d_swapchain_state state
;
5729 void wined3d_swapchain_activate(struct wined3d_swapchain
*swapchain
, BOOL activate
) DECLSPEC_HIDDEN
;
5730 void wined3d_swapchain_cleanup(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
5731 struct wined3d_output
* wined3d_swapchain_get_output(const struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
5732 void swapchain_update_draw_bindings(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
5733 void swapchain_set_max_frame_latency(struct wined3d_swapchain
*swapchain
,
5734 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
5736 HRESULT
wined3d_swapchain_no3d_init(struct wined3d_swapchain
*swapchain_no3d
,
5737 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
5738 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
5739 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5741 struct wined3d_swapchain_gl
5743 struct wined3d_swapchain s
;
5746 static inline struct wined3d_swapchain_gl
*wined3d_swapchain_gl(struct wined3d_swapchain
*swapchain
)
5748 return CONTAINING_RECORD(swapchain
, struct wined3d_swapchain_gl
, s
);
5751 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
5752 struct wined3d_context_gl
*wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
5753 HRESULT
wined3d_swapchain_gl_init(struct wined3d_swapchain_gl
*swapchain_gl
,
5754 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
5755 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
5756 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5758 struct wined3d_swapchain_vk
5760 struct wined3d_swapchain s
;
5762 VkSwapchainKHR vk_swapchain
;
5763 VkSurfaceKHR vk_surface
;
5767 VkSemaphore available
;
5768 VkSemaphore presentable
;
5769 uint64_t command_buffer_id
;
5771 unsigned int current
, image_count
;
5772 unsigned int width
, height
;
5775 static inline struct wined3d_swapchain_vk
*wined3d_swapchain_vk(struct wined3d_swapchain
*swapchain
)
5777 return CONTAINING_RECORD(swapchain
, struct wined3d_swapchain_vk
, s
);
5780 void wined3d_swapchain_vk_cleanup(struct wined3d_swapchain_vk
*swapchain_vk
) DECLSPEC_HIDDEN
;
5781 HRESULT
wined3d_swapchain_vk_init(struct wined3d_swapchain_vk
*swapchain_vk
,
5782 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
5783 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
5784 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5786 /*****************************************************************************
5787 * Utility function prototypes
5790 /* Trace routines */
5791 const char *debug_bo_address(const struct wined3d_bo_address
*address
) DECLSPEC_HIDDEN
;
5792 const char *debug_box(const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
5793 const char *debug_color(const struct wined3d_color
*color
) DECLSPEC_HIDDEN
;
5794 const char *debug_const_bo_address(const struct wined3d_const_bo_address
*address
) DECLSPEC_HIDDEN
;
5795 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
) DECLSPEC_HIDDEN
;
5796 const char *debug_d3dformat(enum wined3d_format_id format_id
) DECLSPEC_HIDDEN
;
5797 const char *debug_d3ddevicetype(enum wined3d_device_type device_type
) DECLSPEC_HIDDEN
;
5798 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type
) DECLSPEC_HIDDEN
;
5799 const char *debug_d3dusage(uint32_t usage
) DECLSPEC_HIDDEN
;
5800 const char *debug_d3ddeclmethod(enum wined3d_decl_method method
) DECLSPEC_HIDDEN
;
5801 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
5802 const char *debug_d3dinput_classification(enum wined3d_input_classification classification
) DECLSPEC_HIDDEN
;
5803 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type
) DECLSPEC_HIDDEN
;
5804 const char *debug_d3drenderstate(enum wined3d_render_state state
) DECLSPEC_HIDDEN
;
5805 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state
) DECLSPEC_HIDDEN
;
5806 const char *debug_d3dstate(uint32_t state
) DECLSPEC_HIDDEN
;
5807 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type
) DECLSPEC_HIDDEN
;
5808 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state
) DECLSPEC_HIDDEN
;
5809 const char *debug_d3dtop(enum wined3d_texture_op d3dtop
) DECLSPEC_HIDDEN
;
5810 const char *debug_d3dtstype(enum wined3d_transform_state tstype
) DECLSPEC_HIDDEN
;
5811 const char *debug_fboattachment(GLenum attachment
) DECLSPEC_HIDDEN
;
5812 const char *debug_fbostatus(GLenum status
) DECLSPEC_HIDDEN
;
5813 const char *debug_glerror(GLenum error
) DECLSPEC_HIDDEN
;
5814 const char *debug_ivec4(const struct wined3d_ivec4
*v
) DECLSPEC_HIDDEN
;
5815 const char *debug_uvec4(const struct wined3d_uvec4
*v
) DECLSPEC_HIDDEN
;
5816 const char *debug_shader_type(enum wined3d_shader_type shader_type
) DECLSPEC_HIDDEN
;
5817 const char *debug_vec4(const struct wined3d_vec4
*v
) DECLSPEC_HIDDEN
;
5818 const char *wined3d_debug_feature_level(enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
5819 void dump_color_fixup_desc(struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
5821 BOOL
is_invalid_op(const struct wined3d_state
*state
, int stage
,
5822 enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
) DECLSPEC_HIDDEN
;
5823 void set_tex_op_nvrc(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
5824 BOOL is_alpha
, int stage
, enum wined3d_texture_op op
, uint32_t arg1
, uint32_t arg2
, uint32_t arg3
,
5825 INT texture_idx
, DWORD dst
) DECLSPEC_HIDDEN
;
5826 void texture_activate_dimensions(struct wined3d_texture
*texture
,
5827 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
5828 void sampler_texdim(struct wined3d_context
*context
,
5829 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5830 void tex_alphaop(struct wined3d_context
*context
,
5831 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5832 void apply_pixelshader(struct wined3d_context
*context
,
5833 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5834 void state_alpha_test(struct wined3d_context
*context
,
5835 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5836 void state_fogcolor(struct wined3d_context
*context
,
5837 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5838 void state_fogdensity(struct wined3d_context
*context
,
5839 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5840 void state_fogstartend(struct wined3d_context
*context
,
5841 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5842 void state_fog_fragpart(struct wined3d_context
*context
,
5843 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5844 void state_nop(struct wined3d_context
*context
,
5845 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5846 void state_srgbwrite(struct wined3d_context
*context
,
5847 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5849 void state_clipping(struct wined3d_context
*context
,
5850 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5851 void clipplane(struct wined3d_context
*context
,
5852 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5853 void state_pointsprite_w(struct wined3d_context
*context
,
5854 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5855 void state_pointsprite(struct wined3d_context
*context
,
5856 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5857 void state_shademode(struct wined3d_context
*context
,
5858 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5861 void multiply_matrix(struct wined3d_matrix
*dest
, const struct wined3d_matrix
*src1
,
5862 const struct wined3d_matrix
*src2
) DECLSPEC_HIDDEN
;
5864 void wined3d_release_dc(HWND window
, HDC dc
) DECLSPEC_HIDDEN
;
5866 struct wined3d_shader_lconst
5870 unsigned int value
[4];
5873 struct wined3d_shader_limits
5875 unsigned int sampler
;
5876 unsigned int constant_int
;
5877 unsigned int constant_float
;
5878 unsigned int constant_bool
;
5879 unsigned int packed_output
;
5880 unsigned int packed_input
;
5883 #define wined3d_lock_init(lock, name) wined3d_lock_init_(lock, __FILE__ ": " name)
5884 static inline void wined3d_lock_init_(CRITICAL_SECTION
*lock
, const char *name
)
5886 InitializeCriticalSection(lock
);
5887 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
5888 lock
->DebugInfo
->Spare
[0] = (DWORD_PTR
)name
;
5891 static inline void wined3d_lock_cleanup(CRITICAL_SECTION
*lock
)
5893 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
5894 lock
->DebugInfo
->Spare
[0] = 0;
5895 DeleteCriticalSection(lock
);
5899 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
5901 #define PRINTF_ATTR(fmt,args)
5904 struct wined3d_string_buffer_list
5909 struct wined3d_string_buffer
*string_buffer_get(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
5910 void string_buffer_sprintf(struct wined3d_string_buffer
*buffer
, const char *format
, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN
;
5911 void string_buffer_release(struct wined3d_string_buffer_list
*list
, struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
5912 void string_buffer_list_init(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
5913 void string_buffer_list_cleanup(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
5915 int shader_addline(struct wined3d_string_buffer
*buffer
, const char *fmt
, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN
;
5916 BOOL
string_buffer_resize(struct wined3d_string_buffer
*buffer
, int rc
) DECLSPEC_HIDDEN
;
5917 int shader_vaddline(struct wined3d_string_buffer
*buffer
, const char *fmt
, va_list args
) DECLSPEC_HIDDEN
;
5919 struct wined3d_shader_phase
5923 unsigned int instance_count
;
5924 unsigned int temporary_count
;
5927 struct wined3d_vertex_shader
5929 struct wined3d_shader_attribute attributes
[MAX_ATTRIBS
];
5932 struct wined3d_hull_shader
5936 struct wined3d_shader_phase
*control_point
;
5937 unsigned int fork_count
;
5938 unsigned int join_count
;
5939 struct wined3d_shader_phase
*fork
;
5941 struct wined3d_shader_phase
*join
;
5944 unsigned int output_vertex_count
;
5945 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
5946 enum wined3d_tessellator_partitioning tessellator_partitioning
;
5949 struct wined3d_domain_shader
5951 enum wined3d_tessellator_domain tessellator_domain
;
5954 struct wined3d_geometry_shader
5956 enum wined3d_primitive_type input_type
;
5957 enum wined3d_primitive_type output_type
;
5958 unsigned int vertices_out
;
5959 unsigned int instance_count
;
5961 const struct wined3d_stream_output_desc
*so_desc
;
5964 struct wined3d_pixel_shader
5966 /* Pixel shader input semantics */
5967 unsigned int input_reg_map
[MAX_REG_INPUT
];
5968 DWORD input_reg_used
; /* MAX_REG_INPUT, 32 */
5969 unsigned int declared_in_count
;
5971 /* Some information about the shader behavior */
5973 unsigned int color0_reg
;
5975 BOOL force_early_depth_stencil
;
5976 enum wined3d_shader_register_type depth_output
;
5977 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
5980 struct wined3d_compute_shader
5982 struct wined3d_shader_thread_group_size thread_group_size
;
5985 struct wined3d_shader
5988 const struct wined3d_shader_limits
*limits
;
5989 const DWORD
*function
;
5990 unsigned int functionLength
;
5992 unsigned int byte_code_size
;
5993 BOOL load_local_constsF
;
5994 const struct wined3d_shader_frontend
*frontend
;
5995 void *frontend_data
;
5999 const struct wined3d_parent_ops
*parent_ops
;
6001 /* Programs this shader is linked with */
6002 struct list linked_programs
;
6004 /* Immediate constants (override global ones) */
6005 struct list constantsB
;
6006 struct list constantsF
;
6007 struct list constantsI
;
6008 struct wined3d_shader_reg_maps reg_maps
;
6009 BOOL lconst_inf_or_nan
;
6011 struct wined3d_shader_signature input_signature
;
6012 struct wined3d_shader_signature output_signature
;
6013 struct wined3d_shader_signature patch_constant_signature
;
6015 /* Pointer to the parent device */
6016 struct wined3d_device
*device
;
6017 struct list shader_list_entry
;
6021 struct wined3d_vertex_shader vs
;
6022 struct wined3d_hull_shader hs
;
6023 struct wined3d_domain_shader ds
;
6024 struct wined3d_geometry_shader gs
;
6025 struct wined3d_pixel_shader ps
;
6026 struct wined3d_compute_shader cs
;
6030 enum wined3d_shader_resource_type
pixelshader_get_resource_type(const struct wined3d_shader_reg_maps
*reg_maps
,
6031 unsigned int resource_idx
, DWORD tex_types
) DECLSPEC_HIDDEN
;
6032 void find_ps_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
6033 BOOL position_transformed
, struct ps_compile_args
*args
,
6034 const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
6036 bool vshader_get_input(const struct wined3d_shader
*shader
,
6037 uint8_t usage_req
, uint8_t usage_idx_req
, unsigned int *regnum
) DECLSPEC_HIDDEN
;
6038 void find_vs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
6039 struct vs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
6041 void find_ds_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
6042 struct ds_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
6044 void find_gs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
6045 struct gs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
6047 void string_buffer_clear(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
6048 BOOL
string_buffer_init(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
6049 void string_buffer_free(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
6050 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps
*reg_maps
,
6051 unsigned int max
) DECLSPEC_HIDDEN
;
6052 HRESULT
shader_generate_code(const struct wined3d_shader
*shader
, struct wined3d_string_buffer
*buffer
,
6053 const struct wined3d_shader_reg_maps
*reg_maps
, void *backend_ctx
,
6054 const DWORD
*start
, const DWORD
*end
) DECLSPEC_HIDDEN
;
6055 BOOL
shader_match_semantic(const char *semantic_name
, enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
6057 static inline BOOL
shader_is_scalar(const struct wined3d_shader_register
*reg
)
6061 case WINED3DSPR_RASTOUT
:
6063 if (reg
->idx
[0].offset
)
6068 case WINED3DSPR_CONSTBOOL
: /* b# */
6069 case WINED3DSPR_DEPTHOUT
: /* oDepth */
6070 case WINED3DSPR_DEPTHOUTGE
:
6071 case WINED3DSPR_DEPTHOUTLE
:
6072 case WINED3DSPR_LOOP
: /* aL */
6073 case WINED3DSPR_OUTPOINTID
:
6074 case WINED3DSPR_PREDICATE
: /* p0 */
6075 case WINED3DSPR_PRIMID
: /* primID */
6076 case WINED3DSPR_COVERAGE
: /* vCoverage */
6077 case WINED3DSPR_SAMPLEMASK
: /* oMask */
6080 case WINED3DSPR_MISCTYPE
:
6081 switch (reg
->idx
[0].offset
)
6091 case WINED3DSPR_IMMCONST
:
6092 return reg
->immconst_type
== WINED3D_IMMCONST_SCALAR
;
6099 static inline void shader_get_position_fixup(const struct wined3d_context
*context
,
6100 const struct wined3d_state
*state
, unsigned int fixup_count
, float *position_fixup
)
6102 float center_offset
, x
= 0.0f
, y
= 0.0f
;
6105 /* See get_projection_matrix() in utils.c for a discussion of the position fixup.
6106 * This function here also applies to d3d10+ which does not need adjustment for
6107 * integer pixel centers, but it may need the filling convention offset. */
6108 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_PIXEL_CENTER_INTEGER
)
6109 center_offset
= 1.0f
;
6111 center_offset
= 0.0f
;
6113 center_offset
+= context
->d3d_info
->filling_convention_offset
;
6115 for (i
= 0; i
< fixup_count
; ++i
)
6117 position_fixup
[4 * i
] = 1.0f
;
6118 position_fixup
[4 * i
+ 1] = 1.0f
;
6119 if (!context
->d3d_info
->subpixel_viewport
)
6122 x
= modf(state
->viewports
[i
].x
, &dummy
) * 2.0f
;
6123 y
= modf(state
->viewports
[i
].y
, &dummy
) * 2.0f
;
6125 position_fixup
[4 * i
+ 2] = (center_offset
+ x
) / state
->viewports
[i
].width
;
6126 position_fixup
[4 * i
+ 3] = -(center_offset
+ y
) / state
->viewports
[i
].height
;
6128 if (context
->render_offscreen
)
6130 position_fixup
[4 * i
+ 1] *= -1.0f
;
6131 position_fixup
[4 * i
+ 3] *= -1.0f
;
6136 static inline BOOL
shader_constant_is_local(const struct wined3d_shader
*shader
, DWORD reg
)
6138 struct wined3d_shader_lconst
*lconst
;
6140 if (shader
->load_local_constsF
)
6143 LIST_FOR_EACH_ENTRY(lconst
, &shader
->constantsF
, struct wined3d_shader_lconst
, entry
)
6145 if (lconst
->idx
== reg
)
6152 void get_identity_matrix(struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
6153 void get_modelview_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
6154 unsigned int index
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
6155 void get_projection_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
6156 struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
6157 void get_texture_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
6158 unsigned int tex
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
6159 void get_pointsize_minmax(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
6160 float *out_min
, float *out_max
) DECLSPEC_HIDDEN
;
6161 void get_pointsize(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
6162 float *out_pointsize
, float *out_att
) DECLSPEC_HIDDEN
;
6163 void get_fog_start_end(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
6164 float *start
, float *end
) DECLSPEC_HIDDEN
;
6166 /* Using additional shader constants (uniforms in GLSL / program environment
6167 * or local parameters in ARB) is costly:
6168 * ARB only knows float4 parameters and GLSL compiler are not really smart
6169 * when it comes to efficiently pack float2 uniforms, so no space is wasted
6170 * (in fact most compilers map a float2 to a full float4 uniform).
6172 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
6173 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
6174 * into a single shader constant (uniform / program parameter).
6176 * This structure is shared between the GLSL and the ARB backend.*/
6177 struct ps_np2fixup_info
{
6178 unsigned char idx
[WINED3D_MAX_FRAGMENT_SAMPLERS
]; /* indices to the real constant */
6179 WORD active
; /* bitfield indicating if we can apply the fixup */
6183 void print_glsl_info_log(const struct wined3d_gl_info
*gl_info
, GLuint id
, BOOL program
) DECLSPEC_HIDDEN
;
6184 void shader_glsl_validate_link(const struct wined3d_gl_info
*gl_info
, GLuint program
) DECLSPEC_HIDDEN
;
6186 struct wined3d_palette
6189 struct wined3d_device
*device
;
6192 RGBQUAD colors
[256];
6196 /* DirectDraw utility functions */
6197 extern enum wined3d_format_id
pixelformat_for_depth(DWORD depth
) DECLSPEC_HIDDEN
;
6199 /*****************************************************************************
6200 * Pixel format management
6203 /* Pixel format attributes */
6204 #define WINED3D_FORMAT_ATTR_FLOAT 0x00000001
6205 #define WINED3D_FORMAT_ATTR_INTEGER 0x00000002
6206 #define WINED3D_FORMAT_ATTR_NORMALISED 0x00000004
6207 #define WINED3D_FORMAT_ATTR_BUMPMAP 0x00000008
6208 #define WINED3D_FORMAT_ATTR_EXTENSION 0x00000010
6209 #define WINED3D_FORMAT_ATTR_BLOCKS 0x00000020
6210 #define WINED3D_FORMAT_ATTR_BLOCKS_NO_VERIFY 0x00000040
6211 #define WINED3D_FORMAT_ATTR_COMPRESSED 0x00000080
6212 #define WINED3D_FORMAT_ATTR_BROKEN_PITCH 0x00000100
6213 #define WINED3D_FORMAT_ATTR_HEIGHT_SCALE 0x00000200
6214 #define WINED3D_FORMAT_ATTR_MAPPABLE 0x00000400
6215 #define WINED3D_FORMAT_ATTR_CAST_TO_BLOCK 0x00000800
6217 /* Pixel format capabilities */
6218 #define WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING 0x00000001
6219 #define WINED3D_FORMAT_CAP_FILTERING 0x00000002
6220 #define WINED3D_FORMAT_CAP_UNORDERED_ACCESS 0x00000004
6221 #define WINED3D_FORMAT_CAP_DEPTH_STENCIL 0x00000008
6222 #define WINED3D_FORMAT_CAP_RENDERTARGET 0x00000010
6223 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE 0x00000020
6224 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE_SRGB 0x00000040
6225 #define WINED3D_FORMAT_CAP_DECOMPRESS 0x00000080
6226 #define WINED3D_FORMAT_CAP_SRGB_READ 0x00000100
6227 #define WINED3D_FORMAT_CAP_SRGB_WRITE 0x00000200
6228 #define WINED3D_FORMAT_CAP_VTF 0x00000400
6229 #define WINED3D_FORMAT_CAP_SHADOW 0x00000800
6230 #define WINED3D_FORMAT_CAP_TEXTURE 0x00001000
6231 #define WINED3D_FORMAT_CAP_GEN_MIPMAP 0x00002000
6232 #define WINED3D_FORMAT_CAP_VERTEX_ATTRIBUTE 0x00004000
6233 #define WINED3D_FORMAT_CAP_BLIT 0x00008000
6234 #define WINED3D_FORMAT_CAP_INDEX_BUFFER 0x00010000
6236 struct wined3d_rational
6242 struct wined3d_color_key_conversion
6244 enum wined3d_format_id dst_format
;
6245 void (*convert
)(const BYTE
*src
, unsigned int src_pitch
, BYTE
*dst
, unsigned int dst_pitch
,
6246 unsigned int width
, unsigned int height
, const struct wined3d_color_key
*colour_key
);
6249 enum wined3d_channel_type
6251 WINED3D_CHANNEL_TYPE_NONE
,
6252 WINED3D_CHANNEL_TYPE_UNORM
,
6253 WINED3D_CHANNEL_TYPE_SNORM
,
6254 WINED3D_CHANNEL_TYPE_UINT
,
6255 WINED3D_CHANNEL_TYPE_SINT
,
6256 WINED3D_CHANNEL_TYPE_FLOAT
,
6257 WINED3D_CHANNEL_TYPE_DEPTH
,
6258 WINED3D_CHANNEL_TYPE_STENCIL
,
6259 WINED3D_CHANNEL_TYPE_UNUSED
,
6262 struct wined3d_format
6264 enum wined3d_format_id id
;
6266 D3DDDIFORMAT ddi_format
;
6267 unsigned int component_count
;
6282 UINT block_byte_count
;
6284 enum wined3d_ffp_emit_idx emit_idx
;
6286 UINT conv_byte_count
;
6287 DWORD multisample_types
;
6289 unsigned int caps
[WINED3D_GL_RES_TYPE_COUNT
];
6290 float depth_bias_scale
;
6291 struct wined3d_rational height_scale
;
6292 struct color_fixup_desc color_fixup
;
6293 void (*upload
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
6294 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
6295 unsigned int width
, unsigned int height
, unsigned int depth
);
6296 void (*download
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
6297 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
6298 unsigned int width
, unsigned int height
, unsigned int depth
);
6299 void (*decompress
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
6300 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
6301 unsigned int width
, unsigned int height
, unsigned int depth
);
6303 enum wined3d_format_id typeless_id
;
6306 const struct wined3d_format
*wined3d_get_format(const struct wined3d_adapter
*adapter
,
6307 enum wined3d_format_id format_id
, unsigned int bind_flags
) DECLSPEC_HIDDEN
;
6308 enum wined3d_format_id
wined3d_get_typed_format_id(const struct wined3d_adapter
*adapter
,
6309 const struct wined3d_format
*format
, enum wined3d_channel_type channel_type
) DECLSPEC_HIDDEN
;
6310 void wined3d_format_calculate_pitch(const struct wined3d_format
*format
, unsigned int alignment
,
6311 unsigned int width
, unsigned int height
, unsigned int *row_pitch
, unsigned int *slice_pitch
) DECLSPEC_HIDDEN
;
6312 UINT
wined3d_format_calculate_size(const struct wined3d_format
*format
,
6313 UINT alignment
, UINT width
, UINT height
, UINT depth
) DECLSPEC_HIDDEN
;
6314 void wined3d_format_colour_to_vk(const struct wined3d_format
*format
, const struct wined3d_color
*c
,
6315 VkClearColorValue
*retval
) DECLSPEC_HIDDEN
;
6316 void wined3d_format_convert_from_float(const struct wined3d_format
*format
,
6317 const struct wined3d_color
*color
, void *ret
) DECLSPEC_HIDDEN
;
6318 void wined3d_format_copy_data(const struct wined3d_format
*format
, const uint8_t *src
,
6319 unsigned int src_row_pitch
, unsigned int src_slice_pitch
, uint8_t *dst
, unsigned int dst_row_pitch
,
6320 unsigned int dst_slice_pitch
, unsigned int w
, unsigned int h
, unsigned int d
) DECLSPEC_HIDDEN
;
6321 void wined3d_format_get_float_color_key(const struct wined3d_format
*format
,
6322 const struct wined3d_color_key
*key
, struct wined3d_color
*float_colors
) DECLSPEC_HIDDEN
;
6323 BOOL
wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id
,
6324 enum wined3d_format_id view_format_id
) DECLSPEC_HIDDEN
;
6325 const struct wined3d_color_key_conversion
* wined3d_format_get_color_key_conversion(
6326 const struct wined3d_texture
*texture
, BOOL need_alpha_ck
) DECLSPEC_HIDDEN
;
6327 uint32_t wined3d_format_pack(const struct wined3d_format
*format
, const struct wined3d_uvec4
*value
) DECLSPEC_HIDDEN
;
6328 BOOL
wined3d_formats_are_srgb_variants(enum wined3d_format_id format1
,
6329 enum wined3d_format_id format2
) DECLSPEC_HIDDEN
;
6331 struct wined3d_format_gl
6333 struct wined3d_format f
;
6339 GLint srgb_internal
;
6347 static inline const struct wined3d_format_gl
*wined3d_format_gl(const struct wined3d_format
*format
)
6349 return CONTAINING_RECORD(format
, struct wined3d_format_gl
, f
);
6352 struct wined3d_format_vk
6354 struct wined3d_format f
;
6359 static inline const struct wined3d_format_vk
*wined3d_format_vk(const struct wined3d_format
*format
)
6361 return CONTAINING_RECORD(format
, struct wined3d_format_vk
, f
);
6364 BOOL
wined3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
) DECLSPEC_HIDDEN
;
6366 static inline BOOL
wined3d_format_is_typeless(const struct wined3d_format
*format
)
6368 return format
->id
== format
->typeless_id
&& format
->id
!= WINED3DFMT_UNKNOWN
;
6371 static inline BOOL
use_vs(const struct wined3d_state
*state
)
6373 /* Check state->vertex_declaration to allow this to be used before the
6374 * stream info is validated, for example in device_update_tex_unit_map(). */
6375 return state
->shader
[WINED3D_SHADER_TYPE_VERTEX
]
6376 && (!state
->vertex_declaration
|| !state
->vertex_declaration
->position_transformed
);
6379 static inline BOOL
use_ps(const struct wined3d_state
*state
)
6381 return !!state
->shader
[WINED3D_SHADER_TYPE_PIXEL
];
6384 static inline BOOL
use_transform_feedback(const struct wined3d_state
*state
)
6386 const struct wined3d_shader
*shader
;
6388 if (!(shader
= state
->shader
[WINED3D_SHADER_TYPE_GEOMETRY
]))
6390 return !!shader
->u
.gs
.so_desc
;
6393 static inline void context_apply_state(struct wined3d_context
*context
,
6394 const struct wined3d_state
*state
, DWORD state_id
)
6396 const struct wined3d_state_entry
*state_table
= context
->state_table
;
6397 unsigned int rep
= state_table
[state_id
].representative
;
6398 state_table
[rep
].apply(context
, state
, rep
);
6401 static inline BOOL
is_srgb_enabled(const uint32_t *sampler_states
)
6403 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
6404 * the behaviour of the AMD Windows driver.
6406 * Might & Magic: Heroes VI - Shades of Darkness sets
6407 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
6408 * pointer—presumably by accident—and expects sRGB decoding to be
6410 return sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
] & 0x1;
6413 static inline BOOL
needs_separate_srgb_gl_texture(const struct wined3d_context
*context
,
6414 const struct wined3d_texture
*texture
)
6416 if (!(context
->d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
))
6419 if (!context
->d3d_info
->srgb_read_control
6420 && (texture
->resource
.bind_flags
& WINED3D_BIND_SHADER_RESOURCE
)
6421 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_READ
))
6424 if (!context
->d3d_info
->srgb_write_control
6425 && (texture
->resource
.bind_flags
& WINED3D_BIND_RENDER_TARGET
)
6426 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
))
6432 static inline BOOL
needs_srgb_write(const struct wined3d_d3d_info
*d3d_info
,
6433 const struct wined3d_state
*state
, const struct wined3d_fb_state
*fb
)
6435 return (!(d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
)
6436 || state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
])
6437 && fb
->render_targets
[0] && fb
->render_targets
[0]->format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
;
6440 static inline GLuint
wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl
*texture_gl
,
6441 const struct wined3d_context
*context
, BOOL srgb
)
6443 return srgb
&& needs_separate_srgb_gl_texture(context
, &texture_gl
->t
)
6444 ? texture_gl
->texture_srgb
.name
: texture_gl
->texture_rgb
.name
;
6447 static inline GLuint
wined3d_gl_get_internal_format(struct wined3d_resource
*resource
,
6448 const struct wined3d_format_gl
*format_gl
, bool srgb
)
6451 return format_gl
->srgb_internal
;
6452 else if (resource
->bind_flags
& WINED3D_BIND_RENDER_TARGET
&& wined3d_resource_is_offscreen(resource
))
6453 return format_gl
->rt_internal
;
6455 return format_gl
->internal
;
6458 static inline BOOL
can_use_texture_swizzle(const struct wined3d_d3d_info
*d3d_info
, const struct wined3d_format
*format
)
6460 return d3d_info
->texture_swizzle
&& !is_complex_fixup(format
->color_fixup
) && !is_scaling_fixup(format
->color_fixup
);
6463 static inline BOOL
is_rasterization_disabled(const struct wined3d_shader
*geometry_shader
)
6465 return geometry_shader
&& geometry_shader
->u
.gs
.so_desc
6466 && geometry_shader
->u
.gs
.so_desc
->rasterizer_stream_idx
== WINED3D_NO_RASTERIZER_STREAM
;
6469 static inline uint32_t wined3d_mask_from_size(unsigned int size
)
6471 return size
< 32 ? (1u << size
) - 1 : ~0u;
6474 static inline DWORD
wined3d_extract_bits(const uint32_t *bitstream
,
6475 unsigned int offset
, unsigned int count
)
6477 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
6478 const unsigned int idx
= offset
/ word_bit_count
;
6479 const unsigned int shift
= offset
% word_bit_count
;
6480 DWORD mask
= (1u << count
) - 1;
6483 ret
= (bitstream
[idx
] >> shift
) & mask
;
6484 if (shift
+ count
> word_bit_count
)
6486 const unsigned int extracted_bit_count
= word_bit_count
- shift
;
6487 const unsigned int remaining_bit_count
= count
- extracted_bit_count
;
6488 mask
= (1u << remaining_bit_count
) - 1;
6489 ret
|= (bitstream
[idx
+ 1] & mask
) << extracted_bit_count
;
6494 static inline void wined3d_insert_bits(uint32_t *bitstream
,
6495 unsigned int offset
, unsigned int count
, DWORD bits
)
6497 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
6498 const unsigned int idx
= offset
/ word_bit_count
;
6499 const unsigned int shift
= offset
% word_bit_count
;
6500 DWORD mask
= (1u << count
) - 1;
6502 bitstream
[idx
] |= (bits
& mask
) << shift
;
6503 if (shift
+ count
> word_bit_count
)
6505 const unsigned int inserted_bit_count
= word_bit_count
- shift
;
6506 const unsigned int remaining_bit_count
= count
- inserted_bit_count
;
6507 mask
= (1u << remaining_bit_count
) - 1;
6508 bitstream
[idx
+ 1] |= (bits
>> inserted_bit_count
) & mask
;
6512 static inline void wined3d_from_cs(const struct wined3d_cs
*cs
)
6515 assert(cs
->thread_id
== GetCurrentThreadId());
6518 static inline void wined3d_not_from_cs(const struct wined3d_cs
*cs
)
6520 assert(cs
->thread_id
!= GetCurrentThreadId());
6523 static inline enum wined3d_material_color_source
validate_material_colour_source(WORD use_map
,
6524 enum wined3d_material_color_source source
)
6526 if (source
== WINED3D_MCS_COLOR1
&& use_map
& (1u << WINED3D_FFP_DIFFUSE
))
6528 if (source
== WINED3D_MCS_COLOR2
&& use_map
& (1u << WINED3D_FFP_SPECULAR
))
6530 return WINED3D_MCS_MATERIAL
;
6533 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source
*diffuse
,
6534 enum wined3d_material_color_source
*emissive
, enum wined3d_material_color_source
*ambient
,
6535 enum wined3d_material_color_source
*specular
, const struct wined3d_state
*state
,
6536 const struct wined3d_stream_info
*si
)
6538 if (!state
->render_states
[WINED3D_RS_LIGHTING
])
6540 *diffuse
= WINED3D_MCS_COLOR1
;
6541 *specular
= WINED3D_MCS_COLOR2
;
6542 *emissive
= *ambient
= WINED3D_MCS_MATERIAL
;
6547 if (!state
->render_states
[WINED3D_RS_COLORVERTEX
])
6549 *diffuse
= *emissive
= *ambient
= *specular
= WINED3D_MCS_MATERIAL
;
6554 *diffuse
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
]);
6555 *emissive
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
]);
6556 *ambient
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
]);
6557 *specular
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
6560 static inline void wined3d_vec4_transform(struct wined3d_vec4
*dst
,
6561 const struct wined3d_vec4
*v
, const struct wined3d_matrix
*m
)
6563 struct wined3d_vec4 tmp
;
6565 tmp
.x
= v
->x
* m
->_11
+ v
->y
* m
->_21
+ v
->z
* m
->_31
+ v
->w
* m
->_41
;
6566 tmp
.y
= v
->x
* m
->_12
+ v
->y
* m
->_22
+ v
->z
* m
->_32
+ v
->w
* m
->_42
;
6567 tmp
.z
= v
->x
* m
->_13
+ v
->y
* m
->_23
+ v
->z
* m
->_33
+ v
->w
* m
->_43
;
6568 tmp
.w
= v
->x
* m
->_14
+ v
->y
* m
->_24
+ v
->z
* m
->_34
+ v
->w
* m
->_44
;
6573 BOOL
invert_matrix(struct wined3d_matrix
*out
, const struct wined3d_matrix
*m
) DECLSPEC_HIDDEN
;
6575 void compute_normal_matrix(float *normal_matrix
, BOOL legacy_lighting
,
6576 const struct wined3d_matrix
*modelview
) DECLSPEC_HIDDEN
;
6578 static inline struct wined3d_context
*context_acquire(struct wined3d_device
*device
,
6579 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
6581 wined3d_from_cs(device
->cs
);
6583 return device
->adapter
->adapter_ops
->adapter_acquire_context(device
, texture
, sub_resource_idx
);
6586 static inline void context_release(struct wined3d_context
*context
)
6588 context
->device
->adapter
->adapter_ops
->adapter_release_context(context
);
6591 static inline float wined3d_get_float_state(const struct wined3d_state
*state
, enum wined3d_render_state rs
)
6600 tmpvalue
.d
= state
->render_states
[rs
];
6604 static inline void *wined3d_context_map_bo_address(struct wined3d_context
*context
,
6605 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
6607 return context
->device
->adapter
->adapter_ops
->adapter_map_bo_address(context
, data
, size
, map_flags
);
6610 static inline void wined3d_context_unmap_bo_address(struct wined3d_context
*context
,
6611 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
6613 context
->device
->adapter
->adapter_ops
->adapter_unmap_bo_address(context
, data
, range_count
, ranges
);
6616 static inline void wined3d_context_copy_bo_address(struct wined3d_context
*context
,
6617 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
6618 unsigned int range_count
, const struct wined3d_range
*ranges
)
6620 context
->device
->adapter
->adapter_ops
->adapter_copy_bo_address(context
, dst
, src
, range_count
, ranges
);
6623 static inline void wined3d_context_flush_bo_address(struct wined3d_context
*context
,
6624 const struct wined3d_const_bo_address
*data
, size_t size
)
6626 context
->device
->adapter
->adapter_ops
->adapter_flush_bo_address(context
, data
, size
);
6629 static inline void wined3d_context_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
6631 context
->device
->adapter
->adapter_ops
->adapter_destroy_bo(context
, bo
);
6634 static inline void wined3d_context_vk_reference_bo(const struct wined3d_context_vk
*context_vk
,
6635 struct wined3d_bo_vk
*bo
)
6637 bo
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
6640 static inline void wined3d_context_vk_reference_image(const struct wined3d_context_vk
*context_vk
,
6641 struct wined3d_image_vk
*image
)
6643 image
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
6646 static inline void wined3d_context_vk_reference_texture(const struct wined3d_context_vk
*context_vk
,
6647 struct wined3d_texture_vk
*texture_vk
)
6649 wined3d_context_vk_reference_image(context_vk
, &texture_vk
->image
);
6652 static inline void wined3d_context_vk_reference_resource(const struct wined3d_context_vk
*context_vk
,
6653 struct wined3d_resource
*resource
)
6655 if (resource
->type
== WINED3D_RTYPE_BUFFER
)
6656 wined3d_context_vk_reference_bo(context_vk
, wined3d_bo_vk(buffer_from_resource(resource
)->buffer_object
));
6658 wined3d_context_vk_reference_texture(context_vk
, wined3d_texture_vk(texture_from_resource(resource
)));
6661 static inline void wined3d_context_vk_reference_query(const struct wined3d_context_vk
*context_vk
,
6662 struct wined3d_query_vk
*query_vk
)
6664 query_vk
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
6667 static inline void wined3d_context_vk_reference_sampler(const struct wined3d_context_vk
*context_vk
,
6668 struct wined3d_sampler_vk
*sampler_vk
)
6670 sampler_vk
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
6673 static inline void wined3d_context_vk_reference_rendertarget_view(const struct wined3d_context_vk
*context_vk
,
6674 struct wined3d_rendertarget_view_vk
*rtv_vk
)
6676 wined3d_context_vk_reference_resource(context_vk
, rtv_vk
->v
.resource
);
6677 rtv_vk
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
6680 static inline void wined3d_context_vk_reference_shader_resource_view(const struct wined3d_context_vk
*context_vk
,
6681 struct wined3d_shader_resource_view_vk
*srv_vk
)
6683 wined3d_context_vk_reference_resource(context_vk
, srv_vk
->v
.resource
);
6684 srv_vk
->view_vk
.command_buffer_id
= context_vk
->current_command_buffer
.id
;
6687 static inline void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk
*context_vk
,
6688 struct wined3d_unordered_access_view_vk
*uav_vk
)
6690 wined3d_context_vk_reference_resource(context_vk
, uav_vk
->v
.resource
);
6691 uav_vk
->view_vk
.command_buffer_id
= context_vk
->current_command_buffer
.id
;
6694 static inline BOOL
wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view
*dsv
,
6695 const struct wined3d_format
*srv_format
)
6697 return !srv_format
|| (srv_format
->red_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_DEPTH
))
6698 || (srv_format
->green_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_STENCIL
));
6701 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture
*texture
)
6703 return texture
->resource
.type
== WINED3D_RTYPE_TEXTURE_3D
? texture
->resource
.depth
: texture
->layer_count
;
6706 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view
*srv
)
6708 struct wined3d_texture
*texture
;
6710 if (srv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
6713 if (srv
->desc
.u
.texture
.layer_idx
|| srv
->desc
.u
.texture
.level_idx
)
6716 texture
= texture_from_resource(srv
->resource
);
6717 return srv
->desc
.u
.texture
.level_count
== texture
->level_count
6718 && srv
->desc
.u
.texture
.layer_count
== wined3d_bind_layer_count(texture
);
6721 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view
*rtv
)
6723 struct wined3d_texture
*texture
;
6725 if (rtv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
6728 if (rtv
->sub_resource_idx
)
6731 texture
= texture_from_resource(rtv
->resource
);
6732 return texture
->level_count
== 1 && rtv
->layer_count
== wined3d_bind_layer_count(texture
);
6735 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view
*srv
)
6737 InterlockedIncrement(&srv
->resource
->srv_bind_count_device
);
6740 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view
*srv
)
6742 InterlockedDecrement(&srv
->resource
->srv_bind_count_device
);
6745 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view
*rtv
)
6747 InterlockedIncrement(&rtv
->resource
->rtv_bind_count_device
);
6750 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view
*rtv
)
6752 InterlockedDecrement(&rtv
->resource
->rtv_bind_count_device
);
6755 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view
*rtv
,
6756 const struct wined3d_shader_resource_view
*srv
)
6758 if (rtv
->resource
!= srv
->resource
)
6761 if (wined3d_srv_all_subresources(srv
) || wined3d_rtv_all_subresources(rtv
))
6764 return rtv
->sub_resource_idx
>= srv
->desc
.u
.texture
.level_idx
6765 && rtv
->sub_resource_idx
< srv
->desc
.u
.texture
.level_idx
+ srv
->desc
.u
.texture
.level_count
6766 && rtv
->layer_count
>= srv
->desc
.u
.texture
.layer_idx
;
6769 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_state
*state
,
6770 const struct wined3d_shader_resource_view
*srv
)
6774 if (!srv
->resource
->rtv_bind_count_device
)
6777 for (i
= 0; i
< ARRAY_SIZE(state
->fb
.render_targets
); ++i
)
6779 const struct wined3d_rendertarget_view
*rtv
;
6781 if ((rtv
= state
->fb
.render_targets
[i
]) && wined3d_rtv_overlaps_srv(rtv
, srv
))
6788 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport
*vp
, float *min_z
, float *max_z
)
6792 /* The magic constant is derived from tests. */
6793 *max_z
= max(vp
->max_z
, vp
->min_z
+ 0.001f
);
6796 static inline BOOL
wined3d_bitmap_clear(uint32_t *map
, unsigned int idx
)
6798 return map
[idx
>> 5] &= ~(1u << (idx
& 0x1f));
6801 static inline BOOL
wined3d_bitmap_set(uint32_t *map
, unsigned int idx
)
6803 return map
[idx
>> 5] |= (1u << (idx
& 0x1f));
6806 static inline BOOL
wined3d_bitmap_is_set(const uint32_t *map
, unsigned int idx
)
6808 return map
[idx
>> 5] & (1u << (idx
& 0x1f));
6811 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap
, unsigned int bit_count
,
6812 unsigned int start
, uint32_t xor_mask
)
6814 const unsigned int word_bit_count
= sizeof(*bitmap
) * CHAR_BIT
;
6815 const uint32_t *ptr
, *end_ptr
;
6818 assert(bit_count
< word_bit_count
|| !(bit_count
% word_bit_count
));
6820 ptr
= bitmap
+ start
/ word_bit_count
;
6821 end_ptr
= bitmap
+ (bit_count
+ word_bit_count
- 1) / word_bit_count
;
6826 mask
= ~0u << start
% word_bit_count
;
6827 map
= (*ptr
^ xor_mask
) & mask
;
6830 if (++ptr
== end_ptr
)
6832 map
= *ptr
^ xor_mask
;
6834 return (ptr
- bitmap
) * word_bit_count
+ wined3d_bit_scan(&map
);
6837 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
6839 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, 0);
6842 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
6844 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, ~0u);
6847 static inline BOOL
wined3d_bitmap_get_range(const uint32_t *bitmap
, unsigned int bit_count
,
6848 unsigned int start
, struct wined3d_range
*range
)
6850 unsigned int range_start
, range_end
;
6852 range_start
= wined3d_bitmap_ffs(bitmap
, bit_count
, start
);
6853 if (range_start
== ~0u)
6856 range_end
= wined3d_bitmap_ffz(bitmap
, bit_count
, range_start
+ 1);
6857 if (range_end
== ~0u)
6858 range_end
= bit_count
;
6860 range
->offset
= range_start
;
6861 range
->size
= range_end
- range_start
;
6865 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
6867 return wined3d_bitmap_is_set(context
->dirty_graphics_states
, state_id
);
6870 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
6872 return wined3d_bitmap_is_set(context
->dirty_compute_states
, state_id
- STATE_COMPUTE_OFFSET
);
6875 static inline bool isStateDirty(const struct wined3d_context
*context
, unsigned int state_id
)
6877 return wined3d_context_is_graphics_state_dirty(context
, state_id
);
6880 static inline VkImageAspectFlags
vk_aspect_mask_from_format(const struct wined3d_format
*format
)
6882 VkImageAspectFlags mask
= 0;
6884 if (format
->depth_size
)
6885 mask
|= VK_IMAGE_ASPECT_DEPTH_BIT
;
6886 if (format
->stencil_size
)
6887 mask
|= VK_IMAGE_ASPECT_STENCIL_BIT
;
6888 if (!mask
|| format
->red_size
|| format
->green_size
|| format
->blue_size
|| format
->alpha_size
)
6889 mask
|= VK_IMAGE_ASPECT_COLOR_BIT
;
6894 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t
)
6896 return t
== WINED3D_PT_POINTLIST
6897 || t
== WINED3D_PT_LINELIST
6898 || t
== WINED3D_PT_TRIANGLELIST
6899 || t
== WINED3D_PT_LINELIST_ADJ
6900 || t
== WINED3D_PT_TRIANGLELIST_ADJ
6901 || t
== WINED3D_PT_PATCH
;
6904 static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo_gl
)
6906 struct wined3d_device_gl
*device_gl
= wined3d_device_gl(context_gl
->c
.device
);
6908 bo_gl
->command_fence_id
= device_gl
->current_fence_id
;
6911 static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl
*context_gl
,
6912 struct wined3d_buffer
*buffer
)
6914 if (buffer
->buffer_object
)
6915 wined3d_context_gl_reference_bo(context_gl
, wined3d_bo_gl(buffer
->buffer_object
));
6918 static inline bool wined3d_map_persistent(void)
6920 return sizeof(void *) >= sizeof(uint64_t);
6923 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
6924 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
6926 extern CRITICAL_SECTION wined3d_command_cs
;