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;
183 struct wined3d_d3d_limits
185 unsigned int vs_version
, hs_version
, ds_version
, gs_version
, ps_version
, cs_version
;
186 DWORD vs_uniform_count
;
187 DWORD ps_uniform_count
;
188 unsigned int varying_count
;
189 unsigned int ffp_textures
;
190 unsigned int ffp_blend_stages
;
191 unsigned int ffp_vertex_blend_matrices
;
192 unsigned int active_light_count
;
194 unsigned int max_rt_count
;
195 unsigned int max_clip_distances
;
196 unsigned int texture_size
;
197 unsigned int sample_count
;
201 struct wined3d_d3d_info
203 struct wined3d_d3d_limits limits
;
204 uint32_t wined3d_creation_flags
;
206 uint32_t emulated_flatshading
: 1;
207 uint32_t ffp_generic_attributes
: 1;
208 uint32_t ffp_alpha_test
: 1;
209 uint32_t vs_clipping
: 1;
210 uint32_t shader_color_key
: 1;
211 uint32_t shader_double_precision
: 1;
212 uint32_t shader_output_interpolation
: 1;
213 uint32_t frag_coord_correction
: 1;
214 uint32_t viewport_array_index_any_shader
: 1;
215 uint32_t texture_npot
: 1;
216 uint32_t texture_npot_conditional
: 1;
217 uint32_t normalized_texrect
: 1;
218 uint32_t draw_base_vertex_offset
: 1;
219 uint32_t vertex_bgra
: 1;
220 uint32_t texture_swizzle
: 1;
221 uint32_t srgb_read_control
: 1;
222 uint32_t srgb_write_control
: 1;
223 uint32_t clip_control
: 1;
224 uint32_t full_ffp_varyings
: 1;
225 uint32_t scaled_resolve
: 1;
227 uint32_t subpixel_viewport
: 1;
229 uint32_t persistent_map
: 1;
230 enum wined3d_feature_level feature_level
;
232 DWORD multisample_draw_location
;
234 float filling_convention_offset
;
237 static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
=
238 {0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_Z
, 0, CHANNEL_SOURCE_W
};
240 static inline struct color_fixup_desc
create_complex_fixup_desc(enum complex_fixup complex_fixup
)
242 struct color_fixup_desc fixup
=
244 0u, complex_fixup
& (1u << 0) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
245 0u, complex_fixup
& (1u << 1) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
246 0u, complex_fixup
& (1u << 2) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
247 0u, complex_fixup
& (1u << 3) ? CHANNEL_SOURCE_COMPLEX1
: CHANNEL_SOURCE_COMPLEX0
,
252 static inline BOOL
is_identity_fixup(struct color_fixup_desc fixup
)
254 return !memcmp(&fixup
, &COLOR_FIXUP_IDENTITY
, sizeof(fixup
));
257 static inline BOOL
is_complex_fixup(struct color_fixup_desc fixup
)
259 return fixup
.x_source
== CHANNEL_SOURCE_COMPLEX0
|| fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
;
262 static inline BOOL
is_scaling_fixup(struct color_fixup_desc fixup
)
264 return fixup
.x_sign_fixup
|| fixup
.y_sign_fixup
|| fixup
.z_sign_fixup
|| fixup
.w_sign_fixup
;
267 static inline BOOL
is_same_fixup(struct color_fixup_desc f1
, struct color_fixup_desc f2
)
269 return f1
.x_sign_fixup
== f2
.x_sign_fixup
&& f1
.x_source
== f2
.x_source
270 && f1
.y_sign_fixup
== f2
.y_sign_fixup
&& f1
.y_source
== f2
.y_source
271 && f1
.z_sign_fixup
== f2
.z_sign_fixup
&& f1
.z_source
== f2
.z_source
272 && f1
.w_sign_fixup
== f2
.w_sign_fixup
&& f1
.w_source
== f2
.w_source
;
275 static inline enum complex_fixup
get_complex_fixup(struct color_fixup_desc fixup
)
277 enum complex_fixup complex_fixup
= 0;
278 if (fixup
.x_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 0);
279 if (fixup
.y_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 1);
280 if (fixup
.z_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 2);
281 if (fixup
.w_source
== CHANNEL_SOURCE_COMPLEX1
) complex_fixup
|= (1u << 3);
282 return complex_fixup
;
286 #define WINED3D_MAX_ACTIVE_LIGHTS 8
287 #define WINED3D_MAX_SOFTWARE_ACTIVE_LIGHTS 32
288 #define MAX_CONSTANT_BUFFERS 15
289 #define MAX_SAMPLER_OBJECTS 16
290 #define MAX_SHADER_RESOURCE_VIEWS 128
291 #define MAX_UNORDERED_ACCESS_VIEWS 8
292 #define MAX_TGSM_REGISTERS 8192
293 #define MAX_VERTEX_BLENDS 4
295 static const uint32_t WINED3D_READ_ONLY_BIND_MASK
= WINED3D_BIND_VERTEX_BUFFER
| WINED3D_BIND_INDEX_BUFFER
296 | WINED3D_BIND_CONSTANT_BUFFER
| WINED3D_BIND_SHADER_RESOURCE
| WINED3D_BIND_INDIRECT_BUFFER
;
298 static inline enum wined3d_cmp_func
wined3d_sanitize_cmp_func(enum wined3d_cmp_func func
)
300 if (func
< WINED3D_CMP_NEVER
|| func
> WINED3D_CMP_ALWAYS
)
301 return WINED3D_CMP_ALWAYS
;
305 /* float_16_to_32() and float_32_to_16() convert 16 bit floats in the
306 * FLOAT16 data type to standard C floats and vice versa. They do not
307 * depend on the encoding of the C float, so they are platform independent,
308 * but slow. On x86 and other IEEE 754 compliant platforms the conversion
309 * can be accelerated by bit shifting the exponent and mantissa. There are
310 * also some SSE-based assembly routines out there.
312 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
314 static inline float float_16_to_32(const unsigned short *in
)
316 const unsigned short s
= ((*in
) & 0x8000u
);
317 const unsigned short e
= ((*in
) & 0x7c00u
) >> 10;
318 const unsigned short m
= (*in
) & 0x3ffu
;
319 const float sgn
= (s
? -1.0f
: 1.0f
);
322 if(m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
323 else return sgn
* powf(2, -14.0f
) * ((float)m
/ 1024.0f
);
325 return sgn
* powf(2, (float)e
- 15.0f
) * (1.0f
+ ((float)m
/ 1024.0f
));
327 if(m
== 0) return sgn
* INFINITY
;
332 static inline float float_24_to_32(DWORD in
)
334 const float sgn
= in
& 0x800000u
? -1.0f
: 1.0f
;
335 const unsigned short e
= (in
& 0x780000u
) >> 19;
336 const unsigned int m
= in
& 0x7ffffu
;
340 if (m
== 0) return sgn
* 0.0f
; /* +0.0 or -0.0 */
341 else return sgn
* powf(2, -6.0f
) * ((float)m
/ 524288.0f
);
345 return sgn
* powf(2, (float)e
- 7.0f
) * (1.0f
+ ((float)m
/ 524288.0f
));
349 if (m
== 0) return sgn
* INFINITY
;
354 static inline unsigned short float_32_to_16(const float *in
)
357 float tmp
= fabsf(*in
);
358 unsigned int mantissa
;
361 /* Deal with special numbers */
367 return (*in
< 0.0f
? 0xfc00 : 0x7c00);
369 if (tmp
< (float)(1u << 10))
375 } while (tmp
< (float)(1u << 10));
377 else if (tmp
>= (float)(1u << 11))
383 } while (tmp
>= (float)(1u << 11));
386 mantissa
= (unsigned int)tmp
;
387 if (tmp
- mantissa
>= 0.5f
)
388 ++mantissa
; /* Round to nearest, away from zero. */
390 exp
+= 10; /* Normalize the mantissa. */
391 exp
+= 15; /* Exponent is encoded with excess 15. */
393 if (exp
> 30) /* too big */
395 ret
= 0x7c00; /* INF */
399 /* exp == 0: Non-normalized mantissa. Returns 0x0000 (=0.0) for too small numbers. */
402 mantissa
= mantissa
>> 1;
405 ret
= mantissa
& 0x3ff;
409 ret
= (exp
<< 10) | (mantissa
& 0x3ff);
412 ret
|= ((*in
< 0.0f
? 1 : 0) << 15); /* Add the sign */
416 static inline unsigned int wined3d_popcount(unsigned int x
)
418 #if defined(__MINGW32__)
419 return __builtin_popcount(x
);
421 x
-= x
>> 1 & 0x55555555;
422 x
= (x
& 0x33333333) + (x
>> 2 & 0x33333333);
423 return ((x
+ (x
>> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
427 static inline int wined3d_uint32_compare(uint32_t x
, uint32_t y
)
429 return (x
> y
) - (x
< y
);
432 static inline int wined3d_uint64_compare(uint64_t x
, uint64_t y
)
434 return (x
> y
) - (x
< y
);
437 #define ORM_BACKBUFFER 0
440 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
441 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
443 enum wined3d_shader_backend
445 WINED3D_SHADER_BACKEND_AUTO
,
446 WINED3D_SHADER_BACKEND_GLSL
,
447 WINED3D_SHADER_BACKEND_ARB
,
448 WINED3D_SHADER_BACKEND_NONE
,
451 #define WINED3D_CSMT_ENABLE 0x00000001
452 #define WINED3D_CSMT_SERIALIZE 0x00000002
454 /* NOTE: When adding fields to this structure, make sure to update the default
455 * values in wined3d_main.c as well. */
456 struct wined3d_settings
458 unsigned int cs_multithreaded
;
459 unsigned int max_gl_version
;
460 int offscreen_rendering_mode
;
461 unsigned short pci_vendor_id
;
462 unsigned short pci_device_id
;
463 /* Memory tracking and object counting. */
464 UINT64 emulated_textureram
;
466 unsigned int multisample_textures
;
467 unsigned int sample_count
;
468 BOOL check_float_constants
;
469 unsigned int strict_shader_math
;
470 unsigned int max_sm_vs
;
471 unsigned int max_sm_hs
;
472 unsigned int max_sm_ds
;
473 unsigned int max_sm_gs
;
474 unsigned int max_sm_ps
;
475 unsigned int max_sm_cs
;
476 enum wined3d_renderer renderer
;
477 enum wined3d_shader_backend shader_backend
;
478 BOOL cb_access_map_w
;
481 extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN
;
483 enum wined3d_shader_resource_type
485 WINED3D_SHADER_RESOURCE_NONE
,
486 WINED3D_SHADER_RESOURCE_BUFFER
,
487 WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
488 WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
489 WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
490 WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
491 WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
492 WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
493 WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
494 WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
495 WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY
,
498 #define WINED3D_SHADER_CONST_VS_F 0x00000001
499 #define WINED3D_SHADER_CONST_VS_I 0x00000002
500 #define WINED3D_SHADER_CONST_VS_B 0x00000004
501 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
502 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
503 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
504 #define WINED3D_SHADER_CONST_PS_F 0x00000040
505 #define WINED3D_SHADER_CONST_PS_I 0x00000080
506 #define WINED3D_SHADER_CONST_PS_B 0x00000100
507 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
508 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
509 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
510 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
511 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
512 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
513 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0x00008000
514 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
515 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
516 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
517 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
518 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
519 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
520 #define WINED3D_SHADER_CONST_BASE_VERTEX_ID 0x00400000
522 enum wined3d_shader_register_type
525 WINED3DSPR_INPUT
= 1,
526 WINED3DSPR_CONST
= 2,
528 WINED3DSPR_TEXTURE
= 3,
529 WINED3DSPR_RASTOUT
= 4,
530 WINED3DSPR_ATTROUT
= 5,
531 WINED3DSPR_TEXCRDOUT
= 6,
532 WINED3DSPR_OUTPUT
= 6,
533 WINED3DSPR_CONSTINT
= 7,
534 WINED3DSPR_COLOROUT
= 8,
535 WINED3DSPR_DEPTHOUT
= 9,
536 WINED3DSPR_SAMPLER
= 10,
537 WINED3DSPR_CONST2
= 11,
538 WINED3DSPR_CONST3
= 12,
539 WINED3DSPR_CONST4
= 13,
540 WINED3DSPR_CONSTBOOL
= 14,
541 WINED3DSPR_LOOP
= 15,
542 WINED3DSPR_TEMPFLOAT16
= 16,
543 WINED3DSPR_MISCTYPE
= 17,
544 WINED3DSPR_LABEL
= 18,
545 WINED3DSPR_PREDICATE
= 19,
547 WINED3DSPR_CONSTBUFFER
,
548 WINED3DSPR_IMMCONSTBUFFER
,
553 WINED3DSPR_OUTPOINTID
,
554 WINED3DSPR_FORKINSTID
,
555 WINED3DSPR_JOININSTID
,
556 WINED3DSPR_INCONTROLPOINT
,
557 WINED3DSPR_OUTCONTROLPOINT
,
558 WINED3DSPR_PATCHCONST
,
559 WINED3DSPR_TESSCOORD
,
560 WINED3DSPR_GROUPSHAREDMEM
,
562 WINED3DSPR_THREADGROUPID
,
563 WINED3DSPR_LOCALTHREADID
,
564 WINED3DSPR_LOCALTHREADINDEX
,
567 WINED3DSPR_FUNCTIONBODY
,
568 WINED3DSPR_FUNCTIONPOINTER
,
570 WINED3DSPR_SAMPLEMASK
,
572 WINED3DSPR_DEPTHOUTGE
,
573 WINED3DSPR_DEPTHOUTLE
,
574 WINED3DSPR_RASTERIZER
,
577 enum wined3d_data_type
581 WINED3D_DATA_RESOURCE
,
582 WINED3D_DATA_SAMPLER
,
590 enum wined3d_immconst_type
592 WINED3D_IMMCONST_SCALAR
,
593 WINED3D_IMMCONST_VEC4
,
596 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
598 enum wined3d_shader_src_modifier
600 WINED3DSPSM_NONE
= 0,
602 WINED3DSPSM_BIAS
= 2,
603 WINED3DSPSM_BIASNEG
= 3,
604 WINED3DSPSM_SIGN
= 4,
605 WINED3DSPSM_SIGNNEG
= 5,
606 WINED3DSPSM_COMP
= 6,
608 WINED3DSPSM_X2NEG
= 8,
611 WINED3DSPSM_ABS
= 11,
612 WINED3DSPSM_ABSNEG
= 12,
613 WINED3DSPSM_NOT
= 13,
616 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
617 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
618 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
619 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
620 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
622 enum wined3d_shader_dst_modifier
624 WINED3DSPDM_NONE
= 0,
625 WINED3DSPDM_SATURATE
= 1,
626 WINED3DSPDM_PARTIALPRECISION
= 2,
627 WINED3DSPDM_MSAMPCENTROID
= 4,
630 enum wined3d_shader_interpolation_mode
633 WINED3DSIM_CONSTANT
= 1,
634 WINED3DSIM_LINEAR
= 2,
635 WINED3DSIM_LINEAR_CENTROID
= 3,
636 WINED3DSIM_LINEAR_NOPERSPECTIVE
= 4,
637 WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID
= 5,
638 WINED3DSIM_LINEAR_SAMPLE
= 6,
639 WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE
= 7,
642 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
643 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
645 enum wined3d_shader_global_flags
647 WINED3DSGF_REFACTORING_ALLOWED
= 0x1,
648 WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL
= 0x4,
649 WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS
= 0x8,
652 enum wined3d_shader_sync_flags
654 WINED3DSSF_THREAD_GROUP
= 0x1,
655 WINED3DSSF_GROUP_SHARED_MEMORY
= 0x2,
656 WINED3DSSF_GLOBAL_UAV
= 0x8,
659 enum wined3d_shader_uav_flags
661 WINED3DSUF_GLOBALLY_COHERENT
= 0x2,
662 WINED3DSUF_ORDER_PRESERVING_COUNTER
= 0x100,
665 enum wined3d_tessellator_domain
667 WINED3D_TESSELLATOR_DOMAIN_LINE
= 1,
668 WINED3D_TESSELLATOR_DOMAIN_TRIANGLE
= 2,
669 WINED3D_TESSELLATOR_DOMAIN_QUAD
= 3,
672 enum wined3d_tessellator_output_primitive
674 WINED3D_TESSELLATOR_OUTPUT_POINT
= 1,
675 WINED3D_TESSELLATOR_OUTPUT_LINE
= 2,
676 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW
= 3,
677 WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW
= 4,
680 enum wined3d_tessellator_partitioning
682 WINED3D_TESSELLATOR_PARTITIONING_INTEGER
= 1,
683 WINED3D_TESSELLATOR_PARTITIONING_POW2
= 2,
684 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD
= 3,
685 WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN
= 4,
688 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
689 #define WINED3DSI_TEXLD_PROJECT 0x1
690 #define WINED3DSI_TEXLD_BIAS 0x2
691 #define WINED3DSI_INDEXED_DYNAMIC 0x4
692 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
693 #define WINED3DSI_RESINFO_UINT 0x2
694 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
695 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
697 #define WINED3DSI_PRECISE_X 0x100
698 #define WINED3DSI_PRECISE_Y 0x200
699 #define WINED3DSI_PRECISE_Z 0x400
700 #define WINED3DSI_PRECISE_W 0x800
701 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
702 | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
703 #define WINED3DSI_PRECISE_SHIFT 8
705 enum wined3d_shader_rel_op
707 WINED3D_SHADER_REL_OP_GT
= 1,
708 WINED3D_SHADER_REL_OP_EQ
= 2,
709 WINED3D_SHADER_REL_OP_GE
= 3,
710 WINED3D_SHADER_REL_OP_LT
= 4,
711 WINED3D_SHADER_REL_OP_NE
= 5,
712 WINED3D_SHADER_REL_OP_LE
= 6,
715 enum wined3d_shader_conditional_op
717 WINED3D_SHADER_CONDITIONAL_OP_NZ
= 0,
718 WINED3D_SHADER_CONDITIONAL_OP_Z
= 1
721 enum wined3d_sysval_semantic
723 WINED3D_SV_POSITION
= 0x01,
724 WINED3D_SV_CLIP_DISTANCE
= 0x02,
725 WINED3D_SV_CULL_DISTANCE
= 0x03,
726 WINED3D_SV_RENDER_TARGET_ARRAY_INDEX
= 0x04,
727 WINED3D_SV_VIEWPORT_ARRAY_INDEX
= 0x05,
728 WINED3D_SV_VERTEX_ID
= 0x06,
729 WINED3D_SV_PRIMITIVE_ID
= 0x07,
730 WINED3D_SV_INSTANCE_ID
= 0x08,
731 WINED3D_SV_IS_FRONT_FACE
= 0x09,
732 WINED3D_SV_SAMPLE_INDEX
= 0x0a,
733 WINED3D_SV_TESS_FACTOR_QUADEDGE
= 0x0b,
734 WINED3D_SV_TESS_FACTOR_QUADINT
= 0x0c,
735 WINED3D_SV_TESS_FACTOR_TRIEDGE
= 0x0d,
736 WINED3D_SV_TESS_FACTOR_TRIINT
= 0x0e,
737 WINED3D_SV_TESS_FACTOR_LINEDET
= 0x0f,
738 WINED3D_SV_TESS_FACTOR_LINEDEN
= 0x10,
741 enum wined3d_component_type
743 WINED3D_TYPE_UNKNOWN
= 0x0,
744 WINED3D_TYPE_UINT
= 0x1,
745 WINED3D_TYPE_INT
= 0x2,
746 WINED3D_TYPE_FLOAT
= 0x3,
749 struct wined3d_shader_signature_element
751 const char *semantic_name
;
752 unsigned int semantic_idx
;
753 unsigned int stream_idx
;
754 enum wined3d_sysval_semantic sysval_semantic
;
755 enum wined3d_component_type component_type
;
756 unsigned int register_idx
;
758 unsigned int min_precision
;
761 struct wined3d_shader_signature
763 unsigned int element_count
;
764 struct wined3d_shader_signature_element
*elements
;
767 #define WINED3D_SM1_VS 0xfffeu
768 #define WINED3D_SM1_PS 0xffffu
769 #define WINED3D_SM4_PS 0x0000u
770 #define WINED3D_SM4_VS 0x0001u
771 #define WINED3D_SM4_GS 0x0002u
772 #define WINED3D_SM5_HS 0x0003u
773 #define WINED3D_SM5_DS 0x0004u
774 #define WINED3D_SM5_CS 0x0005u
776 /* Shader version tokens, and shader end tokens */
777 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
778 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
780 /* Shader backends */
782 #define MAX_ATTRIBS 32
783 #define MAX_REG_ADDR 1
784 #define MAX_REG_TEXCRD 8
785 #define MAX_REG_INPUT 32
786 #define MAX_REG_OUTPUT 32
787 #define WINED3D_MAX_CBS 15
789 /* FIXME: This needs to go up to 2048 for
790 * Shader model 3 according to msdn (and for software shaders) */
791 #define MAX_LABELS 16
793 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
795 struct wined3d_string_buffer
799 unsigned int buffer_size
;
800 unsigned int content_size
;
803 enum WINED3D_SHADER_INSTRUCTION_HANDLER
808 WINED3DSIH_ATOMIC_AND
,
809 WINED3DSIH_ATOMIC_CMP_STORE
,
810 WINED3DSIH_ATOMIC_IADD
,
811 WINED3DSIH_ATOMIC_IMAX
,
812 WINED3DSIH_ATOMIC_IMIN
,
813 WINED3DSIH_ATOMIC_OR
,
814 WINED3DSIH_ATOMIC_UMAX
,
815 WINED3DSIH_ATOMIC_UMIN
,
816 WINED3DSIH_ATOMIC_XOR
,
830 WINED3DSIH_CONTINUEP
,
831 WINED3DSIH_COUNTBITS
,
834 WINED3DSIH_CUT_STREAM
,
836 WINED3DSIH_DCL_CONSTANT_BUFFER
,
837 WINED3DSIH_DCL_FUNCTION_BODY
,
838 WINED3DSIH_DCL_FUNCTION_TABLE
,
839 WINED3DSIH_DCL_GLOBAL_FLAGS
,
840 WINED3DSIH_DCL_GS_INSTANCES
,
841 WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
,
842 WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT
,
843 WINED3DSIH_DCL_HS_MAX_TESSFACTOR
,
844 WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
,
845 WINED3DSIH_DCL_INDEX_RANGE
,
846 WINED3DSIH_DCL_INDEXABLE_TEMP
,
847 WINED3DSIH_DCL_INPUT
,
848 WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
,
849 WINED3DSIH_DCL_INPUT_PRIMITIVE
,
850 WINED3DSIH_DCL_INPUT_PS
,
851 WINED3DSIH_DCL_INPUT_PS_SGV
,
852 WINED3DSIH_DCL_INPUT_PS_SIV
,
853 WINED3DSIH_DCL_INPUT_SGV
,
854 WINED3DSIH_DCL_INPUT_SIV
,
855 WINED3DSIH_DCL_INTERFACE
,
856 WINED3DSIH_DCL_OUTPUT
,
857 WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
,
858 WINED3DSIH_DCL_OUTPUT_SIV
,
859 WINED3DSIH_DCL_OUTPUT_TOPOLOGY
,
860 WINED3DSIH_DCL_RESOURCE_RAW
,
861 WINED3DSIH_DCL_RESOURCE_STRUCTURED
,
862 WINED3DSIH_DCL_SAMPLER
,
863 WINED3DSIH_DCL_STREAM
,
864 WINED3DSIH_DCL_TEMPS
,
865 WINED3DSIH_DCL_TESSELLATOR_DOMAIN
,
866 WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
,
867 WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
,
868 WINED3DSIH_DCL_TGSM_RAW
,
869 WINED3DSIH_DCL_TGSM_STRUCTURED
,
870 WINED3DSIH_DCL_THREAD_GROUP
,
871 WINED3DSIH_DCL_UAV_RAW
,
872 WINED3DSIH_DCL_UAV_STRUCTURED
,
873 WINED3DSIH_DCL_UAV_TYPED
,
874 WINED3DSIH_DCL_VERTICES_OUT
,
886 WINED3DSIH_DSX_COARSE
,
889 WINED3DSIH_DSY_COARSE
,
893 WINED3DSIH_EMIT_STREAM
,
897 WINED3DSIH_ENDSWITCH
,
899 WINED3DSIH_EVAL_CENTROID
,
900 WINED3DSIH_EVAL_SAMPLE_INDEX
,
906 WINED3DSIH_FIRSTBIT_HI
,
907 WINED3DSIH_FIRSTBIT_LO
,
908 WINED3DSIH_FIRSTBIT_SHI
,
913 WINED3DSIH_GATHER4_C
,
914 WINED3DSIH_GATHER4_PO
,
915 WINED3DSIH_GATHER4_PO_C
,
917 WINED3DSIH_HS_CONTROL_POINT_PHASE
,
919 WINED3DSIH_HS_FORK_PHASE
,
920 WINED3DSIH_HS_JOIN_PHASE
,
931 WINED3DSIH_IMM_ATOMIC_ALLOC
,
932 WINED3DSIH_IMM_ATOMIC_AND
,
933 WINED3DSIH_IMM_ATOMIC_CMP_EXCH
,
934 WINED3DSIH_IMM_ATOMIC_CONSUME
,
935 WINED3DSIH_IMM_ATOMIC_EXCH
,
936 WINED3DSIH_IMM_ATOMIC_IADD
,
937 WINED3DSIH_IMM_ATOMIC_IMAX
,
938 WINED3DSIH_IMM_ATOMIC_IMIN
,
939 WINED3DSIH_IMM_ATOMIC_OR
,
940 WINED3DSIH_IMM_ATOMIC_UMAX
,
941 WINED3DSIH_IMM_ATOMIC_UMIN
,
942 WINED3DSIH_IMM_ATOMIC_XOR
,
953 WINED3DSIH_LD_STRUCTURED
,
954 WINED3DSIH_LD_UAV_TYPED
,
994 WINED3DSIH_SAMPLE_C_LZ
,
995 WINED3DSIH_SAMPLE_GRAD
,
996 WINED3DSIH_SAMPLE_INFO
,
997 WINED3DSIH_SAMPLE_LOD
,
998 WINED3DSIH_SAMPLE_POS
,
1005 WINED3DSIH_STORE_RAW
,
1006 WINED3DSIH_STORE_STRUCTURED
,
1007 WINED3DSIH_STORE_UAV_TYPED
,
1015 WINED3DSIH_TEXCOORD
,
1016 WINED3DSIH_TEXDEPTH
,
1018 WINED3DSIH_TEXDP3TEX
,
1022 WINED3DSIH_TEXM3x2DEPTH
,
1023 WINED3DSIH_TEXM3x2PAD
,
1024 WINED3DSIH_TEXM3x2TEX
,
1026 WINED3DSIH_TEXM3x3DIFF
,
1027 WINED3DSIH_TEXM3x3PAD
,
1028 WINED3DSIH_TEXM3x3SPEC
,
1029 WINED3DSIH_TEXM3x3TEX
,
1030 WINED3DSIH_TEXM3x3VSPEC
,
1031 WINED3DSIH_TEXREG2AR
,
1032 WINED3DSIH_TEXREG2GB
,
1033 WINED3DSIH_TEXREG2RGB
,
1044 WINED3DSIH_TABLE_SIZE
1047 struct wined3d_shader_version
1049 enum wined3d_shader_type type
;
1054 struct wined3d_shader_resource_info
1056 enum wined3d_shader_resource_type type
;
1057 enum wined3d_data_type data_type
;
1059 unsigned int stride
;
1062 #define WINED3D_SAMPLER_DEFAULT ~0x0u
1064 struct wined3d_shader_sampler_map_entry
1066 unsigned int resource_idx
;
1067 unsigned int sampler_idx
;
1068 unsigned int bind_idx
;
1071 struct wined3d_shader_sampler_map
1073 struct wined3d_shader_sampler_map_entry
*entries
;
1078 struct wined3d_shader_immediate_constant_buffer
1080 unsigned int vec4_count
;
1081 uint32_t data
[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
];
1084 struct wined3d_shader_indexable_temp
1087 unsigned int register_idx
;
1088 unsigned int register_size
;
1089 unsigned int component_count
;
1092 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
1094 struct wined3d_shader_reg_maps
1096 struct wined3d_shader_version shader_version
;
1097 BYTE texcoord
; /* MAX_REG_TEXCRD, 8 */
1098 BYTE address
; /* MAX_REG_ADDR, 1 */
1099 WORD labels
; /* MAX_LABELS, 16 */
1100 DWORD temporary
; /* 32 */
1101 unsigned int temporary_count
;
1102 uint32_t *constf
; /* pixel, vertex */
1103 struct list indexable_temps
;
1104 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1107 DWORD texcoord_mask
[MAX_REG_TEXCRD
]; /* vertex < 3.0 */
1108 BYTE output_registers_mask
[MAX_REG_OUTPUT
]; /* vertex >= 3.0 */
1110 DWORD input_registers
; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1111 DWORD output_registers
; /* MAX_REG_OUTPUT, 32 */
1112 WORD integer_constants
; /* WINED3D_MAX_CONSTS_I, 16 */
1113 WORD boolean_constants
; /* WINED3D_MAX_CONSTS_B, 16 */
1114 WORD local_int_consts
; /* WINED3D_MAX_CONSTS_I, 16 */
1115 WORD local_bool_consts
; /* WINED3D_MAX_CONSTS_B, 16 */
1116 UINT cb_sizes
[WINED3D_MAX_CBS
];
1117 uint32_t cb_map
; /* WINED3D_MAX_CBS, 15 */
1119 struct wined3d_shader_resource_info resource_info
[MAX_SHADER_RESOURCE_VIEWS
];
1120 uint32_t resource_map
[WINED3D_BITMAP_SIZE(MAX_SHADER_RESOURCE_VIEWS
)];
1121 struct wined3d_shader_sampler_map sampler_map
;
1122 DWORD sampler_comparison_mode
;
1123 BYTE bumpmat
; /* WINED3D_MAX_TEXTURES, 8 */
1124 BYTE luminanceparams
; /* WINED3D_MAX_TEXTURES, 8 */
1125 struct wined3d_shader_resource_info uav_resource_info
[MAX_UNORDERED_ACCESS_VIEWS
];
1126 DWORD uav_read_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1127 DWORD uav_counter_mask
: 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1129 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1130 DWORD cull_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1135 DWORD usestexldd
: 1;
1137 DWORD usesfacing
: 1;
1138 DWORD usesrelconstF
: 1;
1140 DWORD usestexldl
: 1;
1144 DWORD point_size
: 1;
1146 DWORD input_rel_addressing
: 1;
1147 DWORD viewport_array
: 1;
1148 DWORD sample_mask
: 1;
1151 DWORD rt_mask
; /* Used render targets, 32 max. */
1153 /* Whether or not loops are used in this shader, and nesting depth */
1154 unsigned int loop_depth
;
1155 unsigned int min_rel_offset
, max_rel_offset
;
1157 struct wined3d_shader_tgsm
*tgsm
;
1158 SIZE_T tgsm_capacity
;
1159 unsigned int tgsm_count
;
1162 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1163 * state information between multiple instructions. */
1164 struct wined3d_shader_tex_mx
1166 unsigned int current_row
;
1167 unsigned int texcoord_w
[2];
1170 struct wined3d_shader_parser_state
1172 unsigned int current_loop_depth
;
1173 unsigned int current_loop_reg
;
1177 struct wined3d_shader_context
1179 const struct wined3d_shader
*shader
;
1180 const struct wined3d_shader_reg_maps
*reg_maps
;
1181 struct wined3d_string_buffer
*buffer
;
1182 struct wined3d_shader_tex_mx
*tex_mx
;
1183 struct wined3d_shader_parser_state
*state
;
1187 struct wined3d_shader_register_index
1189 const struct wined3d_shader_src_param
*rel_addr
;
1190 unsigned int offset
;
1193 struct wined3d_shader_register
1195 enum wined3d_shader_register_type type
;
1196 enum wined3d_data_type data_type
;
1197 struct wined3d_shader_register_index idx
[2];
1198 enum wined3d_immconst_type immconst_type
;
1201 unsigned int immconst_data
[4];
1202 unsigned fp_body_idx
;
1206 struct wined3d_shader_dst_param
1208 struct wined3d_shader_register reg
;
1209 uint32_t write_mask
;
1214 struct wined3d_shader_src_param
1216 struct wined3d_shader_register reg
;
1218 enum wined3d_shader_src_modifier modifiers
;
1221 struct wined3d_shader_index_range
1223 struct wined3d_shader_dst_param first_register
;
1224 unsigned int last_register
;
1227 struct wined3d_shader_semantic
1229 enum wined3d_decl_usage usage
;
1231 enum wined3d_shader_resource_type resource_type
;
1232 unsigned int sample_count
;
1233 enum wined3d_data_type resource_data_type
;
1234 struct wined3d_shader_dst_param reg
;
1237 enum wined3d_shader_input_sysval_semantic
1239 WINED3D_SIV_POSITION
= 1,
1240 WINED3D_SIV_CLIP_DISTANCE
= 2,
1241 WINED3D_SIV_CULL_DISTANCE
= 3,
1242 WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX
= 4,
1243 WINED3D_SIV_VIEWPORT_ARRAY_INDEX
= 5,
1244 WINED3D_SIV_VERTEX_ID
= 6,
1245 WINED3D_SIV_PRIMITIVE_ID
= 7,
1246 WINED3D_SIV_INSTANCE_ID
= 8,
1247 WINED3D_SIV_IS_FRONT_FACE
= 9,
1248 WINED3D_SIV_SAMPLE_INDEX
= 10,
1249 WINED3D_SIV_QUAD_U0_TESS_FACTOR
= 11,
1250 WINED3D_SIV_QUAD_V0_TESS_FACTOR
= 12,
1251 WINED3D_SIV_QUAD_U1_TESS_FACTOR
= 13,
1252 WINED3D_SIV_QUAD_V1_TESS_FACTOR
= 14,
1253 WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR
= 15,
1254 WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR
= 16,
1255 WINED3D_SIV_TRIANGLE_U_TESS_FACTOR
= 17,
1256 WINED3D_SIV_TRIANGLE_V_TESS_FACTOR
= 18,
1257 WINED3D_SIV_TRIANGLE_W_TESS_FACTOR
= 19,
1258 WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR
= 20,
1259 WINED3D_SIV_LINE_DETAIL_TESS_FACTOR
= 21,
1260 WINED3D_SIV_LINE_DENSITY_TESS_FACTOR
= 22,
1263 struct wined3d_shader_register_semantic
1265 struct wined3d_shader_dst_param reg
;
1266 enum wined3d_shader_input_sysval_semantic sysval_semantic
;
1269 struct wined3d_shader_structured_resource
1271 struct wined3d_shader_dst_param reg
;
1272 unsigned int byte_stride
;
1275 struct wined3d_shader_tgsm
1278 unsigned int stride
;
1281 struct wined3d_shader_tgsm_raw
1283 struct wined3d_shader_dst_param reg
;
1284 unsigned int byte_count
;
1287 struct wined3d_shader_tgsm_structured
1289 struct wined3d_shader_dst_param reg
;
1290 unsigned int byte_stride
;
1291 unsigned int structure_count
;
1294 struct wined3d_shader_thread_group_size
1296 unsigned int x
, y
, z
;
1299 struct wined3d_shader_function_table_pointer
1302 unsigned int array_size
;
1303 unsigned int body_count
;
1304 unsigned int table_count
;
1307 struct wined3d_shader_texel_offset
1309 signed char u
, v
, w
;
1312 struct wined3d_shader_primitive_type
1314 enum wined3d_primitive_type type
;
1315 unsigned int patch_vertex_count
;
1318 struct wined3d_shader_instruction
1320 const struct wined3d_shader_context
*ctx
;
1321 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
1323 unsigned int dst_count
;
1324 unsigned int src_count
;
1325 const struct wined3d_shader_dst_param
*dst
;
1326 const struct wined3d_shader_src_param
*src
;
1327 struct wined3d_shader_texel_offset texel_offset
;
1328 enum wined3d_shader_resource_type resource_type
;
1329 enum wined3d_data_type resource_data_type
;
1331 const struct wined3d_shader_src_param
*predicate
;
1334 struct wined3d_shader_semantic semantic
;
1335 struct wined3d_shader_register_semantic register_semantic
;
1336 struct wined3d_shader_primitive_type primitive_type
;
1337 struct wined3d_shader_dst_param dst
;
1338 struct wined3d_shader_src_param src
;
1341 const struct wined3d_shader_immediate_constant_buffer
*icb
;
1342 struct wined3d_shader_structured_resource structured_resource
;
1343 struct wined3d_shader_tgsm_raw tgsm_raw
;
1344 struct wined3d_shader_tgsm_structured tgsm_structured
;
1345 struct wined3d_shader_thread_group_size thread_group_size
;
1346 enum wined3d_tessellator_domain tessellator_domain
;
1347 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1348 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1349 float max_tessellation_factor
;
1350 struct wined3d_shader_index_range index_range
;
1351 struct wined3d_shader_indexable_temp indexable_temp
;
1352 struct wined3d_shader_function_table_pointer fp
;
1356 static inline BOOL
wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction
*ins
)
1358 return ins
->texel_offset
.u
|| ins
->texel_offset
.v
|| ins
->texel_offset
.w
;
1361 struct wined3d_shader_attribute
1363 enum wined3d_decl_usage usage
;
1367 struct wined3d_shader_loop_control
1374 struct wined3d_shader_frontend
1376 void *(*shader_init
)(const DWORD
*byte_code
, size_t byte_code_size
,
1377 const struct wined3d_shader_signature
*output_signature
);
1378 void (*shader_free
)(void *data
);
1379 void (*shader_read_header
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
);
1380 void (*shader_read_instruction
)(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
);
1381 BOOL (*shader_is_end
)(void *data
, const DWORD
**ptr
);
1384 extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN
;
1385 extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN
;
1387 HRESULT
wined3d_shader_extract_from_dxbc(struct wined3d_shader
*shader
,
1388 unsigned int max_shader_version
, enum vkd3d_shader_source_type
*source_type
) DECLSPEC_HIDDEN
;
1389 BOOL
shader_get_stream_output_register_info(const struct wined3d_shader
*shader
,
1390 const struct wined3d_stream_output_element
*so_element
, unsigned int *register_idx
,
1391 unsigned int *component_idx
) DECLSPEC_HIDDEN
;
1393 typedef void (*SHADER_HANDLER
)(const struct wined3d_shader_instruction
*);
1395 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001u
1396 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002u
1397 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004u
1398 #define WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION 0x00000008u
1399 #define WINED3D_SHADER_CAP_FULL_FFP_VARYINGS 0x00000010u
1403 unsigned int vs_version
;
1404 unsigned int hs_version
;
1405 unsigned int ds_version
;
1406 unsigned int gs_version
;
1407 unsigned int ps_version
;
1408 unsigned int cs_version
;
1410 unsigned int vs_uniform_count
;
1411 unsigned int ps_uniform_count
;
1412 float ps_1x_max_value
;
1413 unsigned int varying_count
;
1418 enum wined3d_gl_resource_type
1420 WINED3D_GL_RES_TYPE_TEX_1D
= 0,
1421 WINED3D_GL_RES_TYPE_TEX_2D
= 1,
1422 WINED3D_GL_RES_TYPE_TEX_3D
= 2,
1423 WINED3D_GL_RES_TYPE_TEX_CUBE
= 3,
1424 WINED3D_GL_RES_TYPE_TEX_RECT
= 4,
1425 WINED3D_GL_RES_TYPE_BUFFER
= 5,
1426 WINED3D_GL_RES_TYPE_RB
= 6,
1427 WINED3D_GL_RES_TYPE_COUNT
= 7,
1430 enum wined3d_vertex_processing_mode
1433 WINED3D_VP_MODE_SHADER
,
1434 WINED3D_VP_MODE_NONE
,
1437 #define WINED3D_CONST_NUM_UNUSED ~0U
1439 enum wined3d_ffp_ps_fog_mode
1441 WINED3D_FFP_PS_FOG_OFF
,
1442 WINED3D_FFP_PS_FOG_LINEAR
,
1443 WINED3D_FFP_PS_FOG_EXP
,
1444 WINED3D_FFP_PS_FOG_EXP2
,
1447 /* Stateblock dependent parameters which have to be hardcoded
1448 * into the shader code
1451 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1452 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1453 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1454 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1455 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1457 /* Used for Shader Model 1 pixel shaders to track the bound texture
1458 * type. 2D and RECT textures are separated through NP2 fixup. */
1459 enum wined3d_shader_tex_types
1461 WINED3D_SHADER_TEX_2D
= 0,
1462 WINED3D_SHADER_TEX_3D
= 1,
1463 WINED3D_SHADER_TEX_CUBE
= 2,
1464 WINED3D_SHADER_TEX_ERR
= 3,
1467 struct ps_compile_args
1469 struct color_fixup_desc color_fixup
[WINED3D_MAX_FRAGMENT_SAMPLERS
];
1470 enum wined3d_vertex_processing_mode vp_mode
;
1471 enum wined3d_ffp_ps_fog_mode fog
;
1472 DWORD tex_types
; /* ps 1 - 3, 16 textures */
1473 WORD tex_transform
; /* ps 1.0-1.3, 4 textures */
1474 WORD srgb_correction
;
1475 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1476 D3D9 has a limit of 16 samplers and the fixup is superfluous
1477 in D3D10 (unconditional NP2 support mandatory). */
1479 WORD shadow
; /* WINED3D_MAX_FRAGMENT_SAMPLERS, 16 */
1480 WORD texcoords_initialized
; /* WINED3D_MAX_TEXTURES, 8 */
1481 WORD padding_to_dword
;
1482 DWORD pointsprite
: 1;
1483 DWORD flatshading
: 1;
1484 DWORD alpha_test_func
: 3;
1485 DWORD y_correction
: 1;
1486 DWORD rt_alpha_swizzle
: 8; /* WINED3D_MAX_RENDER_TARGETS, 8 */
1487 DWORD dual_source_blend
: 1;
1497 struct vs_compile_args
1499 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1500 unsigned int next_shader_input_count
;
1501 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1503 BYTE clip_enabled
: 1;
1504 BYTE point_size
: 1;
1505 BYTE per_vertex_point_size
: 1;
1506 BYTE flatshading
: 1;
1507 BYTE next_shader_type
: 3;
1511 struct ds_compile_args
1513 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
1514 enum wined3d_tessellator_partitioning tessellator_partitioning
;
1515 unsigned int output_count
: 16;
1516 unsigned int next_shader_type
: 3;
1517 unsigned int render_offscreen
: 1;
1518 unsigned int padding
: 12;
1519 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1522 struct gs_compile_args
1524 unsigned int output_count
;
1525 enum wined3d_primitive_type primitive_type
;
1526 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
1529 struct wined3d_shader_backend_ops
1531 void (*shader_handle_instruction
)(const struct wined3d_shader_instruction
*);
1532 void (*shader_precompile
)(void *shader_priv
, struct wined3d_shader
*shader
);
1533 void (*shader_select
)(void *shader_priv
, struct wined3d_context
*context
,
1534 const struct wined3d_state
*state
);
1535 void (*shader_select_compute
)(void *shader_priv
, struct wined3d_context
*context
,
1536 const struct wined3d_state
*state
);
1537 void (*shader_disable
)(void *shader_priv
, struct wined3d_context
*context
);
1538 void (*shader_update_float_vertex_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1539 void (*shader_update_float_pixel_constants
)(struct wined3d_device
*device
, UINT start
, UINT count
);
1540 void (*shader_load_constants
)(void *shader_priv
, struct wined3d_context
*context
,
1541 const struct wined3d_state
*state
);
1542 void (*shader_destroy
)(struct wined3d_shader
*shader
);
1543 HRESULT (*shader_alloc_private
)(struct wined3d_device
*device
, const struct wined3d_vertex_pipe_ops
*vertex_pipe
,
1544 const struct wined3d_fragment_pipe_ops
*fragment_pipe
);
1545 void (*shader_free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
1546 BOOL (*shader_allocate_context_data
)(struct wined3d_context
*context
);
1547 void (*shader_free_context_data
)(struct wined3d_context
*context
);
1548 void (*shader_init_context_state
)(struct wined3d_context
*context
);
1549 void (*shader_get_caps
)(const struct wined3d_adapter
*adapter
, struct shader_caps
*caps
);
1550 BOOL (*shader_color_fixup_supported
)(struct color_fixup_desc fixup
);
1551 BOOL (*shader_has_ffp_proj_control
)(void *shader_priv
);
1552 uint64_t (*shader_compile
)(struct wined3d_context
*context
, const struct wined3d_shader_desc
*shader_desc
,
1553 enum wined3d_shader_type shader_type
);
1556 extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN
;
1557 extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN
;
1558 extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN
;
1560 const struct wined3d_shader_backend_ops
*wined3d_spirv_shader_backend_init_vk(void) DECLSPEC_HIDDEN
;
1562 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1564 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1565 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1566 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1567 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1569 static inline void wined3d_color_from_d3dcolor(struct wined3d_color
*wined3d_color
, DWORD d3d_color
)
1571 wined3d_color
->r
= D3DCOLOR_B_R(d3d_color
) / 255.0f
;
1572 wined3d_color
->g
= D3DCOLOR_B_G(d3d_color
) / 255.0f
;
1573 wined3d_color
->b
= D3DCOLOR_B_B(d3d_color
) / 255.0f
;
1574 wined3d_color
->a
= D3DCOLOR_B_A(d3d_color
) / 255.0f
;
1577 extern const struct wined3d_vec4 wined3d_srgb_const
[] DECLSPEC_HIDDEN
;
1579 static inline float wined3d_srgb_from_linear(float colour
)
1583 if (colour
< wined3d_srgb_const
[1].x
)
1584 return colour
* wined3d_srgb_const
[0].w
;
1586 return wined3d_srgb_const
[0].y
* powf(colour
, wined3d_srgb_const
[0].x
) - wined3d_srgb_const
[0].z
;
1590 static inline void wined3d_colour_srgb_from_linear(struct wined3d_color
*colour_srgb
,
1591 const struct wined3d_color
*colour
)
1593 colour_srgb
->r
= wined3d_srgb_from_linear(colour
->r
);
1594 colour_srgb
->g
= wined3d_srgb_from_linear(colour
->g
);
1595 colour_srgb
->b
= wined3d_srgb_from_linear(colour
->b
);
1596 colour_srgb
->a
= colour
->a
;
1601 /* client_map_count and map_ptr are accessed from both the client and CS
1602 * threads, and protected by wined3d_device.bo_map_lock. */
1605 size_t buffer_offset
;
1606 size_t memory_offset
;
1607 unsigned int client_map_count
;
1609 /* Number of resources referencing this BO, used for COW tracking.
1610 * If a resource has this BO as a location and wants to write to it, it
1611 * needs to make a copy unless it's the only owner (refcount == 1).
1612 * Deferred contexts may also hold a reference. */
1616 struct wined3d_bo_user
1622 struct wined3d_bo_address
1624 struct wined3d_bo
*buffer_object
;
1628 struct wined3d_const_bo_address
1630 struct wined3d_bo
*buffer_object
;
1634 static inline struct wined3d_const_bo_address
*wined3d_const_bo_address(const struct wined3d_bo_address
*data
)
1636 return (struct wined3d_const_bo_address
*)data
;
1639 struct wined3d_stream_info_element
1641 const struct wined3d_format
*format
;
1642 struct wined3d_bo_address data
;
1643 unsigned int stride
;
1644 unsigned int stream_idx
;
1645 unsigned int divisor
;
1649 struct wined3d_stream_info
1651 struct wined3d_stream_info_element elements
[MAX_ATTRIBS
];
1652 DWORD position_transformed
: 1;
1654 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
1655 DWORD use_map
; /* MAX_ATTRIBS, 32 */
1658 void wined3d_stream_info_from_declaration(struct wined3d_stream_info
*stream_info
,
1659 const struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
) DECLSPEC_HIDDEN
;
1661 struct wined3d_direct_dispatch_parameters
1663 unsigned int group_count_x
;
1664 unsigned int group_count_y
;
1665 unsigned int group_count_z
;
1668 struct wined3d_indirect_dispatch_parameters
1670 struct wined3d_buffer
*buffer
;
1671 unsigned int offset
;
1674 struct wined3d_dispatch_parameters
1679 struct wined3d_direct_dispatch_parameters direct
;
1680 struct wined3d_indirect_dispatch_parameters indirect
;
1684 struct wined3d_direct_draw_parameters
1686 int base_vertex_idx
;
1687 unsigned int start_idx
;
1688 unsigned int index_count
;
1689 unsigned int start_instance
;
1690 unsigned int instance_count
;
1693 struct wined3d_indirect_draw_parameters
1695 struct wined3d_buffer
*buffer
;
1696 unsigned int offset
;
1699 struct wined3d_draw_parameters
1704 struct wined3d_direct_draw_parameters direct
;
1705 struct wined3d_indirect_draw_parameters indirect
;
1710 void draw_primitive(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1711 const struct wined3d_draw_parameters
*draw_parameters
) DECLSPEC_HIDDEN
;
1712 void dispatch_compute(struct wined3d_device
*device
, const struct wined3d_state
*state
,
1713 const struct wined3d_dispatch_parameters
*dispatch_parameters
) DECLSPEC_HIDDEN
;
1717 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1718 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1720 /* Routines and structures related to state management */
1722 #define STATE_RENDER(a) (a)
1723 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1725 #define STATE_TEXTURESTAGE(stage, num) \
1726 (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1727 #define STATE_IS_TEXTURESTAGE(a) \
1728 ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1730 /* + 1 because samplers start with 0 */
1731 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(WINED3D_MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1732 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS - 1))
1734 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(WINED3D_MAX_COMBINED_SAMPLERS) + (a))
1735 #define STATE_IS_GRAPHICS_SHADER(a) \
1736 ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1738 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1739 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1740 ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1741 && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1743 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1744 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1746 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1747 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1749 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1750 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1752 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1753 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1754 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1755 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1757 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1758 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1760 #define STATE_VIEWPORT (STATE_VDECL + 1)
1761 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1763 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1764 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1765 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1766 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS))
1768 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(WINED3D_MAX_ACTIVE_LIGHTS - 1) + 1)
1769 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1771 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1772 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES - 1))
1774 #define STATE_MATERIAL (STATE_CLIPPLANE(WINED3D_MAX_CLIP_DISTANCES))
1775 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1777 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1778 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1780 #define STATE_DEPTH_BOUNDS (STATE_RASTERIZER + 1)
1781 #define STATE_IS_DEPTH_BOUNDS(a) ((a) == STATE_DEPTH_BOUNDS)
1783 #define STATE_POINTSPRITECOORDORIGIN (STATE_DEPTH_BOUNDS + 1)
1784 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1786 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1787 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1789 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1790 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1792 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1793 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1795 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1796 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1798 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1799 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1801 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1802 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1804 #define STATE_BLEND_FACTOR (STATE_BLEND + 1)
1805 #define STATE_IS_BLEND_FACTOR(a) ((a) == STATE_BLEND_FACTOR)
1807 #define STATE_SAMPLE_MASK (STATE_BLEND_FACTOR + 1)
1808 #define STATE_IS_SAMPLE_MASK(a) ((a) == STATE_SAMPLE_MASK)
1810 #define STATE_DEPTH_STENCIL (STATE_SAMPLE_MASK + 1)
1811 #define STATE_IS_DEPTH_STENCIL(a) ((a) == STATE_DEPTH_STENCIL)
1813 #define STATE_STENCIL_REF (STATE_DEPTH_STENCIL + 1)
1814 #define STATE_IS_STENCIL_REF(a) ((a) == STATE_STENCIL_REF)
1816 #define STATE_COMPUTE_OFFSET (STATE_STENCIL_REF + 1)
1818 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1819 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1821 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1822 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1824 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1825 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1827 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1828 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1830 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1831 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1833 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1834 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1836 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1837 #define STATE_CONSTANT_BUFFER(a) \
1838 ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1839 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1840 STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1848 /* Direct3D terminology with little modifications. We do not have an issued
1849 * state because only the driver knows about it, but we have a created state
1850 * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1851 enum wined3d_query_state
1858 struct wined3d_query_ops
1860 BOOL (*query_poll
)(struct wined3d_query
*query
, uint32_t flags
);
1861 BOOL (*query_issue
)(struct wined3d_query
*query
, uint32_t flags
);
1862 void (*query_destroy
)(struct wined3d_query
*query
);
1865 struct wined3d_query
1870 const struct wined3d_parent_ops
*parent_ops
;
1871 struct wined3d_device
*device
;
1872 enum wined3d_query_state state
;
1873 enum wined3d_query_type type
;
1876 const struct wined3d_query_ops
*query_ops
;
1878 LONG counter_main
, counter_retrieved
;
1879 struct list poll_list_entry
;
1881 /* FIXME: This is GL-specific. */
1882 unsigned int buffer_object
;
1887 #define WINED3D_QUERY_POOL_SIZE 256
1889 struct wined3d_range
1891 unsigned int offset
;
1895 struct wined3d_fb_state
1897 struct wined3d_rendertarget_view
*render_targets
[WINED3D_MAX_RENDER_TARGETS
];
1898 struct wined3d_rendertarget_view
*depth_stencil
;
1901 struct wined3d_context
1903 const struct wined3d_d3d_info
*d3d_info
;
1904 const struct wined3d_state_entry
*state_table
;
1905 uint32_t dirty_graphics_states
[WINED3D_BITMAP_SIZE(STATE_HIGHEST
)];
1906 uint32_t dirty_compute_states
[WINED3D_BITMAP_SIZE(STATE_COMPUTE_COUNT
)];
1908 struct wined3d_device
*device
;
1909 struct wined3d_swapchain
*swapchain
;
1912 struct wined3d_texture
*texture
;
1913 unsigned int sub_resource_idx
;
1916 /* Stores some information about the context state for optimization */
1917 DWORD last_swizzle_map
; /* MAX_ATTRIBS, 32 */
1919 DWORD shader_update_mask
: 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1920 DWORD update_shader_resource_bindings
: 1;
1921 DWORD update_compute_shader_resource_bindings
: 1;
1922 DWORD update_unordered_access_view_bindings
: 1;
1923 DWORD update_compute_unordered_access_view_bindings
: 1;
1924 DWORD last_was_rhw
: 1; /* True iff last draw_primitive was in xyzrhw mode. */
1925 DWORD last_was_pshader
: 1;
1926 DWORD last_was_vshader
: 1;
1927 DWORD last_was_diffuse
: 1;
1928 DWORD last_was_specular
: 1;
1929 DWORD last_was_normal
: 1;
1930 DWORD last_was_ffp_blit
: 1;
1931 DWORD last_was_blit
: 1;
1932 DWORD last_was_ckey
: 1;
1933 DWORD last_was_dual_source_blend
: 1;
1934 DWORD texShaderBumpMap
: 8; /* WINED3D_MAX_TEXTURES, 8 */
1935 DWORD lowest_disabled_stage
: 4; /* Max WINED3D_MAX_TEXTURES, 8 */
1937 DWORD lastWasPow2Texture
: 8; /* WINED3D_MAX_TEXTURES, 8 */
1938 DWORD fixed_function_usage_map
: 8; /* WINED3D_MAX_TEXTURES, 8 */
1939 DWORD use_immediate_mode_draw
: 1;
1940 DWORD uses_uavs
: 1;
1941 DWORD uses_fbo_attached_resources
: 1;
1942 DWORD transform_feedback_active
: 1;
1943 DWORD transform_feedback_paused
: 1;
1944 DWORD fog_coord
: 1;
1945 DWORD render_offscreen
: 1;
1947 DWORD destroyed
: 1;
1948 DWORD destroy_delayed
: 1;
1949 DWORD namedArraysLoaded
: 1;
1952 DWORD clip_distance_mask
: 8; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
1954 DWORD constant_update_mask
;
1955 DWORD numbered_array_mask
;
1956 enum fogsource fog_source
;
1959 void *shader_backend_data
;
1960 void *fragment_pipe_data
;
1962 struct wined3d_stream_info stream_info
;
1964 unsigned int viewport_count
;
1965 unsigned int scissor_rect_count
;
1968 void wined3d_context_cleanup(struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
1969 void wined3d_context_init(struct wined3d_context
*context
, struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
1970 void context_preload_textures(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
1971 void context_update_stream_info(struct wined3d_context
*context
, const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
1973 HRESULT
wined3d_context_no3d_init(struct wined3d_context
*context_no3d
,
1974 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
1976 typedef void (*APPLYSTATEFUNC
)(struct wined3d_context
*ctx
, const struct wined3d_state
*state
, DWORD state_id
);
1978 struct wined3d_state_entry
1980 unsigned int representative
;
1981 APPLYSTATEFUNC apply
;
1984 struct wined3d_state_entry_template
1987 struct wined3d_state_entry content
;
1988 unsigned int extension
;
1991 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
1992 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
1993 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
1995 struct fragment_caps
1998 DWORD PrimitiveMiscCaps
;
1999 DWORD TextureOpCaps
;
2000 DWORD MaxTextureBlendStages
;
2001 DWORD MaxSimultaneousTextures
;
2004 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2005 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2007 struct wined3d_fragment_pipe_ops
2009 void (*fp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2010 void (*get_caps
)(const struct wined3d_adapter
*adapter
, struct fragment_caps
*caps
);
2011 unsigned int (*get_emul_mask
)(const struct wined3d_adapter
*adapter
);
2012 void *(*alloc_private
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2013 void (*free_private
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2014 BOOL (*allocate_context_data
)(struct wined3d_context
*context
);
2015 void (*free_context_data
)(struct wined3d_context
*context
);
2016 BOOL (*color_fixup_supported
)(struct color_fixup_desc fixup
);
2017 const struct wined3d_state_entry_template
*states
;
2020 struct wined3d_vertex_caps
2023 BOOL emulated_flatshading
;
2024 BOOL ffp_generic_attributes
;
2025 DWORD max_active_lights
;
2026 DWORD max_vertex_blend_matrices
;
2027 DWORD max_vertex_blend_matrix_index
;
2028 DWORD vertex_processing_caps
;
2030 DWORD max_user_clip_planes
;
2034 struct wined3d_vertex_pipe_ops
2036 void (*vp_enable
)(const struct wined3d_context
*context
, BOOL enable
);
2037 void (*vp_get_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_vertex_caps
*caps
);
2038 unsigned int (*vp_get_emul_mask
)(const struct wined3d_adapter
*adapter
);
2039 void *(*vp_alloc
)(const struct wined3d_shader_backend_ops
*shader_backend
, void *shader_priv
);
2040 void (*vp_free
)(struct wined3d_device
*device
, struct wined3d_context
*context
);
2041 const struct wined3d_state_entry_template
*vp_states
;
2044 extern const struct wined3d_state_entry_template misc_state_template_gl
[] DECLSPEC_HIDDEN
;
2045 extern const struct wined3d_fragment_pipe_ops none_fragment_pipe DECLSPEC_HIDDEN
;
2046 extern const struct wined3d_fragment_pipe_ops ffp_fragment_pipeline DECLSPEC_HIDDEN
;
2047 extern const struct wined3d_fragment_pipe_ops atifs_fragment_pipeline DECLSPEC_HIDDEN
;
2048 extern const struct wined3d_fragment_pipe_ops arbfp_fragment_pipeline DECLSPEC_HIDDEN
;
2049 extern const struct wined3d_fragment_pipe_ops nvts_fragment_pipeline DECLSPEC_HIDDEN
;
2050 extern const struct wined3d_fragment_pipe_ops nvrc_fragment_pipeline DECLSPEC_HIDDEN
;
2051 extern const struct wined3d_fragment_pipe_ops glsl_fragment_pipe DECLSPEC_HIDDEN
;
2053 const struct wined3d_fragment_pipe_ops
*wined3d_spirv_fragment_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2055 extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN
;
2056 extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN
;
2057 extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN
;
2059 const struct wined3d_vertex_pipe_ops
*wined3d_spirv_vertex_pipe_init_vk(void) DECLSPEC_HIDDEN
;
2061 /* "Base" state table */
2062 HRESULT
compile_state_table(struct wined3d_state_entry
*state_table
, APPLYSTATEFUNC
**dev_multistate_funcs
,
2063 const struct wined3d_d3d_info
*d3d_info
, const BOOL
*supported_extensions
,
2064 const struct wined3d_vertex_pipe_ops
*vertex
, const struct wined3d_fragment_pipe_ops
*fragment
,
2065 const struct wined3d_state_entry_template
*misc
) DECLSPEC_HIDDEN
;
2067 enum wined3d_blit_op
2069 WINED3D_BLIT_OP_COLOR_BLIT
,
2070 WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST
,
2071 WINED3D_BLIT_OP_COLOR_BLIT_CKEY
,
2072 WINED3D_BLIT_OP_DEPTH_BLIT
,
2073 WINED3D_BLIT_OP_RAW_BLIT
,
2076 struct wined3d_blitter
2078 const struct wined3d_blitter_ops
*ops
;
2079 struct wined3d_blitter
*next
;
2082 struct wined3d_blitter_ops
2084 void (*blitter_destroy
)(struct wined3d_blitter
*blitter
, struct wined3d_context
*context
);
2085 void (*blitter_clear
)(struct wined3d_blitter
*blitter
, struct wined3d_device
*device
,
2086 unsigned int rt_count
, const struct wined3d_fb_state
*fb
, unsigned int rect_count
, const RECT
*clear_rects
,
2087 const RECT
*draw_rect
, uint32_t flags
, const struct wined3d_color
*colour
, float depth
, unsigned int stencil
);
2088 DWORD (*blitter_blit
)(struct wined3d_blitter
*blitter
, enum wined3d_blit_op op
, struct wined3d_context
*context
,
2089 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
, DWORD src_location
,
2090 const RECT
*src_rect
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
2091 DWORD dst_location
, const RECT
*dst_rect
, const struct wined3d_color_key
*colour_key
,
2092 enum wined3d_texture_filter_type filter
, const struct wined3d_format
*resolve_format
);
2095 struct wined3d_blitter
*wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN
;
2096 void wined3d_vk_blitter_create(struct wined3d_blitter
**next
) DECLSPEC_HIDDEN
;
2098 BOOL
wined3d_clip_blit(const RECT
*clip_rect
, RECT
*clipped
, RECT
*other
) DECLSPEC_HIDDEN
;
2100 void context_invalidate_compute_state(struct wined3d_context
*context
, DWORD state_id
) DECLSPEC_HIDDEN
;
2101 void context_invalidate_state(struct wined3d_context
*context
, unsigned int state_id
) DECLSPEC_HIDDEN
;
2102 void context_resource_released(const struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
2103 void context_restore(struct wined3d_context
*context
, struct wined3d_texture
*texture
,
2104 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
2105 void context_set_tls_idx(DWORD idx
) DECLSPEC_HIDDEN
;
2106 void context_state_drawbuf(struct wined3d_context
*context
,
2107 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2108 void context_state_fb(struct wined3d_context
*context
,
2109 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
2111 /*****************************************************************************
2112 * Internal representation of a light
2114 struct wined3d_light_info
2116 struct wined3d_light OriginalParms
; /* Note D3D8LIGHT == D3D9LIGHT */
2117 unsigned int OriginalIndex
;
2121 /* Converted parms to speed up swapping lights */
2122 struct wined3d_vec4 position
;
2123 struct wined3d_vec4 direction
;
2127 struct rb_entry entry
;
2128 struct list changed_entry
;
2132 /* The default light parameters */
2133 extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN
;
2135 struct wined3d_pixel_format
2137 int iPixelFormat
; /* WGL pixel format */
2138 int iPixelType
; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2139 int redSize
, greenSize
, blueSize
, alphaSize
, colorSize
;
2140 int depthSize
, stencilSize
;
2141 BOOL windowDrawable
;
2148 enum wined3d_pci_vendor
2150 HW_VENDOR_SOFTWARE
= 0x0000,
2151 HW_VENDOR_AMD
= 0x1002,
2152 HW_VENDOR_NVIDIA
= 0x10de,
2153 HW_VENDOR_VMWARE
= 0x15ad,
2154 HW_VENDOR_REDHAT
= 0x1af4,
2155 HW_VENDOR_INTEL
= 0x8086,
2158 enum wined3d_pci_device
2162 CARD_AMD_RAGE_128PRO
= 0x5246,
2163 CARD_AMD_RADEON_7200
= 0x5144,
2164 CARD_AMD_RADEON_8500
= 0x514c,
2165 CARD_AMD_RADEON_9500
= 0x4144,
2166 CARD_AMD_RADEON_XPRESS_200M
= 0x5955,
2167 CARD_AMD_RADEON_X700
= 0x5e4c,
2168 CARD_AMD_RADEON_X1600
= 0x71c2,
2169 CARD_AMD_RADEON_HD2350
= 0x94c7,
2170 CARD_AMD_RADEON_HD2600
= 0x9581,
2171 CARD_AMD_RADEON_HD2900
= 0x9400,
2172 CARD_AMD_RADEON_HD3200
= 0x9620,
2173 CARD_AMD_RADEON_HD3850
= 0x9515,
2174 CARD_AMD_RADEON_HD4200M
= 0x9712,
2175 CARD_AMD_RADEON_HD4350
= 0x954f,
2176 CARD_AMD_RADEON_HD4600
= 0x9495,
2177 CARD_AMD_RADEON_HD4700
= 0x944e,
2178 CARD_AMD_RADEON_HD4800
= 0x944c,
2179 CARD_AMD_RADEON_HD5400
= 0x68f9,
2180 CARD_AMD_RADEON_HD5600
= 0x68d8,
2181 CARD_AMD_RADEON_HD5700
= 0x68be,
2182 CARD_AMD_RADEON_HD5800
= 0x6898,
2183 CARD_AMD_RADEON_HD5900
= 0x689c,
2184 CARD_AMD_RADEON_HD6300
= 0x9803,
2185 CARD_AMD_RADEON_HD6400
= 0x6770,
2186 CARD_AMD_RADEON_HD6490M
= 0x6760,
2187 CARD_AMD_RADEON_HD6410D
= 0x9644,
2188 CARD_AMD_RADEON_HD6480G
= 0x9648,
2189 CARD_AMD_RADEON_HD6550D
= 0x9640,
2190 CARD_AMD_RADEON_HD6600
= 0x6758,
2191 CARD_AMD_RADEON_HD6600M
= 0x6741,
2192 CARD_AMD_RADEON_HD6700
= 0x68ba,
2193 CARD_AMD_RADEON_HD6800
= 0x6739,
2194 CARD_AMD_RADEON_HD6900
= 0x6719,
2195 CARD_AMD_RADEON_HD7660D
= 0x9901,
2196 CARD_AMD_RADEON_HD7700
= 0x683d,
2197 CARD_AMD_RADEON_HD7800
= 0x6819,
2198 CARD_AMD_RADEON_HD7870
= 0x6818,
2199 CARD_AMD_RADEON_HD7900
= 0x679a,
2200 CARD_AMD_RADEON_HD8600M
= 0x6660,
2201 CARD_AMD_RADEON_HD8670
= 0x6610,
2202 CARD_AMD_RADEON_HD8770
= 0x665c,
2203 CARD_AMD_RADEON_R3
= 0x9830,
2204 CARD_AMD_RADEON_R7
= 0x130f,
2205 CARD_AMD_RADEON_R9_285
= 0x6939,
2206 CARD_AMD_RADEON_R9_290
= 0x67b1,
2207 CARD_AMD_RADEON_R9_290X
= 0x67b0,
2208 CARD_AMD_RADEON_R9_FURY
= 0x7300,
2209 CARD_AMD_RADEON_R9_M370X
= 0x6821,
2210 CARD_AMD_RADEON_R9_M380
= 0x6647,
2211 CARD_AMD_RADEON_R9_M395X
= 0x6920,
2212 CARD_AMD_RADEON_RX_460
= 0x67ef,
2213 CARD_AMD_RADEON_RX_480
= 0x67df,
2214 CARD_AMD_RADEON_RX_VEGA_10
= 0x687f,
2215 CARD_AMD_RADEON_RX_VEGA_12
= 0x69af,
2216 CARD_AMD_RADEON_RAVEN
= 0x15dd,
2217 CARD_AMD_RADEON_RX_VEGA_20
= 0x66af,
2218 CARD_AMD_RADEON_RX_NAVI_10
= 0x731f,
2219 CARD_AMD_RADEON_RX_NAVI_14
= 0x7340,
2220 CARD_AMD_RADEON_RX_NAVI_21
= 0x73bf,
2221 CARD_AMD_RADEON_PRO_V620
= 0x73a1,
2222 CARD_AMD_RADEON_PRO_V620_VF
= 0x73ae,
2223 CARD_AMD_VANGOGH
= 0x163f,
2224 CARD_AMD_RAPHAEL
= 0x164e,
2226 CARD_NVIDIA_RIVA_128
= 0x0018,
2227 CARD_NVIDIA_RIVA_TNT
= 0x0020,
2228 CARD_NVIDIA_RIVA_TNT2
= 0x0028,
2229 CARD_NVIDIA_GEFORCE
= 0x0100,
2230 CARD_NVIDIA_GEFORCE2_MX
= 0x0110,
2231 CARD_NVIDIA_GEFORCE2
= 0x0150,
2232 CARD_NVIDIA_GEFORCE3
= 0x0200,
2233 CARD_NVIDIA_GEFORCE4_MX
= 0x0170,
2234 CARD_NVIDIA_GEFORCE4_TI4200
= 0x0253,
2235 CARD_NVIDIA_GEFORCEFX_5200
= 0x0320,
2236 CARD_NVIDIA_GEFORCEFX_5600
= 0x0312,
2237 CARD_NVIDIA_GEFORCEFX_5800
= 0x0302,
2238 CARD_NVIDIA_GEFORCE_6200
= 0x014f,
2239 CARD_NVIDIA_GEFORCE_6600GT
= 0x0140,
2240 CARD_NVIDIA_GEFORCE_6800
= 0x0041,
2241 CARD_NVIDIA_GEFORCE_7300
= 0x01d7, /* GeForce Go 7300 */
2242 CARD_NVIDIA_GEFORCE_7400
= 0x01d8,
2243 CARD_NVIDIA_GEFORCE_7600
= 0x0391,
2244 CARD_NVIDIA_GEFORCE_7800GT
= 0x0092,
2245 CARD_NVIDIA_GEFORCE_8200
= 0x0849, /* Other PCI ID 0x084b */
2246 CARD_NVIDIA_GEFORCE_8300GS
= 0x0423,
2247 CARD_NVIDIA_GEFORCE_8400GS
= 0x0404,
2248 CARD_NVIDIA_GEFORCE_8500GT
= 0x0421,
2249 CARD_NVIDIA_GEFORCE_8600GT
= 0x0402,
2250 CARD_NVIDIA_GEFORCE_8600MGT
= 0x0407,
2251 CARD_NVIDIA_GEFORCE_8800GTS
= 0x0193,
2252 CARD_NVIDIA_GEFORCE_8800GTX
= 0x0191,
2253 CARD_NVIDIA_GEFORCE_9200
= 0x086d,
2254 CARD_NVIDIA_GEFORCE_9300
= 0x086c,
2255 CARD_NVIDIA_GEFORCE_9400M
= 0x0863,
2256 CARD_NVIDIA_GEFORCE_9400GT
= 0x042c,
2257 CARD_NVIDIA_GEFORCE_9500GT
= 0x0640,
2258 CARD_NVIDIA_GEFORCE_9600GT
= 0x0622,
2259 CARD_NVIDIA_GEFORCE_9700MGT
= 0x064a,
2260 CARD_NVIDIA_GEFORCE_9800GT
= 0x0614,
2261 CARD_NVIDIA_GEFORCE_210
= 0x0a23,
2262 CARD_NVIDIA_GEFORCE_GT220
= 0x0a20,
2263 CARD_NVIDIA_GEFORCE_GT240
= 0x0ca3,
2264 CARD_NVIDIA_GEFORCE_GTS250
= 0x0615,
2265 CARD_NVIDIA_GEFORCE_GTX260
= 0x05e2,
2266 CARD_NVIDIA_GEFORCE_GTX275
= 0x05e6,
2267 CARD_NVIDIA_GEFORCE_GTX280
= 0x05e1,
2268 CARD_NVIDIA_GEFORCE_315M
= 0x0a7a,
2269 CARD_NVIDIA_GEFORCE_320M
= 0x08a3,
2270 CARD_NVIDIA_GEFORCE_GT320M
= 0x0a2d,
2271 CARD_NVIDIA_GEFORCE_GT325M
= 0x0a35,
2272 CARD_NVIDIA_GEFORCE_GT330
= 0x0ca0,
2273 CARD_NVIDIA_GEFORCE_GTS350M
= 0x0cb0,
2274 CARD_NVIDIA_GEFORCE_410M
= 0x1055,
2275 CARD_NVIDIA_GEFORCE_GT420
= 0x0de2,
2276 CARD_NVIDIA_GEFORCE_GT425M
= 0x0df0,
2277 CARD_NVIDIA_GEFORCE_GT430
= 0x0de1,
2278 CARD_NVIDIA_GEFORCE_GT440
= 0x0de0,
2279 CARD_NVIDIA_GEFORCE_GTS450
= 0x0dc4,
2280 CARD_NVIDIA_GEFORCE_GTX460
= 0x0e22,
2281 CARD_NVIDIA_GEFORCE_GTX460M
= 0x0dd1,
2282 CARD_NVIDIA_GEFORCE_GTX465
= 0x06c4,
2283 CARD_NVIDIA_GEFORCE_GTX470
= 0x06cd,
2284 CARD_NVIDIA_GEFORCE_GTX480
= 0x06c0,
2285 CARD_NVIDIA_GEFORCE_GT520
= 0x1040,
2286 CARD_NVIDIA_GEFORCE_GT525M
= 0x0dec,
2287 CARD_NVIDIA_GEFORCE_GT540M
= 0x0df4,
2288 CARD_NVIDIA_GEFORCE_GTX550
= 0x1244,
2289 CARD_NVIDIA_GEFORCE_GT555M
= 0x04b8,
2290 CARD_NVIDIA_GEFORCE_GTX560TI
= 0x1200,
2291 CARD_NVIDIA_GEFORCE_GTX560M
= 0x1251,
2292 CARD_NVIDIA_GEFORCE_GTX560
= 0x1201,
2293 CARD_NVIDIA_GEFORCE_GTX570
= 0x1081,
2294 CARD_NVIDIA_GEFORCE_GTX580
= 0x1080,
2295 CARD_NVIDIA_GEFORCE_GT610
= 0x104a,
2296 CARD_NVIDIA_GEFORCE_GT630
= 0x0f00,
2297 CARD_NVIDIA_GEFORCE_GT630M
= 0x0de9,
2298 CARD_NVIDIA_GEFORCE_GT640
= 0x0fc1,
2299 CARD_NVIDIA_GEFORCE_GT640M
= 0x0fd2,
2300 CARD_NVIDIA_GEFORCE_GT650M
= 0x0fd1,
2301 CARD_NVIDIA_GEFORCE_GTX650
= 0x0fc6,
2302 CARD_NVIDIA_GEFORCE_GTX650TI
= 0x11c6,
2303 CARD_NVIDIA_GEFORCE_GTX660
= 0x11c0,
2304 CARD_NVIDIA_GEFORCE_GTX660M
= 0x0fd4,
2305 CARD_NVIDIA_GEFORCE_GTX660TI
= 0x1183,
2306 CARD_NVIDIA_GEFORCE_GTX670
= 0x1189,
2307 CARD_NVIDIA_GEFORCE_GTX670MX
= 0x11a1,
2308 CARD_NVIDIA_GEFORCE_GTX675MX_1
= 0x11a7,
2309 CARD_NVIDIA_GEFORCE_GTX675MX_2
= 0x11a2,
2310 CARD_NVIDIA_GEFORCE_GTX680
= 0x1180,
2311 CARD_NVIDIA_GEFORCE_GTX690
= 0x1188,
2312 CARD_NVIDIA_GEFORCE_GT720
= 0x128b,
2313 CARD_NVIDIA_GEFORCE_GT730
= 0x1287,
2314 CARD_NVIDIA_GEFORCE_GT730M
= 0x0fe1,
2315 CARD_NVIDIA_GEFORCE_GT740M
= 0x1292,
2316 CARD_NVIDIA_GEFORCE_GT750M
= 0x0fe9,
2317 CARD_NVIDIA_GEFORCE_GT755M
= 0x0fcd,
2318 CARD_NVIDIA_GEFORCE_GTX750
= 0x1381,
2319 CARD_NVIDIA_GEFORCE_GTX750TI
= 0x1380,
2320 CARD_NVIDIA_GEFORCE_GTX760
= 0x1187,
2321 CARD_NVIDIA_GEFORCE_GTX760TI
= 0x1193,
2322 CARD_NVIDIA_GEFORCE_GTX765M
= 0x11e2,
2323 CARD_NVIDIA_GEFORCE_GTX770M
= 0x11e0,
2324 CARD_NVIDIA_GEFORCE_GTX770
= 0x1184,
2325 CARD_NVIDIA_GEFORCE_GTX775M
= 0x119d,
2326 CARD_NVIDIA_GEFORCE_GTX780
= 0x1004,
2327 CARD_NVIDIA_GEFORCE_GTX780M
= 0x119e,
2328 CARD_NVIDIA_GEFORCE_GTX780TI
= 0x100a,
2329 CARD_NVIDIA_GEFORCE_GTXTITAN
= 0x1005,
2330 CARD_NVIDIA_GEFORCE_GTXTITANB
= 0x100c,
2331 CARD_NVIDIA_GEFORCE_GTXTITANX
= 0x17c2,
2332 CARD_NVIDIA_GEFORCE_GTXTITANZ
= 0x1001,
2333 CARD_NVIDIA_GEFORCE_820M
= 0x0fed,
2334 CARD_NVIDIA_GEFORCE_830M
= 0x1340,
2335 CARD_NVIDIA_GEFORCE_840M
= 0x1341,
2336 CARD_NVIDIA_GEFORCE_845M
= 0x1344,
2337 CARD_NVIDIA_GEFORCE_GTX850M
= 0x1391,
2338 CARD_NVIDIA_GEFORCE_GTX860M
= 0x1392, /* Other PCI ID 0x119a */
2339 CARD_NVIDIA_GEFORCE_GTX870M
= 0x1199,
2340 CARD_NVIDIA_GEFORCE_GTX880M
= 0x1198,
2341 CARD_NVIDIA_GEFORCE_940M
= 0x1347,
2342 CARD_NVIDIA_GEFORCE_GTX950
= 0x1402,
2343 CARD_NVIDIA_GEFORCE_GTX950M
= 0x139a,
2344 CARD_NVIDIA_GEFORCE_GTX960
= 0x1401,
2345 CARD_NVIDIA_GEFORCE_GTX960M
= 0x139b,
2346 CARD_NVIDIA_GEFORCE_GTX970
= 0x13c2,
2347 CARD_NVIDIA_GEFORCE_GTX970M
= 0x13d8,
2348 CARD_NVIDIA_GEFORCE_GTX980
= 0x13c0,
2349 CARD_NVIDIA_GEFORCE_GTX980TI
= 0x17c8,
2350 CARD_NVIDIA_GEFORCE_GT1030
= 0x1d01,
2351 CARD_NVIDIA_GEFORCE_GTX1050
= 0x1c81,
2352 CARD_NVIDIA_GEFORCE_GTX1050TI
= 0x1c82,
2353 CARD_NVIDIA_GEFORCE_GTX1060_3GB
= 0x1c02,
2354 CARD_NVIDIA_GEFORCE_GTX1060
= 0x1c03,
2355 CARD_NVIDIA_GEFORCE_GTX1060M
= 0x1c20,
2356 CARD_NVIDIA_GEFORCE_GTX1070
= 0x1b81,
2357 CARD_NVIDIA_GEFORCE_GTX1080
= 0x1b80,
2358 CARD_NVIDIA_GEFORCE_GTX1080M
= 0x1be0,
2359 CARD_NVIDIA_GEFORCE_GTX1080TI
= 0x1b06,
2360 CARD_NVIDIA_TITANX_PASCAL
= 0x1b00,
2361 CARD_NVIDIA_TITANV
= 0x1d81,
2362 CARD_NVIDIA_GEFORCE_GTX1650SUPER
= 0x2187,
2363 CARD_NVIDIA_GEFORCE_GTX1660SUPER
= 0x21c4,
2364 CARD_NVIDIA_GEFORCE_GTX1660TI
= 0x2182,
2365 CARD_NVIDIA_GEFORCE_RTX2060
= 0x1f08,
2366 CARD_NVIDIA_GEFORCE_RTX2070
= 0x1f07,
2367 CARD_NVIDIA_GEFORCE_RTX2080
= 0x1e87,
2368 CARD_NVIDIA_GEFORCE_RTX2080TI
= 0x1e07,
2369 CARD_NVIDIA_TESLA_T4
= 0x1eb8,
2370 CARD_NVIDIA_AMPERE_A10
= 0x2236,
2372 CARD_REDHAT_VIRGL
= 0x1010,
2374 CARD_VMWARE_SVGA3D
= 0x0405,
2376 CARD_INTEL_830M
= 0x3577,
2377 CARD_INTEL_855GM
= 0x3582,
2378 CARD_INTEL_845G
= 0x2562,
2379 CARD_INTEL_865G
= 0x2572,
2380 CARD_INTEL_915G
= 0x2582,
2381 CARD_INTEL_E7221G
= 0x258a,
2382 CARD_INTEL_915GM
= 0x2592,
2383 CARD_INTEL_945G
= 0x2772,
2384 CARD_INTEL_945GM
= 0x27a2,
2385 CARD_INTEL_945GME
= 0x27ae,
2386 CARD_INTEL_Q35
= 0x29b2,
2387 CARD_INTEL_G33
= 0x29c2,
2388 CARD_INTEL_Q33
= 0x29d2,
2389 CARD_INTEL_PNVG
= 0xa001,
2390 CARD_INTEL_PNVM
= 0xa011,
2391 CARD_INTEL_965Q
= 0x2992,
2392 CARD_INTEL_965G
= 0x2982,
2393 CARD_INTEL_946GZ
= 0x2972,
2394 CARD_INTEL_965GM
= 0x2a02,
2395 CARD_INTEL_965GME
= 0x2a12,
2396 CARD_INTEL_GM45
= 0x2a42,
2397 CARD_INTEL_IGD
= 0x2e02,
2398 CARD_INTEL_Q45
= 0x2e12,
2399 CARD_INTEL_G45
= 0x2e22,
2400 CARD_INTEL_G41
= 0x2e32,
2401 CARD_INTEL_B43
= 0x2e92,
2402 CARD_INTEL_ILKD
= 0x0042,
2403 CARD_INTEL_ILKM
= 0x0046,
2404 CARD_INTEL_SNBD
= 0x0122,
2405 CARD_INTEL_SNBM
= 0x0126,
2406 CARD_INTEL_SNBS
= 0x010a,
2407 CARD_INTEL_IVBD
= 0x0162,
2408 CARD_INTEL_IVBM
= 0x0166,
2409 CARD_INTEL_IVBS
= 0x015a,
2410 CARD_INTEL_HWD
= 0x0412,
2411 CARD_INTEL_HWM
= 0x0416,
2412 CARD_INTEL_HD5000_1
= 0x0a26,
2413 CARD_INTEL_HD5000_2
= 0x0422,
2414 CARD_INTEL_I5100_1
= 0x0a22,
2415 CARD_INTEL_I5100_2
= 0x0a2a,
2416 CARD_INTEL_I5100_3
= 0x0a2b,
2417 CARD_INTEL_I5100_4
= 0x0a2e,
2418 CARD_INTEL_IP5200_1
= 0x0d22,
2419 CARD_INTEL_IP5200_2
= 0x0d26,
2420 CARD_INTEL_IP5200_3
= 0x0d2a,
2421 CARD_INTEL_IP5200_4
= 0x0d2b,
2422 CARD_INTEL_IP5200_5
= 0x0d2e,
2423 CARD_INTEL_IP5200_6
= 0x0c22,
2424 CARD_INTEL_HD5300
= 0x161e,
2425 CARD_INTEL_HD5500
= 0x1616,
2426 CARD_INTEL_HD5600
= 0x1612,
2427 CARD_INTEL_HD6000
= 0x1626,
2428 CARD_INTEL_I6100
= 0x162b,
2429 CARD_INTEL_IP6200
= 0x1622,
2430 CARD_INTEL_IPP6300
= 0x162a,
2431 CARD_INTEL_HD510_1
= 0x1902,
2432 CARD_INTEL_HD510_2
= 0x1906,
2433 CARD_INTEL_HD510_3
= 0x190b,
2434 CARD_INTEL_HD515
= 0x191e,
2435 CARD_INTEL_HD520_1
= 0x1916,
2436 CARD_INTEL_HD520_2
= 0x1921,
2437 CARD_INTEL_HD530_1
= 0x1912,
2438 CARD_INTEL_HD530_2
= 0x191b,
2439 CARD_INTEL_HDP530
= 0x191d,
2440 CARD_INTEL_I540
= 0x1926,
2441 CARD_INTEL_I550
= 0x1927,
2442 CARD_INTEL_I555
= 0x192b,
2443 CARD_INTEL_IP555
= 0x192d,
2444 CARD_INTEL_IP580_1
= 0x1932,
2445 CARD_INTEL_IP580_2
= 0x193b,
2446 CARD_INTEL_IPP580_1
= 0x193a,
2447 CARD_INTEL_IPP580_2
= 0x193d,
2448 CARD_INTEL_UHD617
= 0x87c0,
2449 CARD_INTEL_UHD620
= 0x3ea0,
2450 CARD_INTEL_HD615
= 0x591e,
2451 CARD_INTEL_HD620
= 0x5916,
2452 CARD_INTEL_HD630_1
= 0x5912,
2453 CARD_INTEL_HD630_2
= 0x591b,
2454 CARD_INTEL_UHD630_1
= 0x3e9b,
2455 CARD_INTEL_UHD630_2
= 0x3e91,
2458 /* The driver names reflect the lowest GPU supported
2459 * by a certain driver, so DRIVER_AMD_R300 supports
2460 * R3xx, R4xx and R5xx GPUs. */
2461 enum wined3d_display_driver
2463 DRIVER_AMD_RAGE_128PRO
,
2468 DRIVER_INTEL_GMA800
,
2469 DRIVER_INTEL_GMA900
,
2470 DRIVER_INTEL_GMA950
,
2471 DRIVER_INTEL_GMA3000
,
2472 DRIVER_INTEL_HD4000
,
2474 DRIVER_NVIDIA_GEFORCE2MX
,
2475 DRIVER_NVIDIA_GEFORCEFX
,
2476 DRIVER_NVIDIA_GEFORCE6
,
2477 DRIVER_NVIDIA_GEFORCE8
,
2478 DRIVER_NVIDIA_FERMI
,
2479 DRIVER_NVIDIA_KEPLER
,
2480 DRIVER_REDHAT_VIRGL
,
2486 struct wined3d_gpu_description
2488 enum wined3d_pci_vendor vendor
;
2489 enum wined3d_pci_device device
;
2490 const char *description
;
2491 enum wined3d_display_driver driver
;
2492 unsigned int vidmem
;
2495 const struct wined3d_gpu_description
*wined3d_get_gpu_description(enum wined3d_pci_vendor vendor
,
2496 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
2497 const struct wined3d_gpu_description
*wined3d_get_user_override_gpu_description(enum wined3d_pci_vendor vendor
,
2498 enum wined3d_pci_device device
) DECLSPEC_HIDDEN
;
2499 enum wined3d_pci_device
wined3d_gpu_from_feature_level(enum wined3d_pci_vendor
*vendor
,
2500 enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
2502 /* 512 in Direct3D 8/9, 128 in DXGI. */
2503 #define WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH 512
2505 struct wined3d_driver_info
2507 enum wined3d_pci_vendor vendor
;
2508 enum wined3d_pci_device device
;
2510 char description
[WINED3D_MAX_DEVICE_IDENTIFIER_LENGTH
];
2512 UINT64 sysmem_bytes
;
2513 unsigned int version_high
;
2514 unsigned int version_low
;
2517 bool wined3d_driver_info_init(struct wined3d_driver_info
*driver_info
,
2518 const struct wined3d_gpu_description
*gpu_description
, enum wined3d_feature_level feature_level
,
2519 UINT64 vram_bytes
, UINT64 sysmem_bytes
) DECLSPEC_HIDDEN
;
2521 #define UPLOAD_BO_UPLOAD_ON_UNMAP 0x1
2522 #define UPLOAD_BO_RENAME_ON_UNMAP 0x2
2523 #define UPLOAD_BO_FREE_ON_UNMAP 0x4
2527 struct wined3d_const_bo_address addr
;
2531 struct wined3d_adapter_ops
2533 void (*adapter_destroy
)(struct wined3d_adapter
*adapter
);
2534 HRESULT (*adapter_create_device
)(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
2535 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
2536 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
2537 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
);
2538 void (*adapter_destroy_device
)(struct wined3d_device
*device
);
2539 struct wined3d_context
*(*adapter_acquire_context
)(struct wined3d_device
*device
,
2540 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
);
2541 void (*adapter_release_context
)(struct wined3d_context
*context
);
2542 void (*adapter_get_wined3d_caps
)(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
);
2543 BOOL (*adapter_check_format
)(const struct wined3d_adapter
*adapter
,
2544 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
2545 const struct wined3d_format
*ds_format
);
2546 HRESULT (*adapter_init_3d
)(struct wined3d_device
*device
);
2547 void (*adapter_uninit_3d
)(struct wined3d_device
*device
);
2548 void *(*adapter_map_bo_address
)(struct wined3d_context
*context
,
2549 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
);
2550 void (*adapter_unmap_bo_address
)(struct wined3d_context
*context
, const struct wined3d_bo_address
*data
,
2551 unsigned int range_count
, const struct wined3d_range
*ranges
);
2552 void (*adapter_copy_bo_address
)(struct wined3d_context
*context
,
2553 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
2554 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
);
2555 void (*adapter_flush_bo_address
)(struct wined3d_context
*context
,
2556 const struct wined3d_const_bo_address
*data
, size_t size
);
2557 bool (*adapter_alloc_bo
)(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
2558 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
);
2559 void (*adapter_destroy_bo
)(struct wined3d_context
*context
, struct wined3d_bo
*bo
);
2560 HRESULT (*adapter_create_swapchain
)(struct wined3d_device
*device
,
2561 const struct wined3d_swapchain_desc
*desc
,
2562 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
2563 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
);
2564 void (*adapter_destroy_swapchain
)(struct wined3d_swapchain
*swapchain
);
2565 HRESULT (*adapter_create_buffer
)(struct wined3d_device
*device
, const struct wined3d_buffer_desc
*desc
,
2566 const struct wined3d_sub_resource_data
*data
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2567 struct wined3d_buffer
**buffer
);
2568 void (*adapter_destroy_buffer
)(struct wined3d_buffer
*buffer
);
2569 HRESULT (*adapter_create_texture
)(struct wined3d_device
*device
, const struct wined3d_resource_desc
*desc
,
2570 unsigned int layer_count
, unsigned int level_count
, uint32_t flags
, void *parent
,
2571 const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
);
2572 void (*adapter_destroy_texture
)(struct wined3d_texture
*texture
);
2573 HRESULT (*adapter_create_rendertarget_view
)(const struct wined3d_view_desc
*desc
,
2574 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2575 struct wined3d_rendertarget_view
**view
);
2576 void (*adapter_destroy_rendertarget_view
)(struct wined3d_rendertarget_view
*view
);
2577 HRESULT (*adapter_create_shader_resource_view
)(const struct wined3d_view_desc
*desc
,
2578 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2579 struct wined3d_shader_resource_view
**view
);
2580 void (*adapter_destroy_shader_resource_view
)(struct wined3d_shader_resource_view
*view
);
2581 HRESULT (*adapter_create_unordered_access_view
)(const struct wined3d_view_desc
*desc
,
2582 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
2583 struct wined3d_unordered_access_view
**view
);
2584 void (*adapter_destroy_unordered_access_view
)(struct wined3d_unordered_access_view
*view
);
2585 HRESULT (*adapter_create_sampler
)(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
2586 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
);
2587 void (*adapter_destroy_sampler
)(struct wined3d_sampler
*sampler
);
2588 HRESULT (*adapter_create_query
)(struct wined3d_device
*device
, enum wined3d_query_type type
,
2589 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
);
2590 void (*adapter_destroy_query
)(struct wined3d_query
*query
);
2591 void (*adapter_flush_context
)(struct wined3d_context
*context
);
2592 void (*adapter_draw_primitive
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
2593 const struct wined3d_draw_parameters
*parameters
);
2594 void (*adapter_dispatch_compute
)(struct wined3d_device
*device
, const struct wined3d_state
*state
,
2595 const struct wined3d_dispatch_parameters
*parameters
);
2596 void (*adapter_clear_uav
)(struct wined3d_context
*context
,
2597 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
);
2598 void (*adapter_generate_mipmap
)(struct wined3d_context
*context
, struct wined3d_shader_resource_view
*view
);
2601 struct wined3d_output
2603 unsigned int ordinal
;
2604 WCHAR device_name
[CCHDEVICENAME
];
2605 struct wined3d_adapter
*adapter
;
2606 enum wined3d_format_id screen_format
;
2608 D3DKMT_HANDLE kmt_device
;
2609 D3DDDI_VIDEO_PRESENT_SOURCE_ID vidpn_source_id
;
2611 struct wined3d_display_mode
*modes
;
2612 SIZE_T mode_count
, modes_size
;
2616 HRESULT
wined3d_output_get_gamma_ramp(struct wined3d_output
*output
, struct wined3d_gamma_ramp
*ramp
) DECLSPEC_HIDDEN
;
2619 #define MAX_PERSISTENT_MAPPED_BYTES I64_MAX
2621 #define MAX_PERSISTENT_MAPPED_BYTES (128 * 1024 * 1024)
2624 /* The adapter structure */
2625 struct wined3d_adapter
2627 unsigned int ordinal
;
2629 struct wined3d_d3d_info d3d_info
;
2630 struct wined3d_driver_info driver_info
;
2631 struct wined3d_output
*outputs
;
2632 SIZE_T output_count
, outputs_size
;
2633 D3DKMT_HANDLE kmt_adapter
;
2634 UINT64 vram_bytes_used
;
2642 ssize_t mapped_size
;
2644 const struct wined3d_vertex_pipe_ops
*vertex_pipe
;
2645 const struct wined3d_fragment_pipe_ops
*fragment_pipe
;
2646 const struct wined3d_state_entry_template
*misc_state_template
;
2647 const struct wined3d_shader_backend_ops
*shader_backend
;
2648 const struct wined3d_adapter_ops
*adapter_ops
;
2651 BOOL
wined3d_adapter_init(struct wined3d_adapter
*adapter
, unsigned int ordinal
, const LUID
*luid
,
2652 const struct wined3d_adapter_ops
*adapter_ops
) DECLSPEC_HIDDEN
;
2653 void wined3d_adapter_cleanup(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
2654 BOOL
wined3d_get_primary_adapter_luid(LUID
*luid
) DECLSPEC_HIDDEN
;
2656 struct wined3d_adapter
*wined3d_adapter_vk_create(unsigned int ordinal
,
2657 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
2659 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
,
2660 unsigned int wined3d_creation_flags
) DECLSPEC_HIDDEN
;
2662 BOOL
wined3d_adapter_no3d_init_format_info(struct wined3d_adapter
*adapter
) DECLSPEC_HIDDEN
;
2663 ssize_t
adapter_adjust_mapped_memory(struct wined3d_adapter
*adapter
, ssize_t size
) DECLSPEC_HIDDEN
;
2664 UINT64
adapter_adjust_memory(struct wined3d_adapter
*adapter
, INT64 amount
) DECLSPEC_HIDDEN
;
2666 enum wined3d_projection_type
2668 WINED3D_PROJECTION_NONE
= 0,
2669 WINED3D_PROJECTION_COUNT3
= 1,
2670 WINED3D_PROJECTION_COUNT4
= 2
2673 /*****************************************************************************
2674 * Fixed function pipeline replacements
2676 #define ARG_UNUSED 0xff
2677 struct texture_stage_op
2689 struct color_fixup_desc color_fixup
;
2690 unsigned tex_type
: 3;
2691 unsigned tmp_dst
: 1;
2692 unsigned projected
: 2;
2693 unsigned padding
: 10;
2696 struct ffp_frag_settings
2698 struct texture_stage_op op
[WINED3D_MAX_TEXTURES
];
2699 enum wined3d_ffp_ps_fog_mode fog
;
2700 unsigned char sRGB_write
;
2701 unsigned char emul_clipplanes
;
2702 unsigned char texcoords_initialized
;
2703 unsigned char color_key_enabled
: 1;
2704 unsigned char pointsprite
: 1;
2705 unsigned char flatshading
: 1;
2706 unsigned char alpha_test_func
: 3;
2707 unsigned char padding
: 2;
2710 struct ffp_frag_desc
2712 struct wine_rb_entry entry
;
2713 struct ffp_frag_settings settings
;
2716 int wined3d_ffp_frag_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
2717 int wined3d_ffp_vertex_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
) DECLSPEC_HIDDEN
;
2719 extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN
;
2721 void wined3d_ffp_get_fs_settings(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
2722 struct ffp_frag_settings
*settings
, BOOL ignore_textype
) DECLSPEC_HIDDEN
;
2723 const struct ffp_frag_desc
*find_ffp_frag_shader(const struct wine_rb_tree
*fragment_shaders
,
2724 const struct ffp_frag_settings
*settings
) DECLSPEC_HIDDEN
;
2725 void add_ffp_frag_shader(struct wine_rb_tree
*shaders
, struct ffp_frag_desc
*desc
) DECLSPEC_HIDDEN
;
2726 void wined3d_ftoa(float value
, char *s
) DECLSPEC_HIDDEN
;
2728 enum wined3d_ffp_vs_fog_mode
2730 WINED3D_FFP_VS_FOG_OFF
= 0,
2731 WINED3D_FFP_VS_FOG_FOGCOORD
= 1,
2732 WINED3D_FFP_VS_FOG_DEPTH
= 2,
2733 WINED3D_FFP_VS_FOG_RANGE
= 3,
2736 #define WINED3D_FFP_TCI_SHIFT 16
2737 #define WINED3D_FFP_TCI_MASK 0xffu
2739 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
2740 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
2742 struct wined3d_ffp_vs_settings
2744 DWORD point_light_count
: 4;
2745 DWORD spot_light_count
: 4;
2746 DWORD directional_light_count
: 4;
2747 DWORD parallel_point_light_count
: 4;
2748 DWORD diffuse_source
: 2;
2749 DWORD emissive_source
: 2;
2750 DWORD ambient_source
: 2;
2751 DWORD specular_source
: 2;
2752 DWORD transformed
: 1;
2753 DWORD vertexblends
: 2;
2756 DWORD normalize
: 1;
2758 DWORD localviewer
: 1;
2760 DWORD point_size
: 1;
2761 DWORD per_vertex_point_size
: 1;
2763 DWORD texcoords
: 8; /* WINED3D_MAX_TEXTURES */
2764 DWORD ortho_fog
: 1;
2765 DWORD flatshading
: 1;
2768 DWORD swizzle_map
; /* MAX_ATTRIBS, 32 */
2770 unsigned int texgen
[WINED3D_MAX_TEXTURES
];
2773 struct wined3d_ffp_vs_desc
2775 struct wine_rb_entry entry
;
2776 struct wined3d_ffp_vs_settings settings
;
2779 void wined3d_ffp_get_vs_settings(const struct wined3d_context
*context
,
2780 const struct wined3d_state
*state
, struct wined3d_ffp_vs_settings
*settings
) DECLSPEC_HIDDEN
;
2786 unsigned int adapter_count
;
2787 struct wined3d_adapter
*adapters
[1];
2790 BOOL
wined3d_filter_messages(HWND window
, BOOL filter
) DECLSPEC_HIDDEN
;
2791 HRESULT
wined3d_init(struct wined3d
*wined3d
, uint32_t flags
) DECLSPEC_HIDDEN
;
2792 void wined3d_unregister_window(HWND window
) DECLSPEC_HIDDEN
;
2794 BOOL
wined3d_get_app_name(char *app_name
, unsigned int app_name_size
) DECLSPEC_HIDDEN
;
2796 enum wined3d_push_constants
2798 WINED3D_PUSH_CONSTANTS_VS_F
,
2799 WINED3D_PUSH_CONSTANTS_PS_F
,
2800 WINED3D_PUSH_CONSTANTS_VS_I
,
2801 WINED3D_PUSH_CONSTANTS_PS_I
,
2802 WINED3D_PUSH_CONSTANTS_VS_B
,
2803 WINED3D_PUSH_CONSTANTS_PS_B
,
2804 WINED3D_PUSH_CONSTANTS_COUNT
,
2807 struct wined3d_blend_state
2810 struct wined3d_blend_state_desc desc
;
2814 const struct wined3d_parent_ops
*parent_ops
;
2816 struct wined3d_device
*device
;
2817 struct wine_rb_entry entry
;
2820 static inline unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state
*state
,
2825 if (!state
->desc
.independent
)
2827 return state
->desc
.rt
[index
].writemask
;
2830 struct wined3d_depth_stencil_state
2833 struct wined3d_depth_stencil_state_desc desc
;
2838 const struct wined3d_parent_ops
*parent_ops
;
2840 struct wined3d_device
*device
;
2841 struct wine_rb_entry entry
;
2844 struct wined3d_rasterizer_state
2847 struct wined3d_rasterizer_state_desc desc
;
2850 const struct wined3d_parent_ops
*parent_ops
;
2852 struct wined3d_device
*device
;
2853 struct wine_rb_entry entry
;
2856 struct wined3d_light_state
2858 struct rb_tree lights_tree
;
2859 const struct wined3d_light_info
*lights
[WINED3D_MAX_ACTIVE_LIGHTS
];
2862 #define WINED3D_STATE_NO_REF 0x00000001
2863 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
2865 struct wined3d_state
2867 enum wined3d_feature_level feature_level
;
2869 struct wined3d_fb_state fb
;
2871 struct wined3d_vertex_declaration
*vertex_declaration
;
2872 struct wined3d_stream_output stream_output
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
];
2873 struct wined3d_stream_state streams
[WINED3D_MAX_STREAMS
];
2874 struct wined3d_buffer
*index_buffer
;
2875 enum wined3d_format_id index_format
;
2876 unsigned int index_offset
;
2877 int base_vertex_index
;
2878 int load_base_vertex_index
; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
2879 enum wined3d_primitive_type primitive_type
;
2880 unsigned int patch_vertex_count
;
2881 struct wined3d_query
*predicate
;
2882 BOOL predicate_value
;
2884 struct wined3d_shader
*shader
[WINED3D_SHADER_TYPE_COUNT
];
2885 struct wined3d_constant_buffer_state cb
[WINED3D_SHADER_TYPE_COUNT
][MAX_CONSTANT_BUFFERS
];
2886 struct wined3d_sampler
*sampler
[WINED3D_SHADER_TYPE_COUNT
][MAX_SAMPLER_OBJECTS
];
2887 struct wined3d_shader_resource_view
*shader_resource_view
[WINED3D_SHADER_TYPE_COUNT
][MAX_SHADER_RESOURCE_VIEWS
];
2888 struct wined3d_unordered_access_view
*unordered_access_view
[WINED3D_PIPELINE_COUNT
][MAX_UNORDERED_ACCESS_VIEWS
];
2890 struct wined3d_texture
*textures
[WINED3D_MAX_COMBINED_SAMPLERS
];
2891 uint32_t sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
][WINED3D_HIGHEST_SAMPLER_STATE
+ 1];
2892 uint32_t texture_states
[WINED3D_MAX_TEXTURES
][WINED3D_HIGHEST_TEXTURE_STATE
+ 1];
2894 struct wined3d_matrix transforms
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
2895 struct wined3d_vec4 clip_planes
[WINED3D_MAX_CLIP_DISTANCES
];
2896 struct wined3d_material material
;
2897 struct wined3d_viewport viewports
[WINED3D_MAX_VIEWPORTS
];
2898 unsigned int viewport_count
;
2899 RECT scissor_rects
[WINED3D_MAX_VIEWPORTS
];
2900 unsigned int scissor_rect_count
;
2902 struct wined3d_light_state light_state
;
2904 unsigned int render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
2905 struct wined3d_blend_state
*blend_state
;
2906 struct wined3d_color blend_factor
;
2907 unsigned int sample_mask
;
2908 struct wined3d_depth_stencil_state
*depth_stencil_state
;
2909 unsigned int stencil_ref
;
2910 bool depth_bounds_enable
;
2911 float depth_bounds_min
, depth_bounds_max
;
2912 struct wined3d_rasterizer_state
*rasterizer_state
;
2915 void state_cleanup(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2916 void state_init(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
2917 uint32_t flags
, enum wined3d_feature_level feature_level
) DECLSPEC_HIDDEN
;
2918 void state_unbind_resources(struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
2920 static inline void wined3d_state_reset(struct wined3d_state
*state
, const struct wined3d_d3d_info
*d3d_info
)
2922 enum wined3d_feature_level feature_level
= state
->feature_level
;
2923 uint32_t flags
= state
->flags
;
2925 memset(state
, 0, sizeof(*state
));
2926 state_init(state
, d3d_info
, flags
, feature_level
);
2929 static inline bool wined3d_state_uses_depth_buffer(const struct wined3d_state
*state
)
2931 if (!state
->depth_stencil_state
)
2933 return state
->depth_stencil_state
->desc
.depth
|| state
->depth_stencil_state
->desc
.depth_write
2934 || state
->depth_stencil_state
->desc
.stencil
;
2937 #define WINED3D_UNMAPPED_STAGE ~0u
2939 /* Multithreaded flag. Removed from the public header to signal that
2940 * wined3d_device_create() ignores it. */
2941 #define WINED3DCREATE_MULTITHREADED 0x00000004
2943 struct wined3d_so_desc_entry
2945 struct wine_rb_entry entry
;
2946 struct wined3d_stream_output_desc desc
;
2947 struct wined3d_stream_output_element elements
[1];
2950 struct wined3d_device
2954 /* WineD3D Information */
2955 struct wined3d_device_parent
*device_parent
;
2956 struct wined3d
*wined3d
;
2957 struct wined3d_adapter
*adapter
;
2959 const struct wined3d_shader_backend_ops
*shader_backend
;
2961 void *fragment_priv
;
2963 struct wined3d_state_entry state_table
[STATE_HIGHEST
+ 1];
2964 /* Array of functions for states which are handled by more than one pipeline part */
2965 APPLYSTATEFUNC
*multistate_funcs
[STATE_HIGHEST
+ 1];
2966 struct wined3d_blitter
*blitter
;
2968 BYTE bCursorVisible
: 1;
2969 BYTE d3d_initialized
: 1;
2970 BYTE inScene
: 1; /* A flag to check for proper BeginScene / EndScene call pairs */
2971 BYTE softwareVertexProcessing
: 1; /* process vertex shaders using software or hardware */
2972 BYTE restore_screensaver
: 1;
2975 unsigned char surface_alignment
; /* Line Alignment of surfaces */
2979 /* Internal use fields */
2980 struct wined3d_device_creation_parameters create_parms
;
2983 struct wined3d_rendertarget_view
*back_buffer_view
;
2984 struct wined3d_swapchain
**swapchains
;
2985 UINT swapchain_count
;
2986 unsigned int max_frame_latency
;
2988 struct list resources
; /* a linked list to track resources created by the device */
2989 struct list shaders
; /* a linked list to track shaders (pixel and vertex) */
2990 struct wine_rb_tree so_descs
;
2991 struct wine_rb_tree samplers
, rasterizer_states
, blend_states
, depth_stencil_states
;
2993 /* Render Target Support */
2994 struct wined3d_rendertarget_view
*auto_depth_stencil_view
;
2996 /* Cursor management */
3001 UINT cursorWidth
, cursorHeight
;
3002 struct wined3d_texture
*cursor_texture
;
3003 HCURSOR hardwareCursor
;
3005 /* The Wine logo texture */
3006 struct wined3d_texture
*logo_texture
;
3008 /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3009 struct wined3d_sampler
*default_sampler
;
3010 struct wined3d_sampler
*null_sampler
;
3012 /* Command stream */
3013 struct wined3d_cs
*cs
;
3015 struct wined3d_buffer
*push_constants
[WINED3D_PUSH_CONSTANTS_COUNT
];
3017 /* Context management */
3018 struct wined3d_context
**contexts
;
3021 CRITICAL_SECTION bo_map_lock
;
3024 void wined3d_device_cleanup(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3025 BOOL
device_context_add(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3026 void device_context_remove(struct wined3d_device
*device
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3027 void wined3d_device_create_default_samplers(struct wined3d_device
*device
,
3028 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3029 void wined3d_device_destroy_default_samplers(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3030 HRESULT
wined3d_device_init(struct wined3d_device
*device
, struct wined3d
*wined3d
,
3031 unsigned int adapter_idx
, enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
,
3032 BYTE surface_alignment
, const enum wined3d_feature_level
*levels
, unsigned int level_count
,
3033 const BOOL
*supported_extensions
, struct wined3d_device_parent
*device_parent
) DECLSPEC_HIDDEN
;
3034 LRESULT
device_process_message(struct wined3d_device
*device
, HWND window
, BOOL unicode
,
3035 UINT message
, WPARAM wparam
, LPARAM lparam
, WNDPROC proc
) DECLSPEC_HIDDEN
;
3036 void device_resource_add(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3037 void device_resource_released(struct wined3d_device
*device
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3038 void device_invalidate_state(const struct wined3d_device
*device
, unsigned int state
) DECLSPEC_HIDDEN
;
3039 HRESULT
wined3d_device_set_implicit_swapchain(struct wined3d_device
*device
,
3040 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3041 void wined3d_device_uninit_3d(struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
3043 static inline void wined3d_device_bo_map_lock(struct wined3d_device
*device
)
3045 EnterCriticalSection(&device
->bo_map_lock
);
3048 static inline void wined3d_device_bo_map_unlock(struct wined3d_device
*device
)
3050 LeaveCriticalSection(&device
->bo_map_lock
);
3053 struct wined3d_device_no3d
3055 struct wined3d_device d
;
3057 struct wined3d_context context_no3d
;
3060 static inline struct wined3d_device_no3d
*wined3d_device_no3d(struct wined3d_device
*device
)
3062 return CONTAINING_RECORD(device
, struct wined3d_device_no3d
, d
);
3065 #define WINED3D_ALLOCATOR_CHUNK_SIZE (64 * 1024 * 1024)
3066 #define WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT 15
3067 #define WINED3D_ALLOCATOR_MIN_BLOCK_SIZE (WINED3D_ALLOCATOR_CHUNK_SIZE >> (WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT - 1))
3068 #define WINED3D_SLAB_BO_MIN_OBJECT_ALIGN 16
3069 #define WINED3D_RETIRED_BO_SIZE_THRESHOLD (64 * 1024 * 1024)
3071 struct wined3d_allocator_chunk
3074 struct list available
[WINED3D_ALLOCATOR_CHUNK_ORDER_COUNT
];
3075 struct wined3d_allocator
*allocator
;
3076 unsigned int map_count
;
3080 void wined3d_allocator_chunk_cleanup(struct wined3d_allocator_chunk
*chunk
) DECLSPEC_HIDDEN
;
3081 bool wined3d_allocator_chunk_init(struct wined3d_allocator_chunk
*chunk
,
3082 struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3084 struct wined3d_allocator_block
3087 struct wined3d_allocator_chunk
*chunk
;
3088 struct wined3d_allocator_block
*parent
, *sibling
;
3094 void wined3d_allocator_block_free(struct wined3d_allocator_block
*block
) DECLSPEC_HIDDEN
;
3096 struct wined3d_allocator_pool
3101 struct wined3d_allocator_ops
3103 struct wined3d_allocator_chunk
*(*allocator_create_chunk
)(struct wined3d_allocator
*allocator
,
3104 struct wined3d_context
*context
, unsigned int memory_type
, size_t chunk_size
);
3105 void (*allocator_destroy_chunk
)(struct wined3d_allocator_chunk
*chunk
);
3108 struct wined3d_allocator
3110 const struct wined3d_allocator_ops
*ops
;
3111 struct wined3d_allocator_pool
*pools
;
3113 struct wined3d_allocator_block
*free
;
3116 struct wined3d_allocator_block
*wined3d_allocator_allocate(struct wined3d_allocator
*allocator
,
3117 struct wined3d_context
*context
, unsigned int memory_type
, size_t size
) DECLSPEC_HIDDEN
;
3118 void wined3d_allocator_cleanup(struct wined3d_allocator
*allocator
) DECLSPEC_HIDDEN
;
3119 bool wined3d_allocator_init(struct wined3d_allocator
*allocator
,
3120 size_t pool_count
, const struct wined3d_allocator_ops
*allocator_ops
) DECLSPEC_HIDDEN
;
3122 static inline float wined3d_alpha_ref(const struct wined3d_state
*state
)
3124 return (state
->render_states
[WINED3D_RS_ALPHAREF
] & 0xff) / 255.0f
;
3127 const char *wined3d_debug_resource_access(uint32_t access
) DECLSPEC_HIDDEN
;
3128 const char *wined3d_debug_bind_flags(uint32_t bind_flags
) DECLSPEC_HIDDEN
;
3129 const char *wined3d_debug_view_desc(const struct wined3d_view_desc
*d
,
3130 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3132 static inline ULONG
wined3d_atomic_decrement_mutex_lock(volatile LONG
*refcount
)
3134 ULONG count
, old_count
= *refcount
;
3137 if ((count
= old_count
) == 1)
3139 wined3d_mutex_lock();
3140 count
= InterlockedDecrement(refcount
);
3141 if (count
) wined3d_mutex_unlock();
3145 old_count
= InterlockedCompareExchange(refcount
, count
- 1, count
);
3147 while (old_count
!= count
);
3152 #define CLIENT_BO_DISCARDED ((struct wined3d_bo *)~(UINT_PTR)0)
3154 struct wined3d_client_resource
3156 /* The resource's persistently mapped address, which we may use to perform
3157 * NOOVERWRITE maps from the client thread. */
3158 struct wined3d_bo_address addr
;
3160 /* The currently mapped upload BO, if applicable, and box. */
3161 struct upload_bo mapped_upload
;
3162 struct wined3d_box mapped_box
;
3165 static inline BOOL
wined3d_resource_access_is_managed(unsigned int access
)
3167 return !(~access
& (WINED3D_RESOURCE_ACCESS_GPU
| WINED3D_RESOURCE_ACCESS_CPU
));
3170 struct wined3d_resource_ops
3172 ULONG (*resource_incref
)(struct wined3d_resource
*resource
);
3173 ULONG (*resource_decref
)(struct wined3d_resource
*resource
);
3174 void (*resource_preload
)(struct wined3d_resource
*resource
);
3175 void (*resource_unload
)(struct wined3d_resource
*resource
);
3176 HRESULT (*resource_sub_resource_get_desc
)(struct wined3d_resource
*resource
,
3177 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
);
3178 void (*resource_sub_resource_get_map_pitch
)(struct wined3d_resource
*resource
,
3179 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
);
3180 HRESULT (*resource_sub_resource_map
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3181 void **map_ptr
, const struct wined3d_box
*box
, uint32_t flags
);
3182 HRESULT (*resource_sub_resource_unmap
)(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
);
3185 struct wined3d_resource
3191 struct wined3d_device
*device
;
3192 enum wined3d_resource_type type
;
3193 enum wined3d_gl_resource_type gl_type
;
3194 const struct wined3d_format
*format
;
3195 unsigned int format_attrs
;
3196 unsigned int format_caps
;
3197 enum wined3d_multisample_type multisample_type
;
3198 UINT multisample_quality
;
3200 unsigned int bind_flags
;
3201 unsigned int access
;
3208 unsigned int priority
;
3211 uint32_t pin_sysmem
: 1;
3213 struct wined3d_client_resource client
;
3216 const struct wined3d_parent_ops
*parent_ops
;
3217 const struct wined3d_resource_ops
*resource_ops
;
3219 struct list resource_list_entry
;
3221 LONG srv_bind_count_device
;
3222 LONG rtv_bind_count_device
;
3225 static inline ULONG
wined3d_resource_incref(struct wined3d_resource
*resource
)
3227 return resource
->resource_ops
->resource_incref(resource
);
3230 static inline ULONG
wined3d_resource_decref(struct wined3d_resource
*resource
)
3232 return resource
->resource_ops
->resource_decref(resource
);
3235 static inline HRESULT
wined3d_resource_get_sub_resource_desc(struct wined3d_resource
*resource
,
3236 unsigned int sub_resource_idx
, struct wined3d_sub_resource_desc
*desc
)
3238 return resource
->resource_ops
->resource_sub_resource_get_desc(resource
, sub_resource_idx
, desc
);
3241 static inline void wined3d_resource_get_sub_resource_map_pitch(struct wined3d_resource
*resource
,
3242 unsigned int sub_resource_idx
, unsigned int *row_pitch
, unsigned int *slice_pitch
)
3244 resource
->resource_ops
->resource_sub_resource_get_map_pitch(resource
, sub_resource_idx
, row_pitch
, slice_pitch
);
3247 void resource_cleanup(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3248 HRESULT
resource_init(struct wined3d_resource
*resource
, struct wined3d_device
*device
,
3249 enum wined3d_resource_type type
, const struct wined3d_format
*format
,
3250 enum wined3d_multisample_type multisample_type
, unsigned int multisample_quality
, unsigned int usage
,
3251 unsigned int bind_flags
, unsigned int access
, unsigned int width
, unsigned int height
, unsigned int depth
,
3252 unsigned int size
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
3253 const struct wined3d_resource_ops
*resource_ops
) DECLSPEC_HIDDEN
;
3254 void *resource_offset_map_pointer(struct wined3d_resource
*resource
, unsigned int sub_resource_idx
,
3255 uint8_t *base_memory
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3256 void resource_unload(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3257 HRESULT
wined3d_resource_check_box_dimensions(struct wined3d_resource
*resource
,
3258 unsigned int sub_resource_idx
, const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3259 void wined3d_resource_free_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3260 const struct wined3d_format
*wined3d_resource_get_decompress_format(
3261 const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3262 unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3263 BOOL
wined3d_resource_is_offscreen(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3264 BOOL
wined3d_resource_prepare_sysmem(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3265 void wined3d_resource_update_draw_binding(struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3266 void wined3d_resource_memory_colour_fill(struct wined3d_resource
*resource
,
3267 const struct wined3d_map_desc
*map
, const struct wined3d_color
*colour
,
3268 const struct wined3d_box
*box
, bool full_subresource
) DECLSPEC_HIDDEN
;
3270 /* Tests show that the start address of resources is 32 byte aligned */
3271 #define RESOURCE_ALIGNMENT 16
3272 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3274 #define WINED3D_LOCATION_DISCARDED 0x00000001
3275 #define WINED3D_LOCATION_SYSMEM 0x00000002
3276 #define WINED3D_LOCATION_CLEARED 0x00000004
3277 #define WINED3D_LOCATION_BUFFER 0x00000008
3278 #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3279 #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3280 #define WINED3D_LOCATION_DRAWABLE 0x00000040
3281 #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3282 #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3284 const char *wined3d_debug_location(uint32_t location
) DECLSPEC_HIDDEN
;
3286 struct wined3d_texture_ops
3288 BOOL (*texture_prepare_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3289 struct wined3d_context
*context
, unsigned int location
);
3290 BOOL (*texture_load_location
)(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3291 struct wined3d_context
*context
, unsigned int location
);
3292 void (*texture_unload_location
)(struct wined3d_texture
*texture
,
3293 struct wined3d_context
*context
, unsigned int location
);
3294 void (*texture_upload_data
)(struct wined3d_context
*context
, const struct wined3d_const_bo_address
*src_bo_addr
,
3295 const struct wined3d_format
*src_format
, const struct wined3d_box
*src_box
, unsigned int src_row_pitch
,
3296 unsigned int src_slice_pitch
, struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3297 unsigned int dst_location
, unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
);
3298 void (*texture_download_data
)(struct wined3d_context
*context
, struct wined3d_texture
*src_texture
,
3299 unsigned int src_sub_resource_idx
, unsigned int src_location
, const struct wined3d_box
*src_box
,
3300 const struct wined3d_bo_address
*dst_bo_addr
, const struct wined3d_format
*dst_format
,
3301 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
,
3302 unsigned int dst_row_pitch
, unsigned int dst_slice_pitch
);
3305 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3306 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3307 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3308 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3309 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3310 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3311 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3312 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3313 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3314 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3315 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3316 #define WINED3D_TEXTURE_DISCARD 0x00002000
3317 #define WINED3D_TEXTURE_GET_DC 0x00004000
3318 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3319 #define WINED3D_TEXTURE_DOWNLOADABLE 0x00010000
3321 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3323 struct wined3d_texture
3325 struct wined3d_resource resource
;
3326 const struct wined3d_texture_ops
*texture_ops
;
3327 struct wined3d_swapchain
*swapchain
;
3328 unsigned int pow2_width
;
3329 unsigned int pow2_height
;
3331 unsigned int level_count
;
3332 unsigned int download_count
;
3333 unsigned int sysmem_count
;
3334 float pow2_matrix
[16];
3338 DWORD update_map_binding
;
3340 unsigned int row_pitch
;
3341 unsigned int slice_pitch
;
3343 /* May only be accessed from the command stream worker thread. */
3344 struct wined3d_texture_async
3348 /* Color keys for DDraw */
3349 struct wined3d_color_key dst_blt_color_key
;
3350 struct wined3d_color_key src_blt_color_key
;
3351 struct wined3d_color_key dst_overlay_color_key
;
3352 struct wined3d_color_key src_overlay_color_key
;
3353 struct wined3d_color_key gl_color_key
;
3354 DWORD color_key_flags
;
3357 struct wined3d_dirty_regions
3359 struct wined3d_box
*boxes
;
3361 unsigned int box_count
;
3364 struct wined3d_overlay_info
3367 struct list overlays
;
3368 struct wined3d_texture
*dst_texture
;
3369 unsigned int dst_sub_resource_idx
;
3374 struct wined3d_dc_info
3380 struct wined3d_texture_sub_resource
3383 const struct wined3d_parent_ops
*parent_ops
;
3385 unsigned int offset
;
3388 unsigned int map_count
;
3391 struct wined3d_bo
*bo
;
3394 struct wined3d_color colour
;
3398 unsigned int stencil
;
3406 static inline void *wined3d_texture_allocate_object_memory(SIZE_T s
, SIZE_T level_count
, SIZE_T layer_count
)
3408 struct wined3d_texture
*t
;
3410 if (level_count
> ((~(SIZE_T
)0 - s
) / sizeof(*t
->sub_resources
)) / layer_count
)
3413 return heap_alloc_zero(s
+ level_count
* layer_count
* sizeof(*t
->sub_resources
));
3416 static inline struct wined3d_texture
*texture_from_resource(struct wined3d_resource
*resource
)
3418 return CONTAINING_RECORD(resource
, struct wined3d_texture
, resource
);
3421 static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture
*texture
,
3424 return max(1, texture
->resource
.width
>> level
);
3427 static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture
*texture
,
3430 return max(1, texture
->resource
.height
>> level
);
3433 static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture
*texture
,
3436 return max(1, texture
->resource
.depth
>> level
);
3439 static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture
*texture
,
3442 return max(1, texture
->pow2_width
>> level
);
3445 static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture
*texture
,
3448 return max(1, texture
->pow2_height
>> level
);
3451 static inline void wined3d_texture_get_level_box(const struct wined3d_texture
*texture
,
3452 unsigned int level
, struct wined3d_box
*box
)
3454 wined3d_box_set(box
, 0, 0,
3455 wined3d_texture_get_level_width(texture
, level
),
3456 wined3d_texture_get_level_height(texture
, level
),
3457 0, wined3d_texture_get_level_depth(texture
, level
));
3460 static inline bool wined3d_texture_is_full_rect(const struct wined3d_texture
*texture
,
3461 unsigned int level
, const RECT
*r
)
3465 t
= wined3d_texture_get_level_width(texture
, level
);
3466 if ((r
->left
&& r
->right
) || abs(r
->right
- r
->left
) != t
)
3468 t
= wined3d_texture_get_level_height(texture
, level
);
3469 if ((r
->top
&& r
->bottom
) || abs(r
->bottom
- r
->top
) != t
)
3474 HRESULT
texture2d_blt(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3475 const struct wined3d_box
*dst_box
, struct wined3d_texture
*src_texture
,
3476 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
, uint32_t flags
,
3477 const struct wined3d_blt_fx
*blt_fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
3479 void wined3d_texture_cleanup(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3480 void wined3d_texture_download_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3481 struct wined3d_texture
*src_texture
, unsigned int src_sub_resource_idx
) DECLSPEC_HIDDEN
;
3482 void wined3d_texture_get_bo_address(const struct wined3d_texture
*texture
,
3483 unsigned int sub_resource_idx
, struct wined3d_bo_address
*data
, uint32_t location
) DECLSPEC_HIDDEN
;
3484 void wined3d_texture_invalidate_location(struct wined3d_texture
*texture
,
3485 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
3486 void wined3d_texture_load(struct wined3d_texture
*texture
,
3487 struct wined3d_context
*context
, BOOL srgb
) DECLSPEC_HIDDEN
;
3488 BOOL
wined3d_texture_load_location(struct wined3d_texture
*texture
,
3489 unsigned int sub_resource_idx
, struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3490 BOOL
wined3d_texture_prepare_location(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3491 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3492 void wined3d_texture_set_swapchain(struct wined3d_texture
*texture
,
3493 struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
3494 BOOL
wined3d_texture_can_use_pbo(const struct wined3d_texture
*texture
, const struct wined3d_d3d_info
*d3d_info
)
3496 void wined3d_texture_sub_resources_destroyed(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3497 void wined3d_texture_translate_drawable_coords(const struct wined3d_texture
*texture
,
3498 HWND window
, RECT
*rect
) DECLSPEC_HIDDEN
;
3499 void wined3d_texture_update_sub_resource(struct wined3d_texture
*texture
, unsigned int sub_resource_idx
,
3500 struct wined3d_context
*context
, const struct upload_bo
*upload_bo
, const struct wined3d_box
*box
,
3501 unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
3502 void wined3d_texture_upload_from_texture(struct wined3d_texture
*dst_texture
, unsigned int dst_sub_resource_idx
,
3503 unsigned int dst_x
, unsigned int dst_y
, unsigned int dst_z
, struct wined3d_texture
*src_texture
,
3504 unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
) DECLSPEC_HIDDEN
;
3505 void wined3d_texture_validate_location(struct wined3d_texture
*texture
,
3506 unsigned int sub_resource_idx
, uint32_t location
) DECLSPEC_HIDDEN
;
3507 bool wined3d_texture_validate_sub_resource_idx(const struct wined3d_texture
*texture
,
3508 unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
3509 void wined3d_texture_clear_dirty_regions(struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3511 HRESULT
wined3d_texture_no3d_init(struct wined3d_texture
*texture_no3d
, struct wined3d_device
*device
,
3512 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
3513 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3515 struct wined3d_sampler
3517 struct wine_rb_entry entry
;
3519 struct wined3d_device
*device
;
3521 const struct wined3d_parent_ops
*parent_ops
;
3522 struct wined3d_sampler_desc desc
;
3525 struct wined3d_vertex_declaration_element
3527 const struct wined3d_format
*format
;
3529 unsigned int input_slot
;
3530 unsigned int offset
;
3531 unsigned int output_slot
;
3532 enum wined3d_input_classification input_slot_class
;
3533 unsigned int instance_data_step_rate
;
3539 struct wined3d_vertex_declaration
3543 const struct wined3d_parent_ops
*parent_ops
;
3544 struct wined3d_device
*device
;
3546 struct wined3d_vertex_declaration_element
*elements
;
3547 unsigned int element_count
;
3549 BOOL position_transformed
;
3552 struct wined3d_saved_states
3554 uint32_t vs_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_VS_CONSTS_F
)];
3555 WORD vertexShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
3556 WORD vertexShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
3557 uint32_t ps_consts_f
[WINED3D_BITMAP_SIZE(WINED3D_MAX_PS_CONSTS_F
)];
3558 WORD pixelShaderConstantsI
; /* WINED3D_MAX_CONSTS_I, 16 */
3559 WORD pixelShaderConstantsB
; /* WINED3D_MAX_CONSTS_B, 16 */
3560 uint32_t transform
[WINED3D_BITMAP_SIZE(WINED3D_HIGHEST_TRANSFORM_STATE
+ 1)];
3561 WORD streamSource
; /* WINED3D_MAX_STREAMS, 16 */
3562 WORD streamFreq
; /* WINED3D_MAX_STREAMS, 16 */
3563 uint32_t renderState
[WINED3D_BITMAP_SIZE(WINEHIGHEST_RENDER_STATE
+ 1)];
3564 DWORD textureState
[WINED3D_MAX_TEXTURES
]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
3565 WORD samplerState
[WINED3D_MAX_COMBINED_SAMPLERS
]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
3566 DWORD clipplane
; /* WINED3D_MAX_CLIP_DISTANCES, 8 */
3567 DWORD textures
: 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */
3571 DWORD vertexDecl
: 1;
3572 DWORD pixelShader
: 1;
3573 DWORD vertexShader
: 1;
3574 DWORD scissorRect
: 1;
3575 DWORD store_stream_offset
: 1;
3576 DWORD alpha_to_coverage
: 1;
3578 DWORD transforms
: 1;
3581 struct list changed_lights
;
3589 struct wined3d_stateblock
3591 LONG ref
; /* Note: Ref counting not required */
3592 struct wined3d_device
*device
;
3594 /* Array indicating whether things have been set or changed */
3595 struct wined3d_saved_states changed
;
3597 struct wined3d_stateblock_state stateblock_state
;
3598 struct wined3d_light_state light_state
;
3600 /* Contained state management */
3601 DWORD contained_render_states
[WINEHIGHEST_RENDER_STATE
+ 1];
3602 unsigned int num_contained_render_states
;
3603 DWORD contained_transform_states
[WINED3D_HIGHEST_TRANSFORM_STATE
+ 1];
3604 unsigned int num_contained_transform_states
;
3605 struct StageState contained_tss_states
[WINED3D_MAX_TEXTURES
* (WINED3D_HIGHEST_TEXTURE_STATE
+ 1)];
3606 unsigned int num_contained_tss_states
;
3607 struct StageState contained_sampler_states
[WINED3D_MAX_COMBINED_SAMPLERS
* WINED3D_HIGHEST_SAMPLER_STATE
];
3608 unsigned int num_contained_sampler_states
;
3611 void wined3d_stateblock_state_init(struct wined3d_stateblock_state
*state
,
3612 const struct wined3d_device
*device
, uint32_t flags
) DECLSPEC_HIDDEN
;
3613 void wined3d_stateblock_state_cleanup(struct wined3d_stateblock_state
*state
) DECLSPEC_HIDDEN
;
3615 bool wined3d_light_state_enable_light(struct wined3d_light_state
*state
, const struct wined3d_d3d_info
*d3d_info
,
3616 struct wined3d_light_info
*light_info
, BOOL enable
) DECLSPEC_HIDDEN
;
3617 struct wined3d_light_info
*wined3d_light_state_get_light(const struct wined3d_light_state
*state
,
3618 unsigned int idx
) DECLSPEC_HIDDEN
;
3619 HRESULT
wined3d_light_state_set_light(struct wined3d_light_state
*state
, DWORD light_idx
,
3620 const struct wined3d_light
*params
, struct wined3d_light_info
**light_info
) DECLSPEC_HIDDEN
;
3622 enum wined3d_cs_queue_id
3624 WINED3D_CS_QUEUE_DEFAULT
= 0,
3625 WINED3D_CS_QUEUE_MAP
,
3626 WINED3D_CS_QUEUE_COUNT
,
3629 #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
3631 #define WINED3D_CS_QUEUE_SIZE 0x1000000u
3633 #define WINED3D_CS_QUEUE_SIZE 0x400000u
3635 #define WINED3D_CS_SPIN_COUNT 2000u
3636 #define WINED3D_CS_QUEUE_MASK (WINED3D_CS_QUEUE_SIZE - 1)
3638 C_ASSERT(!(WINED3D_CS_QUEUE_SIZE
& (WINED3D_CS_QUEUE_SIZE
- 1)));
3640 struct wined3d_cs_queue
3643 BYTE data
[WINED3D_CS_QUEUE_SIZE
];
3646 struct wined3d_device_context_ops
3648 void *(*require_space
)(struct wined3d_device_context
*context
, size_t size
, enum wined3d_cs_queue_id queue_id
);
3649 void (*submit
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
3650 void (*finish
)(struct wined3d_device_context
*context
, enum wined3d_cs_queue_id queue_id
);
3651 bool (*map_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
3652 unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
3653 const struct wined3d_box
*box
, uint32_t flags
);
3654 bool (*unmap_upload_bo
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
,
3655 unsigned int sub_resource_idx
, struct wined3d_box
*box
, struct upload_bo
*upload_bo
);
3656 void (*issue_query
)(struct wined3d_device_context
*context
, struct wined3d_query
*query
, unsigned int flags
);
3657 void (*flush
)(struct wined3d_device_context
*context
);
3658 void (*reference_resource
)(struct wined3d_device_context
*context
, struct wined3d_resource
*resource
);
3659 void (*reference_command_list
)(struct wined3d_device_context
*context
, struct wined3d_command_list
*list
);
3662 struct wined3d_device_context
3664 const struct wined3d_device_context_ops
*ops
;
3665 struct wined3d_device
*device
;
3666 struct wined3d_state
*state
;
3671 struct wined3d_device_context c
;
3673 struct wined3d_state state
;
3674 HMODULE wined3d_module
;
3677 BOOL serialize_commands
;
3679 struct wined3d_cs_queue queue
[WINED3D_CS_QUEUE_COUNT
];
3680 size_t data_size
, start
, end
;
3682 struct list query_poll_list
;
3683 BOOL queries_flushed
;
3685 HANDLE event
, present_event
;
3686 LONG waiting_for_event
;
3687 LONG waiting_for_present
;
3688 LONG pending_presents
;
3691 static inline void wined3d_device_context_lock(struct wined3d_device_context
*context
)
3693 if (context
== &context
->device
->cs
->c
)
3694 wined3d_mutex_lock();
3697 static inline void wined3d_device_context_unlock(struct wined3d_device_context
*context
)
3699 if (context
== &context
->device
->cs
->c
)
3700 wined3d_mutex_unlock();
3703 struct wined3d_cs
*wined3d_cs_create(struct wined3d_device
*device
,
3704 const enum wined3d_feature_level
*levels
, unsigned int level_count
) DECLSPEC_HIDDEN
;
3705 void wined3d_cs_destroy(struct wined3d_cs
*cs
) DECLSPEC_HIDDEN
;
3706 void wined3d_cs_destroy_object(struct wined3d_cs
*cs
,
3707 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
3708 void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs
*cs
,
3709 struct wined3d_texture
*texture
, unsigned int layer
) DECLSPEC_HIDDEN
;
3710 void wined3d_cs_emit_clear(struct wined3d_cs
*cs
, DWORD rect_count
, const RECT
*rects
,
3711 uint32_t flags
, const struct wined3d_color
*color
, float depth
, DWORD stencil
) DECLSPEC_HIDDEN
;
3712 void wined3d_device_context_emit_clear_uav(struct wined3d_device_context
*context
,
3713 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
) DECLSPEC_HIDDEN
;
3714 void wined3d_cs_emit_preload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3715 void wined3d_cs_emit_present(struct wined3d_cs
*cs
, struct wined3d_swapchain
*swapchain
, const RECT
*src_rect
,
3716 const RECT
*dst_rect
, HWND dst_window_override
, unsigned int swap_interval
, uint32_t flags
) DECLSPEC_HIDDEN
;
3717 void wined3d_cs_emit_set_color_key(struct wined3d_cs
*cs
, struct wined3d_texture
*texture
,
3718 WORD flags
, const struct wined3d_color_key
*color_key
) DECLSPEC_HIDDEN
;
3719 void wined3d_cs_emit_set_render_state(struct wined3d_cs
*cs
,
3720 enum wined3d_render_state state
, DWORD value
) DECLSPEC_HIDDEN
;
3721 void wined3d_cs_emit_unload_resource(struct wined3d_cs
*cs
, struct wined3d_resource
*resource
) DECLSPEC_HIDDEN
;
3722 void wined3d_cs_init_object(struct wined3d_cs
*cs
,
3723 void (*callback
)(void *object
), void *object
) DECLSPEC_HIDDEN
;
3724 void wined3d_cs_map_bo_address(struct wined3d_cs
*cs
,
3725 struct wined3d_bo_address
*addr
, size_t size
, unsigned int flags
) DECLSPEC_HIDDEN
;
3726 void wined3d_device_context_set_depth_bounds(struct wined3d_device_context
*context
,
3727 bool enable
, float min_depth
, float max_depth
);
3729 static inline void wined3d_cs_finish(struct wined3d_cs
*cs
, enum wined3d_cs_queue_id queue_id
)
3731 cs
->c
.ops
->finish(&cs
->c
, queue_id
);
3734 void wined3d_device_context_emit_blt_sub_resource(struct wined3d_device_context
*context
,
3735 struct wined3d_resource
*dst_resource
, unsigned int dst_sub_resource_idx
, const struct wined3d_box
*dst_box
,
3736 struct wined3d_resource
*src_resource
, unsigned int src_sub_resource_idx
, const struct wined3d_box
*src_box
,
3737 unsigned int flags
, const struct wined3d_blt_fx
*fx
, enum wined3d_texture_filter_type filter
) DECLSPEC_HIDDEN
;
3738 void wined3d_device_context_emit_clear_rendertarget_view(struct wined3d_device_context
*context
,
3739 struct wined3d_rendertarget_view
*view
, const RECT
*rect
, unsigned int flags
,
3740 const struct wined3d_color
*color
, float depth
, unsigned int stencil
) DECLSPEC_HIDDEN
;
3741 void wined3d_device_context_emit_copy_uav_counter(struct wined3d_device_context
*context
,
3742 struct wined3d_buffer
*dst_buffer
, unsigned int offset
,
3743 struct wined3d_unordered_access_view
*uav
) DECLSPEC_HIDDEN
;
3744 void wined3d_device_context_emit_draw(struct wined3d_device_context
*context
,
3745 enum wined3d_primitive_type primitive_type
, unsigned int patch_vertex_count
, int base_vertex_idx
,
3746 unsigned int start_idx
, unsigned int index_count
, unsigned int start_instance
, unsigned int instance_count
,
3747 bool indexed
) DECLSPEC_HIDDEN
;
3748 void wined3d_device_context_emit_execute_command_list(struct wined3d_device_context
*context
,
3749 struct wined3d_command_list
*list
, bool restore_state
) DECLSPEC_HIDDEN
;
3750 void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context
*context
,
3751 struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
3752 HRESULT
wined3d_device_context_emit_map(struct wined3d_device_context
*context
,
3753 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, struct wined3d_map_desc
*map_desc
,
3754 const struct wined3d_box
*box
, unsigned int flags
) DECLSPEC_HIDDEN
;
3755 void wined3d_device_context_emit_reset_state(struct wined3d_device_context
*context
, bool invalidate
) DECLSPEC_HIDDEN
;
3756 void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context
*context
,
3757 struct wined3d_blend_state
*state
, const struct wined3d_color
*blend_factor
,
3758 unsigned int sample_mask
) DECLSPEC_HIDDEN
;
3759 void wined3d_device_context_emit_set_clip_plane(struct wined3d_device_context
*context
, unsigned int plane_idx
,
3760 const struct wined3d_vec4
*plane
) DECLSPEC_HIDDEN
;
3761 void wined3d_device_context_emit_set_constant_buffers(struct wined3d_device_context
*context
,
3762 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
3763 const struct wined3d_constant_buffer_state
*buffers
) DECLSPEC_HIDDEN
;
3764 void wined3d_device_context_emit_set_depth_stencil_state(struct wined3d_device_context
*context
,
3765 struct wined3d_depth_stencil_state
*state
, unsigned int stencil_ref
) DECLSPEC_HIDDEN
;
3766 void wined3d_device_context_emit_set_depth_stencil_view(struct wined3d_device_context
*context
,
3767 struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
3768 void wined3d_device_context_emit_set_feature_level(struct wined3d_device_context
*context
,
3769 enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
3770 void wined3d_device_context_emit_set_index_buffer(struct wined3d_device_context
*context
, struct wined3d_buffer
*buffer
,
3771 enum wined3d_format_id format_id
, unsigned int offset
) DECLSPEC_HIDDEN
;
3772 void wined3d_device_context_emit_set_light(struct wined3d_device_context
*context
,
3773 const struct wined3d_light_info
*light
) DECLSPEC_HIDDEN
;
3774 void wined3d_device_context_emit_set_light_enable(struct wined3d_device_context
*context
, unsigned int idx
,
3775 BOOL enable
) DECLSPEC_HIDDEN
;
3776 void wined3d_device_context_emit_set_material(struct wined3d_device_context
*context
,
3777 const struct wined3d_material
*material
) DECLSPEC_HIDDEN
;
3778 void wined3d_device_context_emit_set_predication(struct wined3d_device_context
*context
,
3779 struct wined3d_query
*predicate
, BOOL value
) DECLSPEC_HIDDEN
;
3780 void wined3d_device_context_emit_set_rasterizer_state(struct wined3d_device_context
*context
,
3781 struct wined3d_rasterizer_state
*rasterizer_state
) DECLSPEC_HIDDEN
;
3782 void wined3d_device_context_emit_set_render_state(struct wined3d_device_context
*context
,
3783 enum wined3d_render_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
3784 void wined3d_device_context_emit_set_rendertarget_views(struct wined3d_device_context
*context
, unsigned int start_idx
,
3785 unsigned int count
, struct wined3d_rendertarget_view
*const *views
) DECLSPEC_HIDDEN
;
3786 void wined3d_device_context_emit_set_samplers(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
3787 unsigned int start_idx
, unsigned int count
, struct wined3d_sampler
*const *samplers
) DECLSPEC_HIDDEN
;
3788 void wined3d_device_context_emit_set_sampler_state(struct wined3d_device_context
*context
, unsigned int sampler_idx
,
3789 enum wined3d_sampler_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
3790 void wined3d_device_context_emit_set_scissor_rects(struct wined3d_device_context
*context
,
3791 unsigned int rect_count
, const RECT
*rects
) DECLSPEC_HIDDEN
;
3792 void wined3d_device_context_emit_set_shader(struct wined3d_device_context
*context
, enum wined3d_shader_type type
,
3793 struct wined3d_shader
*shader
) DECLSPEC_HIDDEN
;
3794 void wined3d_device_context_emit_set_shader_resource_views(struct wined3d_device_context
*context
,
3795 enum wined3d_shader_type type
, unsigned int start_idx
, unsigned int count
,
3796 struct wined3d_shader_resource_view
*const *views
) DECLSPEC_HIDDEN
;
3797 void wined3d_device_context_emit_set_stream_outputs(struct wined3d_device_context
*context
,
3798 const struct wined3d_stream_output outputs
[WINED3D_MAX_STREAM_OUTPUT_BUFFERS
]) DECLSPEC_HIDDEN
;
3799 void wined3d_device_context_emit_set_stream_sources(struct wined3d_device_context
*context
,
3800 unsigned int start_idx
, unsigned int count
, const struct wined3d_stream_state
*streams
) DECLSPEC_HIDDEN
;
3801 void wined3d_device_context_emit_set_texture(struct wined3d_device_context
*context
, unsigned int stage
,
3802 struct wined3d_texture
*texture
) DECLSPEC_HIDDEN
;
3803 void wined3d_device_context_emit_set_texture_state(struct wined3d_device_context
*context
, unsigned int stage
,
3804 enum wined3d_texture_stage_state state
, unsigned int value
) DECLSPEC_HIDDEN
;
3805 void wined3d_device_context_emit_set_transform(struct wined3d_device_context
*context
,
3806 enum wined3d_transform_state state
, const struct wined3d_matrix
*matrix
) DECLSPEC_HIDDEN
;
3807 void wined3d_device_context_emit_set_unordered_access_views(struct wined3d_device_context
*context
,
3808 enum wined3d_pipeline pipeline
, unsigned int start_idx
, unsigned int count
,
3809 struct wined3d_unordered_access_view
*const *views
, const unsigned int *initial_count
) DECLSPEC_HIDDEN
;
3810 void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_context
*context
,
3811 struct wined3d_vertex_declaration
*declaration
) DECLSPEC_HIDDEN
;
3812 void wined3d_device_context_emit_set_viewports(struct wined3d_device_context
*context
, unsigned int viewport_count
,
3813 const struct wined3d_viewport
*viewports
) DECLSPEC_HIDDEN
;
3814 void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context
*context
,
3815 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
, const struct wined3d_box
*box
,
3816 const void *data
, unsigned int row_pitch
, unsigned int slice_pitch
) DECLSPEC_HIDDEN
;
3817 HRESULT
wined3d_device_context_emit_unmap(struct wined3d_device_context
*context
,
3818 struct wined3d_resource
*resource
, unsigned int sub_resource_idx
) DECLSPEC_HIDDEN
;
3819 void wined3d_device_context_push_constants(struct wined3d_device_context
*context
,
3820 enum wined3d_push_constants type
, unsigned int start_idx
,
3821 unsigned int count
, const void *constants
) DECLSPEC_HIDDEN
;
3823 static inline void wined3d_resource_reference(struct wined3d_resource
*resource
)
3825 const struct wined3d_cs
*cs
= resource
->device
->cs
;
3826 resource
->access_time
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
3829 static inline BOOL
wined3d_ge_wrap(ULONG x
, ULONG y
)
3831 return (x
- y
) < UINT_MAX
/ 2;
3833 C_ASSERT(WINED3D_CS_QUEUE_SIZE
< UINT_MAX
/ 4);
3835 static inline void wined3d_resource_wait_idle(const struct wined3d_resource
*resource
)
3837 const struct wined3d_cs
*cs
= resource
->device
->cs
;
3838 ULONG access_time
, tail
, head
;
3840 if (!cs
->thread
|| cs
->thread_id
== GetCurrentThreadId())
3843 access_time
= resource
->access_time
;
3844 head
= cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].head
;
3846 /* The basic idea is that a resource is busy if tail < access_time <= head.
3847 * But we have to be careful about wrap-around of the head and tail. The
3848 * wined3d_ge_wrap function considers x >= y if x - y is smaller than half the
3849 * UINT range. Head is at most WINED3D_CS_QUEUE_SIZE ahead of tail, because
3850 * otherwise the queue memory is considered full and queue_require_space
3851 * stalls. Thus wined3d_ge_wrap(head, tail) is always true. The C_ASSERT above
3852 * ensures this in case we decide to grow the queue size in the future.
3854 * It is possible that a resource has not been used for a long time and is idle, but the head and
3855 * tail wrapped around in such a way that the previously set access time falls between head and tail.
3856 * In this case we will incorrectly wait for the resource. Because we use the entire 32 bits of the
3857 * counters and not just the bits needed to address the actual queue memory, this should happen rarely.
3858 * If it turns out to be a problem we can switch to 64 bit counters or attempt to somehow mark the
3859 * access time of resources invalid. CS packets are at least 4 byte aligned, so we could use the lower
3860 * 2 bits in access_time for such a marker.
3862 * Note that the access time is set before the command is submitted, so we have to wait until the
3863 * tail is bigger than access_time, not equal. */
3865 if (!wined3d_ge_wrap(head
, access_time
))
3870 tail
= *(volatile ULONG
*)&cs
->queue
[WINED3D_CS_QUEUE_DEFAULT
].tail
;
3871 if (head
== tail
) /* Queue empty. */
3874 if (!wined3d_ge_wrap(access_time
, tail
) && access_time
!= tail
)
3881 /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
3882 * fixed function semantics as D3DCOLOR or FLOAT16 */
3883 enum wined3d_buffer_conversion_type
3890 struct wined3d_buffer
3892 struct wined3d_resource resource
;
3893 const struct wined3d_buffer_ops
*buffer_ops
;
3895 unsigned int structure_byte_stride
;
3899 struct wined3d_bo
*buffer_object
;
3900 struct wined3d_bo_user bo_user
;
3902 struct wined3d_range
*maps
;
3903 SIZE_T maps_size
, modified_areas
;
3905 /* conversion stuff */
3906 UINT decl_change_count
, full_conversion_count
;
3908 UINT stride
; /* 0 if no conversion */
3909 enum wined3d_buffer_conversion_type
*conversion_map
; /* NULL if no conversion */
3910 UINT conversion_stride
; /* 0 if no shifted conversion */
3913 static inline struct wined3d_buffer
*buffer_from_resource(struct wined3d_resource
*resource
)
3915 return CONTAINING_RECORD(resource
, struct wined3d_buffer
, resource
);
3918 static inline void wined3d_buffer_validate_user(struct wined3d_buffer
*buffer
)
3920 if (buffer
->bo_user
.valid
)
3922 buffer
->bo_user
.valid
= true;
3923 list_add_head(&buffer
->buffer_object
->users
, &buffer
->bo_user
.entry
);
3926 void wined3d_buffer_acquire_bo_for_write(struct wined3d_buffer
*buffer
,
3927 struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3928 void wined3d_buffer_cleanup(struct wined3d_buffer
*buffer
) DECLSPEC_HIDDEN
;
3929 void wined3d_buffer_copy(struct wined3d_buffer
*dst_buffer
, unsigned int dst_offset
,
3930 struct wined3d_buffer
*src_buffer
, unsigned int src_offset
, unsigned int size
) DECLSPEC_HIDDEN
;
3931 void wined3d_buffer_copy_bo_address(struct wined3d_buffer
*dst_buffer
, struct wined3d_context
*context
,
3932 unsigned int dst_offset
, const struct wined3d_const_bo_address
*src_addr
, unsigned int size
) DECLSPEC_HIDDEN
;
3933 DWORD
wined3d_buffer_get_memory(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
3934 struct wined3d_bo_address
*data
) DECLSPEC_HIDDEN
;
3935 void wined3d_buffer_invalidate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
3936 void wined3d_buffer_load(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
3937 const struct wined3d_state
*state
) DECLSPEC_HIDDEN
;
3938 BOOL
wined3d_buffer_load_location(struct wined3d_buffer
*buffer
,
3939 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3940 void *wined3d_buffer_load_sysmem(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
3941 BOOL
wined3d_buffer_prepare_location(struct wined3d_buffer
*buffer
,
3942 struct wined3d_context
*context
, unsigned int location
) DECLSPEC_HIDDEN
;
3943 void wined3d_buffer_update_sub_resource(struct wined3d_buffer
*buffer
, struct wined3d_context
*context
,
3944 const struct upload_bo
*upload_bo
, unsigned int offset
, unsigned int size
) DECLSPEC_HIDDEN
;
3945 void wined3d_buffer_validate_location(struct wined3d_buffer
*buffer
, uint32_t location
) DECLSPEC_HIDDEN
;
3947 HRESULT
wined3d_buffer_no3d_init(struct wined3d_buffer
*buffer_no3d
, struct wined3d_device
*device
,
3948 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
3949 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3951 struct wined3d_rendertarget_view
3955 struct wined3d_resource
*resource
;
3957 const struct wined3d_parent_ops
*parent_ops
;
3959 const struct wined3d_format
*format
;
3960 unsigned int format_attrs
;
3961 unsigned int format_caps
;
3962 unsigned int sub_resource_idx
;
3963 unsigned int layer_count
;
3966 unsigned int height
;
3968 struct wined3d_view_desc desc
;
3971 void wined3d_rendertarget_view_cleanup(struct wined3d_rendertarget_view
*view
) DECLSPEC_HIDDEN
;
3972 void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view
*view
,
3973 const struct wined3d_context
*context
, unsigned int *width
, unsigned int *height
) DECLSPEC_HIDDEN
;
3974 void wined3d_rendertarget_view_get_box(struct wined3d_rendertarget_view
*view
,
3975 struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
3976 void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view
*view
,
3977 uint32_t location
) DECLSPEC_HIDDEN
;
3978 void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view
*view
,
3979 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3980 void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view
*view
,
3981 struct wined3d_context
*context
, uint32_t location
) DECLSPEC_HIDDEN
;
3982 void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view
*view
,
3983 uint32_t location
) DECLSPEC_HIDDEN
;
3984 DWORD
wined3d_rendertarget_view_get_locations(const struct wined3d_rendertarget_view
*view
)
3987 HRESULT
wined3d_rendertarget_view_no3d_init(struct wined3d_rendertarget_view
*view_no3d
,
3988 const struct wined3d_view_desc
*desc
, struct wined3d_resource
*resource
,
3989 void *parent
, const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
3991 struct wined3d_shader_resource_view
3995 struct wined3d_resource
*resource
;
3997 const struct wined3d_parent_ops
*parent_ops
;
3999 const struct wined3d_format
*format
;
4001 struct wined3d_view_desc desc
;
4004 void wined3d_shader_resource_view_cleanup(struct wined3d_shader_resource_view
*view
) DECLSPEC_HIDDEN
;
4006 struct wined3d_unordered_access_view
4010 struct wined3d_resource
*resource
;
4012 const struct wined3d_parent_ops
*parent_ops
;
4014 const struct wined3d_format
*format
;
4016 struct wined3d_view_desc desc
;
4017 struct wined3d_bo
*counter_bo
;
4020 void wined3d_unordered_access_view_cleanup(struct wined3d_unordered_access_view
*view
) DECLSPEC_HIDDEN
;
4021 void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view
*view
,
4022 struct wined3d_buffer
*buffer
, unsigned int offset
, struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4023 void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view
*view
,
4024 uint32_t location
) DECLSPEC_HIDDEN
;
4025 void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view
*view
,
4026 unsigned int value
) DECLSPEC_HIDDEN
;
4028 struct wined3d_swapchain_state
4030 struct wined3d
*wined3d
;
4031 struct wined3d_swapchain_desc desc
;
4032 struct wined3d_swapchain_state_parent
*parent
;
4034 struct wined3d_display_mode original_mode
, d3d_mode
;
4035 RECT original_window_rect
;
4037 /* Window styles to restore when switching fullscreen mode. */
4043 void wined3d_swapchain_state_cleanup(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
4044 void wined3d_swapchain_state_register(struct wined3d_swapchain_state
*state
) DECLSPEC_HIDDEN
;
4045 void wined3d_swapchain_state_restore_from_fullscreen(struct wined3d_swapchain_state
*state
,
4046 HWND window
, const RECT
*window_rect
) DECLSPEC_HIDDEN
;
4047 HRESULT
wined3d_swapchain_state_setup_fullscreen(struct wined3d_swapchain_state
*state
,
4048 HWND window
, int x
, int y
, int width
, int height
) DECLSPEC_HIDDEN
;
4050 struct wined3d_swapchain_ops
4052 void (*swapchain_present
)(struct wined3d_swapchain
*swapchain
,
4053 const RECT
*src_rect
, const RECT
*dst_rect
, unsigned int swap_interval
, uint32_t flags
);
4054 void (*swapchain_frontbuffer_updated
)(struct wined3d_swapchain
*swapchain
);
4057 struct wined3d_swapchain
4061 const struct wined3d_parent_ops
*parent_ops
;
4062 const struct wined3d_swapchain_ops
*swapchain_ops
;
4063 struct wined3d_device
*device
;
4065 struct wined3d_texture
**back_buffers
;
4066 struct wined3d_texture
*front_buffer
;
4067 struct wined3d_gamma_ramp orig_gamma
;
4069 const struct wined3d_format
*ds_format
;
4070 struct wined3d_palette
*palette
;
4071 RECT front_buffer_update
;
4072 unsigned int swap_interval
;
4073 unsigned int max_frame_latency
;
4075 LONG prev_time
, frames
; /* Performance tracking */
4077 struct wined3d_swapchain_state state
;
4081 void wined3d_swapchain_activate(struct wined3d_swapchain
*swapchain
, BOOL activate
) DECLSPEC_HIDDEN
;
4082 void wined3d_swapchain_cleanup(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4083 struct wined3d_output
* wined3d_swapchain_get_output(const struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4084 void swapchain_update_draw_bindings(struct wined3d_swapchain
*swapchain
) DECLSPEC_HIDDEN
;
4085 void swapchain_set_max_frame_latency(struct wined3d_swapchain
*swapchain
,
4086 const struct wined3d_device
*device
) DECLSPEC_HIDDEN
;
4088 HRESULT
wined3d_swapchain_no3d_init(struct wined3d_swapchain
*swapchain_no3d
,
4089 struct wined3d_device
*device
, const struct wined3d_swapchain_desc
*desc
,
4090 struct wined3d_swapchain_state_parent
*state_parent
, void *parent
,
4091 const struct wined3d_parent_ops
*parent_ops
) DECLSPEC_HIDDEN
;
4093 /*****************************************************************************
4094 * Utility function prototypes
4097 /* Trace routines */
4098 const char *debug_bo_address(const struct wined3d_bo_address
*address
) DECLSPEC_HIDDEN
;
4099 const char *debug_box(const struct wined3d_box
*box
) DECLSPEC_HIDDEN
;
4100 const char *debug_color(const struct wined3d_color
*color
) DECLSPEC_HIDDEN
;
4101 const char *debug_const_bo_address(const struct wined3d_const_bo_address
*address
) DECLSPEC_HIDDEN
;
4102 const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
) DECLSPEC_HIDDEN
;
4103 const char *debug_d3dformat(enum wined3d_format_id format_id
) DECLSPEC_HIDDEN
;
4104 const char *debug_d3ddevicetype(enum wined3d_device_type device_type
) DECLSPEC_HIDDEN
;
4105 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type
) DECLSPEC_HIDDEN
;
4106 const char *debug_d3dusage(uint32_t usage
) DECLSPEC_HIDDEN
;
4107 const char *debug_d3ddeclmethod(enum wined3d_decl_method method
) DECLSPEC_HIDDEN
;
4108 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
4109 const char *debug_d3dinput_classification(enum wined3d_input_classification classification
) DECLSPEC_HIDDEN
;
4110 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type
) DECLSPEC_HIDDEN
;
4111 const char *debug_d3drenderstate(enum wined3d_render_state state
) DECLSPEC_HIDDEN
;
4112 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state
) DECLSPEC_HIDDEN
;
4113 const char *debug_d3dstate(uint32_t state
) DECLSPEC_HIDDEN
;
4114 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type
) DECLSPEC_HIDDEN
;
4115 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state
) DECLSPEC_HIDDEN
;
4116 const char *debug_d3dtop(enum wined3d_texture_op d3dtop
) DECLSPEC_HIDDEN
;
4117 const char *debug_d3dtstype(enum wined3d_transform_state tstype
) DECLSPEC_HIDDEN
;
4118 const char *debug_ivec4(const struct wined3d_ivec4
*v
) DECLSPEC_HIDDEN
;
4119 const char *debug_uvec4(const struct wined3d_uvec4
*v
) DECLSPEC_HIDDEN
;
4120 const char *debug_shader_type(enum wined3d_shader_type shader_type
) DECLSPEC_HIDDEN
;
4121 const char *debug_vec4(const struct wined3d_vec4
*v
) DECLSPEC_HIDDEN
;
4122 const char *wined3d_debug_feature_level(enum wined3d_feature_level level
) DECLSPEC_HIDDEN
;
4123 void dump_color_fixup_desc(struct color_fixup_desc fixup
) DECLSPEC_HIDDEN
;
4125 BOOL
is_invalid_op(const struct wined3d_state
*state
, int stage
,
4126 enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
) DECLSPEC_HIDDEN
;
4127 void sampler_texdim(struct wined3d_context
*context
,
4128 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4129 void tex_alphaop(struct wined3d_context
*context
,
4130 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4131 void apply_pixelshader(struct wined3d_context
*context
,
4132 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4133 void state_alpha_test(struct wined3d_context
*context
,
4134 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4135 void state_fogcolor(struct wined3d_context
*context
,
4136 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4137 void state_fogdensity(struct wined3d_context
*context
,
4138 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4139 void state_fogstartend(struct wined3d_context
*context
,
4140 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4141 void state_fog_fragpart(struct wined3d_context
*context
,
4142 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4143 void state_nop(struct wined3d_context
*context
,
4144 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4145 void state_srgbwrite(struct wined3d_context
*context
,
4146 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4148 void state_clipping(struct wined3d_context
*context
,
4149 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4150 void clipplane(struct wined3d_context
*context
,
4151 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4152 void state_pointsprite_w(struct wined3d_context
*context
,
4153 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4154 void state_pointsprite(struct wined3d_context
*context
,
4155 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4156 void state_shademode(struct wined3d_context
*context
,
4157 const struct wined3d_state
*state
, DWORD state_id
) DECLSPEC_HIDDEN
;
4160 void multiply_matrix(struct wined3d_matrix
*dest
, const struct wined3d_matrix
*src1
,
4161 const struct wined3d_matrix
*src2
) DECLSPEC_HIDDEN
;
4163 void wined3d_release_dc(HWND window
, HDC dc
) DECLSPEC_HIDDEN
;
4165 struct wined3d_shader_lconst
4169 unsigned int value
[4];
4172 struct wined3d_shader_limits
4174 unsigned int sampler
;
4175 unsigned int constant_int
;
4176 unsigned int constant_float
;
4177 unsigned int constant_bool
;
4178 unsigned int packed_output
;
4179 unsigned int packed_input
;
4182 #define wined3d_lock_init(lock, name) wined3d_lock_init_(lock, __FILE__ ": " name)
4183 static inline void wined3d_lock_init_(CRITICAL_SECTION
*lock
, const char *name
)
4185 InitializeCriticalSection(lock
);
4186 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
4187 lock
->DebugInfo
->Spare
[0] = (DWORD_PTR
)name
;
4190 static inline void wined3d_lock_cleanup(CRITICAL_SECTION
*lock
)
4192 if (lock
->DebugInfo
!= (RTL_CRITICAL_SECTION_DEBUG
*)-1)
4193 lock
->DebugInfo
->Spare
[0] = 0;
4194 DeleteCriticalSection(lock
);
4198 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
4200 #define PRINTF_ATTR(fmt,args)
4203 struct wined3d_string_buffer_list
4208 struct wined3d_string_buffer
*string_buffer_get(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4209 void string_buffer_sprintf(struct wined3d_string_buffer
*buffer
, const char *format
, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN
;
4210 void string_buffer_release(struct wined3d_string_buffer_list
*list
, struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4211 void string_buffer_list_init(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4212 void string_buffer_list_cleanup(struct wined3d_string_buffer_list
*list
) DECLSPEC_HIDDEN
;
4214 int shader_addline(struct wined3d_string_buffer
*buffer
, const char *fmt
, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN
;
4215 BOOL
string_buffer_resize(struct wined3d_string_buffer
*buffer
, int rc
) DECLSPEC_HIDDEN
;
4216 int shader_vaddline(struct wined3d_string_buffer
*buffer
, const char *fmt
, va_list args
) DECLSPEC_HIDDEN
;
4218 struct wined3d_shader_phase
4222 unsigned int instance_count
;
4223 unsigned int temporary_count
;
4226 struct wined3d_vertex_shader
4228 struct wined3d_shader_attribute attributes
[MAX_ATTRIBS
];
4231 struct wined3d_hull_shader
4235 struct wined3d_shader_phase
*control_point
;
4236 unsigned int fork_count
;
4237 unsigned int join_count
;
4238 struct wined3d_shader_phase
*fork
;
4240 struct wined3d_shader_phase
*join
;
4243 unsigned int output_vertex_count
;
4244 enum wined3d_tessellator_output_primitive tessellator_output_primitive
;
4245 enum wined3d_tessellator_partitioning tessellator_partitioning
;
4248 struct wined3d_domain_shader
4250 enum wined3d_tessellator_domain tessellator_domain
;
4253 struct wined3d_geometry_shader
4255 enum wined3d_primitive_type input_type
;
4256 enum wined3d_primitive_type output_type
;
4257 unsigned int vertices_out
;
4258 unsigned int instance_count
;
4260 const struct wined3d_stream_output_desc
*so_desc
;
4263 struct wined3d_pixel_shader
4265 /* Pixel shader input semantics */
4266 unsigned int input_reg_map
[MAX_REG_INPUT
];
4267 DWORD input_reg_used
; /* MAX_REG_INPUT, 32 */
4268 unsigned int declared_in_count
;
4270 /* Some information about the shader behavior */
4272 unsigned int color0_reg
;
4274 BOOL force_early_depth_stencil
;
4275 enum wined3d_shader_register_type depth_output
;
4276 uint32_t interpolation_mode
[WINED3D_PACKED_INTERPOLATION_SIZE
];
4279 struct wined3d_compute_shader
4281 struct wined3d_shader_thread_group_size thread_group_size
;
4284 struct wined3d_shader
4287 const struct wined3d_shader_limits
*limits
;
4288 const DWORD
*function
;
4289 unsigned int functionLength
;
4291 unsigned int byte_code_size
;
4292 BOOL load_local_constsF
;
4293 const struct wined3d_shader_frontend
*frontend
;
4294 void *frontend_data
;
4298 const struct wined3d_parent_ops
*parent_ops
;
4300 /* Programs this shader is linked with */
4301 struct list linked_programs
;
4303 /* Immediate constants (override global ones) */
4304 struct list constantsB
;
4305 struct list constantsF
;
4306 struct list constantsI
;
4307 struct wined3d_shader_reg_maps reg_maps
;
4308 BOOL lconst_inf_or_nan
;
4310 struct wined3d_shader_signature input_signature
;
4311 struct wined3d_shader_signature output_signature
;
4312 struct wined3d_shader_signature patch_constant_signature
;
4314 /* Pointer to the parent device */
4315 struct wined3d_device
*device
;
4316 struct list shader_list_entry
;
4320 struct wined3d_vertex_shader vs
;
4321 struct wined3d_hull_shader hs
;
4322 struct wined3d_domain_shader ds
;
4323 struct wined3d_geometry_shader gs
;
4324 struct wined3d_pixel_shader ps
;
4325 struct wined3d_compute_shader cs
;
4329 enum wined3d_shader_resource_type
pixelshader_get_resource_type(const struct wined3d_shader_reg_maps
*reg_maps
,
4330 unsigned int resource_idx
, DWORD tex_types
) DECLSPEC_HIDDEN
;
4331 void find_ps_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4332 BOOL position_transformed
, struct ps_compile_args
*args
,
4333 const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4335 bool vshader_get_input(const struct wined3d_shader
*shader
,
4336 uint8_t usage_req
, uint8_t usage_idx_req
, unsigned int *regnum
) DECLSPEC_HIDDEN
;
4337 void find_vs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4338 struct vs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4340 void find_ds_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4341 struct ds_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4343 void find_gs_compile_args(const struct wined3d_state
*state
, const struct wined3d_shader
*shader
,
4344 struct gs_compile_args
*args
, const struct wined3d_context
*context
) DECLSPEC_HIDDEN
;
4346 void string_buffer_clear(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4347 BOOL
string_buffer_init(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4348 void string_buffer_free(struct wined3d_string_buffer
*buffer
) DECLSPEC_HIDDEN
;
4349 unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps
*reg_maps
,
4350 unsigned int max
) DECLSPEC_HIDDEN
;
4351 HRESULT
shader_generate_code(const struct wined3d_shader
*shader
, struct wined3d_string_buffer
*buffer
,
4352 const struct wined3d_shader_reg_maps
*reg_maps
, void *backend_ctx
,
4353 const DWORD
*start
, const DWORD
*end
) DECLSPEC_HIDDEN
;
4354 BOOL
shader_match_semantic(const char *semantic_name
, enum wined3d_decl_usage usage
) DECLSPEC_HIDDEN
;
4356 static inline BOOL
shader_is_scalar(const struct wined3d_shader_register
*reg
)
4360 case WINED3DSPR_RASTOUT
:
4362 if (reg
->idx
[0].offset
)
4367 case WINED3DSPR_CONSTBOOL
: /* b# */
4368 case WINED3DSPR_DEPTHOUT
: /* oDepth */
4369 case WINED3DSPR_DEPTHOUTGE
:
4370 case WINED3DSPR_DEPTHOUTLE
:
4371 case WINED3DSPR_LOOP
: /* aL */
4372 case WINED3DSPR_OUTPOINTID
:
4373 case WINED3DSPR_PREDICATE
: /* p0 */
4374 case WINED3DSPR_PRIMID
: /* primID */
4375 case WINED3DSPR_COVERAGE
: /* vCoverage */
4376 case WINED3DSPR_SAMPLEMASK
: /* oMask */
4379 case WINED3DSPR_MISCTYPE
:
4380 switch (reg
->idx
[0].offset
)
4390 case WINED3DSPR_IMMCONST
:
4391 return reg
->immconst_type
== WINED3D_IMMCONST_SCALAR
;
4398 static inline void shader_get_position_fixup(const struct wined3d_context
*context
,
4399 const struct wined3d_state
*state
, unsigned int fixup_count
, float *position_fixup
)
4401 float center_offset
, x
= 0.0f
, y
= 0.0f
;
4404 /* See get_projection_matrix() in utils.c for a discussion of the position fixup.
4405 * This function here also applies to d3d10+ which does not need adjustment for
4406 * integer pixel centers, but it may need the filling convention offset. */
4407 if (context
->d3d_info
->wined3d_creation_flags
& WINED3D_PIXEL_CENTER_INTEGER
)
4408 center_offset
= 1.0f
;
4410 center_offset
= 0.0f
;
4412 center_offset
+= context
->d3d_info
->filling_convention_offset
;
4414 for (i
= 0; i
< fixup_count
; ++i
)
4416 position_fixup
[4 * i
] = 1.0f
;
4417 position_fixup
[4 * i
+ 1] = 1.0f
;
4418 if (!context
->d3d_info
->subpixel_viewport
)
4421 x
= modf(state
->viewports
[i
].x
, &dummy
) * 2.0f
;
4422 y
= modf(state
->viewports
[i
].y
, &dummy
) * 2.0f
;
4424 position_fixup
[4 * i
+ 2] = (center_offset
+ x
) / state
->viewports
[i
].width
;
4425 position_fixup
[4 * i
+ 3] = -(center_offset
+ y
) / state
->viewports
[i
].height
;
4427 if (context
->render_offscreen
)
4429 position_fixup
[4 * i
+ 1] *= -1.0f
;
4430 position_fixup
[4 * i
+ 3] *= -1.0f
;
4435 static inline BOOL
shader_constant_is_local(const struct wined3d_shader
*shader
, DWORD reg
)
4437 struct wined3d_shader_lconst
*lconst
;
4439 if (shader
->load_local_constsF
)
4442 LIST_FOR_EACH_ENTRY(lconst
, &shader
->constantsF
, struct wined3d_shader_lconst
, entry
)
4444 if (lconst
->idx
== reg
)
4451 void get_identity_matrix(struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4452 void get_modelview_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4453 unsigned int index
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4454 void get_projection_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4455 struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4456 void get_texture_matrix(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4457 unsigned int tex
, struct wined3d_matrix
*mat
) DECLSPEC_HIDDEN
;
4458 void get_pointsize_minmax(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4459 float *out_min
, float *out_max
) DECLSPEC_HIDDEN
;
4460 void get_pointsize(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4461 float *out_pointsize
, float *out_att
) DECLSPEC_HIDDEN
;
4462 void get_fog_start_end(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
4463 float *start
, float *end
) DECLSPEC_HIDDEN
;
4465 /* Using additional shader constants (uniforms in GLSL / program environment
4466 * or local parameters in ARB) is costly:
4467 * ARB only knows float4 parameters and GLSL compiler are not really smart
4468 * when it comes to efficiently pack float2 uniforms, so no space is wasted
4469 * (in fact most compilers map a float2 to a full float4 uniform).
4471 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
4472 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
4473 * into a single shader constant (uniform / program parameter).
4475 * This structure is shared between the GLSL and the ARB backend.*/
4476 struct ps_np2fixup_info
{
4477 unsigned char idx
[WINED3D_MAX_FRAGMENT_SAMPLERS
]; /* indices to the real constant */
4478 WORD active
; /* bitfield indicating if we can apply the fixup */
4482 struct wined3d_palette
4485 struct wined3d_device
*device
;
4488 RGBQUAD colors
[256];
4492 /* DirectDraw utility functions */
4493 extern enum wined3d_format_id
pixelformat_for_depth(DWORD depth
) DECLSPEC_HIDDEN
;
4495 /*****************************************************************************
4496 * Pixel format management
4499 /* Pixel format attributes */
4500 #define WINED3D_FORMAT_ATTR_FLOAT 0x00000001
4501 #define WINED3D_FORMAT_ATTR_INTEGER 0x00000002
4502 #define WINED3D_FORMAT_ATTR_NORMALISED 0x00000004
4503 #define WINED3D_FORMAT_ATTR_BUMPMAP 0x00000008
4504 #define WINED3D_FORMAT_ATTR_EXTENSION 0x00000010
4505 #define WINED3D_FORMAT_ATTR_BLOCKS 0x00000020
4506 #define WINED3D_FORMAT_ATTR_BLOCKS_NO_VERIFY 0x00000040
4507 #define WINED3D_FORMAT_ATTR_COMPRESSED 0x00000080
4508 #define WINED3D_FORMAT_ATTR_BROKEN_PITCH 0x00000100
4509 #define WINED3D_FORMAT_ATTR_HEIGHT_SCALE 0x00000200
4510 #define WINED3D_FORMAT_ATTR_MAPPABLE 0x00000400
4511 #define WINED3D_FORMAT_ATTR_CAST_TO_BLOCK 0x00000800
4513 /* Pixel format capabilities */
4514 #define WINED3D_FORMAT_CAP_POSTPIXELSHADER_BLENDING 0x00000001
4515 #define WINED3D_FORMAT_CAP_FILTERING 0x00000002
4516 #define WINED3D_FORMAT_CAP_UNORDERED_ACCESS 0x00000004
4517 #define WINED3D_FORMAT_CAP_DEPTH_STENCIL 0x00000008
4518 #define WINED3D_FORMAT_CAP_RENDERTARGET 0x00000010
4519 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE 0x00000020
4520 #define WINED3D_FORMAT_CAP_FBO_ATTACHABLE_SRGB 0x00000040
4521 #define WINED3D_FORMAT_CAP_DECOMPRESS 0x00000080
4522 #define WINED3D_FORMAT_CAP_SRGB_READ 0x00000100
4523 #define WINED3D_FORMAT_CAP_SRGB_WRITE 0x00000200
4524 #define WINED3D_FORMAT_CAP_VTF 0x00000400
4525 #define WINED3D_FORMAT_CAP_SHADOW 0x00000800
4526 #define WINED3D_FORMAT_CAP_TEXTURE 0x00001000
4527 #define WINED3D_FORMAT_CAP_GEN_MIPMAP 0x00002000
4528 #define WINED3D_FORMAT_CAP_VERTEX_ATTRIBUTE 0x00004000
4529 #define WINED3D_FORMAT_CAP_BLIT 0x00008000
4530 #define WINED3D_FORMAT_CAP_INDEX_BUFFER 0x00010000
4532 struct wined3d_rational
4538 struct wined3d_color_key_conversion
4540 enum wined3d_format_id dst_format
;
4541 void (*convert
)(const BYTE
*src
, unsigned int src_pitch
, BYTE
*dst
, unsigned int dst_pitch
,
4542 unsigned int width
, unsigned int height
, const struct wined3d_color_key
*colour_key
);
4545 enum wined3d_channel_type
4547 WINED3D_CHANNEL_TYPE_NONE
,
4548 WINED3D_CHANNEL_TYPE_UNORM
,
4549 WINED3D_CHANNEL_TYPE_SNORM
,
4550 WINED3D_CHANNEL_TYPE_UINT
,
4551 WINED3D_CHANNEL_TYPE_SINT
,
4552 WINED3D_CHANNEL_TYPE_FLOAT
,
4553 WINED3D_CHANNEL_TYPE_DEPTH
,
4554 WINED3D_CHANNEL_TYPE_STENCIL
,
4555 WINED3D_CHANNEL_TYPE_UNUSED
,
4558 struct wined3d_format
4560 enum wined3d_format_id id
;
4562 D3DDDIFORMAT ddi_format
;
4563 unsigned int component_count
;
4578 UINT block_byte_count
;
4580 enum wined3d_ffp_emit_idx emit_idx
;
4582 UINT conv_byte_count
;
4583 DWORD multisample_types
;
4585 unsigned int caps
[WINED3D_GL_RES_TYPE_COUNT
];
4586 float depth_bias_scale
;
4587 struct wined3d_rational height_scale
;
4588 struct color_fixup_desc color_fixup
;
4589 void (*upload
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
4590 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
4591 unsigned int width
, unsigned int height
, unsigned int depth
);
4592 void (*download
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
4593 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
4594 unsigned int width
, unsigned int height
, unsigned int depth
);
4595 void (*decompress
)(const BYTE
*src
, BYTE
*dst
, unsigned int src_row_pitch
, unsigned int src_slice_pitch
,
4596 unsigned int dst_row_pitch
, unsigned dst_slice_pitch
,
4597 unsigned int width
, unsigned int height
, unsigned int depth
);
4599 enum wined3d_format_id typeless_id
;
4602 const struct wined3d_format
*wined3d_get_format(const struct wined3d_adapter
*adapter
,
4603 enum wined3d_format_id format_id
, unsigned int bind_flags
) DECLSPEC_HIDDEN
;
4604 enum wined3d_format_id
wined3d_get_typed_format_id(const struct wined3d_adapter
*adapter
,
4605 const struct wined3d_format
*format
, enum wined3d_channel_type channel_type
) DECLSPEC_HIDDEN
;
4606 void wined3d_format_calculate_pitch(const struct wined3d_format
*format
, unsigned int alignment
,
4607 unsigned int width
, unsigned int height
, unsigned int *row_pitch
, unsigned int *slice_pitch
) DECLSPEC_HIDDEN
;
4608 UINT
wined3d_format_calculate_size(const struct wined3d_format
*format
,
4609 UINT alignment
, UINT width
, UINT height
, UINT depth
) DECLSPEC_HIDDEN
;
4610 void wined3d_format_convert_from_float(const struct wined3d_format
*format
,
4611 const struct wined3d_color
*color
, void *ret
) DECLSPEC_HIDDEN
;
4612 void wined3d_format_copy_data(const struct wined3d_format
*format
, const uint8_t *src
,
4613 unsigned int src_row_pitch
, unsigned int src_slice_pitch
, uint8_t *dst
, unsigned int dst_row_pitch
,
4614 unsigned int dst_slice_pitch
, unsigned int w
, unsigned int h
, unsigned int d
) DECLSPEC_HIDDEN
;
4615 void wined3d_format_get_float_color_key(const struct wined3d_format
*format
,
4616 const struct wined3d_color_key
*key
, struct wined3d_color
*float_colors
) DECLSPEC_HIDDEN
;
4617 BOOL
wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id
,
4618 enum wined3d_format_id view_format_id
) DECLSPEC_HIDDEN
;
4619 const struct wined3d_color_key_conversion
* wined3d_format_get_color_key_conversion(
4620 const struct wined3d_texture
*texture
, BOOL need_alpha_ck
) DECLSPEC_HIDDEN
;
4621 uint32_t wined3d_format_pack(const struct wined3d_format
*format
, const struct wined3d_uvec4
*value
) DECLSPEC_HIDDEN
;
4622 BOOL
wined3d_formats_are_srgb_variants(enum wined3d_format_id format1
,
4623 enum wined3d_format_id format2
) DECLSPEC_HIDDEN
;
4625 BOOL
wined3d_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
) DECLSPEC_HIDDEN
;
4627 static inline BOOL
wined3d_format_is_typeless(const struct wined3d_format
*format
)
4629 return format
->id
== format
->typeless_id
&& format
->id
!= WINED3DFMT_UNKNOWN
;
4632 static inline BOOL
use_vs(const struct wined3d_state
*state
)
4634 /* Check state->vertex_declaration to allow this to be used before the
4635 * stream info is validated, for example in device_update_tex_unit_map(). */
4636 return state
->shader
[WINED3D_SHADER_TYPE_VERTEX
]
4637 && (!state
->vertex_declaration
|| !state
->vertex_declaration
->position_transformed
);
4640 static inline BOOL
use_ps(const struct wined3d_state
*state
)
4642 return !!state
->shader
[WINED3D_SHADER_TYPE_PIXEL
];
4645 static inline BOOL
use_transform_feedback(const struct wined3d_state
*state
)
4647 const struct wined3d_shader
*shader
;
4649 if (!(shader
= state
->shader
[WINED3D_SHADER_TYPE_GEOMETRY
]))
4651 return !!shader
->u
.gs
.so_desc
;
4654 static inline void context_apply_state(struct wined3d_context
*context
,
4655 const struct wined3d_state
*state
, DWORD state_id
)
4657 const struct wined3d_state_entry
*state_table
= context
->state_table
;
4658 unsigned int rep
= state_table
[state_id
].representative
;
4659 state_table
[rep
].apply(context
, state
, rep
);
4662 static inline BOOL
is_srgb_enabled(const uint32_t *sampler_states
)
4664 /* Only use the LSB of the WINED3D_SAMP_SRGB_TEXTURE value. This matches
4665 * the behaviour of the AMD Windows driver.
4667 * Might & Magic: Heroes VI - Shades of Darkness sets
4668 * WINED3D_SAMP_SRGB_TEXTURE to a large value that looks like a
4669 * pointer—presumably by accident—and expects sRGB decoding to be
4671 return sampler_states
[WINED3D_SAMP_SRGB_TEXTURE
] & 0x1;
4674 static inline BOOL
needs_separate_srgb_gl_texture(const struct wined3d_context
*context
,
4675 const struct wined3d_texture
*texture
)
4677 if (!(context
->d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
))
4680 if (!context
->d3d_info
->srgb_read_control
4681 && (texture
->resource
.bind_flags
& WINED3D_BIND_SHADER_RESOURCE
)
4682 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_READ
))
4685 if (!context
->d3d_info
->srgb_write_control
4686 && (texture
->resource
.bind_flags
& WINED3D_BIND_RENDER_TARGET
)
4687 && (texture
->resource
.format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
))
4693 static inline BOOL
needs_srgb_write(const struct wined3d_d3d_info
*d3d_info
,
4694 const struct wined3d_state
*state
, const struct wined3d_fb_state
*fb
)
4696 return (!(d3d_info
->wined3d_creation_flags
& WINED3D_SRGB_READ_WRITE_CONTROL
)
4697 || state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
])
4698 && fb
->render_targets
[0] && fb
->render_targets
[0]->format_caps
& WINED3D_FORMAT_CAP_SRGB_WRITE
;
4701 static inline BOOL
can_use_texture_swizzle(const struct wined3d_d3d_info
*d3d_info
, const struct wined3d_format
*format
)
4703 return d3d_info
->texture_swizzle
&& !is_complex_fixup(format
->color_fixup
) && !is_scaling_fixup(format
->color_fixup
);
4706 static inline BOOL
is_rasterization_disabled(const struct wined3d_shader
*geometry_shader
)
4708 return geometry_shader
&& geometry_shader
->u
.gs
.so_desc
4709 && geometry_shader
->u
.gs
.so_desc
->rasterizer_stream_idx
== WINED3D_NO_RASTERIZER_STREAM
;
4712 static inline uint32_t wined3d_mask_from_size(unsigned int size
)
4714 return size
< 32 ? (1u << size
) - 1 : ~0u;
4717 static inline DWORD
wined3d_extract_bits(const uint32_t *bitstream
,
4718 unsigned int offset
, unsigned int count
)
4720 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
4721 const unsigned int idx
= offset
/ word_bit_count
;
4722 const unsigned int shift
= offset
% word_bit_count
;
4723 DWORD mask
= (1u << count
) - 1;
4726 ret
= (bitstream
[idx
] >> shift
) & mask
;
4727 if (shift
+ count
> word_bit_count
)
4729 const unsigned int extracted_bit_count
= word_bit_count
- shift
;
4730 const unsigned int remaining_bit_count
= count
- extracted_bit_count
;
4731 mask
= (1u << remaining_bit_count
) - 1;
4732 ret
|= (bitstream
[idx
+ 1] & mask
) << extracted_bit_count
;
4737 static inline void wined3d_insert_bits(uint32_t *bitstream
,
4738 unsigned int offset
, unsigned int count
, DWORD bits
)
4740 const unsigned int word_bit_count
= sizeof(*bitstream
) * CHAR_BIT
;
4741 const unsigned int idx
= offset
/ word_bit_count
;
4742 const unsigned int shift
= offset
% word_bit_count
;
4743 DWORD mask
= (1u << count
) - 1;
4745 bitstream
[idx
] |= (bits
& mask
) << shift
;
4746 if (shift
+ count
> word_bit_count
)
4748 const unsigned int inserted_bit_count
= word_bit_count
- shift
;
4749 const unsigned int remaining_bit_count
= count
- inserted_bit_count
;
4750 mask
= (1u << remaining_bit_count
) - 1;
4751 bitstream
[idx
+ 1] |= (bits
>> inserted_bit_count
) & mask
;
4755 static inline void wined3d_from_cs(const struct wined3d_cs
*cs
)
4758 assert(cs
->thread_id
== GetCurrentThreadId());
4761 static inline void wined3d_not_from_cs(const struct wined3d_cs
*cs
)
4763 assert(cs
->thread_id
!= GetCurrentThreadId());
4766 static inline enum wined3d_material_color_source
validate_material_colour_source(WORD use_map
,
4767 enum wined3d_material_color_source source
)
4769 if (source
== WINED3D_MCS_COLOR1
&& use_map
& (1u << WINED3D_FFP_DIFFUSE
))
4771 if (source
== WINED3D_MCS_COLOR2
&& use_map
& (1u << WINED3D_FFP_SPECULAR
))
4773 return WINED3D_MCS_MATERIAL
;
4776 static inline void wined3d_get_material_colour_source(enum wined3d_material_color_source
*diffuse
,
4777 enum wined3d_material_color_source
*emissive
, enum wined3d_material_color_source
*ambient
,
4778 enum wined3d_material_color_source
*specular
, const struct wined3d_state
*state
,
4779 const struct wined3d_stream_info
*si
)
4781 if (!state
->render_states
[WINED3D_RS_LIGHTING
])
4783 *diffuse
= WINED3D_MCS_COLOR1
;
4784 *specular
= WINED3D_MCS_COLOR2
;
4785 *emissive
= *ambient
= WINED3D_MCS_MATERIAL
;
4790 if (!state
->render_states
[WINED3D_RS_COLORVERTEX
])
4792 *diffuse
= *emissive
= *ambient
= *specular
= WINED3D_MCS_MATERIAL
;
4797 *diffuse
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
]);
4798 *emissive
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
]);
4799 *ambient
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
]);
4800 *specular
= validate_material_colour_source(si
->use_map
, state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
]);
4803 static inline void wined3d_vec4_transform(struct wined3d_vec4
*dst
,
4804 const struct wined3d_vec4
*v
, const struct wined3d_matrix
*m
)
4806 struct wined3d_vec4 tmp
;
4808 tmp
.x
= v
->x
* m
->_11
+ v
->y
* m
->_21
+ v
->z
* m
->_31
+ v
->w
* m
->_41
;
4809 tmp
.y
= v
->x
* m
->_12
+ v
->y
* m
->_22
+ v
->z
* m
->_32
+ v
->w
* m
->_42
;
4810 tmp
.z
= v
->x
* m
->_13
+ v
->y
* m
->_23
+ v
->z
* m
->_33
+ v
->w
* m
->_43
;
4811 tmp
.w
= v
->x
* m
->_14
+ v
->y
* m
->_24
+ v
->z
* m
->_34
+ v
->w
* m
->_44
;
4816 BOOL
invert_matrix(struct wined3d_matrix
*out
, const struct wined3d_matrix
*m
) DECLSPEC_HIDDEN
;
4818 void compute_normal_matrix(float *normal_matrix
, BOOL legacy_lighting
,
4819 const struct wined3d_matrix
*modelview
) DECLSPEC_HIDDEN
;
4821 static inline struct wined3d_context
*context_acquire(struct wined3d_device
*device
,
4822 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
4824 wined3d_from_cs(device
->cs
);
4826 return device
->adapter
->adapter_ops
->adapter_acquire_context(device
, texture
, sub_resource_idx
);
4829 static inline void context_release(struct wined3d_context
*context
)
4831 context
->device
->adapter
->adapter_ops
->adapter_release_context(context
);
4834 static inline float wined3d_get_float_state(const struct wined3d_state
*state
, enum wined3d_render_state rs
)
4843 tmpvalue
.d
= state
->render_states
[rs
];
4847 static inline void *wined3d_context_map_bo_address(struct wined3d_context
*context
,
4848 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
4850 return context
->device
->adapter
->adapter_ops
->adapter_map_bo_address(context
, data
, size
, map_flags
);
4853 static inline void wined3d_context_unmap_bo_address(struct wined3d_context
*context
,
4854 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
4856 context
->device
->adapter
->adapter_ops
->adapter_unmap_bo_address(context
, data
, range_count
, ranges
);
4859 static inline void wined3d_context_copy_bo_address(struct wined3d_context
*context
,
4860 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
4861 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
)
4863 context
->device
->adapter
->adapter_ops
->adapter_copy_bo_address(context
, dst
, src
, range_count
, ranges
, map_flags
);
4866 static inline void wined3d_context_flush_bo_address(struct wined3d_context
*context
,
4867 const struct wined3d_const_bo_address
*data
, size_t size
)
4869 context
->device
->adapter
->adapter_ops
->adapter_flush_bo_address(context
, data
, size
);
4872 static inline void wined3d_context_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
4874 context
->device
->adapter
->adapter_ops
->adapter_destroy_bo(context
, bo
);
4877 static inline BOOL
wined3d_dsv_srv_conflict(const struct wined3d_rendertarget_view
*dsv
,
4878 const struct wined3d_format
*srv_format
)
4880 return !srv_format
|| (srv_format
->red_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_DEPTH
))
4881 || (srv_format
->green_size
&& !(dsv
->desc
.flags
& WINED3D_VIEW_READ_ONLY_STENCIL
));
4884 static inline unsigned int wined3d_bind_layer_count(const struct wined3d_texture
*texture
)
4886 return texture
->resource
.type
== WINED3D_RTYPE_TEXTURE_3D
? texture
->resource
.depth
: texture
->layer_count
;
4889 static inline bool wined3d_srv_all_subresources(const struct wined3d_shader_resource_view
*srv
)
4891 struct wined3d_texture
*texture
;
4893 if (srv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
4896 if (srv
->desc
.u
.texture
.layer_idx
|| srv
->desc
.u
.texture
.level_idx
)
4899 texture
= texture_from_resource(srv
->resource
);
4900 return srv
->desc
.u
.texture
.level_count
== texture
->level_count
4901 && srv
->desc
.u
.texture
.layer_count
== wined3d_bind_layer_count(texture
);
4904 static inline bool wined3d_rtv_all_subresources(const struct wined3d_rendertarget_view
*rtv
)
4906 struct wined3d_texture
*texture
;
4908 if (rtv
->resource
->type
== WINED3D_RTYPE_BUFFER
)
4911 if (rtv
->sub_resource_idx
)
4914 texture
= texture_from_resource(rtv
->resource
);
4915 return texture
->level_count
== 1 && rtv
->layer_count
== wined3d_bind_layer_count(texture
);
4918 static inline void wined3d_srv_bind_count_inc(struct wined3d_shader_resource_view
*srv
)
4920 InterlockedIncrement(&srv
->resource
->srv_bind_count_device
);
4923 static inline void wined3d_srv_bind_count_dec(struct wined3d_shader_resource_view
*srv
)
4925 InterlockedDecrement(&srv
->resource
->srv_bind_count_device
);
4928 static inline void wined3d_rtv_bind_count_inc(struct wined3d_rendertarget_view
*rtv
)
4930 InterlockedIncrement(&rtv
->resource
->rtv_bind_count_device
);
4933 static inline void wined3d_rtv_bind_count_dec(struct wined3d_rendertarget_view
*rtv
)
4935 InterlockedDecrement(&rtv
->resource
->rtv_bind_count_device
);
4938 static inline bool wined3d_rtv_overlaps_srv(const struct wined3d_rendertarget_view
*rtv
,
4939 const struct wined3d_shader_resource_view
*srv
)
4941 if (rtv
->resource
!= srv
->resource
)
4944 if (wined3d_srv_all_subresources(srv
) || wined3d_rtv_all_subresources(rtv
))
4947 return rtv
->sub_resource_idx
>= srv
->desc
.u
.texture
.level_idx
4948 && rtv
->sub_resource_idx
< srv
->desc
.u
.texture
.level_idx
+ srv
->desc
.u
.texture
.level_count
4949 && rtv
->layer_count
>= srv
->desc
.u
.texture
.layer_idx
;
4952 static inline bool wined3d_is_srv_rtv_bound(const struct wined3d_state
*state
,
4953 const struct wined3d_shader_resource_view
*srv
)
4957 if (!srv
->resource
->rtv_bind_count_device
)
4960 for (i
= 0; i
< ARRAY_SIZE(state
->fb
.render_targets
); ++i
)
4962 const struct wined3d_rendertarget_view
*rtv
;
4964 if ((rtv
= state
->fb
.render_targets
[i
]) && wined3d_rtv_overlaps_srv(rtv
, srv
))
4971 static inline void wined3d_viewport_get_z_range(const struct wined3d_viewport
*vp
, float *min_z
, float *max_z
)
4975 /* The magic constant is derived from tests. */
4976 *max_z
= max(vp
->max_z
, vp
->min_z
+ 0.001f
);
4979 static inline BOOL
wined3d_bitmap_clear(uint32_t *map
, unsigned int idx
)
4981 return map
[idx
>> 5] &= ~(1u << (idx
& 0x1f));
4984 static inline BOOL
wined3d_bitmap_set(uint32_t *map
, unsigned int idx
)
4986 return map
[idx
>> 5] |= (1u << (idx
& 0x1f));
4989 static inline BOOL
wined3d_bitmap_is_set(const uint32_t *map
, unsigned int idx
)
4991 return map
[idx
>> 5] & (1u << (idx
& 0x1f));
4994 static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap
, unsigned int bit_count
,
4995 unsigned int start
, uint32_t xor_mask
)
4997 const unsigned int word_bit_count
= sizeof(*bitmap
) * CHAR_BIT
;
4998 const uint32_t *ptr
, *end_ptr
;
5001 assert(bit_count
< word_bit_count
|| !(bit_count
% word_bit_count
));
5003 ptr
= bitmap
+ start
/ word_bit_count
;
5004 end_ptr
= bitmap
+ (bit_count
+ word_bit_count
- 1) / word_bit_count
;
5009 mask
= ~0u << start
% word_bit_count
;
5010 map
= (*ptr
^ xor_mask
) & mask
;
5013 if (++ptr
== end_ptr
)
5015 map
= *ptr
^ xor_mask
;
5017 return (ptr
- bitmap
) * word_bit_count
+ wined3d_bit_scan(&map
);
5020 static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
5022 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, 0);
5025 static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap
, unsigned int bit_count
, unsigned int start
)
5027 return wined3d_bitmap_ffs_xor(bitmap
, bit_count
, start
, ~0u);
5030 static inline BOOL
wined3d_bitmap_get_range(const uint32_t *bitmap
, unsigned int bit_count
,
5031 unsigned int start
, struct wined3d_range
*range
)
5033 unsigned int range_start
, range_end
;
5035 range_start
= wined3d_bitmap_ffs(bitmap
, bit_count
, start
);
5036 if (range_start
== ~0u)
5039 range_end
= wined3d_bitmap_ffz(bitmap
, bit_count
, range_start
+ 1);
5040 if (range_end
== ~0u)
5041 range_end
= bit_count
;
5043 range
->offset
= range_start
;
5044 range
->size
= range_end
- range_start
;
5048 static inline bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
5050 return wined3d_bitmap_is_set(context
->dirty_graphics_states
, state_id
);
5053 static inline bool wined3d_context_is_compute_state_dirty(const struct wined3d_context
*context
, unsigned int state_id
)
5055 return wined3d_bitmap_is_set(context
->dirty_compute_states
, state_id
- STATE_COMPUTE_OFFSET
);
5058 static inline bool isStateDirty(const struct wined3d_context
*context
, unsigned int state_id
)
5060 return wined3d_context_is_graphics_state_dirty(context
, state_id
);
5063 static inline bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t
)
5065 return t
== WINED3D_PT_POINTLIST
5066 || t
== WINED3D_PT_LINELIST
5067 || t
== WINED3D_PT_TRIANGLELIST
5068 || t
== WINED3D_PT_LINELIST_ADJ
5069 || t
== WINED3D_PT_TRIANGLELIST_ADJ
5070 || t
== WINED3D_PT_PATCH
;
5073 static inline bool wined3d_map_persistent(void)
5075 return sizeof(void *) >= sizeof(uint64_t);
5078 /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
5079 #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
5081 extern CRITICAL_SECTION wined3d_command_cs
;