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
31 #include <sys/types.h>
35 #define LIBVKD3D_SHADER_SOURCE
36 #include <vkd3d_shader.h>
38 #define WIN32_NO_STATUS
46 #include "ddk/d3dkmthk.h"
47 #include "wine/debug.h"
48 #include "wine/heap.h"
51 #include "wine/wined3d.h"
52 #include "wine/list.h"
53 #include "wine/rbtree.h"
55 static inline size_t align(size_t addr
, size_t alignment
)
57 return (addr
+ (alignment
- 1)) & ~(alignment
- 1);
60 static inline float int_to_float(uint32_t i
)
72 static inline const char *wined3d_get_line(const char **ptr
, const char *end
)
76 if ((p
= *ptr
) >= end
)
79 if (!(q
= memchr(p
, '\n', end
- p
)))
86 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
88 #define WINED3D_MAX_DIRTY_REGION_COUNT 7
90 #define WINED3D_ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A','2','M','1')
91 #define WINED3D_ALPHA_TO_COVERAGE_DISABLE MAKEFOURCC('A','2','M','0')
93 #define WINED3D_BITMAP_SIZE(x) (((x) + 31) >> 5)
95 struct wined3d_fragment_pipe_ops
;
96 struct wined3d_adapter
;
97 struct wined3d_context
;
98 struct wined3d_gl_info
;
100 struct wined3d_swapchain_gl
;
101 struct wined3d_texture_gl
;
102 struct wined3d_vertex_pipe_ops
;
106 WINED3D_FFP_POSITION
= 0,
107 WINED3D_FFP_BLENDWEIGHT
= 1,
108 WINED3D_FFP_BLENDINDICES
= 2,
109 WINED3D_FFP_NORMAL
= 3,
110 WINED3D_FFP_PSIZE
= 4,
111 WINED3D_FFP_DIFFUSE
= 5,
112 WINED3D_FFP_SPECULAR
= 6,
113 WINED3D_FFP_TEXCOORD0
= 7,
114 WINED3D_FFP_TEXCOORD1
= 8,
115 WINED3D_FFP_TEXCOORD2
= 9,
116 WINED3D_FFP_TEXCOORD3
= 10,
117 WINED3D_FFP_TEXCOORD4
= 11,
118 WINED3D_FFP_TEXCOORD5
= 12,
119 WINED3D_FFP_TEXCOORD6
= 13,
120 WINED3D_FFP_TEXCOORD7
= 14,
121 WINED3D_FFP_ATTRIBS_COUNT
= 15,
124 enum wined3d_ffp_emit_idx
126 WINED3D_FFP_EMIT_FLOAT1
,
127 WINED3D_FFP_EMIT_FLOAT2
,
128 WINED3D_FFP_EMIT_FLOAT3
,
129 WINED3D_FFP_EMIT_FLOAT4
,
130 WINED3D_FFP_EMIT_D3DCOLOR
,
131 WINED3D_FFP_EMIT_UBYTE4
,
132 WINED3D_FFP_EMIT_SHORT2
,
133 WINED3D_FFP_EMIT_SHORT4
,
134 WINED3D_FFP_EMIT_UBYTE4N
,
135 WINED3D_FFP_EMIT_SHORT2N
,
136 WINED3D_FFP_EMIT_SHORT4N
,
137 WINED3D_FFP_EMIT_USHORT2N
,
138 WINED3D_FFP_EMIT_USHORT4N
,
139 WINED3D_FFP_EMIT_UDEC3
,
140 WINED3D_FFP_EMIT_DEC3N
,
141 WINED3D_FFP_EMIT_FLOAT16_2
,
142 WINED3D_FFP_EMIT_FLOAT16_4
,
143 WINED3D_FFP_EMIT_INVALID
,
144 WINED3D_FFP_EMIT_COUNT
,
147 /* Texture format fixups */
149 enum fixup_channel_source
151 CHANNEL_SOURCE_ZERO
= 0,
152 CHANNEL_SOURCE_ONE
= 1,
153 CHANNEL_SOURCE_X
= 2,
154 CHANNEL_SOURCE_Y
= 3,
155 CHANNEL_SOURCE_Z
= 4,
156 CHANNEL_SOURCE_W
= 5,
157 CHANNEL_SOURCE_COMPLEX0
= 6,
158 CHANNEL_SOURCE_COMPLEX1
= 7,
163 COMPLEX_FIXUP_NONE
= 0,
164 COMPLEX_FIXUP_YUY2
= 1,
165 COMPLEX_FIXUP_UYVY
= 2,
166 COMPLEX_FIXUP_YV12
= 3,
167 COMPLEX_FIXUP_P8
= 4,
168 COMPLEX_FIXUP_NV12
= 5,
169 COMPLEX_FIXUP_YUV
= 6,
172 #include <pshpack2.h>
173 struct color_fixup_desc
175 unsigned short x_sign_fixup
: 1;
176 unsigned short x_source
: 3;
177 unsigned short y_sign_fixup
: 1;
178 unsigned short y_source
: 3;
179 unsigned short z_sign_fixup
: 1;
180 unsigned short z_source
: 3;
181 unsigned short w_sign_fixup
: 1;
182 unsigned short w_source
: 3;
186 struct wined3d_d3d_limits
188 unsigned int vs_version
, hs_version
, ds_version
, gs_version
, ps_version
, cs_version
;
189 DWORD vs_uniform_count
;
190 DWORD ps_uniform_count
;
191 unsigned int varying_count
;
192 unsigned int ffp_textures
;
193 unsigned int ffp_blend_stages
;
194 unsigned int ffp_vertex_blend_matrices
;
195 unsigned int active_light_count
;
197 unsigned int max_rt_count
;
198 unsigned int max_clip_distances
;
199 unsigned int texture_size
;
200 unsigned int sample_count
;
204 struct wined3d_d3d_info
206 struct wined3d_d3d_limits limits
;
207 uint32_t wined3d_creation_flags
;
209 uint32_t emulated_flatshading
: 1;
210 uint32_t ffp_generic_attributes
: 1;
211 uint32_t ffp_alpha_test
: 1;
212 uint32_t vs_clipping
: 1;
213 uint32_t shader_color_key
: 1;
214 uint32_t shader_double_precision
: 1;
215 uint32_t shader_output_interpolation
: 1;
216 uint32_t frag_coord_correction
: 1;
217 uint32_t viewport_array_index_any_shader
: 1;
218 uint32_t texture_npot
: 1;
219 uint32_t texture_npot_conditional
: 1;
220 uint32_t normalized_texrect
: 1;
221 uint32_t draw_base_vertex_offset
: 1;
222 uint32_t vertex_bgra
: 1;
223 uint32_t texture_swizzle
: 1;
224 uint32_t srgb_read_control
: 1;
225 uint32_t srgb_write_control
: 1;
226 uint32_t clip_control
: 1;
227 uint32_t full_ffp_varyings
: 1;
228 uint32_t scaled_resolve
: 1;
230 uint32_t subpixel_viewport
: 1;
232 uint32_t persistent_map
: 1;
233 enum wined3d_feature_level feature_level
;
235 DWORD multisample_draw_location
;
237 float filling_convention_offset
;
240 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
=
241 {0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_Z
, 0, CHANNEL_SOURCE_W
};
243 static inline struct color_fixup_desc
create_complex_fixup_desc(enum complex_fixup complex_fixup
)
245 struct color_fixup_desc fixup
=
247 0u, complex_fixup
& (1u << 0) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
248 0u, complex_fixup
& (1u << 1) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
249 0u, complex_fixup
& (1u << 2) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
250 0u, complex_fixup
& (1u << 3) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
255 static inline BOOL
is_identity_fixup(struct color_fixup_desc fixup
)
257 return !memcmp(&fixup
, &COLOR_FIXUP_IDENTITY
, sizeof(fixup
));
260 static inline BOOL
is_complex_fixup(struct color_fixup_desc fixup
)
262 return fixup
.x_source
== CHANNEL_SOURCE_COMPLEX0
|| fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
;
265 static inline BOOL
is_scaling_fixup(struct color_fixup_desc fixup
)
267 return fixup
.x_sign_fixup
|| fixup
.y_sign_fixup
|| fixup
.z_sign_fixup
|| fixup
.w_sign_fixup
;
270 static inline BOOL
is_same_fixup(struct color_fixup_desc f1
, struct color_fixup_desc f2
)
272 return f1
.x_sign_fixup
== f2
.x_sign_fixup
&& f1
.x_source
== f2
.x_source
273 && f1
.y_sign_fixup
== f2
.y_sign_fixup
&& f1
.y_source
== f2
.y_source
274 && f1
.z_sign_fixup
== f2
.z_sign_fixup
&& f1
.z_source
== f2
.z_source
275 && f1
.w_sign_fixup
== f2
.w_sign_fixup
&& f1
.w_source
== f2
.w_source
;
278 static inline enum complex_fixup
get_complex_fixup(struct color_fixup_desc fixup
)
280 enum complex_fixup complex_fixup
= 0;
281 if (fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 0);
282 if (fixup
.y_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 1);
283 if (fixup
.z_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 2);
284 if (fixup
.w_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 3);
285 return complex_fixup
;
289 #define WINED3D_MAX_ACTIVE_LIGHTS 8
290 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
291 #define MAX_CONSTANT_BUFFERS 15
292 #define MAX_SAMPLER_OBJECTS 16
293 #define MAX_SHADER_RESOURCE_VIEWS 128
294 #define MAX_UNORDERED_ACCESS_VIEWS 8
295 #define MAX_TGSM_REGISTERS 8192
296 #define MAX_VERTEX_BLENDS 4
298 static const uint32_t WINED3D_READ_ONLY_BIND_MASK
= WINED3D_BIND_VERTEX_BUFFER
| WINED3D_BIND_INDEX_BUFFER
299 | WINED3D_BIND_CONSTANT_BUFFER
| WINED3D_BIND_SHADER_RESOURCE
| WINED3D_BIND_INDIRECT_BUFFER
;
301 static inline enum wined3d_cmp_func
wined3d_sanitize_cmp_func(enum wined3d_cmp_func func
)
303 if (func
< WINED3D_CMP_NEVER
|| func
> WINED3D_CMP_ALWAYS
)
304 return WINED3D_CMP_ALWAYS
;
308 /* float_16_to_32() and float_32_to_16() convert 16 bit floats in the
309 * FLOAT16 data type to standard C floats and vice versa. They do not
310 * depend on the encoding of the C float, so they are platform independent,
311 * but slow. On x86 and other IEEE 754 compliant platforms the conversion
312 * can be accelerated by bit shifting the exponent and mantissa. There are
313 * also some SSE-based assembly routines out there.
315 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
317 static inline float float_16_to_32(const unsigned short *in
)
319 const unsigned short s
= ((*in
) & 0x8000u
);
320 const unsigned short e
= ((*in
) & 0x7c00u
) >> 10;
321 const unsigned short m
= (*in
) & 0x3ffu
;
322 const float sgn
= (s
? -1.0f
: 1.0f
);
325 if(m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
326 else return sgn
* powf(2, -14.0f
) * ((float)m
/ 1024.0f
);
328 return sgn
* powf(2, (float)e
- 15.0f
) * (1.0f
+ ((float)m
/ 1024.0f
));
330 if(m
== 0) return sgn
* INFINITY
;
335 static inline float float_24_to_32(DWORD in
)
337 const float sgn
= in
& 0x800000u
? -1.0f
: 1.0f
;
338 const unsigned short e
= (in
& 0x780000u
) >> 19;
339 const unsigned int m
= in
& 0x7ffffu
;
343 if (m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
344 else return sgn
* powf(2, -6.0f
) * ((float)m
/ 524288.0f
);
348 return sgn
* powf(2, (float)e
- 7.0f
) * (1.0f
+ ((float)m
/ 524288.0f
));
352 if (m
== 0) return sgn
* INFINITY
;
357 static inline unsigned short float_32_to_16(const float *in
)
360 float tmp
= fabsf(*in
);
361 unsigned int mantissa
;
364 /* Deal with special numbers */
370 return (*in
< 0.0f
? 0xfc00 : 0x7c00);
372 if (tmp
< (float)(1u << 10))
378 } while (tmp
< (float)(1u << 10));
380 else if (tmp
>= (float)(1u << 11))
386 } while (tmp
>= (float)(1u << 11));
389 mantissa
= (unsigned int)tmp
;
390 if (tmp
- mantissa
>= 0.5f
)
391 ++mantissa
; /* Round to nearest, away from zero. */
393 exp
+= 10; /* Normalize the mantissa. */
394 exp
+= 15; /* Exponent is encoded with excess 15. */
396 if (exp
> 30) /* too big */
398 ret
= 0x7c00; /* INF */
402 /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
405 mantissa
= mantissa
>> 1;
408 ret
= mantissa
& 0x3ff;
412 ret
= (exp
<< 10) | (mantissa
& 0x3ff);
415 ret
|= ((*in
< 0.0f
? 1 : 0) << 15); /* Add the sign */
419 static inline unsigned int wined3d_popcount(unsigned int x
)
421 #if defined(__MINGW32__)
422 return __builtin_popcount(x
);
424 x
-= x
>> 1 & 0x55555555;
425 x
= (x
& 0x33333333) + (x
>> 2 & 0x33333333);
426 return ((x
+ (x
>> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
430 static inline int wined3d_uint32_compare(uint32_t x
, uint32_t y
)
432 return (x
> y
) - (x
< y
);
435 static inline int wined3d_uint64_compare(uint64_t x
, uint64_t y
)
437 return (x
> y
) - (x
< y
);
440 #define ORM_BACKBUFFER 0
443 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
444 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
446 enum wined3d_shader_backend
448 WINED3D_SHADER_BACKEND_AUTO
,
449 WINED3D_SHADER_BACKEND_GLSL
,
450 WINED3D_SHADER_BACKEND_ARB
,
451 WINED3D_SHADER_BACKEND_NONE
,
454 #define WINED3D_CSMT_ENABLE 0x00000001
455 #define WINED3D_CSMT_SERIALIZE 0x00000002
457 /* NOTE: When adding fields to this structure, make sure to update the default
458 * values in wined3d_main.c as well. */
459 struct wined3d_settings
461 unsigned int cs_multithreaded
;
462 unsigned int max_gl_version
;
463 int offscreen_rendering_mode
;
464 unsigned short pci_vendor_id
;
465 unsigned short pci_device_id
;
466 /* Memory tracking and object counting. */
467 UINT64 emulated_textureram
;
469 unsigned int multisample_textures
;
470 unsigned int sample_count
;
471 BOOL check_float_constants
;
472 unsigned int strict_shader_math
;
473 unsigned int max_sm_vs
;
474 unsigned int max_sm_hs
;
475 unsigned int max_sm_ds
;
476 unsigned int max_sm_gs
;
477 unsigned int max_sm_ps
;
478 unsigned int max_sm_cs
;
479 enum wined3d_renderer renderer
;
480 enum wined3d_shader_backend shader_backend
;
481 BOOL cb_access_map_w
;
484 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN
;
486 enum wined3d_shader_resource_type
488 WINED3D_SHADER_RESOURCE_NONE
,
489 WINED3D_SHADER_RESOURCE_BUFFER
,
490 WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
491 WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
492 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
493 WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
494 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
495 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
496 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
497 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
498 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY
,
501 #define WINED3D_SHADER_CONST_VS_F 0x00000001
502 #define WINED3D_SHADER_CONST_VS_I 0x00000002
503 #define WINED3D_SHADER_CONST_VS_B 0x00000004
504 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
505 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
506 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
507 #define WINED3D_SHADER_CONST_PS_F 0x00000040
508 #define WINED3D_SHADER_CONST_PS_I 0x00000080
509 #define WINED3D_SHADER_CONST_PS_B 0x00000100
510 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
511 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
512 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
513 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
514 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
515 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
516 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
517 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
518 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
519 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
520 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
521 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
522 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
523 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
525 enum wined3d_shader_register_type
528 WINED3DSPR_INPUT
= 1,
529 WINED3DSPR_CONST
= 2,
531 WINED3DSPR_TEXTURE
= 3,
532 WINED3DSPR_RASTOUT
= 4,
533 WINED3DSPR_ATTROUT
= 5,
534 WINED3DSPR_TEXCRDOUT
= 6,
535 WINED3DSPR_OUTPUT
= 6,
536 WINED3DSPR_CONSTINT
= 7,
537 WINED3DSPR_COLOROUT
= 8,
538 WINED3DSPR_DEPTHOUT
= 9,
539 WINED3DSPR_SAMPLER
= 10,
540 WINED3DSPR_CONST2
= 11,
541 WINED3DSPR_CONST3
= 12,
542 WINED3DSPR_CONST4
= 13,
543 WINED3DSPR_CONSTBOOL
= 14,
544 WINED3DSPR_LOOP
= 15,
545 WINED3DSPR_TEMPFLOAT16
= 16,
546 WINED3DSPR_MISCTYPE
= 17,
547 WINED3DSPR_LABEL
= 18,
548 WINED3DSPR_PREDICATE
= 19,
550 WINED3DSPR_CONSTBUFFER
,
551 WINED3DSPR_IMMCONSTBUFFER
,
556 WINED3DSPR_OUTPOINTID
,
557 WINED3DSPR_FORKINSTID
,
558 WINED3DSPR_JOININSTID
,
559 WINED3DSPR_INCONTROLPOINT
,
560 WINED3DSPR_OUTCONTROLPOINT
,
561 WINED3DSPR_PATCHCONST
,
562 WINED3DSPR_TESSCOORD
,
563 WINED3DSPR_GROUPSHAREDMEM
,
565 WINED3DSPR_THREADGROUPID
,
566 WINED3DSPR_LOCALTHREADID
,
567 WINED3DSPR_LOCALTHREADINDEX
,
570 WINED3DSPR_FUNCTIONBODY
,
571 WINED3DSPR_FUNCTIONPOINTER
,
573 WINED3DSPR_SAMPLEMASK
,
575 WINED3DSPR_DEPTHOUTGE
,
576 WINED3DSPR_DEPTHOUTLE
,
577 WINED3DSPR_RASTERIZER
,
580 enum wined3d_data_type
584 WINED3D_DATA_RESOURCE
,
585 WINED3D_DATA_SAMPLER
,
593 enum wined3d_immconst_type
595 WINED3D_IMMCONST_SCALAR
,
596 WINED3D_IMMCONST_VEC4
,
599 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
601 enum wined3d_shader_src_modifier
603 WINED3DSPSM_NONE
= 0,
605 WINED3DSPSM_BIAS
= 2,
606 WINED3DSPSM_BIASNEG
= 3,
607 WINED3DSPSM_SIGN
= 4,
608 WINED3DSPSM_SIGNNEG
= 5,
609 WINED3DSPSM_COMP
= 6,
611 WINED3DSPSM_X2NEG
= 8,
614 WINED3DSPSM_ABS
= 11,
615 WINED3DSPSM_ABSNEG
= 12,
616 WINED3DSPSM_NOT
= 13,
619 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
620 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
621 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
622 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
623 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
625 enum wined3d_shader_dst_modifier
627 WINED3DSPDM_NONE
= 0,
628 WINED3DSPDM_SATURATE
= 1,
629 WINED3DSPDM_PARTIALPRECISION
= 2,
630 WINED3DSPDM_MSAMPCENTROID
= 4,
633 enum wined3d_shader_interpolation_mode
636 WINED3DSIM_CONSTANT
= 1,
637 WINED3DSIM_LINEAR
= 2,
638 WINED3DSIM_LINEAR_CENTROID
= 3,
639 WINED3DSIM_LINEAR_NOPERSPECTIVE
= 4,
640 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
= 5,
641 WINED3DSIM_LINEAR_SAMPLE
= 6,
642 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE
= 7,
645 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
646 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
648 enum wined3d_shader_global_flags
650 WINED3DSGF_REFACTORING_ALLOWED
= 0x1,
651 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL
= 0x4,
652 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS
= 0x8,
655 enum wined3d_shader_sync_flags
657 WINED3DSSF_THREAD_GROUP
= 0x1,
658 WINED3DSSF_GROUP_SHARED_MEMORY
= 0x2,
659 WINED3DSSF_GLOBAL_UAV
= 0x8,
662 enum wined3d_shader_uav_flags
664 WINED3DSUF_GLOBALLY_COHERENT
= 0x2,
665 WINED3DSUF_ORDER_PRESERVING_COUNTER
= 0x100,
668 enum wined3d_tessellator_domain
670 WINED3D_TESSELLATOR_DOMAIN_LINE
= 1,
671 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE
= 2,
672 WINED3D_TESSELLATOR_DOMAIN_QUAD
= 3,
675 enum wined3d_tessellator_output_primitive
677 WINED3D_TESSELLATOR_OUTPUT_POINT
= 1,
678 WINED3D_TESSELLATOR_OUTPUT_LINE
= 2,
679 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW
= 3,
680 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW
= 4,
683 enum wined3d_tessellator_partitioning
685 WINED3D_TESSELLATOR_PARTITIONING_INTEGER
= 1,
686 WINED3D_TESSELLATOR_PARTITIONING_POW2
= 2,
687 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD
= 3,
688 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
= 4,
691 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
692 #define WINED3DSI_TEXLD_PROJECT 0x1
693 #define WINED3DSI_TEXLD_BIAS 0x2
694 #define WINED3DSI_INDEXED_DYNAMIC 0x4
695 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
696 #define WINED3DSI_RESINFO_UINT 0x2
697 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
698 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
700 #define WINED3DSI_PRECISE_X 0x100
701 #define WINED3DSI_PRECISE_Y 0x200
702 #define WINED3DSI_PRECISE_Z 0x400
703 #define WINED3DSI_PRECISE_W 0x800
704 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
705 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
706 #define WINED3DSI_PRECISE_SHIFT 8
708 enum wined3d_shader_rel_op
710 WINED3D_SHADER_REL_OP_GT
= 1,
711 WINED3D_SHADER_REL_OP_EQ
= 2,
712 WINED3D_SHADER_REL_OP_GE
= 3,
713 WINED3D_SHADER_REL_OP_LT
= 4,
714 WINED3D_SHADER_REL_OP_NE
= 5,
715 WINED3D_SHADER_REL_OP_LE
= 6,
718 enum wined3d_shader_conditional_op
720 WINED3D_SHADER_CONDITIONAL_OP_NZ
= 0,
721 WINED3D_SHADER_CONDITIONAL_OP_Z
= 1
724 enum wined3d_sysval_semantic
726 WINED3D_SV_POSITION
= 0x01,
727 WINED3D_SV_CLIP_DISTANCE
= 0x02,
728 WINED3D_SV_CULL_DISTANCE
= 0x03,
729 WINED3D_SV_RENDER_TARGET_ARRAY_INDEX
= 0x04,
730 WINED3D_SV_VIEWPORT_ARRAY_INDEX
= 0x05,
731 WINED3D_SV_VERTEX_ID
= 0x06,
732 WINED3D_SV_PRIMITIVE_ID
= 0x07,
733 WINED3D_SV_INSTANCE_ID
= 0x08,
734 WINED3D_SV_IS_FRONT_FACE
= 0x09,
735 WINED3D_SV_SAMPLE_INDEX
= 0x0a,
736 WINED3D_SV_TESS_FACTOR_QUADEDGE
= 0x0b,
737 WINED3D_SV_TESS_FACTOR_QUADINT
= 0x0c,
738 WINED3D_SV_TESS_FACTOR_TRIEDGE
= 0x0d,
739 WINED3D_SV_TESS_FACTOR_TRIINT
= 0x0e,
740 WINED3D_SV_TESS_FACTOR_LINEDET
= 0x0f,
741 WINED3D_SV_TESS_FACTOR_LINEDEN
= 0x10,
744 enum wined3d_component_type
746 WINED3D_TYPE_UNKNOWN
= 0x0,
747 WINED3D_TYPE_UINT
= 0x1,
748 WINED3D_TYPE_INT
= 0x2,
749 WINED3D_TYPE_FLOAT
= 0x3,
752 struct wined3d_shader_signature_element
754 const char *semantic_name
;
755 unsigned int semantic_idx
;
756 unsigned int stream_idx
;
757 enum wined3d_sysval_semantic sysval_semantic
;
758 enum wined3d_component_type component_type
;
759 unsigned int register_idx
;
761 unsigned int min_precision
;
764 struct wined3d_shader_signature
766 unsigned int element_count
;
767 struct wined3d_shader_signature_element
*elements
;
770 #define WINED3D_SM1_VS 0xfffeu
771 #define WINED3D_SM1_PS 0xffffu
772 #define WINED3D_SM4_PS 0x0000u
773 #define WINED3D_SM4_VS 0x0001u
774 #define WINED3D_SM4_GS 0x0002u
775 #define WINED3D_SM5_HS 0x0003u
776 #define WINED3D_SM5_DS 0x0004u
777 #define WINED3D_SM5_CS 0x0005u
779 /* Shader version tokens, and shader end tokens */
780 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
781 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
783 /* Shader backends */
785 #define MAX_ATTRIBS 32
786 #define MAX_REG_ADDR 1
787 #define MAX_REG_TEXCRD 8
788 #define MAX_REG_INPUT 32
789 #define MAX_REG_OUTPUT 32
790 #define WINED3D_MAX_CBS 15
792 /* FIXME: This needs to go up to 2048 for
793 * Shader model 3 according to msdn (and for software shaders) */
794 #define MAX_LABELS 16
796 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
798 struct wined3d_string_buffer
802 unsigned int buffer_size
;
803 unsigned int content_size
;
806 enum WINED3D_SHADER_INSTRUCTION_HANDLER
811 WINED3DSIH_ATOMIC_AND
,
812 WINED3DSIH_ATOMIC_CMP_STORE
,
813 WINED3DSIH_ATOMIC_IADD
,
814 WINED3DSIH_ATOMIC_IMAX
,
815 WINED3DSIH_ATOMIC_IMIN
,
816 WINED3DSIH_ATOMIC_OR
,
817 WINED3DSIH_ATOMIC_UMAX
,
818 WINED3DSIH_ATOMIC_UMIN
,
819 WINED3DSIH_ATOMIC_XOR
,
833 WINED3DSIH_CONTINUEP
,
834 WINED3DSIH_COUNTBITS
,
837 WINED3DSIH_CUT_STREAM
,
839 WINED3DSIH_DCL_CONSTANT_BUFFER
,
840 WINED3DSIH_DCL_FUNCTION_BODY
,
841 WINED3DSIH_DCL_FUNCTION_TABLE
,
842 WINED3DSIH_DCL_GLOBAL_FLAGS
,
843 WINED3DSIH_DCL_GS_INSTANCES
,
844 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
,
845 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
,
846 WINED3DSIH_DCL_HS_MAX_TESSFACTOR
,
847 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
,
848 WINED3DSIH_DCL_INDEX_RANGE
,
849 WINED3DSIH_DCL_INDEXABLE_TEMP
,
850 WINED3DSIH_DCL_INPUT
,
851 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
,
852 WINED3DSIH_DCL_INPUT_PRIMITIVE
,
853 WINED3DSIH_DCL_INPUT_PS
,
854 WINED3DSIH_DCL_INPUT_PS_SGV
,
855 WINED3DSIH_DCL_INPUT_PS_SIV
,
856 WINED3DSIH_DCL_INPUT_SGV
,
857 WINED3DSIH_DCL_INPUT_SIV
,
858 WINED3DSIH_DCL_INTERFACE
,
859 WINED3DSIH_DCL_OUTPUT
,
860 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
,
861 WINED3DSIH_DCL_OUTPUT_SIV
,
862 WINED3DSIH_DCL_OUTPUT_TOPOLOGY
,
863 WINED3DSIH_DCL_RESOURCE_RAW
,
864 WINED3DSIH_DCL_RESOURCE_STRUCTURED
,
865 WINED3DSIH_DCL_SAMPLER
,
866 WINED3DSIH_DCL_STREAM
,
867 WINED3DSIH_DCL_TEMPS
,
868 WINED3DSIH_DCL_TESSELLATOR_DOMAIN
,
869 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
,
870 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
,
871 WINED3DSIH_DCL_TGSM_RAW
,
872 WINED3DSIH_DCL_TGSM_STRUCTURED
,
873 WINED3DSIH_DCL_THREAD_GROUP
,
874 WINED3DSIH_DCL_UAV_RAW
,
875 WINED3DSIH_DCL_UAV_STRUCTURED
,
876 WINED3DSIH_DCL_UAV_TYPED
,
877 WINED3DSIH_DCL_VERTICES_OUT
,
889 WINED3DSIH_DSX_COARSE
,
892 WINED3DSIH_DSY_COARSE
,
896 WINED3DSIH_EMIT_STREAM
,
900 WINED3DSIH_ENDSWITCH
,
902 WINED3DSIH_EVAL_CENTROID
,
903 WINED3DSIH_EVAL_SAMPLE_INDEX
,
909 WINED3DSIH_FIRSTBIT_HI
,
910 WINED3DSIH_FIRSTBIT_LO
,
911 WINED3DSIH_FIRSTBIT_SHI
,
916 WINED3DSIH_GATHER4_C
,
917 WINED3DSIH_GATHER4_PO
,
918 WINED3DSIH_GATHER4_PO_C
,
920 WINED3DSIH_HS_CONTROL_POINT_PHASE
,
922 WINED3DSIH_HS_FORK_PHASE
,
923 WINED3DSIH_HS_JOIN_PHASE
,
934 WINED3DSIH_IMM_ATOMIC_ALLOC
,
935 WINED3DSIH_IMM_ATOMIC_AND
,
936 WINED3DSIH_IMM_ATOMIC_CMP_EXCH
,
937 WINED3DSIH_IMM_ATOMIC_CONSUME
,
938 WINED3DSIH_IMM_ATOMIC_EXCH
,
939 WINED3DSIH_IMM_ATOMIC_IADD
,
940 WINED3DSIH_IMM_ATOMIC_IMAX
,
941 WINED3DSIH_IMM_ATOMIC_IMIN
,
942 WINED3DSIH_IMM_ATOMIC_OR
,
943 WINED3DSIH_IMM_ATOMIC_UMAX
,
944 WINED3DSIH_IMM_ATOMIC_UMIN
,
945 WINED3DSIH_IMM_ATOMIC_XOR
,
956 WINED3DSIH_LD_STRUCTURED
,
957 WINED3DSIH_LD_UAV_TYPED
,
997 WINED3DSIH_SAMPLE_C_LZ
,
998 WINED3DSIH_SAMPLE_GRAD
,
999 WINED3DSIH_SAMPLE_INFO
,
1000 WINED3DSIH_SAMPLE_LOD
,
1001 WINED3DSIH_SAMPLE_POS
,
1008 WINED3DSIH_STORE_RAW
,
1009 WINED3DSIH_STORE_STRUCTURED
,
1010 WINED3DSIH_STORE_UAV_TYPED
,
1018 WINED3DSIH_TEXCOORD
,
1019 WINED3DSIH_TEXDEPTH
,
1021 WINED3DSIH_TEXDP3TEX
,
1025 WINED3DSIH_TEXM3x2DEPTH
,
1026 WINED3DSIH_TEXM3x2PAD
,
1027 WINED3DSIH_TEXM3x2TEX
,
1029 WINED3DSIH_TEXM3x3DIFF
,
1030 WINED3DSIH_TEXM3x3PAD
,
1031 WINED3DSIH_TEXM3x3SPEC
,
1032 WINED3DSIH_TEXM3x3TEX
,
1033 WINED3DSIH_TEXM3x3VSPEC
,
1034 WINED3DSIH_TEXREG2AR
,
1035 WINED3DSIH_TEXREG2GB
,
1036 WINED3DSIH_TEXREG2RGB
,
1047 WINED3DSIH_TABLE_SIZE
1050 struct wined3d_shader_version
1052 enum wined3d_shader_type type
;
1057 struct wined3d_shader_resource_info
1059 enum wined3d_shader_resource_type type
;
1060 enum wined3d_data_type data_type
;
1062 unsigned int stride
;
1065 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1067 struct wined3d_shader_sampler_map_entry
1069 unsigned int resource_idx
;
1070 unsigned int sampler_idx
;
1071 unsigned int bind_idx
;
1074 struct wined3d_shader_sampler_map
1076 struct wined3d_shader_sampler_map_entry
*entries
;
1081 struct wined3d_shader_immediate_constant_buffer
1083 unsigned int vec4_count
;
1084 uint32_t data
[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
];
1087 struct wined3d_shader_indexable_temp
1090 unsigned int register_idx
;
1091 unsigned int register_size
;
1092 unsigned int component_count
;
1095 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1097 struct wined3d_shader_reg_maps
1099 struct wined3d_shader_version shader_version
;
1100 BYTE texcoord
; /* MAX_REG_TEXCRD, 8 */
1101 BYTE address
; /* MAX_REG_ADDR, 1 */
1102 WORD labels
; /* MAX_LABELS, 16 */
1103 DWORD temporary
; /* 32 */
1104 unsigned int temporary_count
;
1105 uint32_t *constf
; /* pixel, vertex */
1106 struct list indexable_temps
;
1107 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1110 DWORD texcoord_mask
[MAX_REG_TEXCRD
]; /* vertex < 3.0 */
1111 BYTE output_registers_mask
[MAX_REG_OUTPUT
]; /* vertex >= 3.0 */
1113 DWORD input_registers
; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1114 DWORD output_registers
; /* MAX_REG_OUTPUT, 32 */
1115 WORD integer_constants
; /* WINED3D_MAX_CONSTS_I, 16 */
1116 WORD boolean_constants
; /* WINED3D_MAX_CONSTS_B, 16 */
1117 WORD local_int_consts
; /* WINED3D_MAX_CONSTS_I, 16 */
1118 WORD local_bool_consts
; /* WINED3D_MAX_CONSTS_B, 16 */
1119 UINT cb_sizes
[WINED3D_MAX_CBS
];
1120 uint32_t cb_map
; /* WINED3D_MAX_CBS, 15 */
1122 struct wined3d_shader_resource_info resource_info
[MAX_SHADER_RESOURCE_VIEWS
];
1123 uint32_t resource_map
[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS
)];
1124 struct wined3d_shader_sampler_map sampler_map
;
1125 DWORD sampler_comparison_mode
;
1126 BYTE bumpmat
; /* WINED3D_MAX_TEXTURES, 8 */
1127 BYTE luminanceparams
; /* WINED3D_MAX_TEXTURES, 8 */
1128 struct wined3d_shader_resource_info uav_resource_info
[MAX_UNORDERED_ACCESS_VIEWS
];
1129 DWORD uav_read_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1130 DWORD uav_counter_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1132 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1133 DWORD cull_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1138 DWORD usestexldd
: 1;
1140 DWORD usesfacing
: 1;
1141 DWORD usesrelconstF
: 1;
1143 DWORD usestexldl
: 1;
1147 DWORD point_size
: 1;
1149 DWORD input_rel_addressing
: 1;
1150 DWORD viewport_array
: 1;
1151 DWORD sample_mask
: 1;
1154 DWORD rt_mask
; /* Used render targets, 32 max. */
1156 /* Whether or not loops are used in this shader, and nesting depth */
1157 unsigned int loop_depth
;
1158 unsigned int min_rel_offset
, max_rel_offset
;
1160 struct wined3d_shader_tgsm
*tgsm
;
1161 SIZE_T tgsm_capacity
;
1162 unsigned int tgsm_count
;
1165 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1166 * state information between multiple instructions. */
1167 struct wined3d_shader_tex_mx
1169 unsigned int current_row
;
1170 unsigned int texcoord_w
[2];
1173 struct wined3d_shader_parser_state
1175 unsigned int current_loop_depth
;
1176 unsigned int current_loop_reg
;
1180 struct wined3d_shader_context
1182 const struct wined3d_shader
*shader
;
1183 const struct wined3d_shader_reg_maps
*reg_maps
;
1184 struct wined3d_string_buffer
*buffer
;
1185 struct wined3d_shader_tex_mx
*tex_mx
;
1186 struct wined3d_shader_parser_state
*state
;
1190 struct wined3d_shader_register_index
1192 const struct wined3d_shader_src_param
*rel_addr
;
1193 unsigned int offset
;
1196 struct wined3d_shader_register
1198 enum wined3d_shader_register_type type
;
1199 enum wined3d_data_type data_type
;
1200 struct wined3d_shader_register_index idx
[2];
1201 enum wined3d_immconst_type immconst_type
;
1204 unsigned int immconst_data
[4];
1205 unsigned fp_body_idx
;
1209 struct wined3d_shader_dst_param
1211 struct wined3d_shader_register reg
;
1212 uint32_t write_mask
;
1217 struct wined3d_shader_src_param
1219 struct wined3d_shader_register reg
;
1221 enum wined3d_shader_src_modifier modifiers
;
1224 struct wined3d_shader_index_range
1226 struct wined3d_shader_dst_param first_register
;
1227 unsigned int last_register
;
1230 struct wined3d_shader_semantic
1232 enum wined3d_decl_usage usage
;
1234 enum wined3d_shader_resource_type resource_type
;
1235 unsigned int sample_count
;
1236 enum wined3d_data_type resource_data_type
;
1237 struct wined3d_shader_dst_param reg
;
1240 enum wined3d_shader_input_sysval_semantic
1242 WINED3D_SIV_POSITION
= 1,
1243 WINED3D_SIV_CLIP_DISTANCE
= 2,
1244 WINED3D_SIV_CULL_DISTANCE
= 3,
1245 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX
= 4,
1246 WINED3D_SIV_VIEWPORT_ARRAY_INDEX
= 5,
1247 WINED3D_SIV_VERTEX_ID
= 6,
1248 WINED3D_SIV_PRIMITIVE_ID
= 7,
1249 WINED3D_SIV_INSTANCE_ID
= 8,
1250 WINED3D_SIV_IS_FRONT_FACE
= 9,
1251 WINED3D_SIV_SAMPLE_INDEX
= 10,
1252 WINED3D_SIV_QUAD_U0_TESS_FACTOR
= 11,
1253 WINED3D_SIV_QUAD_V0_TESS_FACTOR
= 12,
1254 WINED3D_SIV_QUAD_U1_TESS_FACTOR
= 13,
1255 WINED3D_SIV_QUAD_V1_TESS_FACTOR
= 14,
1256 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR
= 15,
1257 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR
= 16,
1258 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR
= 17,
1259 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR
= 18,
1260 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR
= 19,
1261 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR
= 20,
1262 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR
= 21,
1263 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR
= 22,
1266 struct wined3d_shader_register_semantic
1268 struct wined3d_shader_dst_param reg
;
1269 enum wined3d_shader_input_sysval_semantic sysval_semantic
;
1272 struct wined3d_shader_structured_resource
1274 struct wined3d_shader_dst_param reg
;
1275 unsigned int byte_stride
;
1278 struct wined3d_shader_tgsm
1281 unsigned int stride
;
1284 struct wined3d_shader_tgsm_raw
1286 struct wined3d_shader_dst_param reg
;
1287 unsigned int byte_count
;
1290 struct wined3d_shader_tgsm_structured
1292 struct wined3d_shader_dst_param reg
;
1293 unsigned int byte_stride
;
1294 unsigned int structure_count
;
1297 struct wined3d_shader_thread_group_size
1299 unsigned int x
, y
, z
;
1302 struct wined3d_shader_function_table_pointer
1305 unsigned int array_size
;
1306 unsigned int body_count
;
1307 unsigned int table_count
;
1310 struct wined3d_shader_texel_offset
1312 signed char u
, v
, w
;
1315 struct wined3d_shader_primitive_type
1317 enum wined3d_primitive_type type
;
1318 unsigned int patch_vertex_count
;
1321 struct wined3d_shader_instruction
1323 const struct wined3d_shader_context
*ctx
;
1324 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
1326 unsigned int dst_count
;
1327 unsigned int src_count
;
1328 const struct wined3d_shader_dst_param
*dst
;
1329 const struct wined3d_shader_src_param
*src
;
1330 struct wined3d_shader_texel_offset texel_offset
;
1331 enum wined3d_shader_resource_type resource_type
;
1332 enum wined3d_data_type resource_data_type
;
1334 const struct wined3d_shader_src_param
*predicate
;
1337 struct wined3d_shader_semantic semantic
;
1338 struct wined3d_shader_register_semantic register_semantic
;
1339 struct wined3d_shader_primitive_type primitive_type
;
1340 struct wined3d_shader_dst_param dst
;
1341 struct wined3d_shader_src_param src
;
1344 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1345 struct wined3d_shader_structured_resource structured_resource
;
1346 struct wined3d_shader_tgsm_raw tgsm_raw
;
1347 struct wined3d_shader_tgsm_structured tgsm_structured
;
1348 struct wined3d_shader_thread_group_size thread_group_size
;
1349 enum wined3d_tessellator_domain tessellator_domain
;
1350 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1351 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1352 float max_tessellation_factor
;
1353 struct wined3d_shader_index_range index_range
;
1354 struct wined3d_shader_indexable_temp indexable_temp
;
1355 struct wined3d_shader_function_table_pointer fp
;
1359 static inline BOOL
wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction
*ins
)
1361 return ins
->texel_offset
.u
|| ins
->texel_offset
.v
|| ins
->texel_offset
.w
;
1364 struct wined3d_shader_attribute
1366 enum wined3d_decl_usage usage
;
1370 struct wined3d_shader_loop_control
1377 struct wined3d_shader_frontend
1379 void *(*shader_init
)(const DWORD
*byte_code
, size_t byte_code_size
,
1380 const struct wined3d_shader_signature
*output_signature
);
1381 void (*shader_free
)(void *data
);
1382 void (*shader_read_header
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
);
1383 void (*shader_read_instruction
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
);
1384 BOOL (*shader_is_end
)(void *data
, const DWORD
**ptr
);
1387 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN
;
1388 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN
;
1390 HRESULT
wined3d_shader_extract_from_dxbc(struct wined3d_shader
*shader
,
1391 unsigned int max_shader_version
, enum vkd3d_shader_source_type
*source_type
) DECLSPEC_HIDDEN
;
1392 BOOL
shader_get_stream_output_register_info(const struct wined3d_shader
*shader
,
1393 const struct wined3d_stream_output_element
*so_element
, unsigned int *register_idx
,
1394 unsigned int *component_idx
) DECLSPEC_HIDDEN
;
1396 typedef void (*SHADER_HANDLER
)(const struct wined3d_shader_instruction
*);
1398 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1399 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1400 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1401 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1402 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1406 unsigned int vs_version
;
1407 unsigned int hs_version
;
1408 unsigned int ds_version
;
1409 unsigned int gs_version
;
1410 unsigned int ps_version
;
1411 unsigned int cs_version
;
1413 unsigned int vs_uniform_count
;
1414 unsigned int ps_uniform_count
;
1415 float ps_1x_max_value
;
1416 unsigned int varying_count
;
1421 enum wined3d_gl_resource_type
1423 WINED3D_GL_RES_TYPE_TEX_1D
= 0,
1424 WINED3D_GL_RES_TYPE_TEX_2D
= 1,
1425 WINED3D_GL_RES_TYPE_TEX_3D
= 2,
1426 WINED3D_GL_RES_TYPE_TEX_CUBE
= 3,
1427 WINED3D_GL_RES_TYPE_TEX_RECT
= 4,
1428 WINED3D_GL_RES_TYPE_BUFFER
= 5,
1429 WINED3D_GL_RES_TYPE_RB
= 6,
1430 WINED3D_GL_RES_TYPE_COUNT
= 7,
1433 enum wined3d_vertex_processing_mode
1436 WINED3D_VP_MODE_SHADER
,
1437 WINED3D_VP_MODE_NONE
,
1440 #define WINED3D_CONST_NUM_UNUSED ~0U
1442 enum wined3d_ffp_ps_fog_mode
1444 WINED3D_FFP_PS_FOG_OFF
,
1445 WINED3D_FFP_PS_FOG_LINEAR
,
1446 WINED3D_FFP_PS_FOG_EXP
,
1447 WINED3D_FFP_PS_FOG_EXP2
,
1450 /* Stateblock dependent parameters which have to be hardcoded
1451 * into the shader code
1454 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1455 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1456 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1457 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1458 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1460 /* Used for Shader Model 1 pixel shaders to track the bound texture
1461 * type. 2D and RECT textures are separated through NP2 fixup. */
1462 enum wined3d_shader_tex_types
1464 WINED3D_SHADER_TEX_2D
= 0,
1465 WINED3D_SHADER_TEX_3D
= 1,
1466 WINED3D_SHADER_TEX_CUBE
= 2,
1467 WINED3D_SHADER_TEX_ERR
= 3,
1470 struct ps_compile_args
1472 struct color_fixup_desc color_fixup
[WINED3D_MAX_FRAGMENT_SAMPLERS
];
1473 enum wined3d_vertex_processing_mode vp_mode
;
1474 enum wined3d_ffp_ps_fog_mode fog
;
1475 DWORD tex_types
; /* ps 1 - 3, 16 textures */
1476 WORD tex_transform
; /* ps 1.0-1.3, 4 textures */
1477 WORD srgb_correction
;
1478 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1479 D3D9 has a limit of 16 samplers and the fixup is superfluous
1480 in D3D10 (unconditional NP2 support mandatory). */
1482 WORD shadow
; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1483 WORD texcoords_initialized
; /* WINED3D_MAX_TEXTURES, 8 */
1484 WORD padding_to_dword
;
1485 DWORD pointsprite
: 1;
1486 DWORD flatshading
: 1;
1487 DWORD alpha_test_func
: 3;
1488 DWORD y_correction
: 1;
1489 DWORD rt_alpha_swizzle
: 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1490 DWORD dual_source_blend
: 1;
1500 struct vs_compile_args
1502 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1503 unsigned int next_shader_input_count
;
1504 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1506 BYTE clip_enabled
: 1;
1507 BYTE point_size
: 1;
1508 BYTE per_vertex_point_size
: 1;
1509 BYTE flatshading
: 1;
1510 BYTE next_shader_type
: 3;
1514 struct ds_compile_args
1516 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1517 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1518 unsigned int output_count
: 16;
1519 unsigned int next_shader_type
: 3;
1520 unsigned int render_offscreen
: 1;
1521 unsigned int padding
: 12;
1522 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1525 struct gs_compile_args
1527 unsigned int output_count
;
1528 enum wined3d_primitive_type primitive_type
;
1529 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1532 struct wined3d_shader_backend_ops
1534 void (*shader_handle_instruction
)(const struct wined3d_shader_instruction
*);
1535 void (*shader_precompile
)(void *shader_priv
, struct wined3d_shader
*shader
);
1536 void (*shader_select
)(void *shader_priv
, struct wined3d_context
*context
,
1537 const struct wined3d_state
*state
);
1538 void (*shader_select_compute
)(void *shader_priv
, struct wined3d_context
*context
,
1539 const struct wined3d_state
*state
);
1540 void (*shader_disable
)(void *shader_priv
, struct wined3d_context
*context
);
1541 void (*shader_update_float_vertex_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1542 void (*shader_update_float_pixel_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1543 void (*shader_load_constants
)(void *shader_priv
, struct wined3d_context
*context
,
1544 const struct wined3d_state
*state
);
1545 void (*shader_destroy
)(struct wined3d_shader
*shader
);
1546 HRESULT (*shader_alloc_private
)(struct wined3d_device
*device
, const struct wined3d_vertex_pipe_ops
*vertex_pipe
,
1547 const struct wined3d_fragment_pipe_ops
*fragment_pipe
);
1548 void (*shader_free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
1549 BOOL (*shader_allocate_context_data
)(struct wined3d_context
*context
);
1550 void (*shader_free_context_data
)(struct wined3d_context
*context
);
1551 void (*shader_init_context_state
)(struct wined3d_context
*context
);
1552 void (*shader_get_caps
)(const struct wined3d_adapter
*adapter
, struct shader_caps
*caps
);
1553 BOOL (*shader_color_fixup_supported
)(struct color_fixup_desc fixup
);
1554 BOOL (*shader_has_ffp_proj_control
)(void *shader_priv
);
1555 uint64_t (*shader_compile
)(struct wined3d_context
*context
, const struct wined3d_shader_desc
*shader_desc
,
1556 enum wined3d_shader_type shader_type
);
1559 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN
;
1560 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN
;
1561 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN
;
1563 const struct wined3d_shader_backend_ops
*wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN
;
1565 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1567 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1568 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1569 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1570 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1572 static inline void wined3d_color_from_d3dcolor(struct wined3d_color
*wined3d_color
, DWORD d3d_color
)
1574 wined3d_color
->r
= D3DCOLOR_B_R(d3d_color
) / 255.0f
;
1575 wined3d_color
->g
= D3DCOLOR_B_G(d3d_color
) / 255.0f
;
1576 wined3d_color
->b
= D3DCOLOR_B_B(d3d_color
) / 255.0f
;
1577 wined3d_color
->a
= D3DCOLOR_B_A(d3d_color
) / 255.0f
;
1580 extern const struct wined3d_vec4 wined3d_srgb_const
[] DECLSPEC_HIDDEN
;
1582 static inline float wined3d_srgb_from_linear(float colour
)
1586 if (colour
< wined3d_srgb_const
[1].x
)
1587 return colour
* wined3d_srgb_const
[0].w
;
1589 return wined3d_srgb_const
[0].y
* powf(colour
, wined3d_srgb_const
[0].x
) - wined3d_srgb_const
[0].z
;
1593 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color
*colour_srgb
,
1594 const struct wined3d_color
*colour
)
1596 colour_srgb
->r
= wined3d_srgb_from_linear(colour
->r
);
1597 colour_srgb
->g
= wined3d_srgb_from_linear(colour
->g
);
1598 colour_srgb
->b
= wined3d_srgb_from_linear(colour
->b
);
1599 colour_srgb
->a
= colour
->a
;
1604 /* client_map_count and map_ptr are accessed from both the client and CS
1605 * threads, and protected by wined3d_device.bo_map_lock. */
1608 size_t buffer_offset
;
1609 size_t memory_offset
;
1610 unsigned int client_map_count
;
1614 struct wined3d_bo_user
1620 struct wined3d_bo_address
1622 struct wined3d_bo
*buffer_object
;
1626 struct wined3d_const_bo_address
1628 struct wined3d_bo
*buffer_object
;
1632 static inline struct wined3d_const_bo_address
*wined3d_const_bo_address(const struct wined3d_bo_address
*data
)
1634 return (struct wined3d_const_bo_address
*)data
;
1637 struct wined3d_stream_info_element
1639 const struct wined3d_format
*format
;
1640 struct wined3d_bo_address data
;
1641 unsigned int stride
;
1642 unsigned int stream_idx
;
1643 unsigned int divisor
;
1647 struct wined3d_stream_info
1649 struct wined3d_stream_info_element elements
[MAX_ATTRIBS
];
1650 DWORD position_transformed
: 1;
1652 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1653 DWORD use_map
; /* MAX_ATTRIBS, 32 */
1656 void wined3d_stream_info_from_declaration(struct wined3d_stream_info
*stream_info
,
1657 const struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
) DECLSPEC_HIDDEN
;
1659 struct wined3d_direct_dispatch_parameters
1661 unsigned int group_count_x
;
1662 unsigned int group_count_y
;
1663 unsigned int group_count_z
;
1666 struct wined3d_indirect_dispatch_parameters
1668 struct wined3d_buffer
*buffer
;
1669 unsigned int offset
;
1672 struct wined3d_dispatch_parameters
1677 struct wined3d_direct_dispatch_parameters direct
;
1678 struct wined3d_indirect_dispatch_parameters indirect
;
1682 struct wined3d_direct_draw_parameters
1684 int base_vertex_idx
;
1685 unsigned int start_idx
;
1686 unsigned int index_count
;
1687 unsigned int start_instance
;
1688 unsigned int instance_count
;
1691 struct wined3d_indirect_draw_parameters
1693 struct wined3d_buffer
*buffer
;
1694 unsigned int offset
;
1697 struct wined3d_draw_parameters
1702 struct wined3d_direct_draw_parameters direct
;
1703 struct wined3d_indirect_draw_parameters indirect
;
1708 void draw_primitive(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1709 const struct wined3d_draw_parameters
*draw_parameters
) DECLSPEC_HIDDEN
;
1710 void dispatch_compute(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1711 const struct wined3d_dispatch_parameters
*dispatch_parameters
) DECLSPEC_HIDDEN
;
1715 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1716 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1718 /* Routines and structures related to state management */
1720 #define STATE_RENDER(a) (a)
1721 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1723 #define STATE_TEXTURESTAGE(stage, num) \
1724 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1725 #define STATE_IS_TEXTURESTAGE(a) \
1726 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1728 /* + 1 because samplers start with 0 */
1729 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1730 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1732 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1733 #define STATE_IS_GRAPHICS_SHADER(a) \
1734 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1736 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1737 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1738 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1739 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1741 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1742 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1744 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1745 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1747 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1748 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1750 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1751 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1752 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1753 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1755 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1756 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1758 #define STATE_VIEWPORT (STATE_VDECL + 1)
1759 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1761 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1762 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1763 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1764 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1766 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1767 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1769 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1770 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1772 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1773 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1775 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1776 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1778 #define STATE_DEPTH_BOUNDS (STATE_RASTERIZER + 1)
1779 #define STATE_IS_DEPTH_BOUNDS(a) ((a) == STATE_DEPTH_BOUNDS)
1781 #define STATE_POINTSPRITECOORDORIGIN (STATE_DEPTH_BOUNDS + 1)
1782 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1784 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1785 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1787 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1788 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1790 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1791 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1793 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1794 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1796 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1797 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1799 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1800 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1802 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1803 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1805 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1806 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1808 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1809 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1811 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1812 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1814 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1816 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1817 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1819 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1820 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1822 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1823 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1825 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1826 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1828 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1829 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1831 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1832 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1834 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1835 #define STATE_CONSTANT_BUFFER(a) \
1836 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1837 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1838 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1846 /* Direct3D terminology with little modifications. We do not have an issued
1847 * state because only the driver knows about it, but we have a created state
1848 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1849 enum wined3d_query_state
1856 struct wined3d_query_ops
1858 BOOL (*query_poll
)(struct wined3d_query
*query
, uint32_t flags
);
1859 BOOL (*query_issue
)(struct wined3d_query
*query
, uint32_t flags
);
1860 void (*query_destroy
)(struct wined3d_query
*query
);
1863 struct wined3d_query
1868 const struct wined3d_parent_ops
*parent_ops
;
1869 struct wined3d_device
*device
;
1870 enum wined3d_query_state state
;
1871 enum wined3d_query_type type
;
1874 const struct wined3d_query_ops
*query_ops
;
1876 LONG counter_main
, counter_retrieved
;
1877 struct list poll_list_entry
;
1879 /* FIXME: This is GL-specific. */
1880 unsigned int buffer_object
;
1885 #define WINED3D_QUERY_POOL_SIZE 256
1887 struct wined3d_range
1889 unsigned int offset
;
1893 #include "wined3d_gl.h"
1895 struct wined3d_fb_state
1897 struct wined3d_rendertarget_view
*render_targets
[WINED3D_MAX_RENDER_TARGETS
];
1898 struct wined3d_rendertarget_view
*depth_stencil
;
1901 #define MAX_GL_FRAGMENT_SAMPLERS 32
1903 struct wined3d_context
1905 const struct wined3d_d3d_info
*d3d_info
;
1906 const struct wined3d_state_entry
*state_table
;
1907 uint32_t dirty_graphics_states
[WINED3D_BITMAP_SIZE(STATE_HIGHEST
)];
1908 uint32_t dirty_compute_states
[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT
)];
1910 struct wined3d_device
*device
;
1911 struct wined3d_swapchain
*swapchain
;
1914 struct wined3d_texture
*texture
;
1915 unsigned int sub_resource_idx
;
1918 /* Stores some information about the context state for optimization */
1919 DWORD last_swizzle_map
; /* MAX_ATTRIBS, 32 */
1921 DWORD shader_update_mask
: 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1922 DWORD update_shader_resource_bindings
: 1;
1923 DWORD update_compute_shader_resource_bindings
: 1;
1924 DWORD update_unordered_access_view_bindings
: 1;
1925 DWORD update_compute_unordered_access_view_bindings
: 1;
1926 DWORD last_was_rhw
: 1; /* True iff last draw_primitive was in xyzrhw mode. */
1927 DWORD last_was_pshader
: 1;
1928 DWORD last_was_vshader
: 1;
1929 DWORD last_was_diffuse
: 1;
1930 DWORD last_was_specular
: 1;
1931 DWORD last_was_normal
: 1;
1932 DWORD last_was_ffp_blit
: 1;
1933 DWORD last_was_blit
: 1;
1934 DWORD last_was_ckey
: 1;
1935 DWORD last_was_dual_source_blend
: 1;
1936 DWORD texShaderBumpMap
: 8; /* WINED3D_MAX_TEXTURES, 8 */
1937 DWORD lowest_disabled_stage
: 4; /* Max WINED3D_MAX_TEXTURES, 8 */
1939 DWORD lastWasPow2Texture
: 8; /* WINED3D_MAX_TEXTURES, 8 */
1940 DWORD fixed_function_usage_map
: 8; /* WINED3D_MAX_TEXTURES, 8 */
1941 DWORD use_immediate_mode_draw
: 1;
1942 DWORD uses_uavs
: 1;
1943 DWORD uses_fbo_attached_resources
: 1;
1944 DWORD transform_feedback_active
: 1;
1945 DWORD transform_feedback_paused
: 1;
1946 DWORD fog_coord
: 1;
1947 DWORD render_offscreen
: 1;
1949 DWORD destroyed
: 1;
1950 DWORD destroy_delayed
: 1;
1951 DWORD namedArraysLoaded
: 1;
1954 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1956 DWORD constant_update_mask
;
1957 DWORD numbered_array_mask
;
1958 enum fogsource fog_source
;
1961 void *shader_backend_data
;
1962 void *fragment_pipe_data
;
1964 struct wined3d_stream_info stream_info
;
1966 unsigned int viewport_count
;
1967 unsigned int scissor_rect_count
;
1970 void wined3d_context_cleanup(struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
1971 void wined3d_context_init(struct wined3d_context
*context
, struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
1972 void context_preload_textures(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
1973 void context_update_stream_info(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
1975 HRESULT
wined3d_context_no3d_init(struct wined3d_context
*context_no3d
,
1976 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
1978 struct wined3d_command_fence_gl
1981 struct wined3d_fence
*fence
;
1984 struct wined3d_context_gl
1986 struct wined3d_context c
;
1988 const struct wined3d_gl_info
*gl_info
;
1990 DWORD tid
; /* Thread ID which owns this context at the moment. */
1992 uint32_t dc_is_private
: 1;
1993 uint32_t dc_has_format
: 1; /* Only meaningful for private DCs. */
1994 uint32_t fog_enabled
: 1;
1995 uint32_t diffuse_attrib_to_1
: 1;
1996 uint32_t rebind_fbo
: 1;
1997 uint32_t untracked_material_count
: 2; /* Max value 2 */
1998 uint32_t needs_set
: 1;
1999 uint32_t internal_format_set
: 1;
2001 uint32_t padding
: 22;
2003 uint32_t default_attrib_value_set
;
2005 GLenum tracking_parm
; /* Which source is tracking current colour. */
2006 GLenum untracked_materials
[2];
2008 unsigned int active_texture
;
2010 GLenum
*texture_type
;
2012 /* The WGL context. */
2017 HWND restore_pf_win
;
2025 unsigned int fbo_entry_count
;
2026 struct list fbo_list
;
2027 struct list fbo_destroy_list
;
2028 struct fbo_entry
*current_fbo
;
2029 GLuint fbo_read_binding
;
2030 GLuint fbo_draw_binding
;
2031 struct wined3d_rendertarget_info blit_targets
[WINED3D_MAX_RENDER_TARGETS
];
2032 uint32_t draw_buffers_mask
; /* Enabled draw buffers, 31 max. */
2035 struct list occlusion_queries
;
2037 struct list timestamp_queries
;
2038 struct list so_statistics_queries
;
2039 struct list pipeline_statistics_queries
;
2041 GLuint
*free_occlusion_queries
;
2042 SIZE_T free_occlusion_query_size
;
2043 unsigned int free_occlusion_query_count
;
2045 union wined3d_gl_fence_object
*free_fences
;
2046 SIZE_T free_fence_size
;
2047 unsigned int free_fence_count
;
2049 GLuint
*free_timestamp_queries
;
2050 SIZE_T free_timestamp_query_size
;
2051 unsigned int free_timestamp_query_count
;
2053 union wined3d_gl_so_statistics_query
*free_so_statistics_queries
;
2054 SIZE_T free_so_statistics_query_size
;
2055 unsigned int free_so_statistics_query_count
;
2057 union wined3d_gl_pipeline_statistics_query
*free_pipeline_statistics_queries
;
2058 SIZE_T free_pipeline_statistics_query_size
;
2059 unsigned int free_pipeline_statistics_query_count
;
2063 unsigned int tex_unit_map
[WINED3D_MAX_COMBINED_SAMPLERS
];
2064 unsigned int rev_tex_unit_map
[MAX_GL_FRAGMENT_SAMPLERS
+ WINED3D_MAX_VERTEX_SAMPLERS
];
2066 /* Extension emulation. */
2067 GLint gl_fog_source
;
2068 GLfloat fog_coord_value
;
2069 GLfloat colour
[4], fog_start
, fog_end
, fog_colour
[4];
2071 GLuint dummy_arbfp_prog
;
2075 struct wined3d_command_fence_gl
*fences
;
2081 static inline struct wined3d_context_gl
*wined3d_context_gl(struct wined3d_context
*context
)
2083 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
2086 static inline const struct wined3d_context_gl
*wined3d_context_gl_const(const struct wined3d_context
*context
)
2088 return CONTAINING_RECORD(context
, struct wined3d_context_gl
, c
);
2091 struct wined3d_context
*wined3d_context_gl_acquire(const struct wined3d_device
*device
,
2092 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2093 void wined3d_context_gl_active_texture(struct wined3d_context_gl
*context_gl
,
2094 const struct wined3d_gl_info
*gl_info
, unsigned int unit
) DECLSPEC_HIDDEN
;
2095 void wined3d_context_gl_alloc_fence(struct wined3d_context_gl
*context_gl
,
2096 struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2097 void wined3d_context_gl_alloc_occlusion_query(struct wined3d_context_gl
*context_gl
,
2098 struct wined3d_occlusion_query
*query
) DECLSPEC_HIDDEN
;
2099 void wined3d_context_gl_alloc_pipeline_statistics_query(struct wined3d_context_gl
*context_gl
,
2100 struct wined3d_pipeline_statistics_query
*query
) DECLSPEC_HIDDEN
;
2101 void wined3d_context_gl_alloc_so_statistics_query(struct wined3d_context_gl
*context_gl
,
2102 struct wined3d_so_statistics_query
*query
) DECLSPEC_HIDDEN
;
2103 void wined3d_context_gl_alloc_timestamp_query(struct wined3d_context_gl
*context_gl
,
2104 struct wined3d_timestamp_query
*query
) DECLSPEC_HIDDEN
;
2105 GLuint
wined3d_context_gl_allocate_vram_chunk_buffer(struct wined3d_context_gl
*context_gl
,
2106 unsigned int pool
, size_t size
) DECLSPEC_HIDDEN
;
2107 void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl
*context_gl
,
2108 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2109 BOOL
wined3d_context_gl_apply_clear_state(struct wined3d_context_gl
*context_gl
, const struct wined3d_state
*state
,
2110 unsigned int rt_count
, const struct wined3d_fb_state
*fb
) DECLSPEC_HIDDEN
;
2111 void wined3d_context_gl_apply_fbo_state_blit(struct wined3d_context_gl
*context_gl
, GLenum target
,
2112 struct wined3d_resource
*rt
, unsigned int rt_sub_resource_idx
,
2113 struct wined3d_resource
*ds
, unsigned int ds_sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
2114 void wined3d_context_gl_apply_ffp_blit_state(struct wined3d_context_gl
*context_gl
,
2115 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2116 void wined3d_context_gl_bind_bo(struct wined3d_context_gl
*context_gl
, GLenum binding
, GLuint name
) DECLSPEC_HIDDEN
;
2117 void wined3d_context_gl_bind_dummy_textures(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2118 void wined3d_context_gl_bind_texture(struct wined3d_context_gl
*context_gl
,
2119 GLenum target
, GLuint name
) DECLSPEC_HIDDEN
;
2120 void wined3d_context_gl_check_fbo_status(const struct wined3d_context_gl
*context_gl
, GLenum target
) DECLSPEC_HIDDEN
;
2121 void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl
*context_gl
,
2122 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
2123 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
) DECLSPEC_HIDDEN
;
2124 void wined3d_context_gl_destroy(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2125 void wined3d_context_gl_destroy_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo
) DECLSPEC_HIDDEN
;
2126 void wined3d_context_gl_draw_shaded_quad(struct wined3d_context_gl
*context_gl
, struct wined3d_texture_gl
*texture_gl
,
2127 unsigned int sub_resource_idx
, const RECT
*src_rect
, const RECT
*dst_rect
,
2128 enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
2129 void wined3d_context_gl_draw_textured_quad(struct wined3d_context_gl
*context_gl
,
2130 struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
2131 const RECT
*src_rect
, const RECT
*dst_rect
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
2132 void wined3d_context_gl_enable_clip_distances(struct wined3d_context_gl
*context_gl
, uint32_t mask
) DECLSPEC_HIDDEN
;
2133 void wined3d_context_gl_end_transform_feedback(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2134 void wined3d_context_gl_flush_bo_address(struct wined3d_context_gl
*context_gl
,
2135 const struct wined3d_const_bo_address
*data
, size_t size
) DECLSPEC_HIDDEN
;
2136 void wined3d_context_gl_free_fence(struct wined3d_fence
*fence
) DECLSPEC_HIDDEN
;
2137 void wined3d_context_gl_free_occlusion_query(struct wined3d_occlusion_query
*query
) DECLSPEC_HIDDEN
;
2138 void wined3d_context_gl_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query
*query
) DECLSPEC_HIDDEN
;
2139 void wined3d_context_gl_free_so_statistics_query(struct wined3d_so_statistics_query
*query
) DECLSPEC_HIDDEN
;
2140 void wined3d_context_gl_free_timestamp_query(struct wined3d_timestamp_query
*query
) DECLSPEC_HIDDEN
;
2141 struct wined3d_context_gl
*wined3d_context_gl_get_current(void) DECLSPEC_HIDDEN
;
2142 GLenum
wined3d_context_gl_get_offscreen_gl_buffer(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2143 const unsigned int *wined3d_context_gl_get_tex_unit_mapping(const struct wined3d_context_gl
*context_gl
,
2144 const struct wined3d_shader_version
*shader_version
, unsigned int *base
, unsigned int *count
) DECLSPEC_HIDDEN
;
2145 HRESULT
wined3d_context_gl_init(struct wined3d_context_gl
*context_gl
,
2146 struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
2147 void wined3d_context_gl_load_tex_coords(const struct wined3d_context_gl
*context_gl
,
2148 const struct wined3d_stream_info
*si
, GLuint
*current_bo
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2149 void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl
*context_gl
,
2150 const struct wined3d_bo_address
*data
, size_t size
, uint32_t flags
) DECLSPEC_HIDDEN
;
2151 struct wined3d_context_gl
*wined3d_context_gl_reacquire(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2152 void wined3d_context_gl_release(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2153 BOOL
wined3d_context_gl_set_current(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2154 void wined3d_context_gl_submit_command_fence(struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2155 void wined3d_context_gl_texture_update(struct wined3d_context_gl
*context_gl
,
2156 const struct wined3d_texture_gl
*texture_gl
) DECLSPEC_HIDDEN
;
2157 void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
2158 void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl
*context_gl
, const struct wined3d_bo_address
*data
,
2159 unsigned int range_count
, const struct wined3d_range
*ranges
) DECLSPEC_HIDDEN
;
2160 void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl
*context_gl
,
2161 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2162 void wined3d_context_gl_wait_command_fence(struct wined3d_context_gl
*context_gl
, uint64_t id
) DECLSPEC_HIDDEN
;
2164 typedef void (*APPLYSTATEFUNC
)(struct wined3d_context
*ctx
, const struct wined3d_state
*state
, DWORD state_id
);
2166 struct wined3d_state_entry
2168 unsigned int representative
;
2169 APPLYSTATEFUNC apply
;
2172 struct wined3d_state_entry_template
2175 struct wined3d_state_entry content
;
2176 unsigned int extension
;
2179 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2180 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2181 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2183 struct fragment_caps
2186 DWORD PrimitiveMiscCaps
;
2187 DWORD TextureOpCaps
;
2188 DWORD MaxTextureBlendStages
;
2189 DWORD MaxSimultaneousTextures
;
2192 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2193 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2195 struct wined3d_fragment_pipe_ops
2197 void (*fp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2198 void (*get_caps
)(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
);
2199 unsigned int (*get_emul_mask
)(const struct wined3d_gl_info
*gl_info
);
2200 void *(*alloc_private
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2201 void (*free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2202 BOOL (*allocate_context_data
)(struct wined3d_context
*context
);
2203 void (*free_context_data
)(struct wined3d_context
*context
);
2204 BOOL (*color_fixup_supported
)(struct color_fixup_desc fixup
);
2205 const struct wined3d_state_entry_template
*states
;
2208 struct wined3d_vertex_caps
2211 BOOL emulated_flatshading
;
2212 BOOL ffp_generic_attributes
;
2213 DWORD max_active_lights
;
2214 DWORD max_vertex_blend_matrices
;
2215 DWORD max_vertex_blend_matrix_index
;
2216 DWORD vertex_processing_caps
;
2218 DWORD max_user_clip_planes
;
2222 struct wined3d_vertex_pipe_ops
2224 void (*vp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2225 void (*vp_get_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
);
2226 unsigned int (*vp_get_emul_mask
)(const struct wined3d_gl_info
*gl_info
);
2227 void *(*vp_alloc
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2228 void (*vp_free
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2229 const struct wined3d_state_entry_template
*vp_states
;
2232 extern const struct wined3d_state_entry_template misc_state_template_gl
[] DECLSPEC_HIDDEN
;
2233 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN
;
2234 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN
;
2235 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN
;
2236 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN
;
2237 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN
;
2238 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN
;
2239 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN
;
2241 const struct wined3d_fragment_pipe_ops
*wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2243 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN
;
2244 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN
;
2245 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN
;
2247 const struct wined3d_vertex_pipe_ops
*wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2249 /* "Base" state table */
2250 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
2251 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
2252 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
2253 const struct wined3d_state_entry_template
*misc
) DECLSPEC_HIDDEN
;
2255 enum wined3d_blit_op
2257 WINED3D_BLIT_OP_COLOR_BLIT
,
2258 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
,
2259 WINED3D_BLIT_OP_COLOR_BLIT_CKEY
,
2260 WINED3D_BLIT_OP_DEPTH_BLIT
,
2261 WINED3D_BLIT_OP_RAW_BLIT
,
2264 struct wined3d_blitter
2266 const struct wined3d_blitter_ops
*ops
;
2267 struct wined3d_blitter
*next
;
2270 struct wined3d_blitter_ops
2272 void (*blitter_destroy
)(struct wined3d_blitter
*blitter
, struct wined3d_context
*context
);
2273 void (*blitter_clear
)(struct wined3d_blitter
*blitter
, struct wined3d_device
*device
,
2274 unsigned int rt_count
, const struct wined3d_fb_state
*fb
, unsigned int rect_count
, const RECT
*clear_rects
,
2275 const RECT
*draw_rect
, uint32_t flags
, const struct wined3d_color
*colour
, float depth
, unsigned int stencil
);
2276 DWORD (*blitter_blit
)(struct wined3d_blitter
*blitter
, enum wined3d_blit_op op
, struct wined3d_context
*context
,
2277 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
, DWORD src_location
,
2278 const RECT
*src_rect
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
2279 DWORD dst_location
, const RECT
*dst_rect
, const struct wined3d_color_key
*colour_key
,
2280 enum wined3d_texture_filter_type filter
, const struct wined3d_format
*resolve_format
);
2283 void wined3d_arbfp_blitter_create(struct wined3d_blitter
**next
,
2284 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2285 struct wined3d_blitter
*wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN
;
2286 void wined3d_fbo_blitter_create(struct wined3d_blitter
**next
,
2287 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2288 void wined3d_ffp_blitter_create(struct wined3d_blitter
**next
,
2289 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2290 struct wined3d_blitter
*wined3d_glsl_blitter_create(struct wined3d_blitter
**next
,
2291 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
2292 void wined3d_raw_blitter_create(struct wined3d_blitter
**next
,
2293 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
2294 void wined3d_vk_blitter_create(struct wined3d_blitter
**next
) DECLSPEC_HIDDEN
;
2296 BOOL
wined3d_clip_blit(const RECT
*clip_rect
, RECT
*clipped
, RECT
*other
) DECLSPEC_HIDDEN
;
2298 HGLRC
context_create_wgl_attribs(const struct wined3d_gl_info
*gl_info
, HDC hdc
, HGLRC share_ctx
) DECLSPEC_HIDDEN
;
2299 DWORD
context_get_tls_idx(void) DECLSPEC_HIDDEN
;
2300 void context_gl_apply_texture_draw_state(struct wined3d_context_gl
*context_gl
,
2301 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
, unsigned int location
);
2302 void context_gl_resource_released(struct wined3d_device
*device
,
2303 GLuint name
, BOOL rb_namespace
) DECLSPEC_HIDDEN
;
2304 void context_invalidate_compute_state(struct wined3d_context
*context
, DWORD state_id
) DECLSPEC_HIDDEN
;
2305 void context_invalidate_state(struct wined3d_context
*context
, unsigned int state_id
) DECLSPEC_HIDDEN
;
2306 void context_resource_released(const struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
2307 void context_restore(struct wined3d_context
*context
, struct wined3d_texture
*texture
,
2308 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2309 void context_set_tls_idx(DWORD idx
) DECLSPEC_HIDDEN
;
2310 void context_state_drawbuf(struct wined3d_context
*context
,
2311 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2312 void context_state_fb(struct wined3d_context
*context
,
2313 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2315 /*****************************************************************************
2316 * Internal representation of a light
2318 struct wined3d_light_info
2320 struct wined3d_light OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
2321 unsigned int OriginalIndex
;
2325 /* Converted parms to speed up swapping lights */
2326 struct wined3d_vec4 position
;
2327 struct wined3d_vec4 direction
;
2331 struct rb_entry entry
;
2332 struct list changed_entry
;
2336 /* The default light parameters */
2337 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN
;
2339 struct wined3d_pixel_format
2341 int iPixelFormat
; /* WGL pixel format */
2342 int iPixelType
; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2343 int redSize
, greenSize
, blueSize
, alphaSize
, colorSize
;
2344 int depthSize
, stencilSize
;
2345 BOOL windowDrawable
;
2352 enum wined3d_pci_vendor
2354 HW_VENDOR_SOFTWARE
= 0x0000,
2355 HW_VENDOR_AMD
= 0x1002,
2356 HW_VENDOR_NVIDIA
= 0x10de,
2357 HW_VENDOR_VMWARE
= 0x15ad,
2358 HW_VENDOR_REDHAT
= 0x1af4,
2359 HW_VENDOR_INTEL
= 0x8086,
2362 enum wined3d_pci_device
2366 CARD_AMD_RAGE_128PRO
= 0x5246,
2367 CARD_AMD_RADEON_7200
= 0x5144,
2368 CARD_AMD_RADEON_8500
= 0x514c,
2369 CARD_AMD_RADEON_9500
= 0x4144,
2370 CARD_AMD_RADEON_XPRESS_200M
= 0x5955,
2371 CARD_AMD_RADEON_X700
= 0x5e4c,
2372 CARD_AMD_RADEON_X1600
= 0x71c2,
2373 CARD_AMD_RADEON_HD2350
= 0x94c7,
2374 CARD_AMD_RADEON_HD2600
= 0x9581,
2375 CARD_AMD_RADEON_HD2900
= 0x9400,
2376 CARD_AMD_RADEON_HD3200
= 0x9620,
2377 CARD_AMD_RADEON_HD3850
= 0x9515,
2378 CARD_AMD_RADEON_HD4200M
= 0x9712,
2379 CARD_AMD_RADEON_HD4350
= 0x954f,
2380 CARD_AMD_RADEON_HD4600
= 0x9495,
2381 CARD_AMD_RADEON_HD4700
= 0x944e,
2382 CARD_AMD_RADEON_HD4800
= 0x944c,
2383 CARD_AMD_RADEON_HD5400
= 0x68f9,
2384 CARD_AMD_RADEON_HD5600
= 0x68d8,
2385 CARD_AMD_RADEON_HD5700
= 0x68be,
2386 CARD_AMD_RADEON_HD5800
= 0x6898,
2387 CARD_AMD_RADEON_HD5900
= 0x689c,
2388 CARD_AMD_RADEON_HD6300
= 0x9803,
2389 CARD_AMD_RADEON_HD6400
= 0x6770,
2390 CARD_AMD_RADEON_HD6490M
= 0x6760,
2391 CARD_AMD_RADEON_HD6410D
= 0x9644,
2392 CARD_AMD_RADEON_HD6480G
= 0x9648,
2393 CARD_AMD_RADEON_HD6550D
= 0x9640,
2394 CARD_AMD_RADEON_HD6600
= 0x6758,
2395 CARD_AMD_RADEON_HD6600M
= 0x6741,
2396 CARD_AMD_RADEON_HD6700
= 0x68ba,
2397 CARD_AMD_RADEON_HD6800
= 0x6739,
2398 CARD_AMD_RADEON_HD6900
= 0x6719,
2399 CARD_AMD_RADEON_HD7660D
= 0x9901,
2400 CARD_AMD_RADEON_HD7700
= 0x683d,
2401 CARD_AMD_RADEON_HD7800
= 0x6819,
2402 CARD_AMD_RADEON_HD7870
= 0x6818,
2403 CARD_AMD_RADEON_HD7900
= 0x679a,
2404 CARD_AMD_RADEON_HD8600M
= 0x6660,
2405 CARD_AMD_RADEON_HD8670
= 0x6610,
2406 CARD_AMD_RADEON_HD8770
= 0x665c,
2407 CARD_AMD_RADEON_R3
= 0x9830,
2408 CARD_AMD_RADEON_R7
= 0x130f,
2409 CARD_AMD_RADEON_R9_285
= 0x6939,
2410 CARD_AMD_RADEON_R9_290
= 0x67b1,
2411 CARD_AMD_RADEON_R9_290X
= 0x67b0,
2412 CARD_AMD_RADEON_R9_FURY
= 0x7300,
2413 CARD_AMD_RADEON_R9_M370X
= 0x6821,
2414 CARD_AMD_RADEON_R9_M380
= 0x6647,
2415 CARD_AMD_RADEON_R9_M395X
= 0x6920,
2416 CARD_AMD_RADEON_RX_460
= 0x67ef,
2417 CARD_AMD_RADEON_RX_480
= 0x67df,
2418 CARD_AMD_RADEON_RX_VEGA_10
= 0x687f,
2419 CARD_AMD_RADEON_RX_VEGA_12
= 0x69af,
2420 CARD_AMD_RADEON_RAVEN
= 0x15dd,
2421 CARD_AMD_RADEON_RX_VEGA_20
= 0x66af,
2422 CARD_AMD_RADEON_RX_NAVI_10
= 0x731f,
2423 CARD_AMD_RADEON_RX_NAVI_14
= 0x7340,
2424 CARD_AMD_RADEON_RX_NAVI_21
= 0x73bf,
2425 CARD_AMD_RADEON_PRO_V620
= 0x73a1,
2426 CARD_AMD_RADEON_PRO_V620_VF
= 0x73ae,
2427 CARD_AMD_VANGOGH
= 0x163f,
2428 CARD_AMD_RAPHAEL
= 0x164e,
2430 CARD_NVIDIA_RIVA_128
= 0x0018,
2431 CARD_NVIDIA_RIVA_TNT
= 0x0020,
2432 CARD_NVIDIA_RIVA_TNT2
= 0x0028,
2433 CARD_NVIDIA_GEFORCE
= 0x0100,
2434 CARD_NVIDIA_GEFORCE2_MX
= 0x0110,
2435 CARD_NVIDIA_GEFORCE2
= 0x0150,
2436 CARD_NVIDIA_GEFORCE3
= 0x0200,
2437 CARD_NVIDIA_GEFORCE4_MX
= 0x0170,
2438 CARD_NVIDIA_GEFORCE4_TI4200
= 0x0253,
2439 CARD_NVIDIA_GEFORCEFX_5200
= 0x0320,
2440 CARD_NVIDIA_GEFORCEFX_5600
= 0x0312,
2441 CARD_NVIDIA_GEFORCEFX_5800
= 0x0302,
2442 CARD_NVIDIA_GEFORCE_6200
= 0x014f,
2443 CARD_NVIDIA_GEFORCE_6600GT
= 0x0140,
2444 CARD_NVIDIA_GEFORCE_6800
= 0x0041,
2445 CARD_NVIDIA_GEFORCE_7300
= 0x01d7, /* GeForce Go 7300 */
2446 CARD_NVIDIA_GEFORCE_7400
= 0x01d8,
2447 CARD_NVIDIA_GEFORCE_7600
= 0x0391,
2448 CARD_NVIDIA_GEFORCE_7800GT
= 0x0092,
2449 CARD_NVIDIA_GEFORCE_8200
= 0x0849, /* Other PCI ID 0x084b */
2450 CARD_NVIDIA_GEFORCE_8300GS
= 0x0423,
2451 CARD_NVIDIA_GEFORCE_8400GS
= 0x0404,
2452 CARD_NVIDIA_GEFORCE_8500GT
= 0x0421,
2453 CARD_NVIDIA_GEFORCE_8600GT
= 0x0402,
2454 CARD_NVIDIA_GEFORCE_8600MGT
= 0x0407,
2455 CARD_NVIDIA_GEFORCE_8800GTS
= 0x0193,
2456 CARD_NVIDIA_GEFORCE_8800GTX
= 0x0191,
2457 CARD_NVIDIA_GEFORCE_9200
= 0x086d,
2458 CARD_NVIDIA_GEFORCE_9300
= 0x086c,
2459 CARD_NVIDIA_GEFORCE_9400M
= 0x0863,
2460 CARD_NVIDIA_GEFORCE_9400GT
= 0x042c,
2461 CARD_NVIDIA_GEFORCE_9500GT
= 0x0640,
2462 CARD_NVIDIA_GEFORCE_9600GT
= 0x0622,
2463 CARD_NVIDIA_GEFORCE_9700MGT
= 0x064a,
2464 CARD_NVIDIA_GEFORCE_9800GT
= 0x0614,
2465 CARD_NVIDIA_GEFORCE_210
= 0x0a23,
2466 CARD_NVIDIA_GEFORCE_GT220
= 0x0a20,
2467 CARD_NVIDIA_GEFORCE_GT240
= 0x0ca3,
2468 CARD_NVIDIA_GEFORCE_GTS250
= 0x0615,
2469 CARD_NVIDIA_GEFORCE_GTX260
= 0x05e2,
2470 CARD_NVIDIA_GEFORCE_GTX275
= 0x05e6,
2471 CARD_NVIDIA_GEFORCE_GTX280
= 0x05e1,
2472 CARD_NVIDIA_GEFORCE_315M
= 0x0a7a,
2473 CARD_NVIDIA_GEFORCE_320M
= 0x08a3,
2474 CARD_NVIDIA_GEFORCE_GT320M
= 0x0a2d,
2475 CARD_NVIDIA_GEFORCE_GT325M
= 0x0a35,
2476 CARD_NVIDIA_GEFORCE_GT330
= 0x0ca0,
2477 CARD_NVIDIA_GEFORCE_GTS350M
= 0x0cb0,
2478 CARD_NVIDIA_GEFORCE_410M
= 0x1055,
2479 CARD_NVIDIA_GEFORCE_GT420
= 0x0de2,
2480 CARD_NVIDIA_GEFORCE_GT425M
= 0x0df0,
2481 CARD_NVIDIA_GEFORCE_GT430
= 0x0de1,
2482 CARD_NVIDIA_GEFORCE_GT440
= 0x0de0,
2483 CARD_NVIDIA_GEFORCE_GTS450
= 0x0dc4,
2484 CARD_NVIDIA_GEFORCE_GTX460
= 0x0e22,
2485 CARD_NVIDIA_GEFORCE_GTX460M
= 0x0dd1,
2486 CARD_NVIDIA_GEFORCE_GTX465
= 0x06c4,
2487 CARD_NVIDIA_GEFORCE_GTX470
= 0x06cd,
2488 CARD_NVIDIA_GEFORCE_GTX480
= 0x06c0,
2489 CARD_NVIDIA_GEFORCE_GT520
= 0x1040,
2490 CARD_NVIDIA_GEFORCE_GT525M
= 0x0dec,
2491 CARD_NVIDIA_GEFORCE_GT540M
= 0x0df4,
2492 CARD_NVIDIA_GEFORCE_GTX550
= 0x1244,
2493 CARD_NVIDIA_GEFORCE_GT555M
= 0x04b8,
2494 CARD_NVIDIA_GEFORCE_GTX560TI
= 0x1200,
2495 CARD_NVIDIA_GEFORCE_GTX560M
= 0x1251,
2496 CARD_NVIDIA_GEFORCE_GTX560
= 0x1201,
2497 CARD_NVIDIA_GEFORCE_GTX570
= 0x1081,
2498 CARD_NVIDIA_GEFORCE_GTX580
= 0x1080,
2499 CARD_NVIDIA_GEFORCE_GT610
= 0x104a,
2500 CARD_NVIDIA_GEFORCE_GT630
= 0x0f00,
2501 CARD_NVIDIA_GEFORCE_GT630M
= 0x0de9,
2502 CARD_NVIDIA_GEFORCE_GT640
= 0x0fc1,
2503 CARD_NVIDIA_GEFORCE_GT640M
= 0x0fd2,
2504 CARD_NVIDIA_GEFORCE_GT650M
= 0x0fd1,
2505 CARD_NVIDIA_GEFORCE_GTX650
= 0x0fc6,
2506 CARD_NVIDIA_GEFORCE_GTX650TI
= 0x11c6,
2507 CARD_NVIDIA_GEFORCE_GTX660
= 0x11c0,
2508 CARD_NVIDIA_GEFORCE_GTX660M
= 0x0fd4,
2509 CARD_NVIDIA_GEFORCE_GTX660TI
= 0x1183,
2510 CARD_NVIDIA_GEFORCE_GTX670
= 0x1189,
2511 CARD_NVIDIA_GEFORCE_GTX670MX
= 0x11a1,
2512 CARD_NVIDIA_GEFORCE_GTX675MX_1
= 0x11a7,
2513 CARD_NVIDIA_GEFORCE_GTX675MX_2
= 0x11a2,
2514 CARD_NVIDIA_GEFORCE_GTX680
= 0x1180,
2515 CARD_NVIDIA_GEFORCE_GTX690
= 0x1188,
2516 CARD_NVIDIA_GEFORCE_GT720
= 0x128b,
2517 CARD_NVIDIA_GEFORCE_GT730
= 0x1287,
2518 CARD_NVIDIA_GEFORCE_GT730M
= 0x0fe1,
2519 CARD_NVIDIA_GEFORCE_GT740M
= 0x1292,
2520 CARD_NVIDIA_GEFORCE_GT750M
= 0x0fe9,
2521 CARD_NVIDIA_GEFORCE_GT755M
= 0x0fcd,
2522 CARD_NVIDIA_GEFORCE_GTX750
= 0x1381,
2523 CARD_NVIDIA_GEFORCE_GTX750TI
= 0x1380,
2524 CARD_NVIDIA_GEFORCE_GTX760
= 0x1187,
2525 CARD_NVIDIA_GEFORCE_GTX760TI
= 0x1193,
2526 CARD_NVIDIA_GEFORCE_GTX765M
= 0x11e2,
2527 CARD_NVIDIA_GEFORCE_GTX770M
= 0x11e0,
2528 CARD_NVIDIA_GEFORCE_GTX770
= 0x1184,
2529 CARD_NVIDIA_GEFORCE_GTX775M
= 0x119d,
2530 CARD_NVIDIA_GEFORCE_GTX780
= 0x1004,
2531 CARD_NVIDIA_GEFORCE_GTX780M
= 0x119e,
2532 CARD_NVIDIA_GEFORCE_GTX780TI
= 0x100a,
2533 CARD_NVIDIA_GEFORCE_GTXTITAN
= 0x1005,
2534 CARD_NVIDIA_GEFORCE_GTXTITANB
= 0x100c,
2535 CARD_NVIDIA_GEFORCE_GTXTITANX
= 0x17c2,
2536 CARD_NVIDIA_GEFORCE_GTXTITANZ
= 0x1001,
2537 CARD_NVIDIA_GEFORCE_820M
= 0x0fed,
2538 CARD_NVIDIA_GEFORCE_830M
= 0x1340,
2539 CARD_NVIDIA_GEFORCE_840M
= 0x1341,
2540 CARD_NVIDIA_GEFORCE_845M
= 0x1344,
2541 CARD_NVIDIA_GEFORCE_GTX850M
= 0x1391,
2542 CARD_NVIDIA_GEFORCE_GTX860M
= 0x1392, /* Other PCI ID 0x119a */
2543 CARD_NVIDIA_GEFORCE_GTX870M
= 0x1199,
2544 CARD_NVIDIA_GEFORCE_GTX880M
= 0x1198,
2545 CARD_NVIDIA_GEFORCE_940M
= 0x1347,
2546 CARD_NVIDIA_GEFORCE_GTX950
= 0x1402,
2547 CARD_NVIDIA_GEFORCE_GTX950M
= 0x139a,
2548 CARD_NVIDIA_GEFORCE_GTX960
= 0x1401,
2549 CARD_NVIDIA_GEFORCE_GTX960M
= 0x139b,
2550 CARD_NVIDIA_GEFORCE_GTX970
= 0x13c2,
2551 CARD_NVIDIA_GEFORCE_GTX970M
= 0x13d8,
2552 CARD_NVIDIA_GEFORCE_GTX980
= 0x13c0,
2553 CARD_NVIDIA_GEFORCE_GTX980TI
= 0x17c8,
2554 CARD_NVIDIA_GEFORCE_GT1030
= 0x1d01,
2555 CARD_NVIDIA_GEFORCE_GTX1050
= 0x1c81,
2556 CARD_NVIDIA_GEFORCE_GTX1050TI
= 0x1c82,
2557 CARD_NVIDIA_GEFORCE_GTX1060_3GB
= 0x1c02,
2558 CARD_NVIDIA_GEFORCE_GTX1060
= 0x1c03,
2559 CARD_NVIDIA_GEFORCE_GTX1060M
= 0x1c20,
2560 CARD_NVIDIA_GEFORCE_GTX1070
= 0x1b81,
2561 CARD_NVIDIA_GEFORCE_GTX1080
= 0x1b80,
2562 CARD_NVIDIA_GEFORCE_GTX1080M
= 0x1be0,
2563 CARD_NVIDIA_GEFORCE_GTX1080TI
= 0x1b06,
2564 CARD_NVIDIA_TITANX_PASCAL
= 0x1b00,
2565 CARD_NVIDIA_TITANV
= 0x1d81,
2566 CARD_NVIDIA_GEFORCE_GTX1650SUPER
= 0x2187,
2567 CARD_NVIDIA_GEFORCE_GTX1660SUPER
= 0x21c4,
2568 CARD_NVIDIA_GEFORCE_GTX1660TI
= 0x2182,
2569 CARD_NVIDIA_GEFORCE_RTX2060
= 0x1f08,
2570 CARD_NVIDIA_GEFORCE_RTX2070
= 0x1f07,
2571 CARD_NVIDIA_GEFORCE_RTX2080
= 0x1e87,
2572 CARD_NVIDIA_GEFORCE_RTX2080TI
= 0x1e07,
2573 CARD_NVIDIA_TESLA_T4
= 0x1eb8,
2574 CARD_NVIDIA_AMPERE_A10
= 0x2236,
2576 CARD_REDHAT_VIRGL
= 0x1010,
2578 CARD_VMWARE_SVGA3D
= 0x0405,
2580 CARD_INTEL_830M
= 0x3577,
2581 CARD_INTEL_855GM
= 0x3582,
2582 CARD_INTEL_845G
= 0x2562,
2583 CARD_INTEL_865G
= 0x2572,
2584 CARD_INTEL_915G
= 0x2582,
2585 CARD_INTEL_E7221G
= 0x258a,
2586 CARD_INTEL_915GM
= 0x2592,
2587 CARD_INTEL_945G
= 0x2772,
2588 CARD_INTEL_945GM
= 0x27a2,
2589 CARD_INTEL_945GME
= 0x27ae,
2590 CARD_INTEL_Q35
= 0x29b2,
2591 CARD_INTEL_G33
= 0x29c2,
2592 CARD_INTEL_Q33
= 0x29d2,
2593 CARD_INTEL_PNVG
= 0xa001,
2594 CARD_INTEL_PNVM
= 0xa011,
2595 CARD_INTEL_965Q
= 0x2992,
2596 CARD_INTEL_965G
= 0x2982,
2597 CARD_INTEL_946GZ
= 0x2972,
2598 CARD_INTEL_965GM
= 0x2a02,
2599 CARD_INTEL_965GME
= 0x2a12,
2600 CARD_INTEL_GM45
= 0x2a42,
2601 CARD_INTEL_IGD
= 0x2e02,
2602 CARD_INTEL_Q45
= 0x2e12,
2603 CARD_INTEL_G45
= 0x2e22,
2604 CARD_INTEL_G41
= 0x2e32,
2605 CARD_INTEL_B43
= 0x2e92,
2606 CARD_INTEL_ILKD
= 0x0042,
2607 CARD_INTEL_ILKM
= 0x0046,
2608 CARD_INTEL_SNBD
= 0x0122,
2609 CARD_INTEL_SNBM
= 0x0126,
2610 CARD_INTEL_SNBS
= 0x010a,
2611 CARD_INTEL_IVBD
= 0x0162,
2612 CARD_INTEL_IVBM
= 0x0166,
2613 CARD_INTEL_IVBS
= 0x015a,
2614 CARD_INTEL_HWD
= 0x0412,
2615 CARD_INTEL_HWM
= 0x0416,
2616 CARD_INTEL_HD5000_1
= 0x0a26,
2617 CARD_INTEL_HD5000_2
= 0x0422,
2618 CARD_INTEL_I5100_1
= 0x0a22,
2619 CARD_INTEL_I5100_2
= 0x0a2a,
2620 CARD_INTEL_I5100_3
= 0x0a2b,
2621 CARD_INTEL_I5100_4
= 0x0a2e,
2622 CARD_INTEL_IP5200_1
= 0x0d22,
2623 CARD_INTEL_IP5200_2
= 0x0d26,
2624 CARD_INTEL_IP5200_3
= 0x0d2a,
2625 CARD_INTEL_IP5200_4
= 0x0d2b,
2626 CARD_INTEL_IP5200_5
= 0x0d2e,
2627 CARD_INTEL_IP5200_6
= 0x0c22,
2628 CARD_INTEL_HD5300
= 0x161e,
2629 CARD_INTEL_HD5500
= 0x1616,
2630 CARD_INTEL_HD5600
= 0x1612,
2631 CARD_INTEL_HD6000
= 0x1626,
2632 CARD_INTEL_I6100
= 0x162b,
2633 CARD_INTEL_IP6200
= 0x1622,
2634 CARD_INTEL_IPP6300
= 0x162a,
2635 CARD_INTEL_HD510_1
= 0x1902,
2636 CARD_INTEL_HD510_2
= 0x1906,
2637 CARD_INTEL_HD510_3
= 0x190b,
2638 CARD_INTEL_HD515
= 0x191e,
2639 CARD_INTEL_HD520_1
= 0x1916,
2640 CARD_INTEL_HD520_2
= 0x1921,
2641 CARD_INTEL_HD530_1
= 0x1912,
2642 CARD_INTEL_HD530_2
= 0x191b,
2643 CARD_INTEL_HDP530
= 0x191d,
2644 CARD_INTEL_I540
= 0x1926,
2645 CARD_INTEL_I550
= 0x1927,
2646 CARD_INTEL_I555
= 0x192b,
2647 CARD_INTEL_IP555
= 0x192d,
2648 CARD_INTEL_IP580_1
= 0x1932,
2649 CARD_INTEL_IP580_2
= 0x193b,
2650 CARD_INTEL_IPP580_1
= 0x193a,
2651 CARD_INTEL_IPP580_2
= 0x193d,
2652 CARD_INTEL_UHD617
= 0x87c0,
2653 CARD_INTEL_UHD620
= 0x3ea0,
2654 CARD_INTEL_HD615
= 0x591e,
2655 CARD_INTEL_HD620
= 0x5916,
2656 CARD_INTEL_HD630_1
= 0x5912,
2657 CARD_INTEL_HD630_2
= 0x591b,
2658 CARD_INTEL_UHD630_1
= 0x3e9b,
2659 CARD_INTEL_UHD630_2
= 0x3e91,
2662 /* The driver names reflect the lowest GPU supported
2663 * by a certain driver, so DRIVER_AMD_R300 supports
2664 * R3xx, R4xx and R5xx GPUs. */
2665 enum wined3d_display_driver
2667 DRIVER_AMD_RAGE_128PRO
,
2672 DRIVER_INTEL_GMA800
,
2673 DRIVER_INTEL_GMA900
,
2674 DRIVER_INTEL_GMA950
,
2675 DRIVER_INTEL_GMA3000
,
2676 DRIVER_INTEL_HD4000
,
2678 DRIVER_NVIDIA_GEFORCE2MX
,
2679 DRIVER_NVIDIA_GEFORCEFX
,
2680 DRIVER_NVIDIA_GEFORCE6
,
2681 DRIVER_NVIDIA_GEFORCE8
,
2682 DRIVER_NVIDIA_FERMI
,
2683 DRIVER_NVIDIA_KEPLER
,
2684 DRIVER_REDHAT_VIRGL
,
2690 struct wined3d_gpu_description
2692 enum wined3d_pci_vendor vendor
;
2693 enum wined3d_pci_device device
;
2694 const char *description
;
2695 enum wined3d_display_driver driver
;
2696 unsigned int vidmem
;
2699 const struct wined3d_gpu_description
*wined3d_get_gpu_description(enum wined3d_pci_vendor vendor
,
2700 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
2701 const struct wined3d_gpu_description
*wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor
,
2702 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
2703 enum wined3d_pci_device
wined3d_gpu_from_feature_level(enum wined3d_pci_vendor
*vendor
,
2704 enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
2706 /* 512 in Direct3D 8/9, 128 in DXGI. */
2707 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
2709 struct wined3d_driver_info
2711 enum wined3d_pci_vendor vendor
;
2712 enum wined3d_pci_device device
;
2714 char description
[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH
];
2716 UINT64 sysmem_bytes
;
2717 unsigned int version_high
;
2718 unsigned int version_low
;
2721 bool wined3d_driver_info_init(struct wined3d_driver_info
*driver_info
,
2722 const struct wined3d_gpu_description
*gpu_description
, enum wined3d_feature_level feature_level
,
2723 UINT64 vram_bytes
, UINT64 sysmem_bytes
) DECLSPEC_HIDDEN
;
2725 #define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
2726 #define UPLOAD_BO_RENAME_ON_UNMAP 0x2
2727 #define UPLOAD_BO_FREE_ON_UNMAP 0x4
2731 struct wined3d_const_bo_address addr
;
2735 struct wined3d_adapter_ops
2737 void (*adapter_destroy
)(struct wined3d_adapter
*adapter
);
2738 HRESULT (*adapter_create_device
)(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
2739 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
2740 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
2741 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
);
2742 void (*adapter_destroy_device
)(struct wined3d_device
*device
);
2743 struct wined3d_context
*(*adapter_acquire_context
)(struct wined3d_device
*device
,
2744 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
2745 void (*adapter_release_context
)(struct wined3d_context
*context
);
2746 void (*adapter_get_wined3d_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
);
2747 BOOL (*adapter_check_format
)(const struct wined3d_adapter
*adapter
,
2748 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
2749 const struct wined3d_format
*ds_format
);
2750 HRESULT (*adapter_init_3d
)(struct wined3d_device
*device
);
2751 void (*adapter_uninit_3d
)(struct wined3d_device
*device
);
2752 void *(*adapter_map_bo_address
)(struct wined3d_context
*context
,
2753 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
);
2754 void (*adapter_unmap_bo_address
)(struct wined3d_context
*context
, const struct wined3d_bo_address
*data
,
2755 unsigned int range_count
, const struct wined3d_range
*ranges
);
2756 void (*adapter_copy_bo_address
)(struct wined3d_context
*context
,
2757 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
2758 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
);
2759 void (*adapter_flush_bo_address
)(struct wined3d_context
*context
,
2760 const struct wined3d_const_bo_address
*data
, size_t size
);
2761 bool (*adapter_alloc_bo
)(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
2762 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
);
2763 void (*adapter_destroy_bo
)(struct wined3d_context
*context
, struct wined3d_bo
*bo
);
2764 HRESULT (*adapter_create_swapchain
)(struct wined3d_device
*device
,
2765 struct wined3d_swapchain_desc
*desc
,
2766 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
2767 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
);
2768 void (*adapter_destroy_swapchain
)(struct wined3d_swapchain
*swapchain
);
2769 HRESULT (*adapter_create_buffer
)(struct wined3d_device
*device
, const struct wined3d_buffer_desc
*desc
,
2770 const struct wined3d_sub_resource_data
*data
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2771 struct wined3d_buffer
**buffer
);
2772 void (*adapter_destroy_buffer
)(struct wined3d_buffer
*buffer
);
2773 HRESULT (*adapter_create_texture
)(struct wined3d_device
*device
, const struct wined3d_resource_desc
*desc
,
2774 unsigned int layer_count
, unsigned int level_count
, uint32_t flags
, void *parent
,
2775 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
);
2776 void (*adapter_destroy_texture
)(struct wined3d_texture
*texture
);
2777 HRESULT (*adapter_create_rendertarget_view
)(const struct wined3d_view_desc
*desc
,
2778 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2779 struct wined3d_rendertarget_view
**view
);
2780 void (*adapter_destroy_rendertarget_view
)(struct wined3d_rendertarget_view
*view
);
2781 HRESULT (*adapter_create_shader_resource_view
)(const struct wined3d_view_desc
*desc
,
2782 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2783 struct wined3d_shader_resource_view
**view
);
2784 void (*adapter_destroy_shader_resource_view
)(struct wined3d_shader_resource_view
*view
);
2785 HRESULT (*adapter_create_unordered_access_view
)(const struct wined3d_view_desc
*desc
,
2786 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2787 struct wined3d_unordered_access_view
**view
);
2788 void (*adapter_destroy_unordered_access_view
)(struct wined3d_unordered_access_view
*view
);
2789 HRESULT (*adapter_create_sampler
)(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
2790 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
);
2791 void (*adapter_destroy_sampler
)(struct wined3d_sampler
*sampler
);
2792 HRESULT (*adapter_create_query
)(struct wined3d_device
*device
, enum wined3d_query_type type
,
2793 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
2794 void (*adapter_destroy_query
)(struct wined3d_query
*query
);
2795 void (*adapter_flush_context
)(struct wined3d_context
*context
);
2796 void (*adapter_draw_primitive
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
2797 const struct wined3d_draw_parameters
*parameters
);
2798 void (*adapter_dispatch_compute
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
2799 const struct wined3d_dispatch_parameters
*parameters
);
2800 void (*adapter_clear_uav
)(struct wined3d_context
*context
,
2801 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
);
2802 void (*adapter_generate_mipmap
)(struct wined3d_context
*context
, struct wined3d_shader_resource_view
*view
);
2805 struct wined3d_output
2807 unsigned int ordinal
;
2808 WCHAR device_name
[CCHDEVICENAME
];
2809 struct wined3d_adapter
*adapter
;
2810 enum wined3d_format_id screen_format
;
2812 D3DKMT_HANDLE kmt_device
;
2813 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id
;
2815 struct wined3d_display_mode
*modes
;
2816 SIZE_T mode_count
, modes_size
;
2820 HRESULT
wined3d_output_get_gamma_ramp(struct wined3d_output
*output
, struct wined3d_gamma_ramp
*ramp
) DECLSPEC_HIDDEN
;
2823 #define MAX_PERSISTENT_MAPPED_BYTES I64_MAX
2825 #define MAX_PERSISTENT_MAPPED_BYTES (128 * 1024 * 1024)
2828 /* The adapter structure */
2829 struct wined3d_adapter
2831 unsigned int ordinal
;
2833 struct wined3d_d3d_info d3d_info
;
2834 struct wined3d_driver_info driver_info
;
2835 struct wined3d_output
*outputs
;
2836 SIZE_T output_count
, outputs_size
;
2837 D3DKMT_HANDLE kmt_adapter
;
2838 UINT64 vram_bytes_used
;
2846 ssize_t mapped_size
;
2848 const struct wined3d_vertex_pipe_ops
*vertex_pipe
;
2849 const struct wined3d_fragment_pipe_ops
*fragment_pipe
;
2850 const struct wined3d_state_entry_template
*misc_state_template
;
2851 const struct wined3d_shader_backend_ops
*shader_backend
;
2852 const struct wined3d_adapter_ops
*adapter_ops
;
2855 BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, unsigned int ordinal
, const LUID
*luid
,
2856 const struct wined3d_adapter_ops
*adapter_ops
) DECLSPEC_HIDDEN
;
2857 void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
2858 BOOL
wined3d_get_primary_adapter_luid(LUID
*luid
) DECLSPEC_HIDDEN
;
2860 struct wined3d_adapter
*wined3d_adapter_vk_create(unsigned int ordinal
,
2861 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
2863 struct wined3d_adapter_gl
2865 struct wined3d_adapter a
;
2867 struct wined3d_gl_info gl_info
;
2869 struct wined3d_pixel_format
*pixel_formats
;
2870 unsigned int pixel_format_count
;
2873 static inline struct wined3d_adapter_gl
*wined3d_adapter_gl(struct wined3d_adapter
*adapter
)
2875 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
2878 static inline const struct wined3d_adapter_gl
*wined3d_adapter_gl_const(const struct wined3d_adapter
*adapter
)
2880 return CONTAINING_RECORD(adapter
, struct wined3d_adapter_gl
, a
);
2883 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
,
2884 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
2886 struct wined3d_caps_gl_ctx
2892 HGLRC restore_gl_ctx
;
2894 const struct wined3d_gl_info
*gl_info
;
2896 GLuint test_program_id
;
2898 const struct wined3d_gpu_description
*gpu_description
;
2902 BOOL
wined3d_adapter_gl_init_format_info(struct wined3d_adapter
*adapter
,
2903 struct wined3d_caps_gl_ctx
*ctx
) DECLSPEC_HIDDEN
;
2904 BOOL
wined3d_adapter_no3d_init_format_info(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
2905 ssize_t
adapter_adjust_mapped_memory(struct wined3d_adapter
*adapter
, ssize_t size
) DECLSPEC_HIDDEN
;
2906 UINT64
adapter_adjust_memory(struct wined3d_adapter
*adapter
, INT64 amount
) DECLSPEC_HIDDEN
;
2908 BOOL
wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx
*ctx
) DECLSPEC_HIDDEN
;
2909 bool wined3d_caps_gl_ctx_test_filling_convention(struct wined3d_caps_gl_ctx
*ctx
, float offset
) DECLSPEC_HIDDEN
;
2911 enum wined3d_projection_type
2913 WINED3D_PROJECTION_NONE
= 0,
2914 WINED3D_PROJECTION_COUNT3
= 1,
2915 WINED3D_PROJECTION_COUNT4
= 2
2918 /*****************************************************************************
2919 * Fixed function pipeline replacements
2921 #define ARG_UNUSED 0xff
2922 struct texture_stage_op
2934 struct color_fixup_desc color_fixup
;
2935 unsigned tex_type
: 3;
2936 unsigned tmp_dst
: 1;
2937 unsigned projected
: 2;
2938 unsigned padding
: 10;
2941 struct ffp_frag_settings
2943 struct texture_stage_op op
[WINED3D_MAX_TEXTURES
];
2944 enum wined3d_ffp_ps_fog_mode fog
;
2945 unsigned char sRGB_write
;
2946 unsigned char emul_clipplanes
;
2947 unsigned char texcoords_initialized
;
2948 unsigned char color_key_enabled
: 1;
2949 unsigned char pointsprite
: 1;
2950 unsigned char flatshading
: 1;
2951 unsigned char alpha_test_func
: 3;
2952 unsigned char padding
: 2;
2955 struct ffp_frag_desc
2957 struct wine_rb_entry entry
;
2958 struct ffp_frag_settings settings
;
2961 int wined3d_ffp_frag_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
2962 int wined3d_ffp_vertex_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
2964 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN
;
2966 void wined3d_ffp_get_fs_settings(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
2967 struct ffp_frag_settings
*settings
, BOOL ignore_textype
) DECLSPEC_HIDDEN
;
2968 const struct ffp_frag_desc
*find_ffp_frag_shader(const struct wine_rb_tree
*fragment_shaders
,
2969 const struct ffp_frag_settings
*settings
) DECLSPEC_HIDDEN
;
2970 void add_ffp_frag_shader(struct wine_rb_tree
*shaders
, struct ffp_frag_desc
*desc
) DECLSPEC_HIDDEN
;
2971 void wined3d_ftoa(float value
, char *s
) DECLSPEC_HIDDEN
;
2973 enum wined3d_ffp_vs_fog_mode
2975 WINED3D_FFP_VS_FOG_OFF
= 0,
2976 WINED3D_FFP_VS_FOG_FOGCOORD
= 1,
2977 WINED3D_FFP_VS_FOG_DEPTH
= 2,
2978 WINED3D_FFP_VS_FOG_RANGE
= 3,
2981 #define WINED3D_FFP_TCI_SHIFT 16
2982 #define WINED3D_FFP_TCI_MASK 0xffu
2984 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
2985 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
2987 struct wined3d_ffp_vs_settings
2989 DWORD point_light_count
: 4;
2990 DWORD spot_light_count
: 4;
2991 DWORD directional_light_count
: 4;
2992 DWORD parallel_point_light_count
: 4;
2993 DWORD diffuse_source
: 2;
2994 DWORD emissive_source
: 2;
2995 DWORD ambient_source
: 2;
2996 DWORD specular_source
: 2;
2997 DWORD transformed
: 1;
2998 DWORD vertexblends
: 2;
3001 DWORD normalize
: 1;
3003 DWORD localviewer
: 1;
3005 DWORD point_size
: 1;
3006 DWORD per_vertex_point_size
: 1;
3008 DWORD texcoords
: 8; /* WINED3D_MAX_TEXTURES */
3009 DWORD ortho_fog
: 1;
3010 DWORD flatshading
: 1;
3013 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
3015 unsigned int texgen
[WINED3D_MAX_TEXTURES
];
3018 struct wined3d_ffp_vs_desc
3020 struct wine_rb_entry entry
;
3021 struct wined3d_ffp_vs_settings settings
;
3024 void wined3d_ffp_get_vs_settings(const struct wined3d_context
*context
,
3025 const struct wined3d_state
*state
, struct wined3d_ffp_vs_settings
*settings
) DECLSPEC_HIDDEN
;
3031 unsigned int adapter_count
;
3032 struct wined3d_adapter
*adapters
[1];
3035 BOOL
wined3d_filter_messages(HWND window
, BOOL filter
) DECLSPEC_HIDDEN
;
3036 HRESULT
wined3d_init(struct wined3d
*wined3d
, uint32_t flags
) DECLSPEC_HIDDEN
;
3037 void wined3d_unregister_window(HWND window
) DECLSPEC_HIDDEN
;
3039 BOOL
wined3d_get_app_name(char *app_name
, unsigned int app_name_size
) DECLSPEC_HIDDEN
;
3041 enum wined3d_push_constants
3043 WINED3D_PUSH_CONSTANTS_VS_F
,
3044 WINED3D_PUSH_CONSTANTS_PS_F
,
3045 WINED3D_PUSH_CONSTANTS_VS_I
,
3046 WINED3D_PUSH_CONSTANTS_PS_I
,
3047 WINED3D_PUSH_CONSTANTS_VS_B
,
3048 WINED3D_PUSH_CONSTANTS_PS_B
,
3049 WINED3D_PUSH_CONSTANTS_COUNT
,
3052 struct wined3d_blend_state
3055 struct wined3d_blend_state_desc desc
;
3059 const struct wined3d_parent_ops
*parent_ops
;
3061 struct wined3d_device
*device
;
3062 struct wine_rb_entry entry
;
3065 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state
*state
,
3070 if (!state
->desc
.independent
)
3072 return state
->desc
.rt
[index
].writemask
;
3075 struct wined3d_depth_stencil_state
3078 struct wined3d_depth_stencil_state_desc desc
;
3083 const struct wined3d_parent_ops
*parent_ops
;
3085 struct wined3d_device
*device
;
3086 struct wine_rb_entry entry
;
3089 struct wined3d_rasterizer_state
3092 struct wined3d_rasterizer_state_desc desc
;
3095 const struct wined3d_parent_ops
*parent_ops
;
3097 struct wined3d_device
*device
;
3098 struct wine_rb_entry entry
;
3101 struct wined3d_light_state
3103 struct rb_tree lights_tree
;
3104 const struct wined3d_light_info
*lights
[WINED3D_MAX_ACTIVE_LIGHTS
];
3107 #define WINED3D_STATE_NO_REF 0x00000001
3108 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
3110 struct wined3d_state
3112 enum wined3d_feature_level feature_level
;
3114 struct wined3d_fb_state fb
;
3116 struct wined3d_vertex_declaration
*vertex_declaration
;
3117 struct wined3d_stream_output stream_output
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
3118 struct wined3d_stream_state streams
[WINED3D_MAX_STREAMS
];
3119 struct wined3d_buffer
*index_buffer
;
3120 enum wined3d_format_id index_format
;
3121 unsigned int index_offset
;
3122 int base_vertex_index
;
3123 int load_base_vertex_index
; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
3124 enum wined3d_primitive_type primitive_type
;
3125 unsigned int patch_vertex_count
;
3126 struct wined3d_query
*predicate
;
3127 BOOL predicate_value
;
3129 struct wined3d_shader
*shader
[WINED3D_SHADER_TYPE_COUNT
];
3130 struct wined3d_constant_buffer_state cb
[WINED3D_SHADER_TYPE_COUNT
][MAX_CONSTANT_BUFFERS
];
3131 struct wined3d_sampler
*sampler
[WINED3D_SHADER_TYPE_COUNT
][MAX_SAMPLER_OBJECTS
];
3132 struct wined3d_shader_resource_view
*shader_resource_view
[WINED3D_SHADER_TYPE_COUNT
][MAX_SHADER_RESOURCE_VIEWS
];
3133 struct wined3d_unordered_access_view
*unordered_access_view
[WINED3D_PIPELINE_COUNT
][MAX_UNORDERED_ACCESS_VIEWS
];
3135 struct wined3d_texture
*textures
[WINED3D_MAX_COMBINED_SAMPLERS
];
3136 uint32_t sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
3137 uint32_t texture_states
[WINED3D_MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
3139 struct wined3d_matrix transforms
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
3140 struct wined3d_vec4 clip_planes
[WINED3D_MAX_CLIP_DISTANCES
];
3141 struct wined3d_material material
;
3142 struct wined3d_viewport viewports
[WINED3D_MAX_VIEWPORTS
];
3143 unsigned int viewport_count
;
3144 RECT scissor_rects
[WINED3D_MAX_VIEWPORTS
];
3145 unsigned int scissor_rect_count
;
3147 struct wined3d_light_state light_state
;
3149 unsigned int render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
3150 struct wined3d_blend_state
*blend_state
;
3151 struct wined3d_color blend_factor
;
3152 unsigned int sample_mask
;
3153 struct wined3d_depth_stencil_state
*depth_stencil_state
;
3154 unsigned int stencil_ref
;
3155 bool depth_bounds_enable
;
3156 float depth_bounds_min
, depth_bounds_max
;
3157 struct wined3d_rasterizer_state
*rasterizer_state
;
3160 void state_cleanup(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3161 void state_init(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
3162 uint32_t flags
, enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
3163 void state_unbind_resources(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3165 static inline void wined3d_state_reset(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
)
3167 enum wined3d_feature_level feature_level
= state
->feature_level
;
3168 uint32_t flags
= state
->flags
;
3170 memset(state
, 0, sizeof(*state
));
3171 state_init(state
, d3d_info
, flags
, feature_level
);
3174 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state
*state
)
3176 if (!state
->depth_stencil_state
)
3178 return state
->depth_stencil_state
->desc
.depth
|| state
->depth_stencil_state
->desc
.depth_write
3179 || state
->depth_stencil_state
->desc
.stencil
;
3182 struct wined3d_dummy_textures
3189 GLuint tex_cube_array
;
3190 GLuint tex_1d_array
;
3191 GLuint tex_2d_array
;
3194 GLuint tex_2d_ms_array
;
3197 #define WINED3D_UNMAPPED_STAGE ~0u
3199 /* Multithreaded flag. Removed from the public header to signal that
3200 * wined3d_device_create() ignores it. */
3201 #define WINED3DCREATE_MULTITHREADED 0x00000004
3203 struct wined3d_so_desc_entry
3205 struct wine_rb_entry entry
;
3206 struct wined3d_stream_output_desc desc
;
3207 struct wined3d_stream_output_element elements
[1];
3210 struct wined3d_device
3214 /* WineD3D Information */
3215 struct wined3d_device_parent
*device_parent
;
3216 struct wined3d
*wined3d
;
3217 struct wined3d_adapter
*adapter
;
3219 const struct wined3d_shader_backend_ops
*shader_backend
;
3221 void *fragment_priv
;
3223 struct wined3d_state_entry state_table
[STATE_HIGHEST
+ 1];
3224 /* Array of functions for states which are handled by more than one pipeline part */
3225 APPLYSTATEFUNC
*multistate_funcs
[STATE_HIGHEST
+ 1];
3226 struct wined3d_blitter
*blitter
;
3228 BYTE bCursorVisible
: 1;
3229 BYTE d3d_initialized
: 1;
3230 BYTE inScene
: 1; /* A flag to check for proper BeginScene / EndScene call pairs */
3231 BYTE softwareVertexProcessing
: 1; /* process vertex shaders using software or hardware */
3232 BYTE restore_screensaver
: 1;
3235 unsigned char surface_alignment
; /* Line Alignment of surfaces */
3239 /* Internal use fields */
3240 struct wined3d_device_creation_parameters create_parms
;
3243 struct wined3d_rendertarget_view
*back_buffer_view
;
3244 struct wined3d_swapchain
**swapchains
;
3245 UINT swapchain_count
;
3246 unsigned int max_frame_latency
;
3248 struct list resources
; /* a linked list to track resources created by the device */
3249 struct list shaders
; /* a linked list to track shaders (pixel and vertex) */
3250 struct wine_rb_tree so_descs
;
3251 struct wine_rb_tree samplers
, rasterizer_states
, blend_states
, depth_stencil_states
;
3253 /* Render Target Support */
3254 struct wined3d_rendertarget_view
*auto_depth_stencil_view
;
3256 /* Cursor management */
3261 UINT cursorWidth
, cursorHeight
;
3262 struct wined3d_texture
*cursor_texture
;
3263 HCURSOR hardwareCursor
;
3265 /* The Wine logo texture */
3266 struct wined3d_texture
*logo_texture
;
3268 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3269 struct wined3d_sampler
*default_sampler
;
3270 struct wined3d_sampler
*null_sampler
;
3272 /* Command stream */
3273 struct wined3d_cs
*cs
;
3275 struct wined3d_buffer
*push_constants
[WINED3D_PUSH_CONSTANTS_COUNT
];
3277 /* Context management */
3278 struct wined3d_context
**contexts
;
3281 CRITICAL_SECTION bo_map_lock
;
3284 void wined3d_device_cleanup(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3285 BOOL
device_context_add(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3286 void device_context_remove(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3287 void wined3d_device_create_default_samplers(struct wined3d_device
*device
,
3288 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3289 void wined3d_device_destroy_default_samplers(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3290 HRESULT
wined3d_device_init(struct wined3d_device
*device
, struct wined3d
*wined3d
,
3291 unsigned int adapter_idx
, enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
3292 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
3293 const BOOL
*supported_extensions
, struct wined3d_device_parent
*device_parent
) DECLSPEC_HIDDEN
;
3294 LRESULT
device_process_message(struct wined3d_device
*device
, HWND window
, BOOL unicode
,
3295 UINT message
, WPARAM wparam
, LPARAM lparam
, WNDPROC proc
) DECLSPEC_HIDDEN
;
3296 void device_resource_add(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3297 void device_resource_released(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3298 void device_invalidate_state(const struct wined3d_device
*device
, unsigned int state
) DECLSPEC_HIDDEN
;
3299 HRESULT
wined3d_device_set_implicit_swapchain(struct wined3d_device
*device
,
3300 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3301 void wined3d_device_uninit_3d(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3303 static inline void wined3d_device_bo_map_lock(struct wined3d_device
*device
)
3305 EnterCriticalSection(&device
->bo_map_lock
);
3308 static inline void wined3d_device_bo_map_unlock(struct wined3d_device
*device
)
3310 LeaveCriticalSection(&device
->bo_map_lock
);
3313 struct wined3d_device_no3d
3315 struct wined3d_device d
;
3317 struct wined3d_context context_no3d
;
3320 static inline struct wined3d_device_no3d
*wined3d_device_no3d(struct wined3d_device
*device
)
3322 return CONTAINING_RECORD(device
, struct wined3d_device_no3d
, d
);
3325 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
3326 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
3327 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
3328 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
3329 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
3331 struct wined3d_allocator_chunk
3334 struct list available
[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT
];
3335 struct wined3d_allocator
*allocator
;
3336 unsigned int map_count
;
3340 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk
*chunk
) DECLSPEC_HIDDEN
;
3341 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk
*chunk
,
3342 struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3344 struct wined3d_allocator_chunk_gl
3346 struct wined3d_allocator_chunk c
;
3347 unsigned int memory_type
;
3351 static inline struct wined3d_allocator_chunk_gl
*wined3d_allocator_chunk_gl(struct wined3d_allocator_chunk
*chunk
)
3353 return CONTAINING_RECORD(chunk
, struct wined3d_allocator_chunk_gl
, c
);
3356 struct wined3d_allocator_block
3359 struct wined3d_allocator_chunk
*chunk
;
3360 struct wined3d_allocator_block
*parent
, *sibling
;
3366 void wined3d_allocator_block_free(struct wined3d_allocator_block
*block
) DECLSPEC_HIDDEN
;
3368 struct wined3d_allocator_pool
3373 struct wined3d_allocator_ops
3375 struct wined3d_allocator_chunk
*(*allocator_create_chunk
)(struct wined3d_allocator
*allocator
,
3376 struct wined3d_context
*context
, unsigned int memory_type
, size_t chunk_size
);
3377 void (*allocator_destroy_chunk
)(struct wined3d_allocator_chunk
*chunk
);
3380 struct wined3d_allocator
3382 const struct wined3d_allocator_ops
*ops
;
3383 struct wined3d_allocator_pool
*pools
;
3385 struct wined3d_allocator_block
*free
;
3388 struct wined3d_allocator_block
*wined3d_allocator_allocate(struct wined3d_allocator
*allocator
,
3389 struct wined3d_context
*context
, unsigned int memory_type
, size_t size
) DECLSPEC_HIDDEN
;
3390 void wined3d_allocator_cleanup(struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3391 bool wined3d_allocator_init(struct wined3d_allocator
*allocator
,
3392 size_t pool_count
, const struct wined3d_allocator_ops
*allocator_ops
) DECLSPEC_HIDDEN
;
3394 struct wined3d_device_gl
3396 struct wined3d_device d
;
3398 /* Textures for when no other textures are bound. */
3399 struct wined3d_dummy_textures dummy_textures
;
3401 CRITICAL_SECTION allocator_cs
;
3402 struct wined3d_allocator allocator
;
3403 uint64_t completed_fence_id
;
3404 uint64_t current_fence_id
;
3405 uint64_t retired_bo_size
;
3407 struct wined3d_retired_block_gl
3409 struct wined3d_allocator_block
*block
;
3412 SIZE_T retired_blocks_size
;
3413 SIZE_T retired_block_count
;
3419 static inline struct wined3d_device_gl
*wined3d_device_gl(struct wined3d_device
*device
)
3421 return CONTAINING_RECORD(device
, struct wined3d_device_gl
, d
);
3424 static inline struct wined3d_device_gl
*wined3d_device_gl_from_allocator(struct wined3d_allocator
*allocator
)
3426 return CONTAINING_RECORD(allocator
, struct wined3d_device_gl
, allocator
);
3429 static inline void wined3d_device_gl_allocator_lock(struct wined3d_device_gl
*device_gl
)
3431 EnterCriticalSection(&device_gl
->allocator_cs
);
3434 static inline void wined3d_device_gl_allocator_unlock(struct wined3d_device_gl
*device_gl
)
3436 LeaveCriticalSection(&device_gl
->allocator_cs
);
3439 static inline void wined3d_allocator_chunk_gl_lock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
3441 wined3d_device_gl_allocator_lock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
3444 static inline void wined3d_allocator_chunk_gl_unlock(struct wined3d_allocator_chunk_gl
*chunk_gl
)
3446 wined3d_device_gl_allocator_unlock(wined3d_device_gl_from_allocator(chunk_gl
->c
.allocator
));
3449 bool wined3d_device_gl_create_bo(struct wined3d_device_gl
*device_gl
,
3450 struct wined3d_context_gl
*context_gl
, GLsizeiptr size
, GLenum binding
,
3451 GLenum usage
, bool coherent
, GLbitfield flags
, struct wined3d_bo_gl
*bo
) DECLSPEC_HIDDEN
;
3452 void wined3d_device_gl_create_primary_opengl_context_cs(void *object
) DECLSPEC_HIDDEN
;
3453 void wined3d_device_gl_delete_opengl_contexts_cs(void *object
) DECLSPEC_HIDDEN
;
3454 HDC
wined3d_device_gl_get_backup_dc(struct wined3d_device_gl
*device_gl
) DECLSPEC_HIDDEN
;
3455 GLbitfield
wined3d_device_gl_get_memory_type_flags(unsigned int memory_type_idx
) DECLSPEC_HIDDEN
;
3457 static inline float wined3d_alpha_ref(const struct wined3d_state
*state
)
3459 return (state
->render_states
[WINED3D_RS_ALPHAREF
] & 0xff) / 255.0f
;
3462 const char *wined3d_debug_resource_access(uint32_t access
) DECLSPEC_HIDDEN
;
3463 const char *wined3d_debug_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
3464 const char *wined3d_debug_view_desc(const struct wined3d_view_desc
*d
,
3465 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3467 static inline ULONG
wined3d_atomic_decrement_mutex_lock(volatile LONG
*refcount
)
3469 ULONG count
, old_count
= *refcount
;
3472 if ((count
= old_count
) == 1)
3474 wined3d_mutex_lock();
3475 count
= InterlockedDecrement(refcount
);
3476 if (count
) wined3d_mutex_unlock();
3480 old_count
= InterlockedCompareExchange(refcount
, count
- 1, count
);
3482 while (old_count
!= count
);
3487 #define CLIENT_BO_DISCARDED ((struct wined3d_bo *)~(UINT_PTR)0)
3489 struct wined3d_client_resource
3491 /* The resource's persistently mapped address, which we may use to perform
3492 * NOOVERWRITE maps from the client thread. */
3493 struct wined3d_bo_address addr
;
3495 /* The currently mapped upload BO, if applicable, and box. */
3496 struct upload_bo mapped_upload
;
3497 struct wined3d_box mapped_box
;
3500 static inline BOOL
wined3d_resource_access_is_managed(unsigned int access
)
3502 return !(~access
& (WINED3D_RESOURCE_ACCESS_GPU
| WINED3D_RESOURCE_ACCESS_CPU
));
3505 struct wined3d_resource_ops
3507 ULONG (*resource_incref
)(struct wined3d_resource
*resource
);
3508 ULONG (*resource_decref
)(struct wined3d_resource
*resource
);
3509 void (*resource_preload
)(struct wined3d_resource
*resource
);
3510 void (*resource_unload
)(struct wined3d_resource
*resource
);
3511 HRESULT (*resource_sub_resource_get_desc
)(struct wined3d_resource
*resource
,
3512 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
);
3513 void (*resource_sub_resource_get_map_pitch
)(struct wined3d_resource
*resource
,
3514 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
);
3515 HRESULT (*resource_sub_resource_map
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3516 void **map_ptr
, const struct wined3d_box
*box
, uint32_t flags
);
3517 HRESULT (*resource_sub_resource_unmap
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
);
3520 struct wined3d_resource
3526 struct wined3d_device
*device
;
3527 enum wined3d_resource_type type
;
3528 enum wined3d_gl_resource_type gl_type
;
3529 const struct wined3d_format
*format
;
3530 unsigned int format_attrs
;
3531 unsigned int format_caps
;
3532 enum wined3d_multisample_type multisample_type
;
3533 UINT multisample_quality
;
3535 unsigned int bind_flags
;
3536 unsigned int access
;
3543 unsigned int priority
;
3546 uint32_t pin_sysmem
: 1;
3548 struct wined3d_client_resource client
;
3551 const struct wined3d_parent_ops
*parent_ops
;
3552 const struct wined3d_resource_ops
*resource_ops
;
3554 struct list resource_list_entry
;
3556 LONG srv_bind_count_device
;
3557 LONG rtv_bind_count_device
;
3560 static inline ULONG
wined3d_resource_incref(struct wined3d_resource
*resource
)
3562 return resource
->resource_ops
->resource_incref(resource
);
3565 static inline ULONG
wined3d_resource_decref(struct wined3d_resource
*resource
)
3567 return resource
->resource_ops
->resource_decref(resource
);
3570 static inline HRESULT
wined3d_resource_get_sub_resource_desc(struct wined3d_resource
*resource
,
3571 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
)
3573 return resource
->resource_ops
->resource_sub_resource_get_desc(resource
, sub_resource_idx
, desc
);
3576 static inline void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource
*resource
,
3577 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
)
3579 resource
->resource_ops
->resource_sub_resource_get_map_pitch(resource
, sub_resource_idx
, row_pitch
, slice_pitch
);
3582 void resource_cleanup(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3583 HRESULT
resource_init(struct wined3d_resource
*resource
, struct wined3d_device
*device
,
3584 enum wined3d_resource_type type
, const struct wined3d_format
*format
,
3585 enum wined3d_multisample_type multisample_type
, unsigned int multisample_quality
, unsigned int usage
,
3586 unsigned int bind_flags
, unsigned int access
, unsigned int width
, unsigned int height
, unsigned int depth
,
3587 unsigned int size
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3588 const struct wined3d_resource_ops
*resource_ops
) DECLSPEC_HIDDEN
;
3589 void *resource_offset_map_pointer(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3590 uint8_t *base_memory
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3591 void resource_unload(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3592 HRESULT
wined3d_resource_check_box_dimensions(struct wined3d_resource
*resource
,
3593 unsigned int sub_resource_idx
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3594 void wined3d_resource_free_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3595 const struct wined3d_format
*wined3d_resource_get_decompress_format(
3596 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3597 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3598 GLbitfield
wined3d_resource_gl_map_flags(const struct wined3d_bo_gl
*bo
, DWORD d3d_flags
) DECLSPEC_HIDDEN
;
3599 GLenum
wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags
) DECLSPEC_HIDDEN
;
3600 GLbitfield
wined3d_resource_gl_storage_flags(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3601 BOOL
wined3d_resource_is_offscreen(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3602 BOOL
wined3d_resource_prepare_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3603 void wined3d_resource_update_draw_binding(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3604 void wined3d_resource_memory_colour_fill(struct wined3d_resource
*resource
,
3605 const struct wined3d_map_desc
*map
, const struct wined3d_color
*colour
,
3606 const struct wined3d_box
*box
, bool full_subresource
) DECLSPEC_HIDDEN
;
3608 /* Tests show that the start address of resources is 32 byte aligned */
3609 #define RESOURCE_ALIGNMENT 16
3610 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3612 #define WINED3D_LOCATION_DISCARDED 0x00000001
3613 #define WINED3D_LOCATION_SYSMEM 0x00000002
3614 #define WINED3D_LOCATION_CLEARED 0x00000004
3615 #define WINED3D_LOCATION_BUFFER 0x00000008
3616 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3617 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3618 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3619 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3620 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3622 const char *wined3d_debug_location(uint32_t location
) DECLSPEC_HIDDEN
;
3624 struct wined3d_blt_info
3627 struct wined3d_vec3 texcoords
[4];
3630 struct wined3d_texture_ops
3632 BOOL (*texture_prepare_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3633 struct wined3d_context
*context
, unsigned int location
);
3634 BOOL (*texture_load_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3635 struct wined3d_context
*context
, unsigned int location
);
3636 void (*texture_unload_location
)(struct wined3d_texture
*texture
,
3637 struct wined3d_context
*context
, unsigned int location
);
3638 void (*texture_upload_data
)(struct wined3d_context
*context
, const struct wined3d_const_bo_address
*src_bo_addr
,
3639 const struct wined3d_format
*src_format
, const struct wined3d_box
*src_box
, unsigned int src_row_pitch
,
3640 unsigned int src_slice_pitch
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3641 unsigned int dst_location
, unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
);
3642 void (*texture_download_data
)(struct wined3d_context
*context
, struct wined3d_texture
*src_texture
,
3643 unsigned int src_sub_resource_idx
, unsigned int src_location
, const struct wined3d_box
*src_box
,
3644 const struct wined3d_bo_address
*dst_bo_addr
, const struct wined3d_format
*dst_format
,
3645 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
,
3646 unsigned int dst_row_pitch
, unsigned int dst_slice_pitch
);
3649 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3650 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3651 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3652 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3653 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3654 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3655 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3656 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3657 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3658 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3659 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3660 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3661 #define WINED3D_TEXTURE_DISCARD 0x00002000
3662 #define WINED3D_TEXTURE_GET_DC 0x00004000
3663 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3664 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3666 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3668 struct wined3d_texture
3670 struct wined3d_resource resource
;
3671 const struct wined3d_texture_ops
*texture_ops
;
3672 struct wined3d_swapchain
*swapchain
;
3673 unsigned int pow2_width
;
3674 unsigned int pow2_height
;
3676 unsigned int level_count
;
3677 unsigned int download_count
;
3678 unsigned int sysmem_count
;
3679 float pow2_matrix
[16];
3683 DWORD update_map_binding
;
3685 unsigned int row_pitch
;
3686 unsigned int slice_pitch
;
3688 /* May only be accessed from the command stream worker thread. */
3689 struct wined3d_texture_async
3693 /* Color keys for DDraw */
3694 struct wined3d_color_key dst_blt_color_key
;
3695 struct wined3d_color_key src_blt_color_key
;
3696 struct wined3d_color_key dst_overlay_color_key
;
3697 struct wined3d_color_key src_overlay_color_key
;
3698 struct wined3d_color_key gl_color_key
;
3699 DWORD color_key_flags
;
3702 struct wined3d_dirty_regions
3704 struct wined3d_box
*boxes
;
3706 unsigned int box_count
;
3709 struct wined3d_overlay_info
3712 struct list overlays
;
3713 struct wined3d_texture
*dst_texture
;
3714 unsigned int dst_sub_resource_idx
;
3719 struct wined3d_dc_info
3725 struct wined3d_texture_sub_resource
3728 const struct wined3d_parent_ops
*parent_ops
;
3730 unsigned int offset
;
3733 unsigned int map_count
;
3736 struct wined3d_bo
*bo
;
3739 struct wined3d_color colour
;
3743 unsigned int stencil
;
3751 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s
, SIZE_T level_count
, SIZE_T layer_count
)
3753 struct wined3d_texture
*t
;
3755 if (level_count
> ((~(SIZE_T
)0 - s
) / sizeof(*t
->sub_resources
)) / layer_count
)
3758 return heap_alloc_zero(s
+ level_count
* layer_count
* sizeof(*t
->sub_resources
));
3761 static inline struct wined3d_texture
*texture_from_resource(struct wined3d_resource
*resource
)
3763 return CONTAINING_RECORD(resource
, struct wined3d_texture
, resource
);
3766 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture
*texture
,
3769 return max(1, texture
->resource
.width
>> level
);
3772 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture
*texture
,
3775 return max(1, texture
->resource
.height
>> level
);
3778 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture
*texture
,
3781 return max(1, texture
->resource
.depth
>> level
);
3784 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture
*texture
,
3787 return max(1, texture
->pow2_width
>> level
);
3790 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture
*texture
,
3793 return max(1, texture
->pow2_height
>> level
);
3796 static inline void wined3d_texture_get_level_box(const struct wined3d_texture
*texture
,
3797 unsigned int level
, struct wined3d_box
*box
)
3799 wined3d_box_set(box
, 0, 0,
3800 wined3d_texture_get_level_width(texture
, level
),
3801 wined3d_texture_get_level_height(texture
, level
),
3802 0, wined3d_texture_get_level_depth(texture
, level
));
3805 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture
*texture
,
3806 unsigned int level
, const RECT
*r
)
3810 t
= wined3d_texture_get_level_width(texture
, level
);
3811 if ((r
->left
&& r
->right
) || abs(r
->right
- r
->left
) != t
)
3813 t
= wined3d_texture_get_level_height(texture
, level
);
3814 if ((r
->top
&& r
->bottom
) || abs(r
->bottom
- r
->top
) != t
)
3819 HRESULT
texture2d_blt(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3820 const struct wined3d_box
*dst_box
, struct wined3d_texture
*src_texture
,
3821 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
, uint32_t flags
,
3822 const struct wined3d_blt_fx
*blt_fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
3823 void texture2d_get_blt_info(const struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
3824 const RECT
*rect
, struct wined3d_blt_info
*info
) DECLSPEC_HIDDEN
;
3825 void texture2d_load_fb_texture(struct wined3d_texture_gl
*texture_gl
, unsigned int sub_resource_idx
,
3826 BOOL srgb
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3827 void texture2d_read_from_framebuffer(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3828 struct wined3d_context
*context
, DWORD src_location
, DWORD dst_location
) DECLSPEC_HIDDEN
;
3830 void wined3d_texture_cleanup(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3831 void wined3d_texture_download_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3832 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
) DECLSPEC_HIDDEN
;
3833 void wined3d_texture_get_bo_address(const struct wined3d_texture
*texture
,
3834 unsigned int sub_resource_idx
, struct wined3d_bo_address
*data
, uint32_t location
) DECLSPEC_HIDDEN
;
3835 GLenum
wined3d_texture_get_gl_buffer(const struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3836 void wined3d_texture_invalidate_location(struct wined3d_texture
*texture
,
3837 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
3838 void wined3d_texture_load(struct wined3d_texture
*texture
,
3839 struct wined3d_context
*context
, BOOL srgb
) DECLSPEC_HIDDEN
;
3840 BOOL
wined3d_texture_load_location(struct wined3d_texture
*texture
,
3841 unsigned int sub_resource_idx
, struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3842 BOOL
wined3d_texture_prepare_location(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3843 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3844 void wined3d_texture_set_swapchain(struct wined3d_texture
*texture
,
3845 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3846 BOOL
wined3d_texture_can_use_pbo(const struct wined3d_texture
*texture
, const struct wined3d_d3d_info
*d3d_info
)
3848 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3849 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture
*texture
,
3850 HWND window
, RECT
*rect
) DECLSPEC_HIDDEN
;
3851 void wined3d_texture_update_sub_resource(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3852 struct wined3d_context
*context
, const struct upload_bo
*upload_bo
, const struct wined3d_box
*box
,
3853 unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
3854 void wined3d_texture_upload_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3855 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
, struct wined3d_texture
*src_texture
,
3856 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
) DECLSPEC_HIDDEN
;
3857 void wined3d_texture_validate_location(struct wined3d_texture
*texture
,
3858 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
3859 bool wined3d_texture_validate_sub_resource_idx(const struct wined3d_texture
*texture
,
3860 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
3861 void wined3d_texture_clear_dirty_regions(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3863 HRESULT
wined3d_texture_no3d_init(struct wined3d_texture
*texture_no3d
, struct wined3d_device
*device
,
3864 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
3865 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3867 void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle
[4], struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
3871 struct wined3d_sampler_desc sampler_desc
;
3872 unsigned int base_level
;
3876 struct wined3d_texture_gl
3878 struct wined3d_texture t
;
3880 struct gl_texture texture_rgb
, texture_srgb
;
3884 GLuint rb_multisample
;
3887 struct list renderbuffers
;
3888 const struct wined3d_renderbuffer_entry
*current_renderbuffer
;
3891 static inline struct wined3d_texture_gl
*wined3d_texture_gl(struct wined3d_texture
*texture
)
3893 return CONTAINING_RECORD(texture
, struct wined3d_texture_gl
, t
);
3896 static inline struct gl_texture
*wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl
*texture_gl
,
3899 return srgb
? &texture_gl
->texture_srgb
: &texture_gl
->texture_rgb
;
3902 static inline GLenum
wined3d_texture_gl_get_sub_resource_target(const struct wined3d_texture_gl
*texture_gl
,
3903 unsigned int sub_resource_idx
)
3905 static const GLenum cube_targets
[] =
3907 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
,
3908 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
,
3909 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
,
3910 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
,
3911 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
,
3912 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
,
3915 return texture_gl
->t
.resource
.usage
& WINED3DUSAGE_LEGACY_CUBEMAP
3916 ? cube_targets
[sub_resource_idx
/ texture_gl
->t
.level_count
] : texture_gl
->target
;
3919 static inline BOOL
wined3d_texture_gl_is_multisample_location(const struct wined3d_texture_gl
*texture_gl
,
3922 if (location
== WINED3D_LOCATION_RB_MULTISAMPLE
)
3924 if (location
!= WINED3D_LOCATION_TEXTURE_RGB
&& location
!= WINED3D_LOCATION_TEXTURE_SRGB
)
3926 return texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE
|| texture_gl
->target
== GL_TEXTURE_2D_MULTISAMPLE_ARRAY
;
3929 void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl
*texture_gl
,
3930 const struct wined3d_sampler_desc
*sampler_desc
, const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
3931 void wined3d_texture_gl_bind(struct wined3d_texture_gl
*texture_gl
,
3932 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
3933 void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl
*texture_gl
,
3934 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
3935 HRESULT
wined3d_texture_gl_init(struct wined3d_texture_gl
*texture_gl
, struct wined3d_device
*device
,
3936 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
3937 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3938 void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl
*texture_gl
,
3939 struct wined3d_context_gl
*context_gl
, BOOL srgb
) DECLSPEC_HIDDEN
;
3940 void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl
*texture_gl
,
3941 struct wined3d_context_gl
*context_gl
, unsigned int level
,
3942 const struct wined3d_rendertarget_info
*rt
) DECLSPEC_HIDDEN
;
3944 struct wined3d_renderbuffer_entry
3952 struct wined3d_fbo_resource
3956 GLuint level
, layer
;
3959 #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
3960 #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
3961 #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
3969 struct wined3d_fbo_entry_key
3972 struct wined3d_fbo_resource objects
[WINED3D_MAX_RENDER_TARGETS
+ 1];
3976 struct wined3d_sampler
3978 struct wine_rb_entry entry
;
3980 struct wined3d_device
*device
;
3982 const struct wined3d_parent_ops
*parent_ops
;
3983 struct wined3d_sampler_desc desc
;
3986 struct wined3d_sampler_gl
3988 struct wined3d_sampler s
;
3993 static inline struct wined3d_sampler_gl
*wined3d_sampler_gl(struct wined3d_sampler
*sampler
)
3995 return CONTAINING_RECORD(sampler
, struct wined3d_sampler_gl
, s
);
3998 void wined3d_sampler_gl_bind(struct wined3d_sampler_gl
*sampler_gl
, unsigned int unit
,
3999 struct wined3d_texture_gl
*texture_gl
, const struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4000 void wined3d_sampler_gl_init(struct wined3d_sampler_gl
*sampler_gl
,
4001 struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
4002 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4004 struct wined3d_vertex_declaration_element
4006 const struct wined3d_format
*format
;
4008 unsigned int input_slot
;
4009 unsigned int offset
;
4010 unsigned int output_slot
;
4011 enum wined3d_input_classification input_slot_class
;
4012 unsigned int instance_data_step_rate
;
4018 struct wined3d_vertex_declaration
4022 const struct wined3d_parent_ops
*parent_ops
;
4023 struct wined3d_device
*device
;
4025 struct wined3d_vertex_declaration_element
*elements
;
4026 unsigned int element_count
;
4028 BOOL position_transformed
;
4031 struct wined3d_saved_states
4033 uint32_t vs_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F
)];
4034 WORD vertexShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
4035 WORD vertexShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
4036 uint32_t ps_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F
)];
4037 WORD pixelShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
4038 WORD pixelShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
4039 uint32_t transform
[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE
+ 1)];
4040 WORD streamSource
; /* WINED3D_MAX_STREAMS, 16 */
4041 WORD streamFreq
; /* WINED3D_MAX_STREAMS, 16 */
4042 uint32_t renderState
[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE
+ 1)];
4043 DWORD textureState
[WINED3D_MAX_TEXTURES
]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
4044 WORD samplerState
[WINED3D_MAX_COMBINED_SAMPLERS
]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
4045 DWORD clipplane
; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
4046 DWORD textures
: 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
4050 DWORD vertexDecl
: 1;
4051 DWORD pixelShader
: 1;
4052 DWORD vertexShader
: 1;
4053 DWORD scissorRect
: 1;
4054 DWORD store_stream_offset
: 1;
4055 DWORD alpha_to_coverage
: 1;
4057 DWORD transforms
: 1;
4060 struct list changed_lights
;
4068 struct wined3d_stateblock
4070 LONG ref
; /* Note: Ref counting not required */
4071 struct wined3d_device
*device
;
4073 /* Array indicating whether things have been set or changed */
4074 struct wined3d_saved_states changed
;
4076 struct wined3d_stateblock_state stateblock_state
;
4077 struct wined3d_light_state light_state
;
4079 /* Contained state management */
4080 DWORD contained_render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
4081 unsigned int num_contained_render_states
;
4082 DWORD contained_transform_states
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
4083 unsigned int num_contained_transform_states
;
4084 struct StageState contained_tss_states
[WINED3D_MAX_TEXTURES
* (WINED3D_HIGHEST_TEXTURE_STATE
+ 1)];
4085 unsigned int num_contained_tss_states
;
4086 struct StageState contained_sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
* WINED3D_HIGHEST_SAMPLER_STATE
];
4087 unsigned int num_contained_sampler_states
;
4090 void wined3d_stateblock_state_init(struct wined3d_stateblock_state
*state
,
4091 const struct wined3d_device
*device
, uint32_t flags
) DECLSPEC_HIDDEN
;
4092 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state
*state
) DECLSPEC_HIDDEN
;
4094 bool wined3d_light_state_enable_light(struct wined3d_light_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
4095 struct wined3d_light_info
*light_info
, BOOL enable
) DECLSPEC_HIDDEN
;
4096 struct wined3d_light_info
*wined3d_light_state_get_light(const struct wined3d_light_state
*state
,
4097 unsigned int idx
) DECLSPEC_HIDDEN
;
4098 HRESULT
wined3d_light_state_set_light(struct wined3d_light_state
*state
, DWORD light_idx
,
4099 const struct wined3d_light
*params
, struct wined3d_light_info
**light_info
) DECLSPEC_HIDDEN
;
4101 enum wined3d_cs_queue_id
4103 WINED3D_CS_QUEUE_DEFAULT
= 0,
4104 WINED3D_CS_QUEUE_MAP
,
4105 WINED3D_CS_QUEUE_COUNT
,
4108 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
4110 #define WINED3D_CS_QUEUE_SIZE 0x1000000u
4112 #define WINED3D_CS_QUEUE_SIZE 0x400000u
4114 #define WINED3D_CS_SPIN_COUNT 2000u
4115 #define WINED3D_CS_QUEUE_MASK (WINED3D_CS_QUEUE_SIZE - 1)
4117 C_ASSERT(!(WINED3D_CS_QUEUE_SIZE
& (WINED3D_CS_QUEUE_SIZE
- 1)));
4119 struct wined3d_cs_queue
4122 BYTE data
[WINED3D_CS_QUEUE_SIZE
];
4125 struct wined3d_device_context_ops
4127 void *(*require_space
)(struct wined3d_device_context
*context
, size_t size
, enum wined3d_cs_queue_id queue_id
);
4128 void (*submit
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
4129 void (*finish
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
4130 bool (*map_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
4131 unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
4132 const struct wined3d_box
*box
, uint32_t flags
);
4133 bool (*unmap_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
4134 unsigned int sub_resource_idx
, struct wined3d_box
*box
, struct upload_bo
*upload_bo
);
4135 void (*issue_query
)(struct wined3d_device_context
*context
, struct wined3d_query
*query
, unsigned int flags
);
4136 void (*flush
)(struct wined3d_device_context
*context
);
4137 void (*reference_resource
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
);
4138 void (*reference_command_list
)(struct wined3d_device_context
*context
, struct wined3d_command_list
*list
);
4141 struct wined3d_device_context
4143 const struct wined3d_device_context_ops
*ops
;
4144 struct wined3d_device
*device
;
4145 struct wined3d_state
*state
;
4150 struct wined3d_device_context c
;
4152 struct wined3d_state state
;
4153 HMODULE wined3d_module
;
4156 BOOL serialize_commands
;
4158 struct wined3d_cs_queue queue
[WINED3D_CS_QUEUE_COUNT
];
4159 size_t data_size
, start
, end
;
4161 struct list query_poll_list
;
4162 BOOL queries_flushed
;
4164 HANDLE event
, present_event
;
4165 LONG waiting_for_event
;
4166 LONG waiting_for_present
;
4167 LONG pending_presents
;
4170 static inline void wined3d_device_context_lock(struct wined3d_device_context
*context
)
4172 if (context
== &context
->device
->cs
->c
)
4173 wined3d_mutex_lock();
4176 static inline void wined3d_device_context_unlock(struct wined3d_device_context
*context
)
4178 if (context
== &context
->device
->cs
->c
)
4179 wined3d_mutex_unlock();
4182 struct wined3d_cs
*wined3d_cs_create(struct wined3d_device
*device
,
4183 const enum wined3d_feature_level
*levels
, unsigned int level_count
) DECLSPEC_HIDDEN
;
4184 void wined3d_cs_destroy(struct wined3d_cs
*cs
) DECLSPEC_HIDDEN
;
4185 void wined3d_cs_destroy_object(struct wined3d_cs
*cs
,
4186 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
4187 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs
*cs
,
4188 struct wined3d_texture
*texture
, unsigned int layer
) DECLSPEC_HIDDEN
;
4189 void wined3d_cs_emit_clear(struct wined3d_cs
*cs
, DWORD rect_count
, const RECT
*rects
,
4190 uint32_t flags
, const struct wined3d_color
*color
, float depth
, DWORD stencil
) DECLSPEC_HIDDEN
;
4191 void wined3d_device_context_emit_clear_uav(struct wined3d_device_context
*context
,
4192 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
) DECLSPEC_HIDDEN
;
4193 void wined3d_cs_emit_preload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4194 void wined3d_cs_emit_present(struct wined3d_cs
*cs
, struct wined3d_swapchain
*swapchain
, const RECT
*src_rect
,
4195 const RECT
*dst_rect
, HWND dst_window_override
, unsigned int swap_interval
, uint32_t flags
) DECLSPEC_HIDDEN
;
4196 void wined3d_cs_emit_set_color_key(struct wined3d_cs
*cs
, struct wined3d_texture
*texture
,
4197 WORD flags
, const struct wined3d_color_key
*color_key
) DECLSPEC_HIDDEN
;
4198 void wined3d_cs_emit_set_render_state(struct wined3d_cs
*cs
,
4199 enum wined3d_render_state state
, DWORD value
) DECLSPEC_HIDDEN
;
4200 void wined3d_cs_emit_unload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
4201 void wined3d_cs_init_object(struct wined3d_cs
*cs
,
4202 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
4203 void wined3d_cs_map_bo_address(struct wined3d_cs
*cs
,
4204 struct wined3d_bo_address
*addr
, size_t size
, unsigned int flags
) DECLSPEC_HIDDEN
;
4205 void wined3d_device_context_set_depth_bounds(struct wined3d_device_context
*context
,
4206 bool enable
, float min_depth
, float max_depth
);
4208 static inline void wined3d_cs_finish(struct wined3d_cs
*cs
, enum wined3d_cs_queue_id queue_id
)
4210 cs
->c
.ops
->finish(&cs
->c
, queue_id
);
4213 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
*context
,
4214 struct wined3d_resource
*dst_resource
, unsigned int dst_sub_resource_idx
, const struct wined3d_box
*dst_box
,
4215 struct wined3d_resource
*src_resource
, unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
,
4216 unsigned int flags
, const struct wined3d_blt_fx
*fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
4217 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context
*context
,
4218 struct wined3d_rendertarget_view
*view
, const RECT
*rect
, unsigned int flags
,
4219 const struct wined3d_color
*color
, float depth
, unsigned int stencil
) DECLSPEC_HIDDEN
;
4220 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context
*context
,
4221 struct wined3d_buffer
*dst_buffer
, unsigned int offset
,
4222 struct wined3d_unordered_access_view
*uav
) DECLSPEC_HIDDEN
;
4223 void wined3d_device_context_emit_draw(struct wined3d_device_context
*context
,
4224 enum wined3d_primitive_type primitive_type
, unsigned int patch_vertex_count
, int base_vertex_idx
,
4225 unsigned int start_idx
, unsigned int index_count
, unsigned int start_instance
, unsigned int instance_count
,
4226 bool indexed
) DECLSPEC_HIDDEN
;
4227 void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context
*context
,
4228 struct wined3d_command_list
*list
, bool restore_state
) DECLSPEC_HIDDEN
;
4229 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context
*context
,
4230 struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
4231 HRESULT
wined3d_device_context_emit_map(struct wined3d_device_context
*context
,
4232 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
4233 const struct wined3d_box
*box
, unsigned int flags
) DECLSPEC_HIDDEN
;
4234 void wined3d_device_context_emit_reset_state(struct wined3d_device_context
*context
, bool invalidate
) DECLSPEC_HIDDEN
;
4235 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context
*context
,
4236 struct wined3d_blend_state
*state
, const struct wined3d_color
*blend_factor
,
4237 unsigned int sample_mask
) DECLSPEC_HIDDEN
;
4238 void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context
*context
, unsigned int plane_idx
,
4239 const struct wined3d_vec4
*plane
) DECLSPEC_HIDDEN
;
4240 void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context
*context
,
4241 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
4242 const struct wined3d_constant_buffer_state
*buffers
) DECLSPEC_HIDDEN
;
4243 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context
*context
,
4244 struct wined3d_depth_stencil_state
*state
, unsigned int stencil_ref
) DECLSPEC_HIDDEN
;
4245 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context
*context
,
4246 struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
4247 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context
*context
,
4248 enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
4249 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context
*context
, struct wined3d_buffer
*buffer
,
4250 enum wined3d_format_id format_id
, unsigned int offset
) DECLSPEC_HIDDEN
;
4251 void wined3d_device_context_emit_set_light(struct wined3d_device_context
*context
,
4252 const struct wined3d_light_info
*light
) DECLSPEC_HIDDEN
;
4253 void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context
*context
, unsigned int idx
,
4254 BOOL enable
) DECLSPEC_HIDDEN
;
4255 void wined3d_device_context_emit_set_material(struct wined3d_device_context
*context
,
4256 const struct wined3d_material
*material
) DECLSPEC_HIDDEN
;
4257 void wined3d_device_context_emit_set_predication(struct wined3d_device_context
*context
,
4258 struct wined3d_query
*predicate
, BOOL value
) DECLSPEC_HIDDEN
;
4259 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context
*context
,
4260 struct wined3d_rasterizer_state
*rasterizer_state
) DECLSPEC_HIDDEN
;
4261 void wined3d_device_context_emit_set_render_state(struct wined3d_device_context
*context
,
4262 enum wined3d_render_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
4263 void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context
*context
, unsigned int start_idx
,
4264 unsigned int count
, struct wined3d_rendertarget_view
*const *views
) DECLSPEC_HIDDEN
;
4265 void wined3d_device_context_emit_set_samplers(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
4266 unsigned int start_idx
, unsigned int count
, struct wined3d_sampler
*const *samplers
) DECLSPEC_HIDDEN
;
4267 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context
*context
, unsigned int sampler_idx
,
4268 enum wined3d_sampler_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
4269 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context
*context
,
4270 unsigned int rect_count
, const RECT
*rects
) DECLSPEC_HIDDEN
;
4271 void wined3d_device_context_emit_set_shader(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
4272 struct wined3d_shader
*shader
) DECLSPEC_HIDDEN
;
4273 void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context
*context
,
4274 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
4275 struct wined3d_shader_resource_view
*const *views
) DECLSPEC_HIDDEN
;
4276 void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context
*context
,
4277 const struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
]) DECLSPEC_HIDDEN
;
4278 void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context
*context
,
4279 unsigned int start_idx
, unsigned int count
, const struct wined3d_stream_state
*streams
) DECLSPEC_HIDDEN
;
4280 void wined3d_device_context_emit_set_texture(struct wined3d_device_context
*context
, unsigned int stage
,
4281 struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
4282 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context
*context
, unsigned int stage
,
4283 enum wined3d_texture_stage_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
4284 void wined3d_device_context_emit_set_transform(struct wined3d_device_context
*context
,
4285 enum wined3d_transform_state state
, const struct wined3d_matrix
*matrix
) DECLSPEC_HIDDEN
;
4286 void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context
*context
,
4287 enum wined3d_pipeline pipeline
, unsigned int start_idx
, unsigned int count
,
4288 struct wined3d_unordered_access_view
*const *views
, const unsigned int *initial_count
) DECLSPEC_HIDDEN
;
4289 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context
*context
,
4290 struct wined3d_vertex_declaration
*declaration
) DECLSPEC_HIDDEN
;
4291 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context
*context
, unsigned int viewport_count
,
4292 const struct wined3d_viewport
*viewports
) DECLSPEC_HIDDEN
;
4293 void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context
*context
,
4294 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, const struct wined3d_box
*box
,
4295 const void *data
, unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
4296 HRESULT
wined3d_device_context_emit_unmap(struct wined3d_device_context
*context
,
4297 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
4298 void wined3d_device_context_push_constants(struct wined3d_device_context
*context
,
4299 enum wined3d_push_constants type
, unsigned int start_idx
,
4300 unsigned int count
, const void *constants
) DECLSPEC_HIDDEN
;
4302 static inline void wined3d_resource_reference(struct wined3d_resource
*resource
)
4304 const struct wined3d_cs
*cs
= resource
->device
->cs
;
4305 resource
->access_time
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
4308 static inline BOOL
wined3d_ge_wrap(ULONG x
, ULONG y
)
4310 return (x
- y
) < UINT_MAX
/ 2;
4312 C_ASSERT(WINED3D_CS_QUEUE_SIZE
< UINT_MAX
/ 4);
4314 static inline void wined3d_resource_wait_idle(const struct wined3d_resource
*resource
)
4316 const struct wined3d_cs
*cs
= resource
->device
->cs
;
4317 ULONG access_time
, tail
, head
;
4319 if (!cs
->thread
|| cs
->thread_id
== GetCurrentThreadId())
4322 access_time
= resource
->access_time
;
4323 head
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
4325 /* The basic idea is that a resource is busy if tail < access_time <= head.
4326 * But we have to be careful about wrap-around of the head and tail. The
4327 * wined3d_ge_wrap function considers x >= y if x - y is smaller than half the
4328 * UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because
4329 * otherwise the queue memory is considered full and queue_require_space
4330 * stalls. Thus wined3d_ge_wrap(head, tail) is always true. The C_ASSERT above
4331 * ensures this in case we decide to grow the queue size in the future.
4333 * It is possible that a resource has not been used for a long time and is idle, but the head and
4334 * tail wrapped around in such a way that the previously set access time falls between head and tail.
4335 * In this case we will incorrectly wait for the resource. Because we use the entire 32 bits of the
4336 * counters and not just the bits needed to address the actual queue memory, this should happen rarely.
4337 * If it turns out to be a problem we can switch to 64 bit counters or attempt to somehow mark the
4338 * access time of resources invalid. CS packets are at least 4 byte aligned, so we could use the lower
4339 * 2 bits in access_time for such a marker.
4341 * Note that the access time is set before the command is submitted, so we have to wait until the
4342 * tail is bigger than access_time, not equal. */
4344 if (!wined3d_ge_wrap(head
, access_time
))
4349 tail
= *(volatile ULONG
*)&cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].tail
;
4350 if (head
== tail
) /* Queue empty. */
4353 if (!wined3d_ge_wrap(access_time
, tail
) && access_time
!= tail
)
4360 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
4361 * fixed function semantics as D3DCOLOR or FLOAT16 */
4362 enum wined3d_buffer_conversion_type
4369 struct wined3d_buffer
4371 struct wined3d_resource resource
;
4372 const struct wined3d_buffer_ops
*buffer_ops
;
4374 unsigned int structure_byte_stride
;
4378 struct wined3d_bo
*buffer_object
;
4379 struct wined3d_bo_user bo_user
;
4381 struct wined3d_range
*maps
;
4382 SIZE_T maps_size
, modified_areas
;
4384 /* conversion stuff */
4385 UINT decl_change_count
, full_conversion_count
;
4387 UINT stride
; /* 0 if no conversion */
4388 enum wined3d_buffer_conversion_type
*conversion_map
; /* NULL if no conversion */
4389 UINT conversion_stride
; /* 0 if no shifted conversion */
4392 static inline struct wined3d_buffer
*buffer_from_resource(struct wined3d_resource
*resource
)
4394 return CONTAINING_RECORD(resource
, struct wined3d_buffer
, resource
);
4397 static inline void wined3d_buffer_validate_user(struct wined3d_buffer
*buffer
)
4399 if (buffer
->bo_user
.valid
)
4401 buffer
->bo_user
.valid
= true;
4402 list_add_head(&buffer
->buffer_object
->users
, &buffer
->bo_user
.entry
);
4405 void wined3d_buffer_cleanup(struct wined3d_buffer
*buffer
) DECLSPEC_HIDDEN
;
4406 void wined3d_buffer_copy(struct wined3d_buffer
*dst_buffer
, unsigned int dst_offset
,
4407 struct wined3d_buffer
*src_buffer
, unsigned int src_offset
, unsigned int size
) DECLSPEC_HIDDEN
;
4408 void wined3d_buffer_copy_bo_address(struct wined3d_buffer
*dst_buffer
, struct wined3d_context
*context
,
4409 unsigned int dst_offset
, const struct wined3d_const_bo_address
*src_addr
, unsigned int size
) DECLSPEC_HIDDEN
;
4410 DWORD
wined3d_buffer_get_memory(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
4411 struct wined3d_bo_address
*data
) DECLSPEC_HIDDEN
;
4412 void wined3d_buffer_invalidate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
4413 void wined3d_buffer_load(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
4414 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
4415 BOOL
wined3d_buffer_load_location(struct wined3d_buffer
*buffer
,
4416 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4417 void *wined3d_buffer_load_sysmem(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4418 BOOL
wined3d_buffer_prepare_location(struct wined3d_buffer
*buffer
,
4419 struct wined3d_context
*context
, unsigned int location
) DECLSPEC_HIDDEN
;
4420 void wined3d_buffer_update_sub_resource(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
4421 const struct upload_bo
*upload_bo
, unsigned int offset
, unsigned int size
) DECLSPEC_HIDDEN
;
4422 void wined3d_buffer_validate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
4424 HRESULT
wined3d_buffer_no3d_init(struct wined3d_buffer
*buffer_no3d
, struct wined3d_device
*device
,
4425 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
4426 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4428 struct wined3d_buffer_gl
4430 struct wined3d_buffer b
;
4433 static inline struct wined3d_buffer_gl
*wined3d_buffer_gl(struct wined3d_buffer
*buffer
)
4435 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
4438 static inline const struct wined3d_buffer_gl
*wined3d_buffer_gl_const(const struct wined3d_buffer
*buffer
)
4440 return CONTAINING_RECORD(buffer
, struct wined3d_buffer_gl
, b
);
4443 HRESULT
wined3d_buffer_gl_init(struct wined3d_buffer_gl
*buffer_gl
, struct wined3d_device
*device
,
4444 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
4445 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4447 struct wined3d_rendertarget_view
4451 struct wined3d_resource
*resource
;
4453 const struct wined3d_parent_ops
*parent_ops
;
4455 const struct wined3d_format
*format
;
4456 unsigned int format_attrs
;
4457 unsigned int format_caps
;
4458 unsigned int sub_resource_idx
;
4459 unsigned int layer_count
;
4462 unsigned int height
;
4464 struct wined3d_view_desc desc
;
4467 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
4468 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view
*view
,
4469 const struct wined3d_context
*context
, unsigned int *width
, unsigned int *height
) DECLSPEC_HIDDEN
;
4470 void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view
*view
,
4471 struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4472 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view
*view
,
4473 uint32_t location
) DECLSPEC_HIDDEN
;
4474 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view
*view
,
4475 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4476 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view
*view
,
4477 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
4478 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view
*view
,
4479 uint32_t location
) DECLSPEC_HIDDEN
;
4480 DWORD
wined3d_rendertarget_view_get_locations(const struct wined3d_rendertarget_view
*view
)
4483 HRESULT
wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view
*view_no3d
,
4484 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4485 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4487 struct wined3d_rendertarget_view_gl
4489 struct wined3d_rendertarget_view v
;
4490 struct wined3d_gl_view gl_view
;
4493 static inline struct wined3d_rendertarget_view_gl
*wined3d_rendertarget_view_gl(
4494 struct wined3d_rendertarget_view
*view
)
4496 return CONTAINING_RECORD(view
, struct wined3d_rendertarget_view_gl
, v
);
4499 HRESULT
wined3d_rendertarget_view_gl_init(struct wined3d_rendertarget_view_gl
*view_gl
,
4500 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4501 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4503 struct wined3d_shader_resource_view
4507 struct wined3d_resource
*resource
;
4509 const struct wined3d_parent_ops
*parent_ops
;
4511 const struct wined3d_format
*format
;
4513 struct wined3d_view_desc desc
;
4516 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
4518 struct wined3d_shader_resource_view_gl
4520 struct wined3d_shader_resource_view v
;
4521 struct wined3d_bo_user bo_user
;
4522 struct wined3d_gl_view gl_view
;
4525 static inline struct wined3d_shader_resource_view_gl
*wined3d_shader_resource_view_gl(
4526 struct wined3d_shader_resource_view
*view
)
4528 return CONTAINING_RECORD(view
, struct wined3d_shader_resource_view_gl
, v
);
4531 void wined3d_shader_resource_view_gl_bind(struct wined3d_shader_resource_view_gl
*view_gl
, unsigned int unit
,
4532 struct wined3d_sampler_gl
*sampler_gl
, struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4533 void wined3d_shader_resource_view_gl_generate_mipmap(struct wined3d_shader_resource_view_gl
*srv_gl
,
4534 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4535 HRESULT
wined3d_shader_resource_view_gl_init(struct wined3d_shader_resource_view_gl
*view_gl
,
4536 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4537 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4538 void wined3d_shader_resource_view_gl_update(struct wined3d_shader_resource_view_gl
*srv_gl
,
4539 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4541 struct wined3d_unordered_access_view
4545 struct wined3d_resource
*resource
;
4547 const struct wined3d_parent_ops
*parent_ops
;
4549 const struct wined3d_format
*format
;
4551 struct wined3d_view_desc desc
;
4552 struct wined3d_bo
*counter_bo
;
4555 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view
*view
) DECLSPEC_HIDDEN
;
4556 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view
*view
,
4557 struct wined3d_buffer
*buffer
, unsigned int offset
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4558 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view
*view
,
4559 uint32_t location
) DECLSPEC_HIDDEN
;
4560 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view
*view
,
4561 unsigned int value
) DECLSPEC_HIDDEN
;
4563 struct wined3d_unordered_access_view_gl
4565 struct wined3d_unordered_access_view v
;
4566 struct wined3d_bo_user bo_user
;
4567 struct wined3d_gl_view gl_view
;
4568 struct wined3d_bo_gl counter_bo
;
4571 static inline struct wined3d_unordered_access_view_gl
*wined3d_unordered_access_view_gl(
4572 struct wined3d_unordered_access_view
*view
)
4574 return CONTAINING_RECORD(view
, struct wined3d_unordered_access_view_gl
, v
);
4577 void wined3d_unordered_access_view_gl_clear(struct wined3d_unordered_access_view_gl
*view_gl
,
4578 const struct wined3d_uvec4
*clear_value
, struct wined3d_context_gl
*context_gl
, bool fp
) DECLSPEC_HIDDEN
;
4579 HRESULT
wined3d_unordered_access_view_gl_init(struct wined3d_unordered_access_view_gl
*view_gl
,
4580 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
4581 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4582 void wined3d_unordered_access_view_gl_update(struct wined3d_unordered_access_view_gl
*uav_gl
,
4583 struct wined3d_context_gl
*context_gl
) DECLSPEC_HIDDEN
;
4585 struct wined3d_swapchain_state
4587 struct wined3d
*wined3d
;
4588 struct wined3d_swapchain_desc desc
;
4589 struct wined3d_swapchain_state_parent
*parent
;
4591 struct wined3d_display_mode original_mode
, d3d_mode
;
4592 RECT original_window_rect
;
4594 /* Window styles to restore when switching fullscreen mode. */
4600 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
4601 void wined3d_swapchain_state_register(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
4602 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state
*state
,
4603 HWND window
, const RECT
*window_rect
) DECLSPEC_HIDDEN
;
4604 HRESULT
wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
*state
,
4605 HWND window
, int x
, int y
, int width
, int height
) DECLSPEC_HIDDEN
;
4607 struct wined3d_swapchain_ops
4609 void (*swapchain_present
)(struct wined3d_swapchain
*swapchain
,
4610 const RECT
*src_rect
, const RECT
*dst_rect
, unsigned int swap_interval
, uint32_t flags
);
4611 void (*swapchain_frontbuffer_updated
)(struct wined3d_swapchain
*swapchain
);
4614 struct wined3d_swapchain
4618 const struct wined3d_parent_ops
*parent_ops
;
4619 const struct wined3d_swapchain_ops
*swapchain_ops
;
4620 struct wined3d_device
*device
;
4622 struct wined3d_texture
**back_buffers
;
4623 struct wined3d_texture
*front_buffer
;
4624 struct wined3d_gamma_ramp orig_gamma
;
4626 const struct wined3d_format
*ds_format
;
4627 struct wined3d_palette
*palette
;
4628 RECT front_buffer_update
;
4629 unsigned int swap_interval
;
4630 unsigned int max_frame_latency
;
4632 LONG prev_time
, frames
; /* Performance tracking */
4634 struct wined3d_swapchain_state state
;
4638 void wined3d_swapchain_activate(struct wined3d_swapchain
*swapchain
, BOOL activate
) DECLSPEC_HIDDEN
;
4639 void wined3d_swapchain_cleanup(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4640 struct wined3d_output
* wined3d_swapchain_get_output(const struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4641 void swapchain_update_draw_bindings(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4642 void swapchain_set_max_frame_latency(struct wined3d_swapchain
*swapchain
,
4643 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
4645 HRESULT
wined3d_swapchain_no3d_init(struct wined3d_swapchain
*swapchain_no3d
,
4646 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
4647 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
4648 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4650 struct wined3d_swapchain_gl
4652 struct wined3d_swapchain s
;
4655 static inline struct wined3d_swapchain_gl
*wined3d_swapchain_gl(struct wined3d_swapchain
*swapchain
)
4657 return CONTAINING_RECORD(swapchain
, struct wined3d_swapchain_gl
, s
);
4660 void wined3d_swapchain_gl_cleanup(struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
4661 struct wined3d_context_gl
*wined3d_swapchain_gl_get_context(struct wined3d_swapchain_gl
*swapchain_gl
) DECLSPEC_HIDDEN
;
4662 HRESULT
wined3d_swapchain_gl_init(struct wined3d_swapchain_gl
*swapchain_gl
,
4663 struct wined3d_device
*device
, struct wined3d_swapchain_desc
*desc
,
4664 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
4665 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4667 /*****************************************************************************
4668 * Utility function prototypes
4671 /* Trace routines */
4672 const char *debug_bo_address(const struct wined3d_bo_address
*address
) DECLSPEC_HIDDEN
;
4673 const char *debug_box(const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4674 const char *debug_color(const struct wined3d_color
*color
) DECLSPEC_HIDDEN
;
4675 const char *debug_const_bo_address(const struct wined3d_const_bo_address
*address
) DECLSPEC_HIDDEN
;
4676 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
) DECLSPEC_HIDDEN
;
4677 const char *debug_d3dformat(enum wined3d_format_id format_id
) DECLSPEC_HIDDEN
;
4678 const char *debug_d3ddevicetype(enum wined3d_device_type device_type
) DECLSPEC_HIDDEN
;
4679 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type
) DECLSPEC_HIDDEN
;
4680 const char *debug_d3dusage(uint32_t usage
) DECLSPEC_HIDDEN
;
4681 const char *debug_d3ddeclmethod(enum wined3d_decl_method method
) DECLSPEC_HIDDEN
;
4682 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
4683 const char *debug_d3dinput_classification(enum wined3d_input_classification classification
) DECLSPEC_HIDDEN
;
4684 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type
) DECLSPEC_HIDDEN
;
4685 const char *debug_d3drenderstate(enum wined3d_render_state state
) DECLSPEC_HIDDEN
;
4686 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state
) DECLSPEC_HIDDEN
;
4687 const char *debug_d3dstate(uint32_t state
) DECLSPEC_HIDDEN
;
4688 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type
) DECLSPEC_HIDDEN
;
4689 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state
) DECLSPEC_HIDDEN
;
4690 const char *debug_d3dtop(enum wined3d_texture_op d3dtop
) DECLSPEC_HIDDEN
;
4691 const char *debug_d3dtstype(enum wined3d_transform_state tstype
) DECLSPEC_HIDDEN
;
4692 const char *debug_ivec4(const struct wined3d_ivec4
*v
) DECLSPEC_HIDDEN
;
4693 const char *debug_uvec4(const struct wined3d_uvec4
*v
) DECLSPEC_HIDDEN
;
4694 const char *debug_shader_type(enum wined3d_shader_type shader_type
) DECLSPEC_HIDDEN
;
4695 const char *debug_vec4(const struct wined3d_vec4
*v
) DECLSPEC_HIDDEN
;
4696 const char *wined3d_debug_feature_level(enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
4697 void dump_color_fixup_desc(struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
4699 BOOL
is_invalid_op(const struct wined3d_state
*state
, int stage
,
4700 enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
) DECLSPEC_HIDDEN
;
4701 void set_tex_op_nvrc(const struct wined3d_gl_info
*gl_info
, const struct wined3d_state
*state
,
4702 BOOL is_alpha
, int stage
, enum wined3d_texture_op op
, uint32_t arg1
, uint32_t arg2
, uint32_t arg3
,
4703 INT texture_idx
, DWORD dst
) DECLSPEC_HIDDEN
;
4704 void texture_activate_dimensions(struct wined3d_texture
*texture
,
4705 const struct wined3d_gl_info
*gl_info
) DECLSPEC_HIDDEN
;
4706 void sampler_texdim(struct wined3d_context
*context
,
4707 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4708 void tex_alphaop(struct wined3d_context
*context
,
4709 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4710 void apply_pixelshader(struct wined3d_context
*context
,
4711 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4712 void state_alpha_test(struct wined3d_context
*context
,
4713 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4714 void state_fogcolor(struct wined3d_context
*context
,
4715 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4716 void state_fogdensity(struct wined3d_context
*context
,
4717 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4718 void state_fogstartend(struct wined3d_context
*context
,
4719 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4720 void state_fog_fragpart(struct wined3d_context
*context
,
4721 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4722 void state_nop(struct wined3d_context
*context
,
4723 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4724 void state_srgbwrite(struct wined3d_context
*context
,
4725 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4727 void state_clipping(struct wined3d_context
*context
,
4728 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4729 void clipplane(struct wined3d_context
*context
,
4730 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4731 void state_pointsprite_w(struct wined3d_context
*context
,
4732 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4733 void state_pointsprite(struct wined3d_context
*context
,
4734 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4735 void state_shademode(struct wined3d_context
*context
,
4736 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4739 void multiply_matrix(struct wined3d_matrix
*dest
, const struct wined3d_matrix
*src1
,
4740 const struct wined3d_matrix
*src2
) DECLSPEC_HIDDEN
;
4742 void wined3d_release_dc(HWND window
, HDC dc
) DECLSPEC_HIDDEN
;
4744 struct wined3d_shader_lconst
4748 unsigned int value
[4];
4751 struct wined3d_shader_limits
4753 unsigned int sampler
;
4754 unsigned int constant_int
;
4755 unsigned int constant_float
;
4756 unsigned int constant_bool
;
4757 unsigned int packed_output
;
4758 unsigned int packed_input
;
4761 #define wined3d_lock_init(lock, name) wined3d_lock_init_(lock, __FILE__ ": " name)
4762 static inline void wined3d_lock_init_(CRITICAL_SECTION
*lock
, const char *name
)
4764 InitializeCriticalSection(lock
);
4765 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
4766 lock
->DebugInfo
->Spare
[0] = (DWORD_PTR
)name
;
4769 static inline void wined3d_lock_cleanup(CRITICAL_SECTION
*lock
)
4771 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
4772 lock
->DebugInfo
->Spare
[0] = 0;
4773 DeleteCriticalSection(lock
);
4777 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
4779 #define PRINTF_ATTR(fmt,args)
4782 struct wined3d_string_buffer_list
4787 struct wined3d_string_buffer
*string_buffer_get(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4788 void string_buffer_sprintf(struct wined3d_string_buffer
*buffer
, const char *format
, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN
;
4789 void string_buffer_release(struct wined3d_string_buffer_list
*list
, struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4790 void string_buffer_list_init(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4791 void string_buffer_list_cleanup(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4793 int shader_addline(struct wined3d_string_buffer
*buffer
, const char *fmt
, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN
;
4794 BOOL
string_buffer_resize(struct wined3d_string_buffer
*buffer
, int rc
) DECLSPEC_HIDDEN
;
4795 int shader_vaddline(struct wined3d_string_buffer
*buffer
, const char *fmt
, va_list args
) DECLSPEC_HIDDEN
;
4797 struct wined3d_shader_phase
4801 unsigned int instance_count
;
4802 unsigned int temporary_count
;
4805 struct wined3d_vertex_shader
4807 struct wined3d_shader_attribute attributes
[MAX_ATTRIBS
];
4810 struct wined3d_hull_shader
4814 struct wined3d_shader_phase
*control_point
;
4815 unsigned int fork_count
;
4816 unsigned int join_count
;
4817 struct wined3d_shader_phase
*fork
;
4819 struct wined3d_shader_phase
*join
;
4822 unsigned int output_vertex_count
;
4823 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
4824 enum wined3d_tessellator_partitioning tessellator_partitioning
;
4827 struct wined3d_domain_shader
4829 enum wined3d_tessellator_domain tessellator_domain
;
4832 struct wined3d_geometry_shader
4834 enum wined3d_primitive_type input_type
;
4835 enum wined3d_primitive_type output_type
;
4836 unsigned int vertices_out
;
4837 unsigned int instance_count
;
4839 const struct wined3d_stream_output_desc
*so_desc
;
4842 struct wined3d_pixel_shader
4844 /* Pixel shader input semantics */
4845 unsigned int input_reg_map
[MAX_REG_INPUT
];
4846 DWORD input_reg_used
; /* MAX_REG_INPUT, 32 */
4847 unsigned int declared_in_count
;
4849 /* Some information about the shader behavior */
4851 unsigned int color0_reg
;
4853 BOOL force_early_depth_stencil
;
4854 enum wined3d_shader_register_type depth_output
;
4855 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
4858 struct wined3d_compute_shader
4860 struct wined3d_shader_thread_group_size thread_group_size
;
4863 struct wined3d_shader
4866 const struct wined3d_shader_limits
*limits
;
4867 const DWORD
*function
;
4868 unsigned int functionLength
;
4870 unsigned int byte_code_size
;
4871 BOOL load_local_constsF
;
4872 const struct wined3d_shader_frontend
*frontend
;
4873 void *frontend_data
;
4877 const struct wined3d_parent_ops
*parent_ops
;
4879 /* Programs this shader is linked with */
4880 struct list linked_programs
;
4882 /* Immediate constants (override global ones) */
4883 struct list constantsB
;
4884 struct list constantsF
;
4885 struct list constantsI
;
4886 struct wined3d_shader_reg_maps reg_maps
;
4887 BOOL lconst_inf_or_nan
;
4889 struct wined3d_shader_signature input_signature
;
4890 struct wined3d_shader_signature output_signature
;
4891 struct wined3d_shader_signature patch_constant_signature
;
4893 /* Pointer to the parent device */
4894 struct wined3d_device
*device
;
4895 struct list shader_list_entry
;
4899 struct wined3d_vertex_shader vs
;
4900 struct wined3d_hull_shader hs
;
4901 struct wined3d_domain_shader ds
;
4902 struct wined3d_geometry_shader gs
;
4903 struct wined3d_pixel_shader ps
;
4904 struct wined3d_compute_shader cs
;
4908 enum wined3d_shader_resource_type
pixelshader_get_resource_type(const struct wined3d_shader_reg_maps
*reg_maps
,
4909 unsigned int resource_idx
, DWORD tex_types
) DECLSPEC_HIDDEN
;
4910 void find_ps_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4911 BOOL position_transformed
, struct ps_compile_args
*args
,
4912 const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4914 bool vshader_get_input(const struct wined3d_shader
*shader
,
4915 uint8_t usage_req
, uint8_t usage_idx_req
, unsigned int *regnum
) DECLSPEC_HIDDEN
;
4916 void find_vs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4917 struct vs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4919 void find_ds_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4920 struct ds_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4922 void find_gs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4923 struct gs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4925 void string_buffer_clear(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4926 BOOL
string_buffer_init(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4927 void string_buffer_free(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4928 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps
*reg_maps
,
4929 unsigned int max
) DECLSPEC_HIDDEN
;
4930 HRESULT
shader_generate_code(const struct wined3d_shader
*shader
, struct wined3d_string_buffer
*buffer
,
4931 const struct wined3d_shader_reg_maps
*reg_maps
, void *backend_ctx
,
4932 const DWORD
*start
, const DWORD
*end
) DECLSPEC_HIDDEN
;
4933 BOOL
shader_match_semantic(const char *semantic_name
, enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
4935 static inline BOOL
shader_is_scalar(const struct wined3d_shader_register
*reg
)
4939 case WINED3DSPR_RASTOUT
:
4941 if (reg
->idx
[0].offset
)
4946 case WINED3DSPR_CONSTBOOL
: /* b# */
4947 case WINED3DSPR_DEPTHOUT
: /* oDepth */
4948 case WINED3DSPR_DEPTHOUTGE
:
4949 case WINED3DSPR_DEPTHOUTLE
:
4950 case WINED3DSPR_LOOP
: /* aL */
4951 case WINED3DSPR_OUTPOINTID
:
4952 case WINED3DSPR_PREDICATE
: /* p0 */
4953 case WINED3DSPR_PRIMID
: /* primID */
4954 case WINED3DSPR_COVERAGE
: /* vCoverage */
4955 case WINED3DSPR_SAMPLEMASK
: /* oMask */
4958 case WINED3DSPR_MISCTYPE
:
4959 switch (reg
->idx
[0].offset
)
4969 case WINED3DSPR_IMMCONST
:
4970 return reg
->immconst_type
== WINED3D_IMMCONST_SCALAR
;
4977 static inline void shader_get_position_fixup(const struct wined3d_context
*context
,
4978 const struct wined3d_state
*state
, unsigned int fixup_count
, float *position_fixup
)
4980 float center_offset
, x
= 0.0f
, y
= 0.0f
;
4983 /* See get_projection_matrix() in utils.c for a discussion of the position fixup.
4984 * This function here also applies to d3d10+ which does not need adjustment for
4985 * integer pixel centers, but it may need the filling convention offset. */
4986 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_PIXEL_CENTER_INTEGER
)
4987 center_offset
= 1.0f
;
4989 center_offset
= 0.0f
;
4991 center_offset
+= context
->d3d_info
->filling_convention_offset
;
4993 for (i
= 0; i
< fixup_count
; ++i
)
4995 position_fixup
[4 * i
] = 1.0f
;
4996 position_fixup
[4 * i
+ 1] = 1.0f
;
4997 if (!context
->d3d_info
->subpixel_viewport
)
5000 x
= modf(state
->viewports
[i
].x
, &dummy
) * 2.0f
;
5001 y
= modf(state
->viewports
[i
].y
, &dummy
) * 2.0f
;
5003 position_fixup
[4 * i
+ 2] = (center_offset
+ x
) / state
->viewports
[i
].width
;
5004 position_fixup
[4 * i
+ 3] = -(center_offset
+ y
) / state
->viewports
[i
].height
;
5006 if (context
->render_offscreen
)
5008 position_fixup
[4 * i
+ 1] *= -1.0f
;
5009 position_fixup
[4 * i
+ 3] *= -1.0f
;
5014 static inline BOOL
shader_constant_is_local(const struct wined3d_shader
*shader
, DWORD reg
)
5016 struct wined3d_shader_lconst
*lconst
;
5018 if (shader
->load_local_constsF
)
5021 LIST_FOR_EACH_ENTRY(lconst
, &shader
->constantsF
, struct wined3d_shader_lconst
, entry
)
5023 if (lconst
->idx
== reg
)
5030 void get_identity_matrix(struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5031 void get_modelview_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5032 unsigned int index
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5033 void get_projection_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5034 struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5035 void get_texture_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5036 unsigned int tex
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
5037 void get_pointsize_minmax(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5038 float *out_min
, float *out_max
) DECLSPEC_HIDDEN
;
5039 void get_pointsize(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5040 float *out_pointsize
, float *out_att
) DECLSPEC_HIDDEN
;
5041 void get_fog_start_end(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
5042 float *start
, float *end
) DECLSPEC_HIDDEN
;
5044 /* Using additional shader constants (uniforms in GLSL / program environment
5045 * or local parameters in ARB) is costly:
5046 * ARB only knows float4 parameters and GLSL compiler are not really smart
5047 * when it comes to efficiently pack float2 uniforms, so no space is wasted
5048 * (in fact most compilers map a float2 to a full float4 uniform).
5050 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
5051 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
5052 * into a single shader constant (uniform / program parameter).
5054 * This structure is shared between the GLSL and the ARB backend.*/
5055 struct ps_np2fixup_info
{
5056 unsigned char idx
[WINED3D_MAX_FRAGMENT_SAMPLERS
]; /* indices to the real constant */
5057 WORD active
; /* bitfield indicating if we can apply the fixup */
5061 struct wined3d_palette
5064 struct wined3d_device
*device
;
5067 RGBQUAD colors
[256];
5071 /* DirectDraw utility functions */
5072 extern enum wined3d_format_id
pixelformat_for_depth(DWORD depth
) DECLSPEC_HIDDEN
;
5074 /*****************************************************************************
5075 * Pixel format management
5078 /* Pixel format attributes */
5079 #define WINED3D_FORMAT_ATTR_FLOAT 0x00000001
5080 #define WINED3D_FORMAT_ATTR_INTEGER 0x00000002
5081 #define WINED3D_FORMAT_ATTR_NORMALISED 0x00000004
5082 #define WINED3D_FORMAT_ATTR_BUMPMAP 0x00000008
5083 #define WINED3D_FORMAT_ATTR_EXTENSION 0x00000010
5084 #define WINED3D_FORMAT_ATTR_BLOCKS 0x00000020
5085 #define WINED3D_FORMAT_ATTR_BLOCKS_NO_VERIFY 0x00000040
5086 #define WINED3D_FORMAT_ATTR_COMPRESSED 0x00000080
5087 #define WINED3D_FORMAT_ATTR_BROKEN_PITCH 0x00000100
5088 #define WINED3D_FORMAT_ATTR_HEIGHT_SCALE 0x00000200
5089 #define WINED3D_FORMAT_ATTR_MAPPABLE 0x00000400
5090 #define WINED3D_FORMAT_ATTR_CAST_TO_BLOCK 0x00000800
5092 /* Pixel format capabilities */
5093 #define WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING 0x00000001
5094 #define WINED3D_FORMAT_CAP_FILTERING 0x00000002
5095 #define WINED3D_FORMAT_CAP_UNORDERED_ACCESS 0x00000004
5096 #define WINED3D_FORMAT_CAP_DEPTH_STENCIL 0x00000008
5097 #define WINED3D_FORMAT_CAP_RENDERTARGET 0x00000010
5098 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE 0x00000020
5099 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE_SRGB 0x00000040
5100 #define WINED3D_FORMAT_CAP_DECOMPRESS 0x00000080
5101 #define WINED3D_FORMAT_CAP_SRGB_READ 0x00000100
5102 #define WINED3D_FORMAT_CAP_SRGB_WRITE 0x00000200
5103 #define WINED3D_FORMAT_CAP_VTF 0x00000400
5104 #define WINED3D_FORMAT_CAP_SHADOW 0x00000800
5105 #define WINED3D_FORMAT_CAP_TEXTURE 0x00001000
5106 #define WINED3D_FORMAT_CAP_GEN_MIPMAP 0x00002000
5107 #define WINED3D_FORMAT_CAP_VERTEX_ATTRIBUTE 0x00004000
5108 #define WINED3D_FORMAT_CAP_BLIT 0x00008000
5109 #define WINED3D_FORMAT_CAP_INDEX_BUFFER 0x00010000
5111 struct wined3d_rational
5117 struct wined3d_color_key_conversion
5119 enum wined3d_format_id dst_format
;
5120 void (*convert
)(const BYTE
*src
, unsigned int src_pitch
, BYTE
*dst
, unsigned int dst_pitch
,
5121 unsigned int width
, unsigned int height
, const struct wined3d_color_key
*colour_key
);
5124 enum wined3d_channel_type
5126 WINED3D_CHANNEL_TYPE_NONE
,
5127 WINED3D_CHANNEL_TYPE_UNORM
,
5128 WINED3D_CHANNEL_TYPE_SNORM
,
5129 WINED3D_CHANNEL_TYPE_UINT
,
5130 WINED3D_CHANNEL_TYPE_SINT
,
5131 WINED3D_CHANNEL_TYPE_FLOAT
,
5132 WINED3D_CHANNEL_TYPE_DEPTH
,
5133 WINED3D_CHANNEL_TYPE_STENCIL
,
5134 WINED3D_CHANNEL_TYPE_UNUSED
,
5137 struct wined3d_format
5139 enum wined3d_format_id id
;
5141 D3DDDIFORMAT ddi_format
;
5142 unsigned int component_count
;
5157 UINT block_byte_count
;
5159 enum wined3d_ffp_emit_idx emit_idx
;
5161 UINT conv_byte_count
;
5162 DWORD multisample_types
;
5164 unsigned int caps
[WINED3D_GL_RES_TYPE_COUNT
];
5165 float depth_bias_scale
;
5166 struct wined3d_rational height_scale
;
5167 struct color_fixup_desc color_fixup
;
5168 void (*upload
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
5169 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
5170 unsigned int width
, unsigned int height
, unsigned int depth
);
5171 void (*download
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
5172 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
5173 unsigned int width
, unsigned int height
, unsigned int depth
);
5174 void (*decompress
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
5175 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
5176 unsigned int width
, unsigned int height
, unsigned int depth
);
5178 enum wined3d_format_id typeless_id
;
5181 const struct wined3d_format
*wined3d_get_format(const struct wined3d_adapter
*adapter
,
5182 enum wined3d_format_id format_id
, unsigned int bind_flags
) DECLSPEC_HIDDEN
;
5183 enum wined3d_format_id
wined3d_get_typed_format_id(const struct wined3d_adapter
*adapter
,
5184 const struct wined3d_format
*format
, enum wined3d_channel_type channel_type
) DECLSPEC_HIDDEN
;
5185 void wined3d_format_calculate_pitch(const struct wined3d_format
*format
, unsigned int alignment
,
5186 unsigned int width
, unsigned int height
, unsigned int *row_pitch
, unsigned int *slice_pitch
) DECLSPEC_HIDDEN
;
5187 UINT
wined3d_format_calculate_size(const struct wined3d_format
*format
,
5188 UINT alignment
, UINT width
, UINT height
, UINT depth
) DECLSPEC_HIDDEN
;
5189 void wined3d_format_convert_from_float(const struct wined3d_format
*format
,
5190 const struct wined3d_color
*color
, void *ret
) DECLSPEC_HIDDEN
;
5191 void wined3d_format_copy_data(const struct wined3d_format
*format
, const uint8_t *src
,
5192 unsigned int src_row_pitch
, unsigned int src_slice_pitch
, uint8_t *dst
, unsigned int dst_row_pitch
,
5193 unsigned int dst_slice_pitch
, unsigned int w
, unsigned int h
, unsigned int d
) DECLSPEC_HIDDEN
;
5194 void wined3d_format_get_float_color_key(const struct wined3d_format
*format
,
5195 const struct wined3d_color_key
*key
, struct wined3d_color
*float_colors
) DECLSPEC_HIDDEN
;
5196 BOOL
wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id
,
5197 enum wined3d_format_id view_format_id
) DECLSPEC_HIDDEN
;
5198 const struct wined3d_color_key_conversion
* wined3d_format_get_color_key_conversion(
5199 const struct wined3d_texture
*texture
, BOOL need_alpha_ck
) DECLSPEC_HIDDEN
;
5200 uint32_t wined3d_format_pack(const struct wined3d_format
*format
, const struct wined3d_uvec4
*value
) DECLSPEC_HIDDEN
;
5201 BOOL
wined3d_formats_are_srgb_variants(enum wined3d_format_id format1
,
5202 enum wined3d_format_id format2
) DECLSPEC_HIDDEN
;
5204 struct wined3d_format_gl
5206 struct wined3d_format f
;
5212 GLint srgb_internal
;
5220 static inline const struct wined3d_format_gl
*wined3d_format_gl(const struct wined3d_format
*format
)
5222 return CONTAINING_RECORD(format
, struct wined3d_format_gl
, f
);
5225 BOOL
wined3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
) DECLSPEC_HIDDEN
;
5227 static inline BOOL
wined3d_format_is_typeless(const struct wined3d_format
*format
)
5229 return format
->id
== format
->typeless_id
&& format
->id
!= WINED3DFMT_UNKNOWN
;
5232 static inline BOOL
use_vs(const struct wined3d_state
*state
)
5234 /* Check state->vertex_declaration to allow this to be used before the
5235 * stream info is validated, for example in device_update_tex_unit_map(). */
5236 return state
->shader
[WINED3D_SHADER_TYPE_VERTEX
]
5237 && (!state
->vertex_declaration
|| !state
->vertex_declaration
->position_transformed
);
5240 static inline BOOL
use_ps(const struct wined3d_state
*state
)
5242 return !!state
->shader
[WINED3D_SHADER_TYPE_PIXEL
];
5245 static inline BOOL
use_transform_feedback(const struct wined3d_state
*state
)
5247 const struct wined3d_shader
*shader
;
5249 if (!(shader
= state
->shader
[WINED3D_SHADER_TYPE_GEOMETRY
]))
5251 return !!shader
->u
.gs
.so_desc
;
5254 static inline void context_apply_state(struct wined3d_context
*context
,
5255 const struct wined3d_state
*state
, DWORD state_id
)
5257 const struct wined3d_state_entry
*state_table
= context
->state_table
;
5258 unsigned int rep
= state_table
[state_id
].representative
;
5259 state_table
[rep
].apply(context
, state
, rep
);
5262 static inline BOOL
is_srgb_enabled(const uint32_t *sampler_states
)
5264 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
5265 * the behaviour of the AMD Windows driver.
5267 * Might & Magic: Heroes VI - Shades of Darkness sets
5268 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
5269 * pointer—presumably by accident—and expects sRGB decoding to be
5271 return sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
] & 0x1;
5274 static inline BOOL
needs_separate_srgb_gl_texture(const struct wined3d_context
*context
,
5275 const struct wined3d_texture
*texture
)
5277 if (!(context
->d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
))
5280 if (!context
->d3d_info
->srgb_read_control
5281 && (texture
->resource
.bind_flags
& WINED3D_BIND_SHADER_RESOURCE
)
5282 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_READ
))
5285 if (!context
->d3d_info
->srgb_write_control
5286 && (texture
->resource
.bind_flags
& WINED3D_BIND_RENDER_TARGET
)
5287 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
))
5293 static inline BOOL
needs_srgb_write(const struct wined3d_d3d_info
*d3d_info
,
5294 const struct wined3d_state
*state
, const struct wined3d_fb_state
*fb
)
5296 return (!(d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
)
5297 || state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
])
5298 && fb
->render_targets
[0] && fb
->render_targets
[0]->format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
;
5301 static inline GLuint
wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl
*texture_gl
,
5302 const struct wined3d_context
*context
, BOOL srgb
)
5304 return srgb
&& needs_separate_srgb_gl_texture(context
, &texture_gl
->t
)
5305 ? texture_gl
->texture_srgb
.name
: texture_gl
->texture_rgb
.name
;
5308 static inline GLuint
wined3d_gl_get_internal_format(struct wined3d_resource
*resource
,
5309 const struct wined3d_format_gl
*format_gl
, bool srgb
)
5312 return format_gl
->srgb_internal
;
5313 else if (resource
->bind_flags
& WINED3D_BIND_RENDER_TARGET
&& wined3d_resource_is_offscreen(resource
))
5314 return format_gl
->rt_internal
;
5316 return format_gl
->internal
;
5319 static inline BOOL
can_use_texture_swizzle(const struct wined3d_d3d_info
*d3d_info
, const struct wined3d_format
*format
)
5321 return d3d_info
->texture_swizzle
&& !is_complex_fixup(format
->color_fixup
) && !is_scaling_fixup(format
->color_fixup
);
5324 static inline BOOL
is_rasterization_disabled(const struct wined3d_shader
*geometry_shader
)
5326 return geometry_shader
&& geometry_shader
->u
.gs
.so_desc
5327 && geometry_shader
->u
.gs
.so_desc
->rasterizer_stream_idx
== WINED3D_NO_RASTERIZER_STREAM
;
5330 static inline uint32_t wined3d_mask_from_size(unsigned int size
)
5332 return size
< 32 ? (1u << size
) - 1 : ~0u;
5335 static inline DWORD
wined3d_extract_bits(const uint32_t *bitstream
,
5336 unsigned int offset
, unsigned int count
)
5338 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
5339 const unsigned int idx
= offset
/ word_bit_count
;
5340 const unsigned int shift
= offset
% word_bit_count
;
5341 DWORD mask
= (1u << count
) - 1;
5344 ret
= (bitstream
[idx
] >> shift
) & mask
;
5345 if (shift
+ count
> word_bit_count
)
5347 const unsigned int extracted_bit_count
= word_bit_count
- shift
;
5348 const unsigned int remaining_bit_count
= count
- extracted_bit_count
;
5349 mask
= (1u << remaining_bit_count
) - 1;
5350 ret
|= (bitstream
[idx
+ 1] & mask
) << extracted_bit_count
;
5355 static inline void wined3d_insert_bits(uint32_t *bitstream
,
5356 unsigned int offset
, unsigned int count
, DWORD bits
)
5358 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
5359 const unsigned int idx
= offset
/ word_bit_count
;
5360 const unsigned int shift
= offset
% word_bit_count
;
5361 DWORD mask
= (1u << count
) - 1;
5363 bitstream
[idx
] |= (bits
& mask
) << shift
;
5364 if (shift
+ count
> word_bit_count
)
5366 const unsigned int inserted_bit_count
= word_bit_count
- shift
;
5367 const unsigned int remaining_bit_count
= count
- inserted_bit_count
;
5368 mask
= (1u << remaining_bit_count
) - 1;
5369 bitstream
[idx
+ 1] |= (bits
>> inserted_bit_count
) & mask
;
5373 static inline void wined3d_from_cs(const struct wined3d_cs
*cs
)
5376 assert(cs
->thread_id
== GetCurrentThreadId());
5379 static inline void wined3d_not_from_cs(const struct wined3d_cs
*cs
)
5381 assert(cs
->thread_id
!= GetCurrentThreadId());
5384 static inline enum wined3d_material_color_source
validate_material_colour_source(WORD use_map
,
5385 enum wined3d_material_color_source source
)
5387 if (source
== WINED3D_MCS_COLOR1
&& use_map
& (1u << WINED3D_FFP_DIFFUSE
))
5389 if (source
== WINED3D_MCS_COLOR2
&& use_map
& (1u << WINED3D_FFP_SPECULAR
))
5391 return WINED3D_MCS_MATERIAL
;
5394 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source
*diffuse
,
5395 enum wined3d_material_color_source
*emissive
, enum wined3d_material_color_source
*ambient
,
5396 enum wined3d_material_color_source
*specular
, const struct wined3d_state
*state
,
5397 const struct wined3d_stream_info
*si
)
5399 if (!state
->render_states
[WINED3D_RS_LIGHTING
])
5401 *diffuse
= WINED3D_MCS_COLOR1
;
5402 *specular
= WINED3D_MCS_COLOR2
;
5403 *emissive
= *ambient
= WINED3D_MCS_MATERIAL
;
5408 if (!state
->render_states
[WINED3D_RS_COLORVERTEX
])
5410 *diffuse
= *emissive
= *ambient
= *specular
= WINED3D_MCS_MATERIAL
;
5415 *diffuse
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
]);
5416 *emissive
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
]);
5417 *ambient
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
]);
5418 *specular
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
5421 static inline void wined3d_vec4_transform(struct wined3d_vec4
*dst
,
5422 const struct wined3d_vec4
*v
, const struct wined3d_matrix
*m
)
5424 struct wined3d_vec4 tmp
;
5426 tmp
.x
= v
->x
* m
->_11
+ v
->y
* m
->_21
+ v
->z
* m
->_31
+ v
->w
* m
->_41
;
5427 tmp
.y
= v
->x
* m
->_12
+ v
->y
* m
->_22
+ v
->z
* m
->_32
+ v
->w
* m
->_42
;
5428 tmp
.z
= v
->x
* m
->_13
+ v
->y
* m
->_23
+ v
->z
* m
->_33
+ v
->w
* m
->_43
;
5429 tmp
.w
= v
->x
* m
->_14
+ v
->y
* m
->_24
+ v
->z
* m
->_34
+ v
->w
* m
->_44
;
5434 BOOL
invert_matrix(struct wined3d_matrix
*out
, const struct wined3d_matrix
*m
) DECLSPEC_HIDDEN
;
5436 void compute_normal_matrix(float *normal_matrix
, BOOL legacy_lighting
,
5437 const struct wined3d_matrix
*modelview
) DECLSPEC_HIDDEN
;
5439 static inline struct wined3d_context
*context_acquire(struct wined3d_device
*device
,
5440 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
5442 wined3d_from_cs(device
->cs
);
5444 return device
->adapter
->adapter_ops
->adapter_acquire_context(device
, texture
, sub_resource_idx
);
5447 static inline void context_release(struct wined3d_context
*context
)
5449 context
->device
->adapter
->adapter_ops
->adapter_release_context(context
);
5452 static inline float wined3d_get_float_state(const struct wined3d_state
*state
, enum wined3d_render_state rs
)
5461 tmpvalue
.d
= state
->render_states
[rs
];
5465 static inline void *wined3d_context_map_bo_address(struct wined3d_context
*context
,
5466 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
5468 return context
->device
->adapter
->adapter_ops
->adapter_map_bo_address(context
, data
, size
, map_flags
);
5471 static inline void wined3d_context_unmap_bo_address(struct wined3d_context
*context
,
5472 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
5474 context
->device
->adapter
->adapter_ops
->adapter_unmap_bo_address(context
, data
, range_count
, ranges
);
5477 static inline void wined3d_context_copy_bo_address(struct wined3d_context
*context
,
5478 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
5479 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
)
5481 context
->device
->adapter
->adapter_ops
->adapter_copy_bo_address(context
, dst
, src
, range_count
, ranges
, map_flags
);
5484 static inline void wined3d_context_flush_bo_address(struct wined3d_context
*context
,
5485 const struct wined3d_const_bo_address
*data
, size_t size
)
5487 context
->device
->adapter
->adapter_ops
->adapter_flush_bo_address(context
, data
, size
);
5490 static inline void wined3d_context_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
5492 context
->device
->adapter
->adapter_ops
->adapter_destroy_bo(context
, bo
);
5495 static inline BOOL
wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view
*dsv
,
5496 const struct wined3d_format
*srv_format
)
5498 return !srv_format
|| (srv_format
->red_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_DEPTH
))
5499 || (srv_format
->green_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_STENCIL
));
5502 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture
*texture
)
5504 return texture
->resource
.type
== WINED3D_RTYPE_TEXTURE_3D
? texture
->resource
.depth
: texture
->layer_count
;
5507 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view
*srv
)
5509 struct wined3d_texture
*texture
;
5511 if (srv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
5514 if (srv
->desc
.u
.texture
.layer_idx
|| srv
->desc
.u
.texture
.level_idx
)
5517 texture
= texture_from_resource(srv
->resource
);
5518 return srv
->desc
.u
.texture
.level_count
== texture
->level_count
5519 && srv
->desc
.u
.texture
.layer_count
== wined3d_bind_layer_count(texture
);
5522 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view
*rtv
)
5524 struct wined3d_texture
*texture
;
5526 if (rtv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
5529 if (rtv
->sub_resource_idx
)
5532 texture
= texture_from_resource(rtv
->resource
);
5533 return texture
->level_count
== 1 && rtv
->layer_count
== wined3d_bind_layer_count(texture
);
5536 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view
*srv
)
5538 InterlockedIncrement(&srv
->resource
->srv_bind_count_device
);
5541 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view
*srv
)
5543 InterlockedDecrement(&srv
->resource
->srv_bind_count_device
);
5546 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view
*rtv
)
5548 InterlockedIncrement(&rtv
->resource
->rtv_bind_count_device
);
5551 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view
*rtv
)
5553 InterlockedDecrement(&rtv
->resource
->rtv_bind_count_device
);
5556 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view
*rtv
,
5557 const struct wined3d_shader_resource_view
*srv
)
5559 if (rtv
->resource
!= srv
->resource
)
5562 if (wined3d_srv_all_subresources(srv
) || wined3d_rtv_all_subresources(rtv
))
5565 return rtv
->sub_resource_idx
>= srv
->desc
.u
.texture
.level_idx
5566 && rtv
->sub_resource_idx
< srv
->desc
.u
.texture
.level_idx
+ srv
->desc
.u
.texture
.level_count
5567 && rtv
->layer_count
>= srv
->desc
.u
.texture
.layer_idx
;
5570 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_state
*state
,
5571 const struct wined3d_shader_resource_view
*srv
)
5575 if (!srv
->resource
->rtv_bind_count_device
)
5578 for (i
= 0; i
< ARRAY_SIZE(state
->fb
.render_targets
); ++i
)
5580 const struct wined3d_rendertarget_view
*rtv
;
5582 if ((rtv
= state
->fb
.render_targets
[i
]) && wined3d_rtv_overlaps_srv(rtv
, srv
))
5589 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport
*vp
, float *min_z
, float *max_z
)
5593 /* The magic constant is derived from tests. */
5594 *max_z
= max(vp
->max_z
, vp
->min_z
+ 0.001f
);
5597 static inline BOOL
wined3d_bitmap_clear(uint32_t *map
, unsigned int idx
)
5599 return map
[idx
>> 5] &= ~(1u << (idx
& 0x1f));
5602 static inline BOOL
wined3d_bitmap_set(uint32_t *map
, unsigned int idx
)
5604 return map
[idx
>> 5] |= (1u << (idx
& 0x1f));
5607 static inline BOOL
wined3d_bitmap_is_set(const uint32_t *map
, unsigned int idx
)
5609 return map
[idx
>> 5] & (1u << (idx
& 0x1f));
5612 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap
, unsigned int bit_count
,
5613 unsigned int start
, uint32_t xor_mask
)
5615 const unsigned int word_bit_count
= sizeof(*bitmap
) * CHAR_BIT
;
5616 const uint32_t *ptr
, *end_ptr
;
5619 assert(bit_count
< word_bit_count
|| !(bit_count
% word_bit_count
));
5621 ptr
= bitmap
+ start
/ word_bit_count
;
5622 end_ptr
= bitmap
+ (bit_count
+ word_bit_count
- 1) / word_bit_count
;
5627 mask
= ~0u << start
% word_bit_count
;
5628 map
= (*ptr
^ xor_mask
) & mask
;
5631 if (++ptr
== end_ptr
)
5633 map
= *ptr
^ xor_mask
;
5635 return (ptr
- bitmap
) * word_bit_count
+ wined3d_bit_scan(&map
);
5638 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
5640 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, 0);
5643 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
5645 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, ~0u);
5648 static inline BOOL
wined3d_bitmap_get_range(const uint32_t *bitmap
, unsigned int bit_count
,
5649 unsigned int start
, struct wined3d_range
*range
)
5651 unsigned int range_start
, range_end
;
5653 range_start
= wined3d_bitmap_ffs(bitmap
, bit_count
, start
);
5654 if (range_start
== ~0u)
5657 range_end
= wined3d_bitmap_ffz(bitmap
, bit_count
, range_start
+ 1);
5658 if (range_end
== ~0u)
5659 range_end
= bit_count
;
5661 range
->offset
= range_start
;
5662 range
->size
= range_end
- range_start
;
5666 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
5668 return wined3d_bitmap_is_set(context
->dirty_graphics_states
, state_id
);
5671 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
5673 return wined3d_bitmap_is_set(context
->dirty_compute_states
, state_id
- STATE_COMPUTE_OFFSET
);
5676 static inline bool isStateDirty(const struct wined3d_context
*context
, unsigned int state_id
)
5678 return wined3d_context_is_graphics_state_dirty(context
, state_id
);
5681 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t
)
5683 return t
== WINED3D_PT_POINTLIST
5684 || t
== WINED3D_PT_LINELIST
5685 || t
== WINED3D_PT_TRIANGLELIST
5686 || t
== WINED3D_PT_LINELIST_ADJ
5687 || t
== WINED3D_PT_TRIANGLELIST_ADJ
5688 || t
== WINED3D_PT_PATCH
;
5691 static inline void wined3d_context_gl_reference_bo(struct wined3d_context_gl
*context_gl
, struct wined3d_bo_gl
*bo_gl
)
5693 struct wined3d_device_gl
*device_gl
= wined3d_device_gl(context_gl
->c
.device
);
5695 bo_gl
->command_fence_id
= device_gl
->current_fence_id
;
5698 static inline void wined3d_context_gl_reference_buffer(struct wined3d_context_gl
*context_gl
,
5699 struct wined3d_buffer
*buffer
)
5701 if (buffer
->buffer_object
)
5702 wined3d_context_gl_reference_bo(context_gl
, wined3d_bo_gl(buffer
->buffer_object
));
5705 static inline bool wined3d_map_persistent(void)
5707 return sizeof(void *) >= sizeof(uint64_t);
5710 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
5711 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
5713 extern CRITICAL_SECTION wined3d_command_cs
;