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>
37 #define LIBVKD3D_SHADER_SOURCE
38 #include <vkd3d_shader.h>
40 #define WIN32_NO_STATUS
41 #define NONAMELESSUNION
42 #define NONAMELESSSTRUCT
50 #include "ddk/d3dkmthk.h"
51 #include "wine/debug.h"
52 #include "wine/heap.h"
55 #include "wine/wined3d.h"
56 #include "wined3d_gl.h"
57 #include "wine/list.h"
58 #include "wine/rbtree.h"
59 #include "wine/wgl_driver.h"
61 static inline size_t align(size_t addr
, size_t alignment
)
63 return (addr
+ (alignment
- 1)) & ~(alignment
- 1);
66 static inline float int_to_float(uint32_t i
)
78 static inline const char *wined3d_get_line(const char **ptr
, const char *end
)
82 if ((p
= *ptr
) >= end
)
85 if (!(q
= memchr(p
, '\n', end
- p
)))
92 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
95 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
96 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
97 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
98 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
99 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
100 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
101 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
102 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
103 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
104 #define WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS 0x00000400
106 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
108 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
109 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
111 #define WINED3D_BITMAP_SIZE(x) (((x) + 31) >> 5)
113 struct wined3d_fragment_pipe_ops
;
114 struct wined3d_adapter
;
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 GLenum
wined3d_gl_compare_func(enum wined3d_cmp_func f
) DECLSPEC_HIDDEN
;
344 static inline enum wined3d_cmp_func
wined3d_sanitize_cmp_func(enum wined3d_cmp_func func
)
346 if (func
< WINED3D_CMP_NEVER
|| func
> WINED3D_CMP_ALWAYS
)
347 return WINED3D_CMP_ALWAYS
;
351 static inline GLenum
wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter
)
353 return magLookup
[mag_filter
];
356 static inline GLenum
wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter
,
357 enum wined3d_texture_filter_type mip_filter
)
359 return minMipLookup
[min_filter
].mip
[mip_filter
];
362 /* float_16_to_32() and float_32_to_16() convert 16 bit floats in the
363 * FLOAT16 data type to standard C floats and vice versa. They do not
364 * depend on the encoding of the C float, so they are platform independent,
365 * but slow. On x86 and other IEEE 754 compliant platforms the conversion
366 * can be accelerated by bit shifting the exponent and mantissa. There are
367 * also some SSE-based assembly routines out there.
369 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
371 static inline float float_16_to_32(const unsigned short *in
)
373 const unsigned short s
= ((*in
) & 0x8000u
);
374 const unsigned short e
= ((*in
) & 0x7c00u
) >> 10;
375 const unsigned short m
= (*in
) & 0x3ffu
;
376 const float sgn
= (s
? -1.0f
: 1.0f
);
379 if(m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
380 else return sgn
* powf(2, -14.0f
) * ((float)m
/ 1024.0f
);
382 return sgn
* powf(2, (float)e
- 15.0f
) * (1.0f
+ ((float)m
/ 1024.0f
));
384 if(m
== 0) return sgn
* INFINITY
;
389 static inline float float_24_to_32(DWORD in
)
391 const float sgn
= in
& 0x800000u
? -1.0f
: 1.0f
;
392 const unsigned short e
= (in
& 0x780000u
) >> 19;
393 const unsigned int m
= in
& 0x7ffffu
;
397 if (m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
398 else return sgn
* powf(2, -6.0f
) * ((float)m
/ 524288.0f
);
402 return sgn
* powf(2, (float)e
- 7.0f
) * (1.0f
+ ((float)m
/ 524288.0f
));
406 if (m
== 0) return sgn
* INFINITY
;
411 static inline unsigned short float_32_to_16(const float *in
)
414 float tmp
= fabsf(*in
);
415 unsigned int mantissa
;
418 /* Deal with special numbers */
424 return (*in
< 0.0f
? 0xfc00 : 0x7c00);
426 if (tmp
< (float)(1u << 10))
432 } while (tmp
< (float)(1u << 10));
434 else if (tmp
>= (float)(1u << 11))
440 } while (tmp
>= (float)(1u << 11));
443 mantissa
= (unsigned int)tmp
;
444 if (tmp
- mantissa
>= 0.5f
)
445 ++mantissa
; /* Round to nearest, away from zero. */
447 exp
+= 10; /* Normalize the mantissa. */
448 exp
+= 15; /* Exponent is encoded with excess 15. */
450 if (exp
> 30) /* too big */
452 ret
= 0x7c00; /* INF */
456 /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
459 mantissa
= mantissa
>> 1;
462 ret
= mantissa
& 0x3ff;
466 ret
= (exp
<< 10) | (mantissa
& 0x3ff);
469 ret
|= ((*in
< 0.0f
? 1 : 0) << 15); /* Add the sign */
473 static inline unsigned int wined3d_popcount(unsigned int x
)
475 #if defined(__MINGW32__)
476 return __builtin_popcount(x
);
478 x
-= x
>> 1 & 0x55555555;
479 x
= (x
& 0x33333333) + (x
>> 2 & 0x33333333);
480 return ((x
+ (x
>> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
484 static inline int wined3d_uint32_compare(uint32_t x
, uint32_t y
)
486 return (x
> y
) - (x
< y
);
489 static inline int wined3d_uint64_compare(uint64_t x
, uint64_t y
)
491 return (x
> y
) - (x
< y
);
494 #define ORM_BACKBUFFER 0
497 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
498 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
500 enum wined3d_shader_backend
502 WINED3D_SHADER_BACKEND_AUTO
,
503 WINED3D_SHADER_BACKEND_GLSL
,
504 WINED3D_SHADER_BACKEND_ARB
,
505 WINED3D_SHADER_BACKEND_NONE
,
508 #define WINED3D_CSMT_ENABLE 0x00000001
509 #define WINED3D_CSMT_SERIALIZE 0x00000002
511 /* NOTE: When adding fields to this structure, make sure to update the default
512 * values in wined3d_main.c as well. */
513 struct wined3d_settings
515 unsigned int cs_multithreaded
;
516 unsigned int max_gl_version
;
517 int offscreen_rendering_mode
;
518 unsigned short pci_vendor_id
;
519 unsigned short pci_device_id
;
520 /* Memory tracking and object counting. */
521 UINT64 emulated_textureram
;
523 unsigned int multisample_textures
;
524 unsigned int sample_count
;
525 BOOL check_float_constants
;
526 unsigned int strict_shader_math
;
527 unsigned int max_sm_vs
;
528 unsigned int max_sm_hs
;
529 unsigned int max_sm_ds
;
530 unsigned int max_sm_gs
;
531 unsigned int max_sm_ps
;
532 unsigned int max_sm_cs
;
533 enum wined3d_renderer renderer
;
534 enum wined3d_shader_backend shader_backend
;
535 BOOL cb_access_map_w
;
538 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN
;
540 enum wined3d_shader_resource_type
542 WINED3D_SHADER_RESOURCE_NONE
,
543 WINED3D_SHADER_RESOURCE_BUFFER
,
544 WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
545 WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
546 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
547 WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
548 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
549 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
550 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
551 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
552 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY
,
555 #define WINED3D_SHADER_CONST_VS_F 0x00000001
556 #define WINED3D_SHADER_CONST_VS_I 0x00000002
557 #define WINED3D_SHADER_CONST_VS_B 0x00000004
558 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
559 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
560 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
561 #define WINED3D_SHADER_CONST_PS_F 0x00000040
562 #define WINED3D_SHADER_CONST_PS_I 0x00000080
563 #define WINED3D_SHADER_CONST_PS_B 0x00000100
564 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
565 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
566 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
567 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
568 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
569 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
570 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
571 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
572 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
573 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
574 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
575 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
576 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
577 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
579 enum wined3d_shader_register_type
582 WINED3DSPR_INPUT
= 1,
583 WINED3DSPR_CONST
= 2,
585 WINED3DSPR_TEXTURE
= 3,
586 WINED3DSPR_RASTOUT
= 4,
587 WINED3DSPR_ATTROUT
= 5,
588 WINED3DSPR_TEXCRDOUT
= 6,
589 WINED3DSPR_OUTPUT
= 6,
590 WINED3DSPR_CONSTINT
= 7,
591 WINED3DSPR_COLOROUT
= 8,
592 WINED3DSPR_DEPTHOUT
= 9,
593 WINED3DSPR_SAMPLER
= 10,
594 WINED3DSPR_CONST2
= 11,
595 WINED3DSPR_CONST3
= 12,
596 WINED3DSPR_CONST4
= 13,
597 WINED3DSPR_CONSTBOOL
= 14,
598 WINED3DSPR_LOOP
= 15,
599 WINED3DSPR_TEMPFLOAT16
= 16,
600 WINED3DSPR_MISCTYPE
= 17,
601 WINED3DSPR_LABEL
= 18,
602 WINED3DSPR_PREDICATE
= 19,
604 WINED3DSPR_CONSTBUFFER
,
605 WINED3DSPR_IMMCONSTBUFFER
,
610 WINED3DSPR_OUTPOINTID
,
611 WINED3DSPR_FORKINSTID
,
612 WINED3DSPR_JOININSTID
,
613 WINED3DSPR_INCONTROLPOINT
,
614 WINED3DSPR_OUTCONTROLPOINT
,
615 WINED3DSPR_PATCHCONST
,
616 WINED3DSPR_TESSCOORD
,
617 WINED3DSPR_GROUPSHAREDMEM
,
619 WINED3DSPR_THREADGROUPID
,
620 WINED3DSPR_LOCALTHREADID
,
621 WINED3DSPR_LOCALTHREADINDEX
,
624 WINED3DSPR_FUNCTIONBODY
,
625 WINED3DSPR_FUNCTIONPOINTER
,
627 WINED3DSPR_SAMPLEMASK
,
629 WINED3DSPR_DEPTHOUTGE
,
630 WINED3DSPR_DEPTHOUTLE
,
631 WINED3DSPR_RASTERIZER
,
634 enum wined3d_data_type
638 WINED3D_DATA_RESOURCE
,
639 WINED3D_DATA_SAMPLER
,
647 enum wined3d_immconst_type
649 WINED3D_IMMCONST_SCALAR
,
650 WINED3D_IMMCONST_VEC4
,
653 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
655 enum wined3d_shader_src_modifier
657 WINED3DSPSM_NONE
= 0,
659 WINED3DSPSM_BIAS
= 2,
660 WINED3DSPSM_BIASNEG
= 3,
661 WINED3DSPSM_SIGN
= 4,
662 WINED3DSPSM_SIGNNEG
= 5,
663 WINED3DSPSM_COMP
= 6,
665 WINED3DSPSM_X2NEG
= 8,
668 WINED3DSPSM_ABS
= 11,
669 WINED3DSPSM_ABSNEG
= 12,
670 WINED3DSPSM_NOT
= 13,
673 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
674 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
675 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
676 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
677 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
679 enum wined3d_shader_dst_modifier
681 WINED3DSPDM_NONE
= 0,
682 WINED3DSPDM_SATURATE
= 1,
683 WINED3DSPDM_PARTIALPRECISION
= 2,
684 WINED3DSPDM_MSAMPCENTROID
= 4,
687 enum wined3d_shader_interpolation_mode
690 WINED3DSIM_CONSTANT
= 1,
691 WINED3DSIM_LINEAR
= 2,
692 WINED3DSIM_LINEAR_CENTROID
= 3,
693 WINED3DSIM_LINEAR_NOPERSPECTIVE
= 4,
694 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
= 5,
695 WINED3DSIM_LINEAR_SAMPLE
= 6,
696 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE
= 7,
699 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
700 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
702 enum wined3d_shader_global_flags
704 WINED3DSGF_REFACTORING_ALLOWED
= 0x1,
705 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL
= 0x4,
706 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS
= 0x8,
709 enum wined3d_shader_sync_flags
711 WINED3DSSF_THREAD_GROUP
= 0x1,
712 WINED3DSSF_GROUP_SHARED_MEMORY
= 0x2,
713 WINED3DSSF_GLOBAL_UAV
= 0x8,
716 enum wined3d_shader_uav_flags
718 WINED3DSUF_GLOBALLY_COHERENT
= 0x2,
719 WINED3DSUF_ORDER_PRESERVING_COUNTER
= 0x100,
722 enum wined3d_tessellator_domain
724 WINED3D_TESSELLATOR_DOMAIN_LINE
= 1,
725 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE
= 2,
726 WINED3D_TESSELLATOR_DOMAIN_QUAD
= 3,
729 enum wined3d_tessellator_output_primitive
731 WINED3D_TESSELLATOR_OUTPUT_POINT
= 1,
732 WINED3D_TESSELLATOR_OUTPUT_LINE
= 2,
733 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW
= 3,
734 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW
= 4,
737 enum wined3d_tessellator_partitioning
739 WINED3D_TESSELLATOR_PARTITIONING_INTEGER
= 1,
740 WINED3D_TESSELLATOR_PARTITIONING_POW2
= 2,
741 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD
= 3,
742 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
= 4,
745 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
746 #define WINED3DSI_TEXLD_PROJECT 0x1
747 #define WINED3DSI_TEXLD_BIAS 0x2
748 #define WINED3DSI_INDEXED_DYNAMIC 0x4
749 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
750 #define WINED3DSI_RESINFO_UINT 0x2
751 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
752 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
754 #define WINED3DSI_PRECISE_X 0x100
755 #define WINED3DSI_PRECISE_Y 0x200
756 #define WINED3DSI_PRECISE_Z 0x400
757 #define WINED3DSI_PRECISE_W 0x800
758 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
759 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
760 #define WINED3DSI_PRECISE_SHIFT 8
762 enum wined3d_shader_rel_op
764 WINED3D_SHADER_REL_OP_GT
= 1,
765 WINED3D_SHADER_REL_OP_EQ
= 2,
766 WINED3D_SHADER_REL_OP_GE
= 3,
767 WINED3D_SHADER_REL_OP_LT
= 4,
768 WINED3D_SHADER_REL_OP_NE
= 5,
769 WINED3D_SHADER_REL_OP_LE
= 6,
772 enum wined3d_shader_conditional_op
774 WINED3D_SHADER_CONDITIONAL_OP_NZ
= 0,
775 WINED3D_SHADER_CONDITIONAL_OP_Z
= 1
778 enum wined3d_sysval_semantic
780 WINED3D_SV_POSITION
= 0x01,
781 WINED3D_SV_CLIP_DISTANCE
= 0x02,
782 WINED3D_SV_CULL_DISTANCE
= 0x03,
783 WINED3D_SV_RENDER_TARGET_ARRAY_INDEX
= 0x04,
784 WINED3D_SV_VIEWPORT_ARRAY_INDEX
= 0x05,
785 WINED3D_SV_VERTEX_ID
= 0x06,
786 WINED3D_SV_PRIMITIVE_ID
= 0x07,
787 WINED3D_SV_INSTANCE_ID
= 0x08,
788 WINED3D_SV_IS_FRONT_FACE
= 0x09,
789 WINED3D_SV_SAMPLE_INDEX
= 0x0a,
790 WINED3D_SV_TESS_FACTOR_QUADEDGE
= 0x0b,
791 WINED3D_SV_TESS_FACTOR_QUADINT
= 0x0c,
792 WINED3D_SV_TESS_FACTOR_TRIEDGE
= 0x0d,
793 WINED3D_SV_TESS_FACTOR_TRIINT
= 0x0e,
794 WINED3D_SV_TESS_FACTOR_LINEDET
= 0x0f,
795 WINED3D_SV_TESS_FACTOR_LINEDEN
= 0x10,
798 enum wined3d_component_type
800 WINED3D_TYPE_UNKNOWN
= 0x0,
801 WINED3D_TYPE_UINT
= 0x1,
802 WINED3D_TYPE_INT
= 0x2,
803 WINED3D_TYPE_FLOAT
= 0x3,
806 struct wined3d_shader_signature_element
808 const char *semantic_name
;
809 unsigned int semantic_idx
;
810 unsigned int stream_idx
;
811 enum wined3d_sysval_semantic sysval_semantic
;
812 enum wined3d_component_type component_type
;
813 unsigned int register_idx
;
815 unsigned int min_precision
;
818 struct wined3d_shader_signature
820 unsigned int element_count
;
821 struct wined3d_shader_signature_element
*elements
;
824 #define WINED3D_SM1_VS 0xfffeu
825 #define WINED3D_SM1_PS 0xffffu
826 #define WINED3D_SM4_PS 0x0000u
827 #define WINED3D_SM4_VS 0x0001u
828 #define WINED3D_SM4_GS 0x0002u
829 #define WINED3D_SM5_HS 0x0003u
830 #define WINED3D_SM5_DS 0x0004u
831 #define WINED3D_SM5_CS 0x0005u
833 /* Shader version tokens, and shader end tokens */
834 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
835 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
837 /* Shader backends */
839 #define MAX_ATTRIBS 32
840 #define MAX_REG_ADDR 1
841 #define MAX_REG_TEXCRD 8
842 #define MAX_REG_INPUT 32
843 #define MAX_REG_OUTPUT 32
844 #define WINED3D_MAX_CBS 15
846 /* FIXME: This needs to go up to 2048 for
847 * Shader model 3 according to msdn (and for software shaders) */
848 #define MAX_LABELS 16
850 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
852 struct wined3d_string_buffer
856 unsigned int buffer_size
;
857 unsigned int content_size
;
860 enum WINED3D_SHADER_INSTRUCTION_HANDLER
865 WINED3DSIH_ATOMIC_AND
,
866 WINED3DSIH_ATOMIC_CMP_STORE
,
867 WINED3DSIH_ATOMIC_IADD
,
868 WINED3DSIH_ATOMIC_IMAX
,
869 WINED3DSIH_ATOMIC_IMIN
,
870 WINED3DSIH_ATOMIC_OR
,
871 WINED3DSIH_ATOMIC_UMAX
,
872 WINED3DSIH_ATOMIC_UMIN
,
873 WINED3DSIH_ATOMIC_XOR
,
887 WINED3DSIH_CONTINUEP
,
888 WINED3DSIH_COUNTBITS
,
891 WINED3DSIH_CUT_STREAM
,
893 WINED3DSIH_DCL_CONSTANT_BUFFER
,
894 WINED3DSIH_DCL_FUNCTION_BODY
,
895 WINED3DSIH_DCL_FUNCTION_TABLE
,
896 WINED3DSIH_DCL_GLOBAL_FLAGS
,
897 WINED3DSIH_DCL_GS_INSTANCES
,
898 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
,
899 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
,
900 WINED3DSIH_DCL_HS_MAX_TESSFACTOR
,
901 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
,
902 WINED3DSIH_DCL_INDEX_RANGE
,
903 WINED3DSIH_DCL_INDEXABLE_TEMP
,
904 WINED3DSIH_DCL_INPUT
,
905 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
,
906 WINED3DSIH_DCL_INPUT_PRIMITIVE
,
907 WINED3DSIH_DCL_INPUT_PS
,
908 WINED3DSIH_DCL_INPUT_PS_SGV
,
909 WINED3DSIH_DCL_INPUT_PS_SIV
,
910 WINED3DSIH_DCL_INPUT_SGV
,
911 WINED3DSIH_DCL_INPUT_SIV
,
912 WINED3DSIH_DCL_INTERFACE
,
913 WINED3DSIH_DCL_OUTPUT
,
914 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
,
915 WINED3DSIH_DCL_OUTPUT_SIV
,
916 WINED3DSIH_DCL_OUTPUT_TOPOLOGY
,
917 WINED3DSIH_DCL_RESOURCE_RAW
,
918 WINED3DSIH_DCL_RESOURCE_STRUCTURED
,
919 WINED3DSIH_DCL_SAMPLER
,
920 WINED3DSIH_DCL_STREAM
,
921 WINED3DSIH_DCL_TEMPS
,
922 WINED3DSIH_DCL_TESSELLATOR_DOMAIN
,
923 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
,
924 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
,
925 WINED3DSIH_DCL_TGSM_RAW
,
926 WINED3DSIH_DCL_TGSM_STRUCTURED
,
927 WINED3DSIH_DCL_THREAD_GROUP
,
928 WINED3DSIH_DCL_UAV_RAW
,
929 WINED3DSIH_DCL_UAV_STRUCTURED
,
930 WINED3DSIH_DCL_UAV_TYPED
,
931 WINED3DSIH_DCL_VERTICES_OUT
,
943 WINED3DSIH_DSX_COARSE
,
946 WINED3DSIH_DSY_COARSE
,
950 WINED3DSIH_EMIT_STREAM
,
954 WINED3DSIH_ENDSWITCH
,
956 WINED3DSIH_EVAL_CENTROID
,
957 WINED3DSIH_EVAL_SAMPLE_INDEX
,
963 WINED3DSIH_FIRSTBIT_HI
,
964 WINED3DSIH_FIRSTBIT_LO
,
965 WINED3DSIH_FIRSTBIT_SHI
,
970 WINED3DSIH_GATHER4_C
,
971 WINED3DSIH_GATHER4_PO
,
972 WINED3DSIH_GATHER4_PO_C
,
974 WINED3DSIH_HS_CONTROL_POINT_PHASE
,
976 WINED3DSIH_HS_FORK_PHASE
,
977 WINED3DSIH_HS_JOIN_PHASE
,
988 WINED3DSIH_IMM_ATOMIC_ALLOC
,
989 WINED3DSIH_IMM_ATOMIC_AND
,
990 WINED3DSIH_IMM_ATOMIC_CMP_EXCH
,
991 WINED3DSIH_IMM_ATOMIC_CONSUME
,
992 WINED3DSIH_IMM_ATOMIC_EXCH
,
993 WINED3DSIH_IMM_ATOMIC_IADD
,
994 WINED3DSIH_IMM_ATOMIC_IMAX
,
995 WINED3DSIH_IMM_ATOMIC_IMIN
,
996 WINED3DSIH_IMM_ATOMIC_OR
,
997 WINED3DSIH_IMM_ATOMIC_UMAX
,
998 WINED3DSIH_IMM_ATOMIC_UMIN
,
999 WINED3DSIH_IMM_ATOMIC_XOR
,
1010 WINED3DSIH_LD_STRUCTURED
,
1011 WINED3DSIH_LD_UAV_TYPED
,
1043 WINED3DSIH_ROUND_NE
,
1044 WINED3DSIH_ROUND_NI
,
1045 WINED3DSIH_ROUND_PI
,
1049 WINED3DSIH_SAMPLE_B
,
1050 WINED3DSIH_SAMPLE_C
,
1051 WINED3DSIH_SAMPLE_C_LZ
,
1052 WINED3DSIH_SAMPLE_GRAD
,
1053 WINED3DSIH_SAMPLE_INFO
,
1054 WINED3DSIH_SAMPLE_LOD
,
1055 WINED3DSIH_SAMPLE_POS
,
1062 WINED3DSIH_STORE_RAW
,
1063 WINED3DSIH_STORE_STRUCTURED
,
1064 WINED3DSIH_STORE_UAV_TYPED
,
1072 WINED3DSIH_TEXCOORD
,
1073 WINED3DSIH_TEXDEPTH
,
1075 WINED3DSIH_TEXDP3TEX
,
1079 WINED3DSIH_TEXM3x2DEPTH
,
1080 WINED3DSIH_TEXM3x2PAD
,
1081 WINED3DSIH_TEXM3x2TEX
,
1083 WINED3DSIH_TEXM3x3DIFF
,
1084 WINED3DSIH_TEXM3x3PAD
,
1085 WINED3DSIH_TEXM3x3SPEC
,
1086 WINED3DSIH_TEXM3x3TEX
,
1087 WINED3DSIH_TEXM3x3VSPEC
,
1088 WINED3DSIH_TEXREG2AR
,
1089 WINED3DSIH_TEXREG2GB
,
1090 WINED3DSIH_TEXREG2RGB
,
1101 WINED3DSIH_TABLE_SIZE
1104 struct wined3d_shader_version
1106 enum wined3d_shader_type type
;
1111 struct wined3d_shader_resource_info
1113 enum wined3d_shader_resource_type type
;
1114 enum wined3d_data_type data_type
;
1116 unsigned int stride
;
1119 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1121 struct wined3d_shader_sampler_map_entry
1123 unsigned int resource_idx
;
1124 unsigned int sampler_idx
;
1125 unsigned int bind_idx
;
1128 struct wined3d_shader_sampler_map
1130 struct wined3d_shader_sampler_map_entry
*entries
;
1135 struct wined3d_shader_immediate_constant_buffer
1137 unsigned int vec4_count
;
1138 uint32_t data
[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
];
1141 struct wined3d_shader_indexable_temp
1144 unsigned int register_idx
;
1145 unsigned int register_size
;
1146 unsigned int component_count
;
1149 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1151 struct wined3d_shader_reg_maps
1153 struct wined3d_shader_version shader_version
;
1154 BYTE texcoord
; /* MAX_REG_TEXCRD, 8 */
1155 BYTE address
; /* MAX_REG_ADDR, 1 */
1156 WORD labels
; /* MAX_LABELS, 16 */
1157 DWORD temporary
; /* 32 */
1158 unsigned int temporary_count
;
1159 uint32_t *constf
; /* pixel, vertex */
1160 struct list indexable_temps
;
1161 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1164 DWORD texcoord_mask
[MAX_REG_TEXCRD
]; /* vertex < 3.0 */
1165 BYTE output_registers_mask
[MAX_REG_OUTPUT
]; /* vertex >= 3.0 */
1167 DWORD input_registers
; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1168 DWORD output_registers
; /* MAX_REG_OUTPUT, 32 */
1169 WORD integer_constants
; /* WINED3D_MAX_CONSTS_I, 16 */
1170 WORD boolean_constants
; /* WINED3D_MAX_CONSTS_B, 16 */
1171 WORD local_int_consts
; /* WINED3D_MAX_CONSTS_I, 16 */
1172 WORD local_bool_consts
; /* WINED3D_MAX_CONSTS_B, 16 */
1173 UINT cb_sizes
[WINED3D_MAX_CBS
];
1174 uint32_t cb_map
; /* WINED3D_MAX_CBS, 15 */
1176 struct wined3d_shader_resource_info resource_info
[MAX_SHADER_RESOURCE_VIEWS
];
1177 uint32_t resource_map
[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS
)];
1178 struct wined3d_shader_sampler_map sampler_map
;
1179 DWORD sampler_comparison_mode
;
1180 BYTE bumpmat
; /* WINED3D_MAX_TEXTURES, 8 */
1181 BYTE luminanceparams
; /* WINED3D_MAX_TEXTURES, 8 */
1182 struct wined3d_shader_resource_info uav_resource_info
[MAX_UNORDERED_ACCESS_VIEWS
];
1183 DWORD uav_read_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1184 DWORD uav_counter_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1186 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1187 DWORD cull_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1192 DWORD usestexldd
: 1;
1194 DWORD usesfacing
: 1;
1195 DWORD usesrelconstF
: 1;
1197 DWORD usestexldl
: 1;
1201 DWORD point_size
: 1;
1203 DWORD input_rel_addressing
: 1;
1204 DWORD viewport_array
: 1;
1205 DWORD sample_mask
: 1;
1208 DWORD rt_mask
; /* Used render targets, 32 max. */
1210 /* Whether or not loops are used in this shader, and nesting depth */
1211 unsigned int loop_depth
;
1212 unsigned int min_rel_offset
, max_rel_offset
;
1214 struct wined3d_shader_tgsm
*tgsm
;
1215 SIZE_T tgsm_capacity
;
1216 unsigned int tgsm_count
;
1219 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1220 * state information between multiple instructions. */
1221 struct wined3d_shader_tex_mx
1223 unsigned int current_row
;
1224 unsigned int texcoord_w
[2];
1227 struct wined3d_shader_parser_state
1229 unsigned int current_loop_depth
;
1230 unsigned int current_loop_reg
;
1234 struct wined3d_shader_context
1236 const struct wined3d_shader
*shader
;
1237 const struct wined3d_shader_reg_maps
*reg_maps
;
1238 struct wined3d_string_buffer
*buffer
;
1239 struct wined3d_shader_tex_mx
*tex_mx
;
1240 struct wined3d_shader_parser_state
*state
;
1244 struct wined3d_shader_register_index
1246 const struct wined3d_shader_src_param
*rel_addr
;
1247 unsigned int offset
;
1250 struct wined3d_shader_register
1252 enum wined3d_shader_register_type type
;
1253 enum wined3d_data_type data_type
;
1254 struct wined3d_shader_register_index idx
[2];
1255 enum wined3d_immconst_type immconst_type
;
1258 unsigned int immconst_data
[4];
1259 unsigned fp_body_idx
;
1263 struct wined3d_shader_dst_param
1265 struct wined3d_shader_register reg
;
1266 uint32_t write_mask
;
1271 struct wined3d_shader_src_param
1273 struct wined3d_shader_register reg
;
1275 enum wined3d_shader_src_modifier modifiers
;
1278 struct wined3d_shader_index_range
1280 struct wined3d_shader_dst_param first_register
;
1281 unsigned int last_register
;
1284 struct wined3d_shader_semantic
1286 enum wined3d_decl_usage usage
;
1288 enum wined3d_shader_resource_type resource_type
;
1289 unsigned int sample_count
;
1290 enum wined3d_data_type resource_data_type
;
1291 struct wined3d_shader_dst_param reg
;
1294 enum wined3d_shader_input_sysval_semantic
1296 WINED3D_SIV_POSITION
= 1,
1297 WINED3D_SIV_CLIP_DISTANCE
= 2,
1298 WINED3D_SIV_CULL_DISTANCE
= 3,
1299 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX
= 4,
1300 WINED3D_SIV_VIEWPORT_ARRAY_INDEX
= 5,
1301 WINED3D_SIV_VERTEX_ID
= 6,
1302 WINED3D_SIV_PRIMITIVE_ID
= 7,
1303 WINED3D_SIV_INSTANCE_ID
= 8,
1304 WINED3D_SIV_IS_FRONT_FACE
= 9,
1305 WINED3D_SIV_SAMPLE_INDEX
= 10,
1306 WINED3D_SIV_QUAD_U0_TESS_FACTOR
= 11,
1307 WINED3D_SIV_QUAD_V0_TESS_FACTOR
= 12,
1308 WINED3D_SIV_QUAD_U1_TESS_FACTOR
= 13,
1309 WINED3D_SIV_QUAD_V1_TESS_FACTOR
= 14,
1310 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR
= 15,
1311 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR
= 16,
1312 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR
= 17,
1313 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR
= 18,
1314 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR
= 19,
1315 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR
= 20,
1316 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR
= 21,
1317 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR
= 22,
1320 struct wined3d_shader_register_semantic
1322 struct wined3d_shader_dst_param reg
;
1323 enum wined3d_shader_input_sysval_semantic sysval_semantic
;
1326 struct wined3d_shader_structured_resource
1328 struct wined3d_shader_dst_param reg
;
1329 unsigned int byte_stride
;
1332 struct wined3d_shader_tgsm
1335 unsigned int stride
;
1338 struct wined3d_shader_tgsm_raw
1340 struct wined3d_shader_dst_param reg
;
1341 unsigned int byte_count
;
1344 struct wined3d_shader_tgsm_structured
1346 struct wined3d_shader_dst_param reg
;
1347 unsigned int byte_stride
;
1348 unsigned int structure_count
;
1351 struct wined3d_shader_thread_group_size
1353 unsigned int x
, y
, z
;
1356 struct wined3d_shader_function_table_pointer
1359 unsigned int array_size
;
1360 unsigned int body_count
;
1361 unsigned int table_count
;
1364 struct wined3d_shader_texel_offset
1366 signed char u
, v
, w
;
1369 struct wined3d_shader_primitive_type
1371 enum wined3d_primitive_type type
;
1372 unsigned int patch_vertex_count
;
1375 struct wined3d_shader_instruction
1377 const struct wined3d_shader_context
*ctx
;
1378 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
1380 unsigned int dst_count
;
1381 unsigned int src_count
;
1382 const struct wined3d_shader_dst_param
*dst
;
1383 const struct wined3d_shader_src_param
*src
;
1384 struct wined3d_shader_texel_offset texel_offset
;
1385 enum wined3d_shader_resource_type resource_type
;
1386 enum wined3d_data_type resource_data_type
;
1388 const struct wined3d_shader_src_param
*predicate
;
1391 struct wined3d_shader_semantic semantic
;
1392 struct wined3d_shader_register_semantic register_semantic
;
1393 struct wined3d_shader_primitive_type primitive_type
;
1394 struct wined3d_shader_dst_param dst
;
1395 struct wined3d_shader_src_param src
;
1398 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1399 struct wined3d_shader_structured_resource structured_resource
;
1400 struct wined3d_shader_tgsm_raw tgsm_raw
;
1401 struct wined3d_shader_tgsm_structured tgsm_structured
;
1402 struct wined3d_shader_thread_group_size thread_group_size
;
1403 enum wined3d_tessellator_domain tessellator_domain
;
1404 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1405 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1406 float max_tessellation_factor
;
1407 struct wined3d_shader_index_range index_range
;
1408 struct wined3d_shader_indexable_temp indexable_temp
;
1409 struct wined3d_shader_function_table_pointer fp
;
1413 static inline BOOL
wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction
*ins
)
1415 return ins
->texel_offset
.u
|| ins
->texel_offset
.v
|| ins
->texel_offset
.w
;
1418 struct wined3d_shader_attribute
1420 enum wined3d_decl_usage usage
;
1424 struct wined3d_shader_loop_control
1431 struct wined3d_shader_frontend
1433 void *(*shader_init
)(const DWORD
*byte_code
, size_t byte_code_size
,
1434 const struct wined3d_shader_signature
*output_signature
);
1435 void (*shader_free
)(void *data
);
1436 void (*shader_read_header
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
);
1437 void (*shader_read_instruction
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
);
1438 BOOL (*shader_is_end
)(void *data
, const DWORD
**ptr
);
1441 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN
;
1442 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN
;
1444 HRESULT
wined3d_shader_extract_from_dxbc(struct wined3d_shader
*shader
,
1445 unsigned int max_shader_version
, enum vkd3d_shader_source_type
*source_type
) DECLSPEC_HIDDEN
;
1446 BOOL
shader_get_stream_output_register_info(const struct wined3d_shader
*shader
,
1447 const struct wined3d_stream_output_element
*so_element
, unsigned int *register_idx
,
1448 unsigned int *component_idx
) DECLSPEC_HIDDEN
;
1450 typedef void (*SHADER_HANDLER
)(const struct wined3d_shader_instruction
*);
1452 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1453 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1454 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1455 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1456 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1460 unsigned int vs_version
;
1461 unsigned int hs_version
;
1462 unsigned int ds_version
;
1463 unsigned int gs_version
;
1464 unsigned int ps_version
;
1465 unsigned int cs_version
;
1467 unsigned int vs_uniform_count
;
1468 unsigned int ps_uniform_count
;
1469 float ps_1x_max_value
;
1470 unsigned int varying_count
;
1475 enum wined3d_gl_resource_type
1477 WINED3D_GL_RES_TYPE_TEX_1D
= 0,
1478 WINED3D_GL_RES_TYPE_TEX_2D
= 1,
1479 WINED3D_GL_RES_TYPE_TEX_3D
= 2,
1480 WINED3D_GL_RES_TYPE_TEX_CUBE
= 3,
1481 WINED3D_GL_RES_TYPE_TEX_RECT
= 4,
1482 WINED3D_GL_RES_TYPE_BUFFER
= 5,
1483 WINED3D_GL_RES_TYPE_RB
= 6,
1484 WINED3D_GL_RES_TYPE_COUNT
= 7,
1487 enum wined3d_vertex_processing_mode
1490 WINED3D_VP_MODE_SHADER
,
1491 WINED3D_VP_MODE_NONE
,
1494 #define WINED3D_CONST_NUM_UNUSED ~0U
1496 enum wined3d_ffp_ps_fog_mode
1498 WINED3D_FFP_PS_FOG_OFF
,
1499 WINED3D_FFP_PS_FOG_LINEAR
,
1500 WINED3D_FFP_PS_FOG_EXP
,
1501 WINED3D_FFP_PS_FOG_EXP2
,
1504 /* Stateblock dependent parameters which have to be hardcoded
1505 * into the shader code
1508 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1509 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1510 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1511 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1512 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1514 /* Used for Shader Model 1 pixel shaders to track the bound texture
1515 * type. 2D and RECT textures are separated through NP2 fixup. */
1516 enum wined3d_shader_tex_types
1518 WINED3D_SHADER_TEX_2D
= 0,
1519 WINED3D_SHADER_TEX_3D
= 1,
1520 WINED3D_SHADER_TEX_CUBE
= 2,
1521 WINED3D_SHADER_TEX_ERR
= 3,
1524 struct ps_compile_args
1526 struct color_fixup_desc color_fixup
[WINED3D_MAX_FRAGMENT_SAMPLERS
];
1527 enum wined3d_vertex_processing_mode vp_mode
;
1528 enum wined3d_ffp_ps_fog_mode fog
;
1529 DWORD tex_types
; /* ps 1 - 3, 16 textures */
1530 WORD tex_transform
; /* ps 1.0-1.3, 4 textures */
1531 WORD srgb_correction
;
1532 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1533 D3D9 has a limit of 16 samplers and the fixup is superfluous
1534 in D3D10 (unconditional NP2 support mandatory). */
1536 WORD shadow
; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1537 WORD texcoords_initialized
; /* WINED3D_MAX_TEXTURES, 8 */
1538 WORD padding_to_dword
;
1539 DWORD pointsprite
: 1;
1540 DWORD flatshading
: 1;
1541 DWORD alpha_test_func
: 3;
1542 DWORD y_correction
: 1;
1543 DWORD rt_alpha_swizzle
: 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1544 DWORD dual_source_blend
: 1;
1554 struct vs_compile_args
1556 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1557 unsigned int next_shader_input_count
;
1558 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1560 BYTE clip_enabled
: 1;
1561 BYTE point_size
: 1;
1562 BYTE per_vertex_point_size
: 1;
1563 BYTE flatshading
: 1;
1564 BYTE next_shader_type
: 3;
1568 struct ds_compile_args
1570 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1571 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1572 unsigned int output_count
: 16;
1573 unsigned int next_shader_type
: 3;
1574 unsigned int render_offscreen
: 1;
1575 unsigned int padding
: 12;
1576 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1579 struct gs_compile_args
1581 unsigned int output_count
;
1582 enum wined3d_primitive_type primitive_type
;
1583 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1586 struct wined3d_shader_backend_ops
1588 void (*shader_handle_instruction
)(const struct wined3d_shader_instruction
*);
1589 void (*shader_precompile
)(void *shader_priv
, struct wined3d_shader
*shader
);
1590 void (*shader_select
)(void *shader_priv
, struct wined3d_context
*context
,
1591 const struct wined3d_state
*state
);
1592 void (*shader_select_compute
)(void *shader_priv
, struct wined3d_context
*context
,
1593 const struct wined3d_state
*state
);
1594 void (*shader_disable
)(void *shader_priv
, struct wined3d_context
*context
);
1595 void (*shader_update_float_vertex_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1596 void (*shader_update_float_pixel_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1597 void (*shader_load_constants
)(void *shader_priv
, struct wined3d_context
*context
,
1598 const struct wined3d_state
*state
);
1599 void (*shader_destroy
)(struct wined3d_shader
*shader
);
1600 HRESULT (*shader_alloc_private
)(struct wined3d_device
*device
, const struct wined3d_vertex_pipe_ops
*vertex_pipe
,
1601 const struct wined3d_fragment_pipe_ops
*fragment_pipe
);
1602 void (*shader_free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
1603 BOOL (*shader_allocate_context_data
)(struct wined3d_context
*context
);
1604 void (*shader_free_context_data
)(struct wined3d_context
*context
);
1605 void (*shader_init_context_state
)(struct wined3d_context
*context
);
1606 void (*shader_get_caps
)(const struct wined3d_adapter
*adapter
, struct shader_caps
*caps
);
1607 BOOL (*shader_color_fixup_supported
)(struct color_fixup_desc fixup
);
1608 BOOL (*shader_has_ffp_proj_control
)(void *shader_priv
);
1609 uint64_t (*shader_compile
)(struct wined3d_context
*context
, const struct wined3d_shader_desc
*shader_desc
,
1610 enum wined3d_shader_type shader_type
);
1613 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN
;
1614 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN
;
1615 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN
;
1617 const struct wined3d_shader_backend_ops
*wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN
;
1619 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1621 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1622 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1623 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1624 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1626 static inline void wined3d_color_from_d3dcolor(struct wined3d_color
*wined3d_color
, DWORD d3d_color
)
1628 wined3d_color
->r
= D3DCOLOR_B_R(d3d_color
) / 255.0f
;
1629 wined3d_color
->g
= D3DCOLOR_B_G(d3d_color
) / 255.0f
;
1630 wined3d_color
->b
= D3DCOLOR_B_B(d3d_color
) / 255.0f
;
1631 wined3d_color
->a
= D3DCOLOR_B_A(d3d_color
) / 255.0f
;
1634 extern const struct wined3d_vec4 wined3d_srgb_const
[] DECLSPEC_HIDDEN
;
1636 static inline float wined3d_srgb_from_linear(float colour
)
1640 if (colour
< wined3d_srgb_const
[1].x
)
1641 return colour
* wined3d_srgb_const
[0].w
;
1643 return wined3d_srgb_const
[0].y
* powf(colour
, wined3d_srgb_const
[0].x
) - wined3d_srgb_const
[0].z
;
1647 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color
*colour_srgb
,
1648 const struct wined3d_color
*colour
)
1650 colour_srgb
->r
= wined3d_srgb_from_linear(colour
->r
);
1651 colour_srgb
->g
= wined3d_srgb_from_linear(colour
->g
);
1652 colour_srgb
->b
= wined3d_srgb_from_linear(colour
->b
);
1653 colour_srgb
->a
= colour
->a
;
1656 void wined3d_check_gl_call(const struct wined3d_gl_info
*gl_info
,
1657 const char *file
, unsigned int line
, const char *name
) DECLSPEC_HIDDEN
;
1659 /* Checking of API calls */
1660 /* --------------------- */
1661 #ifndef WINE_NO_DEBUG_MSGS
1662 #define checkGLcall(A) \
1664 if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1665 && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1666 wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1669 #define checkGLcall(A) do {} while(0)
1674 /* client_map_count and map_ptr are accessed from both the client and CS
1675 * threads, and protected by wined3d_device.bo_map_lock. */
1678 size_t buffer_offset
;
1679 size_t memory_offset
;
1680 unsigned int client_map_count
;
1684 struct wined3d_bo_gl
1686 struct wined3d_bo b
;
1690 struct wined3d_allocator_block
*memory
;
1697 uint64_t command_fence_id
;
1700 static inline struct wined3d_bo_gl
*wined3d_bo_gl(struct wined3d_bo
*bo
)
1702 return CONTAINING_RECORD(bo
, struct wined3d_bo_gl
, b
);
1705 static inline GLuint
wined3d_bo_gl_id(struct wined3d_bo
*bo
)
1707 return bo
? wined3d_bo_gl(bo
)->id
: 0;
1710 struct wined3d_bo_user
1716 struct wined3d_bo_address
1718 struct wined3d_bo
*buffer_object
;
1722 struct wined3d_const_bo_address
1724 struct wined3d_bo
*buffer_object
;
1728 static inline struct wined3d_const_bo_address
*wined3d_const_bo_address(const struct wined3d_bo_address
*data
)
1730 return (struct wined3d_const_bo_address
*)data
;
1733 struct wined3d_stream_info_element
1735 const struct wined3d_format
*format
;
1736 struct wined3d_bo_address data
;
1738 unsigned int stream_idx
;
1739 unsigned int divisor
;
1743 struct wined3d_stream_info
1745 struct wined3d_stream_info_element elements
[MAX_ATTRIBS
];
1746 DWORD position_transformed
: 1;
1748 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1749 DWORD use_map
; /* MAX_ATTRIBS, 32 */
1752 void wined3d_stream_info_from_declaration(struct wined3d_stream_info
*stream_info
,
1753 const struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
) DECLSPEC_HIDDEN
;
1755 struct wined3d_direct_dispatch_parameters
1757 unsigned int group_count_x
;
1758 unsigned int group_count_y
;
1759 unsigned int group_count_z
;
1762 struct wined3d_indirect_dispatch_parameters
1764 struct wined3d_buffer
*buffer
;
1765 unsigned int offset
;
1768 struct wined3d_dispatch_parameters
1773 struct wined3d_direct_dispatch_parameters direct
;
1774 struct wined3d_indirect_dispatch_parameters indirect
;
1778 struct wined3d_direct_draw_parameters
1780 int base_vertex_idx
;
1781 unsigned int start_idx
;
1782 unsigned int index_count
;
1783 unsigned int start_instance
;
1784 unsigned int instance_count
;
1787 struct wined3d_indirect_draw_parameters
1789 struct wined3d_buffer
*buffer
;
1790 unsigned int offset
;
1793 struct wined3d_draw_parameters
1798 struct wined3d_direct_draw_parameters direct
;
1799 struct wined3d_indirect_draw_parameters indirect
;
1804 void draw_primitive(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1805 const struct wined3d_draw_parameters
*draw_parameters
) DECLSPEC_HIDDEN
;
1806 void dispatch_compute(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1807 const struct wined3d_dispatch_parameters
*dispatch_parameters
) DECLSPEC_HIDDEN
;
1811 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1812 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1814 /* Routines and structures related to state management */
1816 #define STATE_RENDER(a) (a)
1817 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1819 #define STATE_TEXTURESTAGE(stage, num) \
1820 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1821 #define STATE_IS_TEXTURESTAGE(a) \
1822 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1824 /* + 1 because samplers start with 0 */
1825 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1826 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1828 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1829 #define STATE_IS_GRAPHICS_SHADER(a) \
1830 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1832 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1833 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1834 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1835 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1837 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1838 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1840 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1841 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1843 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1844 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1846 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1847 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1848 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1849 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1851 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1852 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1854 #define STATE_VIEWPORT (STATE_VDECL + 1)
1855 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1857 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1858 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1859 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1860 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1862 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1863 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1865 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1866 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1868 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1869 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1871 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1872 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1874 #define STATE_DEPTH_BOUNDS (STATE_RASTERIZER + 1)
1875 #define STATE_IS_DEPTH_BOUNDS(a) ((a) == STATE_DEPTH_BOUNDS)
1877 #define STATE_POINTSPRITECOORDORIGIN (STATE_DEPTH_BOUNDS + 1)
1878 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1880 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1881 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1883 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1884 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1886 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1887 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1889 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1890 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1892 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1893 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1895 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1896 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1898 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1899 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1901 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1902 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1904 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1905 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1907 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1908 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1910 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1912 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1913 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1915 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1916 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1918 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1919 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1921 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1922 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1924 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1925 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1927 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1928 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1930 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1931 #define STATE_CONSTANT_BUFFER(a) \
1932 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1933 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1934 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1942 union wined3d_gl_fence_object
1948 enum wined3d_fence_result
1951 WINED3D_FENCE_WAITING
,
1952 WINED3D_FENCE_NOT_STARTED
,
1953 WINED3D_FENCE_WRONG_THREAD
,
1954 WINED3D_FENCE_ERROR
,
1957 struct wined3d_fence
1960 union wined3d_gl_fence_object object
;
1961 struct wined3d_context_gl
*context_gl
;
1964 HRESULT
wined3d_fence_create(struct wined3d_device
*device
, struct wined3d_fence
**fence
) DECLSPEC_HIDDEN
;
1965 void wined3d_fence_destroy(struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
1966 void wined3d_fence_issue(struct wined3d_fence
*fence
, struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
1967 enum wined3d_fence_result
wined3d_fence_wait(const struct wined3d_fence
*fence
,
1968 struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
1969 enum wined3d_fence_result
wined3d_fence_test(const struct wined3d_fence
*fence
,
1970 struct wined3d_device
*device
, uint32_t flags
) DECLSPEC_HIDDEN
;
1972 /* Direct3D terminology with little modifications. We do not have an issued
1973 * state because only the driver knows about it, but we have a created state
1974 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1975 enum wined3d_query_state
1982 struct wined3d_query_ops
1984 BOOL (*query_poll
)(struct wined3d_query
*query
, uint32_t flags
);
1985 BOOL (*query_issue
)(struct wined3d_query
*query
, uint32_t flags
);
1986 void (*query_destroy
)(struct wined3d_query
*query
);
1989 struct wined3d_query
1994 const struct wined3d_parent_ops
*parent_ops
;
1995 struct wined3d_device
*device
;
1996 enum wined3d_query_state state
;
1997 enum wined3d_query_type type
;
2000 const struct wined3d_query_ops
*query_ops
;
2002 LONG counter_main
, counter_retrieved
;
2003 struct list poll_list_entry
;
2005 GLuint buffer_object
;
2010 HRESULT
wined3d_query_gl_create(struct wined3d_device
*device
, enum wined3d_query_type type
, void *parent
,
2011 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
) DECLSPEC_HIDDEN
;
2012 void wined3d_query_gl_destroy_buffer_object(struct wined3d_context_gl
*context_gl
,
2013 struct wined3d_query
*query
) DECLSPEC_HIDDEN
;
2015 struct wined3d_event_query
2017 struct wined3d_query query
;
2019 struct wined3d_fence fence
;
2023 struct wined3d_occlusion_query
2025 struct wined3d_query query
;
2029 struct wined3d_context_gl
*context_gl
;
2034 struct wined3d_timestamp_query
2036 struct wined3d_query query
;
2040 struct wined3d_context_gl
*context_gl
;
2044 union wined3d_gl_so_statistics_query
2054 struct wined3d_so_statistics_query
2056 struct wined3d_query query
;
2059 union wined3d_gl_so_statistics_query u
;
2060 struct wined3d_context_gl
*context_gl
;
2061 unsigned int stream_idx
;
2062 struct wined3d_query_data_so_statistics statistics
;
2066 union wined3d_gl_pipeline_statistics_query
2073 GLuint vertex_shader
;
2074 GLuint tess_control_shader
;
2075 GLuint tess_eval_shader
;
2076 GLuint geometry_shader
;
2077 GLuint geometry_primitives
;
2078 GLuint fragment_shader
;
2079 GLuint compute_shader
;
2080 GLuint clipping_input
;
2081 GLuint clipping_output
;
2085 struct wined3d_pipeline_statistics_query
2087 struct wined3d_query query
;
2090 union wined3d_gl_pipeline_statistics_query u
;
2091 struct wined3d_context_gl
*context_gl
;
2092 struct wined3d_query_data_pipeline_statistics statistics
;
2096 #define WINED3D_QUERY_POOL_SIZE 256
2098 struct wined3d_gl_view
2104 struct wined3d_range
2106 unsigned int offset
;
2110 struct wined3d_rendertarget_info
2112 struct wined3d_gl_view gl_view
;
2113 struct wined3d_resource
*resource
;
2114 unsigned int sub_resource_idx
;
2115 unsigned int layer_count
;
2118 struct wined3d_fb_state
2120 struct wined3d_rendertarget_view
*render_targets
[WINED3D_MAX_RENDER_TARGETS
];
2121 struct wined3d_rendertarget_view
*depth_stencil
;
2124 #define MAX_GL_FRAGMENT_SAMPLERS 32
2126 struct wined3d_context
2128 const struct wined3d_d3d_info
*d3d_info
;
2129 const struct wined3d_state_entry
*state_table
;
2130 uint32_t dirty_graphics_states
[WINED3D_BITMAP_SIZE(STATE_HIGHEST
)];
2131 uint32_t dirty_compute_states
[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT
)];
2133 struct wined3d_device
*device
;
2134 struct wined3d_swapchain
*swapchain
;
2137 struct wined3d_texture
*texture
;
2138 unsigned int sub_resource_idx
;
2141 /* Stores some information about the context state for optimization */
2142 DWORD last_swizzle_map
; /* MAX_ATTRIBS, 32 */
2144 DWORD shader_update_mask
: 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
2145 DWORD update_shader_resource_bindings
: 1;
2146 DWORD update_compute_shader_resource_bindings
: 1;
2147 DWORD update_unordered_access_view_bindings
: 1;
2148 DWORD update_compute_unordered_access_view_bindings
: 1;
2149 DWORD last_was_rhw
: 1; /* True iff last draw_primitive was in xyzrhw mode. */
2150 DWORD last_was_pshader
: 1;
2151 DWORD last_was_vshader
: 1;
2152 DWORD last_was_diffuse
: 1;
2153 DWORD last_was_specular
: 1;
2154 DWORD last_was_normal
: 1;
2155 DWORD last_was_ffp_blit
: 1;
2156 DWORD last_was_blit
: 1;
2157 DWORD last_was_ckey
: 1;
2158 DWORD last_was_dual_source_blend
: 1;
2159 DWORD texShaderBumpMap
: 8; /* WINED3D_MAX_TEXTURES, 8 */
2160 DWORD lowest_disabled_stage
: 4; /* Max WINED3D_MAX_TEXTURES, 8 */
2162 DWORD lastWasPow2Texture
: 8; /* WINED3D_MAX_TEXTURES, 8 */
2163 DWORD fixed_function_usage_map
: 8; /* WINED3D_MAX_TEXTURES, 8 */
2164 DWORD use_immediate_mode_draw
: 1;
2165 DWORD uses_uavs
: 1;
2166 DWORD uses_fbo_attached_resources
: 1;
2167 DWORD transform_feedback_active
: 1;
2168 DWORD transform_feedback_paused
: 1;
2169 DWORD fog_coord
: 1;
2170 DWORD render_offscreen
: 1;
2172 DWORD destroyed
: 1;
2173 DWORD destroy_delayed
: 1;
2174 DWORD namedArraysLoaded
: 1;
2177 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
2179 DWORD constant_update_mask
;
2180 DWORD numbered_array_mask
;
2181 enum fogsource fog_source
;
2184 void *shader_backend_data
;
2185 void *fragment_pipe_data
;
2187 struct wined3d_stream_info stream_info
;
2189 unsigned int viewport_count
;
2190 unsigned int scissor_rect_count
;
2193 void wined3d_context_cleanup(struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
2194 void wined3d_context_init(struct wined3d_context
*context
, struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
2195 void context_preload_textures(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2196 void context_update_stream_info(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2198 HRESULT
wined3d_context_no3d_init(struct wined3d_context
*context_no3d
,
2199 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
2201 struct wined3d_command_fence_gl
2204 struct wined3d_fence
*fence
;
2207 struct wined3d_context_gl
2209 struct wined3d_context c
;
2211 const struct wined3d_gl_info
*gl_info
;
2213 DWORD tid
; /* Thread ID which owns this context at the moment. */
2215 uint32_t dc_is_private
: 1;
2216 uint32_t dc_has_format
: 1; /* Only meaningful for private DCs. */
2217 uint32_t fog_enabled
: 1;
2218 uint32_t diffuse_attrib_to_1
: 1;
2219 uint32_t rebind_fbo
: 1;
2220 uint32_t untracked_material_count
: 2; /* Max value 2 */
2221 uint32_t needs_set
: 1;
2222 uint32_t internal_format_set
: 1;
2224 uint32_t padding
: 22;
2226 uint32_t default_attrib_value_set
;
2228 GLenum tracking_parm
; /* Which source is tracking current colour. */
2229 GLenum untracked_materials
[2];
2231 unsigned int active_texture
;
2233 GLenum
*texture_type
;
2235 /* The WGL context. */
2240 HWND restore_pf_win
;
2248 unsigned int fbo_entry_count
;
2249 struct list fbo_list
;
2250 struct list fbo_destroy_list
;
2251 struct fbo_entry
*current_fbo
;
2252 GLuint fbo_read_binding
;
2253 GLuint fbo_draw_binding
;
2254 struct wined3d_rendertarget_info blit_targets
[WINED3D_MAX_RENDER_TARGETS
];
2255 uint32_t draw_buffers_mask
; /* Enabled draw buffers, 31 max. */
2258 struct list occlusion_queries
;
2260 struct list timestamp_queries
;
2261 struct list so_statistics_queries
;
2262 struct list pipeline_statistics_queries
;
2264 GLuint
*free_occlusion_queries
;
2265 SIZE_T free_occlusion_query_size
;
2266 unsigned int free_occlusion_query_count
;
2268 union wined3d_gl_fence_object
*free_fences
;
2269 SIZE_T free_fence_size
;
2270 unsigned int free_fence_count
;
2272 GLuint
*free_timestamp_queries
;
2273 SIZE_T free_timestamp_query_size
;
2274 unsigned int free_timestamp_query_count
;
2276 union wined3d_gl_so_statistics_query
*free_so_statistics_queries
;
2277 SIZE_T free_so_statistics_query_size
;
2278 unsigned int free_so_statistics_query_count
;
2280 union wined3d_gl_pipeline_statistics_query
*free_pipeline_statistics_queries
;
2281 SIZE_T free_pipeline_statistics_query_size
;
2282 unsigned int free_pipeline_statistics_query_count
;
2286 unsigned int tex_unit_map
[WINED3D_MAX_COMBINED_SAMPLERS
];
2287 unsigned int rev_tex_unit_map
[MAX_GL_FRAGMENT_SAMPLERS
+ WINED3D_MAX_VERTEX_SAMPLERS
];
2289 /* Extension emulation. */
2290 GLint gl_fog_source
;
2291 GLfloat fog_coord_value
;
2292 GLfloat colour
[4], fog_start
, fog_end
, fog_colour
[4];
2294 GLuint dummy_arbfp_prog
;
2298 struct wined3d_command_fence_gl
*fences
;
2304 static inline struct wined3d_context_gl
*wined3d_context_gl(struct wined3d_context
*context
)
2306 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
2309 static inline const struct wined3d_context_gl
*wined3d_context_gl_const(const struct wined3d_context
*context
)
2311 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
2314 struct wined3d_context
*wined3d_context_gl_acquire(const struct wined3d_device
*device
,
2315 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2316 void wined3d_context_gl_active_texture(struct wined3d_context_gl
*context_gl
,
2317 const struct wined3d_gl_info
*gl_info
, unsigned int unit
) DECLSPEC_HIDDEN
;
2318 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl
*context_gl
,
2319 struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2320 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl
*context_gl
,
2321 struct wined3d_occlusion_query
*query
) DECLSPEC_HIDDEN
;
2322 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl
*context_gl
,
2323 struct wined3d_pipeline_statistics_query
*query
) DECLSPEC_HIDDEN
;
2324 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl
*context_gl
,
2325 struct wined3d_so_statistics_query
*query
) DECLSPEC_HIDDEN
;
2326 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl
*context_gl
,
2327 struct wined3d_timestamp_query
*query
) DECLSPEC_HIDDEN
;
2328 GLuint
wined3d_context_gl_allocate_vram_chunk_buffer(struct wined3d_context_gl
*context_gl
,
2329 unsigned int pool
, size_t size
) DECLSPEC_HIDDEN
;
2330 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl
*context_gl
,
2331 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2332 BOOL
wined3d_context_gl_apply_clear_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
,
2333 unsigned int rt_count
, const struct wined3d_fb_state
*fb
) DECLSPEC_HIDDEN
;
2334 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl
*context_gl
, GLenum target
,
2335 struct wined3d_resource
*rt
, unsigned int rt_sub_resource_idx
,
2336 struct wined3d_resource
*ds
, unsigned int ds_sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
2337 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl
*context_gl
,
2338 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2339 void wined3d_context_gl_bind_bo(struct wined3d_context_gl
*context_gl
, GLenum binding
, GLuint name
) DECLSPEC_HIDDEN
;
2340 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2341 void wined3d_context_gl_bind_texture(struct wined3d_context_gl
*context_gl
,
2342 GLenum target
, GLuint name
) DECLSPEC_HIDDEN
;
2343 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl
*context_gl
, GLenum target
) DECLSPEC_HIDDEN
;
2344 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl
*context_gl
,
2345 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
2346 unsigned int range_count
, const struct wined3d_range
*ranges
) DECLSPEC_HIDDEN
;
2347 void wined3d_context_gl_destroy(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2348 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo
) DECLSPEC_HIDDEN
;
2349 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl
*context_gl
, struct wined3d_texture_gl
*texture_gl
,
2350 unsigned int sub_resource_idx
, const RECT
*src_rect
, const RECT
*dst_rect
,
2351 enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
2352 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl
*context_gl
,
2353 struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
2354 const RECT
*src_rect
, const RECT
*dst_rect
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
2355 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl
*context_gl
, uint32_t mask
) DECLSPEC_HIDDEN
;
2356 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2357 void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl
*context_gl
,
2358 const struct wined3d_const_bo_address
*data
, size_t size
) DECLSPEC_HIDDEN
;
2359 void wined3d_context_gl_free_fence(struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2360 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query
*query
) DECLSPEC_HIDDEN
;
2361 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query
*query
) DECLSPEC_HIDDEN
;
2362 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query
*query
) DECLSPEC_HIDDEN
;
2363 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query
*query
) DECLSPEC_HIDDEN
;
2364 struct wined3d_context_gl
*wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN
;
2365 GLenum
wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2366 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl
*context_gl
,
2367 const struct wined3d_shader_version
*shader_version
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
2368 HRESULT
wined3d_context_gl_init(struct wined3d_context_gl
*context_gl
,
2369 struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
2370 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl
*context_gl
,
2371 const struct wined3d_stream_info
*si
, GLuint
*current_bo
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2372 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl
*context_gl
,
2373 const struct wined3d_bo_address
*data
, size_t size
, uint32_t flags
) DECLSPEC_HIDDEN
;
2374 struct wined3d_context_gl
*wined3d_context_gl_reacquire(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2375 void wined3d_context_gl_release(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2376 BOOL
wined3d_context_gl_set_current(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2377 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2378 void wined3d_context_gl_texture_update(struct wined3d_context_gl
*context_gl
,
2379 const struct wined3d_texture_gl
*texture_gl
) DECLSPEC_HIDDEN
;
2380 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2381 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl
*context_gl
, const struct wined3d_bo_address
*data
,
2382 unsigned int range_count
, const struct wined3d_range
*ranges
) DECLSPEC_HIDDEN
;
2383 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl
*context_gl
,
2384 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2385 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl
*context_gl
, uint64_t id
) DECLSPEC_HIDDEN
;
2387 typedef void (*APPLYSTATEFUNC
)(struct wined3d_context
*ctx
, const struct wined3d_state
*state
, DWORD state_id
);
2389 struct wined3d_state_entry
2391 unsigned int representative
;
2392 APPLYSTATEFUNC apply
;
2395 struct wined3d_state_entry_template
2398 struct wined3d_state_entry content
;
2399 unsigned int extension
;
2402 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2403 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2404 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2406 struct fragment_caps
2409 DWORD PrimitiveMiscCaps
;
2410 DWORD TextureOpCaps
;
2411 DWORD MaxTextureBlendStages
;
2412 DWORD MaxSimultaneousTextures
;
2415 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2416 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2418 struct wined3d_fragment_pipe_ops
2420 void (*fp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2421 void (*get_caps
)(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
);
2422 unsigned int (*get_emul_mask
)(const struct wined3d_gl_info
*gl_info
);
2423 void *(*alloc_private
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2424 void (*free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2425 BOOL (*allocate_context_data
)(struct wined3d_context
*context
);
2426 void (*free_context_data
)(struct wined3d_context
*context
);
2427 BOOL (*color_fixup_supported
)(struct color_fixup_desc fixup
);
2428 const struct wined3d_state_entry_template
*states
;
2431 struct wined3d_vertex_caps
2434 BOOL emulated_flatshading
;
2435 BOOL ffp_generic_attributes
;
2436 DWORD max_active_lights
;
2437 DWORD max_vertex_blend_matrices
;
2438 DWORD max_vertex_blend_matrix_index
;
2439 DWORD vertex_processing_caps
;
2441 DWORD max_user_clip_planes
;
2445 struct wined3d_vertex_pipe_ops
2447 void (*vp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2448 void (*vp_get_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
);
2449 unsigned int (*vp_get_emul_mask
)(const struct wined3d_gl_info
*gl_info
);
2450 void *(*vp_alloc
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2451 void (*vp_free
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2452 const struct wined3d_state_entry_template
*vp_states
;
2455 extern const struct wined3d_state_entry_template misc_state_template_gl
[] DECLSPEC_HIDDEN
;
2456 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN
;
2457 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN
;
2458 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN
;
2459 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN
;
2460 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN
;
2461 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN
;
2462 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN
;
2464 const struct wined3d_fragment_pipe_ops
*wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2466 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN
;
2467 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN
;
2468 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN
;
2470 const struct wined3d_vertex_pipe_ops
*wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2472 /* "Base" state table */
2473 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
2474 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
2475 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
2476 const struct wined3d_state_entry_template
*misc
) DECLSPEC_HIDDEN
;
2478 enum wined3d_blit_op
2480 WINED3D_BLIT_OP_COLOR_BLIT
,
2481 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
,
2482 WINED3D_BLIT_OP_COLOR_BLIT_CKEY
,
2483 WINED3D_BLIT_OP_DEPTH_BLIT
,
2484 WINED3D_BLIT_OP_RAW_BLIT
,
2487 struct wined3d_blitter
2489 const struct wined3d_blitter_ops
*ops
;
2490 struct wined3d_blitter
*next
;
2493 struct wined3d_blitter_ops
2495 void (*blitter_destroy
)(struct wined3d_blitter
*blitter
, struct wined3d_context
*context
);
2496 void (*blitter_clear
)(struct wined3d_blitter
*blitter
, struct wined3d_device
*device
,
2497 unsigned int rt_count
, const struct wined3d_fb_state
*fb
, unsigned int rect_count
, const RECT
*clear_rects
,
2498 const RECT
*draw_rect
, uint32_t flags
, const struct wined3d_color
*colour
, float depth
, unsigned int stencil
);
2499 DWORD (*blitter_blit
)(struct wined3d_blitter
*blitter
, enum wined3d_blit_op op
, struct wined3d_context
*context
,
2500 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
, DWORD src_location
,
2501 const RECT
*src_rect
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
2502 DWORD dst_location
, const RECT
*dst_rect
, const struct wined3d_color_key
*colour_key
,
2503 enum wined3d_texture_filter_type filter
, const struct wined3d_format
*resolve_format
);
2506 void wined3d_arbfp_blitter_create(struct wined3d_blitter
**next
,
2507 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2508 struct wined3d_blitter
*wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN
;
2509 void wined3d_fbo_blitter_create(struct wined3d_blitter
**next
,
2510 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2511 void wined3d_ffp_blitter_create(struct wined3d_blitter
**next
,
2512 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2513 struct wined3d_blitter
*wined3d_glsl_blitter_create(struct wined3d_blitter
**next
,
2514 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2515 void wined3d_raw_blitter_create(struct wined3d_blitter
**next
,
2516 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2517 void wined3d_vk_blitter_create(struct wined3d_blitter
**next
) DECLSPEC_HIDDEN
;
2519 BOOL
wined3d_clip_blit(const RECT
*clip_rect
, RECT
*clipped
, RECT
*other
) DECLSPEC_HIDDEN
;
2521 HGLRC
context_create_wgl_attribs(const struct wined3d_gl_info
*gl_info
, HDC hdc
, HGLRC share_ctx
) DECLSPEC_HIDDEN
;
2522 DWORD
context_get_tls_idx(void) DECLSPEC_HIDDEN
;
2523 void context_gl_apply_texture_draw_state(struct wined3d_context_gl
*context_gl
,
2524 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
, unsigned int location
);
2525 void context_gl_resource_released(struct wined3d_device
*device
,
2526 GLuint name
, BOOL rb_namespace
) DECLSPEC_HIDDEN
;
2527 void context_invalidate_compute_state(struct wined3d_context
*context
, DWORD state_id
) DECLSPEC_HIDDEN
;
2528 void context_invalidate_state(struct wined3d_context
*context
, unsigned int state_id
) DECLSPEC_HIDDEN
;
2529 void context_resource_released(const struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
2530 void context_restore(struct wined3d_context
*context
, struct wined3d_texture
*texture
,
2531 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2532 void context_set_tls_idx(DWORD idx
) DECLSPEC_HIDDEN
;
2533 void context_state_drawbuf(struct wined3d_context
*context
,
2534 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2535 void context_state_fb(struct wined3d_context
*context
,
2536 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2538 /*****************************************************************************
2539 * Internal representation of a light
2541 struct wined3d_light_info
2543 struct wined3d_light OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
2544 unsigned int OriginalIndex
;
2548 /* Converted parms to speed up swapping lights */
2549 struct wined3d_vec4 position
;
2550 struct wined3d_vec4 direction
;
2554 struct rb_entry entry
;
2555 struct list changed_entry
;
2559 /* The default light parameters */
2560 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN
;
2562 struct wined3d_pixel_format
2564 int iPixelFormat
; /* WGL pixel format */
2565 int iPixelType
; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2566 int redSize
, greenSize
, blueSize
, alphaSize
, colorSize
;
2567 int depthSize
, stencilSize
;
2568 BOOL windowDrawable
;
2575 enum wined3d_pci_vendor
2577 HW_VENDOR_SOFTWARE
= 0x0000,
2578 HW_VENDOR_AMD
= 0x1002,
2579 HW_VENDOR_NVIDIA
= 0x10de,
2580 HW_VENDOR_VMWARE
= 0x15ad,
2581 HW_VENDOR_REDHAT
= 0x1af4,
2582 HW_VENDOR_INTEL
= 0x8086,
2585 enum wined3d_pci_device
2589 CARD_AMD_RAGE_128PRO
= 0x5246,
2590 CARD_AMD_RADEON_7200
= 0x5144,
2591 CARD_AMD_RADEON_8500
= 0x514c,
2592 CARD_AMD_RADEON_9500
= 0x4144,
2593 CARD_AMD_RADEON_XPRESS_200M
= 0x5955,
2594 CARD_AMD_RADEON_X700
= 0x5e4c,
2595 CARD_AMD_RADEON_X1600
= 0x71c2,
2596 CARD_AMD_RADEON_HD2350
= 0x94c7,
2597 CARD_AMD_RADEON_HD2600
= 0x9581,
2598 CARD_AMD_RADEON_HD2900
= 0x9400,
2599 CARD_AMD_RADEON_HD3200
= 0x9620,
2600 CARD_AMD_RADEON_HD3850
= 0x9515,
2601 CARD_AMD_RADEON_HD4200M
= 0x9712,
2602 CARD_AMD_RADEON_HD4350
= 0x954f,
2603 CARD_AMD_RADEON_HD4600
= 0x9495,
2604 CARD_AMD_RADEON_HD4700
= 0x944e,
2605 CARD_AMD_RADEON_HD4800
= 0x944c,
2606 CARD_AMD_RADEON_HD5400
= 0x68f9,
2607 CARD_AMD_RADEON_HD5600
= 0x68d8,
2608 CARD_AMD_RADEON_HD5700
= 0x68be,
2609 CARD_AMD_RADEON_HD5800
= 0x6898,
2610 CARD_AMD_RADEON_HD5900
= 0x689c,
2611 CARD_AMD_RADEON_HD6300
= 0x9803,
2612 CARD_AMD_RADEON_HD6400
= 0x6770,
2613 CARD_AMD_RADEON_HD6490M
= 0x6760,
2614 CARD_AMD_RADEON_HD6410D
= 0x9644,
2615 CARD_AMD_RADEON_HD6480G
= 0x9648,
2616 CARD_AMD_RADEON_HD6550D
= 0x9640,
2617 CARD_AMD_RADEON_HD6600
= 0x6758,
2618 CARD_AMD_RADEON_HD6600M
= 0x6741,
2619 CARD_AMD_RADEON_HD6700
= 0x68ba,
2620 CARD_AMD_RADEON_HD6800
= 0x6739,
2621 CARD_AMD_RADEON_HD6900
= 0x6719,
2622 CARD_AMD_RADEON_HD7660D
= 0x9901,
2623 CARD_AMD_RADEON_HD7700
= 0x683d,
2624 CARD_AMD_RADEON_HD7800
= 0x6819,
2625 CARD_AMD_RADEON_HD7870
= 0x6818,
2626 CARD_AMD_RADEON_HD7900
= 0x679a,
2627 CARD_AMD_RADEON_HD8600M
= 0x6660,
2628 CARD_AMD_RADEON_HD8670
= 0x6610,
2629 CARD_AMD_RADEON_HD8770
= 0x665c,
2630 CARD_AMD_RADEON_R3
= 0x9830,
2631 CARD_AMD_RADEON_R7
= 0x130f,
2632 CARD_AMD_RADEON_R9_285
= 0x6939,
2633 CARD_AMD_RADEON_R9_290
= 0x67b1,
2634 CARD_AMD_RADEON_R9_290X
= 0x67b0,
2635 CARD_AMD_RADEON_R9_FURY
= 0x7300,
2636 CARD_AMD_RADEON_R9_M370X
= 0x6821,
2637 CARD_AMD_RADEON_R9_M380
= 0x6647,
2638 CARD_AMD_RADEON_R9_M395X
= 0x6920,
2639 CARD_AMD_RADEON_RX_460
= 0x67ef,
2640 CARD_AMD_RADEON_RX_480
= 0x67df,
2641 CARD_AMD_RADEON_RX_VEGA_10
= 0x687f,
2642 CARD_AMD_RADEON_RX_VEGA_12
= 0x69af,
2643 CARD_AMD_RADEON_RAVEN
= 0x15dd,
2644 CARD_AMD_RADEON_RX_VEGA_20
= 0x66af,
2645 CARD_AMD_RADEON_RX_NAVI_10
= 0x731f,
2646 CARD_AMD_RADEON_RX_NAVI_14
= 0x7340,
2647 CARD_AMD_RADEON_RX_NAVI_21
= 0x73bf,
2648 CARD_AMD_RADEON_PRO_V620
= 0x73a1,
2649 CARD_AMD_RADEON_PRO_V620_VF
= 0x73ae,
2650 CARD_AMD_VANGOGH
= 0x163f,
2651 CARD_AMD_RAPHAEL
= 0x164e,
2653 CARD_NVIDIA_RIVA_128
= 0x0018,
2654 CARD_NVIDIA_RIVA_TNT
= 0x0020,
2655 CARD_NVIDIA_RIVA_TNT2
= 0x0028,
2656 CARD_NVIDIA_GEFORCE
= 0x0100,
2657 CARD_NVIDIA_GEFORCE2_MX
= 0x0110,
2658 CARD_NVIDIA_GEFORCE2
= 0x0150,
2659 CARD_NVIDIA_GEFORCE3
= 0x0200,
2660 CARD_NVIDIA_GEFORCE4_MX
= 0x0170,
2661 CARD_NVIDIA_GEFORCE4_TI4200
= 0x0253,
2662 CARD_NVIDIA_GEFORCEFX_5200
= 0x0320,
2663 CARD_NVIDIA_GEFORCEFX_5600
= 0x0312,
2664 CARD_NVIDIA_GEFORCEFX_5800
= 0x0302,
2665 CARD_NVIDIA_GEFORCE_6200
= 0x014f,
2666 CARD_NVIDIA_GEFORCE_6600GT
= 0x0140,
2667 CARD_NVIDIA_GEFORCE_6800
= 0x0041,
2668 CARD_NVIDIA_GEFORCE_7300
= 0x01d7, /* GeForce Go 7300 */
2669 CARD_NVIDIA_GEFORCE_7400
= 0x01d8,
2670 CARD_NVIDIA_GEFORCE_7600
= 0x0391,
2671 CARD_NVIDIA_GEFORCE_7800GT
= 0x0092,
2672 CARD_NVIDIA_GEFORCE_8200
= 0x0849, /* Other PCI ID 0x084b */
2673 CARD_NVIDIA_GEFORCE_8300GS
= 0x0423,
2674 CARD_NVIDIA_GEFORCE_8400GS
= 0x0404,
2675 CARD_NVIDIA_GEFORCE_8500GT
= 0x0421,
2676 CARD_NVIDIA_GEFORCE_8600GT
= 0x0402,
2677 CARD_NVIDIA_GEFORCE_8600MGT
= 0x0407,
2678 CARD_NVIDIA_GEFORCE_8800GTS
= 0x0193,
2679 CARD_NVIDIA_GEFORCE_8800GTX
= 0x0191,
2680 CARD_NVIDIA_GEFORCE_9200
= 0x086d,
2681 CARD_NVIDIA_GEFORCE_9300
= 0x086c,
2682 CARD_NVIDIA_GEFORCE_9400M
= 0x0863,
2683 CARD_NVIDIA_GEFORCE_9400GT
= 0x042c,
2684 CARD_NVIDIA_GEFORCE_9500GT
= 0x0640,
2685 CARD_NVIDIA_GEFORCE_9600GT
= 0x0622,
2686 CARD_NVIDIA_GEFORCE_9700MGT
= 0x064a,
2687 CARD_NVIDIA_GEFORCE_9800GT
= 0x0614,
2688 CARD_NVIDIA_GEFORCE_210
= 0x0a23,
2689 CARD_NVIDIA_GEFORCE_GT220
= 0x0a20,
2690 CARD_NVIDIA_GEFORCE_GT240
= 0x0ca3,
2691 CARD_NVIDIA_GEFORCE_GTS250
= 0x0615,
2692 CARD_NVIDIA_GEFORCE_GTX260
= 0x05e2,
2693 CARD_NVIDIA_GEFORCE_GTX275
= 0x05e6,
2694 CARD_NVIDIA_GEFORCE_GTX280
= 0x05e1,
2695 CARD_NVIDIA_GEFORCE_315M
= 0x0a7a,
2696 CARD_NVIDIA_GEFORCE_320M
= 0x08a3,
2697 CARD_NVIDIA_GEFORCE_GT320M
= 0x0a2d,
2698 CARD_NVIDIA_GEFORCE_GT325M
= 0x0a35,
2699 CARD_NVIDIA_GEFORCE_GT330
= 0x0ca0,
2700 CARD_NVIDIA_GEFORCE_GTS350M
= 0x0cb0,
2701 CARD_NVIDIA_GEFORCE_410M
= 0x1055,
2702 CARD_NVIDIA_GEFORCE_GT420
= 0x0de2,
2703 CARD_NVIDIA_GEFORCE_GT425M
= 0x0df0,
2704 CARD_NVIDIA_GEFORCE_GT430
= 0x0de1,
2705 CARD_NVIDIA_GEFORCE_GT440
= 0x0de0,
2706 CARD_NVIDIA_GEFORCE_GTS450
= 0x0dc4,
2707 CARD_NVIDIA_GEFORCE_GTX460
= 0x0e22,
2708 CARD_NVIDIA_GEFORCE_GTX460M
= 0x0dd1,
2709 CARD_NVIDIA_GEFORCE_GTX465
= 0x06c4,
2710 CARD_NVIDIA_GEFORCE_GTX470
= 0x06cd,
2711 CARD_NVIDIA_GEFORCE_GTX480
= 0x06c0,
2712 CARD_NVIDIA_GEFORCE_GT520
= 0x1040,
2713 CARD_NVIDIA_GEFORCE_GT525M
= 0x0dec,
2714 CARD_NVIDIA_GEFORCE_GT540M
= 0x0df4,
2715 CARD_NVIDIA_GEFORCE_GTX550
= 0x1244,
2716 CARD_NVIDIA_GEFORCE_GT555M
= 0x04b8,
2717 CARD_NVIDIA_GEFORCE_GTX560TI
= 0x1200,
2718 CARD_NVIDIA_GEFORCE_GTX560M
= 0x1251,
2719 CARD_NVIDIA_GEFORCE_GTX560
= 0x1201,
2720 CARD_NVIDIA_GEFORCE_GTX570
= 0x1081,
2721 CARD_NVIDIA_GEFORCE_GTX580
= 0x1080,
2722 CARD_NVIDIA_GEFORCE_GT610
= 0x104a,
2723 CARD_NVIDIA_GEFORCE_GT630
= 0x0f00,
2724 CARD_NVIDIA_GEFORCE_GT630M
= 0x0de9,
2725 CARD_NVIDIA_GEFORCE_GT640
= 0x0fc1,
2726 CARD_NVIDIA_GEFORCE_GT640M
= 0x0fd2,
2727 CARD_NVIDIA_GEFORCE_GT650M
= 0x0fd1,
2728 CARD_NVIDIA_GEFORCE_GTX650
= 0x0fc6,
2729 CARD_NVIDIA_GEFORCE_GTX650TI
= 0x11c6,
2730 CARD_NVIDIA_GEFORCE_GTX660
= 0x11c0,
2731 CARD_NVIDIA_GEFORCE_GTX660M
= 0x0fd4,
2732 CARD_NVIDIA_GEFORCE_GTX660TI
= 0x1183,
2733 CARD_NVIDIA_GEFORCE_GTX670
= 0x1189,
2734 CARD_NVIDIA_GEFORCE_GTX670MX
= 0x11a1,
2735 CARD_NVIDIA_GEFORCE_GTX675MX_1
= 0x11a7,
2736 CARD_NVIDIA_GEFORCE_GTX675MX_2
= 0x11a2,
2737 CARD_NVIDIA_GEFORCE_GTX680
= 0x1180,
2738 CARD_NVIDIA_GEFORCE_GTX690
= 0x1188,
2739 CARD_NVIDIA_GEFORCE_GT720
= 0x128b,
2740 CARD_NVIDIA_GEFORCE_GT730
= 0x1287,
2741 CARD_NVIDIA_GEFORCE_GT730M
= 0x0fe1,
2742 CARD_NVIDIA_GEFORCE_GT740M
= 0x1292,
2743 CARD_NVIDIA_GEFORCE_GT750M
= 0x0fe9,
2744 CARD_NVIDIA_GEFORCE_GT755M
= 0x0fcd,
2745 CARD_NVIDIA_GEFORCE_GTX750
= 0x1381,
2746 CARD_NVIDIA_GEFORCE_GTX750TI
= 0x1380,
2747 CARD_NVIDIA_GEFORCE_GTX760
= 0x1187,
2748 CARD_NVIDIA_GEFORCE_GTX760TI
= 0x1193,
2749 CARD_NVIDIA_GEFORCE_GTX765M
= 0x11e2,
2750 CARD_NVIDIA_GEFORCE_GTX770M
= 0x11e0,
2751 CARD_NVIDIA_GEFORCE_GTX770
= 0x1184,
2752 CARD_NVIDIA_GEFORCE_GTX775M
= 0x119d,
2753 CARD_NVIDIA_GEFORCE_GTX780
= 0x1004,
2754 CARD_NVIDIA_GEFORCE_GTX780M
= 0x119e,
2755 CARD_NVIDIA_GEFORCE_GTX780TI
= 0x100a,
2756 CARD_NVIDIA_GEFORCE_GTXTITAN
= 0x1005,
2757 CARD_NVIDIA_GEFORCE_GTXTITANB
= 0x100c,
2758 CARD_NVIDIA_GEFORCE_GTXTITANX
= 0x17c2,
2759 CARD_NVIDIA_GEFORCE_GTXTITANZ
= 0x1001,
2760 CARD_NVIDIA_GEFORCE_820M
= 0x0fed,
2761 CARD_NVIDIA_GEFORCE_830M
= 0x1340,
2762 CARD_NVIDIA_GEFORCE_840M
= 0x1341,
2763 CARD_NVIDIA_GEFORCE_845M
= 0x1344,
2764 CARD_NVIDIA_GEFORCE_GTX850M
= 0x1391,
2765 CARD_NVIDIA_GEFORCE_GTX860M
= 0x1392, /* Other PCI ID 0x119a */
2766 CARD_NVIDIA_GEFORCE_GTX870M
= 0x1199,
2767 CARD_NVIDIA_GEFORCE_GTX880M
= 0x1198,
2768 CARD_NVIDIA_GEFORCE_940M
= 0x1347,
2769 CARD_NVIDIA_GEFORCE_GTX950
= 0x1402,
2770 CARD_NVIDIA_GEFORCE_GTX950M
= 0x139a,
2771 CARD_NVIDIA_GEFORCE_GTX960
= 0x1401,
2772 CARD_NVIDIA_GEFORCE_GTX960M
= 0x139b,
2773 CARD_NVIDIA_GEFORCE_GTX970
= 0x13c2,
2774 CARD_NVIDIA_GEFORCE_GTX970M
= 0x13d8,
2775 CARD_NVIDIA_GEFORCE_GTX980
= 0x13c0,
2776 CARD_NVIDIA_GEFORCE_GTX980TI
= 0x17c8,
2777 CARD_NVIDIA_GEFORCE_GT1030
= 0x1d01,
2778 CARD_NVIDIA_GEFORCE_GTX1050
= 0x1c81,
2779 CARD_NVIDIA_GEFORCE_GTX1050TI
= 0x1c82,
2780 CARD_NVIDIA_GEFORCE_GTX1060_3GB
= 0x1c02,
2781 CARD_NVIDIA_GEFORCE_GTX1060
= 0x1c03,
2782 CARD_NVIDIA_GEFORCE_GTX1060M
= 0x1c20,
2783 CARD_NVIDIA_GEFORCE_GTX1070
= 0x1b81,
2784 CARD_NVIDIA_GEFORCE_GTX1080
= 0x1b80,
2785 CARD_NVIDIA_GEFORCE_GTX1080M
= 0x1be0,
2786 CARD_NVIDIA_GEFORCE_GTX1080TI
= 0x1b06,
2787 CARD_NVIDIA_TITANX_PASCAL
= 0x1b00,
2788 CARD_NVIDIA_TITANV
= 0x1d81,
2789 CARD_NVIDIA_GEFORCE_GTX1650SUPER
= 0x2187,
2790 CARD_NVIDIA_GEFORCE_GTX1660SUPER
= 0x21c4,
2791 CARD_NVIDIA_GEFORCE_GTX1660TI
= 0x2182,
2792 CARD_NVIDIA_GEFORCE_RTX2060
= 0x1f08,
2793 CARD_NVIDIA_GEFORCE_RTX2070
= 0x1f07,
2794 CARD_NVIDIA_GEFORCE_RTX2080
= 0x1e87,
2795 CARD_NVIDIA_GEFORCE_RTX2080TI
= 0x1e07,
2796 CARD_NVIDIA_TESLA_T4
= 0x1eb8,
2797 CARD_NVIDIA_AMPERE_A10
= 0x2236,
2799 CARD_REDHAT_VIRGL
= 0x1010,
2801 CARD_VMWARE_SVGA3D
= 0x0405,
2803 CARD_INTEL_830M
= 0x3577,
2804 CARD_INTEL_855GM
= 0x3582,
2805 CARD_INTEL_845G
= 0x2562,
2806 CARD_INTEL_865G
= 0x2572,
2807 CARD_INTEL_915G
= 0x2582,
2808 CARD_INTEL_E7221G
= 0x258a,
2809 CARD_INTEL_915GM
= 0x2592,
2810 CARD_INTEL_945G
= 0x2772,
2811 CARD_INTEL_945GM
= 0x27a2,
2812 CARD_INTEL_945GME
= 0x27ae,
2813 CARD_INTEL_Q35
= 0x29b2,
2814 CARD_INTEL_G33
= 0x29c2,
2815 CARD_INTEL_Q33
= 0x29d2,
2816 CARD_INTEL_PNVG
= 0xa001,
2817 CARD_INTEL_PNVM
= 0xa011,
2818 CARD_INTEL_965Q
= 0x2992,
2819 CARD_INTEL_965G
= 0x2982,
2820 CARD_INTEL_946GZ
= 0x2972,
2821 CARD_INTEL_965GM
= 0x2a02,
2822 CARD_INTEL_965GME
= 0x2a12,
2823 CARD_INTEL_GM45
= 0x2a42,
2824 CARD_INTEL_IGD
= 0x2e02,
2825 CARD_INTEL_Q45
= 0x2e12,
2826 CARD_INTEL_G45
= 0x2e22,
2827 CARD_INTEL_G41
= 0x2e32,
2828 CARD_INTEL_B43
= 0x2e92,
2829 CARD_INTEL_ILKD
= 0x0042,
2830 CARD_INTEL_ILKM
= 0x0046,
2831 CARD_INTEL_SNBD
= 0x0122,
2832 CARD_INTEL_SNBM
= 0x0126,
2833 CARD_INTEL_SNBS
= 0x010a,
2834 CARD_INTEL_IVBD
= 0x0162,
2835 CARD_INTEL_IVBM
= 0x0166,
2836 CARD_INTEL_IVBS
= 0x015a,
2837 CARD_INTEL_HWD
= 0x0412,
2838 CARD_INTEL_HWM
= 0x0416,
2839 CARD_INTEL_HD5000_1
= 0x0a26,
2840 CARD_INTEL_HD5000_2
= 0x0422,
2841 CARD_INTEL_I5100_1
= 0x0a22,
2842 CARD_INTEL_I5100_2
= 0x0a2a,
2843 CARD_INTEL_I5100_3
= 0x0a2b,
2844 CARD_INTEL_I5100_4
= 0x0a2e,
2845 CARD_INTEL_IP5200_1
= 0x0d22,
2846 CARD_INTEL_IP5200_2
= 0x0d26,
2847 CARD_INTEL_IP5200_3
= 0x0d2a,
2848 CARD_INTEL_IP5200_4
= 0x0d2b,
2849 CARD_INTEL_IP5200_5
= 0x0d2e,
2850 CARD_INTEL_IP5200_6
= 0x0c22,
2851 CARD_INTEL_HD5300
= 0x161e,
2852 CARD_INTEL_HD5500
= 0x1616,
2853 CARD_INTEL_HD5600
= 0x1612,
2854 CARD_INTEL_HD6000
= 0x1626,
2855 CARD_INTEL_I6100
= 0x162b,
2856 CARD_INTEL_IP6200
= 0x1622,
2857 CARD_INTEL_IPP6300
= 0x162a,
2858 CARD_INTEL_HD510_1
= 0x1902,
2859 CARD_INTEL_HD510_2
= 0x1906,
2860 CARD_INTEL_HD510_3
= 0x190b,
2861 CARD_INTEL_HD515
= 0x191e,
2862 CARD_INTEL_HD520_1
= 0x1916,
2863 CARD_INTEL_HD520_2
= 0x1921,
2864 CARD_INTEL_HD530_1
= 0x1912,
2865 CARD_INTEL_HD530_2
= 0x191b,
2866 CARD_INTEL_HDP530
= 0x191d,
2867 CARD_INTEL_I540
= 0x1926,
2868 CARD_INTEL_I550
= 0x1927,
2869 CARD_INTEL_I555
= 0x192b,
2870 CARD_INTEL_IP555
= 0x192d,
2871 CARD_INTEL_IP580_1
= 0x1932,
2872 CARD_INTEL_IP580_2
= 0x193b,
2873 CARD_INTEL_IPP580_1
= 0x193a,
2874 CARD_INTEL_IPP580_2
= 0x193d,
2875 CARD_INTEL_UHD617
= 0x87c0,
2876 CARD_INTEL_UHD620
= 0x3ea0,
2877 CARD_INTEL_HD615
= 0x591e,
2878 CARD_INTEL_HD620
= 0x5916,
2879 CARD_INTEL_HD630_1
= 0x5912,
2880 CARD_INTEL_HD630_2
= 0x591b,
2881 CARD_INTEL_UHD630_1
= 0x3e9b,
2882 CARD_INTEL_UHD630_2
= 0x3e91,
2885 struct wined3d_fbo_ops
2887 GLboolean (WINE_GLAPI
*glIsRenderbuffer
)(GLuint renderbuffer
);
2888 void (WINE_GLAPI
*glBindRenderbuffer
)(GLenum target
, GLuint renderbuffer
);
2889 void (WINE_GLAPI
*glDeleteRenderbuffers
)(GLsizei n
, const GLuint
*renderbuffers
);
2890 void (WINE_GLAPI
*glGenRenderbuffers
)(GLsizei n
, GLuint
*renderbuffers
);
2891 void (WINE_GLAPI
*glRenderbufferStorage
)(GLenum target
, GLenum internalformat
,
2892 GLsizei width
, GLsizei height
);
2893 void (WINE_GLAPI
*glRenderbufferStorageMultisample
)(GLenum target
, GLsizei samples
,
2894 GLenum internalformat
, GLsizei width
, GLsizei height
);
2895 void (WINE_GLAPI
*glGetRenderbufferParameteriv
)(GLenum target
, GLenum pname
, GLint
*params
);
2896 GLboolean (WINE_GLAPI
*glIsFramebuffer
)(GLuint framebuffer
);
2897 void (WINE_GLAPI
*glBindFramebuffer
)(GLenum target
, GLuint framebuffer
);
2898 void (WINE_GLAPI
*glDeleteFramebuffers
)(GLsizei n
, const GLuint
*framebuffers
);
2899 void (WINE_GLAPI
*glGenFramebuffers
)(GLsizei n
, GLuint
*framebuffers
);
2900 GLenum (WINE_GLAPI
*glCheckFramebufferStatus
)(GLenum target
);
2901 void (WINE_GLAPI
*glFramebufferTexture
)(GLenum target
, GLenum attachment
,
2902 GLuint texture
, GLint level
);
2903 void (WINE_GLAPI
*glFramebufferTexture1D
)(GLenum target
, GLenum attachment
,
2904 GLenum textarget
, GLuint texture
, GLint level
);
2905 void (WINE_GLAPI
*glFramebufferTexture2D
)(GLenum target
, GLenum attachment
,
2906 GLenum textarget
, GLuint texture
, GLint level
);
2907 void (WINE_GLAPI
*glFramebufferTexture3D
)(GLenum target
, GLenum attachment
,
2908 GLenum textarget
, GLuint texture
, GLint level
, GLint layer
);
2909 void (WINE_GLAPI
*glFramebufferTextureLayer
)(GLenum target
, GLenum attachment
,
2910 GLuint texture
, GLint level
, GLint layer
);
2911 void (WINE_GLAPI
*glFramebufferRenderbuffer
)(GLenum target
, GLenum attachment
,
2912 GLenum renderbuffertarget
, GLuint renderbuffer
);
2913 void (WINE_GLAPI
*glGetFramebufferAttachmentParameteriv
)(GLenum target
, GLenum attachment
,
2914 GLenum pname
, GLint
*params
);
2915 void (WINE_GLAPI
*glBlitFramebuffer
)(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
2916 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
, GLbitfield mask
, GLenum filter
);
2917 void (WINE_GLAPI
*glGenerateMipmap
)(GLenum target
);
2920 struct wined3d_gl_limits
2925 UINT texture_coords
;
2926 unsigned int uniform_blocks
[WINED3D_SHADER_TYPE_COUNT
];
2927 unsigned int samplers
[WINED3D_SHADER_TYPE_COUNT
];
2928 unsigned int graphics_samplers
;
2929 unsigned int combined_samplers
;
2930 UINT general_combiners
;
2931 UINT user_clip_distances
;
2932 unsigned int texture_size
;
2933 UINT texture3d_size
;
2937 UINT vertex_attribs
;
2939 unsigned int texture_buffer_offset_alignment
;
2941 unsigned int framebuffer_width
;
2942 unsigned int framebuffer_height
;
2943 unsigned int viewport_subpixel_bits
;
2946 UINT glsl_vs_float_constants
;
2947 UINT glsl_ps_float_constants
;
2949 UINT arb_vs_float_constants
;
2950 UINT arb_vs_native_constants
;
2951 UINT arb_vs_instructions
;
2953 UINT arb_ps_float_constants
;
2954 UINT arb_ps_local_constants
;
2955 UINT arb_ps_native_constants
;
2956 UINT arb_ps_instructions
;
2960 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits
*gl_limits
,
2961 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
2962 void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits
*gl_limits
,
2963 enum wined3d_shader_type shader_type
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
2965 struct wined3d_gl_info
2967 unsigned int selected_gl_version
;
2968 unsigned int glsl_version
;
2969 struct wined3d_gl_limits limits
;
2970 DWORD reserved_glsl_constants
, reserved_arb_constants
;
2972 BOOL supported
[WINED3D_GL_EXT_COUNT
];
2973 GLint wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
+ 1];
2974 float filling_convention_offset
;
2976 HGLRC (WINAPI
*p_wglCreateContextAttribsARB
)(HDC dc
, HGLRC share
, const GLint
*attribs
);
2977 struct opengl_funcs gl_ops
;
2978 struct wined3d_fbo_ops fbo_ops
;
2980 void (WINE_GLAPI
*p_glDisableWINE
)(GLenum cap
);
2981 void (WINE_GLAPI
*p_glEnableWINE
)(GLenum cap
);
2984 static inline BOOL
wined3d_fence_supported(const struct wined3d_gl_info
*gl_info
)
2986 return gl_info
->supported
[ARB_SYNC
] || gl_info
->supported
[NV_FENCE
] || gl_info
->supported
[APPLE_FENCE
];
2989 /* The driver names reflect the lowest GPU supported
2990 * by a certain driver, so DRIVER_AMD_R300 supports
2991 * R3xx, R4xx and R5xx GPUs. */
2992 enum wined3d_display_driver
2994 DRIVER_AMD_RAGE_128PRO
,
2999 DRIVER_INTEL_GMA800
,
3000 DRIVER_INTEL_GMA900
,
3001 DRIVER_INTEL_GMA950
,
3002 DRIVER_INTEL_GMA3000
,
3003 DRIVER_INTEL_HD4000
,
3005 DRIVER_NVIDIA_GEFORCE2MX
,
3006 DRIVER_NVIDIA_GEFORCEFX
,
3007 DRIVER_NVIDIA_GEFORCE6
,
3008 DRIVER_NVIDIA_GEFORCE8
,
3009 DRIVER_NVIDIA_FERMI
,
3010 DRIVER_NVIDIA_KEPLER
,
3011 DRIVER_REDHAT_VIRGL
,
3017 struct wined3d_gpu_description
3019 enum wined3d_pci_vendor vendor
;
3020 enum wined3d_pci_device device
;
3021 const char *description
;
3022 enum wined3d_display_driver driver
;
3023 unsigned int vidmem
;
3026 const struct wined3d_gpu_description
*wined3d_get_gpu_description(enum wined3d_pci_vendor vendor
,
3027 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
3028 const struct wined3d_gpu_description
*wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor
,
3029 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
3030 enum wined3d_pci_device
wined3d_gpu_from_feature_level(enum wined3d_pci_vendor
*vendor
,
3031 enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
3033 /* 512 in Direct3D 8/9, 128 in DXGI. */
3034 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
3036 struct wined3d_driver_info
3038 enum wined3d_pci_vendor vendor
;
3039 enum wined3d_pci_device device
;
3041 char description
[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH
];
3043 UINT64 sysmem_bytes
;
3044 unsigned int version_high
;
3045 unsigned int version_low
;
3048 bool wined3d_driver_info_init(struct wined3d_driver_info
*driver_info
,
3049 const struct wined3d_gpu_description
*gpu_description
, enum wined3d_feature_level feature_level
,
3050 UINT64 vram_bytes
, UINT64 sysmem_bytes
) DECLSPEC_HIDDEN
;
3052 #define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
3053 #define UPLOAD_BO_RENAME_ON_UNMAP 0x2
3054 #define UPLOAD_BO_FREE_ON_UNMAP 0x4
3058 struct wined3d_const_bo_address addr
;
3062 struct wined3d_adapter_ops
3064 void (*adapter_destroy
)(struct wined3d_adapter
*adapter
);
3065 HRESULT (*adapter_create_device
)(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
3066 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
3067 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
3068 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
);
3069 void (*adapter_destroy_device
)(struct wined3d_device
*device
);
3070 struct wined3d_context
*(*adapter_acquire_context
)(struct wined3d_device
*device
,
3071 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
3072 void (*adapter_release_context
)(struct wined3d_context
*context
);
3073 void (*adapter_get_wined3d_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
);
3074 BOOL (*adapter_check_format
)(const struct wined3d_adapter
*adapter
,
3075 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
3076 const struct wined3d_format
*ds_format
);
3077 HRESULT (*adapter_init_3d
)(struct wined3d_device
*device
);
3078 void (*adapter_uninit_3d
)(struct wined3d_device
*device
);
3079 void *(*adapter_map_bo_address
)(struct wined3d_context
*context
,
3080 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
);
3081 void (*adapter_unmap_bo_address
)(struct wined3d_context
*context
, const struct wined3d_bo_address
*data
,
3082 unsigned int range_count
, const struct wined3d_range
*ranges
);
3083 void (*adapter_copy_bo_address
)(struct wined3d_context
*context
,
3084 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
3085 unsigned int range_count
, const struct wined3d_range
*ranges
);
3086 void (*adapter_flush_bo_address
)(struct wined3d_context
*context
,
3087 const struct wined3d_const_bo_address
*data
, size_t size
);
3088 bool (*adapter_alloc_bo
)(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
3089 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
);
3090 void (*adapter_destroy_bo
)(struct wined3d_context
*context
, struct wined3d_bo
*bo
);
3091 HRESULT (*adapter_create_swapchain
)(struct wined3d_device
*device
,
3092 struct wined3d_swapchain_desc
*desc
,
3093 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
3094 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
);
3095 void (*adapter_destroy_swapchain
)(struct wined3d_swapchain
*swapchain
);
3096 HRESULT (*adapter_create_buffer
)(struct wined3d_device
*device
, const struct wined3d_buffer_desc
*desc
,
3097 const struct wined3d_sub_resource_data
*data
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3098 struct wined3d_buffer
**buffer
);
3099 void (*adapter_destroy_buffer
)(struct wined3d_buffer
*buffer
);
3100 HRESULT (*adapter_create_texture
)(struct wined3d_device
*device
, const struct wined3d_resource_desc
*desc
,
3101 unsigned int layer_count
, unsigned int level_count
, uint32_t flags
, void *parent
,
3102 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
);
3103 void (*adapter_destroy_texture
)(struct wined3d_texture
*texture
);
3104 HRESULT (*adapter_create_rendertarget_view
)(const struct wined3d_view_desc
*desc
,
3105 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3106 struct wined3d_rendertarget_view
**view
);
3107 void (*adapter_destroy_rendertarget_view
)(struct wined3d_rendertarget_view
*view
);
3108 HRESULT (*adapter_create_shader_resource_view
)(const struct wined3d_view_desc
*desc
,
3109 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3110 struct wined3d_shader_resource_view
**view
);
3111 void (*adapter_destroy_shader_resource_view
)(struct wined3d_shader_resource_view
*view
);
3112 HRESULT (*adapter_create_unordered_access_view
)(const struct wined3d_view_desc
*desc
,
3113 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3114 struct wined3d_unordered_access_view
**view
);
3115 void (*adapter_destroy_unordered_access_view
)(struct wined3d_unordered_access_view
*view
);
3116 HRESULT (*adapter_create_sampler
)(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
3117 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
);
3118 void (*adapter_destroy_sampler
)(struct wined3d_sampler
*sampler
);
3119 HRESULT (*adapter_create_query
)(struct wined3d_device
*device
, enum wined3d_query_type type
,
3120 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
3121 void (*adapter_destroy_query
)(struct wined3d_query
*query
);
3122 void (*adapter_flush_context
)(struct wined3d_context
*context
);
3123 void (*adapter_draw_primitive
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
3124 const struct wined3d_draw_parameters
*parameters
);
3125 void (*adapter_dispatch_compute
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
3126 const struct wined3d_dispatch_parameters
*parameters
);
3127 void (*adapter_clear_uav
)(struct wined3d_context
*context
,
3128 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
);
3129 void (*adapter_generate_mipmap
)(struct wined3d_context
*context
, struct wined3d_shader_resource_view
*view
);
3132 struct wined3d_output
3134 unsigned int ordinal
;
3135 WCHAR device_name
[CCHDEVICENAME
];
3136 struct wined3d_adapter
*adapter
;
3137 enum wined3d_format_id screen_format
;
3139 D3DKMT_HANDLE kmt_device
;
3140 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id
;
3142 struct wined3d_display_mode
*modes
;
3143 SIZE_T mode_count
, modes_size
;
3147 HRESULT
wined3d_output_get_gamma_ramp(struct wined3d_output
*output
, struct wined3d_gamma_ramp
*ramp
) DECLSPEC_HIDDEN
;
3150 #define MAX_PERSISTENT_MAPPED_BYTES I64_MAX
3152 #define MAX_PERSISTENT_MAPPED_BYTES (128 * 1024 * 1024)
3155 /* The adapter structure */
3156 struct wined3d_adapter
3158 unsigned int ordinal
;
3160 struct wined3d_gl_info gl_info
;
3161 struct wined3d_d3d_info d3d_info
;
3162 struct wined3d_driver_info driver_info
;
3163 struct wined3d_output
*outputs
;
3164 SIZE_T output_count
, outputs_size
;
3165 D3DKMT_HANDLE kmt_adapter
;
3166 UINT64 vram_bytes_used
;
3174 ssize_t mapped_size
;
3176 const struct wined3d_vertex_pipe_ops
*vertex_pipe
;
3177 const struct wined3d_fragment_pipe_ops
*fragment_pipe
;
3178 const struct wined3d_state_entry_template
*misc_state_template
;
3179 const struct wined3d_shader_backend_ops
*shader_backend
;
3180 const struct wined3d_adapter_ops
*adapter_ops
;
3183 BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, unsigned int ordinal
, const LUID
*luid
,
3184 const struct wined3d_adapter_ops
*adapter_ops
) DECLSPEC_HIDDEN
;
3185 void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
3186 BOOL
wined3d_get_primary_adapter_luid(LUID
*luid
) DECLSPEC_HIDDEN
;
3188 struct wined3d_adapter
*wined3d_adapter_vk_create(unsigned int ordinal
,
3189 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
3191 struct wined3d_adapter_gl
3193 struct wined3d_adapter a
;
3195 struct wined3d_pixel_format
*pixel_formats
;
3196 unsigned int pixel_format_count
;
3199 static inline struct wined3d_adapter_gl
*wined3d_adapter_gl(struct wined3d_adapter
*adapter
)
3201 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
3204 static inline const struct wined3d_adapter_gl
*wined3d_adapter_gl_const(const struct wined3d_adapter
*adapter
)
3206 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
3209 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
,
3210 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
3212 struct wined3d_caps_gl_ctx
3218 HGLRC restore_gl_ctx
;
3220 const struct wined3d_gl_info
*gl_info
;
3222 GLuint test_program_id
;
3224 const struct wined3d_gpu_description
*gpu_description
;
3228 BOOL
wined3d_adapter_gl_init_format_info(struct wined3d_adapter
*adapter
,
3229 struct wined3d_caps_gl_ctx
*ctx
) DECLSPEC_HIDDEN
;
3230 BOOL
wined3d_adapter_no3d_init_format_info(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
3231 ssize_t
adapter_adjust_mapped_memory(struct wined3d_adapter
*adapter
, ssize_t size
) DECLSPEC_HIDDEN
;
3232 UINT64
adapter_adjust_memory(struct wined3d_adapter
*adapter
, INT64 amount
) DECLSPEC_HIDDEN
;
3234 BOOL
wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
*ctx
) DECLSPEC_HIDDEN
;
3235 bool wined3d_caps_gl_ctx_test_filling_convention(struct wined3d_caps_gl_ctx
*ctx
, float offset
) DECLSPEC_HIDDEN
;
3237 void install_gl_compat_wrapper(struct wined3d_gl_info
*gl_info
, enum wined3d_gl_extension ext
) DECLSPEC_HIDDEN
;
3239 enum wined3d_projection_type
3241 WINED3D_PROJECTION_NONE
= 0,
3242 WINED3D_PROJECTION_COUNT3
= 1,
3243 WINED3D_PROJECTION_COUNT4
= 2
3246 /*****************************************************************************
3247 * Fixed function pipeline replacements
3249 #define ARG_UNUSED 0xff
3250 struct texture_stage_op
3262 struct color_fixup_desc color_fixup
;
3263 unsigned tex_type
: 3;
3264 unsigned tmp_dst
: 1;
3265 unsigned projected
: 2;
3266 unsigned padding
: 10;
3269 struct ffp_frag_settings
3271 struct texture_stage_op op
[WINED3D_MAX_TEXTURES
];
3272 enum wined3d_ffp_ps_fog_mode fog
;
3273 unsigned char sRGB_write
;
3274 unsigned char emul_clipplanes
;
3275 unsigned char texcoords_initialized
;
3276 unsigned char color_key_enabled
: 1;
3277 unsigned char pointsprite
: 1;
3278 unsigned char flatshading
: 1;
3279 unsigned char alpha_test_func
: 3;
3280 unsigned char padding
: 2;
3283 struct ffp_frag_desc
3285 struct wine_rb_entry entry
;
3286 struct ffp_frag_settings settings
;
3289 int wined3d_ffp_frag_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
3290 int wined3d_ffp_vertex_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
3292 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN
;
3294 void wined3d_ffp_get_fs_settings(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
3295 struct ffp_frag_settings
*settings
, BOOL ignore_textype
) DECLSPEC_HIDDEN
;
3296 const struct ffp_frag_desc
*find_ffp_frag_shader(const struct wine_rb_tree
*fragment_shaders
,
3297 const struct ffp_frag_settings
*settings
) DECLSPEC_HIDDEN
;
3298 void add_ffp_frag_shader(struct wine_rb_tree
*shaders
, struct ffp_frag_desc
*desc
) DECLSPEC_HIDDEN
;
3299 void wined3d_ftoa(float value
, char *s
) DECLSPEC_HIDDEN
;
3301 enum wined3d_ffp_vs_fog_mode
3303 WINED3D_FFP_VS_FOG_OFF
= 0,
3304 WINED3D_FFP_VS_FOG_FOGCOORD
= 1,
3305 WINED3D_FFP_VS_FOG_DEPTH
= 2,
3306 WINED3D_FFP_VS_FOG_RANGE
= 3,
3309 #define WINED3D_FFP_TCI_SHIFT 16
3310 #define WINED3D_FFP_TCI_MASK 0xffu
3312 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
3313 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
3315 struct wined3d_ffp_vs_settings
3317 DWORD point_light_count
: 4;
3318 DWORD spot_light_count
: 4;
3319 DWORD directional_light_count
: 4;
3320 DWORD parallel_point_light_count
: 4;
3321 DWORD diffuse_source
: 2;
3322 DWORD emissive_source
: 2;
3323 DWORD ambient_source
: 2;
3324 DWORD specular_source
: 2;
3325 DWORD transformed
: 1;
3326 DWORD vertexblends
: 2;
3329 DWORD normalize
: 1;
3331 DWORD localviewer
: 1;
3333 DWORD point_size
: 1;
3334 DWORD per_vertex_point_size
: 1;
3336 DWORD texcoords
: 8; /* WINED3D_MAX_TEXTURES */
3337 DWORD ortho_fog
: 1;
3338 DWORD flatshading
: 1;
3341 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
3343 unsigned int texgen
[WINED3D_MAX_TEXTURES
];
3346 struct wined3d_ffp_vs_desc
3348 struct wine_rb_entry entry
;
3349 struct wined3d_ffp_vs_settings settings
;
3352 void wined3d_ffp_get_vs_settings(const struct wined3d_context
*context
,
3353 const struct wined3d_state
*state
, struct wined3d_ffp_vs_settings
*settings
) DECLSPEC_HIDDEN
;
3359 unsigned int adapter_count
;
3360 struct wined3d_adapter
*adapters
[1];
3363 BOOL
wined3d_filter_messages(HWND window
, BOOL filter
) DECLSPEC_HIDDEN
;
3364 HRESULT
wined3d_init(struct wined3d
*wined3d
, uint32_t flags
) DECLSPEC_HIDDEN
;
3365 void wined3d_unregister_window(HWND window
) DECLSPEC_HIDDEN
;
3367 BOOL
wined3d_get_app_name(char *app_name
, unsigned int app_name_size
) DECLSPEC_HIDDEN
;
3369 struct wined3d_blend_state
3372 struct wined3d_blend_state_desc desc
;
3376 const struct wined3d_parent_ops
*parent_ops
;
3378 struct wined3d_device
*device
;
3379 struct wine_rb_entry entry
;
3382 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state
*state
,
3387 if (!state
->desc
.independent
)
3389 return state
->desc
.rt
[index
].writemask
;
3392 struct wined3d_depth_stencil_state
3395 struct wined3d_depth_stencil_state_desc desc
;
3400 const struct wined3d_parent_ops
*parent_ops
;
3402 struct wined3d_device
*device
;
3403 struct wine_rb_entry entry
;
3406 struct wined3d_rasterizer_state
3409 struct wined3d_rasterizer_state_desc desc
;
3412 const struct wined3d_parent_ops
*parent_ops
;
3414 struct wined3d_device
*device
;
3415 struct wine_rb_entry entry
;
3418 struct wined3d_light_state
3420 struct rb_tree lights_tree
;
3421 const struct wined3d_light_info
*lights
[WINED3D_MAX_ACTIVE_LIGHTS
];
3424 #define WINED3D_STATE_NO_REF 0x00000001
3425 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3427 struct wined3d_state
3429 enum wined3d_feature_level feature_level
;
3431 struct wined3d_fb_state fb
;
3433 struct wined3d_vertex_declaration
*vertex_declaration
;
3434 struct wined3d_stream_output stream_output
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
3435 struct wined3d_stream_state streams
[WINED3D_MAX_STREAMS
];
3436 struct wined3d_buffer
*index_buffer
;
3437 enum wined3d_format_id index_format
;
3438 unsigned int index_offset
;
3439 int base_vertex_index
;
3440 int load_base_vertex_index
; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3441 enum wined3d_primitive_type primitive_type
;
3442 unsigned int patch_vertex_count
;
3443 struct wined3d_query
*predicate
;
3444 BOOL predicate_value
;
3446 struct wined3d_shader
*shader
[WINED3D_SHADER_TYPE_COUNT
];
3447 struct wined3d_constant_buffer_state cb
[WINED3D_SHADER_TYPE_COUNT
][MAX_CONSTANT_BUFFERS
];
3448 struct wined3d_sampler
*sampler
[WINED3D_SHADER_TYPE_COUNT
][MAX_SAMPLER_OBJECTS
];
3449 struct wined3d_shader_resource_view
*shader_resource_view
[WINED3D_SHADER_TYPE_COUNT
][MAX_SHADER_RESOURCE_VIEWS
];
3450 struct wined3d_unordered_access_view
*unordered_access_view
[WINED3D_PIPELINE_COUNT
][MAX_UNORDERED_ACCESS_VIEWS
];
3452 struct wined3d_vec4 vs_consts_f
[WINED3D_MAX_VS_CONSTS_F
];
3453 struct wined3d_ivec4 vs_consts_i
[WINED3D_MAX_CONSTS_I
];
3454 BOOL vs_consts_b
[WINED3D_MAX_CONSTS_B
];
3456 struct wined3d_vec4 ps_consts_f
[WINED3D_MAX_PS_CONSTS_F
];
3457 struct wined3d_ivec4 ps_consts_i
[WINED3D_MAX_CONSTS_I
];
3458 BOOL ps_consts_b
[WINED3D_MAX_CONSTS_B
];
3460 struct wined3d_texture
*textures
[WINED3D_MAX_COMBINED_SAMPLERS
];
3461 uint32_t sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
3462 uint32_t texture_states
[WINED3D_MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
3464 struct wined3d_matrix transforms
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
3465 struct wined3d_vec4 clip_planes
[WINED3D_MAX_CLIP_DISTANCES
];
3466 struct wined3d_material material
;
3467 struct wined3d_viewport viewports
[WINED3D_MAX_VIEWPORTS
];
3468 unsigned int viewport_count
;
3469 RECT scissor_rects
[WINED3D_MAX_VIEWPORTS
];
3470 unsigned int scissor_rect_count
;
3472 struct wined3d_light_state light_state
;
3474 unsigned int render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
3475 struct wined3d_blend_state
*blend_state
;
3476 struct wined3d_color blend_factor
;
3477 unsigned int sample_mask
;
3478 struct wined3d_depth_stencil_state
*depth_stencil_state
;
3479 unsigned int stencil_ref
;
3480 bool depth_bounds_enable
;
3481 float depth_bounds_min
, depth_bounds_max
;
3482 struct wined3d_rasterizer_state
*rasterizer_state
;
3485 void state_cleanup(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3486 void state_init(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
3487 uint32_t flags
, enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
3488 void state_unbind_resources(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3490 static inline void wined3d_state_reset(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
)
3492 enum wined3d_feature_level feature_level
= state
->feature_level
;
3493 uint32_t flags
= state
->flags
;
3495 memset(state
, 0, sizeof(*state
));
3496 state_init(state
, d3d_info
, flags
, feature_level
);
3499 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state
*state
)
3501 if (!state
->depth_stencil_state
)
3503 return state
->depth_stencil_state
->desc
.depth
|| state
->depth_stencil_state
->desc
.depth_write
3504 || state
->depth_stencil_state
->desc
.stencil
;
3507 struct wined3d_dummy_textures
3514 GLuint tex_cube_array
;
3515 GLuint tex_1d_array
;
3516 GLuint tex_2d_array
;
3519 GLuint tex_2d_ms_array
;
3522 #define WINED3D_UNMAPPED_STAGE ~0u
3524 /* Multithreaded flag. Removed from the public header to signal that
3525 * wined3d_device_create() ignores it. */
3526 #define WINED3DCREATE_MULTITHREADED 0x00000004
3528 struct wined3d_so_desc_entry
3530 struct wine_rb_entry entry
;
3531 struct wined3d_stream_output_desc desc
;
3532 struct wined3d_stream_output_element elements
[1];
3535 struct wined3d_device
3539 /* WineD3D Information */
3540 struct wined3d_device_parent
*device_parent
;
3541 struct wined3d
*wined3d
;
3542 struct wined3d_adapter
*adapter
;
3544 const struct wined3d_shader_backend_ops
*shader_backend
;
3546 void *fragment_priv
;
3548 struct wined3d_state_entry state_table
[STATE_HIGHEST
+ 1];
3549 /* Array of functions for states which are handled by more than one pipeline part */
3550 APPLYSTATEFUNC
*multistate_funcs
[STATE_HIGHEST
+ 1];
3551 struct wined3d_blitter
*blitter
;
3553 BYTE bCursorVisible
: 1;
3554 BYTE d3d_initialized
: 1;
3555 BYTE inScene
: 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3556 BYTE softwareVertexProcessing
: 1; /* process vertex shaders using software or hardware */
3557 BYTE restore_screensaver
: 1;
3560 unsigned char surface_alignment
; /* Line Alignment of surfaces */
3564 /* Internal use fields */
3565 struct wined3d_device_creation_parameters create_parms
;
3568 struct wined3d_rendertarget_view
*back_buffer_view
;
3569 struct wined3d_swapchain
**swapchains
;
3570 UINT swapchain_count
;
3571 unsigned int max_frame_latency
;
3573 struct list resources
; /* a linked list to track resources created by the device */
3574 struct list shaders
; /* a linked list to track shaders (pixel and vertex) */
3575 struct wine_rb_tree so_descs
;
3576 struct wine_rb_tree samplers
, rasterizer_states
, blend_states
, depth_stencil_states
;
3578 /* Render Target Support */
3579 struct wined3d_rendertarget_view
*auto_depth_stencil_view
;
3581 /* Cursor management */
3586 UINT cursorWidth
, cursorHeight
;
3587 struct wined3d_texture
*cursor_texture
;
3588 HCURSOR hardwareCursor
;
3590 /* The Wine logo texture */
3591 struct wined3d_texture
*logo_texture
;
3593 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3594 struct wined3d_sampler
*default_sampler
;
3595 struct wined3d_sampler
*null_sampler
;
3597 /* Command stream */
3598 struct wined3d_cs
*cs
;
3600 /* Context management */
3601 struct wined3d_context
**contexts
;
3604 CRITICAL_SECTION bo_map_lock
;
3607 void wined3d_device_cleanup(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3608 BOOL
device_context_add(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3609 void device_context_remove(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3610 void wined3d_device_create_default_samplers(struct wined3d_device
*device
,
3611 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3612 void wined3d_device_destroy_default_samplers(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3613 HRESULT
wined3d_device_init(struct wined3d_device
*device
, struct wined3d
*wined3d
,
3614 unsigned int adapter_idx
, enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
3615 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
3616 const BOOL
*supported_extensions
, struct wined3d_device_parent
*device_parent
) DECLSPEC_HIDDEN
;
3617 LRESULT
device_process_message(struct wined3d_device
*device
, HWND window
, BOOL unicode
,
3618 UINT message
, WPARAM wparam
, LPARAM lparam
, WNDPROC proc
) DECLSPEC_HIDDEN
;
3619 void device_resource_add(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3620 void device_resource_released(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3621 void device_invalidate_state(const struct wined3d_device
*device
, unsigned int state
) DECLSPEC_HIDDEN
;
3622 HRESULT
wined3d_device_set_implicit_swapchain(struct wined3d_device
*device
,
3623 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3624 void wined3d_device_uninit_3d(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3626 static inline void wined3d_device_bo_map_lock(struct wined3d_device
*device
)
3628 EnterCriticalSection(&device
->bo_map_lock
);
3631 static inline void wined3d_device_bo_map_unlock(struct wined3d_device
*device
)
3633 LeaveCriticalSection(&device
->bo_map_lock
);
3636 struct wined3d_device_no3d
3638 struct wined3d_device d
;
3640 struct wined3d_context context_no3d
;
3643 static inline struct wined3d_device_no3d
*wined3d_device_no3d(struct wined3d_device
*device
)
3645 return CONTAINING_RECORD(device
, struct wined3d_device_no3d
, d
);
3648 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
3649 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
3650 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
3651 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
3652 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
3654 struct wined3d_allocator_chunk
3657 struct list available
[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT
];
3658 struct wined3d_allocator
*allocator
;
3659 unsigned int map_count
;
3663 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk
*chunk
) DECLSPEC_HIDDEN
;
3664 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk
*chunk
,
3665 struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3667 struct wined3d_allocator_chunk_gl
3669 struct wined3d_allocator_chunk c
;
3670 unsigned int memory_type
;
3674 static inline struct wined3d_allocator_chunk_gl
*wined3d_allocator_chunk_gl(struct wined3d_allocator_chunk
*chunk
)
3676 return CONTAINING_RECORD(chunk
, struct wined3d_allocator_chunk_gl
, c
);
3679 struct wined3d_allocator_block
3682 struct wined3d_allocator_chunk
*chunk
;
3683 struct wined3d_allocator_block
*parent
, *sibling
;
3689 void wined3d_allocator_block_free(struct wined3d_allocator_block
*block
) DECLSPEC_HIDDEN
;
3691 struct wined3d_allocator_pool
3696 struct wined3d_allocator_ops
3698 struct wined3d_allocator_chunk
*(*allocator_create_chunk
)(struct wined3d_allocator
*allocator
,
3699 struct wined3d_context
*context
, unsigned int memory_type
, size_t chunk_size
);
3700 void (*allocator_destroy_chunk
)(struct wined3d_allocator_chunk
*chunk
);
3703 struct wined3d_allocator
3705 const struct wined3d_allocator_ops
*ops
;
3706 struct wined3d_allocator_pool
*pools
;
3708 struct wined3d_allocator_block
*free
;
3711 struct wined3d_allocator_block
*wined3d_allocator_allocate(struct wined3d_allocator
*allocator
,
3712 struct wined3d_context
*context
, unsigned int memory_type
, size_t size
) DECLSPEC_HIDDEN
;
3713 void wined3d_allocator_cleanup(struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3714 bool wined3d_allocator_init(struct wined3d_allocator
*allocator
,
3715 size_t pool_count
, const struct wined3d_allocator_ops
*allocator_ops
) DECLSPEC_HIDDEN
;
3717 struct wined3d_device_gl
3719 struct wined3d_device d
;
3721 /* Textures for when no other textures are bound. */
3722 struct wined3d_dummy_textures dummy_textures
;
3724 CRITICAL_SECTION allocator_cs
;
3725 struct wined3d_allocator allocator
;
3726 uint64_t completed_fence_id
;
3727 uint64_t current_fence_id
;
3728 uint64_t retired_bo_size
;
3730 struct wined3d_retired_block_gl
3732 struct wined3d_allocator_block
*block
;
3735 SIZE_T retired_blocks_size
;
3736 SIZE_T retired_block_count
;
3742 static inline struct wined3d_device_gl
*wined3d_device_gl(struct wined3d_device
*device
)
3744 return CONTAINING_RECORD(device
, struct wined3d_device_gl
, d
);
3747 static inline struct wined3d_device_gl
*wined3d_device_gl_from_allocator(struct wined3d_allocator
*allocator
)
3749 return CONTAINING_RECORD(allocator
, struct wined3d_device_gl
, allocator
);
3752 static inline void wined3d_device_gl_allocator_lock(struct wined3d_device_gl
*device_gl
)
3754 EnterCriticalSection(&device_gl
->allocator_cs
);
3757 static inline void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl
*device_gl
)
3759 LeaveCriticalSection(&device_gl
->allocator_cs
);
3762 static inline void wined3d_allocator_chunk_gl_lock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
3764 wined3d_device_gl_allocator_lock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
3767 static inline void wined3d_allocator_chunk_gl_unlock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
3769 wined3d_device_gl_allocator_unlock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
3772 bool wined3d_device_gl_create_bo(struct wined3d_device_gl
*device_gl
,
3773 struct wined3d_context_gl
*context_gl
, GLsizeiptr size
, GLenum binding
,
3774 GLenum usage
, bool coherent
, GLbitfield flags
, struct wined3d_bo_gl
*bo
) DECLSPEC_HIDDEN
;
3775 void wined3d_device_gl_create_primary_opengl_context_cs(void *object
) DECLSPEC_HIDDEN
;
3776 void wined3d_device_gl_delete_opengl_contexts_cs(void *object
) DECLSPEC_HIDDEN
;
3777 HDC
wined3d_device_gl_get_backup_dc(struct wined3d_device_gl
*device_gl
) DECLSPEC_HIDDEN
;
3778 GLbitfield
wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx
) DECLSPEC_HIDDEN
;
3780 static inline float wined3d_alpha_ref(const struct wined3d_state
*state
)
3782 return (state
->render_states
[WINED3D_RS_ALPHAREF
] & 0xff) / 255.0f
;
3785 const char *wined3d_debug_resource_access(uint32_t access
) DECLSPEC_HIDDEN
;
3786 const char *wined3d_debug_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
3787 const char *wined3d_debug_view_desc(const struct wined3d_view_desc
*d
,
3788 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3790 static inline ULONG
wined3d_atomic_decrement_mutex_lock(volatile LONG
*refcount
)
3792 ULONG count
, old_count
= *refcount
;
3795 if ((count
= old_count
) == 1)
3797 wined3d_mutex_lock();
3798 count
= InterlockedDecrement(refcount
);
3799 if (count
) wined3d_mutex_unlock();
3803 old_count
= InterlockedCompareExchange(refcount
, count
- 1, count
);
3805 while (old_count
!= count
);
3810 #define CLIENT_BO_DISCARDED ((struct wined3d_bo *)~(UINT_PTR)0)
3812 struct wined3d_client_resource
3814 /* The resource's persistently mapped address, which we may use to perform
3815 * NOOVERWRITE maps from the client thread. */
3816 struct wined3d_bo_address addr
;
3818 /* The currently mapped upload BO, if applicable, and box. */
3819 struct upload_bo mapped_upload
;
3820 struct wined3d_box mapped_box
;
3823 static inline BOOL
wined3d_resource_access_is_managed(unsigned int access
)
3825 return !(~access
& (WINED3D_RESOURCE_ACCESS_GPU
| WINED3D_RESOURCE_ACCESS_CPU
));
3828 struct wined3d_resource_ops
3830 ULONG (*resource_incref
)(struct wined3d_resource
*resource
);
3831 ULONG (*resource_decref
)(struct wined3d_resource
*resource
);
3832 void (*resource_preload
)(struct wined3d_resource
*resource
);
3833 void (*resource_unload
)(struct wined3d_resource
*resource
);
3834 HRESULT (*resource_sub_resource_get_desc
)(struct wined3d_resource
*resource
,
3835 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
);
3836 void (*resource_sub_resource_get_map_pitch
)(struct wined3d_resource
*resource
,
3837 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
);
3838 HRESULT (*resource_sub_resource_map
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3839 void **map_ptr
, const struct wined3d_box
*box
, uint32_t flags
);
3840 HRESULT (*resource_sub_resource_unmap
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
);
3843 struct wined3d_resource
3849 struct wined3d_device
*device
;
3850 enum wined3d_resource_type type
;
3851 enum wined3d_gl_resource_type gl_type
;
3852 const struct wined3d_format
*format
;
3853 unsigned int format_attrs
;
3854 unsigned int format_caps
;
3855 enum wined3d_multisample_type multisample_type
;
3856 UINT multisample_quality
;
3858 unsigned int bind_flags
;
3859 unsigned int access
;
3866 unsigned int priority
;
3869 uint32_t pin_sysmem
: 1;
3871 struct wined3d_client_resource client
;
3874 const struct wined3d_parent_ops
*parent_ops
;
3875 const struct wined3d_resource_ops
*resource_ops
;
3877 struct list resource_list_entry
;
3879 LONG srv_bind_count_device
;
3880 LONG rtv_bind_count_device
;
3883 static inline ULONG
wined3d_resource_incref(struct wined3d_resource
*resource
)
3885 return resource
->resource_ops
->resource_incref(resource
);
3888 static inline ULONG
wined3d_resource_decref(struct wined3d_resource
*resource
)
3890 return resource
->resource_ops
->resource_decref(resource
);
3893 static inline HRESULT
wined3d_resource_get_sub_resource_desc(struct wined3d_resource
*resource
,
3894 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
)
3896 return resource
->resource_ops
->resource_sub_resource_get_desc(resource
, sub_resource_idx
, desc
);
3899 static inline void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource
*resource
,
3900 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
)
3902 resource
->resource_ops
->resource_sub_resource_get_map_pitch(resource
, sub_resource_idx
, row_pitch
, slice_pitch
);
3905 void resource_cleanup(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3906 HRESULT
resource_init(struct wined3d_resource
*resource
, struct wined3d_device
*device
,
3907 enum wined3d_resource_type type
, const struct wined3d_format
*format
,
3908 enum wined3d_multisample_type multisample_type
, unsigned int multisample_quality
, unsigned int usage
,
3909 unsigned int bind_flags
, unsigned int access
, unsigned int width
, unsigned int height
, unsigned int depth
,
3910 unsigned int size
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3911 const struct wined3d_resource_ops
*resource_ops
) DECLSPEC_HIDDEN
;
3912 void *resource_offset_map_pointer(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3913 uint8_t *base_memory
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3914 void resource_unload(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3915 HRESULT
wined3d_resource_check_box_dimensions(struct wined3d_resource
*resource
,
3916 unsigned int sub_resource_idx
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3917 void wined3d_resource_free_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3918 const struct wined3d_format
*wined3d_resource_get_decompress_format(
3919 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3920 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3921 GLbitfield
wined3d_resource_gl_map_flags(const struct wined3d_bo_gl
*bo
, DWORD d3d_flags
) DECLSPEC_HIDDEN
;
3922 GLenum
wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags
) DECLSPEC_HIDDEN
;
3923 GLbitfield
wined3d_resource_gl_storage_flags(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3924 BOOL
wined3d_resource_is_offscreen(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3925 BOOL
wined3d_resource_prepare_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3926 void wined3d_resource_update_draw_binding(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3927 void wined3d_resource_memory_colour_fill(struct wined3d_resource
*resource
,
3928 const struct wined3d_map_desc
*map
, const struct wined3d_color
*colour
,
3929 const struct wined3d_box
*box
, bool full_subresource
) DECLSPEC_HIDDEN
;
3931 /* Tests show that the start address of resources is 32 byte aligned */
3932 #define RESOURCE_ALIGNMENT 16
3933 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3935 #define WINED3D_LOCATION_DISCARDED 0x00000001
3936 #define WINED3D_LOCATION_SYSMEM 0x00000002
3937 #define WINED3D_LOCATION_CLEARED 0x00000004
3938 #define WINED3D_LOCATION_BUFFER 0x00000008
3939 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3940 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3941 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3942 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3943 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3945 const char *wined3d_debug_location(uint32_t location
) DECLSPEC_HIDDEN
;
3947 struct wined3d_blt_info
3950 struct wined3d_vec3 texcoords
[4];
3953 struct wined3d_texture_ops
3955 BOOL (*texture_prepare_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3956 struct wined3d_context
*context
, unsigned int location
);
3957 BOOL (*texture_load_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3958 struct wined3d_context
*context
, unsigned int location
);
3959 void (*texture_unload_location
)(struct wined3d_texture
*texture
,
3960 struct wined3d_context
*context
, unsigned int location
);
3961 void (*texture_upload_data
)(struct wined3d_context
*context
, const struct wined3d_const_bo_address
*src_bo_addr
,
3962 const struct wined3d_format
*src_format
, const struct wined3d_box
*src_box
, unsigned int src_row_pitch
,
3963 unsigned int src_slice_pitch
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3964 unsigned int dst_location
, unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
);
3965 void (*texture_download_data
)(struct wined3d_context
*context
, struct wined3d_texture
*src_texture
,
3966 unsigned int src_sub_resource_idx
, unsigned int src_location
, const struct wined3d_box
*src_box
,
3967 const struct wined3d_bo_address
*dst_bo_addr
, const struct wined3d_format
*dst_format
,
3968 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
,
3969 unsigned int dst_row_pitch
, unsigned int dst_slice_pitch
);
3972 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3973 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3974 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3975 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3976 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3977 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3978 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3979 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3980 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3981 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3982 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3983 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3984 #define WINED3D_TEXTURE_DISCARD 0x00002000
3985 #define WINED3D_TEXTURE_GET_DC 0x00004000
3986 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3987 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3989 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3991 struct wined3d_texture
3993 struct wined3d_resource resource
;
3994 const struct wined3d_texture_ops
*texture_ops
;
3995 struct wined3d_swapchain
*swapchain
;
3996 unsigned int pow2_width
;
3997 unsigned int pow2_height
;
3999 unsigned int level_count
;
4000 unsigned int download_count
;
4001 unsigned int sysmem_count
;
4002 float pow2_matrix
[16];
4006 DWORD update_map_binding
;
4008 unsigned int row_pitch
;
4009 unsigned int slice_pitch
;
4011 /* May only be accessed from the command stream worker thread. */
4012 struct wined3d_texture_async
4016 /* Color keys for DDraw */
4017 struct wined3d_color_key dst_blt_color_key
;
4018 struct wined3d_color_key src_blt_color_key
;
4019 struct wined3d_color_key dst_overlay_color_key
;
4020 struct wined3d_color_key src_overlay_color_key
;
4021 struct wined3d_color_key gl_color_key
;
4022 DWORD color_key_flags
;
4025 struct wined3d_dirty_regions
4027 struct wined3d_box
*boxes
;
4029 unsigned int box_count
;
4032 struct wined3d_overlay_info
4035 struct list overlays
;
4036 struct wined3d_texture
*dst_texture
;
4037 unsigned int dst_sub_resource_idx
;
4042 struct wined3d_dc_info
4048 struct wined3d_texture_sub_resource
4051 const struct wined3d_parent_ops
*parent_ops
;
4053 unsigned int offset
;
4056 unsigned int map_count
;
4059 struct wined3d_bo
*bo
;
4062 struct wined3d_color colour
;
4066 unsigned int stencil
;
4074 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s
, SIZE_T level_count
, SIZE_T layer_count
)
4076 struct wined3d_texture
*t
;
4078 if (level_count
> ((~(SIZE_T
)0 - s
) / sizeof(*t
->sub_resources
)) / layer_count
)
4081 return heap_alloc_zero(s
+ level_count
* layer_count
* sizeof(*t
->sub_resources
));
4084 static inline struct wined3d_texture
*texture_from_resource(struct wined3d_resource
*resource
)
4086 return CONTAINING_RECORD(resource
, struct wined3d_texture
, resource
);
4089 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture
*texture
,
4092 return max(1, texture
->resource
.width
>> level
);
4095 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture
*texture
,
4098 return max(1, texture
->resource
.height
>> level
);
4101 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture
*texture
,
4104 return max(1, texture
->resource
.depth
>> level
);
4107 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture
*texture
,
4110 return max(1, texture
->pow2_width
>> level
);
4113 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture
*texture
,
4116 return max(1, texture
->pow2_height
>> level
);
4119 static inline void wined3d_texture_get_level_box(const struct wined3d_texture
*texture
,
4120 unsigned int level
, struct wined3d_box
*box
)
4122 wined3d_box_set(box
, 0, 0,
4123 wined3d_texture_get_level_width(texture
, level
),
4124 wined3d_texture_get_level_height(texture
, level
),
4125 0, wined3d_texture_get_level_depth(texture
, level
));
4128 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture
*texture
,
4129 unsigned int level
, const RECT
*r
)
4133 t
= wined3d_texture_get_level_width(texture
, level
);
4134 if ((r
->left
&& r
->right
) || abs(r
->right
- r
->left
) != t
)
4136 t
= wined3d_texture_get_level_height(texture
, level
);
4137 if ((r
->top
&& r
->bottom
) || abs(r
->bottom
- r
->top
) != t
)
4142 HRESULT
texture2d_blt(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4143 const struct wined3d_box
*dst_box
, struct wined3d_texture
*src_texture
,
4144 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
, uint32_t flags
,
4145 const struct wined3d_blt_fx
*blt_fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
4146 void texture2d_get_blt_info(const struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
4147 const RECT
*rect
, struct wined3d_blt_info
*info
) DECLSPEC_HIDDEN
;
4148 void texture2d_load_fb_texture(struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
4149 BOOL srgb
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4150 void texture2d_read_from_framebuffer(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4151 struct wined3d_context
*context
, DWORD src_location
, DWORD dst_location
) DECLSPEC_HIDDEN
;
4153 void wined3d_texture_cleanup(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4154 void wined3d_texture_download_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4155 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
) DECLSPEC_HIDDEN
;
4156 void wined3d_texture_get_bo_address(const struct wined3d_texture
*texture
,
4157 unsigned int sub_resource_idx
, struct wined3d_bo_address
*data
, uint32_t location
) DECLSPEC_HIDDEN
;
4158 GLenum
wined3d_texture_get_gl_buffer(const struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4159 void wined3d_texture_invalidate_location(struct wined3d_texture
*texture
,
4160 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
4161 void wined3d_texture_load(struct wined3d_texture
*texture
,
4162 struct wined3d_context
*context
, BOOL srgb
) DECLSPEC_HIDDEN
;
4163 BOOL
wined3d_texture_load_location(struct wined3d_texture
*texture
,
4164 unsigned int sub_resource_idx
, struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4165 BOOL
wined3d_texture_prepare_location(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4166 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4167 void wined3d_texture_set_swapchain(struct wined3d_texture
*texture
,
4168 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4169 BOOL
wined3d_texture_can_use_pbo(const struct wined3d_texture
*texture
, const struct wined3d_d3d_info
*d3d_info
)
4171 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4172 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture
*texture
,
4173 HWND window
, RECT
*rect
) DECLSPEC_HIDDEN
;
4174 void wined3d_texture_update_sub_resource(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
4175 struct wined3d_context
*context
, const struct upload_bo
*upload_bo
, const struct wined3d_box
*box
,
4176 unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
4177 void wined3d_texture_upload_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
4178 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
, struct wined3d_texture
*src_texture
,
4179 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
) DECLSPEC_HIDDEN
;
4180 void wined3d_texture_validate_location(struct wined3d_texture
*texture
,
4181 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
4182 bool wined3d_texture_validate_sub_resource_idx(const struct wined3d_texture
*texture
,
4183 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
4184 void wined3d_texture_clear_dirty_regions(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4186 HRESULT
wined3d_texture_no3d_init(struct wined3d_texture
*texture_no3d
, struct wined3d_device
*device
,
4187 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
4188 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4190 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle
[4], struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
4194 struct wined3d_sampler_desc sampler_desc
;
4195 unsigned int base_level
;
4199 struct wined3d_texture_gl
4201 struct wined3d_texture t
;
4203 struct gl_texture texture_rgb
, texture_srgb
;
4207 GLuint rb_multisample
;
4210 struct list renderbuffers
;
4211 const struct wined3d_renderbuffer_entry
*current_renderbuffer
;
4214 static inline struct wined3d_texture_gl
*wined3d_texture_gl(struct wined3d_texture
*texture
)
4216 return CONTAINING_RECORD(texture
, struct wined3d_texture_gl
, t
);
4219 static inline struct gl_texture
*wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl
*texture_gl
,
4222 return srgb
? &texture_gl
->texture_srgb
: &texture_gl
->texture_rgb
;
4225 static inline GLenum
wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl
*texture_gl
,
4226 unsigned int sub_resource_idx
)
4228 static const GLenum cube_targets
[] =
4230 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
,
4231 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
,
4232 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
,
4233 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
,
4234 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
,
4235 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
,
4238 return texture_gl
->t
.resource
.usage
& WINED3DUSAGE_LEGACY_CUBEMAP
4239 ? cube_targets
[sub_resource_idx
/ texture_gl
->t
.level_count
] : texture_gl
->target
;
4242 static inline BOOL
wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl
*texture_gl
,
4245 if (location
== WINED3D_LOCATION_RB_MULTISAMPLE
)
4247 if (location
!= WINED3D_LOCATION_TEXTURE_RGB
&& location
!= WINED3D_LOCATION_TEXTURE_SRGB
)
4249 return texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE
|| texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
;
4252 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl
*texture_gl
,
4253 const struct wined3d_sampler_desc
*sampler_desc
, const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4254 void wined3d_texture_gl_bind(struct wined3d_texture_gl
*texture_gl
,
4255 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
4256 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl
*texture_gl
,
4257 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
4258 HRESULT
wined3d_texture_gl_init(struct wined3d_texture_gl
*texture_gl
, struct wined3d_device
*device
,
4259 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
4260 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4261 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl
*texture_gl
,
4262 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
4263 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl
*texture_gl
,
4264 struct wined3d_context_gl
*context_gl
, unsigned int level
,
4265 const struct wined3d_rendertarget_info
*rt
) DECLSPEC_HIDDEN
;
4267 struct wined3d_renderbuffer_entry
4275 struct wined3d_fbo_resource
4279 GLuint level
, layer
;
4282 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
4283 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
4284 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
4292 struct wined3d_fbo_entry_key
4295 struct wined3d_fbo_resource objects
[WINED3D_MAX_RENDER_TARGETS
+ 1];
4299 struct wined3d_sampler
4301 struct wine_rb_entry entry
;
4303 struct wined3d_device
*device
;
4305 const struct wined3d_parent_ops
*parent_ops
;
4306 struct wined3d_sampler_desc desc
;
4309 struct wined3d_sampler_gl
4311 struct wined3d_sampler s
;
4316 static inline struct wined3d_sampler_gl
*wined3d_sampler_gl(struct wined3d_sampler
*sampler
)
4318 return CONTAINING_RECORD(sampler
, struct wined3d_sampler_gl
, s
);
4321 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl
*sampler_gl
, unsigned int unit
,
4322 struct wined3d_texture_gl
*texture_gl
, const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4323 void wined3d_sampler_gl_init(struct wined3d_sampler_gl
*sampler_gl
,
4324 struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
4325 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4327 struct wined3d_vertex_declaration_element
4329 const struct wined3d_format
*format
;
4331 unsigned int input_slot
;
4332 unsigned int offset
;
4333 unsigned int output_slot
;
4334 enum wined3d_input_classification input_slot_class
;
4335 unsigned int instance_data_step_rate
;
4341 struct wined3d_vertex_declaration
4345 const struct wined3d_parent_ops
*parent_ops
;
4346 struct wined3d_device
*device
;
4348 struct wined3d_vertex_declaration_element
*elements
;
4349 unsigned int element_count
;
4351 BOOL position_transformed
;
4354 struct wined3d_saved_states
4356 uint32_t vs_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F
)];
4357 WORD vertexShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
4358 WORD vertexShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
4359 uint32_t ps_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F
)];
4360 WORD pixelShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
4361 WORD pixelShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
4362 uint32_t transform
[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE
+ 1)];
4363 WORD streamSource
; /* WINED3D_MAX_STREAMS, 16 */
4364 WORD streamFreq
; /* WINED3D_MAX_STREAMS, 16 */
4365 uint32_t renderState
[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE
+ 1)];
4366 DWORD textureState
[WINED3D_MAX_TEXTURES
]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
4367 WORD samplerState
[WINED3D_MAX_COMBINED_SAMPLERS
]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
4368 DWORD clipplane
; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
4369 DWORD textures
: 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
4373 DWORD vertexDecl
: 1;
4374 DWORD pixelShader
: 1;
4375 DWORD vertexShader
: 1;
4376 DWORD scissorRect
: 1;
4377 DWORD store_stream_offset
: 1;
4378 DWORD alpha_to_coverage
: 1;
4380 DWORD transforms
: 1;
4383 struct list changed_lights
;
4391 struct wined3d_stateblock
4393 LONG ref
; /* Note: Ref counting not required */
4394 struct wined3d_device
*device
;
4396 /* Array indicating whether things have been set or changed */
4397 struct wined3d_saved_states changed
;
4399 struct wined3d_stateblock_state stateblock_state
;
4400 struct wined3d_light_state light_state
;
4402 /* Contained state management */
4403 DWORD contained_render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
4404 unsigned int num_contained_render_states
;
4405 DWORD contained_transform_states
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
4406 unsigned int num_contained_transform_states
;
4407 struct StageState contained_tss_states
[WINED3D_MAX_TEXTURES
* (WINED3D_HIGHEST_TEXTURE_STATE
+ 1)];
4408 unsigned int num_contained_tss_states
;
4409 struct StageState contained_sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
* WINED3D_HIGHEST_SAMPLER_STATE
];
4410 unsigned int num_contained_sampler_states
;
4413 void wined3d_stateblock_state_init(struct wined3d_stateblock_state
*state
,
4414 const struct wined3d_device
*device
, uint32_t flags
) DECLSPEC_HIDDEN
;
4415 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state
*state
) DECLSPEC_HIDDEN
;
4417 bool wined3d_light_state_enable_light(struct wined3d_light_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
4418 struct wined3d_light_info
*light_info
, BOOL enable
) DECLSPEC_HIDDEN
;
4419 struct wined3d_light_info
*wined3d_light_state_get_light(const struct wined3d_light_state
*state
,
4420 unsigned int idx
) DECLSPEC_HIDDEN
;
4421 HRESULT
wined3d_light_state_set_light(struct wined3d_light_state
*state
, DWORD light_idx
,
4422 const struct wined3d_light
*params
, struct wined3d_light_info
**light_info
) DECLSPEC_HIDDEN
;
4424 enum wined3d_cs_queue_id
4426 WINED3D_CS_QUEUE_DEFAULT
= 0,
4427 WINED3D_CS_QUEUE_MAP
,
4428 WINED3D_CS_QUEUE_COUNT
,
4431 enum wined3d_push_constants
4433 WINED3D_PUSH_CONSTANTS_VS_F
,
4434 WINED3D_PUSH_CONSTANTS_PS_F
,
4435 WINED3D_PUSH_CONSTANTS_VS_I
,
4436 WINED3D_PUSH_CONSTANTS_PS_I
,
4437 WINED3D_PUSH_CONSTANTS_VS_B
,
4438 WINED3D_PUSH_CONSTANTS_PS_B
,
4441 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
4443 #define WINED3D_CS_QUEUE_SIZE 0x1000000u
4445 #define WINED3D_CS_QUEUE_SIZE 0x400000u
4447 #define WINED3D_CS_SPIN_COUNT 2000u
4448 #define WINED3D_CS_QUEUE_MASK (WINED3D_CS_QUEUE_SIZE - 1)
4450 C_ASSERT(!(WINED3D_CS_QUEUE_SIZE
& (WINED3D_CS_QUEUE_SIZE
- 1)));
4452 struct wined3d_cs_queue
4455 BYTE data
[WINED3D_CS_QUEUE_SIZE
];
4458 struct wined3d_device_context_ops
4460 void *(*require_space
)(struct wined3d_device_context
*context
, size_t size
, enum wined3d_cs_queue_id queue_id
);
4461 void (*submit
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
4462 void (*finish
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
4463 void (*push_constants
)(struct wined3d_device_context
*context
, enum wined3d_push_constants p
,
4464 unsigned int start_idx
, unsigned int count
, const void *constants
);
4465 bool (*map_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
4466 unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
4467 const struct wined3d_box
*box
, uint32_t flags
);
4468 bool (*unmap_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
4469 unsigned int sub_resource_idx
, struct wined3d_box
*box
, struct upload_bo
*upload_bo
);
4470 void (*issue_query
)(struct wined3d_device_context
*context
, struct wined3d_query
*query
, unsigned int flags
);
4471 void (*flush
)(struct wined3d_device_context
*context
);
4472 void (*reference_resource
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
);
4473 void (*reference_command_list
)(struct wined3d_device_context
*context
, struct wined3d_command_list
*list
);
4476 struct wined3d_device_context
4478 const struct wined3d_device_context_ops
*ops
;
4479 struct wined3d_device
*device
;
4480 struct wined3d_state
*state
;
4485 struct wined3d_device_context c
;
4487 struct wined3d_state state
;
4488 HMODULE wined3d_module
;
4491 BOOL serialize_commands
;
4493 struct wined3d_cs_queue queue
[WINED3D_CS_QUEUE_COUNT
];
4494 size_t data_size
, start
, end
;
4496 struct list query_poll_list
;
4497 BOOL queries_flushed
;
4499 HANDLE event
, present_event
;
4500 LONG waiting_for_event
;
4501 LONG waiting_for_present
;
4502 LONG pending_presents
;
4505 static inline void wined3d_device_context_lock(struct wined3d_device_context
*context
)
4507 if (context
== &context
->device
->cs
->c
)
4508 wined3d_mutex_lock();
4511 static inline void wined3d_device_context_unlock(struct wined3d_device_context
*context
)
4513 if (context
== &context
->device
->cs
->c
)
4514 wined3d_mutex_unlock();
4517 struct wined3d_cs
*wined3d_cs_create(struct wined3d_device
*device
,
4518 const enum wined3d_feature_level
*levels
, unsigned int level_count
) DECLSPEC_HIDDEN
;
4519 void wined3d_cs_destroy(struct wined3d_cs
*cs
) DECLSPEC_HIDDEN
;
4520 void wined3d_cs_destroy_object(struct wined3d_cs
*cs
,
4521 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
4522 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs
*cs
,
4523 struct wined3d_texture
*texture
, unsigned int layer
) DECLSPEC_HIDDEN
;
4524 void wined3d_cs_emit_clear(struct wined3d_cs
*cs
, DWORD rect_count
, const RECT
*rects
,
4525 uint32_t flags
, const struct wined3d_color
*color
, float depth
, DWORD stencil
) DECLSPEC_HIDDEN
;
4526 void wined3d_device_context_emit_clear_uav(struct wined3d_device_context
*context
,
4527 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
) DECLSPEC_HIDDEN
;
4528 void wined3d_cs_emit_preload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4529 void wined3d_cs_emit_present(struct wined3d_cs
*cs
, struct wined3d_swapchain
*swapchain
, const RECT
*src_rect
,
4530 const RECT
*dst_rect
, HWND dst_window_override
, unsigned int swap_interval
, uint32_t flags
) DECLSPEC_HIDDEN
;
4531 void wined3d_cs_emit_set_color_key(struct wined3d_cs
*cs
, struct wined3d_texture
*texture
,
4532 WORD flags
, const struct wined3d_color_key
*color_key
) DECLSPEC_HIDDEN
;
4533 void wined3d_cs_emit_set_render_state(struct wined3d_cs
*cs
,
4534 enum wined3d_render_state state
, DWORD value
) DECLSPEC_HIDDEN
;
4535 void wined3d_cs_emit_unload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4536 void wined3d_cs_init_object(struct wined3d_cs
*cs
,
4537 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
4538 void wined3d_cs_map_bo_address(struct wined3d_cs
*cs
,
4539 struct wined3d_bo_address
*addr
, size_t size
, unsigned int flags
) DECLSPEC_HIDDEN
;
4540 void wined3d_device_context_set_depth_bounds(struct wined3d_device_context
*context
,
4541 bool enable
, float min_depth
, float max_depth
);
4543 static inline void wined3d_cs_finish(struct wined3d_cs
*cs
, enum wined3d_cs_queue_id queue_id
)
4545 cs
->c
.ops
->finish(&cs
->c
, queue_id
);
4548 static inline void wined3d_device_context_push_constants(struct wined3d_device_context
*context
,
4549 enum wined3d_push_constants p
, unsigned int start_idx
, unsigned int count
, const void *constants
)
4551 context
->ops
->push_constants(context
, p
, start_idx
, count
, constants
);
4554 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
*context
,
4555 struct wined3d_resource
*dst_resource
, unsigned int dst_sub_resource_idx
, const struct wined3d_box
*dst_box
,
4556 struct wined3d_resource
*src_resource
, unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
,
4557 unsigned int flags
, const struct wined3d_blt_fx
*fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
4558 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context
*context
,
4559 struct wined3d_rendertarget_view
*view
, const RECT
*rect
, unsigned int flags
,
4560 const struct wined3d_color
*color
, float depth
, unsigned int stencil
) DECLSPEC_HIDDEN
;
4561 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context
*context
,
4562 struct wined3d_buffer
*dst_buffer
, unsigned int offset
,
4563 struct wined3d_unordered_access_view
*uav
) DECLSPEC_HIDDEN
;
4564 void wined3d_device_context_emit_draw(struct wined3d_device_context
*context
,
4565 enum wined3d_primitive_type primitive_type
, unsigned int patch_vertex_count
, int base_vertex_idx
,
4566 unsigned int start_idx
, unsigned int index_count
, unsigned int start_instance
, unsigned int instance_count
,
4567 bool indexed
) DECLSPEC_HIDDEN
;
4568 void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context
*context
,
4569 struct wined3d_command_list
*list
, bool restore_state
) DECLSPEC_HIDDEN
;
4570 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context
*context
,
4571 struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
4572 HRESULT
wined3d_device_context_emit_map(struct wined3d_device_context
*context
,
4573 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
4574 const struct wined3d_box
*box
, unsigned int flags
) DECLSPEC_HIDDEN
;
4575 void wined3d_device_context_emit_reset_state(struct wined3d_device_context
*context
, bool invalidate
) DECLSPEC_HIDDEN
;
4576 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context
*context
,
4577 struct wined3d_blend_state
*state
, const struct wined3d_color
*blend_factor
,
4578 unsigned int sample_mask
) DECLSPEC_HIDDEN
;
4579 void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context
*context
, unsigned int plane_idx
,
4580 const struct wined3d_vec4
*plane
) DECLSPEC_HIDDEN
;
4581 void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context
*context
,
4582 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
4583 const struct wined3d_constant_buffer_state
*buffers
) DECLSPEC_HIDDEN
;
4584 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context
*context
,
4585 struct wined3d_depth_stencil_state
*state
, unsigned int stencil_ref
) DECLSPEC_HIDDEN
;
4586 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context
*context
,
4587 struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
4588 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context
*context
,
4589 enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
4590 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context
*context
, struct wined3d_buffer
*buffer
,
4591 enum wined3d_format_id format_id
, unsigned int offset
) DECLSPEC_HIDDEN
;
4592 void wined3d_device_context_emit_set_light(struct wined3d_device_context
*context
,
4593 const struct wined3d_light_info
*light
) DECLSPEC_HIDDEN
;
4594 void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context
*context
, unsigned int idx
,
4595 BOOL enable
) DECLSPEC_HIDDEN
;
4596 void wined3d_device_context_emit_set_material(struct wined3d_device_context
*context
,
4597 const struct wined3d_material
*material
) DECLSPEC_HIDDEN
;
4598 void wined3d_device_context_emit_set_predication(struct wined3d_device_context
*context
,
4599 struct wined3d_query
*predicate
, BOOL value
) DECLSPEC_HIDDEN
;
4600 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context
*context
,
4601 struct wined3d_rasterizer_state
*rasterizer_state
) DECLSPEC_HIDDEN
;
4602 void wined3d_device_context_emit_set_render_state(struct wined3d_device_context
*context
,
4603 enum wined3d_render_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
4604 void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context
*context
, unsigned int start_idx
,
4605 unsigned int count
, struct wined3d_rendertarget_view
*const *views
) DECLSPEC_HIDDEN
;
4606 void wined3d_device_context_emit_set_samplers(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
4607 unsigned int start_idx
, unsigned int count
, struct wined3d_sampler
*const *samplers
) DECLSPEC_HIDDEN
;
4608 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context
*context
, unsigned int sampler_idx
,
4609 enum wined3d_sampler_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
4610 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context
*context
,
4611 unsigned int rect_count
, const RECT
*rects
) DECLSPEC_HIDDEN
;
4612 void wined3d_device_context_emit_set_shader(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
4613 struct wined3d_shader
*shader
) DECLSPEC_HIDDEN
;
4614 void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context
*context
,
4615 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
4616 struct wined3d_shader_resource_view
*const *views
) DECLSPEC_HIDDEN
;
4617 void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context
*context
,
4618 const struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
]) DECLSPEC_HIDDEN
;
4619 void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context
*context
,
4620 unsigned int start_idx
, unsigned int count
, const struct wined3d_stream_state
*streams
) DECLSPEC_HIDDEN
;
4621 void wined3d_device_context_emit_set_texture(struct wined3d_device_context
*context
, unsigned int stage
,
4622 struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4623 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context
*context
, unsigned int stage
,
4624 enum wined3d_texture_stage_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
4625 void wined3d_device_context_emit_set_transform(struct wined3d_device_context
*context
,
4626 enum wined3d_transform_state state
, const struct wined3d_matrix
*matrix
) DECLSPEC_HIDDEN
;
4627 void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context
*context
,
4628 enum wined3d_pipeline pipeline
, unsigned int start_idx
, unsigned int count
,
4629 struct wined3d_unordered_access_view
*const *views
, const unsigned int *initial_count
) DECLSPEC_HIDDEN
;
4630 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context
*context
,
4631 struct wined3d_vertex_declaration
*declaration
) DECLSPEC_HIDDEN
;
4632 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context
*context
, unsigned int viewport_count
,
4633 const struct wined3d_viewport
*viewports
) DECLSPEC_HIDDEN
;
4634 void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context
*context
,
4635 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, const struct wined3d_box
*box
,
4636 const void *data
, unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
4637 HRESULT
wined3d_device_context_emit_unmap(struct wined3d_device_context
*context
,
4638 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
4640 static inline void wined3d_resource_reference(struct wined3d_resource
*resource
)
4642 const struct wined3d_cs
*cs
= resource
->device
->cs
;
4643 resource
->access_time
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
4646 static inline BOOL
wined3d_ge_wrap(ULONG x
, ULONG y
)
4648 return (x
- y
) < UINT_MAX
/ 2;
4650 C_ASSERT(WINED3D_CS_QUEUE_SIZE
< UINT_MAX
/ 4);
4652 static inline void wined3d_resource_wait_idle(const struct wined3d_resource
*resource
)
4654 const struct wined3d_cs
*cs
= resource
->device
->cs
;
4655 ULONG access_time
, tail
, head
;
4657 if (!cs
->thread
|| cs
->thread_id
== GetCurrentThreadId())
4660 access_time
= resource
->access_time
;
4661 head
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
4663 /* The basic idea is that a resource is busy if tail < access_time <= head.
4664 * But we have to be careful about wrap-around of the head and tail. The
4665 * wined3d_ge_wrap function considers x >= y if x - y is smaller than half the
4666 * UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because
4667 * otherwise the queue memory is considered full and queue_require_space
4668 * stalls. Thus wined3d_ge_wrap(head, tail) is always true. The C_ASSERT above
4669 * ensures this in case we decide to grow the queue size in the future.
4671 * It is possible that a resource has not been used for a long time and is idle, but the head and
4672 * tail wrapped around in such a way that the previously set access time falls between head and tail.
4673 * In this case we will incorrectly wait for the resource. Because we use the entire 32 bits of the
4674 * counters and not just the bits needed to address the actual queue memory, this should happen rarely.
4675 * If it turns out to be a problem we can switch to 64 bit counters or attempt to somehow mark the
4676 * access time of resources invalid. CS packets are at least 4 byte aligned, so we could use the lower
4677 * 2 bits in access_time for such a marker.
4679 * Note that the access time is set before the command is submitted, so we have to wait until the
4680 * tail is bigger than access_time, not equal. */
4682 if (!wined3d_ge_wrap(head
, access_time
))
4687 tail
= *(volatile ULONG
*)&cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].tail
;
4688 if (head
== tail
) /* Queue empty. */
4691 if (!wined3d_ge_wrap(access_time
, tail
) && access_time
!= tail
)
4698 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
4699 * fixed function semantics as D3DCOLOR or FLOAT16 */
4700 enum wined3d_buffer_conversion_type
4707 struct wined3d_buffer
4709 struct wined3d_resource resource
;
4710 const struct wined3d_buffer_ops
*buffer_ops
;
4712 unsigned int structure_byte_stride
;
4716 struct wined3d_bo
*buffer_object
;
4717 struct wined3d_bo_user bo_user
;
4719 struct wined3d_range
*maps
;
4720 SIZE_T maps_size
, modified_areas
;
4722 /* conversion stuff */
4723 UINT decl_change_count
, full_conversion_count
;
4725 UINT stride
; /* 0 if no conversion */
4726 enum wined3d_buffer_conversion_type
*conversion_map
; /* NULL if no conversion */
4727 UINT conversion_stride
; /* 0 if no shifted conversion */
4730 static inline struct wined3d_buffer
*buffer_from_resource(struct wined3d_resource
*resource
)
4732 return CONTAINING_RECORD(resource
, struct wined3d_buffer
, resource
);
4735 void wined3d_buffer_cleanup(struct wined3d_buffer
*buffer
) DECLSPEC_HIDDEN
;
4736 void wined3d_buffer_copy(struct wined3d_buffer
*dst_buffer
, unsigned int dst_offset
,
4737 struct wined3d_buffer
*src_buffer
, unsigned int src_offset
, unsigned int size
) DECLSPEC_HIDDEN
;
4738 void wined3d_buffer_copy_bo_address(struct wined3d_buffer
*dst_buffer
, struct wined3d_context
*context
,
4739 unsigned int dst_offset
, const struct wined3d_const_bo_address
*src_addr
, unsigned int size
) DECLSPEC_HIDDEN
;
4740 DWORD
wined3d_buffer_get_memory(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
4741 struct wined3d_bo_address
*data
) DECLSPEC_HIDDEN
;
4742 void wined3d_buffer_invalidate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
4743 void wined3d_buffer_load(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
4744 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
4745 BOOL
wined3d_buffer_load_location(struct wined3d_buffer
*buffer
,
4746 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4747 BYTE
*wined3d_buffer_load_sysmem(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4748 BOOL
wined3d_buffer_prepare_location(struct wined3d_buffer
*buffer
,
4749 struct wined3d_context
*context
, unsigned int location
) DECLSPEC_HIDDEN
;
4750 void wined3d_buffer_update_sub_resource(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
4751 const struct upload_bo
*upload_bo
, unsigned int offset
, unsigned int size
) DECLSPEC_HIDDEN
;
4753 HRESULT
wined3d_buffer_no3d_init(struct wined3d_buffer
*buffer_no3d
, struct wined3d_device
*device
,
4754 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
4755 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4757 struct wined3d_buffer_gl
4759 struct wined3d_buffer b
;
4762 static inline struct wined3d_buffer_gl
*wined3d_buffer_gl(struct wined3d_buffer
*buffer
)
4764 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
4767 static inline const struct wined3d_buffer_gl
*wined3d_buffer_gl_const(const struct wined3d_buffer
*buffer
)
4769 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
4772 GLenum
wined3d_buffer_gl_binding_from_bind_flags(const struct wined3d_gl_info
*gl_info
,
4773 uint32_t bind_flags
) DECLSPEC_HIDDEN
;
4774 HRESULT
wined3d_buffer_gl_init(struct wined3d_buffer_gl
*buffer_gl
, struct wined3d_device
*device
,
4775 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
4776 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4778 struct wined3d_rendertarget_view
4782 struct wined3d_resource
*resource
;
4784 const struct wined3d_parent_ops
*parent_ops
;
4786 const struct wined3d_format
*format
;
4787 unsigned int format_attrs
;
4788 unsigned int format_caps
;
4789 unsigned int sub_resource_idx
;
4790 unsigned int layer_count
;
4793 unsigned int height
;
4795 struct wined3d_view_desc desc
;
4798 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
4799 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view
*view
,
4800 const struct wined3d_context
*context
, unsigned int *width
, unsigned int *height
) DECLSPEC_HIDDEN
;
4801 void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view
*view
,
4802 struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4803 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view
*view
,
4804 uint32_t location
) DECLSPEC_HIDDEN
;
4805 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view
*view
,
4806 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4807 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view
*view
,
4808 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4809 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view
*view
,
4810 uint32_t location
) DECLSPEC_HIDDEN
;
4811 DWORD
wined3d_rendertarget_view_get_locations(const struct wined3d_rendertarget_view
*view
)
4814 HRESULT
wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view
*view_no3d
,
4815 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4816 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4818 struct wined3d_rendertarget_view_gl
4820 struct wined3d_rendertarget_view v
;
4821 struct wined3d_gl_view gl_view
;
4824 static inline struct wined3d_rendertarget_view_gl
*wined3d_rendertarget_view_gl(
4825 struct wined3d_rendertarget_view
*view
)
4827 return CONTAINING_RECORD(view
, struct wined3d_rendertarget_view_gl
, v
);
4830 HRESULT
wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl
*view_gl
,
4831 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4832 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4834 struct wined3d_shader_resource_view
4838 struct wined3d_resource
*resource
;
4840 const struct wined3d_parent_ops
*parent_ops
;
4842 const struct wined3d_format
*format
;
4844 struct wined3d_view_desc desc
;
4847 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
4849 struct wined3d_shader_resource_view_gl
4851 struct wined3d_shader_resource_view v
;
4852 struct wined3d_bo_user bo_user
;
4853 struct wined3d_gl_view gl_view
;
4856 static inline struct wined3d_shader_resource_view_gl
*wined3d_shader_resource_view_gl(
4857 struct wined3d_shader_resource_view
*view
)
4859 return CONTAINING_RECORD(view
, struct wined3d_shader_resource_view_gl
, v
);
4862 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
*view_gl
, unsigned int unit
,
4863 struct wined3d_sampler_gl
*sampler_gl
, struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4864 void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl
*srv_gl
,
4865 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4866 HRESULT
wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl
*view_gl
,
4867 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4868 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4869 void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl
*srv_gl
,
4870 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4872 #include "wined3d_vk.h"
4874 struct wined3d_view_vk
4876 struct wined3d_bo_user bo_user
;
4879 VkBufferView vk_buffer_view
;
4880 VkDescriptorImageInfo vk_image_info
;
4882 uint64_t command_buffer_id
;
4885 struct wined3d_shader_resource_view_vk
4887 struct wined3d_shader_resource_view v
;
4888 struct wined3d_view_vk view_vk
;
4891 static inline struct wined3d_shader_resource_view_vk
*wined3d_shader_resource_view_vk(
4892 struct wined3d_shader_resource_view
*view
)
4894 return CONTAINING_RECORD(view
, struct wined3d_shader_resource_view_vk
, v
);
4897 static inline void wined3d_shader_resource_view_vk_barrier(struct wined3d_shader_resource_view_vk
*srv_vk
,
4898 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
)
4900 wined3d_resource_vk_barrier(srv_vk
->v
.resource
, context_vk
, bind_mask
);
4903 void wined3d_shader_resource_view_vk_generate_mipmap(struct wined3d_shader_resource_view_vk
*srv_vk
,
4904 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4905 HRESULT
wined3d_shader_resource_view_vk_init(struct wined3d_shader_resource_view_vk
*view_vk
,
4906 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4907 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4908 void wined3d_shader_resource_view_vk_update_buffer(struct wined3d_shader_resource_view_vk
*view_vk
,
4909 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4910 void wined3d_shader_resource_view_vk_update_layout(struct wined3d_shader_resource_view_vk
*srv_vk
,
4911 VkImageLayout layout
) DECLSPEC_HIDDEN
;
4913 struct wined3d_unordered_access_view
4917 struct wined3d_resource
*resource
;
4919 const struct wined3d_parent_ops
*parent_ops
;
4921 const struct wined3d_format
*format
;
4923 struct wined3d_view_desc desc
;
4924 struct wined3d_bo
*counter_bo
;
4927 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view
*view
) DECLSPEC_HIDDEN
;
4928 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view
*view
,
4929 struct wined3d_buffer
*buffer
, unsigned int offset
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4930 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view
*view
,
4931 uint32_t location
) DECLSPEC_HIDDEN
;
4932 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view
*view
,
4933 unsigned int value
) DECLSPEC_HIDDEN
;
4935 struct wined3d_unordered_access_view_gl
4937 struct wined3d_unordered_access_view v
;
4938 struct wined3d_bo_user bo_user
;
4939 struct wined3d_gl_view gl_view
;
4940 struct wined3d_bo_gl counter_bo
;
4943 static inline struct wined3d_unordered_access_view_gl
*wined3d_unordered_access_view_gl(
4944 struct wined3d_unordered_access_view
*view
)
4946 return CONTAINING_RECORD(view
, struct wined3d_unordered_access_view_gl
, v
);
4949 void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view_gl
*view_gl
,
4950 const struct wined3d_uvec4
*clear_value
, struct wined3d_context_gl
*context_gl
, bool fp
) DECLSPEC_HIDDEN
;
4951 HRESULT
wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl
*view_gl
,
4952 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4953 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4954 void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl
*uav_gl
,
4955 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4957 struct wined3d_unordered_access_view_vk
4959 struct wined3d_unordered_access_view v
;
4960 struct wined3d_view_vk view_vk
;
4962 VkBufferView vk_counter_view
;
4963 struct wined3d_bo_vk counter_bo
;
4966 static inline struct wined3d_unordered_access_view_vk
*wined3d_unordered_access_view_vk(
4967 struct wined3d_unordered_access_view
*view
)
4969 return CONTAINING_RECORD(view
, struct wined3d_unordered_access_view_vk
, v
);
4972 static inline void wined3d_unordered_access_view_vk_barrier(struct wined3d_unordered_access_view_vk
*uav_vk
,
4973 struct wined3d_context_vk
*context_vk
, uint32_t bind_mask
)
4975 wined3d_resource_vk_barrier(uav_vk
->v
.resource
, context_vk
, bind_mask
);
4978 void wined3d_unordered_access_view_vk_clear(struct wined3d_unordered_access_view_vk
*view_vk
,
4979 const struct wined3d_uvec4
*clear_value
, struct wined3d_context_vk
*context_vk
, bool fp
) DECLSPEC_HIDDEN
;
4980 HRESULT
wined3d_unordered_access_view_vk_init(struct wined3d_unordered_access_view_vk
*view_vk
,
4981 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4982 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4983 void wined3d_unordered_access_view_vk_update(struct wined3d_unordered_access_view_vk
*view_vk
,
4984 struct wined3d_context_vk
*context_vk
) DECLSPEC_HIDDEN
;
4986 struct wined3d_swapchain_state
4988 struct wined3d
*wined3d
;
4989 struct wined3d_swapchain_desc desc
;
4990 struct wined3d_swapchain_state_parent
*parent
;
4992 struct wined3d_display_mode original_mode
, d3d_mode
;
4993 RECT original_window_rect
;
4995 /* Window styles to restore when switching fullscreen mode. */
5001 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
5002 void wined3d_swapchain_state_register(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
5003 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state
*state
,
5004 HWND window
, const RECT
*window_rect
) DECLSPEC_HIDDEN
;
5005 HRESULT
wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
*state
,
5006 HWND window
, int x
, int y
, int width
, int height
) DECLSPEC_HIDDEN
;
5008 struct wined3d_swapchain_ops
5010 void (*swapchain_present
)(struct wined3d_swapchain
*swapchain
,
5011 const RECT
*src_rect
, const RECT
*dst_rect
, unsigned int swap_interval
, uint32_t flags
);
5012 void (*swapchain_frontbuffer_updated
)(struct wined3d_swapchain
*swapchain
);
5015 struct wined3d_swapchain
5019 const struct wined3d_parent_ops
*parent_ops
;
5020 const struct wined3d_swapchain_ops
*swapchain_ops
;
5021 struct wined3d_device
*device
;
5023 struct wined3d_texture
**back_buffers
;
5024 struct wined3d_texture
*front_buffer
;
5025 struct wined3d_gamma_ramp orig_gamma
;
5027 const struct wined3d_format
*ds_format
;
5028 struct wined3d_palette
*palette
;
5029 RECT front_buffer_update
;
5030 unsigned int swap_interval
;
5031 unsigned int max_frame_latency
;
5033 LONG prev_time
, frames
; /* Performance tracking */
5035 struct wined3d_swapchain_state state
;
5039 void wined3d_swapchain_activate(struct wined3d_swapchain
*swapchain
, BOOL activate
) DECLSPEC_HIDDEN
;
5040 void wined3d_swapchain_cleanup(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
5041 struct wined3d_output
* wined3d_swapchain_get_output(const struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
5042 void swapchain_update_draw_bindings(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
5043 void swapchain_set_max_frame_latency(struct wined3d_swapchain
*swapchain
,
5044 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
5046 HRESULT
wined3d_swapchain_no3d_init(struct wined3d_swapchain
*swapchain_no3d
,
5047 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
5048 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
5049 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5051 struct wined3d_swapchain_gl
5053 struct wined3d_swapchain s
;
5056 static inline struct wined3d_swapchain_gl
*wined3d_swapchain_gl(struct wined3d_swapchain
*swapchain
)
5058 return CONTAINING_RECORD(swapchain
, struct wined3d_swapchain_gl
, s
);
5061 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
5062 struct wined3d_context_gl
*wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
5063 HRESULT
wined3d_swapchain_gl_init(struct wined3d_swapchain_gl
*swapchain_gl
,
5064 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
5065 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
5066 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5068 struct wined3d_swapchain_vk
5070 struct wined3d_swapchain s
;
5072 VkSwapchainKHR vk_swapchain
;
5073 VkSurfaceKHR vk_surface
;
5077 VkSemaphore available
;
5078 VkSemaphore presentable
;
5079 uint64_t command_buffer_id
;
5081 unsigned int current
, image_count
;
5082 unsigned int width
, height
;
5085 static inline struct wined3d_swapchain_vk
*wined3d_swapchain_vk(struct wined3d_swapchain
*swapchain
)
5087 return CONTAINING_RECORD(swapchain
, struct wined3d_swapchain_vk
, s
);
5090 void wined3d_swapchain_vk_cleanup(struct wined3d_swapchain_vk
*swapchain_vk
) DECLSPEC_HIDDEN
;
5091 HRESULT
wined3d_swapchain_vk_init(struct wined3d_swapchain_vk
*swapchain_vk
,
5092 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
5093 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
5094 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
5096 /*****************************************************************************
5097 * Utility function prototypes
5100 /* Trace routines */
5101 const char *debug_bo_address(const struct wined3d_bo_address
*address
) DECLSPEC_HIDDEN
;
5102 const char *debug_box(const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
5103 const char *debug_color(const struct wined3d_color
*color
) DECLSPEC_HIDDEN
;
5104 const char *debug_const_bo_address(const struct wined3d_const_bo_address
*address
) DECLSPEC_HIDDEN
;
5105 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
) DECLSPEC_HIDDEN
;
5106 const char *debug_d3dformat(enum wined3d_format_id format_id
) DECLSPEC_HIDDEN
;
5107 const char *debug_d3ddevicetype(enum wined3d_device_type device_type
) DECLSPEC_HIDDEN
;
5108 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type
) DECLSPEC_HIDDEN
;
5109 const char *debug_d3dusage(uint32_t usage
) DECLSPEC_HIDDEN
;
5110 const char *debug_d3ddeclmethod(enum wined3d_decl_method method
) DECLSPEC_HIDDEN
;
5111 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
5112 const char *debug_d3dinput_classification(enum wined3d_input_classification classification
) DECLSPEC_HIDDEN
;
5113 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type
) DECLSPEC_HIDDEN
;
5114 const char *debug_d3drenderstate(enum wined3d_render_state state
) DECLSPEC_HIDDEN
;
5115 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state
) DECLSPEC_HIDDEN
;
5116 const char *debug_d3dstate(uint32_t state
) DECLSPEC_HIDDEN
;
5117 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type
) DECLSPEC_HIDDEN
;
5118 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state
) DECLSPEC_HIDDEN
;
5119 const char *debug_d3dtop(enum wined3d_texture_op d3dtop
) DECLSPEC_HIDDEN
;
5120 const char *debug_d3dtstype(enum wined3d_transform_state tstype
) DECLSPEC_HIDDEN
;
5121 const char *debug_fboattachment(GLenum attachment
) DECLSPEC_HIDDEN
;
5122 const char *debug_fbostatus(GLenum status
) DECLSPEC_HIDDEN
;
5123 const char *debug_glerror(GLenum error
) DECLSPEC_HIDDEN
;
5124 const char *debug_ivec4(const struct wined3d_ivec4
*v
) DECLSPEC_HIDDEN
;
5125 const char *debug_uvec4(const struct wined3d_uvec4
*v
) DECLSPEC_HIDDEN
;
5126 const char *debug_shader_type(enum wined3d_shader_type shader_type
) DECLSPEC_HIDDEN
;
5127 const char *debug_vec4(const struct wined3d_vec4
*v
) DECLSPEC_HIDDEN
;
5128 const char *wined3d_debug_feature_level(enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
5129 void dump_color_fixup_desc(struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
5131 BOOL
is_invalid_op(const struct wined3d_state
*state
, int stage
,
5132 enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
) DECLSPEC_HIDDEN
;
5133 void set_tex_op_nvrc(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
5134 BOOL is_alpha
, int stage
, enum wined3d_texture_op op
, uint32_t arg1
, uint32_t arg2
, uint32_t arg3
,
5135 INT texture_idx
, DWORD dst
) DECLSPEC_HIDDEN
;
5136 void texture_activate_dimensions(struct wined3d_texture
*texture
,
5137 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
5138 void sampler_texdim(struct wined3d_context
*context
,
5139 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5140 void tex_alphaop(struct wined3d_context
*context
,
5141 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5142 void apply_pixelshader(struct wined3d_context
*context
,
5143 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5144 void state_alpha_test(struct wined3d_context
*context
,
5145 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5146 void state_fogcolor(struct wined3d_context
*context
,
5147 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5148 void state_fogdensity(struct wined3d_context
*context
,
5149 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5150 void state_fogstartend(struct wined3d_context
*context
,
5151 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5152 void state_fog_fragpart(struct wined3d_context
*context
,
5153 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5154 void state_nop(struct wined3d_context
*context
,
5155 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5156 void state_srgbwrite(struct wined3d_context
*context
,
5157 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5159 void state_clipping(struct wined3d_context
*context
,
5160 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5161 void clipplane(struct wined3d_context
*context
,
5162 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5163 void state_pointsprite_w(struct wined3d_context
*context
,
5164 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5165 void state_pointsprite(struct wined3d_context
*context
,
5166 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5167 void state_shademode(struct wined3d_context
*context
,
5168 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
5171 void multiply_matrix(struct wined3d_matrix
*dest
, const struct wined3d_matrix
*src1
,
5172 const struct wined3d_matrix
*src2
) DECLSPEC_HIDDEN
;
5174 void wined3d_release_dc(HWND window
, HDC dc
) DECLSPEC_HIDDEN
;
5176 struct wined3d_shader_lconst
5180 unsigned int value
[4];
5183 struct wined3d_shader_limits
5185 unsigned int sampler
;
5186 unsigned int constant_int
;
5187 unsigned int constant_float
;
5188 unsigned int constant_bool
;
5189 unsigned int packed_output
;
5190 unsigned int packed_input
;
5193 #define wined3d_lock_init(lock, name) wined3d_lock_init_(lock, __FILE__ ": " name)
5194 static inline void wined3d_lock_init_(CRITICAL_SECTION
*lock
, const char *name
)
5196 InitializeCriticalSection(lock
);
5197 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
5198 lock
->DebugInfo
->Spare
[0] = (DWORD_PTR
)name
;
5201 static inline void wined3d_lock_cleanup(CRITICAL_SECTION
*lock
)
5203 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
5204 lock
->DebugInfo
->Spare
[0] = 0;
5205 DeleteCriticalSection(lock
);
5209 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
5211 #define PRINTF_ATTR(fmt,args)
5214 struct wined3d_string_buffer_list
5219 struct wined3d_string_buffer
*string_buffer_get(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
5220 void string_buffer_sprintf(struct wined3d_string_buffer
*buffer
, const char *format
, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN
;
5221 void string_buffer_release(struct wined3d_string_buffer_list
*list
, struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
5222 void string_buffer_list_init(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
5223 void string_buffer_list_cleanup(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
5225 int shader_addline(struct wined3d_string_buffer
*buffer
, const char *fmt
, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN
;
5226 BOOL
string_buffer_resize(struct wined3d_string_buffer
*buffer
, int rc
) DECLSPEC_HIDDEN
;
5227 int shader_vaddline(struct wined3d_string_buffer
*buffer
, const char *fmt
, va_list args
) DECLSPEC_HIDDEN
;
5229 struct wined3d_shader_phase
5233 unsigned int instance_count
;
5234 unsigned int temporary_count
;
5237 struct wined3d_vertex_shader
5239 struct wined3d_shader_attribute attributes
[MAX_ATTRIBS
];
5242 struct wined3d_hull_shader
5246 struct wined3d_shader_phase
*control_point
;
5247 unsigned int fork_count
;
5248 unsigned int join_count
;
5249 struct wined3d_shader_phase
*fork
;
5251 struct wined3d_shader_phase
*join
;
5254 unsigned int output_vertex_count
;
5255 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
5256 enum wined3d_tessellator_partitioning tessellator_partitioning
;
5259 struct wined3d_domain_shader
5261 enum wined3d_tessellator_domain tessellator_domain
;
5264 struct wined3d_geometry_shader
5266 enum wined3d_primitive_type input_type
;
5267 enum wined3d_primitive_type output_type
;
5268 unsigned int vertices_out
;
5269 unsigned int instance_count
;
5271 const struct wined3d_stream_output_desc
*so_desc
;
5274 struct wined3d_pixel_shader
5276 /* Pixel shader input semantics */
5277 unsigned int input_reg_map
[MAX_REG_INPUT
];
5278 DWORD input_reg_used
; /* MAX_REG_INPUT, 32 */
5279 unsigned int declared_in_count
;
5281 /* Some information about the shader behavior */
5283 unsigned int color0_reg
;
5285 BOOL force_early_depth_stencil
;
5286 enum wined3d_shader_register_type depth_output
;
5287 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
5290 struct wined3d_compute_shader
5292 struct wined3d_shader_thread_group_size thread_group_size
;
5295 struct wined3d_shader
5298 const struct wined3d_shader_limits
*limits
;
5299 const DWORD
*function
;
5300 unsigned int functionLength
;
5302 unsigned int byte_code_size
;
5303 BOOL load_local_constsF
;
5304 const struct wined3d_shader_frontend
*frontend
;
5305 void *frontend_data
;
5309 const struct wined3d_parent_ops
*parent_ops
;
5311 /* Programs this shader is linked with */
5312 struct list linked_programs
;
5314 /* Immediate constants (override global ones) */
5315 struct list constantsB
;
5316 struct list constantsF
;
5317 struct list constantsI
;
5318 struct wined3d_shader_reg_maps reg_maps
;
5319 BOOL lconst_inf_or_nan
;
5321 struct wined3d_shader_signature input_signature
;
5322 struct wined3d_shader_signature output_signature
;
5323 struct wined3d_shader_signature patch_constant_signature
;
5325 /* Pointer to the parent device */
5326 struct wined3d_device
*device
;
5327 struct list shader_list_entry
;
5331 struct wined3d_vertex_shader vs
;
5332 struct wined3d_hull_shader hs
;
5333 struct wined3d_domain_shader ds
;
5334 struct wined3d_geometry_shader gs
;
5335 struct wined3d_pixel_shader ps
;
5336 struct wined3d_compute_shader cs
;
5340 enum wined3d_shader_resource_type
pixelshader_get_resource_type(const struct wined3d_shader_reg_maps
*reg_maps
,
5341 unsigned int resource_idx
, DWORD tex_types
) DECLSPEC_HIDDEN
;
5342 void find_ps_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
5343 BOOL position_transformed
, struct ps_compile_args
*args
,
5344 const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
5346 bool vshader_get_input(const struct wined3d_shader
*shader
,
5347 uint8_t usage_req
, uint8_t usage_idx_req
, unsigned int *regnum
) DECLSPEC_HIDDEN
;
5348 void find_vs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
5349 struct vs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
5351 void find_ds_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
5352 struct ds_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
5354 void find_gs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
5355 struct gs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
5357 void string_buffer_clear(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
5358 BOOL
string_buffer_init(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
5359 void string_buffer_free(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
5360 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps
*reg_maps
,
5361 unsigned int max
) DECLSPEC_HIDDEN
;
5362 HRESULT
shader_generate_code(const struct wined3d_shader
*shader
, struct wined3d_string_buffer
*buffer
,
5363 const struct wined3d_shader_reg_maps
*reg_maps
, void *backend_ctx
,
5364 const DWORD
*start
, const DWORD
*end
) DECLSPEC_HIDDEN
;
5365 BOOL
shader_match_semantic(const char *semantic_name
, enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
5367 static inline BOOL
shader_is_scalar(const struct wined3d_shader_register
*reg
)
5371 case WINED3DSPR_RASTOUT
:
5373 if (reg
->idx
[0].offset
)
5378 case WINED3DSPR_CONSTBOOL
: /* b# */
5379 case WINED3DSPR_DEPTHOUT
: /* oDepth */
5380 case WINED3DSPR_DEPTHOUTGE
:
5381 case WINED3DSPR_DEPTHOUTLE
:
5382 case WINED3DSPR_LOOP
: /* aL */
5383 case WINED3DSPR_OUTPOINTID
:
5384 case WINED3DSPR_PREDICATE
: /* p0 */
5385 case WINED3DSPR_PRIMID
: /* primID */
5386 case WINED3DSPR_COVERAGE
: /* vCoverage */
5387 case WINED3DSPR_SAMPLEMASK
: /* oMask */
5390 case WINED3DSPR_MISCTYPE
:
5391 switch (reg
->idx
[0].offset
)
5401 case WINED3DSPR_IMMCONST
:
5402 return reg
->immconst_type
== WINED3D_IMMCONST_SCALAR
;
5409 static inline void shader_get_position_fixup(const struct wined3d_context
*context
,
5410 const struct wined3d_state
*state
, unsigned int fixup_count
, float *position_fixup
)
5412 float center_offset
, x
= 0.0f
, y
= 0.0f
;
5415 /* See get_projection_matrix() in utils.c for a discussion of the position fixup.
5416 * This function here also applies to d3d10+ which does not need adjustment for
5417 * integer pixel centers, but it may need the filling convention offset. */
5418 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_PIXEL_CENTER_INTEGER
)
5419 center_offset
= 1.0f
;
5421 center_offset
= 0.0f
;
5423 center_offset
+= context
->d3d_info
->filling_convention_offset
;
5425 for (i
= 0; i
< fixup_count
; ++i
)
5427 position_fixup
[4 * i
] = 1.0f
;
5428 position_fixup
[4 * i
+ 1] = 1.0f
;
5429 if (!context
->d3d_info
->subpixel_viewport
)
5432 x
= modf(state
->viewports
[i
].x
, &dummy
) * 2.0f
;
5433 y
= modf(state
->viewports
[i
].y
, &dummy
) * 2.0f
;
5435 position_fixup
[4 * i
+ 2] = (center_offset
+ x
) / state
->viewports
[i
].width
;
5436 position_fixup
[4 * i
+ 3] = -(center_offset
+ y
) / state
->viewports
[i
].height
;
5438 if (context
->render_offscreen
)
5440 position_fixup
[4 * i
+ 1] *= -1.0f
;
5441 position_fixup
[4 * i
+ 3] *= -1.0f
;
5446 static inline BOOL
shader_constant_is_local(const struct wined3d_shader
*shader
, DWORD reg
)
5448 struct wined3d_shader_lconst
*lconst
;
5450 if (shader
->load_local_constsF
)
5453 LIST_FOR_EACH_ENTRY(lconst
, &shader
->constantsF
, struct wined3d_shader_lconst
, entry
)
5455 if (lconst
->idx
== reg
)
5462 void get_identity_matrix(struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5463 void get_modelview_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5464 unsigned int index
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5465 void get_projection_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5466 struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5467 void get_texture_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5468 unsigned int tex
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5469 void get_pointsize_minmax(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5470 float *out_min
, float *out_max
) DECLSPEC_HIDDEN
;
5471 void get_pointsize(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5472 float *out_pointsize
, float *out_att
) DECLSPEC_HIDDEN
;
5473 void get_fog_start_end(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5474 float *start
, float *end
) DECLSPEC_HIDDEN
;
5476 /* Using additional shader constants (uniforms in GLSL / program environment
5477 * or local parameters in ARB) is costly:
5478 * ARB only knows float4 parameters and GLSL compiler are not really smart
5479 * when it comes to efficiently pack float2 uniforms, so no space is wasted
5480 * (in fact most compilers map a float2 to a full float4 uniform).
5482 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
5483 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
5484 * into a single shader constant (uniform / program parameter).
5486 * This structure is shared between the GLSL and the ARB backend.*/
5487 struct ps_np2fixup_info
{
5488 unsigned char idx
[WINED3D_MAX_FRAGMENT_SAMPLERS
]; /* indices to the real constant */
5489 WORD active
; /* bitfield indicating if we can apply the fixup */
5493 void print_glsl_info_log(const struct wined3d_gl_info
*gl_info
, GLuint id
, BOOL program
) DECLSPEC_HIDDEN
;
5494 void shader_glsl_validate_link(const struct wined3d_gl_info
*gl_info
, GLuint program
) DECLSPEC_HIDDEN
;
5496 struct wined3d_palette
5499 struct wined3d_device
*device
;
5502 RGBQUAD colors
[256];
5506 /* DirectDraw utility functions */
5507 extern enum wined3d_format_id
pixelformat_for_depth(DWORD depth
) DECLSPEC_HIDDEN
;
5509 /*****************************************************************************
5510 * Pixel format management
5513 /* Pixel format attributes */
5514 #define WINED3D_FORMAT_ATTR_FLOAT 0x00000001
5515 #define WINED3D_FORMAT_ATTR_INTEGER 0x00000002
5516 #define WINED3D_FORMAT_ATTR_NORMALISED 0x00000004
5517 #define WINED3D_FORMAT_ATTR_BUMPMAP 0x00000008
5518 #define WINED3D_FORMAT_ATTR_EXTENSION 0x00000010
5519 #define WINED3D_FORMAT_ATTR_BLOCKS 0x00000020
5520 #define WINED3D_FORMAT_ATTR_BLOCKS_NO_VERIFY 0x00000040
5521 #define WINED3D_FORMAT_ATTR_COMPRESSED 0x00000080
5522 #define WINED3D_FORMAT_ATTR_BROKEN_PITCH 0x00000100
5523 #define WINED3D_FORMAT_ATTR_HEIGHT_SCALE 0x00000200
5524 #define WINED3D_FORMAT_ATTR_MAPPABLE 0x00000400
5525 #define WINED3D_FORMAT_ATTR_CAST_TO_BLOCK 0x00000800
5527 /* Pixel format capabilities */
5528 #define WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING 0x00000001
5529 #define WINED3D_FORMAT_CAP_FILTERING 0x00000002
5530 #define WINED3D_FORMAT_CAP_UNORDERED_ACCESS 0x00000004
5531 #define WINED3D_FORMAT_CAP_DEPTH_STENCIL 0x00000008
5532 #define WINED3D_FORMAT_CAP_RENDERTARGET 0x00000010
5533 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE 0x00000020
5534 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE_SRGB 0x00000040
5535 #define WINED3D_FORMAT_CAP_DECOMPRESS 0x00000080
5536 #define WINED3D_FORMAT_CAP_SRGB_READ 0x00000100
5537 #define WINED3D_FORMAT_CAP_SRGB_WRITE 0x00000200
5538 #define WINED3D_FORMAT_CAP_VTF 0x00000400
5539 #define WINED3D_FORMAT_CAP_SHADOW 0x00000800
5540 #define WINED3D_FORMAT_CAP_TEXTURE 0x00001000
5541 #define WINED3D_FORMAT_CAP_GEN_MIPMAP 0x00002000
5542 #define WINED3D_FORMAT_CAP_VERTEX_ATTRIBUTE 0x00004000
5543 #define WINED3D_FORMAT_CAP_BLIT 0x00008000
5544 #define WINED3D_FORMAT_CAP_INDEX_BUFFER 0x00010000
5546 struct wined3d_rational
5552 struct wined3d_color_key_conversion
5554 enum wined3d_format_id dst_format
;
5555 void (*convert
)(const BYTE
*src
, unsigned int src_pitch
, BYTE
*dst
, unsigned int dst_pitch
,
5556 unsigned int width
, unsigned int height
, const struct wined3d_color_key
*colour_key
);
5559 enum wined3d_channel_type
5561 WINED3D_CHANNEL_TYPE_NONE
,
5562 WINED3D_CHANNEL_TYPE_UNORM
,
5563 WINED3D_CHANNEL_TYPE_SNORM
,
5564 WINED3D_CHANNEL_TYPE_UINT
,
5565 WINED3D_CHANNEL_TYPE_SINT
,
5566 WINED3D_CHANNEL_TYPE_FLOAT
,
5567 WINED3D_CHANNEL_TYPE_DEPTH
,
5568 WINED3D_CHANNEL_TYPE_STENCIL
,
5569 WINED3D_CHANNEL_TYPE_UNUSED
,
5572 struct wined3d_format
5574 enum wined3d_format_id id
;
5576 D3DDDIFORMAT ddi_format
;
5577 unsigned int component_count
;
5592 UINT block_byte_count
;
5594 enum wined3d_ffp_emit_idx emit_idx
;
5596 UINT conv_byte_count
;
5597 DWORD multisample_types
;
5599 unsigned int caps
[WINED3D_GL_RES_TYPE_COUNT
];
5600 float depth_bias_scale
;
5601 struct wined3d_rational height_scale
;
5602 struct color_fixup_desc color_fixup
;
5603 void (*upload
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
5604 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
5605 unsigned int width
, unsigned int height
, unsigned int depth
);
5606 void (*download
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
5607 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
5608 unsigned int width
, unsigned int height
, unsigned int depth
);
5609 void (*decompress
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
5610 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
5611 unsigned int width
, unsigned int height
, unsigned int depth
);
5613 enum wined3d_format_id typeless_id
;
5616 const struct wined3d_format
*wined3d_get_format(const struct wined3d_adapter
*adapter
,
5617 enum wined3d_format_id format_id
, unsigned int bind_flags
) DECLSPEC_HIDDEN
;
5618 enum wined3d_format_id
wined3d_get_typed_format_id(const struct wined3d_adapter
*adapter
,
5619 const struct wined3d_format
*format
, enum wined3d_channel_type channel_type
) DECLSPEC_HIDDEN
;
5620 void wined3d_format_calculate_pitch(const struct wined3d_format
*format
, unsigned int alignment
,
5621 unsigned int width
, unsigned int height
, unsigned int *row_pitch
, unsigned int *slice_pitch
) DECLSPEC_HIDDEN
;
5622 UINT
wined3d_format_calculate_size(const struct wined3d_format
*format
,
5623 UINT alignment
, UINT width
, UINT height
, UINT depth
) DECLSPEC_HIDDEN
;
5624 void wined3d_format_colour_to_vk(const struct wined3d_format
*format
, const struct wined3d_color
*c
,
5625 VkClearColorValue
*retval
) DECLSPEC_HIDDEN
;
5626 void wined3d_format_convert_from_float(const struct wined3d_format
*format
,
5627 const struct wined3d_color
*color
, void *ret
) DECLSPEC_HIDDEN
;
5628 void wined3d_format_copy_data(const struct wined3d_format
*format
, const uint8_t *src
,
5629 unsigned int src_row_pitch
, unsigned int src_slice_pitch
, uint8_t *dst
, unsigned int dst_row_pitch
,
5630 unsigned int dst_slice_pitch
, unsigned int w
, unsigned int h
, unsigned int d
) DECLSPEC_HIDDEN
;
5631 void wined3d_format_get_float_color_key(const struct wined3d_format
*format
,
5632 const struct wined3d_color_key
*key
, struct wined3d_color
*float_colors
) DECLSPEC_HIDDEN
;
5633 BOOL
wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id
,
5634 enum wined3d_format_id view_format_id
) DECLSPEC_HIDDEN
;
5635 const struct wined3d_color_key_conversion
* wined3d_format_get_color_key_conversion(
5636 const struct wined3d_texture
*texture
, BOOL need_alpha_ck
) DECLSPEC_HIDDEN
;
5637 uint32_t wined3d_format_pack(const struct wined3d_format
*format
, const struct wined3d_uvec4
*value
) DECLSPEC_HIDDEN
;
5638 BOOL
wined3d_formats_are_srgb_variants(enum wined3d_format_id format1
,
5639 enum wined3d_format_id format2
) DECLSPEC_HIDDEN
;
5641 struct wined3d_format_gl
5643 struct wined3d_format f
;
5649 GLint srgb_internal
;
5657 static inline const struct wined3d_format_gl
*wined3d_format_gl(const struct wined3d_format
*format
)
5659 return CONTAINING_RECORD(format
, struct wined3d_format_gl
, f
);
5662 struct wined3d_format_vk
5664 struct wined3d_format f
;
5669 static inline const struct wined3d_format_vk
*wined3d_format_vk(const struct wined3d_format
*format
)
5671 return CONTAINING_RECORD(format
, struct wined3d_format_vk
, f
);
5674 BOOL
wined3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
) DECLSPEC_HIDDEN
;
5676 static inline BOOL
wined3d_format_is_typeless(const struct wined3d_format
*format
)
5678 return format
->id
== format
->typeless_id
&& format
->id
!= WINED3DFMT_UNKNOWN
;
5681 static inline BOOL
use_vs(const struct wined3d_state
*state
)
5683 /* Check state->vertex_declaration to allow this to be used before the
5684 * stream info is validated, for example in device_update_tex_unit_map(). */
5685 return state
->shader
[WINED3D_SHADER_TYPE_VERTEX
]
5686 && (!state
->vertex_declaration
|| !state
->vertex_declaration
->position_transformed
);
5689 static inline BOOL
use_ps(const struct wined3d_state
*state
)
5691 return !!state
->shader
[WINED3D_SHADER_TYPE_PIXEL
];
5694 static inline BOOL
use_transform_feedback(const struct wined3d_state
*state
)
5696 const struct wined3d_shader
*shader
;
5698 if (!(shader
= state
->shader
[WINED3D_SHADER_TYPE_GEOMETRY
]))
5700 return !!shader
->u
.gs
.so_desc
;
5703 static inline void context_apply_state(struct wined3d_context
*context
,
5704 const struct wined3d_state
*state
, DWORD state_id
)
5706 const struct wined3d_state_entry
*state_table
= context
->state_table
;
5707 unsigned int rep
= state_table
[state_id
].representative
;
5708 state_table
[rep
].apply(context
, state
, rep
);
5711 static inline BOOL
is_srgb_enabled(const uint32_t *sampler_states
)
5713 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
5714 * the behaviour of the AMD Windows driver.
5716 * Might & Magic: Heroes VI - Shades of Darkness sets
5717 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
5718 * pointer—presumably by accident—and expects sRGB decoding to be
5720 return sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
] & 0x1;
5723 static inline BOOL
needs_separate_srgb_gl_texture(const struct wined3d_context
*context
,
5724 const struct wined3d_texture
*texture
)
5726 if (!(context
->d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
))
5729 if (!context
->d3d_info
->srgb_read_control
5730 && (texture
->resource
.bind_flags
& WINED3D_BIND_SHADER_RESOURCE
)
5731 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_READ
))
5734 if (!context
->d3d_info
->srgb_write_control
5735 && (texture
->resource
.bind_flags
& WINED3D_BIND_RENDER_TARGET
)
5736 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
))
5742 static inline BOOL
needs_srgb_write(const struct wined3d_d3d_info
*d3d_info
,
5743 const struct wined3d_state
*state
, const struct wined3d_fb_state
*fb
)
5745 return (!(d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
)
5746 || state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
])
5747 && fb
->render_targets
[0] && fb
->render_targets
[0]->format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
;
5750 static inline GLuint
wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl
*texture_gl
,
5751 const struct wined3d_context
*context
, BOOL srgb
)
5753 return srgb
&& needs_separate_srgb_gl_texture(context
, &texture_gl
->t
)
5754 ? texture_gl
->texture_srgb
.name
: texture_gl
->texture_rgb
.name
;
5757 static inline GLuint
wined3d_gl_get_internal_format(struct wined3d_resource
*resource
,
5758 const struct wined3d_format_gl
*format_gl
, bool srgb
)
5761 return format_gl
->srgb_internal
;
5762 else if (resource
->bind_flags
& WINED3D_BIND_RENDER_TARGET
&& wined3d_resource_is_offscreen(resource
))
5763 return format_gl
->rt_internal
;
5765 return format_gl
->internal
;
5768 static inline BOOL
can_use_texture_swizzle(const struct wined3d_d3d_info
*d3d_info
, const struct wined3d_format
*format
)
5770 return d3d_info
->texture_swizzle
&& !is_complex_fixup(format
->color_fixup
) && !is_scaling_fixup(format
->color_fixup
);
5773 static inline BOOL
is_rasterization_disabled(const struct wined3d_shader
*geometry_shader
)
5775 return geometry_shader
&& geometry_shader
->u
.gs
.so_desc
5776 && geometry_shader
->u
.gs
.so_desc
->rasterizer_stream_idx
== WINED3D_NO_RASTERIZER_STREAM
;
5779 static inline uint32_t wined3d_mask_from_size(unsigned int size
)
5781 return size
< 32 ? (1u << size
) - 1 : ~0u;
5784 static inline DWORD
wined3d_extract_bits(const uint32_t *bitstream
,
5785 unsigned int offset
, unsigned int count
)
5787 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
5788 const unsigned int idx
= offset
/ word_bit_count
;
5789 const unsigned int shift
= offset
% word_bit_count
;
5790 DWORD mask
= (1u << count
) - 1;
5793 ret
= (bitstream
[idx
] >> shift
) & mask
;
5794 if (shift
+ count
> word_bit_count
)
5796 const unsigned int extracted_bit_count
= word_bit_count
- shift
;
5797 const unsigned int remaining_bit_count
= count
- extracted_bit_count
;
5798 mask
= (1u << remaining_bit_count
) - 1;
5799 ret
|= (bitstream
[idx
+ 1] & mask
) << extracted_bit_count
;
5804 static inline void wined3d_insert_bits(uint32_t *bitstream
,
5805 unsigned int offset
, unsigned int count
, DWORD bits
)
5807 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
5808 const unsigned int idx
= offset
/ word_bit_count
;
5809 const unsigned int shift
= offset
% word_bit_count
;
5810 DWORD mask
= (1u << count
) - 1;
5812 bitstream
[idx
] |= (bits
& mask
) << shift
;
5813 if (shift
+ count
> word_bit_count
)
5815 const unsigned int inserted_bit_count
= word_bit_count
- shift
;
5816 const unsigned int remaining_bit_count
= count
- inserted_bit_count
;
5817 mask
= (1u << remaining_bit_count
) - 1;
5818 bitstream
[idx
+ 1] |= (bits
>> inserted_bit_count
) & mask
;
5822 static inline void wined3d_from_cs(const struct wined3d_cs
*cs
)
5825 assert(cs
->thread_id
== GetCurrentThreadId());
5828 static inline void wined3d_not_from_cs(const struct wined3d_cs
*cs
)
5830 assert(cs
->thread_id
!= GetCurrentThreadId());
5833 static inline enum wined3d_material_color_source
validate_material_colour_source(WORD use_map
,
5834 enum wined3d_material_color_source source
)
5836 if (source
== WINED3D_MCS_COLOR1
&& use_map
& (1u << WINED3D_FFP_DIFFUSE
))
5838 if (source
== WINED3D_MCS_COLOR2
&& use_map
& (1u << WINED3D_FFP_SPECULAR
))
5840 return WINED3D_MCS_MATERIAL
;
5843 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source
*diffuse
,
5844 enum wined3d_material_color_source
*emissive
, enum wined3d_material_color_source
*ambient
,
5845 enum wined3d_material_color_source
*specular
, const struct wined3d_state
*state
,
5846 const struct wined3d_stream_info
*si
)
5848 if (!state
->render_states
[WINED3D_RS_LIGHTING
])
5850 *diffuse
= WINED3D_MCS_COLOR1
;
5851 *specular
= WINED3D_MCS_COLOR2
;
5852 *emissive
= *ambient
= WINED3D_MCS_MATERIAL
;
5857 if (!state
->render_states
[WINED3D_RS_COLORVERTEX
])
5859 *diffuse
= *emissive
= *ambient
= *specular
= WINED3D_MCS_MATERIAL
;
5864 *diffuse
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
]);
5865 *emissive
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
]);
5866 *ambient
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
]);
5867 *specular
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
5870 static inline void wined3d_vec4_transform(struct wined3d_vec4
*dst
,
5871 const struct wined3d_vec4
*v
, const struct wined3d_matrix
*m
)
5873 struct wined3d_vec4 tmp
;
5875 tmp
.x
= v
->x
* m
->_11
+ v
->y
* m
->_21
+ v
->z
* m
->_31
+ v
->w
* m
->_41
;
5876 tmp
.y
= v
->x
* m
->_12
+ v
->y
* m
->_22
+ v
->z
* m
->_32
+ v
->w
* m
->_42
;
5877 tmp
.z
= v
->x
* m
->_13
+ v
->y
* m
->_23
+ v
->z
* m
->_33
+ v
->w
* m
->_43
;
5878 tmp
.w
= v
->x
* m
->_14
+ v
->y
* m
->_24
+ v
->z
* m
->_34
+ v
->w
* m
->_44
;
5883 BOOL
invert_matrix(struct wined3d_matrix
*out
, const struct wined3d_matrix
*m
) DECLSPEC_HIDDEN
;
5885 void compute_normal_matrix(float *normal_matrix
, BOOL legacy_lighting
,
5886 const struct wined3d_matrix
*modelview
) DECLSPEC_HIDDEN
;
5888 static inline struct wined3d_context
*context_acquire(struct wined3d_device
*device
,
5889 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
5891 wined3d_from_cs(device
->cs
);
5893 return device
->adapter
->adapter_ops
->adapter_acquire_context(device
, texture
, sub_resource_idx
);
5896 static inline void context_release(struct wined3d_context
*context
)
5898 context
->device
->adapter
->adapter_ops
->adapter_release_context(context
);
5901 static inline float wined3d_get_float_state(const struct wined3d_state
*state
, enum wined3d_render_state rs
)
5910 tmpvalue
.d
= state
->render_states
[rs
];
5914 static inline void *wined3d_context_map_bo_address(struct wined3d_context
*context
,
5915 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
5917 return context
->device
->adapter
->adapter_ops
->adapter_map_bo_address(context
, data
, size
, map_flags
);
5920 static inline void wined3d_context_unmap_bo_address(struct wined3d_context
*context
,
5921 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
5923 context
->device
->adapter
->adapter_ops
->adapter_unmap_bo_address(context
, data
, range_count
, ranges
);
5926 static inline void wined3d_context_copy_bo_address(struct wined3d_context
*context
,
5927 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
5928 unsigned int range_count
, const struct wined3d_range
*ranges
)
5930 context
->device
->adapter
->adapter_ops
->adapter_copy_bo_address(context
, dst
, src
, range_count
, ranges
);
5933 static inline void wined3d_context_flush_bo_address(struct wined3d_context
*context
,
5934 const struct wined3d_const_bo_address
*data
, size_t size
)
5936 context
->device
->adapter
->adapter_ops
->adapter_flush_bo_address(context
, data
, size
);
5939 static inline void wined3d_context_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
5941 context
->device
->adapter
->adapter_ops
->adapter_destroy_bo(context
, bo
);
5944 static inline void wined3d_context_vk_reference_bo(const struct wined3d_context_vk
*context_vk
,
5945 struct wined3d_bo_vk
*bo
)
5947 bo
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
5950 static inline void wined3d_context_vk_reference_image(const struct wined3d_context_vk
*context_vk
,
5951 struct wined3d_image_vk
*image
)
5953 image
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
5956 static inline void wined3d_context_vk_reference_texture(const struct wined3d_context_vk
*context_vk
,
5957 struct wined3d_texture_vk
*texture_vk
)
5959 wined3d_context_vk_reference_image(context_vk
, &texture_vk
->image
);
5962 static inline void wined3d_context_vk_reference_resource(const struct wined3d_context_vk
*context_vk
,
5963 struct wined3d_resource
*resource
)
5965 if (resource
->type
== WINED3D_RTYPE_BUFFER
)
5966 wined3d_context_vk_reference_bo(context_vk
, wined3d_bo_vk(buffer_from_resource(resource
)->buffer_object
));
5968 wined3d_context_vk_reference_texture(context_vk
, wined3d_texture_vk(texture_from_resource(resource
)));
5971 static inline void wined3d_context_vk_reference_query(const struct wined3d_context_vk
*context_vk
,
5972 struct wined3d_query_vk
*query_vk
)
5974 query_vk
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
5977 static inline void wined3d_context_vk_reference_sampler(const struct wined3d_context_vk
*context_vk
,
5978 struct wined3d_sampler_vk
*sampler_vk
)
5980 sampler_vk
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
5983 static inline void wined3d_context_vk_reference_rendertarget_view(const struct wined3d_context_vk
*context_vk
,
5984 struct wined3d_rendertarget_view_vk
*rtv_vk
)
5986 wined3d_context_vk_reference_resource(context_vk
, rtv_vk
->v
.resource
);
5987 rtv_vk
->command_buffer_id
= context_vk
->current_command_buffer
.id
;
5990 static inline void wined3d_context_vk_reference_shader_resource_view(const struct wined3d_context_vk
*context_vk
,
5991 struct wined3d_shader_resource_view_vk
*srv_vk
)
5993 wined3d_context_vk_reference_resource(context_vk
, srv_vk
->v
.resource
);
5994 srv_vk
->view_vk
.command_buffer_id
= context_vk
->current_command_buffer
.id
;
5997 static inline void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk
*context_vk
,
5998 struct wined3d_unordered_access_view_vk
*uav_vk
)
6000 wined3d_context_vk_reference_resource(context_vk
, uav_vk
->v
.resource
);
6001 uav_vk
->view_vk
.command_buffer_id
= context_vk
->current_command_buffer
.id
;
6004 static inline BOOL
wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view
*dsv
,
6005 const struct wined3d_format
*srv_format
)
6007 return !srv_format
|| (srv_format
->red_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_DEPTH
))
6008 || (srv_format
->green_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_STENCIL
));
6011 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture
*texture
)
6013 return texture
->resource
.type
== WINED3D_RTYPE_TEXTURE_3D
? texture
->resource
.depth
: texture
->layer_count
;
6016 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view
*srv
)
6018 struct wined3d_texture
*texture
;
6020 if (srv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
6023 if (srv
->desc
.u
.texture
.layer_idx
|| srv
->desc
.u
.texture
.level_idx
)
6026 texture
= texture_from_resource(srv
->resource
);
6027 return srv
->desc
.u
.texture
.level_count
== texture
->level_count
6028 && srv
->desc
.u
.texture
.layer_count
== wined3d_bind_layer_count(texture
);
6031 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view
*rtv
)
6033 struct wined3d_texture
*texture
;
6035 if (rtv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
6038 if (rtv
->sub_resource_idx
)
6041 texture
= texture_from_resource(rtv
->resource
);
6042 return texture
->level_count
== 1 && rtv
->layer_count
== wined3d_bind_layer_count(texture
);
6045 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view
*srv
)
6047 InterlockedIncrement(&srv
->resource
->srv_bind_count_device
);
6050 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view
*srv
)
6052 InterlockedDecrement(&srv
->resource
->srv_bind_count_device
);
6055 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view
*rtv
)
6057 InterlockedIncrement(&rtv
->resource
->rtv_bind_count_device
);
6060 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view
*rtv
)
6062 InterlockedDecrement(&rtv
->resource
->rtv_bind_count_device
);
6065 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view
*rtv
,
6066 const struct wined3d_shader_resource_view
*srv
)
6068 if (rtv
->resource
!= srv
->resource
)
6071 if (wined3d_srv_all_subresources(srv
) || wined3d_rtv_all_subresources(rtv
))
6074 return rtv
->sub_resource_idx
>= srv
->desc
.u
.texture
.level_idx
6075 && rtv
->sub_resource_idx
< srv
->desc
.u
.texture
.level_idx
+ srv
->desc
.u
.texture
.level_count
6076 && rtv
->layer_count
>= srv
->desc
.u
.texture
.layer_idx
;
6079 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_state
*state
,
6080 const struct wined3d_shader_resource_view
*srv
)
6084 if (!srv
->resource
->rtv_bind_count_device
)
6087 for (i
= 0; i
< ARRAY_SIZE(state
->fb
.render_targets
); ++i
)
6089 const struct wined3d_rendertarget_view
*rtv
;
6091 if ((rtv
= state
->fb
.render_targets
[i
]) && wined3d_rtv_overlaps_srv(rtv
, srv
))
6098 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport
*vp
, float *min_z
, float *max_z
)
6102 /* The magic constant is derived from tests. */
6103 *max_z
= max(vp
->max_z
, vp
->min_z
+ 0.001f
);
6106 static inline BOOL
wined3d_bitmap_clear(uint32_t *map
, unsigned int idx
)
6108 return map
[idx
>> 5] &= ~(1u << (idx
& 0x1f));
6111 static inline BOOL
wined3d_bitmap_set(uint32_t *map
, unsigned int idx
)
6113 return map
[idx
>> 5] |= (1u << (idx
& 0x1f));
6116 static inline BOOL
wined3d_bitmap_is_set(const uint32_t *map
, unsigned int idx
)
6118 return map
[idx
>> 5] & (1u << (idx
& 0x1f));
6121 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap
, unsigned int bit_count
,
6122 unsigned int start
, uint32_t xor_mask
)
6124 const unsigned int word_bit_count
= sizeof(*bitmap
) * CHAR_BIT
;
6125 const uint32_t *ptr
, *end_ptr
;
6128 assert(bit_count
< word_bit_count
|| !(bit_count
% word_bit_count
));
6130 ptr
= bitmap
+ start
/ word_bit_count
;
6131 end_ptr
= bitmap
+ (bit_count
+ word_bit_count
- 1) / word_bit_count
;
6136 mask
= ~0u << start
% word_bit_count
;
6137 map
= (*ptr
^ xor_mask
) & mask
;
6140 if (++ptr
== end_ptr
)
6142 map
= *ptr
^ xor_mask
;
6144 return (ptr
- bitmap
) * word_bit_count
+ wined3d_bit_scan(&map
);
6147 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
6149 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, 0);
6152 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
6154 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, ~0u);
6157 static inline BOOL
wined3d_bitmap_get_range(const uint32_t *bitmap
, unsigned int bit_count
,
6158 unsigned int start
, struct wined3d_range
*range
)
6160 unsigned int range_start
, range_end
;
6162 range_start
= wined3d_bitmap_ffs(bitmap
, bit_count
, start
);
6163 if (range_start
== ~0u)
6166 range_end
= wined3d_bitmap_ffz(bitmap
, bit_count
, range_start
+ 1);
6167 if (range_end
== ~0u)
6168 range_end
= bit_count
;
6170 range
->offset
= range_start
;
6171 range
->size
= range_end
- range_start
;
6175 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
6177 return wined3d_bitmap_is_set(context
->dirty_graphics_states
, state_id
);
6180 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
6182 return wined3d_bitmap_is_set(context
->dirty_compute_states
, state_id
- STATE_COMPUTE_OFFSET
);
6185 static inline bool isStateDirty(const struct wined3d_context
*context
, unsigned int state_id
)
6187 return wined3d_context_is_graphics_state_dirty(context
, state_id
);
6190 static inline VkImageAspectFlags
vk_aspect_mask_from_format(const struct wined3d_format
*format
)
6192 VkImageAspectFlags mask
= 0;
6194 if (format
->depth_size
)
6195 mask
|= VK_IMAGE_ASPECT_DEPTH_BIT
;
6196 if (format
->stencil_size
)
6197 mask
|= VK_IMAGE_ASPECT_STENCIL_BIT
;
6198 if (!mask
|| format
->red_size
|| format
->green_size
|| format
->blue_size
|| format
->alpha_size
)
6199 mask
|= VK_IMAGE_ASPECT_COLOR_BIT
;
6204 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t
)
6206 return t
== WINED3D_PT_POINTLIST
6207 || t
== WINED3D_PT_LINELIST
6208 || t
== WINED3D_PT_TRIANGLELIST
6209 || t
== WINED3D_PT_LINELIST_ADJ
6210 || t
== WINED3D_PT_TRIANGLELIST_ADJ
6211 || t
== WINED3D_PT_PATCH
;
6214 static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo_gl
)
6216 struct wined3d_device_gl
*device_gl
= wined3d_device_gl(context_gl
->c
.device
);
6218 bo_gl
->command_fence_id
= device_gl
->current_fence_id
;
6221 static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl
*context_gl
,
6222 struct wined3d_buffer
*buffer
)
6224 if (buffer
->buffer_object
)
6225 wined3d_context_gl_reference_bo(context_gl
, wined3d_bo_gl(buffer
->buffer_object
));
6228 static inline bool wined3d_map_persistent(void)
6230 return sizeof(void *) >= sizeof(uint64_t);
6233 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
6234 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
6236 extern CRITICAL_SECTION wined3d_command_cs
;