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
;
99 struct wined3d_vertex_pipe_ops
;
103 WINED3D_FFP_POSITION
= 0,
104 WINED3D_FFP_BLENDWEIGHT
= 1,
105 WINED3D_FFP_BLENDINDICES
= 2,
106 WINED3D_FFP_NORMAL
= 3,
107 WINED3D_FFP_PSIZE
= 4,
108 WINED3D_FFP_DIFFUSE
= 5,
109 WINED3D_FFP_SPECULAR
= 6,
110 WINED3D_FFP_TEXCOORD0
= 7,
111 WINED3D_FFP_TEXCOORD1
= 8,
112 WINED3D_FFP_TEXCOORD2
= 9,
113 WINED3D_FFP_TEXCOORD3
= 10,
114 WINED3D_FFP_TEXCOORD4
= 11,
115 WINED3D_FFP_TEXCOORD5
= 12,
116 WINED3D_FFP_TEXCOORD6
= 13,
117 WINED3D_FFP_TEXCOORD7
= 14,
118 WINED3D_FFP_ATTRIBS_COUNT
= 15,
121 enum wined3d_ffp_emit_idx
123 WINED3D_FFP_EMIT_FLOAT1
,
124 WINED3D_FFP_EMIT_FLOAT2
,
125 WINED3D_FFP_EMIT_FLOAT3
,
126 WINED3D_FFP_EMIT_FLOAT4
,
127 WINED3D_FFP_EMIT_D3DCOLOR
,
128 WINED3D_FFP_EMIT_UBYTE4
,
129 WINED3D_FFP_EMIT_SHORT2
,
130 WINED3D_FFP_EMIT_SHORT4
,
131 WINED3D_FFP_EMIT_UBYTE4N
,
132 WINED3D_FFP_EMIT_SHORT2N
,
133 WINED3D_FFP_EMIT_SHORT4N
,
134 WINED3D_FFP_EMIT_USHORT2N
,
135 WINED3D_FFP_EMIT_USHORT4N
,
136 WINED3D_FFP_EMIT_UDEC3
,
137 WINED3D_FFP_EMIT_DEC3N
,
138 WINED3D_FFP_EMIT_FLOAT16_2
,
139 WINED3D_FFP_EMIT_FLOAT16_4
,
140 WINED3D_FFP_EMIT_INVALID
,
141 WINED3D_FFP_EMIT_COUNT
,
144 /* Texture format fixups */
146 enum fixup_channel_source
148 CHANNEL_SOURCE_ZERO
= 0,
149 CHANNEL_SOURCE_ONE
= 1,
150 CHANNEL_SOURCE_X
= 2,
151 CHANNEL_SOURCE_Y
= 3,
152 CHANNEL_SOURCE_Z
= 4,
153 CHANNEL_SOURCE_W
= 5,
154 CHANNEL_SOURCE_COMPLEX0
= 6,
155 CHANNEL_SOURCE_COMPLEX1
= 7,
160 COMPLEX_FIXUP_NONE
= 0,
161 COMPLEX_FIXUP_YUY2
= 1,
162 COMPLEX_FIXUP_UYVY
= 2,
163 COMPLEX_FIXUP_YV12
= 3,
164 COMPLEX_FIXUP_P8
= 4,
165 COMPLEX_FIXUP_NV12
= 5,
166 COMPLEX_FIXUP_YUV
= 6,
169 #include <pshpack2.h>
170 struct color_fixup_desc
172 unsigned short x_sign_fixup
: 1;
173 unsigned short x_source
: 3;
174 unsigned short y_sign_fixup
: 1;
175 unsigned short y_source
: 3;
176 unsigned short z_sign_fixup
: 1;
177 unsigned short z_source
: 3;
178 unsigned short w_sign_fixup
: 1;
179 unsigned short w_source
: 3;
185 unsigned int PrimitiveMiscCaps
;
186 unsigned int TextureOpCaps
;
187 unsigned int max_blend_stages
;
188 unsigned int max_textures
;
194 struct wined3d_d3d_limits
196 unsigned int vs_version
, hs_version
, ds_version
, gs_version
, ps_version
, cs_version
;
197 DWORD vs_uniform_count
;
198 DWORD ps_uniform_count
;
199 unsigned int varying_count
;
200 unsigned int ffp_vertex_blend_matrices
;
201 unsigned int active_light_count
;
203 unsigned int max_rt_count
;
204 unsigned int max_clip_distances
;
205 unsigned int texture_size
;
206 unsigned int sample_count
;
210 struct wined3d_d3d_info
212 struct fragment_caps ffp_fragment_caps
;
213 struct wined3d_d3d_limits limits
;
214 uint32_t wined3d_creation_flags
;
216 uint32_t emulated_flatshading
: 1;
217 uint32_t ffp_generic_attributes
: 1;
218 uint32_t ffp_alpha_test
: 1;
219 uint32_t vs_clipping
: 1;
220 uint32_t shader_double_precision
: 1;
221 uint32_t shader_output_interpolation
: 1;
222 uint32_t frag_coord_correction
: 1;
223 uint32_t viewport_array_index_any_shader
: 1;
224 uint32_t texture_npot
: 1;
225 uint32_t texture_npot_conditional
: 1;
226 uint32_t normalized_texrect
: 1;
227 uint32_t draw_base_vertex_offset
: 1;
228 uint32_t vertex_bgra
: 1;
229 uint32_t texture_swizzle
: 1;
230 uint32_t srgb_read_control
: 1;
231 uint32_t srgb_write_control
: 1;
232 uint32_t clip_control
: 1;
233 uint32_t full_ffp_varyings
: 1;
234 uint32_t scaled_resolve
: 1;
236 uint32_t subpixel_viewport
: 1;
238 uint32_t persistent_map
: 1;
239 enum wined3d_feature_level feature_level
;
241 DWORD multisample_draw_location
;
243 float filling_convention_offset
;
246 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
=
247 {0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_Z
, 0, CHANNEL_SOURCE_W
};
249 static inline struct color_fixup_desc
create_complex_fixup_desc(enum complex_fixup complex_fixup
)
251 struct color_fixup_desc fixup
=
253 0u, complex_fixup
& (1u << 0) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
254 0u, complex_fixup
& (1u << 1) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
255 0u, complex_fixup
& (1u << 2) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
256 0u, complex_fixup
& (1u << 3) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
261 static inline BOOL
is_identity_fixup(struct color_fixup_desc fixup
)
263 return !memcmp(&fixup
, &COLOR_FIXUP_IDENTITY
, sizeof(fixup
));
266 static inline BOOL
is_complex_fixup(struct color_fixup_desc fixup
)
268 return fixup
.x_source
== CHANNEL_SOURCE_COMPLEX0
|| fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
;
271 static inline BOOL
is_scaling_fixup(struct color_fixup_desc fixup
)
273 return fixup
.x_sign_fixup
|| fixup
.y_sign_fixup
|| fixup
.z_sign_fixup
|| fixup
.w_sign_fixup
;
276 static inline BOOL
is_same_fixup(struct color_fixup_desc f1
, struct color_fixup_desc f2
)
278 return f1
.x_sign_fixup
== f2
.x_sign_fixup
&& f1
.x_source
== f2
.x_source
279 && f1
.y_sign_fixup
== f2
.y_sign_fixup
&& f1
.y_source
== f2
.y_source
280 && f1
.z_sign_fixup
== f2
.z_sign_fixup
&& f1
.z_source
== f2
.z_source
281 && f1
.w_sign_fixup
== f2
.w_sign_fixup
&& f1
.w_source
== f2
.w_source
;
284 static inline enum complex_fixup
get_complex_fixup(struct color_fixup_desc fixup
)
286 enum complex_fixup complex_fixup
= 0;
287 if (fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 0);
288 if (fixup
.y_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 1);
289 if (fixup
.z_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 2);
290 if (fixup
.w_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 3);
291 return complex_fixup
;
295 #define WINED3D_MAX_ACTIVE_LIGHTS 8
296 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
297 #define MAX_CONSTANT_BUFFERS 15
298 #define MAX_SAMPLER_OBJECTS 16
299 #define MAX_SHADER_RESOURCE_VIEWS 128
300 #define MAX_UNORDERED_ACCESS_VIEWS 8
301 #define MAX_TGSM_REGISTERS 8192
302 #define MAX_VERTEX_BLENDS 4
304 static const uint32_t WINED3D_READ_ONLY_BIND_MASK
= WINED3D_BIND_VERTEX_BUFFER
| WINED3D_BIND_INDEX_BUFFER
305 | WINED3D_BIND_CONSTANT_BUFFER
| WINED3D_BIND_SHADER_RESOURCE
| WINED3D_BIND_INDIRECT_BUFFER
;
307 static inline enum wined3d_cmp_func
wined3d_sanitize_cmp_func(enum wined3d_cmp_func func
)
309 if (func
< WINED3D_CMP_NEVER
|| func
> WINED3D_CMP_ALWAYS
)
310 return WINED3D_CMP_ALWAYS
;
314 /* float_16_to_32() and float_32_to_16() convert 16 bit floats in the
315 * FLOAT16 data type to standard C floats and vice versa. They do not
316 * depend on the encoding of the C float, so they are platform independent,
317 * but slow. On x86 and other IEEE 754 compliant platforms the conversion
318 * can be accelerated by bit shifting the exponent and mantissa. There are
319 * also some SSE-based assembly routines out there.
321 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
323 static inline float float_16_to_32(const unsigned short *in
)
325 const unsigned short s
= ((*in
) & 0x8000u
);
326 const unsigned short e
= ((*in
) & 0x7c00u
) >> 10;
327 const unsigned short m
= (*in
) & 0x3ffu
;
328 const float sgn
= (s
? -1.0f
: 1.0f
);
331 if(m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
332 else return sgn
* powf(2, -14.0f
) * ((float)m
/ 1024.0f
);
334 return sgn
* powf(2, (float)e
- 15.0f
) * (1.0f
+ ((float)m
/ 1024.0f
));
336 if(m
== 0) return sgn
* INFINITY
;
341 static inline float float_24_to_32(DWORD in
)
343 const float sgn
= in
& 0x800000u
? -1.0f
: 1.0f
;
344 const unsigned short e
= (in
& 0x780000u
) >> 19;
345 const unsigned int m
= in
& 0x7ffffu
;
349 if (m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
350 else return sgn
* powf(2, -6.0f
) * ((float)m
/ 524288.0f
);
354 return sgn
* powf(2, (float)e
- 7.0f
) * (1.0f
+ ((float)m
/ 524288.0f
));
358 if (m
== 0) return sgn
* INFINITY
;
363 static inline unsigned short float_32_to_16(const float *in
)
366 float tmp
= fabsf(*in
);
367 unsigned int mantissa
;
370 /* Deal with special numbers */
376 return (*in
< 0.0f
? 0xfc00 : 0x7c00);
378 if (tmp
< (float)(1u << 10))
384 } while (tmp
< (float)(1u << 10));
386 else if (tmp
>= (float)(1u << 11))
392 } while (tmp
>= (float)(1u << 11));
395 mantissa
= (unsigned int)tmp
;
396 if (tmp
- mantissa
>= 0.5f
)
397 ++mantissa
; /* Round to nearest, away from zero. */
399 exp
+= 10; /* Normalize the mantissa. */
400 exp
+= 15; /* Exponent is encoded with excess 15. */
402 if (exp
> 30) /* too big */
404 ret
= 0x7c00; /* INF */
408 /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
411 mantissa
= mantissa
>> 1;
414 ret
= mantissa
& 0x3ff;
418 ret
= (exp
<< 10) | (mantissa
& 0x3ff);
421 ret
|= ((*in
< 0.0f
? 1 : 0) << 15); /* Add the sign */
425 static inline unsigned int wined3d_popcount(unsigned int x
)
427 #if defined(__MINGW32__)
428 return __builtin_popcount(x
);
430 x
-= x
>> 1 & 0x55555555;
431 x
= (x
& 0x33333333) + (x
>> 2 & 0x33333333);
432 return ((x
+ (x
>> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
436 static inline int wined3d_uint32_compare(uint32_t x
, uint32_t y
)
438 return (x
> y
) - (x
< y
);
441 static inline int wined3d_uint64_compare(uint64_t x
, uint64_t y
)
443 return (x
> y
) - (x
< y
);
446 #define ORM_BACKBUFFER 0
449 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
450 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
452 enum wined3d_shader_backend
454 WINED3D_SHADER_BACKEND_AUTO
,
455 WINED3D_SHADER_BACKEND_GLSL
,
456 WINED3D_SHADER_BACKEND_ARB
,
457 WINED3D_SHADER_BACKEND_NONE
,
460 #define WINED3D_CSMT_ENABLE 0x00000001
461 #define WINED3D_CSMT_SERIALIZE 0x00000002
463 /* NOTE: When adding fields to this structure, make sure to update the default
464 * values in wined3d_main.c as well. */
465 struct wined3d_settings
467 unsigned int cs_multithreaded
;
468 unsigned int max_gl_version
;
469 int offscreen_rendering_mode
;
470 unsigned short pci_vendor_id
;
471 unsigned short pci_device_id
;
472 /* Memory tracking and object counting. */
473 UINT64 emulated_textureram
;
475 unsigned int multisample_textures
;
476 unsigned int sample_count
;
477 BOOL check_float_constants
;
478 unsigned int strict_shader_math
;
479 unsigned int max_sm_vs
;
480 unsigned int max_sm_hs
;
481 unsigned int max_sm_ds
;
482 unsigned int max_sm_gs
;
483 unsigned int max_sm_ps
;
484 unsigned int max_sm_cs
;
485 enum wined3d_renderer renderer
;
486 enum wined3d_shader_backend shader_backend
;
487 BOOL cb_access_map_w
;
490 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN
;
492 enum wined3d_shader_resource_type
494 WINED3D_SHADER_RESOURCE_NONE
,
495 WINED3D_SHADER_RESOURCE_BUFFER
,
496 WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
497 WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
498 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
499 WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
500 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
501 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
502 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
503 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
504 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY
,
507 #define WINED3D_SHADER_CONST_VS_F 0x00000001
508 #define WINED3D_SHADER_CONST_VS_I 0x00000002
509 #define WINED3D_SHADER_CONST_VS_B 0x00000004
510 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
511 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
512 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
513 #define WINED3D_SHADER_CONST_PS_F 0x00000040
514 #define WINED3D_SHADER_CONST_PS_I 0x00000080
515 #define WINED3D_SHADER_CONST_PS_B 0x00000100
516 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
517 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
518 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
519 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
520 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
521 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
522 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
523 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
524 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
525 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
526 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
527 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
528 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
529 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
531 enum wined3d_shader_register_type
534 WINED3DSPR_INPUT
= 1,
535 WINED3DSPR_CONST
= 2,
537 WINED3DSPR_TEXTURE
= 3,
538 WINED3DSPR_RASTOUT
= 4,
539 WINED3DSPR_ATTROUT
= 5,
540 WINED3DSPR_TEXCRDOUT
= 6,
541 WINED3DSPR_OUTPUT
= 6,
542 WINED3DSPR_CONSTINT
= 7,
543 WINED3DSPR_COLOROUT
= 8,
544 WINED3DSPR_DEPTHOUT
= 9,
545 WINED3DSPR_SAMPLER
= 10,
546 WINED3DSPR_CONST2
= 11,
547 WINED3DSPR_CONST3
= 12,
548 WINED3DSPR_CONST4
= 13,
549 WINED3DSPR_CONSTBOOL
= 14,
550 WINED3DSPR_LOOP
= 15,
551 WINED3DSPR_TEMPFLOAT16
= 16,
552 WINED3DSPR_MISCTYPE
= 17,
553 WINED3DSPR_LABEL
= 18,
554 WINED3DSPR_PREDICATE
= 19,
556 WINED3DSPR_CONSTBUFFER
,
557 WINED3DSPR_IMMCONSTBUFFER
,
562 WINED3DSPR_OUTPOINTID
,
563 WINED3DSPR_FORKINSTID
,
564 WINED3DSPR_JOININSTID
,
565 WINED3DSPR_INCONTROLPOINT
,
566 WINED3DSPR_OUTCONTROLPOINT
,
567 WINED3DSPR_PATCHCONST
,
568 WINED3DSPR_TESSCOORD
,
569 WINED3DSPR_GROUPSHAREDMEM
,
571 WINED3DSPR_THREADGROUPID
,
572 WINED3DSPR_LOCALTHREADID
,
573 WINED3DSPR_LOCALTHREADINDEX
,
576 WINED3DSPR_FUNCTIONBODY
,
577 WINED3DSPR_FUNCTIONPOINTER
,
579 WINED3DSPR_SAMPLEMASK
,
581 WINED3DSPR_DEPTHOUTGE
,
582 WINED3DSPR_DEPTHOUTLE
,
583 WINED3DSPR_RASTERIZER
,
586 enum wined3d_data_type
590 WINED3D_DATA_RESOURCE
,
591 WINED3D_DATA_SAMPLER
,
599 enum wined3d_immconst_type
601 WINED3D_IMMCONST_SCALAR
,
602 WINED3D_IMMCONST_VEC4
,
605 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
607 enum wined3d_shader_src_modifier
609 WINED3DSPSM_NONE
= 0,
611 WINED3DSPSM_BIAS
= 2,
612 WINED3DSPSM_BIASNEG
= 3,
613 WINED3DSPSM_SIGN
= 4,
614 WINED3DSPSM_SIGNNEG
= 5,
615 WINED3DSPSM_COMP
= 6,
617 WINED3DSPSM_X2NEG
= 8,
620 WINED3DSPSM_ABS
= 11,
621 WINED3DSPSM_ABSNEG
= 12,
622 WINED3DSPSM_NOT
= 13,
625 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
626 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
627 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
628 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
629 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
631 enum wined3d_shader_dst_modifier
633 WINED3DSPDM_NONE
= 0,
634 WINED3DSPDM_SATURATE
= 1,
635 WINED3DSPDM_PARTIALPRECISION
= 2,
636 WINED3DSPDM_MSAMPCENTROID
= 4,
639 enum wined3d_shader_interpolation_mode
642 WINED3DSIM_CONSTANT
= 1,
643 WINED3DSIM_LINEAR
= 2,
644 WINED3DSIM_LINEAR_CENTROID
= 3,
645 WINED3DSIM_LINEAR_NOPERSPECTIVE
= 4,
646 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
= 5,
647 WINED3DSIM_LINEAR_SAMPLE
= 6,
648 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE
= 7,
651 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
652 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
654 enum wined3d_shader_global_flags
656 WINED3DSGF_REFACTORING_ALLOWED
= 0x1,
657 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL
= 0x4,
658 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS
= 0x8,
661 enum wined3d_shader_sync_flags
663 WINED3DSSF_THREAD_GROUP
= 0x1,
664 WINED3DSSF_GROUP_SHARED_MEMORY
= 0x2,
665 WINED3DSSF_GLOBAL_UAV
= 0x8,
668 enum wined3d_shader_uav_flags
670 WINED3DSUF_GLOBALLY_COHERENT
= 0x2,
671 WINED3DSUF_ORDER_PRESERVING_COUNTER
= 0x100,
674 enum wined3d_tessellator_domain
676 WINED3D_TESSELLATOR_DOMAIN_LINE
= 1,
677 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE
= 2,
678 WINED3D_TESSELLATOR_DOMAIN_QUAD
= 3,
681 enum wined3d_tessellator_output_primitive
683 WINED3D_TESSELLATOR_OUTPUT_POINT
= 1,
684 WINED3D_TESSELLATOR_OUTPUT_LINE
= 2,
685 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW
= 3,
686 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW
= 4,
689 enum wined3d_tessellator_partitioning
691 WINED3D_TESSELLATOR_PARTITIONING_INTEGER
= 1,
692 WINED3D_TESSELLATOR_PARTITIONING_POW2
= 2,
693 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD
= 3,
694 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
= 4,
697 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
698 #define WINED3DSI_TEXLD_PROJECT 0x1
699 #define WINED3DSI_TEXLD_BIAS 0x2
700 #define WINED3DSI_INDEXED_DYNAMIC 0x4
701 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
702 #define WINED3DSI_RESINFO_UINT 0x2
703 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
704 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
706 #define WINED3DSI_PRECISE_X 0x100
707 #define WINED3DSI_PRECISE_Y 0x200
708 #define WINED3DSI_PRECISE_Z 0x400
709 #define WINED3DSI_PRECISE_W 0x800
710 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
711 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
712 #define WINED3DSI_PRECISE_SHIFT 8
714 enum wined3d_shader_rel_op
716 WINED3D_SHADER_REL_OP_GT
= 1,
717 WINED3D_SHADER_REL_OP_EQ
= 2,
718 WINED3D_SHADER_REL_OP_GE
= 3,
719 WINED3D_SHADER_REL_OP_LT
= 4,
720 WINED3D_SHADER_REL_OP_NE
= 5,
721 WINED3D_SHADER_REL_OP_LE
= 6,
724 enum wined3d_shader_conditional_op
726 WINED3D_SHADER_CONDITIONAL_OP_NZ
= 0,
727 WINED3D_SHADER_CONDITIONAL_OP_Z
= 1
730 enum wined3d_sysval_semantic
732 WINED3D_SV_POSITION
= 0x01,
733 WINED3D_SV_CLIP_DISTANCE
= 0x02,
734 WINED3D_SV_CULL_DISTANCE
= 0x03,
735 WINED3D_SV_RENDER_TARGET_ARRAY_INDEX
= 0x04,
736 WINED3D_SV_VIEWPORT_ARRAY_INDEX
= 0x05,
737 WINED3D_SV_VERTEX_ID
= 0x06,
738 WINED3D_SV_PRIMITIVE_ID
= 0x07,
739 WINED3D_SV_INSTANCE_ID
= 0x08,
740 WINED3D_SV_IS_FRONT_FACE
= 0x09,
741 WINED3D_SV_SAMPLE_INDEX
= 0x0a,
742 WINED3D_SV_TESS_FACTOR_QUADEDGE
= 0x0b,
743 WINED3D_SV_TESS_FACTOR_QUADINT
= 0x0c,
744 WINED3D_SV_TESS_FACTOR_TRIEDGE
= 0x0d,
745 WINED3D_SV_TESS_FACTOR_TRIINT
= 0x0e,
746 WINED3D_SV_TESS_FACTOR_LINEDET
= 0x0f,
747 WINED3D_SV_TESS_FACTOR_LINEDEN
= 0x10,
750 enum wined3d_component_type
752 WINED3D_TYPE_UNKNOWN
= 0x0,
753 WINED3D_TYPE_UINT
= 0x1,
754 WINED3D_TYPE_INT
= 0x2,
755 WINED3D_TYPE_FLOAT
= 0x3,
758 struct wined3d_shader_signature_element
760 const char *semantic_name
;
761 unsigned int semantic_idx
;
762 unsigned int stream_idx
;
763 enum wined3d_sysval_semantic sysval_semantic
;
764 enum wined3d_component_type component_type
;
765 unsigned int register_idx
;
767 unsigned int min_precision
;
770 struct wined3d_shader_signature
772 unsigned int element_count
;
773 struct wined3d_shader_signature_element
*elements
;
776 #define WINED3D_SM1_VS 0xfffeu
777 #define WINED3D_SM1_PS 0xffffu
778 #define WINED3D_SM4_PS 0x0000u
779 #define WINED3D_SM4_VS 0x0001u
780 #define WINED3D_SM4_GS 0x0002u
781 #define WINED3D_SM5_HS 0x0003u
782 #define WINED3D_SM5_DS 0x0004u
783 #define WINED3D_SM5_CS 0x0005u
785 /* Shader version tokens, and shader end tokens */
786 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
787 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
789 /* Shader backends */
791 #define MAX_ATTRIBS 32
792 #define MAX_REG_ADDR 1
793 #define MAX_REG_TEXCRD 8
794 #define MAX_REG_INPUT 32
795 #define MAX_REG_OUTPUT 32
796 #define WINED3D_MAX_CBS 15
798 /* FIXME: This needs to go up to 2048 for
799 * Shader model 3 according to msdn (and for software shaders) */
800 #define MAX_LABELS 16
802 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
804 struct wined3d_string_buffer
808 unsigned int buffer_size
;
809 unsigned int content_size
;
812 enum WINED3D_SHADER_INSTRUCTION_HANDLER
817 WINED3DSIH_ATOMIC_AND
,
818 WINED3DSIH_ATOMIC_CMP_STORE
,
819 WINED3DSIH_ATOMIC_IADD
,
820 WINED3DSIH_ATOMIC_IMAX
,
821 WINED3DSIH_ATOMIC_IMIN
,
822 WINED3DSIH_ATOMIC_OR
,
823 WINED3DSIH_ATOMIC_UMAX
,
824 WINED3DSIH_ATOMIC_UMIN
,
825 WINED3DSIH_ATOMIC_XOR
,
839 WINED3DSIH_CONTINUEP
,
840 WINED3DSIH_COUNTBITS
,
843 WINED3DSIH_CUT_STREAM
,
845 WINED3DSIH_DCL_CONSTANT_BUFFER
,
846 WINED3DSIH_DCL_FUNCTION_BODY
,
847 WINED3DSIH_DCL_FUNCTION_TABLE
,
848 WINED3DSIH_DCL_GLOBAL_FLAGS
,
849 WINED3DSIH_DCL_GS_INSTANCES
,
850 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
,
851 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
,
852 WINED3DSIH_DCL_HS_MAX_TESSFACTOR
,
853 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
,
854 WINED3DSIH_DCL_INDEX_RANGE
,
855 WINED3DSIH_DCL_INDEXABLE_TEMP
,
856 WINED3DSIH_DCL_INPUT
,
857 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
,
858 WINED3DSIH_DCL_INPUT_PRIMITIVE
,
859 WINED3DSIH_DCL_INPUT_PS
,
860 WINED3DSIH_DCL_INPUT_PS_SGV
,
861 WINED3DSIH_DCL_INPUT_PS_SIV
,
862 WINED3DSIH_DCL_INPUT_SGV
,
863 WINED3DSIH_DCL_INPUT_SIV
,
864 WINED3DSIH_DCL_INTERFACE
,
865 WINED3DSIH_DCL_OUTPUT
,
866 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
,
867 WINED3DSIH_DCL_OUTPUT_SIV
,
868 WINED3DSIH_DCL_OUTPUT_TOPOLOGY
,
869 WINED3DSIH_DCL_RESOURCE_RAW
,
870 WINED3DSIH_DCL_RESOURCE_STRUCTURED
,
871 WINED3DSIH_DCL_SAMPLER
,
872 WINED3DSIH_DCL_STREAM
,
873 WINED3DSIH_DCL_TEMPS
,
874 WINED3DSIH_DCL_TESSELLATOR_DOMAIN
,
875 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
,
876 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
,
877 WINED3DSIH_DCL_TGSM_RAW
,
878 WINED3DSIH_DCL_TGSM_STRUCTURED
,
879 WINED3DSIH_DCL_THREAD_GROUP
,
880 WINED3DSIH_DCL_UAV_RAW
,
881 WINED3DSIH_DCL_UAV_STRUCTURED
,
882 WINED3DSIH_DCL_UAV_TYPED
,
883 WINED3DSIH_DCL_VERTICES_OUT
,
895 WINED3DSIH_DSX_COARSE
,
898 WINED3DSIH_DSY_COARSE
,
902 WINED3DSIH_EMIT_STREAM
,
906 WINED3DSIH_ENDSWITCH
,
908 WINED3DSIH_EVAL_CENTROID
,
909 WINED3DSIH_EVAL_SAMPLE_INDEX
,
915 WINED3DSIH_FIRSTBIT_HI
,
916 WINED3DSIH_FIRSTBIT_LO
,
917 WINED3DSIH_FIRSTBIT_SHI
,
922 WINED3DSIH_GATHER4_C
,
923 WINED3DSIH_GATHER4_PO
,
924 WINED3DSIH_GATHER4_PO_C
,
926 WINED3DSIH_HS_CONTROL_POINT_PHASE
,
928 WINED3DSIH_HS_FORK_PHASE
,
929 WINED3DSIH_HS_JOIN_PHASE
,
940 WINED3DSIH_IMM_ATOMIC_ALLOC
,
941 WINED3DSIH_IMM_ATOMIC_AND
,
942 WINED3DSIH_IMM_ATOMIC_CMP_EXCH
,
943 WINED3DSIH_IMM_ATOMIC_CONSUME
,
944 WINED3DSIH_IMM_ATOMIC_EXCH
,
945 WINED3DSIH_IMM_ATOMIC_IADD
,
946 WINED3DSIH_IMM_ATOMIC_IMAX
,
947 WINED3DSIH_IMM_ATOMIC_IMIN
,
948 WINED3DSIH_IMM_ATOMIC_OR
,
949 WINED3DSIH_IMM_ATOMIC_UMAX
,
950 WINED3DSIH_IMM_ATOMIC_UMIN
,
951 WINED3DSIH_IMM_ATOMIC_XOR
,
962 WINED3DSIH_LD_STRUCTURED
,
963 WINED3DSIH_LD_UAV_TYPED
,
1001 WINED3DSIH_SAMPLE_B
,
1002 WINED3DSIH_SAMPLE_C
,
1003 WINED3DSIH_SAMPLE_C_LZ
,
1004 WINED3DSIH_SAMPLE_GRAD
,
1005 WINED3DSIH_SAMPLE_INFO
,
1006 WINED3DSIH_SAMPLE_LOD
,
1007 WINED3DSIH_SAMPLE_POS
,
1014 WINED3DSIH_STORE_RAW
,
1015 WINED3DSIH_STORE_STRUCTURED
,
1016 WINED3DSIH_STORE_UAV_TYPED
,
1024 WINED3DSIH_TEXCOORD
,
1025 WINED3DSIH_TEXDEPTH
,
1027 WINED3DSIH_TEXDP3TEX
,
1031 WINED3DSIH_TEXM3x2DEPTH
,
1032 WINED3DSIH_TEXM3x2PAD
,
1033 WINED3DSIH_TEXM3x2TEX
,
1035 WINED3DSIH_TEXM3x3DIFF
,
1036 WINED3DSIH_TEXM3x3PAD
,
1037 WINED3DSIH_TEXM3x3SPEC
,
1038 WINED3DSIH_TEXM3x3TEX
,
1039 WINED3DSIH_TEXM3x3VSPEC
,
1040 WINED3DSIH_TEXREG2AR
,
1041 WINED3DSIH_TEXREG2GB
,
1042 WINED3DSIH_TEXREG2RGB
,
1053 WINED3DSIH_TABLE_SIZE
1056 struct wined3d_shader_version
1058 enum wined3d_shader_type type
;
1063 struct wined3d_shader_resource_info
1065 enum wined3d_shader_resource_type type
;
1066 enum wined3d_data_type data_type
;
1068 unsigned int stride
;
1071 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1073 struct wined3d_shader_sampler_map_entry
1075 unsigned int resource_idx
;
1076 unsigned int sampler_idx
;
1077 unsigned int bind_idx
;
1080 struct wined3d_shader_sampler_map
1082 struct wined3d_shader_sampler_map_entry
*entries
;
1087 struct wined3d_shader_immediate_constant_buffer
1089 unsigned int vec4_count
;
1090 uint32_t data
[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
];
1093 struct wined3d_shader_indexable_temp
1096 unsigned int register_idx
;
1097 unsigned int register_size
;
1098 unsigned int component_count
;
1101 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1103 struct wined3d_shader_reg_maps
1105 struct wined3d_shader_version shader_version
;
1106 BYTE texcoord
; /* MAX_REG_TEXCRD, 8 */
1107 BYTE address
; /* MAX_REG_ADDR, 1 */
1108 WORD labels
; /* MAX_LABELS, 16 */
1109 DWORD temporary
; /* 32 */
1110 unsigned int temporary_count
;
1111 uint32_t *constf
; /* pixel, vertex */
1112 struct list indexable_temps
;
1113 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1116 DWORD texcoord_mask
[MAX_REG_TEXCRD
]; /* vertex < 3.0 */
1117 BYTE output_registers_mask
[MAX_REG_OUTPUT
]; /* vertex >= 3.0 */
1119 DWORD input_registers
; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1120 DWORD output_registers
; /* MAX_REG_OUTPUT, 32 */
1121 WORD integer_constants
; /* WINED3D_MAX_CONSTS_I, 16 */
1122 WORD boolean_constants
; /* WINED3D_MAX_CONSTS_B, 16 */
1123 WORD local_int_consts
; /* WINED3D_MAX_CONSTS_I, 16 */
1124 WORD local_bool_consts
; /* WINED3D_MAX_CONSTS_B, 16 */
1125 UINT cb_sizes
[WINED3D_MAX_CBS
];
1126 uint32_t cb_map
; /* WINED3D_MAX_CBS, 15 */
1128 struct wined3d_shader_resource_info resource_info
[MAX_SHADER_RESOURCE_VIEWS
];
1129 uint32_t resource_map
[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS
)];
1130 struct wined3d_shader_sampler_map sampler_map
;
1131 DWORD sampler_comparison_mode
;
1132 BYTE bumpmat
; /* WINED3D_MAX_FFP_TEXTURES, 8 */
1133 BYTE luminanceparams
; /* WINED3D_MAX_FFP_TEXTURES, 8 */
1134 struct wined3d_shader_resource_info uav_resource_info
[MAX_UNORDERED_ACCESS_VIEWS
];
1135 DWORD uav_read_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1136 DWORD uav_counter_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1138 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1139 DWORD cull_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1144 DWORD usestexldd
: 1;
1146 DWORD usesfacing
: 1;
1147 DWORD usesrelconstF
: 1;
1149 DWORD usestexldl
: 1;
1153 DWORD point_size
: 1;
1155 DWORD input_rel_addressing
: 1;
1156 DWORD viewport_array
: 1;
1157 DWORD sample_mask
: 1;
1160 DWORD rt_mask
; /* Used render targets, 32 max. */
1162 /* Whether or not loops are used in this shader, and nesting depth */
1163 unsigned int loop_depth
;
1164 unsigned int min_rel_offset
, max_rel_offset
;
1166 struct wined3d_shader_tgsm
*tgsm
;
1167 SIZE_T tgsm_capacity
;
1168 unsigned int tgsm_count
;
1171 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1172 * state information between multiple instructions. */
1173 struct wined3d_shader_tex_mx
1175 unsigned int current_row
;
1176 unsigned int texcoord_w
[2];
1179 struct wined3d_shader_parser_state
1181 unsigned int current_loop_depth
;
1182 unsigned int current_loop_reg
;
1186 struct wined3d_shader_context
1188 const struct wined3d_shader
*shader
;
1189 const struct wined3d_shader_reg_maps
*reg_maps
;
1190 struct wined3d_string_buffer
*buffer
;
1191 struct wined3d_shader_tex_mx
*tex_mx
;
1192 struct wined3d_shader_parser_state
*state
;
1196 struct wined3d_shader_register_index
1198 const struct wined3d_shader_src_param
*rel_addr
;
1199 unsigned int offset
;
1202 struct wined3d_shader_register
1204 enum wined3d_shader_register_type type
;
1205 enum wined3d_data_type data_type
;
1206 struct wined3d_shader_register_index idx
[2];
1207 enum wined3d_immconst_type immconst_type
;
1210 unsigned int immconst_data
[4];
1211 unsigned fp_body_idx
;
1215 struct wined3d_shader_dst_param
1217 struct wined3d_shader_register reg
;
1218 uint32_t write_mask
;
1223 struct wined3d_shader_src_param
1225 struct wined3d_shader_register reg
;
1227 enum wined3d_shader_src_modifier modifiers
;
1230 struct wined3d_shader_index_range
1232 struct wined3d_shader_dst_param first_register
;
1233 unsigned int last_register
;
1236 struct wined3d_shader_semantic
1238 enum wined3d_decl_usage usage
;
1240 enum wined3d_shader_resource_type resource_type
;
1241 unsigned int sample_count
;
1242 enum wined3d_data_type resource_data_type
;
1243 struct wined3d_shader_dst_param reg
;
1246 enum wined3d_shader_input_sysval_semantic
1248 WINED3D_SIV_POSITION
= 1,
1249 WINED3D_SIV_CLIP_DISTANCE
= 2,
1250 WINED3D_SIV_CULL_DISTANCE
= 3,
1251 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX
= 4,
1252 WINED3D_SIV_VIEWPORT_ARRAY_INDEX
= 5,
1253 WINED3D_SIV_VERTEX_ID
= 6,
1254 WINED3D_SIV_PRIMITIVE_ID
= 7,
1255 WINED3D_SIV_INSTANCE_ID
= 8,
1256 WINED3D_SIV_IS_FRONT_FACE
= 9,
1257 WINED3D_SIV_SAMPLE_INDEX
= 10,
1258 WINED3D_SIV_QUAD_U0_TESS_FACTOR
= 11,
1259 WINED3D_SIV_QUAD_V0_TESS_FACTOR
= 12,
1260 WINED3D_SIV_QUAD_U1_TESS_FACTOR
= 13,
1261 WINED3D_SIV_QUAD_V1_TESS_FACTOR
= 14,
1262 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR
= 15,
1263 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR
= 16,
1264 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR
= 17,
1265 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR
= 18,
1266 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR
= 19,
1267 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR
= 20,
1268 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR
= 21,
1269 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR
= 22,
1272 struct wined3d_shader_register_semantic
1274 struct wined3d_shader_dst_param reg
;
1275 enum wined3d_shader_input_sysval_semantic sysval_semantic
;
1278 struct wined3d_shader_structured_resource
1280 struct wined3d_shader_dst_param reg
;
1281 unsigned int byte_stride
;
1284 struct wined3d_shader_tgsm
1287 unsigned int stride
;
1290 struct wined3d_shader_tgsm_raw
1292 struct wined3d_shader_dst_param reg
;
1293 unsigned int byte_count
;
1296 struct wined3d_shader_tgsm_structured
1298 struct wined3d_shader_dst_param reg
;
1299 unsigned int byte_stride
;
1300 unsigned int structure_count
;
1303 struct wined3d_shader_thread_group_size
1305 unsigned int x
, y
, z
;
1308 struct wined3d_shader_function_table_pointer
1311 unsigned int array_size
;
1312 unsigned int body_count
;
1313 unsigned int table_count
;
1316 struct wined3d_shader_texel_offset
1318 signed char u
, v
, w
;
1321 struct wined3d_shader_primitive_type
1323 enum wined3d_primitive_type type
;
1324 unsigned int patch_vertex_count
;
1327 struct wined3d_shader_instruction
1329 const struct wined3d_shader_context
*ctx
;
1330 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
1332 unsigned int dst_count
;
1333 unsigned int src_count
;
1334 const struct wined3d_shader_dst_param
*dst
;
1335 const struct wined3d_shader_src_param
*src
;
1336 struct wined3d_shader_texel_offset texel_offset
;
1337 enum wined3d_shader_resource_type resource_type
;
1338 enum wined3d_data_type resource_data_type
;
1340 const struct wined3d_shader_src_param
*predicate
;
1343 struct wined3d_shader_semantic semantic
;
1344 struct wined3d_shader_register_semantic register_semantic
;
1345 struct wined3d_shader_primitive_type primitive_type
;
1346 struct wined3d_shader_dst_param dst
;
1347 struct wined3d_shader_src_param src
;
1350 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1351 struct wined3d_shader_structured_resource structured_resource
;
1352 struct wined3d_shader_tgsm_raw tgsm_raw
;
1353 struct wined3d_shader_tgsm_structured tgsm_structured
;
1354 struct wined3d_shader_thread_group_size thread_group_size
;
1355 enum wined3d_tessellator_domain tessellator_domain
;
1356 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1357 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1358 float max_tessellation_factor
;
1359 struct wined3d_shader_index_range index_range
;
1360 struct wined3d_shader_indexable_temp indexable_temp
;
1361 struct wined3d_shader_function_table_pointer fp
;
1365 static inline BOOL
wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction
*ins
)
1367 return ins
->texel_offset
.u
|| ins
->texel_offset
.v
|| ins
->texel_offset
.w
;
1370 struct wined3d_shader_attribute
1372 enum wined3d_decl_usage usage
;
1376 struct wined3d_shader_loop_control
1383 struct wined3d_shader_frontend
1385 void *(*shader_init
)(const DWORD
*byte_code
, size_t byte_code_size
,
1386 const struct wined3d_shader_signature
*output_signature
);
1387 void (*shader_free
)(void *data
);
1388 void (*shader_read_header
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
);
1389 void (*shader_read_instruction
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
);
1390 BOOL (*shader_is_end
)(void *data
, const DWORD
**ptr
);
1393 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN
;
1394 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN
;
1396 HRESULT
wined3d_shader_extract_from_dxbc(struct wined3d_shader
*shader
,
1397 unsigned int max_shader_version
, enum vkd3d_shader_source_type
*source_type
) DECLSPEC_HIDDEN
;
1398 BOOL
shader_get_stream_output_register_info(const struct wined3d_shader
*shader
,
1399 const struct wined3d_stream_output_element
*so_element
, unsigned int *register_idx
,
1400 unsigned int *component_idx
) DECLSPEC_HIDDEN
;
1402 typedef void (*SHADER_HANDLER
)(const struct wined3d_shader_instruction
*);
1404 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1405 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1406 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1407 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1408 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1412 unsigned int vs_version
;
1413 unsigned int hs_version
;
1414 unsigned int ds_version
;
1415 unsigned int gs_version
;
1416 unsigned int ps_version
;
1417 unsigned int cs_version
;
1419 unsigned int vs_uniform_count
;
1420 unsigned int ps_uniform_count
;
1421 float ps_1x_max_value
;
1422 unsigned int varying_count
;
1427 enum wined3d_gl_resource_type
1429 WINED3D_GL_RES_TYPE_TEX_1D
= 0,
1430 WINED3D_GL_RES_TYPE_TEX_2D
= 1,
1431 WINED3D_GL_RES_TYPE_TEX_3D
= 2,
1432 WINED3D_GL_RES_TYPE_TEX_CUBE
= 3,
1433 WINED3D_GL_RES_TYPE_TEX_RECT
= 4,
1434 WINED3D_GL_RES_TYPE_BUFFER
= 5,
1435 WINED3D_GL_RES_TYPE_RB
= 6,
1436 WINED3D_GL_RES_TYPE_COUNT
= 7,
1439 enum wined3d_vertex_processing_mode
1442 WINED3D_VP_MODE_SHADER
,
1443 WINED3D_VP_MODE_NONE
,
1446 #define WINED3D_CONST_NUM_UNUSED ~0U
1448 enum wined3d_ffp_ps_fog_mode
1450 WINED3D_FFP_PS_FOG_OFF
,
1451 WINED3D_FFP_PS_FOG_LINEAR
,
1452 WINED3D_FFP_PS_FOG_EXP
,
1453 WINED3D_FFP_PS_FOG_EXP2
,
1456 /* Stateblock dependent parameters which have to be hardcoded
1457 * into the shader code
1460 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1461 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1462 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1463 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1464 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1466 /* Used for Shader Model 1 pixel shaders to track the bound texture
1467 * type. 2D and RECT textures are separated through NP2 fixup. */
1468 enum wined3d_shader_tex_types
1470 WINED3D_SHADER_TEX_2D
= 0,
1471 WINED3D_SHADER_TEX_3D
= 1,
1472 WINED3D_SHADER_TEX_CUBE
= 2,
1473 WINED3D_SHADER_TEX_ERR
= 3,
1476 struct ps_compile_args
1478 struct color_fixup_desc color_fixup
[WINED3D_MAX_FRAGMENT_SAMPLERS
];
1479 enum wined3d_vertex_processing_mode vp_mode
;
1480 enum wined3d_ffp_ps_fog_mode fog
;
1481 DWORD tex_types
; /* ps 1 - 3, 16 textures */
1482 WORD tex_transform
; /* ps 1.0-1.3, 4 textures */
1483 WORD srgb_correction
;
1484 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1485 D3D9 has a limit of 16 samplers and the fixup is superfluous
1486 in D3D10 (unconditional NP2 support mandatory). */
1488 WORD shadow
; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1489 WORD texcoords_initialized
; /* WINED3D_MAX_FFP_TEXTURES, 8 */
1490 WORD padding_to_dword
;
1491 DWORD pointsprite
: 1;
1492 DWORD flatshading
: 1;
1493 DWORD alpha_test_func
: 3;
1494 DWORD y_correction
: 1;
1495 DWORD rt_alpha_swizzle
: 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1496 DWORD dual_source_blend
: 1;
1506 struct vs_compile_args
1508 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1509 unsigned int next_shader_input_count
;
1510 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1512 BYTE clip_enabled
: 1;
1513 BYTE point_size
: 1;
1514 BYTE per_vertex_point_size
: 1;
1515 BYTE flatshading
: 1;
1516 BYTE next_shader_type
: 3;
1520 struct ds_compile_args
1522 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1523 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1524 unsigned int output_count
: 16;
1525 unsigned int next_shader_type
: 3;
1526 unsigned int render_offscreen
: 1;
1527 unsigned int padding
: 12;
1528 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1531 struct gs_compile_args
1533 unsigned int output_count
;
1534 enum wined3d_primitive_type primitive_type
;
1535 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1538 struct wined3d_shader_backend_ops
1540 void (*shader_handle_instruction
)(const struct wined3d_shader_instruction
*);
1541 void (*shader_precompile
)(void *shader_priv
, struct wined3d_shader
*shader
);
1542 void (*shader_select
)(void *shader_priv
, struct wined3d_context
*context
,
1543 const struct wined3d_state
*state
);
1544 void (*shader_select_compute
)(void *shader_priv
, struct wined3d_context
*context
,
1545 const struct wined3d_state
*state
);
1546 void (*shader_disable
)(void *shader_priv
, struct wined3d_context
*context
);
1547 void (*shader_update_float_vertex_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1548 void (*shader_update_float_pixel_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1549 void (*shader_load_constants
)(void *shader_priv
, struct wined3d_context
*context
,
1550 const struct wined3d_state
*state
);
1551 void (*shader_destroy
)(struct wined3d_shader
*shader
);
1552 HRESULT (*shader_alloc_private
)(struct wined3d_device
*device
, const struct wined3d_vertex_pipe_ops
*vertex_pipe
,
1553 const struct wined3d_fragment_pipe_ops
*fragment_pipe
);
1554 void (*shader_free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
1555 BOOL (*shader_allocate_context_data
)(struct wined3d_context
*context
);
1556 void (*shader_free_context_data
)(struct wined3d_context
*context
);
1557 void (*shader_init_context_state
)(struct wined3d_context
*context
);
1558 void (*shader_get_caps
)(const struct wined3d_adapter
*adapter
, struct shader_caps
*caps
);
1559 BOOL (*shader_color_fixup_supported
)(struct color_fixup_desc fixup
);
1560 BOOL (*shader_has_ffp_proj_control
)(void *shader_priv
);
1561 uint64_t (*shader_compile
)(struct wined3d_context
*context
, const struct wined3d_shader_desc
*shader_desc
,
1562 enum wined3d_shader_type shader_type
);
1565 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN
;
1566 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN
;
1567 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN
;
1569 const struct wined3d_shader_backend_ops
*wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN
;
1571 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1573 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1574 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1575 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1576 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1578 static inline void wined3d_color_from_d3dcolor(struct wined3d_color
*wined3d_color
, DWORD d3d_color
)
1580 wined3d_color
->r
= D3DCOLOR_B_R(d3d_color
) / 255.0f
;
1581 wined3d_color
->g
= D3DCOLOR_B_G(d3d_color
) / 255.0f
;
1582 wined3d_color
->b
= D3DCOLOR_B_B(d3d_color
) / 255.0f
;
1583 wined3d_color
->a
= D3DCOLOR_B_A(d3d_color
) / 255.0f
;
1586 extern const struct wined3d_vec4 wined3d_srgb_const
[] DECLSPEC_HIDDEN
;
1588 static inline float wined3d_srgb_from_linear(float colour
)
1592 if (colour
< wined3d_srgb_const
[1].x
)
1593 return colour
* wined3d_srgb_const
[0].w
;
1595 return wined3d_srgb_const
[0].y
* powf(colour
, wined3d_srgb_const
[0].x
) - wined3d_srgb_const
[0].z
;
1599 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color
*colour_srgb
,
1600 const struct wined3d_color
*colour
)
1602 colour_srgb
->r
= wined3d_srgb_from_linear(colour
->r
);
1603 colour_srgb
->g
= wined3d_srgb_from_linear(colour
->g
);
1604 colour_srgb
->b
= wined3d_srgb_from_linear(colour
->b
);
1605 colour_srgb
->a
= colour
->a
;
1610 /* client_map_count and map_ptr are accessed from both the client and CS
1611 * threads, and protected by wined3d_device.bo_map_lock. */
1614 size_t buffer_offset
;
1615 size_t memory_offset
;
1616 unsigned int client_map_count
;
1618 /* Number of resources referencing this BO, used for COW tracking.
1619 * If a resource has this BO as a location and wants to write to it, it
1620 * needs to make a copy unless it's the only owner (refcount == 1).
1621 * Deferred contexts may also hold a reference. */
1625 struct wined3d_bo_user
1631 struct wined3d_bo_address
1633 struct wined3d_bo
*buffer_object
;
1637 struct wined3d_const_bo_address
1639 struct wined3d_bo
*buffer_object
;
1643 static inline struct wined3d_const_bo_address
*wined3d_const_bo_address(const struct wined3d_bo_address
*data
)
1645 return (struct wined3d_const_bo_address
*)data
;
1648 struct wined3d_stream_info_element
1650 const struct wined3d_format
*format
;
1651 struct wined3d_bo_address data
;
1652 unsigned int stride
;
1653 unsigned int stream_idx
;
1654 unsigned int divisor
;
1658 struct wined3d_stream_info
1660 struct wined3d_stream_info_element elements
[MAX_ATTRIBS
];
1661 DWORD position_transformed
: 1;
1663 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1664 DWORD use_map
; /* MAX_ATTRIBS, 32 */
1667 void wined3d_stream_info_from_declaration(struct wined3d_stream_info
*stream_info
,
1668 const struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
) DECLSPEC_HIDDEN
;
1670 struct wined3d_direct_dispatch_parameters
1672 unsigned int group_count_x
;
1673 unsigned int group_count_y
;
1674 unsigned int group_count_z
;
1677 struct wined3d_indirect_dispatch_parameters
1679 struct wined3d_buffer
*buffer
;
1680 unsigned int offset
;
1683 struct wined3d_dispatch_parameters
1688 struct wined3d_direct_dispatch_parameters direct
;
1689 struct wined3d_indirect_dispatch_parameters indirect
;
1693 struct wined3d_direct_draw_parameters
1695 int base_vertex_idx
;
1696 unsigned int start_idx
;
1697 unsigned int index_count
;
1698 unsigned int start_instance
;
1699 unsigned int instance_count
;
1702 struct wined3d_indirect_draw_parameters
1704 struct wined3d_buffer
*buffer
;
1705 unsigned int offset
;
1708 struct wined3d_draw_parameters
1713 struct wined3d_direct_draw_parameters direct
;
1714 struct wined3d_indirect_draw_parameters indirect
;
1719 void draw_primitive(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1720 const struct wined3d_draw_parameters
*draw_parameters
) DECLSPEC_HIDDEN
;
1721 void dispatch_compute(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1722 const struct wined3d_dispatch_parameters
*dispatch_parameters
) DECLSPEC_HIDDEN
;
1726 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1727 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1729 /* Routines and structures related to state management */
1731 #define STATE_RENDER(a) (a)
1732 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1734 #define STATE_TEXTURESTAGE(stage, num) \
1735 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1736 #define STATE_IS_TEXTURESTAGE(a) \
1737 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_FFP_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1739 /* + 1 because samplers start with 0 */
1740 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_FFP_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1741 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1743 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1744 #define STATE_IS_GRAPHICS_SHADER(a) \
1745 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1747 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1748 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1749 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1750 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1752 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1753 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1755 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1756 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1758 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1759 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1761 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1762 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1763 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1764 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1766 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1767 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1769 #define STATE_VIEWPORT (STATE_VDECL + 1)
1770 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1772 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1773 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1774 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1775 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1777 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1778 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1780 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1781 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1783 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1784 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1786 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1787 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1789 #define STATE_DEPTH_BOUNDS (STATE_RASTERIZER + 1)
1790 #define STATE_IS_DEPTH_BOUNDS(a) ((a) == STATE_DEPTH_BOUNDS)
1792 #define STATE_POINTSPRITECOORDORIGIN (STATE_DEPTH_BOUNDS + 1)
1793 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1795 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1796 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1798 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1799 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1801 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1802 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1804 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1805 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1807 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1808 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1810 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1811 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1813 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1814 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1816 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1817 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1819 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1820 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1822 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1823 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1825 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1827 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1828 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1830 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1831 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1833 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1834 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1836 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1837 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1839 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1840 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1842 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1843 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1845 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1846 #define STATE_CONSTANT_BUFFER(a) \
1847 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1848 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1849 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1857 /* Direct3D terminology with little modifications. We do not have an issued
1858 * state because only the driver knows about it, but we have a created state
1859 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1860 enum wined3d_query_state
1867 struct wined3d_query_ops
1869 BOOL (*query_poll
)(struct wined3d_query
*query
, uint32_t flags
);
1870 BOOL (*query_issue
)(struct wined3d_query
*query
, uint32_t flags
);
1871 void (*query_destroy
)(struct wined3d_query
*query
);
1874 struct wined3d_query
1879 const struct wined3d_parent_ops
*parent_ops
;
1880 struct wined3d_device
*device
;
1881 enum wined3d_query_state state
;
1882 enum wined3d_query_type type
;
1885 const struct wined3d_query_ops
*query_ops
;
1887 LONG counter_main
, counter_retrieved
;
1888 struct list poll_list_entry
;
1890 /* FIXME: This is GL-specific. */
1891 unsigned int buffer_object
;
1896 #define WINED3D_QUERY_POOL_SIZE 256
1898 struct wined3d_range
1900 unsigned int offset
;
1904 struct wined3d_fb_state
1906 struct wined3d_rendertarget_view
*render_targets
[WINED3D_MAX_RENDER_TARGETS
];
1907 struct wined3d_rendertarget_view
*depth_stencil
;
1910 struct wined3d_context
1912 const struct wined3d_d3d_info
*d3d_info
;
1913 const struct wined3d_state_entry
*state_table
;
1914 uint32_t dirty_graphics_states
[WINED3D_BITMAP_SIZE(STATE_HIGHEST
)];
1915 uint32_t dirty_compute_states
[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT
)];
1917 struct wined3d_device
*device
;
1918 struct wined3d_swapchain
*swapchain
;
1921 struct wined3d_texture
*texture
;
1922 unsigned int sub_resource_idx
;
1925 /* Stores some information about the context state for optimization */
1926 DWORD last_swizzle_map
; /* MAX_ATTRIBS, 32 */
1928 DWORD shader_update_mask
: 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1929 DWORD update_shader_resource_bindings
: 1;
1930 DWORD update_compute_shader_resource_bindings
: 1;
1931 DWORD update_unordered_access_view_bindings
: 1;
1932 DWORD update_compute_unordered_access_view_bindings
: 1;
1933 DWORD last_was_rhw
: 1; /* True iff last draw_primitive was in xyzrhw mode. */
1934 DWORD last_was_pshader
: 1;
1935 DWORD last_was_vshader
: 1;
1936 DWORD last_was_diffuse
: 1;
1937 DWORD last_was_specular
: 1;
1938 DWORD last_was_normal
: 1;
1939 DWORD last_was_ffp_blit
: 1;
1940 DWORD last_was_blit
: 1;
1941 DWORD last_was_ckey
: 1;
1942 DWORD last_was_dual_source_blend
: 1;
1943 DWORD texShaderBumpMap
: 8; /* WINED3D_MAX_FFP_TEXTURES, 8 */
1944 DWORD lowest_disabled_stage
: 4; /* Max WINED3D_MAX_FFP_TEXTURES, 8 */
1946 DWORD lastWasPow2Texture
: 8; /* WINED3D_MAX_FFP_TEXTURES, 8 */
1947 DWORD fixed_function_usage_map
: 8; /* WINED3D_MAX_FFP_TEXTURES, 8 */
1948 DWORD use_immediate_mode_draw
: 1;
1949 DWORD uses_uavs
: 1;
1950 DWORD uses_fbo_attached_resources
: 1;
1951 DWORD transform_feedback_active
: 1;
1952 DWORD transform_feedback_paused
: 1;
1953 DWORD fog_coord
: 1;
1954 DWORD render_offscreen
: 1;
1956 DWORD destroyed
: 1;
1957 DWORD destroy_delayed
: 1;
1958 DWORD namedArraysLoaded
: 1;
1961 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1963 DWORD constant_update_mask
;
1964 DWORD numbered_array_mask
;
1965 enum fogsource fog_source
;
1968 void *shader_backend_data
;
1969 void *fragment_pipe_data
;
1971 struct wined3d_stream_info stream_info
;
1973 unsigned int viewport_count
;
1974 unsigned int scissor_rect_count
;
1977 void wined3d_context_cleanup(struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
1978 void wined3d_context_init(struct wined3d_context
*context
, struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
1979 void context_preload_textures(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
1980 void context_update_stream_info(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
1982 HRESULT
wined3d_context_no3d_init(struct wined3d_context
*context_no3d
,
1983 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
1985 typedef void (*APPLYSTATEFUNC
)(struct wined3d_context
*ctx
, const struct wined3d_state
*state
, DWORD state_id
);
1987 struct wined3d_state_entry
1989 unsigned int representative
;
1990 APPLYSTATEFUNC apply
;
1993 struct wined3d_state_entry_template
1996 struct wined3d_state_entry content
;
1997 unsigned int extension
;
2000 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2001 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2003 struct wined3d_fragment_pipe_ops
2005 void (*fp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2006 void (*get_caps
)(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
);
2007 unsigned int (*get_emul_mask
)(const struct wined3d_adapter
*adapter
);
2008 void *(*alloc_private
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2009 void (*free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2010 BOOL (*allocate_context_data
)(struct wined3d_context
*context
);
2011 void (*free_context_data
)(struct wined3d_context
*context
);
2012 BOOL (*color_fixup_supported
)(struct color_fixup_desc fixup
);
2013 const struct wined3d_state_entry_template
*states
;
2016 struct wined3d_vertex_caps
2019 BOOL emulated_flatshading
;
2020 BOOL ffp_generic_attributes
;
2021 DWORD max_active_lights
;
2022 DWORD max_vertex_blend_matrices
;
2023 DWORD max_vertex_blend_matrix_index
;
2024 DWORD vertex_processing_caps
;
2026 DWORD max_user_clip_planes
;
2030 struct wined3d_vertex_pipe_ops
2032 void (*vp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2033 void (*vp_get_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
);
2034 unsigned int (*vp_get_emul_mask
)(const struct wined3d_adapter
*adapter
);
2035 void *(*vp_alloc
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2036 void (*vp_free
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2037 const struct wined3d_state_entry_template
*vp_states
;
2040 extern const struct wined3d_state_entry_template misc_state_template_gl
[] DECLSPEC_HIDDEN
;
2041 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN
;
2042 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN
;
2043 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN
;
2044 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN
;
2045 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN
;
2046 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN
;
2047 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN
;
2049 const struct wined3d_fragment_pipe_ops
*wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2051 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN
;
2052 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN
;
2053 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN
;
2055 const struct wined3d_vertex_pipe_ops
*wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2057 /* "Base" state table */
2058 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
2059 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
2060 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
2061 const struct wined3d_state_entry_template
*misc
) DECLSPEC_HIDDEN
;
2063 enum wined3d_blit_op
2065 WINED3D_BLIT_OP_COLOR_BLIT
,
2066 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
,
2067 WINED3D_BLIT_OP_COLOR_BLIT_CKEY
,
2068 WINED3D_BLIT_OP_DEPTH_BLIT
,
2069 WINED3D_BLIT_OP_RAW_BLIT
,
2072 struct wined3d_blitter
2074 const struct wined3d_blitter_ops
*ops
;
2075 struct wined3d_blitter
*next
;
2078 struct wined3d_blitter_ops
2080 void (*blitter_destroy
)(struct wined3d_blitter
*blitter
, struct wined3d_context
*context
);
2081 void (*blitter_clear
)(struct wined3d_blitter
*blitter
, struct wined3d_device
*device
,
2082 unsigned int rt_count
, const struct wined3d_fb_state
*fb
, unsigned int rect_count
, const RECT
*clear_rects
,
2083 const RECT
*draw_rect
, uint32_t flags
, const struct wined3d_color
*colour
, float depth
, unsigned int stencil
);
2084 DWORD (*blitter_blit
)(struct wined3d_blitter
*blitter
, enum wined3d_blit_op op
, struct wined3d_context
*context
,
2085 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
, DWORD src_location
,
2086 const RECT
*src_rect
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
2087 DWORD dst_location
, const RECT
*dst_rect
, const struct wined3d_color_key
*colour_key
,
2088 enum wined3d_texture_filter_type filter
, const struct wined3d_format
*resolve_format
);
2091 struct wined3d_blitter
*wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN
;
2092 void wined3d_vk_blitter_create(struct wined3d_blitter
**next
) DECLSPEC_HIDDEN
;
2094 BOOL
wined3d_clip_blit(const RECT
*clip_rect
, RECT
*clipped
, RECT
*other
) DECLSPEC_HIDDEN
;
2096 void context_invalidate_compute_state(struct wined3d_context
*context
, DWORD state_id
) DECLSPEC_HIDDEN
;
2097 void context_invalidate_state(struct wined3d_context
*context
, unsigned int state_id
) DECLSPEC_HIDDEN
;
2098 void context_resource_released(const struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
2099 void context_restore(struct wined3d_context
*context
, struct wined3d_texture
*texture
,
2100 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2101 void context_set_tls_idx(DWORD idx
) DECLSPEC_HIDDEN
;
2102 void context_state_drawbuf(struct wined3d_context
*context
,
2103 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2104 void context_state_fb(struct wined3d_context
*context
,
2105 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2107 /*****************************************************************************
2108 * Internal representation of a light
2110 struct wined3d_light_info
2112 struct wined3d_light OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
2113 unsigned int OriginalIndex
;
2117 /* Converted parms to speed up swapping lights */
2118 struct wined3d_vec4 position
;
2119 struct wined3d_vec4 direction
;
2123 struct rb_entry entry
;
2124 struct list changed_entry
;
2128 /* The default light parameters */
2129 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN
;
2131 struct wined3d_pixel_format
2133 int iPixelFormat
; /* WGL pixel format */
2134 int iPixelType
; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2135 int redSize
, greenSize
, blueSize
, alphaSize
, colorSize
;
2136 int depthSize
, stencilSize
;
2137 BOOL windowDrawable
;
2144 enum wined3d_pci_vendor
2146 HW_VENDOR_SOFTWARE
= 0x0000,
2147 HW_VENDOR_AMD
= 0x1002,
2148 HW_VENDOR_NVIDIA
= 0x10de,
2149 HW_VENDOR_VMWARE
= 0x15ad,
2150 HW_VENDOR_REDHAT
= 0x1af4,
2151 HW_VENDOR_INTEL
= 0x8086,
2154 enum wined3d_pci_device
2158 CARD_AMD_RAGE_128PRO
= 0x5246,
2159 CARD_AMD_RADEON_7200
= 0x5144,
2160 CARD_AMD_RADEON_8500
= 0x514c,
2161 CARD_AMD_RADEON_9500
= 0x4144,
2162 CARD_AMD_RADEON_XPRESS_200M
= 0x5955,
2163 CARD_AMD_RADEON_X700
= 0x5e4c,
2164 CARD_AMD_RADEON_X1600
= 0x71c2,
2165 CARD_AMD_RADEON_HD2350
= 0x94c7,
2166 CARD_AMD_RADEON_HD2600
= 0x9581,
2167 CARD_AMD_RADEON_HD2900
= 0x9400,
2168 CARD_AMD_RADEON_HD3200
= 0x9620,
2169 CARD_AMD_RADEON_HD3850
= 0x9515,
2170 CARD_AMD_RADEON_HD4200M
= 0x9712,
2171 CARD_AMD_RADEON_HD4350
= 0x954f,
2172 CARD_AMD_RADEON_HD4600
= 0x9495,
2173 CARD_AMD_RADEON_HD4700
= 0x944e,
2174 CARD_AMD_RADEON_HD4800
= 0x944c,
2175 CARD_AMD_RADEON_HD5400
= 0x68f9,
2176 CARD_AMD_RADEON_HD5600
= 0x68d8,
2177 CARD_AMD_RADEON_HD5700
= 0x68be,
2178 CARD_AMD_RADEON_HD5800
= 0x6898,
2179 CARD_AMD_RADEON_HD5900
= 0x689c,
2180 CARD_AMD_RADEON_HD6300
= 0x9803,
2181 CARD_AMD_RADEON_HD6400
= 0x6770,
2182 CARD_AMD_RADEON_HD6490M
= 0x6760,
2183 CARD_AMD_RADEON_HD6410D
= 0x9644,
2184 CARD_AMD_RADEON_HD6480G
= 0x9648,
2185 CARD_AMD_RADEON_HD6550D
= 0x9640,
2186 CARD_AMD_RADEON_HD6600
= 0x6758,
2187 CARD_AMD_RADEON_HD6600M
= 0x6741,
2188 CARD_AMD_RADEON_HD6700
= 0x68ba,
2189 CARD_AMD_RADEON_HD6800
= 0x6739,
2190 CARD_AMD_RADEON_HD6900
= 0x6719,
2191 CARD_AMD_RADEON_HD7660D
= 0x9901,
2192 CARD_AMD_RADEON_HD7700
= 0x683d,
2193 CARD_AMD_RADEON_HD7800
= 0x6819,
2194 CARD_AMD_RADEON_HD7870
= 0x6818,
2195 CARD_AMD_RADEON_HD7900
= 0x679a,
2196 CARD_AMD_RADEON_HD8600M
= 0x6660,
2197 CARD_AMD_RADEON_HD8670
= 0x6610,
2198 CARD_AMD_RADEON_HD8770
= 0x665c,
2199 CARD_AMD_RADEON_R3
= 0x9830,
2200 CARD_AMD_RADEON_R7
= 0x130f,
2201 CARD_AMD_RADEON_R9_285
= 0x6939,
2202 CARD_AMD_RADEON_R9_290
= 0x67b1,
2203 CARD_AMD_RADEON_R9_290X
= 0x67b0,
2204 CARD_AMD_RADEON_R9_FURY
= 0x7300,
2205 CARD_AMD_RADEON_R9_M370X
= 0x6821,
2206 CARD_AMD_RADEON_R9_M380
= 0x6647,
2207 CARD_AMD_RADEON_R9_M395X
= 0x6920,
2208 CARD_AMD_RADEON_RX_460
= 0x67ef,
2209 CARD_AMD_RADEON_RX_480
= 0x67df,
2210 CARD_AMD_RADEON_RX_VEGA_10
= 0x687f,
2211 CARD_AMD_RADEON_RX_VEGA_12
= 0x69af,
2212 CARD_AMD_RADEON_RAVEN
= 0x15dd,
2213 CARD_AMD_RADEON_RX_VEGA_20
= 0x66af,
2214 CARD_AMD_RADEON_RX_NAVI_10
= 0x731f,
2215 CARD_AMD_RADEON_RX_NAVI_14
= 0x7340,
2216 CARD_AMD_RADEON_RX_NAVI_21
= 0x73bf,
2217 CARD_AMD_RADEON_PRO_V620
= 0x73a1,
2218 CARD_AMD_RADEON_PRO_V620_VF
= 0x73ae,
2219 CARD_AMD_VANGOGH
= 0x163f,
2220 CARD_AMD_RAPHAEL
= 0x164e,
2222 CARD_NVIDIA_RIVA_128
= 0x0018,
2223 CARD_NVIDIA_RIVA_TNT
= 0x0020,
2224 CARD_NVIDIA_RIVA_TNT2
= 0x0028,
2225 CARD_NVIDIA_GEFORCE
= 0x0100,
2226 CARD_NVIDIA_GEFORCE2_MX
= 0x0110,
2227 CARD_NVIDIA_GEFORCE2
= 0x0150,
2228 CARD_NVIDIA_GEFORCE3
= 0x0200,
2229 CARD_NVIDIA_GEFORCE4_MX
= 0x0170,
2230 CARD_NVIDIA_GEFORCE4_TI4200
= 0x0253,
2231 CARD_NVIDIA_GEFORCEFX_5200
= 0x0320,
2232 CARD_NVIDIA_GEFORCEFX_5600
= 0x0312,
2233 CARD_NVIDIA_GEFORCEFX_5800
= 0x0302,
2234 CARD_NVIDIA_GEFORCE_6200
= 0x014f,
2235 CARD_NVIDIA_GEFORCE_6600GT
= 0x0140,
2236 CARD_NVIDIA_GEFORCE_6800
= 0x0041,
2237 CARD_NVIDIA_GEFORCE_7300
= 0x01d7, /* GeForce Go 7300 */
2238 CARD_NVIDIA_GEFORCE_7400
= 0x01d8,
2239 CARD_NVIDIA_GEFORCE_7600
= 0x0391,
2240 CARD_NVIDIA_GEFORCE_7800GT
= 0x0092,
2241 CARD_NVIDIA_GEFORCE_8200
= 0x0849, /* Other PCI ID 0x084b */
2242 CARD_NVIDIA_GEFORCE_8300GS
= 0x0423,
2243 CARD_NVIDIA_GEFORCE_8400GS
= 0x0404,
2244 CARD_NVIDIA_GEFORCE_8500GT
= 0x0421,
2245 CARD_NVIDIA_GEFORCE_8600GT
= 0x0402,
2246 CARD_NVIDIA_GEFORCE_8600MGT
= 0x0407,
2247 CARD_NVIDIA_GEFORCE_8800GTS
= 0x0193,
2248 CARD_NVIDIA_GEFORCE_8800GTX
= 0x0191,
2249 CARD_NVIDIA_GEFORCE_9200
= 0x086d,
2250 CARD_NVIDIA_GEFORCE_9300
= 0x086c,
2251 CARD_NVIDIA_GEFORCE_9400M
= 0x0863,
2252 CARD_NVIDIA_GEFORCE_9400GT
= 0x042c,
2253 CARD_NVIDIA_GEFORCE_9500GT
= 0x0640,
2254 CARD_NVIDIA_GEFORCE_9600GT
= 0x0622,
2255 CARD_NVIDIA_GEFORCE_9700MGT
= 0x064a,
2256 CARD_NVIDIA_GEFORCE_9800GT
= 0x0614,
2257 CARD_NVIDIA_GEFORCE_210
= 0x0a23,
2258 CARD_NVIDIA_GEFORCE_GT220
= 0x0a20,
2259 CARD_NVIDIA_GEFORCE_GT240
= 0x0ca3,
2260 CARD_NVIDIA_GEFORCE_GTS250
= 0x0615,
2261 CARD_NVIDIA_GEFORCE_GTX260
= 0x05e2,
2262 CARD_NVIDIA_GEFORCE_GTX275
= 0x05e6,
2263 CARD_NVIDIA_GEFORCE_GTX280
= 0x05e1,
2264 CARD_NVIDIA_GEFORCE_315M
= 0x0a7a,
2265 CARD_NVIDIA_GEFORCE_320M
= 0x08a3,
2266 CARD_NVIDIA_GEFORCE_GT320M
= 0x0a2d,
2267 CARD_NVIDIA_GEFORCE_GT325M
= 0x0a35,
2268 CARD_NVIDIA_GEFORCE_GT330
= 0x0ca0,
2269 CARD_NVIDIA_GEFORCE_GTS350M
= 0x0cb0,
2270 CARD_NVIDIA_GEFORCE_410M
= 0x1055,
2271 CARD_NVIDIA_GEFORCE_GT420
= 0x0de2,
2272 CARD_NVIDIA_GEFORCE_GT425M
= 0x0df0,
2273 CARD_NVIDIA_GEFORCE_GT430
= 0x0de1,
2274 CARD_NVIDIA_GEFORCE_GT440
= 0x0de0,
2275 CARD_NVIDIA_GEFORCE_GTS450
= 0x0dc4,
2276 CARD_NVIDIA_GEFORCE_GTX460
= 0x0e22,
2277 CARD_NVIDIA_GEFORCE_GTX460M
= 0x0dd1,
2278 CARD_NVIDIA_GEFORCE_GTX465
= 0x06c4,
2279 CARD_NVIDIA_GEFORCE_GTX470
= 0x06cd,
2280 CARD_NVIDIA_GEFORCE_GTX480
= 0x06c0,
2281 CARD_NVIDIA_GEFORCE_GT520
= 0x1040,
2282 CARD_NVIDIA_GEFORCE_GT525M
= 0x0dec,
2283 CARD_NVIDIA_GEFORCE_GT540M
= 0x0df4,
2284 CARD_NVIDIA_GEFORCE_GTX550
= 0x1244,
2285 CARD_NVIDIA_GEFORCE_GT555M
= 0x04b8,
2286 CARD_NVIDIA_GEFORCE_GTX560TI
= 0x1200,
2287 CARD_NVIDIA_GEFORCE_GTX560M
= 0x1251,
2288 CARD_NVIDIA_GEFORCE_GTX560
= 0x1201,
2289 CARD_NVIDIA_GEFORCE_GTX570
= 0x1081,
2290 CARD_NVIDIA_GEFORCE_GTX580
= 0x1080,
2291 CARD_NVIDIA_GEFORCE_GT610
= 0x104a,
2292 CARD_NVIDIA_GEFORCE_GT630
= 0x0f00,
2293 CARD_NVIDIA_GEFORCE_GT630M
= 0x0de9,
2294 CARD_NVIDIA_GEFORCE_GT640
= 0x0fc1,
2295 CARD_NVIDIA_GEFORCE_GT640M
= 0x0fd2,
2296 CARD_NVIDIA_GEFORCE_GT650M
= 0x0fd1,
2297 CARD_NVIDIA_GEFORCE_GTX650
= 0x0fc6,
2298 CARD_NVIDIA_GEFORCE_GTX650TI
= 0x11c6,
2299 CARD_NVIDIA_GEFORCE_GTX660
= 0x11c0,
2300 CARD_NVIDIA_GEFORCE_GTX660M
= 0x0fd4,
2301 CARD_NVIDIA_GEFORCE_GTX660TI
= 0x1183,
2302 CARD_NVIDIA_GEFORCE_GTX670
= 0x1189,
2303 CARD_NVIDIA_GEFORCE_GTX670MX
= 0x11a1,
2304 CARD_NVIDIA_GEFORCE_GTX675MX_1
= 0x11a7,
2305 CARD_NVIDIA_GEFORCE_GTX675MX_2
= 0x11a2,
2306 CARD_NVIDIA_GEFORCE_GTX680
= 0x1180,
2307 CARD_NVIDIA_GEFORCE_GTX690
= 0x1188,
2308 CARD_NVIDIA_GEFORCE_GT720
= 0x128b,
2309 CARD_NVIDIA_GEFORCE_GT730
= 0x1287,
2310 CARD_NVIDIA_GEFORCE_GT730M
= 0x0fe1,
2311 CARD_NVIDIA_GEFORCE_GT740M
= 0x1292,
2312 CARD_NVIDIA_GEFORCE_GT750M
= 0x0fe9,
2313 CARD_NVIDIA_GEFORCE_GT755M
= 0x0fcd,
2314 CARD_NVIDIA_GEFORCE_GTX750
= 0x1381,
2315 CARD_NVIDIA_GEFORCE_GTX750TI
= 0x1380,
2316 CARD_NVIDIA_GEFORCE_GTX760
= 0x1187,
2317 CARD_NVIDIA_GEFORCE_GTX760TI
= 0x1193,
2318 CARD_NVIDIA_GEFORCE_GTX765M
= 0x11e2,
2319 CARD_NVIDIA_GEFORCE_GTX770M
= 0x11e0,
2320 CARD_NVIDIA_GEFORCE_GTX770
= 0x1184,
2321 CARD_NVIDIA_GEFORCE_GTX775M
= 0x119d,
2322 CARD_NVIDIA_GEFORCE_GTX780
= 0x1004,
2323 CARD_NVIDIA_GEFORCE_GTX780M
= 0x119e,
2324 CARD_NVIDIA_GEFORCE_GTX780TI
= 0x100a,
2325 CARD_NVIDIA_GEFORCE_GTXTITAN
= 0x1005,
2326 CARD_NVIDIA_GEFORCE_GTXTITANB
= 0x100c,
2327 CARD_NVIDIA_GEFORCE_GTXTITANX
= 0x17c2,
2328 CARD_NVIDIA_GEFORCE_GTXTITANZ
= 0x1001,
2329 CARD_NVIDIA_GEFORCE_820M
= 0x0fed,
2330 CARD_NVIDIA_GEFORCE_830M
= 0x1340,
2331 CARD_NVIDIA_GEFORCE_840M
= 0x1341,
2332 CARD_NVIDIA_GEFORCE_845M
= 0x1344,
2333 CARD_NVIDIA_GEFORCE_GTX850M
= 0x1391,
2334 CARD_NVIDIA_GEFORCE_GTX860M
= 0x1392, /* Other PCI ID 0x119a */
2335 CARD_NVIDIA_GEFORCE_GTX870M
= 0x1199,
2336 CARD_NVIDIA_GEFORCE_GTX880M
= 0x1198,
2337 CARD_NVIDIA_GEFORCE_940M
= 0x1347,
2338 CARD_NVIDIA_GEFORCE_GTX950
= 0x1402,
2339 CARD_NVIDIA_GEFORCE_GTX950M
= 0x139a,
2340 CARD_NVIDIA_GEFORCE_GTX960
= 0x1401,
2341 CARD_NVIDIA_GEFORCE_GTX960M
= 0x139b,
2342 CARD_NVIDIA_GEFORCE_GTX970
= 0x13c2,
2343 CARD_NVIDIA_GEFORCE_GTX970M
= 0x13d8,
2344 CARD_NVIDIA_GEFORCE_GTX980
= 0x13c0,
2345 CARD_NVIDIA_GEFORCE_GTX980TI
= 0x17c8,
2346 CARD_NVIDIA_GEFORCE_GT1030
= 0x1d01,
2347 CARD_NVIDIA_GEFORCE_GTX1050
= 0x1c81,
2348 CARD_NVIDIA_GEFORCE_GTX1050TI
= 0x1c82,
2349 CARD_NVIDIA_GEFORCE_GTX1060_3GB
= 0x1c02,
2350 CARD_NVIDIA_GEFORCE_GTX1060
= 0x1c03,
2351 CARD_NVIDIA_GEFORCE_GTX1060M
= 0x1c20,
2352 CARD_NVIDIA_GEFORCE_GTX1070
= 0x1b81,
2353 CARD_NVIDIA_GEFORCE_GTX1080
= 0x1b80,
2354 CARD_NVIDIA_GEFORCE_GTX1080M
= 0x1be0,
2355 CARD_NVIDIA_GEFORCE_GTX1080TI
= 0x1b06,
2356 CARD_NVIDIA_TITANX_PASCAL
= 0x1b00,
2357 CARD_NVIDIA_TITANV
= 0x1d81,
2358 CARD_NVIDIA_GEFORCE_GTX1650SUPER
= 0x2187,
2359 CARD_NVIDIA_GEFORCE_GTX1660SUPER
= 0x21c4,
2360 CARD_NVIDIA_GEFORCE_GTX1660TI
= 0x2182,
2361 CARD_NVIDIA_GEFORCE_RTX2060
= 0x1f08,
2362 CARD_NVIDIA_GEFORCE_RTX2070
= 0x1f07,
2363 CARD_NVIDIA_GEFORCE_RTX2080
= 0x1e87,
2364 CARD_NVIDIA_GEFORCE_RTX2080TI
= 0x1e07,
2365 CARD_NVIDIA_TESLA_T4
= 0x1eb8,
2366 CARD_NVIDIA_AMPERE_A10
= 0x2236,
2368 CARD_REDHAT_VIRGL
= 0x1010,
2370 CARD_VMWARE_SVGA3D
= 0x0405,
2372 CARD_INTEL_830M
= 0x3577,
2373 CARD_INTEL_855GM
= 0x3582,
2374 CARD_INTEL_845G
= 0x2562,
2375 CARD_INTEL_865G
= 0x2572,
2376 CARD_INTEL_915G
= 0x2582,
2377 CARD_INTEL_E7221G
= 0x258a,
2378 CARD_INTEL_915GM
= 0x2592,
2379 CARD_INTEL_945G
= 0x2772,
2380 CARD_INTEL_945GM
= 0x27a2,
2381 CARD_INTEL_945GME
= 0x27ae,
2382 CARD_INTEL_Q35
= 0x29b2,
2383 CARD_INTEL_G33
= 0x29c2,
2384 CARD_INTEL_Q33
= 0x29d2,
2385 CARD_INTEL_PNVG
= 0xa001,
2386 CARD_INTEL_PNVM
= 0xa011,
2387 CARD_INTEL_965Q
= 0x2992,
2388 CARD_INTEL_965G
= 0x2982,
2389 CARD_INTEL_946GZ
= 0x2972,
2390 CARD_INTEL_965GM
= 0x2a02,
2391 CARD_INTEL_965GME
= 0x2a12,
2392 CARD_INTEL_GM45
= 0x2a42,
2393 CARD_INTEL_IGD
= 0x2e02,
2394 CARD_INTEL_Q45
= 0x2e12,
2395 CARD_INTEL_G45
= 0x2e22,
2396 CARD_INTEL_G41
= 0x2e32,
2397 CARD_INTEL_B43
= 0x2e92,
2398 CARD_INTEL_ILKD
= 0x0042,
2399 CARD_INTEL_ILKM
= 0x0046,
2400 CARD_INTEL_SNBD
= 0x0122,
2401 CARD_INTEL_SNBM
= 0x0126,
2402 CARD_INTEL_SNBS
= 0x010a,
2403 CARD_INTEL_IVBD
= 0x0162,
2404 CARD_INTEL_IVBM
= 0x0166,
2405 CARD_INTEL_IVBS
= 0x015a,
2406 CARD_INTEL_HWD
= 0x0412,
2407 CARD_INTEL_HWM
= 0x0416,
2408 CARD_INTEL_HD5000_1
= 0x0a26,
2409 CARD_INTEL_HD5000_2
= 0x0422,
2410 CARD_INTEL_I5100_1
= 0x0a22,
2411 CARD_INTEL_I5100_2
= 0x0a2a,
2412 CARD_INTEL_I5100_3
= 0x0a2b,
2413 CARD_INTEL_I5100_4
= 0x0a2e,
2414 CARD_INTEL_IP5200_1
= 0x0d22,
2415 CARD_INTEL_IP5200_2
= 0x0d26,
2416 CARD_INTEL_IP5200_3
= 0x0d2a,
2417 CARD_INTEL_IP5200_4
= 0x0d2b,
2418 CARD_INTEL_IP5200_5
= 0x0d2e,
2419 CARD_INTEL_IP5200_6
= 0x0c22,
2420 CARD_INTEL_HD5300
= 0x161e,
2421 CARD_INTEL_HD5500
= 0x1616,
2422 CARD_INTEL_HD5600
= 0x1612,
2423 CARD_INTEL_HD6000
= 0x1626,
2424 CARD_INTEL_I6100
= 0x162b,
2425 CARD_INTEL_IP6200
= 0x1622,
2426 CARD_INTEL_IPP6300
= 0x162a,
2427 CARD_INTEL_HD510_1
= 0x1902,
2428 CARD_INTEL_HD510_2
= 0x1906,
2429 CARD_INTEL_HD510_3
= 0x190b,
2430 CARD_INTEL_HD515
= 0x191e,
2431 CARD_INTEL_HD520_1
= 0x1916,
2432 CARD_INTEL_HD520_2
= 0x1921,
2433 CARD_INTEL_HD530_1
= 0x1912,
2434 CARD_INTEL_HD530_2
= 0x191b,
2435 CARD_INTEL_HDP530
= 0x191d,
2436 CARD_INTEL_I540
= 0x1926,
2437 CARD_INTEL_I550
= 0x1927,
2438 CARD_INTEL_I555
= 0x192b,
2439 CARD_INTEL_IP555
= 0x192d,
2440 CARD_INTEL_IP580_1
= 0x1932,
2441 CARD_INTEL_IP580_2
= 0x193b,
2442 CARD_INTEL_IPP580_1
= 0x193a,
2443 CARD_INTEL_IPP580_2
= 0x193d,
2444 CARD_INTEL_UHD617
= 0x87c0,
2445 CARD_INTEL_UHD620
= 0x3ea0,
2446 CARD_INTEL_HD615
= 0x591e,
2447 CARD_INTEL_HD620
= 0x5916,
2448 CARD_INTEL_HD630_1
= 0x5912,
2449 CARD_INTEL_HD630_2
= 0x591b,
2450 CARD_INTEL_UHD630_1
= 0x3e9b,
2451 CARD_INTEL_UHD630_2
= 0x3e91,
2454 /* The driver names reflect the lowest GPU supported
2455 * by a certain driver, so DRIVER_AMD_R300 supports
2456 * R3xx, R4xx and R5xx GPUs. */
2457 enum wined3d_display_driver
2459 DRIVER_AMD_RAGE_128PRO
,
2464 DRIVER_INTEL_GMA800
,
2465 DRIVER_INTEL_GMA900
,
2466 DRIVER_INTEL_GMA950
,
2467 DRIVER_INTEL_GMA3000
,
2468 DRIVER_INTEL_HD4000
,
2470 DRIVER_NVIDIA_GEFORCE2MX
,
2471 DRIVER_NVIDIA_GEFORCEFX
,
2472 DRIVER_NVIDIA_GEFORCE6
,
2473 DRIVER_NVIDIA_GEFORCE8
,
2474 DRIVER_NVIDIA_FERMI
,
2475 DRIVER_NVIDIA_KEPLER
,
2476 DRIVER_REDHAT_VIRGL
,
2482 struct wined3d_gpu_description
2484 enum wined3d_pci_vendor vendor
;
2485 enum wined3d_pci_device device
;
2486 const char *description
;
2487 enum wined3d_display_driver driver
;
2488 unsigned int vidmem
;
2491 const struct wined3d_gpu_description
*wined3d_get_gpu_description(enum wined3d_pci_vendor vendor
,
2492 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
2493 const struct wined3d_gpu_description
*wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor
,
2494 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
2495 enum wined3d_pci_device
wined3d_gpu_from_feature_level(enum wined3d_pci_vendor
*vendor
,
2496 enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
2498 /* 512 in Direct3D 8/9, 128 in DXGI. */
2499 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
2501 struct wined3d_driver_info
2503 enum wined3d_pci_vendor vendor
;
2504 enum wined3d_pci_device device
;
2506 char description
[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH
];
2508 UINT64 sysmem_bytes
;
2509 unsigned int version_high
;
2510 unsigned int version_low
;
2513 bool wined3d_driver_info_init(struct wined3d_driver_info
*driver_info
,
2514 const struct wined3d_gpu_description
*gpu_description
, enum wined3d_feature_level feature_level
,
2515 UINT64 vram_bytes
, UINT64 sysmem_bytes
) DECLSPEC_HIDDEN
;
2517 #define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
2518 #define UPLOAD_BO_RENAME_ON_UNMAP 0x2
2519 #define UPLOAD_BO_FREE_ON_UNMAP 0x4
2523 struct wined3d_const_bo_address addr
;
2527 struct wined3d_adapter_ops
2529 void (*adapter_destroy
)(struct wined3d_adapter
*adapter
);
2530 HRESULT (*adapter_create_device
)(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
2531 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
2532 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
2533 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
);
2534 void (*adapter_destroy_device
)(struct wined3d_device
*device
);
2535 struct wined3d_context
*(*adapter_acquire_context
)(struct wined3d_device
*device
,
2536 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
2537 void (*adapter_release_context
)(struct wined3d_context
*context
);
2538 void (*adapter_get_wined3d_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
);
2539 BOOL (*adapter_check_format
)(const struct wined3d_adapter
*adapter
,
2540 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
2541 const struct wined3d_format
*ds_format
);
2542 HRESULT (*adapter_init_3d
)(struct wined3d_device
*device
);
2543 void (*adapter_uninit_3d
)(struct wined3d_device
*device
);
2544 void *(*adapter_map_bo_address
)(struct wined3d_context
*context
,
2545 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
);
2546 void (*adapter_unmap_bo_address
)(struct wined3d_context
*context
, const struct wined3d_bo_address
*data
,
2547 unsigned int range_count
, const struct wined3d_range
*ranges
);
2548 void (*adapter_copy_bo_address
)(struct wined3d_context
*context
,
2549 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
2550 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
);
2551 void (*adapter_flush_bo_address
)(struct wined3d_context
*context
,
2552 const struct wined3d_const_bo_address
*data
, size_t size
);
2553 bool (*adapter_alloc_bo
)(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
2554 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
);
2555 void (*adapter_destroy_bo
)(struct wined3d_context
*context
, struct wined3d_bo
*bo
);
2556 HRESULT (*adapter_create_swapchain
)(struct wined3d_device
*device
,
2557 const struct wined3d_swapchain_desc
*desc
,
2558 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
2559 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
);
2560 void (*adapter_destroy_swapchain
)(struct wined3d_swapchain
*swapchain
);
2561 HRESULT (*adapter_create_buffer
)(struct wined3d_device
*device
, const struct wined3d_buffer_desc
*desc
,
2562 const struct wined3d_sub_resource_data
*data
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2563 struct wined3d_buffer
**buffer
);
2564 void (*adapter_destroy_buffer
)(struct wined3d_buffer
*buffer
);
2565 HRESULT (*adapter_create_texture
)(struct wined3d_device
*device
, const struct wined3d_resource_desc
*desc
,
2566 unsigned int layer_count
, unsigned int level_count
, uint32_t flags
, void *parent
,
2567 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
);
2568 void (*adapter_destroy_texture
)(struct wined3d_texture
*texture
);
2569 HRESULT (*adapter_create_rendertarget_view
)(const struct wined3d_view_desc
*desc
,
2570 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2571 struct wined3d_rendertarget_view
**view
);
2572 void (*adapter_destroy_rendertarget_view
)(struct wined3d_rendertarget_view
*view
);
2573 HRESULT (*adapter_create_shader_resource_view
)(const struct wined3d_view_desc
*desc
,
2574 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2575 struct wined3d_shader_resource_view
**view
);
2576 void (*adapter_destroy_shader_resource_view
)(struct wined3d_shader_resource_view
*view
);
2577 HRESULT (*adapter_create_unordered_access_view
)(const struct wined3d_view_desc
*desc
,
2578 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2579 struct wined3d_unordered_access_view
**view
);
2580 void (*adapter_destroy_unordered_access_view
)(struct wined3d_unordered_access_view
*view
);
2581 HRESULT (*adapter_create_sampler
)(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
2582 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
);
2583 void (*adapter_destroy_sampler
)(struct wined3d_sampler
*sampler
);
2584 HRESULT (*adapter_create_query
)(struct wined3d_device
*device
, enum wined3d_query_type type
,
2585 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
2586 void (*adapter_destroy_query
)(struct wined3d_query
*query
);
2587 void (*adapter_flush_context
)(struct wined3d_context
*context
);
2588 void (*adapter_draw_primitive
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
2589 const struct wined3d_draw_parameters
*parameters
);
2590 void (*adapter_dispatch_compute
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
2591 const struct wined3d_dispatch_parameters
*parameters
);
2592 void (*adapter_clear_uav
)(struct wined3d_context
*context
,
2593 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
);
2594 void (*adapter_generate_mipmap
)(struct wined3d_context
*context
, struct wined3d_shader_resource_view
*view
);
2597 struct wined3d_output
2599 unsigned int ordinal
;
2600 WCHAR device_name
[CCHDEVICENAME
];
2601 struct wined3d_adapter
*adapter
;
2602 enum wined3d_format_id screen_format
;
2604 D3DKMT_HANDLE kmt_device
;
2605 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id
;
2607 struct wined3d_display_mode
*modes
;
2608 SIZE_T mode_count
, modes_size
;
2612 HRESULT
wined3d_output_get_gamma_ramp(struct wined3d_output
*output
, struct wined3d_gamma_ramp
*ramp
) DECLSPEC_HIDDEN
;
2615 #define MAX_PERSISTENT_MAPPED_BYTES I64_MAX
2617 #define MAX_PERSISTENT_MAPPED_BYTES (128 * 1024 * 1024)
2620 /* The adapter structure */
2621 struct wined3d_adapter
2623 unsigned int ordinal
;
2625 struct wined3d_d3d_info d3d_info
;
2626 struct wined3d_driver_info driver_info
;
2627 struct wined3d_output
*outputs
;
2628 SIZE_T output_count
, outputs_size
;
2629 D3DKMT_HANDLE kmt_adapter
;
2630 UINT64 vram_bytes_used
;
2638 ssize_t mapped_size
;
2640 const struct wined3d_vertex_pipe_ops
*vertex_pipe
;
2641 const struct wined3d_fragment_pipe_ops
*fragment_pipe
;
2642 const struct wined3d_state_entry_template
*misc_state_template
;
2643 const struct wined3d_shader_backend_ops
*shader_backend
;
2644 const struct wined3d_adapter_ops
*adapter_ops
;
2647 BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, unsigned int ordinal
, const LUID
*luid
,
2648 const struct wined3d_adapter_ops
*adapter_ops
) DECLSPEC_HIDDEN
;
2649 void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
2650 BOOL
wined3d_get_primary_adapter_luid(LUID
*luid
) DECLSPEC_HIDDEN
;
2652 struct wined3d_adapter
*wined3d_adapter_vk_create(unsigned int ordinal
,
2653 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
2655 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
,
2656 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
2658 BOOL
wined3d_adapter_no3d_init_format_info(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
2659 ssize_t
adapter_adjust_mapped_memory(struct wined3d_adapter
*adapter
, ssize_t size
) DECLSPEC_HIDDEN
;
2660 UINT64
adapter_adjust_memory(struct wined3d_adapter
*adapter
, INT64 amount
) DECLSPEC_HIDDEN
;
2662 enum wined3d_projection_type
2664 WINED3D_PROJECTION_NONE
= 0,
2665 WINED3D_PROJECTION_COUNT3
= 1,
2666 WINED3D_PROJECTION_COUNT4
= 2
2669 /*****************************************************************************
2670 * Fixed function pipeline replacements
2672 #define ARG_UNUSED 0xff
2673 struct texture_stage_op
2685 struct color_fixup_desc color_fixup
;
2686 unsigned tex_type
: 3;
2687 unsigned tmp_dst
: 1;
2688 unsigned projected
: 2;
2689 unsigned padding
: 10;
2692 struct ffp_frag_settings
2694 struct texture_stage_op op
[WINED3D_MAX_FFP_TEXTURES
];
2695 enum wined3d_ffp_ps_fog_mode fog
;
2696 unsigned char sRGB_write
;
2697 unsigned char emul_clipplanes
;
2698 unsigned char texcoords_initialized
;
2699 unsigned char color_key_enabled
: 1;
2700 unsigned char pointsprite
: 1;
2701 unsigned char flatshading
: 1;
2702 unsigned char alpha_test_func
: 3;
2703 unsigned char padding
: 2;
2706 struct ffp_frag_desc
2708 struct wine_rb_entry entry
;
2709 struct ffp_frag_settings settings
;
2712 int wined3d_ffp_frag_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
2713 int wined3d_ffp_vertex_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
2715 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN
;
2717 void wined3d_ffp_get_fs_settings(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
2718 struct ffp_frag_settings
*settings
, BOOL ignore_textype
) DECLSPEC_HIDDEN
;
2719 const struct ffp_frag_desc
*find_ffp_frag_shader(const struct wine_rb_tree
*fragment_shaders
,
2720 const struct ffp_frag_settings
*settings
) DECLSPEC_HIDDEN
;
2721 void add_ffp_frag_shader(struct wine_rb_tree
*shaders
, struct ffp_frag_desc
*desc
) DECLSPEC_HIDDEN
;
2722 void wined3d_ftoa(float value
, char *s
) DECLSPEC_HIDDEN
;
2724 enum wined3d_ffp_vs_fog_mode
2726 WINED3D_FFP_VS_FOG_OFF
= 0,
2727 WINED3D_FFP_VS_FOG_FOGCOORD
= 1,
2728 WINED3D_FFP_VS_FOG_DEPTH
= 2,
2729 WINED3D_FFP_VS_FOG_RANGE
= 3,
2732 #define WINED3D_FFP_TCI_SHIFT 16
2733 #define WINED3D_FFP_TCI_MASK 0xffu
2735 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
2736 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
2738 struct wined3d_ffp_vs_settings
2740 DWORD point_light_count
: 4;
2741 DWORD spot_light_count
: 4;
2742 DWORD directional_light_count
: 4;
2743 DWORD parallel_point_light_count
: 4;
2744 DWORD diffuse_source
: 2;
2745 DWORD emissive_source
: 2;
2746 DWORD ambient_source
: 2;
2747 DWORD specular_source
: 2;
2748 DWORD transformed
: 1;
2749 DWORD vertexblends
: 2;
2752 DWORD normalize
: 1;
2754 DWORD localviewer
: 1;
2756 DWORD point_size
: 1;
2757 DWORD per_vertex_point_size
: 1;
2759 DWORD texcoords
: 8; /* WINED3D_MAX_FFP_TEXTURES */
2760 DWORD ortho_fog
: 1;
2761 DWORD flatshading
: 1;
2764 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
2766 unsigned int texgen
[WINED3D_MAX_FFP_TEXTURES
];
2769 struct wined3d_ffp_vs_desc
2771 struct wine_rb_entry entry
;
2772 struct wined3d_ffp_vs_settings settings
;
2775 void wined3d_ffp_get_vs_settings(const struct wined3d_context
*context
,
2776 const struct wined3d_state
*state
, struct wined3d_ffp_vs_settings
*settings
) DECLSPEC_HIDDEN
;
2782 unsigned int adapter_count
;
2783 struct wined3d_adapter
*adapters
[1];
2786 BOOL
wined3d_filter_messages(HWND window
, BOOL filter
) DECLSPEC_HIDDEN
;
2787 HRESULT
wined3d_init(struct wined3d
*wined3d
, uint32_t flags
) DECLSPEC_HIDDEN
;
2788 void wined3d_unregister_window(HWND window
) DECLSPEC_HIDDEN
;
2790 BOOL
wined3d_get_app_name(char *app_name
, unsigned int app_name_size
) DECLSPEC_HIDDEN
;
2792 enum wined3d_push_constants
2794 WINED3D_PUSH_CONSTANTS_VS_F
,
2795 WINED3D_PUSH_CONSTANTS_PS_F
,
2796 WINED3D_PUSH_CONSTANTS_VS_I
,
2797 WINED3D_PUSH_CONSTANTS_PS_I
,
2798 WINED3D_PUSH_CONSTANTS_VS_B
,
2799 WINED3D_PUSH_CONSTANTS_PS_B
,
2800 WINED3D_PUSH_CONSTANTS_COUNT
,
2803 struct wined3d_blend_state
2806 struct wined3d_blend_state_desc desc
;
2810 const struct wined3d_parent_ops
*parent_ops
;
2812 struct wined3d_device
*device
;
2813 struct wine_rb_entry entry
;
2816 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state
*state
,
2821 if (!state
->desc
.independent
)
2823 return state
->desc
.rt
[index
].writemask
;
2826 struct wined3d_depth_stencil_state
2829 struct wined3d_depth_stencil_state_desc desc
;
2834 const struct wined3d_parent_ops
*parent_ops
;
2836 struct wined3d_device
*device
;
2837 struct wine_rb_entry entry
;
2840 struct wined3d_rasterizer_state
2843 struct wined3d_rasterizer_state_desc desc
;
2846 const struct wined3d_parent_ops
*parent_ops
;
2848 struct wined3d_device
*device
;
2849 struct wine_rb_entry entry
;
2852 struct wined3d_light_state
2854 struct rb_tree lights_tree
;
2855 const struct wined3d_light_info
*lights
[WINED3D_MAX_ACTIVE_LIGHTS
];
2858 #define WINED3D_STATE_NO_REF 0x00000001
2859 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
2861 struct wined3d_state
2863 enum wined3d_feature_level feature_level
;
2865 struct wined3d_fb_state fb
;
2867 struct wined3d_vertex_declaration
*vertex_declaration
;
2868 struct wined3d_stream_output stream_output
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
2869 struct wined3d_stream_state streams
[WINED3D_MAX_STREAMS
];
2870 struct wined3d_buffer
*index_buffer
;
2871 enum wined3d_format_id index_format
;
2872 unsigned int index_offset
;
2873 int base_vertex_index
;
2874 int load_base_vertex_index
; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
2875 enum wined3d_primitive_type primitive_type
;
2876 unsigned int patch_vertex_count
;
2877 struct wined3d_query
*predicate
;
2878 BOOL predicate_value
;
2880 struct wined3d_shader
*shader
[WINED3D_SHADER_TYPE_COUNT
];
2881 struct wined3d_constant_buffer_state cb
[WINED3D_SHADER_TYPE_COUNT
][MAX_CONSTANT_BUFFERS
];
2882 struct wined3d_sampler
*sampler
[WINED3D_SHADER_TYPE_COUNT
][MAX_SAMPLER_OBJECTS
];
2883 struct wined3d_shader_resource_view
*shader_resource_view
[WINED3D_SHADER_TYPE_COUNT
][MAX_SHADER_RESOURCE_VIEWS
];
2884 struct wined3d_unordered_access_view
*unordered_access_view
[WINED3D_PIPELINE_COUNT
][MAX_UNORDERED_ACCESS_VIEWS
];
2886 struct wined3d_texture
*textures
[WINED3D_MAX_COMBINED_SAMPLERS
];
2887 uint32_t sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
2888 uint32_t texture_states
[WINED3D_MAX_FFP_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
2890 struct wined3d_matrix transforms
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
2891 struct wined3d_vec4 clip_planes
[WINED3D_MAX_CLIP_DISTANCES
];
2892 struct wined3d_material material
;
2893 struct wined3d_viewport viewports
[WINED3D_MAX_VIEWPORTS
];
2894 unsigned int viewport_count
;
2895 RECT scissor_rects
[WINED3D_MAX_VIEWPORTS
];
2896 unsigned int scissor_rect_count
;
2898 struct wined3d_light_state light_state
;
2900 unsigned int render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
2901 struct wined3d_blend_state
*blend_state
;
2902 struct wined3d_color blend_factor
;
2903 unsigned int sample_mask
;
2904 struct wined3d_depth_stencil_state
*depth_stencil_state
;
2905 unsigned int stencil_ref
;
2906 bool depth_bounds_enable
;
2907 float depth_bounds_min
, depth_bounds_max
;
2908 struct wined3d_rasterizer_state
*rasterizer_state
;
2911 void state_cleanup(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2912 void state_init(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
2913 uint32_t flags
, enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
2914 void state_unbind_resources(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2916 static inline void wined3d_state_reset(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
)
2918 enum wined3d_feature_level feature_level
= state
->feature_level
;
2919 uint32_t flags
= state
->flags
;
2921 memset(state
, 0, sizeof(*state
));
2922 state_init(state
, d3d_info
, flags
, feature_level
);
2925 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state
*state
)
2927 if (!state
->depth_stencil_state
)
2929 return state
->depth_stencil_state
->desc
.depth
|| state
->depth_stencil_state
->desc
.depth_write
2930 || state
->depth_stencil_state
->desc
.stencil
;
2933 #define WINED3D_UNMAPPED_STAGE ~0u
2935 /* Multithreaded flag. Removed from the public header to signal that
2936 * wined3d_device_create() ignores it. */
2937 #define WINED3DCREATE_MULTITHREADED 0x00000004
2939 struct wined3d_so_desc_entry
2941 struct wine_rb_entry entry
;
2942 struct wined3d_stream_output_desc desc
;
2943 struct wined3d_stream_output_element elements
[1];
2946 struct wined3d_device
2950 /* WineD3D Information */
2951 struct wined3d_device_parent
*device_parent
;
2952 struct wined3d
*wined3d
;
2953 struct wined3d_adapter
*adapter
;
2955 const struct wined3d_shader_backend_ops
*shader_backend
;
2957 void *fragment_priv
;
2959 struct wined3d_state_entry state_table
[STATE_HIGHEST
+ 1];
2960 /* Array of functions for states which are handled by more than one pipeline part */
2961 APPLYSTATEFUNC
*multistate_funcs
[STATE_HIGHEST
+ 1];
2962 struct wined3d_blitter
*blitter
;
2964 BYTE bCursorVisible
: 1;
2965 BYTE d3d_initialized
: 1;
2966 BYTE inScene
: 1; /* A flag to check for proper BeginScene / EndScene call pairs */
2967 BYTE softwareVertexProcessing
: 1; /* process vertex shaders using software or hardware */
2968 BYTE restore_screensaver
: 1;
2971 unsigned char surface_alignment
; /* Line Alignment of surfaces */
2975 /* Internal use fields */
2976 struct wined3d_device_creation_parameters create_parms
;
2979 struct wined3d_rendertarget_view
*back_buffer_view
;
2980 struct wined3d_swapchain
**swapchains
;
2981 UINT swapchain_count
;
2982 unsigned int max_frame_latency
;
2984 struct list resources
; /* a linked list to track resources created by the device */
2985 struct list shaders
; /* a linked list to track shaders (pixel and vertex) */
2986 struct wine_rb_tree so_descs
;
2987 struct wine_rb_tree samplers
, rasterizer_states
, blend_states
, depth_stencil_states
;
2989 /* Render Target Support */
2990 struct wined3d_rendertarget_view
*auto_depth_stencil_view
;
2992 /* Cursor management */
2997 UINT cursorWidth
, cursorHeight
;
2998 struct wined3d_texture
*cursor_texture
;
2999 HCURSOR hardwareCursor
;
3001 /* The Wine logo texture */
3002 struct wined3d_texture
*logo_texture
;
3004 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3005 struct wined3d_sampler
*default_sampler
;
3006 struct wined3d_sampler
*null_sampler
;
3008 /* Command stream */
3009 struct wined3d_cs
*cs
;
3011 struct wined3d_buffer
*push_constants
[WINED3D_PUSH_CONSTANTS_COUNT
];
3013 /* Context management */
3014 struct wined3d_context
**contexts
;
3017 CRITICAL_SECTION bo_map_lock
;
3020 void wined3d_device_cleanup(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3021 BOOL
device_context_add(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3022 void device_context_remove(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3023 void wined3d_device_create_default_samplers(struct wined3d_device
*device
,
3024 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3025 void wined3d_device_destroy_default_samplers(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3026 HRESULT
wined3d_device_init(struct wined3d_device
*device
, struct wined3d
*wined3d
,
3027 unsigned int adapter_idx
, enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
3028 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
3029 const BOOL
*supported_extensions
, struct wined3d_device_parent
*device_parent
) DECLSPEC_HIDDEN
;
3030 LRESULT
device_process_message(struct wined3d_device
*device
, HWND window
, BOOL unicode
,
3031 UINT message
, WPARAM wparam
, LPARAM lparam
, WNDPROC proc
) DECLSPEC_HIDDEN
;
3032 void device_resource_add(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3033 void device_resource_released(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3034 void device_invalidate_state(const struct wined3d_device
*device
, unsigned int state
) DECLSPEC_HIDDEN
;
3035 HRESULT
wined3d_device_set_implicit_swapchain(struct wined3d_device
*device
,
3036 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3037 void wined3d_device_uninit_3d(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3039 static inline void wined3d_device_bo_map_lock(struct wined3d_device
*device
)
3041 EnterCriticalSection(&device
->bo_map_lock
);
3044 static inline void wined3d_device_bo_map_unlock(struct wined3d_device
*device
)
3046 LeaveCriticalSection(&device
->bo_map_lock
);
3049 struct wined3d_device_no3d
3051 struct wined3d_device d
;
3053 struct wined3d_context context_no3d
;
3056 static inline struct wined3d_device_no3d
*wined3d_device_no3d(struct wined3d_device
*device
)
3058 return CONTAINING_RECORD(device
, struct wined3d_device_no3d
, d
);
3061 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
3062 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
3063 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
3064 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
3065 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
3067 struct wined3d_allocator_chunk
3070 struct list available
[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT
];
3071 struct wined3d_allocator
*allocator
;
3072 unsigned int map_count
;
3076 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk
*chunk
) DECLSPEC_HIDDEN
;
3077 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk
*chunk
,
3078 struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3080 struct wined3d_allocator_block
3083 struct wined3d_allocator_chunk
*chunk
;
3084 struct wined3d_allocator_block
*parent
, *sibling
;
3090 void wined3d_allocator_block_free(struct wined3d_allocator_block
*block
) DECLSPEC_HIDDEN
;
3092 struct wined3d_allocator_pool
3097 struct wined3d_allocator_ops
3099 struct wined3d_allocator_chunk
*(*allocator_create_chunk
)(struct wined3d_allocator
*allocator
,
3100 struct wined3d_context
*context
, unsigned int memory_type
, size_t chunk_size
);
3101 void (*allocator_destroy_chunk
)(struct wined3d_allocator_chunk
*chunk
);
3104 struct wined3d_allocator
3106 const struct wined3d_allocator_ops
*ops
;
3107 struct wined3d_allocator_pool
*pools
;
3109 struct wined3d_allocator_block
*free
;
3112 struct wined3d_allocator_block
*wined3d_allocator_allocate(struct wined3d_allocator
*allocator
,
3113 struct wined3d_context
*context
, unsigned int memory_type
, size_t size
) DECLSPEC_HIDDEN
;
3114 void wined3d_allocator_cleanup(struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3115 bool wined3d_allocator_init(struct wined3d_allocator
*allocator
,
3116 size_t pool_count
, const struct wined3d_allocator_ops
*allocator_ops
) DECLSPEC_HIDDEN
;
3118 static inline float wined3d_alpha_ref(const struct wined3d_state
*state
)
3120 return (state
->render_states
[WINED3D_RS_ALPHAREF
] & 0xff) / 255.0f
;
3123 const char *wined3d_debug_resource_access(uint32_t access
) DECLSPEC_HIDDEN
;
3124 const char *wined3d_debug_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
3125 const char *wined3d_debug_view_desc(const struct wined3d_view_desc
*d
,
3126 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3128 static inline ULONG
wined3d_atomic_decrement_mutex_lock(volatile LONG
*refcount
)
3130 ULONG count
, old_count
= *refcount
;
3133 if ((count
= old_count
) == 1)
3135 wined3d_mutex_lock();
3136 count
= InterlockedDecrement(refcount
);
3137 if (count
) wined3d_mutex_unlock();
3141 old_count
= InterlockedCompareExchange(refcount
, count
- 1, count
);
3143 while (old_count
!= count
);
3148 #define CLIENT_BO_DISCARDED ((struct wined3d_bo *)~(UINT_PTR)0)
3150 struct wined3d_client_resource
3152 /* The resource's persistently mapped address, which we may use to perform
3153 * NOOVERWRITE maps from the client thread. */
3154 struct wined3d_bo_address addr
;
3156 /* The currently mapped upload BO, if applicable, and box. */
3157 struct upload_bo mapped_upload
;
3158 struct wined3d_box mapped_box
;
3161 static inline BOOL
wined3d_resource_access_is_managed(unsigned int access
)
3163 return !(~access
& (WINED3D_RESOURCE_ACCESS_GPU
| WINED3D_RESOURCE_ACCESS_CPU
));
3166 struct wined3d_resource_ops
3168 ULONG (*resource_incref
)(struct wined3d_resource
*resource
);
3169 ULONG (*resource_decref
)(struct wined3d_resource
*resource
);
3170 void (*resource_preload
)(struct wined3d_resource
*resource
);
3171 void (*resource_unload
)(struct wined3d_resource
*resource
);
3172 HRESULT (*resource_sub_resource_get_desc
)(struct wined3d_resource
*resource
,
3173 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
);
3174 void (*resource_sub_resource_get_map_pitch
)(struct wined3d_resource
*resource
,
3175 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
);
3176 HRESULT (*resource_sub_resource_map
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3177 void **map_ptr
, const struct wined3d_box
*box
, uint32_t flags
);
3178 HRESULT (*resource_sub_resource_unmap
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
);
3181 struct wined3d_resource
3187 struct wined3d_device
*device
;
3188 enum wined3d_resource_type type
;
3189 enum wined3d_gl_resource_type gl_type
;
3190 const struct wined3d_format
*format
;
3191 unsigned int format_attrs
;
3192 unsigned int format_caps
;
3193 enum wined3d_multisample_type multisample_type
;
3194 UINT multisample_quality
;
3196 unsigned int bind_flags
;
3197 unsigned int access
;
3204 unsigned int priority
;
3207 uint32_t pin_sysmem
: 1;
3209 struct wined3d_client_resource client
;
3212 const struct wined3d_parent_ops
*parent_ops
;
3213 const struct wined3d_resource_ops
*resource_ops
;
3215 struct list resource_list_entry
;
3217 LONG srv_bind_count_device
;
3218 LONG rtv_bind_count_device
;
3221 static inline ULONG
wined3d_resource_incref(struct wined3d_resource
*resource
)
3223 return resource
->resource_ops
->resource_incref(resource
);
3226 static inline ULONG
wined3d_resource_decref(struct wined3d_resource
*resource
)
3228 return resource
->resource_ops
->resource_decref(resource
);
3231 static inline HRESULT
wined3d_resource_get_sub_resource_desc(struct wined3d_resource
*resource
,
3232 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
)
3234 return resource
->resource_ops
->resource_sub_resource_get_desc(resource
, sub_resource_idx
, desc
);
3237 static inline void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource
*resource
,
3238 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
)
3240 resource
->resource_ops
->resource_sub_resource_get_map_pitch(resource
, sub_resource_idx
, row_pitch
, slice_pitch
);
3243 void resource_cleanup(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3244 HRESULT
resource_init(struct wined3d_resource
*resource
, struct wined3d_device
*device
,
3245 enum wined3d_resource_type type
, const struct wined3d_format
*format
,
3246 enum wined3d_multisample_type multisample_type
, unsigned int multisample_quality
, unsigned int usage
,
3247 unsigned int bind_flags
, unsigned int access
, unsigned int width
, unsigned int height
, unsigned int depth
,
3248 unsigned int size
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3249 const struct wined3d_resource_ops
*resource_ops
) DECLSPEC_HIDDEN
;
3250 void *resource_offset_map_pointer(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3251 uint8_t *base_memory
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3252 void resource_unload(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3253 HRESULT
wined3d_resource_check_box_dimensions(struct wined3d_resource
*resource
,
3254 unsigned int sub_resource_idx
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3255 void wined3d_resource_free_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3256 const struct wined3d_format
*wined3d_resource_get_decompress_format(
3257 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3258 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3259 BOOL
wined3d_resource_is_offscreen(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3260 BOOL
wined3d_resource_prepare_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3261 void wined3d_resource_update_draw_binding(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3262 void wined3d_resource_memory_colour_fill(struct wined3d_resource
*resource
,
3263 const struct wined3d_map_desc
*map
, const struct wined3d_color
*colour
,
3264 const struct wined3d_box
*box
, bool full_subresource
) DECLSPEC_HIDDEN
;
3266 /* Tests show that the start address of resources is 32 byte aligned */
3267 #define RESOURCE_ALIGNMENT 16
3268 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3270 #define WINED3D_LOCATION_DISCARDED 0x00000001
3271 #define WINED3D_LOCATION_SYSMEM 0x00000002
3272 #define WINED3D_LOCATION_CLEARED 0x00000004
3273 #define WINED3D_LOCATION_BUFFER 0x00000008
3274 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3275 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3276 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3277 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3278 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3280 const char *wined3d_debug_location(uint32_t location
) DECLSPEC_HIDDEN
;
3282 struct wined3d_texture_ops
3284 BOOL (*texture_prepare_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3285 struct wined3d_context
*context
, unsigned int location
);
3286 BOOL (*texture_load_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3287 struct wined3d_context
*context
, unsigned int location
);
3288 void (*texture_unload_location
)(struct wined3d_texture
*texture
,
3289 struct wined3d_context
*context
, unsigned int location
);
3290 void (*texture_upload_data
)(struct wined3d_context
*context
, const struct wined3d_const_bo_address
*src_bo_addr
,
3291 const struct wined3d_format
*src_format
, const struct wined3d_box
*src_box
, unsigned int src_row_pitch
,
3292 unsigned int src_slice_pitch
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3293 unsigned int dst_location
, unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
);
3294 void (*texture_download_data
)(struct wined3d_context
*context
, struct wined3d_texture
*src_texture
,
3295 unsigned int src_sub_resource_idx
, unsigned int src_location
, const struct wined3d_box
*src_box
,
3296 const struct wined3d_bo_address
*dst_bo_addr
, const struct wined3d_format
*dst_format
,
3297 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
,
3298 unsigned int dst_row_pitch
, unsigned int dst_slice_pitch
);
3301 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3302 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3303 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3304 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3305 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3306 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3307 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3308 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3309 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3310 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3311 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3312 #define WINED3D_TEXTURE_DISCARD 0x00002000
3313 #define WINED3D_TEXTURE_GET_DC 0x00004000
3314 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3315 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3317 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3319 struct wined3d_texture
3321 struct wined3d_resource resource
;
3322 const struct wined3d_texture_ops
*texture_ops
;
3323 struct wined3d_swapchain
*swapchain
;
3324 unsigned int pow2_width
;
3325 unsigned int pow2_height
;
3327 unsigned int level_count
;
3328 unsigned int download_count
;
3329 unsigned int sysmem_count
;
3330 float pow2_matrix
[16];
3334 DWORD update_map_binding
;
3336 unsigned int row_pitch
;
3337 unsigned int slice_pitch
;
3339 /* May only be accessed from the command stream worker thread. */
3340 struct wined3d_texture_async
3344 /* Color keys for DDraw */
3345 struct wined3d_color_key dst_blt_color_key
;
3346 struct wined3d_color_key src_blt_color_key
;
3347 struct wined3d_color_key dst_overlay_color_key
;
3348 struct wined3d_color_key src_overlay_color_key
;
3349 struct wined3d_color_key gl_color_key
;
3350 DWORD color_key_flags
;
3353 struct wined3d_dirty_regions
3355 struct wined3d_box
*boxes
;
3357 unsigned int box_count
;
3360 struct wined3d_overlay_info
3363 struct list overlays
;
3364 struct wined3d_texture
*dst_texture
;
3365 unsigned int dst_sub_resource_idx
;
3370 struct wined3d_dc_info
3376 struct wined3d_texture_sub_resource
3379 const struct wined3d_parent_ops
*parent_ops
;
3381 unsigned int offset
;
3384 unsigned int map_count
;
3387 struct wined3d_bo
*bo
;
3390 struct wined3d_color colour
;
3394 unsigned int stencil
;
3402 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s
, SIZE_T level_count
, SIZE_T layer_count
)
3404 struct wined3d_texture
*t
;
3406 if (level_count
> ((~(SIZE_T
)0 - s
) / sizeof(*t
->sub_resources
)) / layer_count
)
3409 return heap_alloc_zero(s
+ level_count
* layer_count
* sizeof(*t
->sub_resources
));
3412 static inline struct wined3d_texture
*texture_from_resource(struct wined3d_resource
*resource
)
3414 return CONTAINING_RECORD(resource
, struct wined3d_texture
, resource
);
3417 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture
*texture
,
3420 return max(1, texture
->resource
.width
>> level
);
3423 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture
*texture
,
3426 return max(1, texture
->resource
.height
>> level
);
3429 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture
*texture
,
3432 return max(1, texture
->resource
.depth
>> level
);
3435 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture
*texture
,
3438 return max(1, texture
->pow2_width
>> level
);
3441 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture
*texture
,
3444 return max(1, texture
->pow2_height
>> level
);
3447 static inline void wined3d_texture_get_level_box(const struct wined3d_texture
*texture
,
3448 unsigned int level
, struct wined3d_box
*box
)
3450 wined3d_box_set(box
, 0, 0,
3451 wined3d_texture_get_level_width(texture
, level
),
3452 wined3d_texture_get_level_height(texture
, level
),
3453 0, wined3d_texture_get_level_depth(texture
, level
));
3456 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture
*texture
,
3457 unsigned int level
, const RECT
*r
)
3461 t
= wined3d_texture_get_level_width(texture
, level
);
3462 if ((r
->left
&& r
->right
) || abs(r
->right
- r
->left
) != t
)
3464 t
= wined3d_texture_get_level_height(texture
, level
);
3465 if ((r
->top
&& r
->bottom
) || abs(r
->bottom
- r
->top
) != t
)
3470 HRESULT
texture2d_blt(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3471 const struct wined3d_box
*dst_box
, struct wined3d_texture
*src_texture
,
3472 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
, uint32_t flags
,
3473 const struct wined3d_blt_fx
*blt_fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
3475 void wined3d_texture_cleanup(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3476 void wined3d_texture_download_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3477 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
) DECLSPEC_HIDDEN
;
3478 void wined3d_texture_get_bo_address(const struct wined3d_texture
*texture
,
3479 unsigned int sub_resource_idx
, struct wined3d_bo_address
*data
, uint32_t location
) DECLSPEC_HIDDEN
;
3480 void wined3d_texture_invalidate_location(struct wined3d_texture
*texture
,
3481 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
3482 void wined3d_texture_load(struct wined3d_texture
*texture
,
3483 struct wined3d_context
*context
, BOOL srgb
) DECLSPEC_HIDDEN
;
3484 BOOL
wined3d_texture_load_location(struct wined3d_texture
*texture
,
3485 unsigned int sub_resource_idx
, struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3486 BOOL
wined3d_texture_prepare_location(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3487 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3488 void wined3d_texture_set_swapchain(struct wined3d_texture
*texture
,
3489 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3490 BOOL
wined3d_texture_can_use_pbo(const struct wined3d_texture
*texture
, const struct wined3d_d3d_info
*d3d_info
)
3492 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3493 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture
*texture
,
3494 HWND window
, RECT
*rect
) DECLSPEC_HIDDEN
;
3495 void wined3d_texture_update_sub_resource(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3496 struct wined3d_context
*context
, const struct upload_bo
*upload_bo
, const struct wined3d_box
*box
,
3497 unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
3498 void wined3d_texture_upload_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3499 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
, struct wined3d_texture
*src_texture
,
3500 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
) DECLSPEC_HIDDEN
;
3501 void wined3d_texture_validate_location(struct wined3d_texture
*texture
,
3502 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
3503 bool wined3d_texture_validate_sub_resource_idx(const struct wined3d_texture
*texture
,
3504 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
3505 void wined3d_texture_clear_dirty_regions(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3507 HRESULT
wined3d_texture_no3d_init(struct wined3d_texture
*texture_no3d
, struct wined3d_device
*device
,
3508 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
3509 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3511 struct wined3d_sampler
3513 struct wine_rb_entry entry
;
3515 struct wined3d_device
*device
;
3517 const struct wined3d_parent_ops
*parent_ops
;
3518 struct wined3d_sampler_desc desc
;
3521 struct wined3d_vertex_declaration_element
3523 const struct wined3d_format
*format
;
3525 unsigned int input_slot
;
3526 unsigned int offset
;
3527 unsigned int output_slot
;
3528 enum wined3d_input_classification input_slot_class
;
3529 unsigned int instance_data_step_rate
;
3535 struct wined3d_vertex_declaration
3539 const struct wined3d_parent_ops
*parent_ops
;
3540 struct wined3d_device
*device
;
3542 struct wined3d_vertex_declaration_element
*elements
;
3543 unsigned int element_count
;
3545 BOOL position_transformed
;
3548 bool wined3d_light_state_enable_light(struct wined3d_light_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
3549 struct wined3d_light_info
*light_info
, BOOL enable
) DECLSPEC_HIDDEN
;
3550 struct wined3d_light_info
*wined3d_light_state_get_light(const struct wined3d_light_state
*state
,
3551 unsigned int idx
) DECLSPEC_HIDDEN
;
3552 HRESULT
wined3d_light_state_set_light(struct wined3d_light_state
*state
, DWORD light_idx
,
3553 const struct wined3d_light
*params
, struct wined3d_light_info
**light_info
) DECLSPEC_HIDDEN
;
3555 enum wined3d_cs_queue_id
3557 WINED3D_CS_QUEUE_DEFAULT
= 0,
3558 WINED3D_CS_QUEUE_MAP
,
3559 WINED3D_CS_QUEUE_COUNT
,
3562 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
3564 #define WINED3D_CS_QUEUE_SIZE 0x1000000u
3566 #define WINED3D_CS_QUEUE_SIZE 0x400000u
3568 #define WINED3D_CS_SPIN_COUNT 2000u
3569 #define WINED3D_CS_QUEUE_MASK (WINED3D_CS_QUEUE_SIZE - 1)
3571 C_ASSERT(!(WINED3D_CS_QUEUE_SIZE
& (WINED3D_CS_QUEUE_SIZE
- 1)));
3573 struct wined3d_cs_queue
3576 BYTE data
[WINED3D_CS_QUEUE_SIZE
];
3579 struct wined3d_device_context_ops
3581 void *(*require_space
)(struct wined3d_device_context
*context
, size_t size
, enum wined3d_cs_queue_id queue_id
);
3582 void (*submit
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
3583 void (*finish
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
3584 bool (*map_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
3585 unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
3586 const struct wined3d_box
*box
, uint32_t flags
);
3587 bool (*unmap_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
3588 unsigned int sub_resource_idx
, struct wined3d_box
*box
, struct upload_bo
*upload_bo
);
3589 void (*issue_query
)(struct wined3d_device_context
*context
, struct wined3d_query
*query
, unsigned int flags
);
3590 void (*flush
)(struct wined3d_device_context
*context
);
3591 void (*reference_resource
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
);
3592 void (*reference_command_list
)(struct wined3d_device_context
*context
, struct wined3d_command_list
*list
);
3595 struct wined3d_device_context
3597 const struct wined3d_device_context_ops
*ops
;
3598 struct wined3d_device
*device
;
3599 struct wined3d_state
*state
;
3604 struct wined3d_device_context c
;
3606 struct wined3d_state state
;
3607 HMODULE wined3d_module
;
3610 BOOL serialize_commands
;
3612 struct wined3d_cs_queue queue
[WINED3D_CS_QUEUE_COUNT
];
3613 size_t data_size
, start
, end
;
3615 struct list query_poll_list
;
3616 BOOL queries_flushed
;
3618 HANDLE event
, present_event
;
3619 LONG waiting_for_event
;
3620 LONG waiting_for_present
;
3621 LONG pending_presents
;
3624 static inline void wined3d_device_context_lock(struct wined3d_device_context
*context
)
3626 if (context
== &context
->device
->cs
->c
)
3627 wined3d_mutex_lock();
3630 static inline void wined3d_device_context_unlock(struct wined3d_device_context
*context
)
3632 if (context
== &context
->device
->cs
->c
)
3633 wined3d_mutex_unlock();
3636 struct wined3d_cs
*wined3d_cs_create(struct wined3d_device
*device
,
3637 const enum wined3d_feature_level
*levels
, unsigned int level_count
) DECLSPEC_HIDDEN
;
3638 void wined3d_cs_destroy(struct wined3d_cs
*cs
) DECLSPEC_HIDDEN
;
3639 void wined3d_cs_destroy_object(struct wined3d_cs
*cs
,
3640 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
3641 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs
*cs
,
3642 struct wined3d_texture
*texture
, unsigned int layer
) DECLSPEC_HIDDEN
;
3643 void wined3d_cs_emit_clear(struct wined3d_cs
*cs
, DWORD rect_count
, const RECT
*rects
,
3644 uint32_t flags
, const struct wined3d_color
*color
, float depth
, DWORD stencil
) DECLSPEC_HIDDEN
;
3645 void wined3d_device_context_emit_clear_uav(struct wined3d_device_context
*context
,
3646 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
) DECLSPEC_HIDDEN
;
3647 void wined3d_cs_emit_preload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3648 void wined3d_cs_emit_present(struct wined3d_cs
*cs
, struct wined3d_swapchain
*swapchain
, const RECT
*src_rect
,
3649 const RECT
*dst_rect
, HWND dst_window_override
, unsigned int swap_interval
, uint32_t flags
) DECLSPEC_HIDDEN
;
3650 void wined3d_cs_emit_set_color_key(struct wined3d_cs
*cs
, struct wined3d_texture
*texture
,
3651 WORD flags
, const struct wined3d_color_key
*color_key
) DECLSPEC_HIDDEN
;
3652 void wined3d_cs_emit_set_render_state(struct wined3d_cs
*cs
,
3653 enum wined3d_render_state state
, DWORD value
) DECLSPEC_HIDDEN
;
3654 void wined3d_cs_emit_unload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3655 void wined3d_cs_init_object(struct wined3d_cs
*cs
,
3656 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
3657 void wined3d_cs_map_bo_address(struct wined3d_cs
*cs
,
3658 struct wined3d_bo_address
*addr
, size_t size
, unsigned int flags
) DECLSPEC_HIDDEN
;
3659 void wined3d_device_context_set_depth_bounds(struct wined3d_device_context
*context
,
3660 bool enable
, float min_depth
, float max_depth
);
3662 static inline void wined3d_cs_finish(struct wined3d_cs
*cs
, enum wined3d_cs_queue_id queue_id
)
3664 cs
->c
.ops
->finish(&cs
->c
, queue_id
);
3667 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
*context
,
3668 struct wined3d_resource
*dst_resource
, unsigned int dst_sub_resource_idx
, const struct wined3d_box
*dst_box
,
3669 struct wined3d_resource
*src_resource
, unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
,
3670 unsigned int flags
, const struct wined3d_blt_fx
*fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
3671 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context
*context
,
3672 struct wined3d_rendertarget_view
*view
, const RECT
*rect
, unsigned int flags
,
3673 const struct wined3d_color
*color
, float depth
, unsigned int stencil
) DECLSPEC_HIDDEN
;
3674 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context
*context
,
3675 struct wined3d_buffer
*dst_buffer
, unsigned int offset
,
3676 struct wined3d_unordered_access_view
*uav
) DECLSPEC_HIDDEN
;
3677 void wined3d_device_context_emit_draw(struct wined3d_device_context
*context
,
3678 enum wined3d_primitive_type primitive_type
, unsigned int patch_vertex_count
, int base_vertex_idx
,
3679 unsigned int start_idx
, unsigned int index_count
, unsigned int start_instance
, unsigned int instance_count
,
3680 bool indexed
) DECLSPEC_HIDDEN
;
3681 void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context
*context
,
3682 struct wined3d_command_list
*list
, bool restore_state
) DECLSPEC_HIDDEN
;
3683 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context
*context
,
3684 struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
3685 HRESULT
wined3d_device_context_emit_map(struct wined3d_device_context
*context
,
3686 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
3687 const struct wined3d_box
*box
, unsigned int flags
) DECLSPEC_HIDDEN
;
3688 void wined3d_device_context_emit_reset_state(struct wined3d_device_context
*context
, bool invalidate
) DECLSPEC_HIDDEN
;
3689 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context
*context
,
3690 struct wined3d_blend_state
*state
, const struct wined3d_color
*blend_factor
,
3691 unsigned int sample_mask
) DECLSPEC_HIDDEN
;
3692 void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context
*context
, unsigned int plane_idx
,
3693 const struct wined3d_vec4
*plane
) DECLSPEC_HIDDEN
;
3694 void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context
*context
,
3695 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
3696 const struct wined3d_constant_buffer_state
*buffers
) DECLSPEC_HIDDEN
;
3697 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context
*context
,
3698 struct wined3d_depth_stencil_state
*state
, unsigned int stencil_ref
) DECLSPEC_HIDDEN
;
3699 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context
*context
,
3700 struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
3701 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context
*context
,
3702 enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
3703 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context
*context
, struct wined3d_buffer
*buffer
,
3704 enum wined3d_format_id format_id
, unsigned int offset
) DECLSPEC_HIDDEN
;
3705 void wined3d_device_context_emit_set_light(struct wined3d_device_context
*context
,
3706 const struct wined3d_light_info
*light
) DECLSPEC_HIDDEN
;
3707 void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context
*context
, unsigned int idx
,
3708 BOOL enable
) DECLSPEC_HIDDEN
;
3709 void wined3d_device_context_emit_set_material(struct wined3d_device_context
*context
,
3710 const struct wined3d_material
*material
) DECLSPEC_HIDDEN
;
3711 void wined3d_device_context_emit_set_predication(struct wined3d_device_context
*context
,
3712 struct wined3d_query
*predicate
, BOOL value
) DECLSPEC_HIDDEN
;
3713 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context
*context
,
3714 struct wined3d_rasterizer_state
*rasterizer_state
) DECLSPEC_HIDDEN
;
3715 void wined3d_device_context_emit_set_render_state(struct wined3d_device_context
*context
,
3716 enum wined3d_render_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
3717 void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context
*context
, unsigned int start_idx
,
3718 unsigned int count
, struct wined3d_rendertarget_view
*const *views
) DECLSPEC_HIDDEN
;
3719 void wined3d_device_context_emit_set_samplers(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
3720 unsigned int start_idx
, unsigned int count
, struct wined3d_sampler
*const *samplers
) DECLSPEC_HIDDEN
;
3721 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context
*context
, unsigned int sampler_idx
,
3722 enum wined3d_sampler_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
3723 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context
*context
,
3724 unsigned int rect_count
, const RECT
*rects
) DECLSPEC_HIDDEN
;
3725 void wined3d_device_context_emit_set_shader(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
3726 struct wined3d_shader
*shader
) DECLSPEC_HIDDEN
;
3727 void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context
*context
,
3728 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
3729 struct wined3d_shader_resource_view
*const *views
) DECLSPEC_HIDDEN
;
3730 void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context
*context
,
3731 const struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
]) DECLSPEC_HIDDEN
;
3732 void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context
*context
,
3733 unsigned int start_idx
, unsigned int count
, const struct wined3d_stream_state
*streams
) DECLSPEC_HIDDEN
;
3734 void wined3d_device_context_emit_set_texture(struct wined3d_device_context
*context
, unsigned int stage
,
3735 struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3736 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context
*context
, unsigned int stage
,
3737 enum wined3d_texture_stage_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
3738 void wined3d_device_context_emit_set_transform(struct wined3d_device_context
*context
,
3739 enum wined3d_transform_state state
, const struct wined3d_matrix
*matrix
) DECLSPEC_HIDDEN
;
3740 void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context
*context
,
3741 enum wined3d_pipeline pipeline
, unsigned int start_idx
, unsigned int count
,
3742 struct wined3d_unordered_access_view
*const *views
, const unsigned int *initial_count
) DECLSPEC_HIDDEN
;
3743 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context
*context
,
3744 struct wined3d_vertex_declaration
*declaration
) DECLSPEC_HIDDEN
;
3745 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context
*context
, unsigned int viewport_count
,
3746 const struct wined3d_viewport
*viewports
) DECLSPEC_HIDDEN
;
3747 void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context
*context
,
3748 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, const struct wined3d_box
*box
,
3749 const void *data
, unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
3750 HRESULT
wined3d_device_context_emit_unmap(struct wined3d_device_context
*context
,
3751 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
3752 void wined3d_device_context_push_constants(struct wined3d_device_context
*context
,
3753 enum wined3d_push_constants type
, unsigned int start_idx
,
3754 unsigned int count
, const void *constants
) DECLSPEC_HIDDEN
;
3756 static inline void wined3d_resource_reference(struct wined3d_resource
*resource
)
3758 const struct wined3d_cs
*cs
= resource
->device
->cs
;
3759 resource
->access_time
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
3762 static inline BOOL
wined3d_ge_wrap(ULONG x
, ULONG y
)
3764 return (x
- y
) < UINT_MAX
/ 2;
3766 C_ASSERT(WINED3D_CS_QUEUE_SIZE
< UINT_MAX
/ 4);
3768 static inline void wined3d_resource_wait_idle(const struct wined3d_resource
*resource
)
3770 const struct wined3d_cs
*cs
= resource
->device
->cs
;
3771 ULONG access_time
, tail
, head
;
3773 if (!cs
->thread
|| cs
->thread_id
== GetCurrentThreadId())
3776 access_time
= resource
->access_time
;
3777 head
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
3779 /* The basic idea is that a resource is busy if tail < access_time <= head.
3780 * But we have to be careful about wrap-around of the head and tail. The
3781 * wined3d_ge_wrap function considers x >= y if x - y is smaller than half the
3782 * UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because
3783 * otherwise the queue memory is considered full and queue_require_space
3784 * stalls. Thus wined3d_ge_wrap(head, tail) is always true. The C_ASSERT above
3785 * ensures this in case we decide to grow the queue size in the future.
3787 * It is possible that a resource has not been used for a long time and is idle, but the head and
3788 * tail wrapped around in such a way that the previously set access time falls between head and tail.
3789 * In this case we will incorrectly wait for the resource. Because we use the entire 32 bits of the
3790 * counters and not just the bits needed to address the actual queue memory, this should happen rarely.
3791 * If it turns out to be a problem we can switch to 64 bit counters or attempt to somehow mark the
3792 * access time of resources invalid. CS packets are at least 4 byte aligned, so we could use the lower
3793 * 2 bits in access_time for such a marker.
3795 * Note that the access time is set before the command is submitted, so we have to wait until the
3796 * tail is bigger than access_time, not equal. */
3798 if (!wined3d_ge_wrap(head
, access_time
))
3803 tail
= *(volatile ULONG
*)&cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].tail
;
3804 if (head
== tail
) /* Queue empty. */
3807 if (!wined3d_ge_wrap(access_time
, tail
) && access_time
!= tail
)
3814 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
3815 * fixed function semantics as D3DCOLOR or FLOAT16 */
3816 enum wined3d_buffer_conversion_type
3823 struct wined3d_buffer
3825 struct wined3d_resource resource
;
3826 const struct wined3d_buffer_ops
*buffer_ops
;
3828 unsigned int structure_byte_stride
;
3832 struct wined3d_bo
*buffer_object
;
3833 struct wined3d_bo_user bo_user
;
3835 /* For buffers which are GPU accessible but for which BUFFER is not
3836 * currently a valid location, this is a list of areas that need to be
3837 * uploaded to BUFFER. */
3838 struct wined3d_range
*dirty_ranges
;
3839 SIZE_T dirty_range_count
, dirty_ranges_capacity
;
3841 /* conversion stuff */
3842 UINT decl_change_count
, full_conversion_count
;
3844 UINT stride
; /* 0 if no conversion */
3845 enum wined3d_buffer_conversion_type
*conversion_map
; /* NULL if no conversion */
3846 UINT conversion_stride
; /* 0 if no shifted conversion */
3849 static inline struct wined3d_buffer
*buffer_from_resource(struct wined3d_resource
*resource
)
3851 return CONTAINING_RECORD(resource
, struct wined3d_buffer
, resource
);
3854 static inline void wined3d_buffer_validate_user(struct wined3d_buffer
*buffer
)
3856 if (buffer
->bo_user
.valid
)
3858 buffer
->bo_user
.valid
= true;
3859 list_add_head(&buffer
->buffer_object
->users
, &buffer
->bo_user
.entry
);
3862 void wined3d_buffer_acquire_bo_for_write(struct wined3d_buffer
*buffer
,
3863 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3864 void wined3d_buffer_cleanup(struct wined3d_buffer
*buffer
) DECLSPEC_HIDDEN
;
3865 void wined3d_buffer_copy(struct wined3d_buffer
*dst_buffer
, unsigned int dst_offset
,
3866 struct wined3d_buffer
*src_buffer
, unsigned int src_offset
, unsigned int size
) DECLSPEC_HIDDEN
;
3867 void wined3d_buffer_copy_bo_address(struct wined3d_buffer
*dst_buffer
, struct wined3d_context
*context
,
3868 unsigned int dst_offset
, const struct wined3d_const_bo_address
*src_addr
, unsigned int size
) DECLSPEC_HIDDEN
;
3869 DWORD
wined3d_buffer_get_memory(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
3870 struct wined3d_bo_address
*data
) DECLSPEC_HIDDEN
;
3871 void wined3d_buffer_invalidate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
3872 void wined3d_buffer_load(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
3873 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3874 BOOL
wined3d_buffer_load_location(struct wined3d_buffer
*buffer
,
3875 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3876 void *wined3d_buffer_load_sysmem(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3877 BOOL
wined3d_buffer_prepare_location(struct wined3d_buffer
*buffer
,
3878 struct wined3d_context
*context
, unsigned int location
) DECLSPEC_HIDDEN
;
3879 void wined3d_buffer_update_sub_resource(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
3880 const struct upload_bo
*upload_bo
, unsigned int offset
, unsigned int size
) DECLSPEC_HIDDEN
;
3881 void wined3d_buffer_validate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
3883 HRESULT
wined3d_buffer_no3d_init(struct wined3d_buffer
*buffer_no3d
, struct wined3d_device
*device
,
3884 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
3885 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3887 struct wined3d_rendertarget_view
3891 struct wined3d_resource
*resource
;
3893 const struct wined3d_parent_ops
*parent_ops
;
3895 const struct wined3d_format
*format
;
3896 unsigned int format_attrs
;
3897 unsigned int format_caps
;
3898 unsigned int sub_resource_idx
;
3899 unsigned int layer_count
;
3902 unsigned int height
;
3904 struct wined3d_view_desc desc
;
3907 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
3908 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view
*view
,
3909 const struct wined3d_context
*context
, unsigned int *width
, unsigned int *height
) DECLSPEC_HIDDEN
;
3910 void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view
*view
,
3911 struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3912 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view
*view
,
3913 uint32_t location
) DECLSPEC_HIDDEN
;
3914 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view
*view
,
3915 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3916 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view
*view
,
3917 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3918 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view
*view
,
3919 uint32_t location
) DECLSPEC_HIDDEN
;
3920 DWORD
wined3d_rendertarget_view_get_locations(const struct wined3d_rendertarget_view
*view
)
3923 HRESULT
wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view
*view_no3d
,
3924 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
3925 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3927 struct wined3d_shader_resource_view
3931 struct wined3d_resource
*resource
;
3933 const struct wined3d_parent_ops
*parent_ops
;
3935 const struct wined3d_format
*format
;
3937 struct wined3d_view_desc desc
;
3940 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
3942 struct wined3d_unordered_access_view
3946 struct wined3d_resource
*resource
;
3948 const struct wined3d_parent_ops
*parent_ops
;
3950 const struct wined3d_format
*format
;
3952 struct wined3d_view_desc desc
;
3953 struct wined3d_bo
*counter_bo
;
3956 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view
*view
) DECLSPEC_HIDDEN
;
3957 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view
*view
,
3958 struct wined3d_buffer
*buffer
, unsigned int offset
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3959 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view
*view
,
3960 uint32_t location
) DECLSPEC_HIDDEN
;
3961 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view
*view
,
3962 unsigned int value
) DECLSPEC_HIDDEN
;
3964 struct wined3d_swapchain_state
3966 struct wined3d
*wined3d
;
3967 struct wined3d_swapchain_desc desc
;
3968 struct wined3d_swapchain_state_parent
*parent
;
3970 struct wined3d_display_mode original_mode
, d3d_mode
;
3971 RECT original_window_rect
;
3973 /* Window styles to restore when switching fullscreen mode. */
3979 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
3980 void wined3d_swapchain_state_register(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
3981 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state
*state
,
3982 HWND window
, const RECT
*window_rect
) DECLSPEC_HIDDEN
;
3983 HRESULT
wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
*state
,
3984 HWND window
, int x
, int y
, int width
, int height
) DECLSPEC_HIDDEN
;
3986 struct wined3d_swapchain_ops
3988 void (*swapchain_present
)(struct wined3d_swapchain
*swapchain
,
3989 const RECT
*src_rect
, const RECT
*dst_rect
, unsigned int swap_interval
, uint32_t flags
);
3990 void (*swapchain_frontbuffer_updated
)(struct wined3d_swapchain
*swapchain
);
3993 struct wined3d_swapchain
3997 const struct wined3d_parent_ops
*parent_ops
;
3998 const struct wined3d_swapchain_ops
*swapchain_ops
;
3999 struct wined3d_device
*device
;
4001 struct wined3d_texture
**back_buffers
;
4002 struct wined3d_texture
*front_buffer
;
4003 struct wined3d_gamma_ramp orig_gamma
;
4005 const struct wined3d_format
*ds_format
;
4006 struct wined3d_palette
*palette
;
4007 RECT front_buffer_update
;
4008 unsigned int swap_interval
;
4009 unsigned int max_frame_latency
;
4011 LONG prev_time
, frames
; /* Performance tracking */
4013 struct wined3d_swapchain_state state
;
4017 void wined3d_swapchain_activate(struct wined3d_swapchain
*swapchain
, BOOL activate
) DECLSPEC_HIDDEN
;
4018 void wined3d_swapchain_cleanup(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4019 struct wined3d_output
* wined3d_swapchain_get_output(const struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4020 void swapchain_update_draw_bindings(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4021 void swapchain_set_max_frame_latency(struct wined3d_swapchain
*swapchain
,
4022 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
4024 HRESULT
wined3d_swapchain_no3d_init(struct wined3d_swapchain
*swapchain_no3d
,
4025 struct wined3d_device
*device
, const struct wined3d_swapchain_desc
*desc
,
4026 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
4027 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4029 /*****************************************************************************
4030 * Utility function prototypes
4033 /* Trace routines */
4034 const char *debug_bo_address(const struct wined3d_bo_address
*address
) DECLSPEC_HIDDEN
;
4035 const char *debug_box(const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4036 const char *debug_color(const struct wined3d_color
*color
) DECLSPEC_HIDDEN
;
4037 const char *debug_const_bo_address(const struct wined3d_const_bo_address
*address
) DECLSPEC_HIDDEN
;
4038 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
) DECLSPEC_HIDDEN
;
4039 const char *debug_d3dformat(enum wined3d_format_id format_id
) DECLSPEC_HIDDEN
;
4040 const char *debug_d3ddevicetype(enum wined3d_device_type device_type
) DECLSPEC_HIDDEN
;
4041 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type
) DECLSPEC_HIDDEN
;
4042 const char *debug_d3dusage(uint32_t usage
) DECLSPEC_HIDDEN
;
4043 const char *debug_d3ddeclmethod(enum wined3d_decl_method method
) DECLSPEC_HIDDEN
;
4044 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
4045 const char *debug_d3dinput_classification(enum wined3d_input_classification classification
) DECLSPEC_HIDDEN
;
4046 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type
) DECLSPEC_HIDDEN
;
4047 const char *debug_d3drenderstate(enum wined3d_render_state state
) DECLSPEC_HIDDEN
;
4048 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state
) DECLSPEC_HIDDEN
;
4049 const char *debug_d3dstate(uint32_t state
) DECLSPEC_HIDDEN
;
4050 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type
) DECLSPEC_HIDDEN
;
4051 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state
) DECLSPEC_HIDDEN
;
4052 const char *debug_d3dtop(enum wined3d_texture_op d3dtop
) DECLSPEC_HIDDEN
;
4053 const char *debug_d3dtstype(enum wined3d_transform_state tstype
) DECLSPEC_HIDDEN
;
4054 const char *debug_ivec4(const struct wined3d_ivec4
*v
) DECLSPEC_HIDDEN
;
4055 const char *debug_uvec4(const struct wined3d_uvec4
*v
) DECLSPEC_HIDDEN
;
4056 const char *debug_shader_type(enum wined3d_shader_type shader_type
) DECLSPEC_HIDDEN
;
4057 const char *debug_vec4(const struct wined3d_vec4
*v
) DECLSPEC_HIDDEN
;
4058 const char *wined3d_debug_feature_level(enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
4059 void dump_color_fixup_desc(struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
4061 BOOL
is_invalid_op(const struct wined3d_state
*state
, int stage
,
4062 enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
) DECLSPEC_HIDDEN
;
4063 void sampler_texdim(struct wined3d_context
*context
,
4064 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4065 void tex_alphaop(struct wined3d_context
*context
,
4066 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4067 void apply_pixelshader(struct wined3d_context
*context
,
4068 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4069 void state_alpha_test(struct wined3d_context
*context
,
4070 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4071 void state_fogcolor(struct wined3d_context
*context
,
4072 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4073 void state_fogdensity(struct wined3d_context
*context
,
4074 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4075 void state_fogstartend(struct wined3d_context
*context
,
4076 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4077 void state_fog_fragpart(struct wined3d_context
*context
,
4078 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4079 void state_nop(struct wined3d_context
*context
,
4080 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4081 void state_srgbwrite(struct wined3d_context
*context
,
4082 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4084 void state_clipping(struct wined3d_context
*context
,
4085 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4086 void clipplane(struct wined3d_context
*context
,
4087 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4088 void state_pointsprite_w(struct wined3d_context
*context
,
4089 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4090 void state_pointsprite(struct wined3d_context
*context
,
4091 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4092 void state_shademode(struct wined3d_context
*context
,
4093 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4096 void multiply_matrix(struct wined3d_matrix
*dest
, const struct wined3d_matrix
*src1
,
4097 const struct wined3d_matrix
*src2
) DECLSPEC_HIDDEN
;
4099 void wined3d_release_dc(HWND window
, HDC dc
) DECLSPEC_HIDDEN
;
4101 struct wined3d_shader_lconst
4105 unsigned int value
[4];
4108 struct wined3d_shader_limits
4110 unsigned int sampler
;
4111 unsigned int constant_int
;
4112 unsigned int constant_float
;
4113 unsigned int constant_bool
;
4114 unsigned int packed_output
;
4115 unsigned int packed_input
;
4118 #define wined3d_lock_init(lock, name) wined3d_lock_init_(lock, __FILE__ ": " name)
4119 static inline void wined3d_lock_init_(CRITICAL_SECTION
*lock
, const char *name
)
4121 InitializeCriticalSection(lock
);
4122 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
4123 lock
->DebugInfo
->Spare
[0] = (DWORD_PTR
)name
;
4126 static inline void wined3d_lock_cleanup(CRITICAL_SECTION
*lock
)
4128 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
4129 lock
->DebugInfo
->Spare
[0] = 0;
4130 DeleteCriticalSection(lock
);
4134 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
4136 #define PRINTF_ATTR(fmt,args)
4139 struct wined3d_string_buffer_list
4144 struct wined3d_string_buffer
*string_buffer_get(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4145 void string_buffer_sprintf(struct wined3d_string_buffer
*buffer
, const char *format
, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN
;
4146 void string_buffer_release(struct wined3d_string_buffer_list
*list
, struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4147 void string_buffer_list_init(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4148 void string_buffer_list_cleanup(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4150 int shader_addline(struct wined3d_string_buffer
*buffer
, const char *fmt
, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN
;
4151 BOOL
string_buffer_resize(struct wined3d_string_buffer
*buffer
, int rc
) DECLSPEC_HIDDEN
;
4152 int shader_vaddline(struct wined3d_string_buffer
*buffer
, const char *fmt
, va_list args
) DECLSPEC_HIDDEN
;
4154 struct wined3d_shader_phase
4158 unsigned int instance_count
;
4159 unsigned int temporary_count
;
4162 struct wined3d_vertex_shader
4164 struct wined3d_shader_attribute attributes
[MAX_ATTRIBS
];
4167 struct wined3d_hull_shader
4171 struct wined3d_shader_phase
*control_point
;
4172 unsigned int fork_count
;
4173 unsigned int join_count
;
4174 struct wined3d_shader_phase
*fork
;
4176 struct wined3d_shader_phase
*join
;
4179 unsigned int output_vertex_count
;
4180 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
4181 enum wined3d_tessellator_partitioning tessellator_partitioning
;
4184 struct wined3d_domain_shader
4186 enum wined3d_tessellator_domain tessellator_domain
;
4189 struct wined3d_geometry_shader
4191 enum wined3d_primitive_type input_type
;
4192 enum wined3d_primitive_type output_type
;
4193 unsigned int vertices_out
;
4194 unsigned int instance_count
;
4196 const struct wined3d_stream_output_desc
*so_desc
;
4199 struct wined3d_pixel_shader
4201 /* Pixel shader input semantics */
4202 unsigned int input_reg_map
[MAX_REG_INPUT
];
4203 DWORD input_reg_used
; /* MAX_REG_INPUT, 32 */
4204 unsigned int declared_in_count
;
4206 /* Some information about the shader behavior */
4208 unsigned int color0_reg
;
4210 BOOL force_early_depth_stencil
;
4211 enum wined3d_shader_register_type depth_output
;
4212 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
4215 struct wined3d_compute_shader
4217 struct wined3d_shader_thread_group_size thread_group_size
;
4220 struct wined3d_shader
4223 const struct wined3d_shader_limits
*limits
;
4224 const DWORD
*function
;
4225 unsigned int functionLength
;
4227 unsigned int byte_code_size
;
4228 BOOL load_local_constsF
;
4229 const struct wined3d_shader_frontend
*frontend
;
4230 void *frontend_data
;
4234 const struct wined3d_parent_ops
*parent_ops
;
4236 /* Programs this shader is linked with */
4237 struct list linked_programs
;
4239 /* Immediate constants (override global ones) */
4240 struct list constantsB
;
4241 struct list constantsF
;
4242 struct list constantsI
;
4243 struct wined3d_shader_reg_maps reg_maps
;
4244 BOOL lconst_inf_or_nan
;
4246 struct wined3d_shader_signature input_signature
;
4247 struct wined3d_shader_signature output_signature
;
4248 struct wined3d_shader_signature patch_constant_signature
;
4250 /* Pointer to the parent device */
4251 struct wined3d_device
*device
;
4252 struct list shader_list_entry
;
4256 struct wined3d_vertex_shader vs
;
4257 struct wined3d_hull_shader hs
;
4258 struct wined3d_domain_shader ds
;
4259 struct wined3d_geometry_shader gs
;
4260 struct wined3d_pixel_shader ps
;
4261 struct wined3d_compute_shader cs
;
4265 enum wined3d_shader_resource_type
pixelshader_get_resource_type(const struct wined3d_shader_reg_maps
*reg_maps
,
4266 unsigned int resource_idx
, DWORD tex_types
) DECLSPEC_HIDDEN
;
4267 void find_ps_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4268 BOOL position_transformed
, struct ps_compile_args
*args
,
4269 const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4271 bool vshader_get_input(const struct wined3d_shader
*shader
,
4272 uint8_t usage_req
, uint8_t usage_idx_req
, unsigned int *regnum
) DECLSPEC_HIDDEN
;
4273 void find_vs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4274 struct vs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4276 void find_ds_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4277 struct ds_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4279 void find_gs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4280 struct gs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4282 void string_buffer_clear(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4283 BOOL
string_buffer_init(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4284 void string_buffer_free(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4285 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps
*reg_maps
,
4286 unsigned int max
) DECLSPEC_HIDDEN
;
4287 HRESULT
shader_generate_code(const struct wined3d_shader
*shader
, struct wined3d_string_buffer
*buffer
,
4288 const struct wined3d_shader_reg_maps
*reg_maps
, void *backend_ctx
,
4289 const DWORD
*start
, const DWORD
*end
) DECLSPEC_HIDDEN
;
4290 BOOL
shader_match_semantic(const char *semantic_name
, enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
4292 static inline BOOL
shader_is_scalar(const struct wined3d_shader_register
*reg
)
4296 case WINED3DSPR_RASTOUT
:
4298 if (reg
->idx
[0].offset
)
4303 case WINED3DSPR_CONSTBOOL
: /* b# */
4304 case WINED3DSPR_DEPTHOUT
: /* oDepth */
4305 case WINED3DSPR_DEPTHOUTGE
:
4306 case WINED3DSPR_DEPTHOUTLE
:
4307 case WINED3DSPR_LOOP
: /* aL */
4308 case WINED3DSPR_OUTPOINTID
:
4309 case WINED3DSPR_PREDICATE
: /* p0 */
4310 case WINED3DSPR_PRIMID
: /* primID */
4311 case WINED3DSPR_COVERAGE
: /* vCoverage */
4312 case WINED3DSPR_SAMPLEMASK
: /* oMask */
4315 case WINED3DSPR_MISCTYPE
:
4316 switch (reg
->idx
[0].offset
)
4326 case WINED3DSPR_IMMCONST
:
4327 return reg
->immconst_type
== WINED3D_IMMCONST_SCALAR
;
4334 static inline void shader_get_position_fixup(const struct wined3d_context
*context
,
4335 const struct wined3d_state
*state
, unsigned int fixup_count
, float *position_fixup
)
4337 float center_offset
, x
= 0.0f
, y
= 0.0f
;
4340 /* See get_projection_matrix() in utils.c for a discussion of the position fixup.
4341 * This function here also applies to d3d10+ which does not need adjustment for
4342 * integer pixel centers, but it may need the filling convention offset. */
4343 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_PIXEL_CENTER_INTEGER
)
4344 center_offset
= 1.0f
;
4346 center_offset
= 0.0f
;
4348 center_offset
+= context
->d3d_info
->filling_convention_offset
;
4350 for (i
= 0; i
< fixup_count
; ++i
)
4352 position_fixup
[4 * i
] = 1.0f
;
4353 position_fixup
[4 * i
+ 1] = 1.0f
;
4354 if (!context
->d3d_info
->subpixel_viewport
)
4357 x
= modf(state
->viewports
[i
].x
, &dummy
) * 2.0f
;
4358 y
= modf(state
->viewports
[i
].y
, &dummy
) * 2.0f
;
4360 position_fixup
[4 * i
+ 2] = (center_offset
+ x
) / state
->viewports
[i
].width
;
4361 position_fixup
[4 * i
+ 3] = -(center_offset
+ y
) / state
->viewports
[i
].height
;
4363 if (context
->render_offscreen
)
4365 position_fixup
[4 * i
+ 1] *= -1.0f
;
4366 position_fixup
[4 * i
+ 3] *= -1.0f
;
4371 static inline BOOL
shader_constant_is_local(const struct wined3d_shader
*shader
, DWORD reg
)
4373 struct wined3d_shader_lconst
*lconst
;
4375 if (shader
->load_local_constsF
)
4378 LIST_FOR_EACH_ENTRY(lconst
, &shader
->constantsF
, struct wined3d_shader_lconst
, entry
)
4380 if (lconst
->idx
== reg
)
4387 void get_identity_matrix(struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4388 void get_modelview_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4389 unsigned int index
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4390 void get_projection_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4391 struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4392 void get_texture_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4393 unsigned int tex
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4394 void get_pointsize_minmax(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4395 float *out_min
, float *out_max
) DECLSPEC_HIDDEN
;
4396 void get_pointsize(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4397 float *out_pointsize
, float *out_att
) DECLSPEC_HIDDEN
;
4398 void get_fog_start_end(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4399 float *start
, float *end
) DECLSPEC_HIDDEN
;
4401 /* Using additional shader constants (uniforms in GLSL / program environment
4402 * or local parameters in ARB) is costly:
4403 * ARB only knows float4 parameters and GLSL compiler are not really smart
4404 * when it comes to efficiently pack float2 uniforms, so no space is wasted
4405 * (in fact most compilers map a float2 to a full float4 uniform).
4407 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
4408 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
4409 * into a single shader constant (uniform / program parameter).
4411 * This structure is shared between the GLSL and the ARB backend.*/
4412 struct ps_np2fixup_info
{
4413 unsigned char idx
[WINED3D_MAX_FRAGMENT_SAMPLERS
]; /* indices to the real constant */
4414 WORD active
; /* bitfield indicating if we can apply the fixup */
4418 struct wined3d_palette
4421 struct wined3d_device
*device
;
4424 RGBQUAD colors
[256];
4428 /* DirectDraw utility functions */
4429 extern enum wined3d_format_id
pixelformat_for_depth(DWORD depth
) DECLSPEC_HIDDEN
;
4431 /*****************************************************************************
4432 * Pixel format management
4435 /* Pixel format attributes */
4436 #define WINED3D_FORMAT_ATTR_FLOAT 0x00000001
4437 #define WINED3D_FORMAT_ATTR_INTEGER 0x00000002
4438 #define WINED3D_FORMAT_ATTR_NORMALISED 0x00000004
4439 #define WINED3D_FORMAT_ATTR_BUMPMAP 0x00000008
4440 #define WINED3D_FORMAT_ATTR_EXTENSION 0x00000010
4441 #define WINED3D_FORMAT_ATTR_BLOCKS 0x00000020
4442 #define WINED3D_FORMAT_ATTR_BLOCKS_NO_VERIFY 0x00000040
4443 #define WINED3D_FORMAT_ATTR_COMPRESSED 0x00000080
4444 #define WINED3D_FORMAT_ATTR_BROKEN_PITCH 0x00000100
4445 #define WINED3D_FORMAT_ATTR_HEIGHT_SCALE 0x00000200
4446 #define WINED3D_FORMAT_ATTR_MAPPABLE 0x00000400
4447 #define WINED3D_FORMAT_ATTR_CAST_TO_BLOCK 0x00000800
4449 /* Pixel format capabilities */
4450 #define WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING 0x00000001
4451 #define WINED3D_FORMAT_CAP_FILTERING 0x00000002
4452 #define WINED3D_FORMAT_CAP_UNORDERED_ACCESS 0x00000004
4453 #define WINED3D_FORMAT_CAP_DEPTH_STENCIL 0x00000008
4454 #define WINED3D_FORMAT_CAP_RENDERTARGET 0x00000010
4455 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE 0x00000020
4456 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE_SRGB 0x00000040
4457 #define WINED3D_FORMAT_CAP_DECOMPRESS 0x00000080
4458 #define WINED3D_FORMAT_CAP_SRGB_READ 0x00000100
4459 #define WINED3D_FORMAT_CAP_SRGB_WRITE 0x00000200
4460 #define WINED3D_FORMAT_CAP_VTF 0x00000400
4461 #define WINED3D_FORMAT_CAP_SHADOW 0x00000800
4462 #define WINED3D_FORMAT_CAP_TEXTURE 0x00001000
4463 #define WINED3D_FORMAT_CAP_GEN_MIPMAP 0x00002000
4464 #define WINED3D_FORMAT_CAP_VERTEX_ATTRIBUTE 0x00004000
4465 #define WINED3D_FORMAT_CAP_BLIT 0x00008000
4466 #define WINED3D_FORMAT_CAP_INDEX_BUFFER 0x00010000
4468 struct wined3d_rational
4474 struct wined3d_color_key_conversion
4476 enum wined3d_format_id dst_format
;
4477 void (*convert
)(const BYTE
*src
, unsigned int src_pitch
, BYTE
*dst
, unsigned int dst_pitch
,
4478 unsigned int width
, unsigned int height
, const struct wined3d_color_key
*colour_key
);
4481 enum wined3d_channel_type
4483 WINED3D_CHANNEL_TYPE_NONE
,
4484 WINED3D_CHANNEL_TYPE_UNORM
,
4485 WINED3D_CHANNEL_TYPE_SNORM
,
4486 WINED3D_CHANNEL_TYPE_UINT
,
4487 WINED3D_CHANNEL_TYPE_SINT
,
4488 WINED3D_CHANNEL_TYPE_FLOAT
,
4489 WINED3D_CHANNEL_TYPE_DEPTH
,
4490 WINED3D_CHANNEL_TYPE_STENCIL
,
4491 WINED3D_CHANNEL_TYPE_UNUSED
,
4494 struct wined3d_format
4496 enum wined3d_format_id id
;
4498 D3DDDIFORMAT ddi_format
;
4499 unsigned int component_count
;
4514 UINT block_byte_count
;
4516 enum wined3d_ffp_emit_idx emit_idx
;
4518 UINT conv_byte_count
;
4519 DWORD multisample_types
;
4521 unsigned int caps
[WINED3D_GL_RES_TYPE_COUNT
];
4522 float depth_bias_scale
;
4523 struct wined3d_rational height_scale
;
4524 struct color_fixup_desc color_fixup
;
4525 void (*upload
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
4526 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
4527 unsigned int width
, unsigned int height
, unsigned int depth
);
4528 void (*download
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
4529 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
4530 unsigned int width
, unsigned int height
, unsigned int depth
);
4531 void (*decompress
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
4532 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
4533 unsigned int width
, unsigned int height
, unsigned int depth
);
4535 enum wined3d_format_id typeless_id
;
4538 const struct wined3d_format
*wined3d_get_format(const struct wined3d_adapter
*adapter
,
4539 enum wined3d_format_id format_id
, unsigned int bind_flags
) DECLSPEC_HIDDEN
;
4540 enum wined3d_format_id
wined3d_get_typed_format_id(const struct wined3d_adapter
*adapter
,
4541 const struct wined3d_format
*format
, enum wined3d_channel_type channel_type
) DECLSPEC_HIDDEN
;
4542 void wined3d_format_calculate_pitch(const struct wined3d_format
*format
, unsigned int alignment
,
4543 unsigned int width
, unsigned int height
, unsigned int *row_pitch
, unsigned int *slice_pitch
) DECLSPEC_HIDDEN
;
4544 UINT
wined3d_format_calculate_size(const struct wined3d_format
*format
,
4545 UINT alignment
, UINT width
, UINT height
, UINT depth
) DECLSPEC_HIDDEN
;
4546 void wined3d_format_convert_from_float(const struct wined3d_format
*format
,
4547 const struct wined3d_color
*color
, void *ret
) DECLSPEC_HIDDEN
;
4548 void wined3d_format_copy_data(const struct wined3d_format
*format
, const uint8_t *src
,
4549 unsigned int src_row_pitch
, unsigned int src_slice_pitch
, uint8_t *dst
, unsigned int dst_row_pitch
,
4550 unsigned int dst_slice_pitch
, unsigned int w
, unsigned int h
, unsigned int d
) DECLSPEC_HIDDEN
;
4551 void wined3d_format_get_float_color_key(const struct wined3d_format
*format
,
4552 const struct wined3d_color_key
*key
, struct wined3d_color
*float_colors
) DECLSPEC_HIDDEN
;
4553 BOOL
wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id
,
4554 enum wined3d_format_id view_format_id
) DECLSPEC_HIDDEN
;
4555 const struct wined3d_color_key_conversion
* wined3d_format_get_color_key_conversion(
4556 const struct wined3d_texture
*texture
, BOOL need_alpha_ck
) DECLSPEC_HIDDEN
;
4557 uint32_t wined3d_format_pack(const struct wined3d_format
*format
, const struct wined3d_uvec4
*value
) DECLSPEC_HIDDEN
;
4558 BOOL
wined3d_formats_are_srgb_variants(enum wined3d_format_id format1
,
4559 enum wined3d_format_id format2
) DECLSPEC_HIDDEN
;
4561 BOOL
wined3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
) DECLSPEC_HIDDEN
;
4563 static inline BOOL
wined3d_format_is_typeless(const struct wined3d_format
*format
)
4565 return format
->id
== format
->typeless_id
&& format
->id
!= WINED3DFMT_UNKNOWN
;
4568 static inline BOOL
use_vs(const struct wined3d_state
*state
)
4570 /* Check state->vertex_declaration to allow this to be used before the
4571 * stream info is validated, for example in device_update_tex_unit_map(). */
4572 return state
->shader
[WINED3D_SHADER_TYPE_VERTEX
]
4573 && (!state
->vertex_declaration
|| !state
->vertex_declaration
->position_transformed
);
4576 static inline BOOL
use_ps(const struct wined3d_state
*state
)
4578 return !!state
->shader
[WINED3D_SHADER_TYPE_PIXEL
];
4581 static inline BOOL
use_transform_feedback(const struct wined3d_state
*state
)
4583 const struct wined3d_shader
*shader
;
4585 if (!(shader
= state
->shader
[WINED3D_SHADER_TYPE_GEOMETRY
]))
4587 return !!shader
->u
.gs
.so_desc
;
4590 static inline void context_apply_state(struct wined3d_context
*context
,
4591 const struct wined3d_state
*state
, DWORD state_id
)
4593 const struct wined3d_state_entry
*state_table
= context
->state_table
;
4594 unsigned int rep
= state_table
[state_id
].representative
;
4595 state_table
[rep
].apply(context
, state
, rep
);
4598 static inline BOOL
is_srgb_enabled(const uint32_t *sampler_states
)
4600 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
4601 * the behaviour of the AMD Windows driver.
4603 * Might & Magic: Heroes VI - Shades of Darkness sets
4604 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
4605 * pointer—presumably by accident—and expects sRGB decoding to be
4607 return sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
] & 0x1;
4610 static inline BOOL
needs_separate_srgb_gl_texture(const struct wined3d_context
*context
,
4611 const struct wined3d_texture
*texture
)
4613 if (!(context
->d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
))
4616 if (!context
->d3d_info
->srgb_read_control
4617 && (texture
->resource
.bind_flags
& WINED3D_BIND_SHADER_RESOURCE
)
4618 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_READ
))
4621 if (!context
->d3d_info
->srgb_write_control
4622 && (texture
->resource
.bind_flags
& WINED3D_BIND_RENDER_TARGET
)
4623 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
))
4629 static inline BOOL
needs_srgb_write(const struct wined3d_d3d_info
*d3d_info
,
4630 const struct wined3d_state
*state
, const struct wined3d_fb_state
*fb
)
4632 return (!(d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
)
4633 || state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
])
4634 && fb
->render_targets
[0] && fb
->render_targets
[0]->format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
;
4637 static inline BOOL
can_use_texture_swizzle(const struct wined3d_d3d_info
*d3d_info
, const struct wined3d_format
*format
)
4639 return d3d_info
->texture_swizzle
&& !is_complex_fixup(format
->color_fixup
) && !is_scaling_fixup(format
->color_fixup
);
4642 static inline BOOL
is_rasterization_disabled(const struct wined3d_shader
*geometry_shader
)
4644 return geometry_shader
&& geometry_shader
->u
.gs
.so_desc
4645 && geometry_shader
->u
.gs
.so_desc
->rasterizer_stream_idx
== WINED3D_NO_RASTERIZER_STREAM
;
4648 static inline uint32_t wined3d_mask_from_size(unsigned int size
)
4650 return size
< 32 ? (1u << size
) - 1 : ~0u;
4653 static inline DWORD
wined3d_extract_bits(const uint32_t *bitstream
,
4654 unsigned int offset
, unsigned int count
)
4656 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
4657 const unsigned int idx
= offset
/ word_bit_count
;
4658 const unsigned int shift
= offset
% word_bit_count
;
4659 DWORD mask
= (1u << count
) - 1;
4662 ret
= (bitstream
[idx
] >> shift
) & mask
;
4663 if (shift
+ count
> word_bit_count
)
4665 const unsigned int extracted_bit_count
= word_bit_count
- shift
;
4666 const unsigned int remaining_bit_count
= count
- extracted_bit_count
;
4667 mask
= (1u << remaining_bit_count
) - 1;
4668 ret
|= (bitstream
[idx
+ 1] & mask
) << extracted_bit_count
;
4673 static inline void wined3d_insert_bits(uint32_t *bitstream
,
4674 unsigned int offset
, unsigned int count
, DWORD bits
)
4676 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
4677 const unsigned int idx
= offset
/ word_bit_count
;
4678 const unsigned int shift
= offset
% word_bit_count
;
4679 DWORD mask
= (1u << count
) - 1;
4681 bitstream
[idx
] |= (bits
& mask
) << shift
;
4682 if (shift
+ count
> word_bit_count
)
4684 const unsigned int inserted_bit_count
= word_bit_count
- shift
;
4685 const unsigned int remaining_bit_count
= count
- inserted_bit_count
;
4686 mask
= (1u << remaining_bit_count
) - 1;
4687 bitstream
[idx
+ 1] |= (bits
>> inserted_bit_count
) & mask
;
4691 static inline void wined3d_from_cs(const struct wined3d_cs
*cs
)
4694 assert(cs
->thread_id
== GetCurrentThreadId());
4697 static inline void wined3d_not_from_cs(const struct wined3d_cs
*cs
)
4699 assert(cs
->thread_id
!= GetCurrentThreadId());
4702 static inline enum wined3d_material_color_source
validate_material_colour_source(WORD use_map
,
4703 enum wined3d_material_color_source source
)
4705 if (source
== WINED3D_MCS_COLOR1
&& use_map
& (1u << WINED3D_FFP_DIFFUSE
))
4707 if (source
== WINED3D_MCS_COLOR2
&& use_map
& (1u << WINED3D_FFP_SPECULAR
))
4709 return WINED3D_MCS_MATERIAL
;
4712 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source
*diffuse
,
4713 enum wined3d_material_color_source
*emissive
, enum wined3d_material_color_source
*ambient
,
4714 enum wined3d_material_color_source
*specular
, const struct wined3d_state
*state
,
4715 const struct wined3d_stream_info
*si
)
4717 if (!state
->render_states
[WINED3D_RS_LIGHTING
])
4719 *diffuse
= WINED3D_MCS_COLOR1
;
4720 *specular
= WINED3D_MCS_COLOR2
;
4721 *emissive
= *ambient
= WINED3D_MCS_MATERIAL
;
4726 if (!state
->render_states
[WINED3D_RS_COLORVERTEX
])
4728 *diffuse
= *emissive
= *ambient
= *specular
= WINED3D_MCS_MATERIAL
;
4733 *diffuse
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
]);
4734 *emissive
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
]);
4735 *ambient
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
]);
4736 *specular
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
4739 static inline void wined3d_vec4_transform(struct wined3d_vec4
*dst
,
4740 const struct wined3d_vec4
*v
, const struct wined3d_matrix
*m
)
4742 struct wined3d_vec4 tmp
;
4744 tmp
.x
= v
->x
* m
->_11
+ v
->y
* m
->_21
+ v
->z
* m
->_31
+ v
->w
* m
->_41
;
4745 tmp
.y
= v
->x
* m
->_12
+ v
->y
* m
->_22
+ v
->z
* m
->_32
+ v
->w
* m
->_42
;
4746 tmp
.z
= v
->x
* m
->_13
+ v
->y
* m
->_23
+ v
->z
* m
->_33
+ v
->w
* m
->_43
;
4747 tmp
.w
= v
->x
* m
->_14
+ v
->y
* m
->_24
+ v
->z
* m
->_34
+ v
->w
* m
->_44
;
4752 BOOL
invert_matrix(struct wined3d_matrix
*out
, const struct wined3d_matrix
*m
) DECLSPEC_HIDDEN
;
4754 void compute_normal_matrix(float *normal_matrix
, BOOL legacy_lighting
,
4755 const struct wined3d_matrix
*modelview
) DECLSPEC_HIDDEN
;
4757 static inline struct wined3d_context
*context_acquire(struct wined3d_device
*device
,
4758 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
4760 wined3d_from_cs(device
->cs
);
4762 return device
->adapter
->adapter_ops
->adapter_acquire_context(device
, texture
, sub_resource_idx
);
4765 static inline void context_release(struct wined3d_context
*context
)
4767 context
->device
->adapter
->adapter_ops
->adapter_release_context(context
);
4770 static inline float wined3d_get_float_state(const struct wined3d_state
*state
, enum wined3d_render_state rs
)
4779 tmpvalue
.d
= state
->render_states
[rs
];
4783 static inline void *wined3d_context_map_bo_address(struct wined3d_context
*context
,
4784 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
4786 return context
->device
->adapter
->adapter_ops
->adapter_map_bo_address(context
, data
, size
, map_flags
);
4789 static inline void wined3d_context_unmap_bo_address(struct wined3d_context
*context
,
4790 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
4792 context
->device
->adapter
->adapter_ops
->adapter_unmap_bo_address(context
, data
, range_count
, ranges
);
4795 static inline void wined3d_context_copy_bo_address(struct wined3d_context
*context
,
4796 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
4797 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
)
4799 context
->device
->adapter
->adapter_ops
->adapter_copy_bo_address(context
, dst
, src
, range_count
, ranges
, map_flags
);
4802 static inline void wined3d_context_flush_bo_address(struct wined3d_context
*context
,
4803 const struct wined3d_const_bo_address
*data
, size_t size
)
4805 context
->device
->adapter
->adapter_ops
->adapter_flush_bo_address(context
, data
, size
);
4808 static inline void wined3d_context_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
4810 context
->device
->adapter
->adapter_ops
->adapter_destroy_bo(context
, bo
);
4813 static inline BOOL
wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view
*dsv
,
4814 const struct wined3d_format
*srv_format
)
4816 return !srv_format
|| (srv_format
->red_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_DEPTH
))
4817 || (srv_format
->green_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_STENCIL
));
4820 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture
*texture
)
4822 return texture
->resource
.type
== WINED3D_RTYPE_TEXTURE_3D
? texture
->resource
.depth
: texture
->layer_count
;
4825 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view
*srv
)
4827 struct wined3d_texture
*texture
;
4829 if (srv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
4832 if (srv
->desc
.u
.texture
.layer_idx
|| srv
->desc
.u
.texture
.level_idx
)
4835 texture
= texture_from_resource(srv
->resource
);
4836 return srv
->desc
.u
.texture
.level_count
== texture
->level_count
4837 && srv
->desc
.u
.texture
.layer_count
== wined3d_bind_layer_count(texture
);
4840 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view
*rtv
)
4842 struct wined3d_texture
*texture
;
4844 if (rtv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
4847 if (rtv
->sub_resource_idx
)
4850 texture
= texture_from_resource(rtv
->resource
);
4851 return texture
->level_count
== 1 && rtv
->layer_count
== wined3d_bind_layer_count(texture
);
4854 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view
*srv
)
4856 InterlockedIncrement(&srv
->resource
->srv_bind_count_device
);
4859 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view
*srv
)
4861 InterlockedDecrement(&srv
->resource
->srv_bind_count_device
);
4864 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view
*rtv
)
4866 InterlockedIncrement(&rtv
->resource
->rtv_bind_count_device
);
4869 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view
*rtv
)
4871 InterlockedDecrement(&rtv
->resource
->rtv_bind_count_device
);
4874 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view
*rtv
,
4875 const struct wined3d_shader_resource_view
*srv
)
4877 if (rtv
->resource
!= srv
->resource
)
4880 if (wined3d_srv_all_subresources(srv
) || wined3d_rtv_all_subresources(rtv
))
4883 return rtv
->sub_resource_idx
>= srv
->desc
.u
.texture
.level_idx
4884 && rtv
->sub_resource_idx
< srv
->desc
.u
.texture
.level_idx
+ srv
->desc
.u
.texture
.level_count
4885 && rtv
->layer_count
>= srv
->desc
.u
.texture
.layer_idx
;
4888 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_state
*state
,
4889 const struct wined3d_shader_resource_view
*srv
)
4893 if (!srv
->resource
->rtv_bind_count_device
)
4896 for (i
= 0; i
< ARRAY_SIZE(state
->fb
.render_targets
); ++i
)
4898 const struct wined3d_rendertarget_view
*rtv
;
4900 if ((rtv
= state
->fb
.render_targets
[i
]) && wined3d_rtv_overlaps_srv(rtv
, srv
))
4907 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport
*vp
, float *min_z
, float *max_z
)
4911 /* The magic constant is derived from tests. */
4912 *max_z
= max(vp
->max_z
, vp
->min_z
+ 0.001f
);
4915 static inline BOOL
wined3d_bitmap_clear(uint32_t *map
, unsigned int idx
)
4917 return map
[idx
>> 5] &= ~(1u << (idx
& 0x1f));
4920 static inline BOOL
wined3d_bitmap_set(uint32_t *map
, unsigned int idx
)
4922 return map
[idx
>> 5] |= (1u << (idx
& 0x1f));
4925 static inline BOOL
wined3d_bitmap_is_set(const uint32_t *map
, unsigned int idx
)
4927 return map
[idx
>> 5] & (1u << (idx
& 0x1f));
4930 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap
, unsigned int bit_count
,
4931 unsigned int start
, uint32_t xor_mask
)
4933 const unsigned int word_bit_count
= sizeof(*bitmap
) * CHAR_BIT
;
4934 const uint32_t *ptr
, *end_ptr
;
4937 assert(bit_count
< word_bit_count
|| !(bit_count
% word_bit_count
));
4939 ptr
= bitmap
+ start
/ word_bit_count
;
4940 end_ptr
= bitmap
+ (bit_count
+ word_bit_count
- 1) / word_bit_count
;
4945 mask
= ~0u << start
% word_bit_count
;
4946 map
= (*ptr
^ xor_mask
) & mask
;
4949 if (++ptr
== end_ptr
)
4951 map
= *ptr
^ xor_mask
;
4953 return (ptr
- bitmap
) * word_bit_count
+ wined3d_bit_scan(&map
);
4956 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
4958 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, 0);
4961 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
4963 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, ~0u);
4966 static inline BOOL
wined3d_bitmap_get_range(const uint32_t *bitmap
, unsigned int bit_count
,
4967 unsigned int start
, struct wined3d_range
*range
)
4969 unsigned int range_start
, range_end
;
4971 range_start
= wined3d_bitmap_ffs(bitmap
, bit_count
, start
);
4972 if (range_start
== ~0u)
4975 range_end
= wined3d_bitmap_ffz(bitmap
, bit_count
, range_start
+ 1);
4976 if (range_end
== ~0u)
4977 range_end
= bit_count
;
4979 range
->offset
= range_start
;
4980 range
->size
= range_end
- range_start
;
4984 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
4986 return wined3d_bitmap_is_set(context
->dirty_graphics_states
, state_id
);
4989 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
4991 return wined3d_bitmap_is_set(context
->dirty_compute_states
, state_id
- STATE_COMPUTE_OFFSET
);
4994 static inline bool isStateDirty(const struct wined3d_context
*context
, unsigned int state_id
)
4996 return wined3d_context_is_graphics_state_dirty(context
, state_id
);
4999 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t
)
5001 return t
== WINED3D_PT_POINTLIST
5002 || t
== WINED3D_PT_LINELIST
5003 || t
== WINED3D_PT_TRIANGLELIST
5004 || t
== WINED3D_PT_LINELIST_ADJ
5005 || t
== WINED3D_PT_TRIANGLELIST_ADJ
5006 || t
== WINED3D_PT_PATCH
;
5009 static inline bool wined3d_map_persistent(void)
5011 return sizeof(void *) >= sizeof(uint64_t);
5014 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
5015 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
5017 extern CRITICAL_SECTION wined3d_command_cs
;