1c2c66affSColin Finck /*
2c2c66affSColin Finck * Direct3D wine internal private include file
3c2c66affSColin Finck *
4c2c66affSColin Finck * Copyright 2002-2003 The wine-d3d team
5c2c66affSColin Finck * Copyright 2002-2003 Raphael Junqueira
6c2c66affSColin Finck * Copyright 2002-2003, 2004 Jason Edmeades
7c2c66affSColin Finck * Copyright 2005 Oliver Stieber
8c2c66affSColin Finck * Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
9c2c66affSColin Finck *
10c2c66affSColin Finck * This library is free software; you can redistribute it and/or
11c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
12c2c66affSColin Finck * License as published by the Free Software Foundation; either
13c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
14c2c66affSColin Finck *
15c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
16c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
17c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18c2c66affSColin Finck * Lesser General Public License for more details.
19c2c66affSColin Finck *
20c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
21c2c66affSColin Finck * License along with this library; if not, write to the Free Software
22c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23c2c66affSColin Finck */
24c2c66affSColin Finck
25c2c66affSColin Finck #ifndef __WINE_WINED3D_PRIVATE_H
26c2c66affSColin Finck #define __WINE_WINED3D_PRIVATE_H
27c2c66affSColin Finck
28c2c66affSColin Finck #ifdef USE_WIN32_OPENGL
29c2c66affSColin Finck #define WINE_GLAPI __stdcall
30c2c66affSColin Finck #else
31c2c66affSColin Finck #define WINE_GLAPI
32c2c66affSColin Finck #endif
33c2c66affSColin Finck
34c2c66affSColin Finck #include <assert.h>
359987f029SAmine Khaldi #include <stdarg.h>
369987f029SAmine Khaldi #include <math.h>
379987f029SAmine Khaldi #include <limits.h>
389987f029SAmine Khaldi #include "ntstatus.h"
39c2c66affSColin Finck #define WIN32_NO_STATUS
40c2c66affSColin Finck #define NONAMELESSUNION
41c2c66affSColin Finck #define NONAMELESSSTRUCT
42c2c66affSColin Finck #define COBJMACROS
439987f029SAmine Khaldi #include "windef.h"
449987f029SAmine Khaldi #include "winbase.h"
459987f029SAmine Khaldi #include "winreg.h"
469987f029SAmine Khaldi #include "wingdi.h"
479987f029SAmine Khaldi #include "winuser.h"
489987f029SAmine Khaldi #include "winternl.h"
499987f029SAmine Khaldi #include "ddk/d3dkmthk.h"
509987f029SAmine Khaldi #include "wine/debug.h"
519987f029SAmine Khaldi #include "wine/heap.h"
529987f029SAmine Khaldi #include "wine/unicode.h"
53c2c66affSColin Finck
549987f029SAmine Khaldi #include "objbase.h"
559987f029SAmine Khaldi #include "wine/wined3d.h"
56c2c66affSColin Finck #include "wined3d_gl.h"
579987f029SAmine Khaldi #include "wine/list.h"
589987f029SAmine Khaldi #include "wine/rbtree.h"
599987f029SAmine Khaldi #include "wine/wgl_driver.h"
60c2c66affSColin Finck
61c2c66affSColin Finck #ifndef ARRAY_SIZE
62c2c66affSColin Finck #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
63c2c66affSColin Finck #endif
64c2c66affSColin Finck
65d6ac0a71SAmine Khaldi #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
66d6ac0a71SAmine Khaldi
67c2c66affSColin Finck /* Driver quirks */
68c2c66affSColin Finck #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
69c2c66affSColin Finck #define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
70c2c66affSColin Finck #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
71c2c66affSColin Finck #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
72c2c66affSColin Finck #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
73c2c66affSColin Finck #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
74c2c66affSColin Finck #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
75c2c66affSColin Finck #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
76c2c66affSColin Finck #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
77c2c66affSColin Finck #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
78c2c66affSColin Finck
79c2c66affSColin Finck enum wined3d_ffp_idx
80c2c66affSColin Finck {
81c2c66affSColin Finck WINED3D_FFP_POSITION = 0,
82c2c66affSColin Finck WINED3D_FFP_BLENDWEIGHT = 1,
83c2c66affSColin Finck WINED3D_FFP_BLENDINDICES = 2,
84c2c66affSColin Finck WINED3D_FFP_NORMAL = 3,
85c2c66affSColin Finck WINED3D_FFP_PSIZE = 4,
86c2c66affSColin Finck WINED3D_FFP_DIFFUSE = 5,
87c2c66affSColin Finck WINED3D_FFP_SPECULAR = 6,
88c2c66affSColin Finck WINED3D_FFP_TEXCOORD0 = 7,
89c2c66affSColin Finck WINED3D_FFP_TEXCOORD1 = 8,
90c2c66affSColin Finck WINED3D_FFP_TEXCOORD2 = 9,
91c2c66affSColin Finck WINED3D_FFP_TEXCOORD3 = 10,
92c2c66affSColin Finck WINED3D_FFP_TEXCOORD4 = 11,
93c2c66affSColin Finck WINED3D_FFP_TEXCOORD5 = 12,
94c2c66affSColin Finck WINED3D_FFP_TEXCOORD6 = 13,
95c2c66affSColin Finck WINED3D_FFP_TEXCOORD7 = 14,
96c2c66affSColin Finck WINED3D_FFP_ATTRIBS_COUNT = 15,
97c2c66affSColin Finck };
98c2c66affSColin Finck
99c2c66affSColin Finck enum wined3d_ffp_emit_idx
100c2c66affSColin Finck {
101c2c66affSColin Finck WINED3D_FFP_EMIT_FLOAT1,
102c2c66affSColin Finck WINED3D_FFP_EMIT_FLOAT2,
103c2c66affSColin Finck WINED3D_FFP_EMIT_FLOAT3,
104c2c66affSColin Finck WINED3D_FFP_EMIT_FLOAT4,
105c2c66affSColin Finck WINED3D_FFP_EMIT_D3DCOLOR,
106c2c66affSColin Finck WINED3D_FFP_EMIT_UBYTE4,
107c2c66affSColin Finck WINED3D_FFP_EMIT_SHORT2,
108c2c66affSColin Finck WINED3D_FFP_EMIT_SHORT4,
109c2c66affSColin Finck WINED3D_FFP_EMIT_UBYTE4N,
110c2c66affSColin Finck WINED3D_FFP_EMIT_SHORT2N,
111c2c66affSColin Finck WINED3D_FFP_EMIT_SHORT4N,
112c2c66affSColin Finck WINED3D_FFP_EMIT_USHORT2N,
113c2c66affSColin Finck WINED3D_FFP_EMIT_USHORT4N,
114c2c66affSColin Finck WINED3D_FFP_EMIT_UDEC3,
115c2c66affSColin Finck WINED3D_FFP_EMIT_DEC3N,
116c2c66affSColin Finck WINED3D_FFP_EMIT_FLOAT16_2,
117c2c66affSColin Finck WINED3D_FFP_EMIT_FLOAT16_4,
118c2c66affSColin Finck WINED3D_FFP_EMIT_INVALID,
119c2c66affSColin Finck WINED3D_FFP_EMIT_COUNT,
120c2c66affSColin Finck };
121c2c66affSColin Finck
122c2c66affSColin Finck /* Texture format fixups */
123c2c66affSColin Finck
124c2c66affSColin Finck enum fixup_channel_source
125c2c66affSColin Finck {
126c2c66affSColin Finck CHANNEL_SOURCE_ZERO = 0,
127c2c66affSColin Finck CHANNEL_SOURCE_ONE = 1,
128c2c66affSColin Finck CHANNEL_SOURCE_X = 2,
129c2c66affSColin Finck CHANNEL_SOURCE_Y = 3,
130c2c66affSColin Finck CHANNEL_SOURCE_Z = 4,
131c2c66affSColin Finck CHANNEL_SOURCE_W = 5,
132c2c66affSColin Finck CHANNEL_SOURCE_COMPLEX0 = 6,
133c2c66affSColin Finck CHANNEL_SOURCE_COMPLEX1 = 7,
134c2c66affSColin Finck };
135c2c66affSColin Finck
136c2c66affSColin Finck enum complex_fixup
137c2c66affSColin Finck {
138c2c66affSColin Finck COMPLEX_FIXUP_NONE = 0,
139c2c66affSColin Finck COMPLEX_FIXUP_YUY2 = 1,
140c2c66affSColin Finck COMPLEX_FIXUP_UYVY = 2,
141c2c66affSColin Finck COMPLEX_FIXUP_YV12 = 3,
142c2c66affSColin Finck COMPLEX_FIXUP_P8 = 4,
143c2c66affSColin Finck COMPLEX_FIXUP_NV12 = 5,
144c2c66affSColin Finck };
145c2c66affSColin Finck
146c2c66affSColin Finck #include <pshpack2.h>
147c2c66affSColin Finck struct color_fixup_desc
148c2c66affSColin Finck {
149c2c66affSColin Finck unsigned short x_sign_fixup : 1;
150c2c66affSColin Finck unsigned short x_source : 3;
151c2c66affSColin Finck unsigned short y_sign_fixup : 1;
152c2c66affSColin Finck unsigned short y_source : 3;
153c2c66affSColin Finck unsigned short z_sign_fixup : 1;
154c2c66affSColin Finck unsigned short z_source : 3;
155c2c66affSColin Finck unsigned short w_sign_fixup : 1;
156c2c66affSColin Finck unsigned short w_source : 3;
157c2c66affSColin Finck };
158c2c66affSColin Finck #include <poppack.h>
159c2c66affSColin Finck
160c2c66affSColin Finck struct wined3d_d3d_limits
161c2c66affSColin Finck {
162c2c66affSColin Finck unsigned int vs_version, hs_version, ds_version, gs_version, ps_version, cs_version;
163c2c66affSColin Finck DWORD vs_uniform_count;
164c2c66affSColin Finck DWORD ps_uniform_count;
165c2c66affSColin Finck unsigned int varying_count;
166c2c66affSColin Finck unsigned int ffp_textures;
167c2c66affSColin Finck unsigned int ffp_blend_stages;
168c2c66affSColin Finck unsigned int ffp_vertex_blend_matrices;
169c2c66affSColin Finck unsigned int active_light_count;
170c2c66affSColin Finck };
171c2c66affSColin Finck
172c2c66affSColin Finck typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
173c2c66affSColin Finck typedef void (WINE_GLAPI *wined3d_ffp_texcoord_func)(GLenum unit, const void *data);
174c2c66affSColin Finck typedef void (WINE_GLAPI *wined3d_generic_attrib_func)(GLuint idx, const void *data);
175c2c66affSColin Finck extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
176c2c66affSColin Finck
177c2c66affSColin Finck struct wined3d_ffp_attrib_ops
178c2c66affSColin Finck {
179c2c66affSColin Finck wined3d_ffp_attrib_func position[WINED3D_FFP_EMIT_COUNT];
180c2c66affSColin Finck wined3d_ffp_attrib_func diffuse[WINED3D_FFP_EMIT_COUNT];
181c2c66affSColin Finck wined3d_ffp_attrib_func specular[WINED3D_FFP_EMIT_COUNT];
182c2c66affSColin Finck wined3d_ffp_attrib_func normal[WINED3D_FFP_EMIT_COUNT];
183c2c66affSColin Finck wined3d_ffp_texcoord_func texcoord[WINED3D_FFP_EMIT_COUNT];
184c2c66affSColin Finck wined3d_generic_attrib_func generic[WINED3D_FFP_EMIT_COUNT];
185c2c66affSColin Finck };
186c2c66affSColin Finck
187c2c66affSColin Finck struct wined3d_d3d_info
188c2c66affSColin Finck {
189c2c66affSColin Finck struct wined3d_d3d_limits limits;
190c2c66affSColin Finck struct wined3d_ffp_attrib_ops ffp_attrib_ops;
191c2c66affSColin Finck BOOL xyzrhw;
192c2c66affSColin Finck BOOL emulated_flatshading;
193c2c66affSColin Finck BOOL ffp_generic_attributes;
194c2c66affSColin Finck BOOL vs_clipping;
195c2c66affSColin Finck BOOL shader_color_key;
196c2c66affSColin Finck DWORD valid_rt_mask;
1979987f029SAmine Khaldi DWORD valid_dual_rt_mask;
198c2c66affSColin Finck DWORD wined3d_creation_flags;
199c2c66affSColin Finck BOOL shader_double_precision;
200c2c66affSColin Finck };
201c2c66affSColin Finck
202c2c66affSColin Finck static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
203c2c66affSColin Finck {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
204c2c66affSColin Finck
create_color_fixup_desc(int sign0,enum fixup_channel_source src0,int sign1,enum fixup_channel_source src1,int sign2,enum fixup_channel_source src2,int sign3,enum fixup_channel_source src3)205c2c66affSColin Finck static inline struct color_fixup_desc create_color_fixup_desc(
206c2c66affSColin Finck int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1,
207c2c66affSColin Finck int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)
208c2c66affSColin Finck {
209c2c66affSColin Finck struct color_fixup_desc fixup =
210c2c66affSColin Finck {
211c2c66affSColin Finck sign0, src0,
212c2c66affSColin Finck sign1, src1,
213c2c66affSColin Finck sign2, src2,
214c2c66affSColin Finck sign3, src3,
215c2c66affSColin Finck };
216c2c66affSColin Finck return fixup;
217c2c66affSColin Finck }
218c2c66affSColin Finck
create_complex_fixup_desc(enum complex_fixup complex_fixup)219c2c66affSColin Finck static inline struct color_fixup_desc create_complex_fixup_desc(enum complex_fixup complex_fixup)
220c2c66affSColin Finck {
221c2c66affSColin Finck struct color_fixup_desc fixup =
222c2c66affSColin Finck {
223c2c66affSColin Finck 0u, complex_fixup & (1u << 0) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
224c2c66affSColin Finck 0u, complex_fixup & (1u << 1) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
225c2c66affSColin Finck 0u, complex_fixup & (1u << 2) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
226c2c66affSColin Finck 0u, complex_fixup & (1u << 3) ? CHANNEL_SOURCE_COMPLEX1 : CHANNEL_SOURCE_COMPLEX0,
227c2c66affSColin Finck };
228c2c66affSColin Finck return fixup;
229c2c66affSColin Finck }
230c2c66affSColin Finck
is_identity_fixup(struct color_fixup_desc fixup)231c2c66affSColin Finck static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
232c2c66affSColin Finck {
233c2c66affSColin Finck return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
234c2c66affSColin Finck }
235c2c66affSColin Finck
is_complex_fixup(struct color_fixup_desc fixup)236c2c66affSColin Finck static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
237c2c66affSColin Finck {
238c2c66affSColin Finck return fixup.x_source == CHANNEL_SOURCE_COMPLEX0 || fixup.x_source == CHANNEL_SOURCE_COMPLEX1;
239c2c66affSColin Finck }
240c2c66affSColin Finck
is_scaling_fixup(struct color_fixup_desc fixup)241c2c66affSColin Finck static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
242c2c66affSColin Finck {
243c2c66affSColin Finck return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
244c2c66affSColin Finck }
245c2c66affSColin Finck
is_same_fixup(struct color_fixup_desc f1,struct color_fixup_desc f2)246c2c66affSColin Finck static inline BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
247c2c66affSColin Finck {
248c2c66affSColin Finck return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
249c2c66affSColin Finck && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
250c2c66affSColin Finck && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
251c2c66affSColin Finck && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
252c2c66affSColin Finck }
253c2c66affSColin Finck
get_complex_fixup(struct color_fixup_desc fixup)254c2c66affSColin Finck static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
255c2c66affSColin Finck {
256c2c66affSColin Finck enum complex_fixup complex_fixup = 0;
257c2c66affSColin Finck if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
258c2c66affSColin Finck if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
259c2c66affSColin Finck if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
260c2c66affSColin Finck if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
261c2c66affSColin Finck return complex_fixup;
262c2c66affSColin Finck }
263c2c66affSColin Finck
264c2c66affSColin Finck /* Device caps */
265c2c66affSColin Finck #define MAX_STREAMS 16
266c2c66affSColin Finck #define MAX_TEXTURES 8
267c2c66affSColin Finck #define MAX_FRAGMENT_SAMPLERS 16
268c2c66affSColin Finck #define MAX_VERTEX_SAMPLERS 4
269c2c66affSColin Finck #define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
270c2c66affSColin Finck #define MAX_ACTIVE_LIGHTS 8
271d6ac0a71SAmine Khaldi #define MAX_CLIP_DISTANCES 8
272c2c66affSColin Finck #define MAX_CONSTANT_BUFFERS 15
273c2c66affSColin Finck #define MAX_SAMPLER_OBJECTS 16
274c2c66affSColin Finck #define MAX_SHADER_RESOURCE_VIEWS 128
2759987f029SAmine Khaldi #define MAX_RENDER_TARGET_VIEWS 8
276c2c66affSColin Finck #define MAX_UNORDERED_ACCESS_VIEWS 8
277c2c66affSColin Finck #define MAX_TGSM_REGISTERS 8192
278c2c66affSColin Finck #define MAX_VERTEX_BLENDS 4
2799987f029SAmine Khaldi #define MAX_VERTEX_INDEX_BLENDS 9
280*81cffd76SJoachim Henze #define MAX_MULTISAMPLE_TYPES 8
2819987f029SAmine Khaldi #define MAX_RENDER_TARGETS 8
282c2c66affSColin Finck
283c2c66affSColin Finck struct min_lookup
284c2c66affSColin Finck {
285c2c66affSColin Finck GLenum mip[WINED3D_TEXF_LINEAR + 1];
286c2c66affSColin Finck };
287c2c66affSColin Finck
288c2c66affSColin Finck extern const struct min_lookup minMipLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
289c2c66affSColin Finck extern const GLenum magLookup[WINED3D_TEXF_LINEAR + 1] DECLSPEC_HIDDEN;
290c2c66affSColin Finck
291c2c66affSColin Finck GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f) DECLSPEC_HIDDEN;
292c2c66affSColin Finck
wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)293c2c66affSColin Finck static inline enum wined3d_cmp_func wined3d_sanitize_cmp_func(enum wined3d_cmp_func func)
294c2c66affSColin Finck {
295c2c66affSColin Finck if (func < WINED3D_CMP_NEVER || func > WINED3D_CMP_ALWAYS)
296c2c66affSColin Finck return WINED3D_CMP_ALWAYS;
297c2c66affSColin Finck return func;
298c2c66affSColin Finck }
299c2c66affSColin Finck
wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)300c2c66affSColin Finck static inline GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
301c2c66affSColin Finck {
302c2c66affSColin Finck return magLookup[mag_filter];
303c2c66affSColin Finck }
304c2c66affSColin Finck
wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,enum wined3d_texture_filter_type mip_filter)305c2c66affSColin Finck static inline GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter,
306c2c66affSColin Finck enum wined3d_texture_filter_type mip_filter)
307c2c66affSColin Finck {
308c2c66affSColin Finck return minMipLookup[min_filter].mip[mip_filter];
309c2c66affSColin Finck }
310c2c66affSColin Finck
311c2c66affSColin Finck /* float_16_to_32() and float_32_to_16() (see implementation in
312c2c66affSColin Finck * surface_base.c) convert 16 bit floats in the FLOAT16 data type
313c2c66affSColin Finck * to standard C floats and vice versa. They do not depend on the encoding
314c2c66affSColin Finck * of the C float, so they are platform independent, but slow. On x86 and
315c2c66affSColin Finck * other IEEE 754 compliant platforms the conversion can be accelerated by
316c2c66affSColin Finck * bit shifting the exponent and mantissa. There are also some SSE-based
317c2c66affSColin Finck * assembly routines out there.
318c2c66affSColin Finck *
319c2c66affSColin Finck * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
320c2c66affSColin Finck */
float_16_to_32(const unsigned short * in)321c2c66affSColin Finck static inline float float_16_to_32(const unsigned short *in)
322c2c66affSColin Finck {
323c2c66affSColin Finck const unsigned short s = ((*in) & 0x8000u);
324c2c66affSColin Finck const unsigned short e = ((*in) & 0x7c00u) >> 10;
325c2c66affSColin Finck const unsigned short m = (*in) & 0x3ffu;
326c2c66affSColin Finck const float sgn = (s ? -1.0f : 1.0f);
327c2c66affSColin Finck
328c2c66affSColin Finck if(e == 0) {
329c2c66affSColin Finck if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
330c2c66affSColin Finck else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
331c2c66affSColin Finck } else if(e < 31) {
332c2c66affSColin Finck return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
333c2c66affSColin Finck } else {
334c2c66affSColin Finck if(m == 0) return sgn * INFINITY;
335c2c66affSColin Finck else return NAN;
336c2c66affSColin Finck }
337c2c66affSColin Finck }
338c2c66affSColin Finck
float_24_to_32(DWORD in)339c2c66affSColin Finck static inline float float_24_to_32(DWORD in)
340c2c66affSColin Finck {
341c2c66affSColin Finck const float sgn = in & 0x800000u ? -1.0f : 1.0f;
342c2c66affSColin Finck const unsigned short e = (in & 0x780000u) >> 19;
343c2c66affSColin Finck const unsigned int m = in & 0x7ffffu;
344c2c66affSColin Finck
345c2c66affSColin Finck if (e == 0)
346c2c66affSColin Finck {
347c2c66affSColin Finck if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
348c2c66affSColin Finck else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
349c2c66affSColin Finck }
350c2c66affSColin Finck else if (e < 15)
351c2c66affSColin Finck {
352c2c66affSColin Finck return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
353c2c66affSColin Finck }
354c2c66affSColin Finck else
355c2c66affSColin Finck {
356c2c66affSColin Finck if (m == 0) return sgn * INFINITY;
357c2c66affSColin Finck else return NAN;
358c2c66affSColin Finck }
359c2c66affSColin Finck }
360c2c66affSColin Finck
wined3d_popcount(unsigned int x)361c2c66affSColin Finck static inline unsigned int wined3d_popcount(unsigned int x)
362c2c66affSColin Finck {
363c2c66affSColin Finck #ifdef HAVE___BUILTIN_POPCOUNT
364c2c66affSColin Finck return __builtin_popcount(x);
365c2c66affSColin Finck #else
366c2c66affSColin Finck x -= x >> 1 & 0x55555555;
367c2c66affSColin Finck x = (x & 0x33333333) + (x >> 2 & 0x33333333);
368c2c66affSColin Finck return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
369c2c66affSColin Finck #endif
370c2c66affSColin Finck }
371c2c66affSColin Finck
wined3d_pause(void)372c2c66affSColin Finck static inline void wined3d_pause(void)
373c2c66affSColin Finck {
374c97e9defSThomas Faber #ifdef __REACTOS__
375c97e9defSThomas Faber Sleep(0);
376c97e9defSThomas Faber #else
377c2c66affSColin Finck #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
378c2c66affSColin Finck __asm__ __volatile__( "rep;nop" : : : "memory" );
379c2c66affSColin Finck #endif
380c97e9defSThomas Faber #endif
381c2c66affSColin Finck }
382c2c66affSColin Finck
383c2c66affSColin Finck #define ORM_BACKBUFFER 0
384c2c66affSColin Finck #define ORM_FBO 1
385c2c66affSColin Finck
386c2c66affSColin Finck #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
387c2c66affSColin Finck #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
388c2c66affSColin Finck
389c2c66affSColin Finck /* NOTE: When adding fields to this structure, make sure to update the default
390c2c66affSColin Finck * values in wined3d_main.c as well. */
391c2c66affSColin Finck struct wined3d_settings
392c2c66affSColin Finck {
393c2c66affSColin Finck unsigned int cs_multithreaded;
394d6ac0a71SAmine Khaldi BOOL explicit_gl_version;
395c2c66affSColin Finck DWORD max_gl_version;
396c2c66affSColin Finck BOOL glslRequested;
397c2c66affSColin Finck int offscreen_rendering_mode;
398c2c66affSColin Finck unsigned short pci_vendor_id;
399c2c66affSColin Finck unsigned short pci_device_id;
400c2c66affSColin Finck /* Memory tracking and object counting. */
401c2c66affSColin Finck UINT64 emulated_textureram;
402c2c66affSColin Finck char *logo;
4039987f029SAmine Khaldi unsigned int multisample_textures;
404c2c66affSColin Finck unsigned int sample_count;
405*81cffd76SJoachim Henze BOOL strict_draw_ordering;
406c2c66affSColin Finck BOOL check_float_constants;
407c2c66affSColin Finck unsigned int max_sm_vs;
408c2c66affSColin Finck unsigned int max_sm_hs;
409c2c66affSColin Finck unsigned int max_sm_ds;
410c2c66affSColin Finck unsigned int max_sm_gs;
411c2c66affSColin Finck unsigned int max_sm_ps;
412c2c66affSColin Finck unsigned int max_sm_cs;
413c2c66affSColin Finck BOOL no_3d;
414c2c66affSColin Finck };
415c2c66affSColin Finck
416c2c66affSColin Finck extern struct wined3d_settings wined3d_settings DECLSPEC_HIDDEN;
417c2c66affSColin Finck
418c2c66affSColin Finck enum wined3d_shader_resource_type
419c2c66affSColin Finck {
420c2c66affSColin Finck WINED3D_SHADER_RESOURCE_NONE,
421c2c66affSColin Finck WINED3D_SHADER_RESOURCE_BUFFER,
422c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_1D,
423c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_2D,
424c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_2DMS,
425c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_3D,
426c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_CUBE,
427c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY,
428c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY,
429c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY,
430c2c66affSColin Finck WINED3D_SHADER_RESOURCE_TEXTURE_CUBEARRAY,
431c2c66affSColin Finck };
432c2c66affSColin Finck
433c2c66affSColin Finck #define WINED3D_SHADER_CONST_VS_F 0x00000001
434c2c66affSColin Finck #define WINED3D_SHADER_CONST_VS_I 0x00000002
435c2c66affSColin Finck #define WINED3D_SHADER_CONST_VS_B 0x00000004
436c2c66affSColin Finck #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
437c2c66affSColin Finck #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
438c2c66affSColin Finck #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
439c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_F 0x00000040
440c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_I 0x00000080
441c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_B 0x00000100
442c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
443c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
444c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
445c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
446c2c66affSColin Finck #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
447c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
448c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
449c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
450c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
451c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
452c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
453c2c66affSColin Finck #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
4549987f029SAmine Khaldi #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0xff000000
4559987f029SAmine Khaldi #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND_INDEX(i) (0x01000000 << ((i) - 1))
456c2c66affSColin Finck
457c2c66affSColin Finck enum wined3d_shader_register_type
458c2c66affSColin Finck {
459c2c66affSColin Finck WINED3DSPR_TEMP = 0,
460c2c66affSColin Finck WINED3DSPR_INPUT = 1,
461c2c66affSColin Finck WINED3DSPR_CONST = 2,
462c2c66affSColin Finck WINED3DSPR_ADDR = 3,
463c2c66affSColin Finck WINED3DSPR_TEXTURE = 3,
464c2c66affSColin Finck WINED3DSPR_RASTOUT = 4,
465c2c66affSColin Finck WINED3DSPR_ATTROUT = 5,
466c2c66affSColin Finck WINED3DSPR_TEXCRDOUT = 6,
467c2c66affSColin Finck WINED3DSPR_OUTPUT = 6,
468c2c66affSColin Finck WINED3DSPR_CONSTINT = 7,
469c2c66affSColin Finck WINED3DSPR_COLOROUT = 8,
470c2c66affSColin Finck WINED3DSPR_DEPTHOUT = 9,
471c2c66affSColin Finck WINED3DSPR_SAMPLER = 10,
472c2c66affSColin Finck WINED3DSPR_CONST2 = 11,
473c2c66affSColin Finck WINED3DSPR_CONST3 = 12,
474c2c66affSColin Finck WINED3DSPR_CONST4 = 13,
475c2c66affSColin Finck WINED3DSPR_CONSTBOOL = 14,
476c2c66affSColin Finck WINED3DSPR_LOOP = 15,
477c2c66affSColin Finck WINED3DSPR_TEMPFLOAT16 = 16,
478c2c66affSColin Finck WINED3DSPR_MISCTYPE = 17,
479c2c66affSColin Finck WINED3DSPR_LABEL = 18,
480c2c66affSColin Finck WINED3DSPR_PREDICATE = 19,
481c2c66affSColin Finck WINED3DSPR_IMMCONST,
482c2c66affSColin Finck WINED3DSPR_CONSTBUFFER,
483c2c66affSColin Finck WINED3DSPR_IMMCONSTBUFFER,
484c2c66affSColin Finck WINED3DSPR_PRIMID,
485c2c66affSColin Finck WINED3DSPR_NULL,
486c2c66affSColin Finck WINED3DSPR_RESOURCE,
487c2c66affSColin Finck WINED3DSPR_UAV,
488c2c66affSColin Finck WINED3DSPR_OUTPOINTID,
489c2c66affSColin Finck WINED3DSPR_FORKINSTID,
490c2c66affSColin Finck WINED3DSPR_JOININSTID,
491c2c66affSColin Finck WINED3DSPR_INCONTROLPOINT,
492c2c66affSColin Finck WINED3DSPR_OUTCONTROLPOINT,
493c2c66affSColin Finck WINED3DSPR_PATCHCONST,
494c2c66affSColin Finck WINED3DSPR_TESSCOORD,
495c2c66affSColin Finck WINED3DSPR_GROUPSHAREDMEM,
496c2c66affSColin Finck WINED3DSPR_THREADID,
497c2c66affSColin Finck WINED3DSPR_THREADGROUPID,
498c2c66affSColin Finck WINED3DSPR_LOCALTHREADID,
499c2c66affSColin Finck WINED3DSPR_LOCALTHREADINDEX,
500c2c66affSColin Finck WINED3DSPR_IDXTEMP,
501c2c66affSColin Finck WINED3DSPR_STREAM,
502c2c66affSColin Finck WINED3DSPR_FUNCTIONBODY,
503c2c66affSColin Finck WINED3DSPR_FUNCTIONPOINTER,
504c2c66affSColin Finck WINED3DSPR_COVERAGE,
505c2c66affSColin Finck WINED3DSPR_SAMPLEMASK,
506c2c66affSColin Finck WINED3DSPR_GSINSTID,
507d6ac0a71SAmine Khaldi WINED3DSPR_DEPTHOUTGE,
508d6ac0a71SAmine Khaldi WINED3DSPR_DEPTHOUTLE,
509c2c66affSColin Finck };
510c2c66affSColin Finck
511c2c66affSColin Finck enum wined3d_data_type
512c2c66affSColin Finck {
513c2c66affSColin Finck WINED3D_DATA_FLOAT,
514c2c66affSColin Finck WINED3D_DATA_INT,
515c2c66affSColin Finck WINED3D_DATA_RESOURCE,
516c2c66affSColin Finck WINED3D_DATA_SAMPLER,
517c2c66affSColin Finck WINED3D_DATA_UAV,
518c2c66affSColin Finck WINED3D_DATA_UINT,
519c2c66affSColin Finck WINED3D_DATA_UNORM,
520c2c66affSColin Finck WINED3D_DATA_SNORM,
521c2c66affSColin Finck WINED3D_DATA_OPAQUE,
522c2c66affSColin Finck };
523c2c66affSColin Finck
524c2c66affSColin Finck enum wined3d_immconst_type
525c2c66affSColin Finck {
526c2c66affSColin Finck WINED3D_IMMCONST_SCALAR,
527c2c66affSColin Finck WINED3D_IMMCONST_VEC4,
528c2c66affSColin Finck };
529c2c66affSColin Finck
530c2c66affSColin Finck #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
531c2c66affSColin Finck
532c2c66affSColin Finck enum wined3d_shader_src_modifier
533c2c66affSColin Finck {
534c2c66affSColin Finck WINED3DSPSM_NONE = 0,
535c2c66affSColin Finck WINED3DSPSM_NEG = 1,
536c2c66affSColin Finck WINED3DSPSM_BIAS = 2,
537c2c66affSColin Finck WINED3DSPSM_BIASNEG = 3,
538c2c66affSColin Finck WINED3DSPSM_SIGN = 4,
539c2c66affSColin Finck WINED3DSPSM_SIGNNEG = 5,
540c2c66affSColin Finck WINED3DSPSM_COMP = 6,
541c2c66affSColin Finck WINED3DSPSM_X2 = 7,
542c2c66affSColin Finck WINED3DSPSM_X2NEG = 8,
543c2c66affSColin Finck WINED3DSPSM_DZ = 9,
544c2c66affSColin Finck WINED3DSPSM_DW = 10,
545c2c66affSColin Finck WINED3DSPSM_ABS = 11,
546c2c66affSColin Finck WINED3DSPSM_ABSNEG = 12,
547c2c66affSColin Finck WINED3DSPSM_NOT = 13,
548c2c66affSColin Finck };
549c2c66affSColin Finck
550c2c66affSColin Finck #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
551c2c66affSColin Finck #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
552c2c66affSColin Finck #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
553c2c66affSColin Finck #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
554c2c66affSColin Finck #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
555c2c66affSColin Finck
556c2c66affSColin Finck enum wined3d_shader_dst_modifier
557c2c66affSColin Finck {
558c2c66affSColin Finck WINED3DSPDM_NONE = 0,
559c2c66affSColin Finck WINED3DSPDM_SATURATE = 1,
560c2c66affSColin Finck WINED3DSPDM_PARTIALPRECISION = 2,
561c2c66affSColin Finck WINED3DSPDM_MSAMPCENTROID = 4,
562c2c66affSColin Finck };
563c2c66affSColin Finck
564c2c66affSColin Finck enum wined3d_shader_interpolation_mode
565c2c66affSColin Finck {
566d6ac0a71SAmine Khaldi WINED3DSIM_NONE = 0,
567c2c66affSColin Finck WINED3DSIM_CONSTANT = 1,
568c2c66affSColin Finck WINED3DSIM_LINEAR = 2,
569c2c66affSColin Finck WINED3DSIM_LINEAR_CENTROID = 3,
570c2c66affSColin Finck WINED3DSIM_LINEAR_NOPERSPECTIVE = 4,
571c2c66affSColin Finck WINED3DSIM_LINEAR_NOPERSPECTIVE_CENTROID = 5,
572c2c66affSColin Finck WINED3DSIM_LINEAR_SAMPLE = 6,
573c2c66affSColin Finck WINED3DSIM_LINEAR_NOPERSPECTIVE_SAMPLE = 7,
574c2c66affSColin Finck };
575c2c66affSColin Finck
576d6ac0a71SAmine Khaldi #define WINED3D_PACKED_INTERPOLATION_SIZE 3
577d6ac0a71SAmine Khaldi #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
578d6ac0a71SAmine Khaldi
579c2c66affSColin Finck enum wined3d_shader_global_flags
580c2c66affSColin Finck {
581c2c66affSColin Finck WINED3DSGF_REFACTORING_ALLOWED = 0x1,
582c2c66affSColin Finck WINED3DSGF_FORCE_EARLY_DEPTH_STENCIL = 0x4,
583c2c66affSColin Finck WINED3DSGF_ENABLE_RAW_AND_STRUCTURED_BUFFERS = 0x8,
584c2c66affSColin Finck };
585c2c66affSColin Finck
586c2c66affSColin Finck enum wined3d_shader_sync_flags
587c2c66affSColin Finck {
588c2c66affSColin Finck WINED3DSSF_THREAD_GROUP = 0x1,
589c2c66affSColin Finck WINED3DSSF_GROUP_SHARED_MEMORY = 0x2,
590c2c66affSColin Finck };
591c2c66affSColin Finck
592c2c66affSColin Finck enum wined3d_shader_uav_flags
593c2c66affSColin Finck {
594c2c66affSColin Finck WINED3DSUF_GLOBALLY_COHERENT = 0x2,
595c2c66affSColin Finck WINED3DSUF_ORDER_PRESERVING_COUNTER = 0x100,
596c2c66affSColin Finck };
597c2c66affSColin Finck
598c2c66affSColin Finck enum wined3d_tessellator_domain
599c2c66affSColin Finck {
600c2c66affSColin Finck WINED3D_TESSELLATOR_DOMAIN_LINE = 1,
601c2c66affSColin Finck WINED3D_TESSELLATOR_DOMAIN_TRIANGLE = 2,
602c2c66affSColin Finck WINED3D_TESSELLATOR_DOMAIN_QUAD = 3,
603c2c66affSColin Finck };
604c2c66affSColin Finck
605c2c66affSColin Finck enum wined3d_tessellator_output_primitive
606c2c66affSColin Finck {
607c2c66affSColin Finck WINED3D_TESSELLATOR_OUTPUT_POINT = 1,
608c2c66affSColin Finck WINED3D_TESSELLATOR_OUTPUT_LINE = 2,
609c2c66affSColin Finck WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CW = 3,
610c2c66affSColin Finck WINED3D_TESSELLATOR_OUTPUT_TRIANGLE_CCW = 4,
611c2c66affSColin Finck };
612c2c66affSColin Finck
613c2c66affSColin Finck enum wined3d_tessellator_partitioning
614c2c66affSColin Finck {
615c2c66affSColin Finck WINED3D_TESSELLATOR_PARTITIONING_INTEGER = 1,
616c2c66affSColin Finck WINED3D_TESSELLATOR_PARTITIONING_POW2 = 2,
617c2c66affSColin Finck WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_ODD = 3,
618c2c66affSColin Finck WINED3D_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN = 4,
619c2c66affSColin Finck };
620c2c66affSColin Finck
621c2c66affSColin Finck /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
622c2c66affSColin Finck #define WINED3DSI_TEXLD_PROJECT 0x1
623c2c66affSColin Finck #define WINED3DSI_TEXLD_BIAS 0x2
624c2c66affSColin Finck #define WINED3DSI_INDEXED_DYNAMIC 0x4
625c2c66affSColin Finck #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
626c2c66affSColin Finck #define WINED3DSI_RESINFO_UINT 0x2
627c2c66affSColin Finck #define WINED3DSI_SAMPLE_INFO_UINT 0x1
628c2c66affSColin Finck #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
629c2c66affSColin Finck
630c2c66affSColin Finck enum wined3d_shader_rel_op
631c2c66affSColin Finck {
632c2c66affSColin Finck WINED3D_SHADER_REL_OP_GT = 1,
633c2c66affSColin Finck WINED3D_SHADER_REL_OP_EQ = 2,
634c2c66affSColin Finck WINED3D_SHADER_REL_OP_GE = 3,
635c2c66affSColin Finck WINED3D_SHADER_REL_OP_LT = 4,
636c2c66affSColin Finck WINED3D_SHADER_REL_OP_NE = 5,
637c2c66affSColin Finck WINED3D_SHADER_REL_OP_LE = 6,
638c2c66affSColin Finck };
639c2c66affSColin Finck
640c2c66affSColin Finck enum wined3d_shader_conditional_op
641c2c66affSColin Finck {
642c2c66affSColin Finck WINED3D_SHADER_CONDITIONAL_OP_NZ = 0,
643c2c66affSColin Finck WINED3D_SHADER_CONDITIONAL_OP_Z = 1
644c2c66affSColin Finck };
645c2c66affSColin Finck
646c2c66affSColin Finck #define WINED3D_SM1_VS 0xfffeu
647c2c66affSColin Finck #define WINED3D_SM1_PS 0xffffu
648c2c66affSColin Finck #define WINED3D_SM4_PS 0x0000u
649c2c66affSColin Finck #define WINED3D_SM4_VS 0x0001u
650c2c66affSColin Finck #define WINED3D_SM4_GS 0x0002u
651c2c66affSColin Finck #define WINED3D_SM5_HS 0x0003u
652c2c66affSColin Finck #define WINED3D_SM5_DS 0x0004u
653c2c66affSColin Finck #define WINED3D_SM5_CS 0x0005u
654c2c66affSColin Finck
655c2c66affSColin Finck /* Shader version tokens, and shader end tokens */
656c2c66affSColin Finck #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
657c2c66affSColin Finck #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
658c2c66affSColin Finck
659c2c66affSColin Finck /* Shader backends */
660c2c66affSColin Finck
661c2c66affSColin Finck /* TODO: Make this dynamic, based on shader limits ? */
662c2c66affSColin Finck #define MAX_ATTRIBS 16
663c2c66affSColin Finck #define MAX_REG_ADDR 1
664c2c66affSColin Finck #define MAX_REG_TEXCRD 8
665c2c66affSColin Finck #define MAX_REG_INPUT 32
666c2c66affSColin Finck #define MAX_REG_OUTPUT 32
667c2c66affSColin Finck #define WINED3D_MAX_CBS 15
668c2c66affSColin Finck #define WINED3D_MAX_CONSTS_B 16
669c2c66affSColin Finck #define WINED3D_MAX_CONSTS_I 16
670c2c66affSColin Finck #define WINED3D_MAX_VS_CONSTS_F 256
671c2c66affSColin Finck #define WINED3D_MAX_PS_CONSTS_F 224
672c2c66affSColin Finck
673c2c66affSColin Finck /* FIXME: This needs to go up to 2048 for
674c2c66affSColin Finck * Shader model 3 according to msdn (and for software shaders) */
675c2c66affSColin Finck #define MAX_LABELS 16
676c2c66affSColin Finck
677c2c66affSColin Finck #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
678c2c66affSColin Finck
679c2c66affSColin Finck struct wined3d_string_buffer
680c2c66affSColin Finck {
681c2c66affSColin Finck struct list entry;
682c2c66affSColin Finck char *buffer;
683c2c66affSColin Finck unsigned int buffer_size;
684c2c66affSColin Finck unsigned int content_size;
685c2c66affSColin Finck };
686c2c66affSColin Finck
687c2c66affSColin Finck enum WINED3D_SHADER_INSTRUCTION_HANDLER
688c2c66affSColin Finck {
689c2c66affSColin Finck WINED3DSIH_ABS,
690c2c66affSColin Finck WINED3DSIH_ADD,
691c2c66affSColin Finck WINED3DSIH_AND,
692c2c66affSColin Finck WINED3DSIH_ATOMIC_AND,
693c2c66affSColin Finck WINED3DSIH_ATOMIC_CMP_STORE,
694c2c66affSColin Finck WINED3DSIH_ATOMIC_IADD,
695c2c66affSColin Finck WINED3DSIH_ATOMIC_IMAX,
696c2c66affSColin Finck WINED3DSIH_ATOMIC_IMIN,
697c2c66affSColin Finck WINED3DSIH_ATOMIC_OR,
698c2c66affSColin Finck WINED3DSIH_ATOMIC_UMAX,
699c2c66affSColin Finck WINED3DSIH_ATOMIC_UMIN,
700c2c66affSColin Finck WINED3DSIH_ATOMIC_XOR,
701c2c66affSColin Finck WINED3DSIH_BEM,
702c2c66affSColin Finck WINED3DSIH_BFI,
703c2c66affSColin Finck WINED3DSIH_BFREV,
704c2c66affSColin Finck WINED3DSIH_BREAK,
705c2c66affSColin Finck WINED3DSIH_BREAKC,
706c2c66affSColin Finck WINED3DSIH_BREAKP,
707c2c66affSColin Finck WINED3DSIH_BUFINFO,
708c2c66affSColin Finck WINED3DSIH_CALL,
709c2c66affSColin Finck WINED3DSIH_CALLNZ,
710c2c66affSColin Finck WINED3DSIH_CASE,
711c2c66affSColin Finck WINED3DSIH_CMP,
712c2c66affSColin Finck WINED3DSIH_CND,
713c2c66affSColin Finck WINED3DSIH_CONTINUE,
714c2c66affSColin Finck WINED3DSIH_CONTINUEP,
715c2c66affSColin Finck WINED3DSIH_COUNTBITS,
716c2c66affSColin Finck WINED3DSIH_CRS,
717c2c66affSColin Finck WINED3DSIH_CUT,
718c2c66affSColin Finck WINED3DSIH_CUT_STREAM,
719c2c66affSColin Finck WINED3DSIH_DCL,
720c2c66affSColin Finck WINED3DSIH_DCL_CONSTANT_BUFFER,
721c2c66affSColin Finck WINED3DSIH_DCL_FUNCTION_BODY,
722c2c66affSColin Finck WINED3DSIH_DCL_FUNCTION_TABLE,
723c2c66affSColin Finck WINED3DSIH_DCL_GLOBAL_FLAGS,
724c2c66affSColin Finck WINED3DSIH_DCL_GS_INSTANCES,
725c2c66affSColin Finck WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT,
726c2c66affSColin Finck WINED3DSIH_DCL_HS_JOIN_PHASE_INSTANCE_COUNT,
727c2c66affSColin Finck WINED3DSIH_DCL_HS_MAX_TESSFACTOR,
728c2c66affSColin Finck WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER,
729c2c66affSColin Finck WINED3DSIH_DCL_INDEX_RANGE,
730c2c66affSColin Finck WINED3DSIH_DCL_INDEXABLE_TEMP,
731c2c66affSColin Finck WINED3DSIH_DCL_INPUT,
732c2c66affSColin Finck WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT,
733c2c66affSColin Finck WINED3DSIH_DCL_INPUT_PRIMITIVE,
734c2c66affSColin Finck WINED3DSIH_DCL_INPUT_PS,
735c2c66affSColin Finck WINED3DSIH_DCL_INPUT_PS_SGV,
736c2c66affSColin Finck WINED3DSIH_DCL_INPUT_PS_SIV,
737c2c66affSColin Finck WINED3DSIH_DCL_INPUT_SGV,
738c2c66affSColin Finck WINED3DSIH_DCL_INPUT_SIV,
739c2c66affSColin Finck WINED3DSIH_DCL_INTERFACE,
740c2c66affSColin Finck WINED3DSIH_DCL_OUTPUT,
741c2c66affSColin Finck WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT,
742c2c66affSColin Finck WINED3DSIH_DCL_OUTPUT_SIV,
743c2c66affSColin Finck WINED3DSIH_DCL_OUTPUT_TOPOLOGY,
744c2c66affSColin Finck WINED3DSIH_DCL_RESOURCE_RAW,
745c2c66affSColin Finck WINED3DSIH_DCL_RESOURCE_STRUCTURED,
746c2c66affSColin Finck WINED3DSIH_DCL_SAMPLER,
747c2c66affSColin Finck WINED3DSIH_DCL_STREAM,
748c2c66affSColin Finck WINED3DSIH_DCL_TEMPS,
749c2c66affSColin Finck WINED3DSIH_DCL_TESSELLATOR_DOMAIN,
750c2c66affSColin Finck WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE,
751c2c66affSColin Finck WINED3DSIH_DCL_TESSELLATOR_PARTITIONING,
752c2c66affSColin Finck WINED3DSIH_DCL_TGSM_RAW,
753c2c66affSColin Finck WINED3DSIH_DCL_TGSM_STRUCTURED,
754c2c66affSColin Finck WINED3DSIH_DCL_THREAD_GROUP,
755c2c66affSColin Finck WINED3DSIH_DCL_UAV_RAW,
756c2c66affSColin Finck WINED3DSIH_DCL_UAV_STRUCTURED,
757c2c66affSColin Finck WINED3DSIH_DCL_UAV_TYPED,
758c2c66affSColin Finck WINED3DSIH_DCL_VERTICES_OUT,
759c2c66affSColin Finck WINED3DSIH_DEF,
760c2c66affSColin Finck WINED3DSIH_DEFAULT,
761c2c66affSColin Finck WINED3DSIH_DEFB,
762c2c66affSColin Finck WINED3DSIH_DEFI,
763c2c66affSColin Finck WINED3DSIH_DIV,
764c2c66affSColin Finck WINED3DSIH_DP2,
765c2c66affSColin Finck WINED3DSIH_DP2ADD,
766c2c66affSColin Finck WINED3DSIH_DP3,
767c2c66affSColin Finck WINED3DSIH_DP4,
768c2c66affSColin Finck WINED3DSIH_DST,
769c2c66affSColin Finck WINED3DSIH_DSX,
770c2c66affSColin Finck WINED3DSIH_DSX_COARSE,
771c2c66affSColin Finck WINED3DSIH_DSX_FINE,
772c2c66affSColin Finck WINED3DSIH_DSY,
773c2c66affSColin Finck WINED3DSIH_DSY_COARSE,
774c2c66affSColin Finck WINED3DSIH_DSY_FINE,
775d6ac0a71SAmine Khaldi WINED3DSIH_EVAL_SAMPLE_INDEX,
776c2c66affSColin Finck WINED3DSIH_ELSE,
777c2c66affSColin Finck WINED3DSIH_EMIT,
778c2c66affSColin Finck WINED3DSIH_EMIT_STREAM,
779c2c66affSColin Finck WINED3DSIH_ENDIF,
780c2c66affSColin Finck WINED3DSIH_ENDLOOP,
781c2c66affSColin Finck WINED3DSIH_ENDREP,
782c2c66affSColin Finck WINED3DSIH_ENDSWITCH,
783c2c66affSColin Finck WINED3DSIH_EQ,
784c2c66affSColin Finck WINED3DSIH_EXP,
785c2c66affSColin Finck WINED3DSIH_EXPP,
786c2c66affSColin Finck WINED3DSIH_F16TOF32,
787c2c66affSColin Finck WINED3DSIH_F32TOF16,
788c2c66affSColin Finck WINED3DSIH_FCALL,
789c2c66affSColin Finck WINED3DSIH_FIRSTBIT_HI,
790c2c66affSColin Finck WINED3DSIH_FIRSTBIT_LO,
791c2c66affSColin Finck WINED3DSIH_FIRSTBIT_SHI,
792c2c66affSColin Finck WINED3DSIH_FRC,
793c2c66affSColin Finck WINED3DSIH_FTOI,
794c2c66affSColin Finck WINED3DSIH_FTOU,
795c2c66affSColin Finck WINED3DSIH_GATHER4,
796c2c66affSColin Finck WINED3DSIH_GATHER4_C,
797c2c66affSColin Finck WINED3DSIH_GATHER4_PO,
798c2c66affSColin Finck WINED3DSIH_GATHER4_PO_C,
799c2c66affSColin Finck WINED3DSIH_GE,
800c2c66affSColin Finck WINED3DSIH_HS_CONTROL_POINT_PHASE,
801c2c66affSColin Finck WINED3DSIH_HS_DECLS,
802c2c66affSColin Finck WINED3DSIH_HS_FORK_PHASE,
803c2c66affSColin Finck WINED3DSIH_HS_JOIN_PHASE,
804c2c66affSColin Finck WINED3DSIH_IADD,
805c2c66affSColin Finck WINED3DSIH_IBFE,
806c2c66affSColin Finck WINED3DSIH_IEQ,
807c2c66affSColin Finck WINED3DSIH_IF,
808c2c66affSColin Finck WINED3DSIH_IFC,
809c2c66affSColin Finck WINED3DSIH_IGE,
810c2c66affSColin Finck WINED3DSIH_ILT,
811c2c66affSColin Finck WINED3DSIH_IMAD,
812c2c66affSColin Finck WINED3DSIH_IMAX,
813c2c66affSColin Finck WINED3DSIH_IMIN,
814c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_ALLOC,
815c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_AND,
816c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_CMP_EXCH,
817c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_CONSUME,
818c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_EXCH,
819c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_IADD,
820c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_IMAX,
821c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_IMIN,
822c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_OR,
823c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_UMAX,
824c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_UMIN,
825c2c66affSColin Finck WINED3DSIH_IMM_ATOMIC_XOR,
826c2c66affSColin Finck WINED3DSIH_IMUL,
827c2c66affSColin Finck WINED3DSIH_INE,
828c2c66affSColin Finck WINED3DSIH_INEG,
829c2c66affSColin Finck WINED3DSIH_ISHL,
830c2c66affSColin Finck WINED3DSIH_ISHR,
831c2c66affSColin Finck WINED3DSIH_ITOF,
832c2c66affSColin Finck WINED3DSIH_LABEL,
833c2c66affSColin Finck WINED3DSIH_LD,
834c2c66affSColin Finck WINED3DSIH_LD2DMS,
835c2c66affSColin Finck WINED3DSIH_LD_RAW,
836c2c66affSColin Finck WINED3DSIH_LD_STRUCTURED,
837c2c66affSColin Finck WINED3DSIH_LD_UAV_TYPED,
838c2c66affSColin Finck WINED3DSIH_LIT,
839c2c66affSColin Finck WINED3DSIH_LOD,
840c2c66affSColin Finck WINED3DSIH_LOG,
841c2c66affSColin Finck WINED3DSIH_LOGP,
842c2c66affSColin Finck WINED3DSIH_LOOP,
843c2c66affSColin Finck WINED3DSIH_LRP,
844c2c66affSColin Finck WINED3DSIH_LT,
845c2c66affSColin Finck WINED3DSIH_M3x2,
846c2c66affSColin Finck WINED3DSIH_M3x3,
847c2c66affSColin Finck WINED3DSIH_M3x4,
848c2c66affSColin Finck WINED3DSIH_M4x3,
849c2c66affSColin Finck WINED3DSIH_M4x4,
850c2c66affSColin Finck WINED3DSIH_MAD,
851c2c66affSColin Finck WINED3DSIH_MAX,
852c2c66affSColin Finck WINED3DSIH_MIN,
853c2c66affSColin Finck WINED3DSIH_MOV,
854c2c66affSColin Finck WINED3DSIH_MOVA,
855c2c66affSColin Finck WINED3DSIH_MOVC,
856c2c66affSColin Finck WINED3DSIH_MUL,
857c2c66affSColin Finck WINED3DSIH_NE,
858c2c66affSColin Finck WINED3DSIH_NOP,
859c2c66affSColin Finck WINED3DSIH_NOT,
860c2c66affSColin Finck WINED3DSIH_NRM,
861c2c66affSColin Finck WINED3DSIH_OR,
862c2c66affSColin Finck WINED3DSIH_PHASE,
863c2c66affSColin Finck WINED3DSIH_POW,
864c2c66affSColin Finck WINED3DSIH_RCP,
865c2c66affSColin Finck WINED3DSIH_REP,
866c2c66affSColin Finck WINED3DSIH_RESINFO,
867c2c66affSColin Finck WINED3DSIH_RET,
868c2c66affSColin Finck WINED3DSIH_RETP,
869c2c66affSColin Finck WINED3DSIH_ROUND_NE,
870c2c66affSColin Finck WINED3DSIH_ROUND_NI,
871c2c66affSColin Finck WINED3DSIH_ROUND_PI,
872c2c66affSColin Finck WINED3DSIH_ROUND_Z,
873c2c66affSColin Finck WINED3DSIH_RSQ,
874c2c66affSColin Finck WINED3DSIH_SAMPLE,
875c2c66affSColin Finck WINED3DSIH_SAMPLE_B,
876c2c66affSColin Finck WINED3DSIH_SAMPLE_C,
877c2c66affSColin Finck WINED3DSIH_SAMPLE_C_LZ,
878c2c66affSColin Finck WINED3DSIH_SAMPLE_GRAD,
879c2c66affSColin Finck WINED3DSIH_SAMPLE_INFO,
880c2c66affSColin Finck WINED3DSIH_SAMPLE_LOD,
881c2c66affSColin Finck WINED3DSIH_SAMPLE_POS,
882c2c66affSColin Finck WINED3DSIH_SETP,
883c2c66affSColin Finck WINED3DSIH_SGE,
884c2c66affSColin Finck WINED3DSIH_SGN,
885c2c66affSColin Finck WINED3DSIH_SINCOS,
886c2c66affSColin Finck WINED3DSIH_SLT,
887c2c66affSColin Finck WINED3DSIH_SQRT,
888c2c66affSColin Finck WINED3DSIH_STORE_RAW,
889c2c66affSColin Finck WINED3DSIH_STORE_STRUCTURED,
890c2c66affSColin Finck WINED3DSIH_STORE_UAV_TYPED,
891c2c66affSColin Finck WINED3DSIH_SUB,
892c2c66affSColin Finck WINED3DSIH_SWAPC,
893c2c66affSColin Finck WINED3DSIH_SWITCH,
894c2c66affSColin Finck WINED3DSIH_SYNC,
895c2c66affSColin Finck WINED3DSIH_TEX,
896c2c66affSColin Finck WINED3DSIH_TEXBEM,
897c2c66affSColin Finck WINED3DSIH_TEXBEML,
898c2c66affSColin Finck WINED3DSIH_TEXCOORD,
899c2c66affSColin Finck WINED3DSIH_TEXDEPTH,
900c2c66affSColin Finck WINED3DSIH_TEXDP3,
901c2c66affSColin Finck WINED3DSIH_TEXDP3TEX,
902c2c66affSColin Finck WINED3DSIH_TEXKILL,
903c2c66affSColin Finck WINED3DSIH_TEXLDD,
904c2c66affSColin Finck WINED3DSIH_TEXLDL,
905c2c66affSColin Finck WINED3DSIH_TEXM3x2DEPTH,
906c2c66affSColin Finck WINED3DSIH_TEXM3x2PAD,
907c2c66affSColin Finck WINED3DSIH_TEXM3x2TEX,
908c2c66affSColin Finck WINED3DSIH_TEXM3x3,
909c2c66affSColin Finck WINED3DSIH_TEXM3x3DIFF,
910c2c66affSColin Finck WINED3DSIH_TEXM3x3PAD,
911c2c66affSColin Finck WINED3DSIH_TEXM3x3SPEC,
912c2c66affSColin Finck WINED3DSIH_TEXM3x3TEX,
913c2c66affSColin Finck WINED3DSIH_TEXM3x3VSPEC,
914c2c66affSColin Finck WINED3DSIH_TEXREG2AR,
915c2c66affSColin Finck WINED3DSIH_TEXREG2GB,
916c2c66affSColin Finck WINED3DSIH_TEXREG2RGB,
917c2c66affSColin Finck WINED3DSIH_UBFE,
918c2c66affSColin Finck WINED3DSIH_UDIV,
919c2c66affSColin Finck WINED3DSIH_UGE,
920c2c66affSColin Finck WINED3DSIH_ULT,
921c2c66affSColin Finck WINED3DSIH_UMAX,
922c2c66affSColin Finck WINED3DSIH_UMIN,
923c2c66affSColin Finck WINED3DSIH_UMUL,
924c2c66affSColin Finck WINED3DSIH_USHR,
925c2c66affSColin Finck WINED3DSIH_UTOF,
926c2c66affSColin Finck WINED3DSIH_XOR,
927c2c66affSColin Finck WINED3DSIH_TABLE_SIZE
928c2c66affSColin Finck };
929c2c66affSColin Finck
930c2c66affSColin Finck enum wined3d_shader_type
931c2c66affSColin Finck {
932c2c66affSColin Finck WINED3D_SHADER_TYPE_PIXEL,
933c2c66affSColin Finck WINED3D_SHADER_TYPE_VERTEX,
934c2c66affSColin Finck WINED3D_SHADER_TYPE_GEOMETRY,
935c2c66affSColin Finck WINED3D_SHADER_TYPE_HULL,
936c2c66affSColin Finck WINED3D_SHADER_TYPE_DOMAIN,
937c2c66affSColin Finck WINED3D_SHADER_TYPE_GRAPHICS_COUNT,
938c2c66affSColin Finck
939c2c66affSColin Finck WINED3D_SHADER_TYPE_COMPUTE = WINED3D_SHADER_TYPE_GRAPHICS_COUNT,
940c2c66affSColin Finck WINED3D_SHADER_TYPE_COUNT,
941c2c66affSColin Finck };
942c2c66affSColin Finck
943c2c66affSColin Finck struct wined3d_shader_version
944c2c66affSColin Finck {
945c2c66affSColin Finck enum wined3d_shader_type type;
946c2c66affSColin Finck BYTE major;
947c2c66affSColin Finck BYTE minor;
948c2c66affSColin Finck };
949c2c66affSColin Finck
950c2c66affSColin Finck struct wined3d_shader_resource_info
951c2c66affSColin Finck {
952c2c66affSColin Finck enum wined3d_shader_resource_type type;
953c2c66affSColin Finck enum wined3d_data_type data_type;
954c2c66affSColin Finck unsigned int flags;
955c2c66affSColin Finck unsigned int stride;
956c2c66affSColin Finck };
957c2c66affSColin Finck
958c2c66affSColin Finck #define WINED3D_SAMPLER_DEFAULT ~0x0u
959c2c66affSColin Finck
960c2c66affSColin Finck struct wined3d_shader_sampler_map_entry
961c2c66affSColin Finck {
962c2c66affSColin Finck unsigned int resource_idx;
963c2c66affSColin Finck unsigned int sampler_idx;
964c2c66affSColin Finck unsigned int bind_idx;
965c2c66affSColin Finck };
966c2c66affSColin Finck
967c2c66affSColin Finck struct wined3d_shader_sampler_map
968c2c66affSColin Finck {
969c2c66affSColin Finck struct wined3d_shader_sampler_map_entry *entries;
970c2c66affSColin Finck size_t size;
971c2c66affSColin Finck size_t count;
972c2c66affSColin Finck };
973c2c66affSColin Finck
974c2c66affSColin Finck struct wined3d_shader_immediate_constant_buffer
975c2c66affSColin Finck {
976c2c66affSColin Finck unsigned int vec4_count;
977c2c66affSColin Finck DWORD data[MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE];
978c2c66affSColin Finck };
979c2c66affSColin Finck
980c2c66affSColin Finck struct wined3d_shader_indexable_temp
981c2c66affSColin Finck {
982c2c66affSColin Finck struct list entry;
983c2c66affSColin Finck unsigned int register_idx;
984c2c66affSColin Finck unsigned int register_size;
985c2c66affSColin Finck unsigned int component_count;
986c2c66affSColin Finck };
987c2c66affSColin Finck
988c2c66affSColin Finck #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
989c2c66affSColin Finck
990c2c66affSColin Finck struct wined3d_shader_reg_maps
991c2c66affSColin Finck {
992c2c66affSColin Finck struct wined3d_shader_version shader_version;
993c2c66affSColin Finck BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
994c2c66affSColin Finck BYTE address; /* MAX_REG_ADDR, 1 */
995c2c66affSColin Finck WORD labels; /* MAX_LABELS, 16 */
996c2c66affSColin Finck DWORD temporary; /* 32 */
997c2c66affSColin Finck unsigned int temporary_count;
998c2c66affSColin Finck DWORD *constf; /* pixel, vertex */
999c2c66affSColin Finck struct list indexable_temps;
1000c2c66affSColin Finck const struct wined3d_shader_immediate_constant_buffer *icb;
1001c2c66affSColin Finck union
1002c2c66affSColin Finck {
1003c2c66affSColin Finck DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1004c2c66affSColin Finck BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1005c2c66affSColin Finck } u;
1006c2c66affSColin Finck DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1007c2c66affSColin Finck DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1008c2c66affSColin Finck WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1009c2c66affSColin Finck WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1010c2c66affSColin Finck WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1011c2c66affSColin Finck WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1012c2c66affSColin Finck UINT cb_sizes[WINED3D_MAX_CBS];
1013c2c66affSColin Finck
1014c2c66affSColin Finck struct wined3d_shader_resource_info resource_info[MAX_SHADER_RESOURCE_VIEWS];
1015c2c66affSColin Finck struct wined3d_shader_sampler_map sampler_map;
1016c2c66affSColin Finck DWORD sampler_comparison_mode;
1017c2c66affSColin Finck BYTE bumpmat; /* MAX_TEXTURES, 8 */
1018c2c66affSColin Finck BYTE luminanceparams; /* MAX_TEXTURES, 8 */
1019c2c66affSColin Finck struct wined3d_shader_resource_info uav_resource_info[MAX_UNORDERED_ACCESS_VIEWS];
1020d6ac0a71SAmine Khaldi DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1021d6ac0a71SAmine Khaldi DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1022c2c66affSColin Finck
1023d6ac0a71SAmine Khaldi DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
1024d6ac0a71SAmine Khaldi DWORD cull_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
1025d6ac0a71SAmine Khaldi DWORD usesnrm : 1;
1026d6ac0a71SAmine Khaldi DWORD vpos : 1;
1027d6ac0a71SAmine Khaldi DWORD usesdsx : 1;
1028d6ac0a71SAmine Khaldi DWORD usesdsy : 1;
1029d6ac0a71SAmine Khaldi DWORD usestexldd : 1;
1030d6ac0a71SAmine Khaldi DWORD usesmova : 1;
1031d6ac0a71SAmine Khaldi DWORD usesfacing : 1;
1032d6ac0a71SAmine Khaldi DWORD usesrelconstF : 1;
1033d6ac0a71SAmine Khaldi DWORD fog : 1;
1034d6ac0a71SAmine Khaldi DWORD usestexldl : 1;
1035d6ac0a71SAmine Khaldi DWORD usesifc : 1;
1036d6ac0a71SAmine Khaldi DWORD usescall : 1;
1037d6ac0a71SAmine Khaldi DWORD usespow : 1;
1038d6ac0a71SAmine Khaldi DWORD point_size : 1;
1039d6ac0a71SAmine Khaldi DWORD vocp : 1;
1040d6ac0a71SAmine Khaldi DWORD input_rel_addressing : 1;
1041*81cffd76SJoachim Henze DWORD padding : 16;
1042c2c66affSColin Finck
1043c2c66affSColin Finck DWORD rt_mask; /* Used render targets, 32 max. */
1044c2c66affSColin Finck
1045c2c66affSColin Finck /* Whether or not loops are used in this shader, and nesting depth */
1046d6ac0a71SAmine Khaldi unsigned int loop_depth;
1047d6ac0a71SAmine Khaldi unsigned int min_rel_offset, max_rel_offset;
1048c2c66affSColin Finck
1049c2c66affSColin Finck struct wined3d_shader_tgsm *tgsm;
1050c2c66affSColin Finck SIZE_T tgsm_capacity;
1051c2c66affSColin Finck unsigned int tgsm_count;
1052c2c66affSColin Finck };
1053c2c66affSColin Finck
1054c2c66affSColin Finck /* Keeps track of details for TEX_M#x# instructions which need to maintain
1055c2c66affSColin Finck * state information between multiple instructions. */
1056c2c66affSColin Finck struct wined3d_shader_tex_mx
1057c2c66affSColin Finck {
1058c2c66affSColin Finck unsigned int current_row;
1059c2c66affSColin Finck DWORD texcoord_w[2];
1060c2c66affSColin Finck };
1061c2c66affSColin Finck
1062c2c66affSColin Finck struct wined3d_shader_parser_state
1063c2c66affSColin Finck {
1064c2c66affSColin Finck unsigned int current_loop_depth;
1065c2c66affSColin Finck unsigned int current_loop_reg;
1066c2c66affSColin Finck BOOL in_subroutine;
1067c2c66affSColin Finck };
1068c2c66affSColin Finck
1069c2c66affSColin Finck struct wined3d_shader_context
1070c2c66affSColin Finck {
1071c2c66affSColin Finck const struct wined3d_shader *shader;
1072c2c66affSColin Finck const struct wined3d_gl_info *gl_info;
1073c2c66affSColin Finck const struct wined3d_shader_reg_maps *reg_maps;
1074c2c66affSColin Finck struct wined3d_string_buffer *buffer;
1075c2c66affSColin Finck struct wined3d_shader_tex_mx *tex_mx;
1076c2c66affSColin Finck struct wined3d_shader_parser_state *state;
1077c2c66affSColin Finck void *backend_data;
1078c2c66affSColin Finck };
1079c2c66affSColin Finck
1080c2c66affSColin Finck struct wined3d_shader_register_index
1081c2c66affSColin Finck {
1082c2c66affSColin Finck const struct wined3d_shader_src_param *rel_addr;
1083c2c66affSColin Finck unsigned int offset;
1084c2c66affSColin Finck };
1085c2c66affSColin Finck
1086c2c66affSColin Finck struct wined3d_shader_register
1087c2c66affSColin Finck {
1088c2c66affSColin Finck enum wined3d_shader_register_type type;
1089c2c66affSColin Finck enum wined3d_data_type data_type;
1090c2c66affSColin Finck struct wined3d_shader_register_index idx[2];
1091c2c66affSColin Finck enum wined3d_immconst_type immconst_type;
1092c2c66affSColin Finck union
1093c2c66affSColin Finck {
1094c2c66affSColin Finck DWORD immconst_data[4];
1095c2c66affSColin Finck unsigned fp_body_idx;
1096c2c66affSColin Finck } u;
1097c2c66affSColin Finck };
1098c2c66affSColin Finck
1099c2c66affSColin Finck struct wined3d_shader_dst_param
1100c2c66affSColin Finck {
1101c2c66affSColin Finck struct wined3d_shader_register reg;
1102c2c66affSColin Finck DWORD write_mask;
1103c2c66affSColin Finck DWORD modifiers;
1104c2c66affSColin Finck DWORD shift;
1105c2c66affSColin Finck };
1106c2c66affSColin Finck
1107c2c66affSColin Finck struct wined3d_shader_src_param
1108c2c66affSColin Finck {
1109c2c66affSColin Finck struct wined3d_shader_register reg;
1110c2c66affSColin Finck DWORD swizzle;
1111c2c66affSColin Finck enum wined3d_shader_src_modifier modifiers;
1112c2c66affSColin Finck };
1113c2c66affSColin Finck
1114c2c66affSColin Finck struct wined3d_shader_index_range
1115c2c66affSColin Finck {
1116c2c66affSColin Finck struct wined3d_shader_dst_param first_register;
1117c2c66affSColin Finck unsigned int last_register;
1118c2c66affSColin Finck };
1119c2c66affSColin Finck
1120c2c66affSColin Finck struct wined3d_shader_semantic
1121c2c66affSColin Finck {
1122c2c66affSColin Finck enum wined3d_decl_usage usage;
1123c2c66affSColin Finck UINT usage_idx;
1124c2c66affSColin Finck enum wined3d_shader_resource_type resource_type;
1125c2c66affSColin Finck enum wined3d_data_type resource_data_type;
1126c2c66affSColin Finck struct wined3d_shader_dst_param reg;
1127c2c66affSColin Finck };
1128c2c66affSColin Finck
1129c2c66affSColin Finck enum wined3d_shader_input_sysval_semantic
1130c2c66affSColin Finck {
1131c2c66affSColin Finck WINED3D_SIV_POSITION = 1,
1132c2c66affSColin Finck WINED3D_SIV_CLIP_DISTANCE = 2,
1133c2c66affSColin Finck WINED3D_SIV_CULL_DISTANCE = 3,
1134c2c66affSColin Finck WINED3D_SIV_RENDER_TARGET_ARRAY_INDEX = 4,
1135c2c66affSColin Finck WINED3D_SIV_VIEWPORT_ARRAY_INDEX = 5,
1136c2c66affSColin Finck WINED3D_SIV_VERTEX_ID = 6,
1137c2c66affSColin Finck WINED3D_SIV_PRIMITIVE_ID = 7,
1138c2c66affSColin Finck WINED3D_SIV_INSTANCE_ID = 8,
1139c2c66affSColin Finck WINED3D_SIV_IS_FRONT_FACE = 9,
1140c2c66affSColin Finck WINED3D_SIV_SAMPLE_INDEX = 10,
1141c2c66affSColin Finck WINED3D_SIV_QUAD_U0_TESS_FACTOR = 11,
1142c2c66affSColin Finck WINED3D_SIV_QUAD_V0_TESS_FACTOR = 12,
1143c2c66affSColin Finck WINED3D_SIV_QUAD_U1_TESS_FACTOR = 13,
1144c2c66affSColin Finck WINED3D_SIV_QUAD_V1_TESS_FACTOR = 14,
1145c2c66affSColin Finck WINED3D_SIV_QUAD_U_INNER_TESS_FACTOR = 15,
1146c2c66affSColin Finck WINED3D_SIV_QUAD_V_INNER_TESS_FACTOR = 16,
1147c2c66affSColin Finck WINED3D_SIV_TRIANGLE_U_TESS_FACTOR = 17,
1148c2c66affSColin Finck WINED3D_SIV_TRIANGLE_V_TESS_FACTOR = 18,
1149c2c66affSColin Finck WINED3D_SIV_TRIANGLE_W_TESS_FACTOR = 19,
1150c2c66affSColin Finck WINED3D_SIV_TRIANGLE_INNER_TESS_FACTOR = 20,
1151c2c66affSColin Finck WINED3D_SIV_LINE_DETAIL_TESS_FACTOR = 21,
1152c2c66affSColin Finck WINED3D_SIV_LINE_DENSITY_TESS_FACTOR = 22,
1153c2c66affSColin Finck };
1154c2c66affSColin Finck
1155c2c66affSColin Finck struct wined3d_shader_register_semantic
1156c2c66affSColin Finck {
1157c2c66affSColin Finck struct wined3d_shader_dst_param reg;
1158c2c66affSColin Finck enum wined3d_shader_input_sysval_semantic sysval_semantic;
1159c2c66affSColin Finck };
1160c2c66affSColin Finck
1161c2c66affSColin Finck struct wined3d_shader_structured_resource
1162c2c66affSColin Finck {
1163c2c66affSColin Finck struct wined3d_shader_dst_param reg;
1164c2c66affSColin Finck unsigned int byte_stride;
1165c2c66affSColin Finck };
1166c2c66affSColin Finck
1167c2c66affSColin Finck struct wined3d_shader_tgsm
1168c2c66affSColin Finck {
1169c2c66affSColin Finck unsigned int size;
1170c2c66affSColin Finck unsigned int stride;
1171c2c66affSColin Finck };
1172c2c66affSColin Finck
1173c2c66affSColin Finck struct wined3d_shader_tgsm_raw
1174c2c66affSColin Finck {
1175c2c66affSColin Finck struct wined3d_shader_dst_param reg;
1176c2c66affSColin Finck unsigned int byte_count;
1177c2c66affSColin Finck };
1178c2c66affSColin Finck
1179c2c66affSColin Finck struct wined3d_shader_tgsm_structured
1180c2c66affSColin Finck {
1181c2c66affSColin Finck struct wined3d_shader_dst_param reg;
1182c2c66affSColin Finck unsigned int byte_stride;
1183c2c66affSColin Finck unsigned int structure_count;
1184c2c66affSColin Finck };
1185c2c66affSColin Finck
1186c2c66affSColin Finck struct wined3d_shader_thread_group_size
1187c2c66affSColin Finck {
1188c2c66affSColin Finck unsigned int x, y, z;
1189c2c66affSColin Finck };
1190c2c66affSColin Finck
1191c2c66affSColin Finck struct wined3d_shader_function_table_pointer
1192c2c66affSColin Finck {
1193c2c66affSColin Finck unsigned int index;
1194c2c66affSColin Finck unsigned int array_size;
1195c2c66affSColin Finck unsigned int body_count;
1196c2c66affSColin Finck unsigned int table_count;
1197c2c66affSColin Finck };
1198c2c66affSColin Finck
1199c2c66affSColin Finck struct wined3d_shader_texel_offset
1200c2c66affSColin Finck {
1201c2c66affSColin Finck signed char u, v, w;
1202c2c66affSColin Finck };
1203c2c66affSColin Finck
1204c2c66affSColin Finck struct wined3d_shader_primitive_type
1205c2c66affSColin Finck {
1206c2c66affSColin Finck enum wined3d_primitive_type type;
1207c2c66affSColin Finck unsigned int patch_vertex_count;
1208c2c66affSColin Finck };
1209c2c66affSColin Finck
1210c2c66affSColin Finck struct wined3d_shader_instruction
1211c2c66affSColin Finck {
1212c2c66affSColin Finck const struct wined3d_shader_context *ctx;
1213c2c66affSColin Finck enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
1214c2c66affSColin Finck DWORD flags;
1215c2c66affSColin Finck unsigned int dst_count;
1216c2c66affSColin Finck unsigned int src_count;
1217c2c66affSColin Finck const struct wined3d_shader_dst_param *dst;
1218c2c66affSColin Finck const struct wined3d_shader_src_param *src;
1219c2c66affSColin Finck struct wined3d_shader_texel_offset texel_offset;
1220c2c66affSColin Finck BOOL coissue;
1221c2c66affSColin Finck const struct wined3d_shader_src_param *predicate;
1222c2c66affSColin Finck union
1223c2c66affSColin Finck {
1224c2c66affSColin Finck struct wined3d_shader_semantic semantic;
1225c2c66affSColin Finck struct wined3d_shader_register_semantic register_semantic;
1226c2c66affSColin Finck struct wined3d_shader_primitive_type primitive_type;
1227c2c66affSColin Finck struct wined3d_shader_dst_param dst;
1228c2c66affSColin Finck struct wined3d_shader_src_param src;
1229c2c66affSColin Finck unsigned int count;
1230c2c66affSColin Finck unsigned int index;
1231c2c66affSColin Finck const struct wined3d_shader_immediate_constant_buffer *icb;
1232c2c66affSColin Finck struct wined3d_shader_structured_resource structured_resource;
1233c2c66affSColin Finck struct wined3d_shader_tgsm_raw tgsm_raw;
1234c2c66affSColin Finck struct wined3d_shader_tgsm_structured tgsm_structured;
1235c2c66affSColin Finck struct wined3d_shader_thread_group_size thread_group_size;
1236c2c66affSColin Finck enum wined3d_tessellator_domain tessellator_domain;
1237c2c66affSColin Finck enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1238c2c66affSColin Finck enum wined3d_tessellator_partitioning tessellator_partitioning;
1239c2c66affSColin Finck float max_tessellation_factor;
1240c2c66affSColin Finck struct wined3d_shader_index_range index_range;
1241c2c66affSColin Finck struct wined3d_shader_indexable_temp indexable_temp;
1242c2c66affSColin Finck struct wined3d_shader_function_table_pointer fp;
1243c2c66affSColin Finck } declaration;
1244c2c66affSColin Finck };
1245c2c66affSColin Finck
wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction * ins)1246c2c66affSColin Finck static inline BOOL wined3d_shader_instruction_has_texel_offset(const struct wined3d_shader_instruction *ins)
1247c2c66affSColin Finck {
1248c2c66affSColin Finck return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1249c2c66affSColin Finck }
1250c2c66affSColin Finck
1251c2c66affSColin Finck struct wined3d_shader_attribute
1252c2c66affSColin Finck {
1253c2c66affSColin Finck enum wined3d_decl_usage usage;
1254c2c66affSColin Finck UINT usage_idx;
1255c2c66affSColin Finck };
1256c2c66affSColin Finck
1257c2c66affSColin Finck struct wined3d_shader_loop_control
1258c2c66affSColin Finck {
1259c2c66affSColin Finck unsigned int count;
1260c2c66affSColin Finck unsigned int start;
1261c2c66affSColin Finck int step;
1262c2c66affSColin Finck };
1263c2c66affSColin Finck
1264c2c66affSColin Finck struct wined3d_shader_frontend
1265c2c66affSColin Finck {
1266c2c66affSColin Finck void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1267c2c66affSColin Finck const struct wined3d_shader_signature *output_signature);
1268c2c66affSColin Finck void (*shader_free)(void *data);
1269c2c66affSColin Finck void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1270c2c66affSColin Finck void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1271c2c66affSColin Finck BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1272c2c66affSColin Finck };
1273c2c66affSColin Finck
1274c2c66affSColin Finck extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
1275c2c66affSColin Finck extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
1276c2c66affSColin Finck
1277c2c66affSColin Finck typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
1278c2c66affSColin Finck
1279c2c66affSColin Finck #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001
1280c2c66affSColin Finck #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002
1281c2c66affSColin Finck #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004
1282c2c66affSColin Finck
1283c2c66affSColin Finck struct shader_caps
1284c2c66affSColin Finck {
1285c2c66affSColin Finck unsigned int vs_version;
1286c2c66affSColin Finck unsigned int hs_version;
1287c2c66affSColin Finck unsigned int ds_version;
1288c2c66affSColin Finck unsigned int gs_version;
1289c2c66affSColin Finck unsigned int ps_version;
1290c2c66affSColin Finck unsigned int cs_version;
1291c2c66affSColin Finck
1292c2c66affSColin Finck DWORD vs_uniform_count;
1293c2c66affSColin Finck DWORD ps_uniform_count;
1294c2c66affSColin Finck float ps_1x_max_value;
1295c2c66affSColin Finck DWORD varying_count;
1296c2c66affSColin Finck
1297c2c66affSColin Finck DWORD wined3d_caps;
1298c2c66affSColin Finck };
1299c2c66affSColin Finck
1300c2c66affSColin Finck enum wined3d_gl_resource_type
1301c2c66affSColin Finck {
1302c2c66affSColin Finck WINED3D_GL_RES_TYPE_TEX_1D = 0,
1303c2c66affSColin Finck WINED3D_GL_RES_TYPE_TEX_2D = 1,
1304c2c66affSColin Finck WINED3D_GL_RES_TYPE_TEX_3D = 2,
1305c2c66affSColin Finck WINED3D_GL_RES_TYPE_TEX_CUBE = 3,
1306c2c66affSColin Finck WINED3D_GL_RES_TYPE_TEX_RECT = 4,
1307c2c66affSColin Finck WINED3D_GL_RES_TYPE_BUFFER = 5,
1308c2c66affSColin Finck WINED3D_GL_RES_TYPE_RB = 6,
1309c2c66affSColin Finck WINED3D_GL_RES_TYPE_COUNT = 7,
1310c2c66affSColin Finck };
1311c2c66affSColin Finck
1312*81cffd76SJoachim Henze enum vertexprocessing_mode {
1313*81cffd76SJoachim Henze fixedfunction,
1314*81cffd76SJoachim Henze vertexshader,
1315*81cffd76SJoachim Henze pretransformed
1316c2c66affSColin Finck };
1317c2c66affSColin Finck
1318c2c66affSColin Finck #define WINED3D_CONST_NUM_UNUSED ~0U
1319c2c66affSColin Finck
1320c2c66affSColin Finck enum wined3d_ffp_ps_fog_mode
1321c2c66affSColin Finck {
1322c2c66affSColin Finck WINED3D_FFP_PS_FOG_OFF,
1323c2c66affSColin Finck WINED3D_FFP_PS_FOG_LINEAR,
1324c2c66affSColin Finck WINED3D_FFP_PS_FOG_EXP,
1325c2c66affSColin Finck WINED3D_FFP_PS_FOG_EXP2,
1326c2c66affSColin Finck };
1327c2c66affSColin Finck
1328c2c66affSColin Finck /* Stateblock dependent parameters which have to be hardcoded
1329c2c66affSColin Finck * into the shader code
1330c2c66affSColin Finck */
1331c2c66affSColin Finck
1332c2c66affSColin Finck #define WINED3D_PSARGS_PROJECTED (1u << 3)
1333c2c66affSColin Finck #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1334c2c66affSColin Finck #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1335c2c66affSColin Finck #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1336c2c66affSColin Finck #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1337c2c66affSColin Finck
1338c2c66affSColin Finck /* Used for Shader Model 1 pixel shaders to track the bound texture
1339c2c66affSColin Finck * type. 2D and RECT textures are separated through NP2 fixup. */
1340c2c66affSColin Finck enum wined3d_shader_tex_types
1341c2c66affSColin Finck {
1342c2c66affSColin Finck WINED3D_SHADER_TEX_2D = 0,
1343c2c66affSColin Finck WINED3D_SHADER_TEX_3D = 1,
1344c2c66affSColin Finck WINED3D_SHADER_TEX_CUBE = 2,
1345c2c66affSColin Finck };
1346c2c66affSColin Finck
1347d6ac0a71SAmine Khaldi struct ps_compile_args
1348d6ac0a71SAmine Khaldi {
1349c2c66affSColin Finck struct color_fixup_desc color_fixup[MAX_FRAGMENT_SAMPLERS];
1350*81cffd76SJoachim Henze enum vertexprocessing_mode vp_mode;
1351c2c66affSColin Finck enum wined3d_ffp_ps_fog_mode fog;
1352c2c66affSColin Finck WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1353c2c66affSColin Finck WORD tex_types; /* ps 1.0 - 1.4, 6 textures */
1354c2c66affSColin Finck WORD srgb_correction;
1355c2c66affSColin Finck /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1356c2c66affSColin Finck D3D9 has a limit of 16 samplers and the fixup is superfluous
1357c2c66affSColin Finck in D3D10 (unconditional NP2 support mandatory). */
1358c2c66affSColin Finck WORD np2_fixup;
1359c2c66affSColin Finck WORD shadow; /* MAX_FRAGMENT_SAMPLERS, 16 */
1360c2c66affSColin Finck WORD texcoords_initialized; /* MAX_TEXTURES, 8 */
1361c2c66affSColin Finck DWORD pointsprite : 1;
1362c2c66affSColin Finck DWORD flatshading : 1;
1363c2c66affSColin Finck DWORD alpha_test_func : 3;
1364c2c66affSColin Finck DWORD render_offscreen : 1;
13659987f029SAmine Khaldi DWORD dual_source_blend : 1;
13669987f029SAmine Khaldi DWORD padding : 25;
1367c2c66affSColin Finck };
1368c2c66affSColin Finck
1369d6ac0a71SAmine Khaldi enum fog_src_type
1370d6ac0a71SAmine Khaldi {
1371c2c66affSColin Finck VS_FOG_Z = 0,
1372c2c66affSColin Finck VS_FOG_COORD = 1
1373c2c66affSColin Finck };
1374c2c66affSColin Finck
1375c2c66affSColin Finck struct vs_compile_args
1376c2c66affSColin Finck {
1377c2c66affSColin Finck BYTE fog_src;
1378c2c66affSColin Finck BYTE clip_enabled : 1;
1379c2c66affSColin Finck BYTE point_size : 1;
1380c2c66affSColin Finck BYTE per_vertex_point_size : 1;
1381c2c66affSColin Finck BYTE flatshading : 1;
1382c2c66affSColin Finck BYTE next_shader_type : 3;
1383c2c66affSColin Finck BYTE padding : 1;
1384c2c66affSColin Finck WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1385c2c66affSColin Finck unsigned int next_shader_input_count;
1386d6ac0a71SAmine Khaldi DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1387c2c66affSColin Finck };
1388c2c66affSColin Finck
1389c2c66affSColin Finck struct ds_compile_args
1390c2c66affSColin Finck {
1391c2c66affSColin Finck enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1392c2c66affSColin Finck enum wined3d_tessellator_partitioning tessellator_partitioning;
1393c2c66affSColin Finck unsigned int output_count : 16;
1394c2c66affSColin Finck unsigned int next_shader_type : 3;
1395c2c66affSColin Finck unsigned int render_offscreen : 1;
1396c2c66affSColin Finck unsigned int padding : 12;
1397d6ac0a71SAmine Khaldi DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1398c2c66affSColin Finck };
1399c2c66affSColin Finck
1400c2c66affSColin Finck struct gs_compile_args
1401c2c66affSColin Finck {
1402c2c66affSColin Finck unsigned int output_count;
1403d6ac0a71SAmine Khaldi DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
1404c2c66affSColin Finck };
1405c2c66affSColin Finck
1406c2c66affSColin Finck struct wined3d_context;
1407c2c66affSColin Finck struct wined3d_state;
1408c2c66affSColin Finck struct fragment_pipeline;
1409c2c66affSColin Finck struct wined3d_vertex_pipe_ops;
1410c2c66affSColin Finck
1411c2c66affSColin Finck struct wined3d_shader_backend_ops
1412c2c66affSColin Finck {
1413c2c66affSColin Finck void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1414c2c66affSColin Finck void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1415c2c66affSColin Finck void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1416c2c66affSColin Finck const struct wined3d_state *state);
1417c2c66affSColin Finck void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1418c2c66affSColin Finck const struct wined3d_state *state);
1419c2c66affSColin Finck void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1420c2c66affSColin Finck void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1421c2c66affSColin Finck void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1422c2c66affSColin Finck void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1423c2c66affSColin Finck const struct wined3d_state *state);
1424c2c66affSColin Finck void (*shader_destroy)(struct wined3d_shader *shader);
1425c2c66affSColin Finck HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1426c2c66affSColin Finck const struct fragment_pipeline *fragment_pipe);
1427c2c66affSColin Finck void (*shader_free_private)(struct wined3d_device *device);
1428c2c66affSColin Finck BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1429c2c66affSColin Finck void (*shader_free_context_data)(struct wined3d_context *context);
1430c2c66affSColin Finck void (*shader_init_context_state)(struct wined3d_context *context);
1431c2c66affSColin Finck void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
1432c2c66affSColin Finck BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1433c2c66affSColin Finck BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1434c2c66affSColin Finck };
1435c2c66affSColin Finck
1436c2c66affSColin Finck extern const struct wined3d_shader_backend_ops glsl_shader_backend DECLSPEC_HIDDEN;
1437c2c66affSColin Finck extern const struct wined3d_shader_backend_ops arb_program_shader_backend DECLSPEC_HIDDEN;
1438c2c66affSColin Finck extern const struct wined3d_shader_backend_ops none_shader_backend DECLSPEC_HIDDEN;
1439c2c66affSColin Finck
1440c2c66affSColin Finck #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1441c2c66affSColin Finck
1442c2c66affSColin Finck #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1443c2c66affSColin Finck #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1444c2c66affSColin Finck #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1445c2c66affSColin Finck #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1446c2c66affSColin Finck
wined3d_color_from_d3dcolor(struct wined3d_color * wined3d_color,DWORD d3d_color)1447c2c66affSColin Finck static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1448c2c66affSColin Finck {
1449c2c66affSColin Finck wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1450c2c66affSColin Finck wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1451c2c66affSColin Finck wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1452c2c66affSColin Finck wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1453c2c66affSColin Finck }
1454c2c66affSColin Finck
1455c2c66affSColin Finck #define HIGHEST_TRANSFORMSTATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */
1456c2c66affSColin Finck
1457c2c66affSColin Finck void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1458c2c66affSColin Finck const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1459c2c66affSColin Finck
1460c2c66affSColin Finck /* Checking of API calls */
1461c2c66affSColin Finck /* --------------------- */
1462c2c66affSColin Finck #ifndef WINE_NO_DEBUG_MSGS
1463c2c66affSColin Finck #define checkGLcall(A) \
1464c2c66affSColin Finck do { \
1465c2c66affSColin Finck if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1466c2c66affSColin Finck && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1467c2c66affSColin Finck wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1468c2c66affSColin Finck } while(0)
1469c2c66affSColin Finck #else
1470c2c66affSColin Finck #define checkGLcall(A) do {} while(0)
1471c2c66affSColin Finck #endif
1472c2c66affSColin Finck
1473c2c66affSColin Finck struct wined3d_bo_address
1474c2c66affSColin Finck {
1475c2c66affSColin Finck GLuint buffer_object;
1476c2c66affSColin Finck BYTE *addr;
1477c2c66affSColin Finck };
1478c2c66affSColin Finck
1479c2c66affSColin Finck struct wined3d_const_bo_address
1480c2c66affSColin Finck {
1481c2c66affSColin Finck GLuint buffer_object;
1482c2c66affSColin Finck const BYTE *addr;
1483c2c66affSColin Finck };
1484c2c66affSColin Finck
wined3d_const_bo_address(struct wined3d_bo_address * data)1485c2c66affSColin Finck static inline struct wined3d_const_bo_address *wined3d_const_bo_address(struct wined3d_bo_address *data)
1486c2c66affSColin Finck {
1487c2c66affSColin Finck return (struct wined3d_const_bo_address *)data;
1488c2c66affSColin Finck }
1489c2c66affSColin Finck
1490c2c66affSColin Finck struct wined3d_stream_info_element
1491c2c66affSColin Finck {
1492c2c66affSColin Finck const struct wined3d_format *format;
1493c2c66affSColin Finck struct wined3d_bo_address data;
1494c2c66affSColin Finck GLsizei stride;
1495c2c66affSColin Finck unsigned int stream_idx;
1496c2c66affSColin Finck unsigned int divisor;
1497c2c66affSColin Finck };
1498c2c66affSColin Finck
1499c2c66affSColin Finck struct wined3d_stream_info
1500c2c66affSColin Finck {
1501c2c66affSColin Finck struct wined3d_stream_info_element elements[MAX_ATTRIBS];
1502c2c66affSColin Finck DWORD position_transformed : 1;
1503c2c66affSColin Finck DWORD all_vbo : 1;
1504c2c66affSColin Finck WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1505c2c66affSColin Finck WORD use_map; /* MAX_ATTRIBS, 16 */
1506c2c66affSColin Finck };
1507c2c66affSColin Finck
1508c2c66affSColin Finck void wined3d_stream_info_from_declaration(struct wined3d_stream_info *stream_info,
1509c2c66affSColin Finck const struct wined3d_state *state, const struct wined3d_gl_info *gl_info,
1510c2c66affSColin Finck const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
1511c2c66affSColin Finck
1512d6ac0a71SAmine Khaldi struct wined3d_direct_dispatch_parameters
1513d6ac0a71SAmine Khaldi {
1514d6ac0a71SAmine Khaldi unsigned int group_count_x;
1515d6ac0a71SAmine Khaldi unsigned int group_count_y;
1516d6ac0a71SAmine Khaldi unsigned int group_count_z;
1517d6ac0a71SAmine Khaldi };
1518d6ac0a71SAmine Khaldi
1519d6ac0a71SAmine Khaldi struct wined3d_indirect_dispatch_parameters
1520d6ac0a71SAmine Khaldi {
1521d6ac0a71SAmine Khaldi struct wined3d_buffer *buffer;
1522d6ac0a71SAmine Khaldi unsigned int offset;
1523d6ac0a71SAmine Khaldi };
1524d6ac0a71SAmine Khaldi
1525d6ac0a71SAmine Khaldi struct wined3d_dispatch_parameters
1526d6ac0a71SAmine Khaldi {
1527d6ac0a71SAmine Khaldi BOOL indirect;
1528d6ac0a71SAmine Khaldi union
1529d6ac0a71SAmine Khaldi {
1530d6ac0a71SAmine Khaldi struct wined3d_direct_dispatch_parameters direct;
1531d6ac0a71SAmine Khaldi struct wined3d_indirect_dispatch_parameters indirect;
1532d6ac0a71SAmine Khaldi } u;
1533d6ac0a71SAmine Khaldi };
1534d6ac0a71SAmine Khaldi
1535c2c66affSColin Finck struct wined3d_direct_draw_parameters
1536c2c66affSColin Finck {
1537c2c66affSColin Finck int base_vertex_idx;
1538c2c66affSColin Finck unsigned int start_idx;
1539c2c66affSColin Finck unsigned int index_count;
1540c2c66affSColin Finck unsigned int start_instance;
1541c2c66affSColin Finck unsigned int instance_count;
1542c2c66affSColin Finck };
1543c2c66affSColin Finck
1544c2c66affSColin Finck struct wined3d_indirect_draw_parameters
1545c2c66affSColin Finck {
1546c2c66affSColin Finck struct wined3d_buffer *buffer;
1547c2c66affSColin Finck unsigned int offset;
1548c2c66affSColin Finck };
1549c2c66affSColin Finck
1550c2c66affSColin Finck struct wined3d_draw_parameters
1551c2c66affSColin Finck {
1552c2c66affSColin Finck BOOL indirect;
1553c2c66affSColin Finck union
1554c2c66affSColin Finck {
1555c2c66affSColin Finck struct wined3d_direct_draw_parameters direct;
1556c2c66affSColin Finck struct wined3d_indirect_draw_parameters indirect;
1557c2c66affSColin Finck } u;
1558c2c66affSColin Finck BOOL indexed;
1559c2c66affSColin Finck };
1560c2c66affSColin Finck
1561c2c66affSColin Finck void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
1562c2c66affSColin Finck const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
1563c2c66affSColin Finck void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
1564c2c66affSColin Finck const struct wined3d_dispatch_parameters *dispatch_parameters) DECLSPEC_HIDDEN;
1565c2c66affSColin Finck DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
1566c2c66affSColin Finck
1567c2c66affSColin Finck #define eps 1e-8f
1568c2c66affSColin Finck
1569c2c66affSColin Finck #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1570c2c66affSColin Finck (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1571c2c66affSColin Finck
1572c2c66affSColin Finck enum wined3d_pipeline
1573c2c66affSColin Finck {
1574c2c66affSColin Finck WINED3D_PIPELINE_GRAPHICS,
1575c2c66affSColin Finck WINED3D_PIPELINE_COMPUTE,
1576c2c66affSColin Finck WINED3D_PIPELINE_COUNT,
1577c2c66affSColin Finck };
1578c2c66affSColin Finck
1579c2c66affSColin Finck /* Routines and structures related to state management */
1580c2c66affSColin Finck
1581c2c66affSColin Finck #define STATE_RENDER(a) (a)
1582c2c66affSColin Finck #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1583c2c66affSColin Finck
1584c2c66affSColin Finck #define STATE_TEXTURESTAGE(stage, num) \
1585c2c66affSColin Finck (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1586c2c66affSColin Finck #define STATE_IS_TEXTURESTAGE(a) \
1587c2c66affSColin Finck ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1588c2c66affSColin Finck
1589c2c66affSColin Finck /* + 1 because samplers start with 0 */
1590c2c66affSColin Finck #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1591c2c66affSColin Finck #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
1592c2c66affSColin Finck
1593c2c66affSColin Finck #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(MAX_COMBINED_SAMPLERS) + (a))
1594c2c66affSColin Finck #define STATE_IS_GRAPHICS_SHADER(a) \
1595c2c66affSColin Finck ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1596c2c66affSColin Finck
1597c2c66affSColin Finck #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1598c2c66affSColin Finck #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1599c2c66affSColin Finck ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1600c2c66affSColin Finck && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1601c2c66affSColin Finck
1602c2c66affSColin Finck #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1603c2c66affSColin Finck #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1604c2c66affSColin Finck
1605c2c66affSColin Finck #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1606c2c66affSColin Finck #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1607c2c66affSColin Finck
1608c2c66affSColin Finck #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1609c2c66affSColin Finck #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1610c2c66affSColin Finck
1611c2c66affSColin Finck #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1612c2c66affSColin Finck #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1613c2c66affSColin Finck #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1614c2c66affSColin Finck #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1615c2c66affSColin Finck
1616c2c66affSColin Finck #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1617c2c66affSColin Finck #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1618c2c66affSColin Finck
1619c2c66affSColin Finck #define STATE_VIEWPORT (STATE_VDECL + 1)
1620c2c66affSColin Finck #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1621c2c66affSColin Finck
1622c2c66affSColin Finck #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1623c2c66affSColin Finck #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1624c2c66affSColin Finck #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1625c2c66affSColin Finck #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS))
1626c2c66affSColin Finck
1627c2c66affSColin Finck #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS - 1) + 1)
1628c2c66affSColin Finck #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1629c2c66affSColin Finck
1630c2c66affSColin Finck #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1631c2c66affSColin Finck #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIP_DISTANCES - 1))
1632c2c66affSColin Finck
1633c2c66affSColin Finck #define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIP_DISTANCES))
1634c2c66affSColin Finck #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1635c2c66affSColin Finck
1636*81cffd76SJoachim Henze #define STATE_FRONTFACE (STATE_MATERIAL + 1)
1637*81cffd76SJoachim Henze #define STATE_IS_FRONTFACE(a) ((a) == STATE_FRONTFACE)
1638c2c66affSColin Finck
1639*81cffd76SJoachim Henze #define STATE_POINTSPRITECOORDORIGIN (STATE_FRONTFACE + 1)
1640c2c66affSColin Finck #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1641c2c66affSColin Finck
1642c2c66affSColin Finck #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1643c2c66affSColin Finck #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1644c2c66affSColin Finck
1645c2c66affSColin Finck #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1646c2c66affSColin Finck #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1647c2c66affSColin Finck
1648c2c66affSColin Finck #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1649c2c66affSColin Finck #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1650c2c66affSColin Finck
1651c2c66affSColin Finck #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1652c2c66affSColin Finck #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1653c2c66affSColin Finck
1654c2c66affSColin Finck #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1655c2c66affSColin Finck #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1656c2c66affSColin Finck
16579987f029SAmine Khaldi #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
16589987f029SAmine Khaldi #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
16599987f029SAmine Khaldi
16609987f029SAmine Khaldi #define STATE_COMPUTE_OFFSET (STATE_BLEND + 1)
1661c2c66affSColin Finck
1662c2c66affSColin Finck #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1663c2c66affSColin Finck #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1664c2c66affSColin Finck
1665c2c66affSColin Finck #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1666c2c66affSColin Finck #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1667c2c66affSColin Finck
1668c2c66affSColin Finck #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1669c2c66affSColin Finck #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1670c2c66affSColin Finck
1671c2c66affSColin Finck #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1672c2c66affSColin Finck #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1673c2c66affSColin Finck
1674c2c66affSColin Finck #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1675c2c66affSColin Finck #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1676c2c66affSColin Finck
1677c2c66affSColin Finck #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1678c2c66affSColin Finck #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1679c2c66affSColin Finck
1680c2c66affSColin Finck #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1681c2c66affSColin Finck #define STATE_CONSTANT_BUFFER(a) \
1682c2c66affSColin Finck ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1683c2c66affSColin Finck #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1684c2c66affSColin Finck STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1685c2c66affSColin Finck
1686c2c66affSColin Finck enum fogsource {
1687c2c66affSColin Finck FOGSOURCE_FFP,
1688c2c66affSColin Finck FOGSOURCE_VS,
1689c2c66affSColin Finck FOGSOURCE_COORD,
1690c2c66affSColin Finck };
1691c2c66affSColin Finck
1692c2c66affSColin Finck union wined3d_gl_fence_object
1693c2c66affSColin Finck {
1694c2c66affSColin Finck GLuint id;
1695c2c66affSColin Finck GLsync sync;
1696c2c66affSColin Finck };
1697c2c66affSColin Finck
1698c2c66affSColin Finck enum wined3d_fence_result
1699c2c66affSColin Finck {
1700c2c66affSColin Finck WINED3D_FENCE_OK,
1701c2c66affSColin Finck WINED3D_FENCE_WAITING,
1702c2c66affSColin Finck WINED3D_FENCE_NOT_STARTED,
1703c2c66affSColin Finck WINED3D_FENCE_WRONG_THREAD,
1704c2c66affSColin Finck WINED3D_FENCE_ERROR,
1705c2c66affSColin Finck };
1706c2c66affSColin Finck
1707c2c66affSColin Finck struct wined3d_fence
1708c2c66affSColin Finck {
1709c2c66affSColin Finck struct list entry;
1710c2c66affSColin Finck union wined3d_gl_fence_object object;
1711c2c66affSColin Finck struct wined3d_context *context;
1712c2c66affSColin Finck };
1713c2c66affSColin Finck
1714c2c66affSColin Finck HRESULT wined3d_fence_create(struct wined3d_device *device, struct wined3d_fence **fence) DECLSPEC_HIDDEN;
1715c2c66affSColin Finck void wined3d_fence_destroy(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
1716c2c66affSColin Finck void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_device *device) DECLSPEC_HIDDEN;
1717c2c66affSColin Finck enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
1718c2c66affSColin Finck const struct wined3d_device *device) DECLSPEC_HIDDEN;
1719c2c66affSColin Finck
1720c2c66affSColin Finck /* Direct3D terminology with little modifications. We do not have an issued
1721c2c66affSColin Finck * state because only the driver knows about it, but we have a created state
1722c2c66affSColin Finck * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1723c2c66affSColin Finck enum wined3d_query_state
1724c2c66affSColin Finck {
1725c2c66affSColin Finck QUERY_CREATED,
1726c2c66affSColin Finck QUERY_SIGNALLED,
1727c2c66affSColin Finck QUERY_BUILDING
1728c2c66affSColin Finck };
1729c2c66affSColin Finck
1730c2c66affSColin Finck struct wined3d_query_ops
1731c2c66affSColin Finck {
1732c2c66affSColin Finck BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
1733c2c66affSColin Finck BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
1734c2c66affSColin Finck void (*query_destroy)(struct wined3d_query *query);
1735c2c66affSColin Finck };
1736c2c66affSColin Finck
1737c2c66affSColin Finck struct wined3d_query
1738c2c66affSColin Finck {
1739c2c66affSColin Finck LONG ref;
1740c2c66affSColin Finck
1741c2c66affSColin Finck void *parent;
1742c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
1743c2c66affSColin Finck struct wined3d_device *device;
1744c2c66affSColin Finck enum wined3d_query_state state;
1745c2c66affSColin Finck enum wined3d_query_type type;
1746c2c66affSColin Finck const void *data;
1747c2c66affSColin Finck DWORD data_size;
1748c2c66affSColin Finck const struct wined3d_query_ops *query_ops;
1749c2c66affSColin Finck
1750c2c66affSColin Finck LONG counter_main, counter_retrieved;
1751c2c66affSColin Finck struct list poll_list_entry;
1752c2c66affSColin Finck };
1753c2c66affSColin Finck
1754c2c66affSColin Finck struct wined3d_event_query
1755c2c66affSColin Finck {
1756c2c66affSColin Finck struct wined3d_query query;
1757c2c66affSColin Finck
1758c2c66affSColin Finck struct wined3d_fence fence;
1759c2c66affSColin Finck BOOL signalled;
1760c2c66affSColin Finck };
1761c2c66affSColin Finck
1762c2c66affSColin Finck struct wined3d_occlusion_query
1763c2c66affSColin Finck {
1764c2c66affSColin Finck struct wined3d_query query;
1765c2c66affSColin Finck
1766c2c66affSColin Finck struct list entry;
1767c2c66affSColin Finck GLuint id;
1768c2c66affSColin Finck struct wined3d_context *context;
1769c2c66affSColin Finck UINT64 samples;
1770c2c66affSColin Finck BOOL started;
1771c2c66affSColin Finck };
1772c2c66affSColin Finck
1773c2c66affSColin Finck struct wined3d_timestamp_query
1774c2c66affSColin Finck {
1775c2c66affSColin Finck struct wined3d_query query;
1776c2c66affSColin Finck
1777c2c66affSColin Finck struct list entry;
1778c2c66affSColin Finck GLuint id;
1779c2c66affSColin Finck struct wined3d_context *context;
1780c2c66affSColin Finck UINT64 timestamp;
1781c2c66affSColin Finck };
1782c2c66affSColin Finck
1783c2c66affSColin Finck void context_alloc_timestamp_query(struct wined3d_context *context, struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
1784c2c66affSColin Finck void context_free_timestamp_query(struct wined3d_timestamp_query *query) DECLSPEC_HIDDEN;
1785c2c66affSColin Finck
1786c2c66affSColin Finck union wined3d_gl_so_statistics_query
1787c2c66affSColin Finck {
1788c2c66affSColin Finck GLuint id[2];
1789c2c66affSColin Finck struct
1790c2c66affSColin Finck {
1791c2c66affSColin Finck GLuint written;
1792c2c66affSColin Finck GLuint generated;
1793c2c66affSColin Finck } query;
1794c2c66affSColin Finck };
1795c2c66affSColin Finck
1796c2c66affSColin Finck struct wined3d_so_statistics_query
1797c2c66affSColin Finck {
1798c2c66affSColin Finck struct wined3d_query query;
1799c2c66affSColin Finck
1800c2c66affSColin Finck struct list entry;
1801c2c66affSColin Finck union wined3d_gl_so_statistics_query u;
1802c2c66affSColin Finck struct wined3d_context *context;
1803c2c66affSColin Finck unsigned int stream_idx;
1804c2c66affSColin Finck struct wined3d_query_data_so_statistics statistics;
1805c2c66affSColin Finck BOOL started;
1806c2c66affSColin Finck };
1807c2c66affSColin Finck
1808c2c66affSColin Finck void context_alloc_so_statistics_query(struct wined3d_context *context,
1809c2c66affSColin Finck struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
1810c2c66affSColin Finck void context_free_so_statistics_query(struct wined3d_so_statistics_query *query) DECLSPEC_HIDDEN;
1811c2c66affSColin Finck
1812c2c66affSColin Finck union wined3d_gl_pipeline_statistics_query
1813c2c66affSColin Finck {
1814c2c66affSColin Finck GLuint id[11];
1815c2c66affSColin Finck struct
1816c2c66affSColin Finck {
1817c2c66affSColin Finck GLuint vertices;
1818c2c66affSColin Finck GLuint primitives;
1819c2c66affSColin Finck GLuint vertex_shader;
1820c2c66affSColin Finck GLuint tess_control_shader;
1821c2c66affSColin Finck GLuint tess_eval_shader;
1822c2c66affSColin Finck GLuint geometry_shader;
1823c2c66affSColin Finck GLuint geometry_primitives;
1824c2c66affSColin Finck GLuint fragment_shader;
1825c2c66affSColin Finck GLuint compute_shader;
1826c2c66affSColin Finck GLuint clipping_input;
1827c2c66affSColin Finck GLuint clipping_output;
1828c2c66affSColin Finck } query;
1829c2c66affSColin Finck };
1830c2c66affSColin Finck
1831c2c66affSColin Finck struct wined3d_pipeline_statistics_query
1832c2c66affSColin Finck {
1833c2c66affSColin Finck struct wined3d_query query;
1834c2c66affSColin Finck
1835c2c66affSColin Finck struct list entry;
1836c2c66affSColin Finck union wined3d_gl_pipeline_statistics_query u;
1837c2c66affSColin Finck struct wined3d_context *context;
1838c2c66affSColin Finck struct wined3d_query_data_pipeline_statistics statistics;
1839c2c66affSColin Finck BOOL started;
1840c2c66affSColin Finck };
1841c2c66affSColin Finck
1842c2c66affSColin Finck void context_alloc_pipeline_statistics_query(struct wined3d_context *context,
1843c2c66affSColin Finck struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
1844c2c66affSColin Finck void context_free_pipeline_statistics_query(struct wined3d_pipeline_statistics_query *query) DECLSPEC_HIDDEN;
1845c2c66affSColin Finck
1846c2c66affSColin Finck struct wined3d_gl_view
1847c2c66affSColin Finck {
1848c2c66affSColin Finck GLenum target;
1849c2c66affSColin Finck GLuint name;
1850c2c66affSColin Finck };
1851c2c66affSColin Finck
1852c2c66affSColin Finck struct wined3d_rendertarget_info
1853c2c66affSColin Finck {
1854c2c66affSColin Finck struct wined3d_gl_view gl_view;
1855c2c66affSColin Finck struct wined3d_resource *resource;
1856c2c66affSColin Finck unsigned int sub_resource_idx;
1857c2c66affSColin Finck unsigned int layer_count;
1858c2c66affSColin Finck };
1859c2c66affSColin Finck
1860c2c66affSColin Finck #define MAX_GL_FRAGMENT_SAMPLERS 32
1861c2c66affSColin Finck
1862c2c66affSColin Finck struct wined3d_context
1863c2c66affSColin Finck {
1864c2c66affSColin Finck const struct wined3d_gl_info *gl_info;
1865c2c66affSColin Finck const struct wined3d_d3d_info *d3d_info;
1866c2c66affSColin Finck const struct StateEntry *state_table;
1867c2c66affSColin Finck /* State dirtification
1868c2c66affSColin Finck * dirtyArray is an array that contains markers for dirty states. numDirtyEntries states are dirty, their numbers are in indices
1869c2c66affSColin Finck * 0...numDirtyEntries - 1. isStateDirty is a redundant copy of the dirtyArray. Technically only one of them would be needed,
1870c2c66affSColin Finck * but with the help of both it is easy to find out if a state is dirty(just check the array index), and for applying dirty states
1871c2c66affSColin Finck * only numDirtyEntries array elements have to be checked, not STATE_HIGHEST states.
1872c2c66affSColin Finck */
1873c2c66affSColin Finck DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */
1874c2c66affSColin Finck DWORD numDirtyEntries;
1875c2c66affSColin Finck DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
1876c2c66affSColin Finck unsigned int dirty_compute_states[STATE_COMPUTE_COUNT / (sizeof(unsigned int) * CHAR_BIT) + 1];
1877c2c66affSColin Finck
1878c2c66affSColin Finck struct wined3d_device *device;
1879c2c66affSColin Finck struct wined3d_swapchain *swapchain;
1880c2c66affSColin Finck struct
1881c2c66affSColin Finck {
1882c2c66affSColin Finck struct wined3d_texture *texture;
1883c2c66affSColin Finck unsigned int sub_resource_idx;
1884c2c66affSColin Finck } current_rt;
1885c2c66affSColin Finck DWORD tid; /* Thread ID which owns this context at the moment */
1886c2c66affSColin Finck
1887c2c66affSColin Finck /* Stores some information about the context state for optimization */
1888c2c66affSColin Finck DWORD render_offscreen : 1;
1889c2c66affSColin Finck DWORD last_was_rhw : 1; /* true iff last draw_primitive was in xyzrhw mode */
1890d6ac0a71SAmine Khaldi DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
1891c2c66affSColin Finck DWORD last_was_pshader : 1;
1892c2c66affSColin Finck DWORD last_was_vshader : 1;
1893c2c66affSColin Finck DWORD last_was_normal : 1;
1894c2c66affSColin Finck DWORD namedArraysLoaded : 1;
1895*81cffd76SJoachim Henze DWORD numberedArraysLoaded : 1;
1896c2c66affSColin Finck DWORD last_was_blit : 1;
1897c2c66affSColin Finck DWORD last_was_ckey : 1;
1898c2c66affSColin Finck DWORD fog_coord : 1;
1899c2c66affSColin Finck DWORD fog_enabled : 1;
1900c2c66affSColin Finck DWORD num_untracked_materials : 2; /* Max value 2 */
1901c2c66affSColin Finck DWORD current : 1;
1902c2c66affSColin Finck DWORD destroyed : 1;
1903c2c66affSColin Finck DWORD valid : 1;
1904c2c66affSColin Finck DWORD texShaderBumpMap : 8; /* MAX_TEXTURES, 8 */
1905c2c66affSColin Finck DWORD lastWasPow2Texture : 8; /* MAX_TEXTURES, 8 */
1906c2c66affSColin Finck DWORD fixed_function_usage_map : 8; /* MAX_TEXTURES, 8 */
1907c2c66affSColin Finck DWORD lowest_disabled_stage : 4; /* Max MAX_TEXTURES, 8 */
1908c2c66affSColin Finck DWORD use_immediate_mode_draw : 1;
1909c2c66affSColin Finck DWORD rebind_fbo : 1;
1910c2c66affSColin Finck DWORD needs_set : 1;
1911c2c66affSColin Finck DWORD hdc_is_private : 1;
1912c2c66affSColin Finck DWORD hdc_has_format : 1; /* only meaningful if hdc_is_private */
1913c2c66affSColin Finck DWORD update_shader_resource_bindings : 1;
1914c2c66affSColin Finck DWORD update_compute_shader_resource_bindings : 1;
1915c2c66affSColin Finck DWORD update_unordered_access_view_bindings : 1;
1916c2c66affSColin Finck DWORD update_compute_unordered_access_view_bindings : 1;
1917c2c66affSColin Finck DWORD uses_uavs : 1;
1918c2c66affSColin Finck DWORD destroy_delayed : 1;
1919c2c66affSColin Finck DWORD transform_feedback_active : 1;
1920c2c66affSColin Finck DWORD transform_feedback_paused : 1;
1921d6ac0a71SAmine Khaldi DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1922d6ac0a71SAmine Khaldi DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
19239987f029SAmine Khaldi DWORD last_was_dual_blend : 1;
19249987f029SAmine Khaldi DWORD padding : 8;
1925c2c66affSColin Finck DWORD constant_update_mask;
1926c2c66affSColin Finck DWORD numbered_array_mask;
1927c2c66affSColin Finck GLenum tracking_parm; /* Which source is tracking current colour */
1928c2c66affSColin Finck GLenum untracked_materials[2];
1929c2c66affSColin Finck UINT blit_w, blit_h;
1930c2c66affSColin Finck enum fogsource fog_source;
1931c2c66affSColin Finck DWORD active_texture;
1932c2c66affSColin Finck DWORD *texture_type;
1933c2c66affSColin Finck
1934c2c66affSColin Finck UINT instance_count;
1935c2c66affSColin Finck
1936c2c66affSColin Finck /* The actual opengl context */
1937c2c66affSColin Finck UINT level;
1938c2c66affSColin Finck HGLRC restore_ctx;
1939c2c66affSColin Finck HDC restore_dc;
1940c2c66affSColin Finck int restore_pf;
1941c2c66affSColin Finck HWND restore_pf_win;
1942c2c66affSColin Finck HGLRC glCtx;
1943c2c66affSColin Finck HWND win_handle;
1944c2c66affSColin Finck HDC hdc;
1945c2c66affSColin Finck int pixel_format;
1946c2c66affSColin Finck GLint aux_buffers;
1947c2c66affSColin Finck
1948c2c66affSColin Finck void *shader_backend_data;
1949c2c66affSColin Finck void *fragment_pipe_data;
1950c2c66affSColin Finck
1951c2c66affSColin Finck /* FBOs */
1952c2c66affSColin Finck UINT fbo_entry_count;
1953c2c66affSColin Finck struct list fbo_list;
1954c2c66affSColin Finck struct list fbo_destroy_list;
1955c2c66affSColin Finck struct fbo_entry *current_fbo;
1956c2c66affSColin Finck GLuint fbo_read_binding;
1957c2c66affSColin Finck GLuint fbo_draw_binding;
19589987f029SAmine Khaldi struct wined3d_rendertarget_info blit_targets[MAX_RENDER_TARGET_VIEWS];
1959c2c66affSColin Finck DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
1960c2c66affSColin Finck
1961c2c66affSColin Finck /* Queries */
1962c2c66affSColin Finck GLuint *free_occlusion_queries;
1963c2c66affSColin Finck SIZE_T free_occlusion_query_size;
1964c2c66affSColin Finck unsigned int free_occlusion_query_count;
1965c2c66affSColin Finck struct list occlusion_queries;
1966c2c66affSColin Finck
1967c2c66affSColin Finck union wined3d_gl_fence_object *free_fences;
1968c2c66affSColin Finck SIZE_T free_fence_size;
1969c2c66affSColin Finck unsigned int free_fence_count;
1970c2c66affSColin Finck struct list fences;
1971c2c66affSColin Finck
1972c2c66affSColin Finck GLuint *free_timestamp_queries;
1973c2c66affSColin Finck SIZE_T free_timestamp_query_size;
1974c2c66affSColin Finck unsigned int free_timestamp_query_count;
1975c2c66affSColin Finck struct list timestamp_queries;
1976c2c66affSColin Finck
1977c2c66affSColin Finck union wined3d_gl_so_statistics_query *free_so_statistics_queries;
1978c2c66affSColin Finck SIZE_T free_so_statistics_query_size;
1979c2c66affSColin Finck unsigned int free_so_statistics_query_count;
1980c2c66affSColin Finck struct list so_statistics_queries;
1981c2c66affSColin Finck
1982c2c66affSColin Finck union wined3d_gl_pipeline_statistics_query *free_pipeline_statistics_queries;
1983c2c66affSColin Finck SIZE_T free_pipeline_statistics_query_size;
1984c2c66affSColin Finck unsigned int free_pipeline_statistics_query_count;
1985c2c66affSColin Finck struct list pipeline_statistics_queries;
1986c2c66affSColin Finck
1987c2c66affSColin Finck struct wined3d_stream_info stream_info;
1988c2c66affSColin Finck
1989c2c66affSColin Finck /* Fences for GL_APPLE_flush_buffer_range */
1990c2c66affSColin Finck struct wined3d_fence *buffer_fences[MAX_ATTRIBS];
1991c2c66affSColin Finck unsigned int buffer_fence_count;
1992c2c66affSColin Finck
1993c2c66affSColin Finck DWORD tex_unit_map[MAX_COMBINED_SAMPLERS];
1994c2c66affSColin Finck DWORD rev_tex_unit_map[MAX_GL_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS];
1995c2c66affSColin Finck
1996c2c66affSColin Finck /* Extension emulation */
1997c2c66affSColin Finck GLint gl_fog_source;
1998c2c66affSColin Finck GLfloat fog_coord_value;
1999c2c66affSColin Finck GLfloat color[4], fogstart, fogend, fogcolor[4];
2000c2c66affSColin Finck GLuint dummy_arbfp_prog;
2001c2c66affSColin Finck };
2002c2c66affSColin Finck
2003c2c66affSColin Finck struct wined3d_fb_state
2004c2c66affSColin Finck {
20059987f029SAmine Khaldi struct wined3d_rendertarget_view *render_targets[MAX_RENDER_TARGET_VIEWS];
2006c2c66affSColin Finck struct wined3d_rendertarget_view *depth_stencil;
2007c2c66affSColin Finck };
2008c2c66affSColin Finck
2009c2c66affSColin Finck typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2010c2c66affSColin Finck
2011c2c66affSColin Finck struct StateEntry
2012c2c66affSColin Finck {
2013c2c66affSColin Finck DWORD representative;
2014c2c66affSColin Finck APPLYSTATEFUNC apply;
2015c2c66affSColin Finck };
2016c2c66affSColin Finck
2017c2c66affSColin Finck struct StateEntryTemplate
2018c2c66affSColin Finck {
2019c2c66affSColin Finck DWORD state;
2020c2c66affSColin Finck struct StateEntry content;
2021c2c66affSColin Finck enum wined3d_gl_extension extension;
2022c2c66affSColin Finck };
2023c2c66affSColin Finck
2024c2c66affSColin Finck #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2025c2c66affSColin Finck #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2026c2c66affSColin Finck #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2027c2c66affSColin Finck
2028c2c66affSColin Finck struct fragment_caps
2029c2c66affSColin Finck {
2030c2c66affSColin Finck DWORD wined3d_caps;
2031c2c66affSColin Finck DWORD PrimitiveMiscCaps;
2032c2c66affSColin Finck DWORD TextureOpCaps;
2033c2c66affSColin Finck DWORD MaxTextureBlendStages;
2034c2c66affSColin Finck DWORD MaxSimultaneousTextures;
2035c2c66affSColin Finck };
2036c2c66affSColin Finck
2037c2c66affSColin Finck #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2038c2c66affSColin Finck #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2039c2c66affSColin Finck
2040c2c66affSColin Finck struct fragment_pipeline
2041c2c66affSColin Finck {
2042c2c66affSColin Finck void (*enable_extension)(const struct wined3d_gl_info *gl_info, BOOL enable);
2043c2c66affSColin Finck void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
2044c2c66affSColin Finck DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2045c2c66affSColin Finck void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2046c2c66affSColin Finck void (*free_private)(struct wined3d_device *device);
2047c2c66affSColin Finck BOOL (*allocate_context_data)(struct wined3d_context *context);
2048c2c66affSColin Finck void (*free_context_data)(struct wined3d_context *context);
2049c2c66affSColin Finck BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2050c2c66affSColin Finck const struct StateEntryTemplate *states;
2051c2c66affSColin Finck };
2052c2c66affSColin Finck
2053c2c66affSColin Finck struct wined3d_vertex_caps
2054c2c66affSColin Finck {
2055c2c66affSColin Finck BOOL xyzrhw;
2056c2c66affSColin Finck BOOL emulated_flatshading;
2057c2c66affSColin Finck BOOL ffp_generic_attributes;
2058c2c66affSColin Finck DWORD max_active_lights;
2059c2c66affSColin Finck DWORD max_vertex_blend_matrices;
2060c2c66affSColin Finck DWORD max_vertex_blend_matrix_index;
2061c2c66affSColin Finck DWORD vertex_processing_caps;
2062c2c66affSColin Finck DWORD fvf_caps;
2063c2c66affSColin Finck DWORD max_user_clip_planes;
2064c2c66affSColin Finck DWORD raster_caps;
2065c2c66affSColin Finck };
2066c2c66affSColin Finck
2067c2c66affSColin Finck struct wined3d_vertex_pipe_ops
2068c2c66affSColin Finck {
2069c2c66affSColin Finck void (*vp_enable)(const struct wined3d_gl_info *gl_info, BOOL enable);
2070c2c66affSColin Finck void (*vp_get_caps)(const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps);
2071c2c66affSColin Finck DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2072c2c66affSColin Finck void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2073c2c66affSColin Finck void (*vp_free)(struct wined3d_device *device);
2074c2c66affSColin Finck const struct StateEntryTemplate *vp_states;
2075c2c66affSColin Finck };
2076c2c66affSColin Finck
2077c2c66affSColin Finck extern const struct StateEntryTemplate misc_state_template[] DECLSPEC_HIDDEN;
2078c2c66affSColin Finck extern const struct fragment_pipeline none_fragment_pipe DECLSPEC_HIDDEN;
2079c2c66affSColin Finck extern const struct fragment_pipeline ffp_fragment_pipeline DECLSPEC_HIDDEN;
2080c2c66affSColin Finck extern const struct fragment_pipeline atifs_fragment_pipeline DECLSPEC_HIDDEN;
2081c2c66affSColin Finck extern const struct fragment_pipeline arbfp_fragment_pipeline DECLSPEC_HIDDEN;
2082c2c66affSColin Finck extern const struct fragment_pipeline nvts_fragment_pipeline DECLSPEC_HIDDEN;
2083c2c66affSColin Finck extern const struct fragment_pipeline nvrc_fragment_pipeline DECLSPEC_HIDDEN;
2084c2c66affSColin Finck extern const struct fragment_pipeline glsl_fragment_pipe DECLSPEC_HIDDEN;
2085c2c66affSColin Finck
2086c2c66affSColin Finck extern const struct wined3d_vertex_pipe_ops none_vertex_pipe DECLSPEC_HIDDEN;
2087c2c66affSColin Finck extern const struct wined3d_vertex_pipe_ops ffp_vertex_pipe DECLSPEC_HIDDEN;
2088c2c66affSColin Finck extern const struct wined3d_vertex_pipe_ops glsl_vertex_pipe DECLSPEC_HIDDEN;
2089c2c66affSColin Finck
2090c2c66affSColin Finck /* "Base" state table */
2091c2c66affSColin Finck HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
2092c2c66affSColin Finck const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info,
2093c2c66affSColin Finck const struct wined3d_vertex_pipe_ops *vertex, const struct fragment_pipeline *fragment,
2094c2c66affSColin Finck const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
2095c2c66affSColin Finck
2096*81cffd76SJoachim Henze struct wined3d_surface;
2097*81cffd76SJoachim Henze
2098c2c66affSColin Finck enum wined3d_blit_op
2099c2c66affSColin Finck {
2100c2c66affSColin Finck WINED3D_BLIT_OP_COLOR_BLIT,
2101c2c66affSColin Finck WINED3D_BLIT_OP_COLOR_BLIT_ALPHATEST,
2102c2c66affSColin Finck WINED3D_BLIT_OP_COLOR_BLIT_CKEY,
2103c2c66affSColin Finck WINED3D_BLIT_OP_COLOR_FILL,
2104c2c66affSColin Finck WINED3D_BLIT_OP_DEPTH_FILL,
2105c2c66affSColin Finck WINED3D_BLIT_OP_DEPTH_BLIT,
2106d6ac0a71SAmine Khaldi WINED3D_BLIT_OP_RAW_BLIT,
2107c2c66affSColin Finck };
2108c2c66affSColin Finck
2109c2c66affSColin Finck struct wined3d_blitter
2110c2c66affSColin Finck {
2111c2c66affSColin Finck const struct wined3d_blitter_ops *ops;
2112c2c66affSColin Finck struct wined3d_blitter *next;
2113c2c66affSColin Finck };
2114c2c66affSColin Finck
2115c2c66affSColin Finck struct wined3d_blitter_ops
2116c2c66affSColin Finck {
2117c2c66affSColin Finck void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2118c2c66affSColin Finck void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2119c2c66affSColin Finck unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2120c2c66affSColin Finck const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2121d6ac0a71SAmine Khaldi DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2122*81cffd76SJoachim Henze struct wined3d_surface *src_surface, DWORD src_location, const RECT *src_rect,
2123*81cffd76SJoachim Henze struct wined3d_surface *dst_surface, DWORD dst_location, const RECT *dst_rect,
2124*81cffd76SJoachim Henze const struct wined3d_color_key *color_key, enum wined3d_texture_filter_type filter);
2125c2c66affSColin Finck };
2126c2c66affSColin Finck
2127c2c66affSColin Finck void wined3d_arbfp_blitter_create(struct wined3d_blitter **next,
2128c2c66affSColin Finck const struct wined3d_device *device) DECLSPEC_HIDDEN;
2129c2c66affSColin Finck struct wined3d_blitter *wined3d_cpu_blitter_create(void) DECLSPEC_HIDDEN;
2130c2c66affSColin Finck void wined3d_fbo_blitter_create(struct wined3d_blitter **next,
2131c2c66affSColin Finck const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2132c2c66affSColin Finck void wined3d_ffp_blitter_create(struct wined3d_blitter **next,
2133c2c66affSColin Finck const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2134d6ac0a71SAmine Khaldi void wined3d_raw_blitter_create(struct wined3d_blitter **next,
2135d6ac0a71SAmine Khaldi const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2136c2c66affSColin Finck
2137c2c66affSColin Finck BOOL wined3d_clip_blit(const RECT *clip_rect, RECT *clipped, RECT *other) DECLSPEC_HIDDEN;
2138c2c66affSColin Finck
2139c2c66affSColin Finck struct wined3d_context *context_acquire(const struct wined3d_device *device,
2140c2c66affSColin Finck struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2141c2c66affSColin Finck void context_alloc_fence(struct wined3d_context *context, struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2142c2c66affSColin Finck void context_alloc_occlusion_query(struct wined3d_context *context,
2143c2c66affSColin Finck struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2144c2c66affSColin Finck void context_apply_blit_state(struct wined3d_context *context, const struct wined3d_device *device) DECLSPEC_HIDDEN;
2145c2c66affSColin Finck BOOL context_apply_clear_state(struct wined3d_context *context, const struct wined3d_state *state,
2146c2c66affSColin Finck UINT rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2147c2c66affSColin Finck void context_apply_fbo_state_blit(struct wined3d_context *context, GLenum target,
2148*81cffd76SJoachim Henze struct wined3d_surface *render_target, struct wined3d_surface *depth_stencil, DWORD location) DECLSPEC_HIDDEN;
2149c2c66affSColin Finck void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info,
2150c2c66affSColin Finck unsigned int unit) DECLSPEC_HIDDEN;
2151c2c66affSColin Finck void context_bind_bo(struct wined3d_context *context, GLenum binding, GLuint name) DECLSPEC_HIDDEN;
2152c2c66affSColin Finck void context_bind_dummy_textures(const struct wined3d_device *device,
2153c2c66affSColin Finck const struct wined3d_context *context) DECLSPEC_HIDDEN;
2154c2c66affSColin Finck void context_bind_texture(struct wined3d_context *context, GLenum target, GLuint name) DECLSPEC_HIDDEN;
2155c2c66affSColin Finck void context_check_fbo_status(const struct wined3d_context *context, GLenum target) DECLSPEC_HIDDEN;
2156c2c66affSColin Finck void context_copy_bo_address(struct wined3d_context *context,
2157c2c66affSColin Finck const struct wined3d_bo_address *dst, GLenum dst_binding,
2158c2c66affSColin Finck const struct wined3d_bo_address *src, GLenum src_binding, size_t size) DECLSPEC_HIDDEN;
2159c2c66affSColin Finck struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_texture *target,
2160c2c66affSColin Finck const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
2161c2c66affSColin Finck HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2162c2c66affSColin Finck void context_destroy(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
2163d6ac0a71SAmine Khaldi void context_enable_clip_distances(struct wined3d_context *context, unsigned int mask) DECLSPEC_HIDDEN;
2164c2c66affSColin Finck void context_end_transform_feedback(struct wined3d_context *context) DECLSPEC_HIDDEN;
2165c2c66affSColin Finck void context_free_fence(struct wined3d_fence *fence) DECLSPEC_HIDDEN;
2166c2c66affSColin Finck void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
2167c2c66affSColin Finck struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
2168c2c66affSColin Finck GLenum context_get_offscreen_gl_buffer(const struct wined3d_context *context) DECLSPEC_HIDDEN;
2169c2c66affSColin Finck const DWORD *context_get_tex_unit_mapping(const struct wined3d_context *context,
2170c2c66affSColin Finck const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2171c2c66affSColin Finck DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
2172c2c66affSColin Finck void context_gl_resource_released(struct wined3d_device *device,
2173c2c66affSColin Finck GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2174c2c66affSColin Finck void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2175c2c66affSColin Finck void context_invalidate_state(struct wined3d_context *context, DWORD state_id) DECLSPEC_HIDDEN;
2176c2c66affSColin Finck void *context_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data,
2177c2c66affSColin Finck size_t size, GLenum binding, DWORD flags) DECLSPEC_HIDDEN;
2178c2c66affSColin Finck struct wined3d_context *context_reacquire(const struct wined3d_device *device,
2179c2c66affSColin Finck struct wined3d_context *context) DECLSPEC_HIDDEN;
2180c2c66affSColin Finck void context_release(struct wined3d_context *context) DECLSPEC_HIDDEN;
2181*81cffd76SJoachim Henze void context_resource_released(const struct wined3d_device *device,
2182*81cffd76SJoachim Henze struct wined3d_resource *resource, enum wined3d_resource_type type) DECLSPEC_HIDDEN;
2183*81cffd76SJoachim Henze void context_restore(struct wined3d_context *context, struct wined3d_surface *restore) DECLSPEC_HIDDEN;
2184c2c66affSColin Finck BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN;
2185c2c66affSColin Finck void context_set_draw_buffer(struct wined3d_context *context, GLenum buffer) DECLSPEC_HIDDEN;
2186c2c66affSColin Finck void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
2187c2c66affSColin Finck void context_state_drawbuf(struct wined3d_context *context,
2188c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2189c2c66affSColin Finck void context_state_fb(struct wined3d_context *context,
2190c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2191*81cffd76SJoachim Henze void context_surface_update(struct wined3d_context *context, const struct wined3d_surface *surface) DECLSPEC_HIDDEN;
2192c2c66affSColin Finck void context_unmap_bo_address(struct wined3d_context *context,
2193c2c66affSColin Finck const struct wined3d_bo_address *data, GLenum binding) DECLSPEC_HIDDEN;
2194c2c66affSColin Finck
2195c2c66affSColin Finck /*****************************************************************************
2196c2c66affSColin Finck * Internal representation of a light
2197c2c66affSColin Finck */
2198c2c66affSColin Finck struct wined3d_light_info
2199c2c66affSColin Finck {
2200c2c66affSColin Finck struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2201c2c66affSColin Finck DWORD OriginalIndex;
2202c2c66affSColin Finck LONG glIndex;
2203c2c66affSColin Finck BOOL enabled;
2204c2c66affSColin Finck
2205c2c66affSColin Finck /* Converted parms to speed up swapping lights */
2206c2c66affSColin Finck struct wined3d_vec4 position;
2207c2c66affSColin Finck struct wined3d_vec4 direction;
2208c2c66affSColin Finck float exponent;
2209c2c66affSColin Finck float cutoff;
2210c2c66affSColin Finck
2211c2c66affSColin Finck struct list entry;
2212c2c66affSColin Finck };
2213c2c66affSColin Finck
2214c2c66affSColin Finck /* The default light parameters */
2215c2c66affSColin Finck extern const struct wined3d_light WINED3D_default_light DECLSPEC_HIDDEN;
2216c2c66affSColin Finck
2217c2c66affSColin Finck struct wined3d_pixel_format
2218c2c66affSColin Finck {
2219c2c66affSColin Finck int iPixelFormat; /* WGL pixel format */
2220c2c66affSColin Finck int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2221c2c66affSColin Finck int redSize, greenSize, blueSize, alphaSize, colorSize;
2222c2c66affSColin Finck int depthSize, stencilSize;
2223c2c66affSColin Finck BOOL windowDrawable;
2224c2c66affSColin Finck BOOL doubleBuffer;
2225c2c66affSColin Finck int auxBuffers;
2226c2c66affSColin Finck int numSamples;
2227c2c66affSColin Finck };
2228c2c66affSColin Finck
2229c2c66affSColin Finck enum wined3d_pci_vendor
2230c2c66affSColin Finck {
2231c2c66affSColin Finck HW_VENDOR_SOFTWARE = 0x0000,
2232c2c66affSColin Finck HW_VENDOR_AMD = 0x1002,
2233c2c66affSColin Finck HW_VENDOR_NVIDIA = 0x10de,
2234c2c66affSColin Finck HW_VENDOR_VMWARE = 0x15ad,
2235c2c66affSColin Finck HW_VENDOR_INTEL = 0x8086,
2236c2c66affSColin Finck };
2237c2c66affSColin Finck
2238c2c66affSColin Finck enum wined3d_pci_device
2239c2c66affSColin Finck {
2240c2c66affSColin Finck CARD_WINE = 0x0000,
2241c2c66affSColin Finck
2242c2c66affSColin Finck CARD_AMD_RAGE_128PRO = 0x5246,
2243c2c66affSColin Finck CARD_AMD_RADEON_7200 = 0x5144,
2244c2c66affSColin Finck CARD_AMD_RADEON_8500 = 0x514c,
2245c2c66affSColin Finck CARD_AMD_RADEON_9500 = 0x4144,
2246c2c66affSColin Finck CARD_AMD_RADEON_XPRESS_200M = 0x5955,
2247c2c66affSColin Finck CARD_AMD_RADEON_X700 = 0x5e4c,
2248c2c66affSColin Finck CARD_AMD_RADEON_X1600 = 0x71c2,
2249c2c66affSColin Finck CARD_AMD_RADEON_HD2350 = 0x94c7,
2250c2c66affSColin Finck CARD_AMD_RADEON_HD2600 = 0x9581,
2251c2c66affSColin Finck CARD_AMD_RADEON_HD2900 = 0x9400,
2252c2c66affSColin Finck CARD_AMD_RADEON_HD3200 = 0x9620,
2253c2c66affSColin Finck CARD_AMD_RADEON_HD3850 = 0x9515,
2254c2c66affSColin Finck CARD_AMD_RADEON_HD4200M = 0x9712,
2255c2c66affSColin Finck CARD_AMD_RADEON_HD4350 = 0x954f,
2256c2c66affSColin Finck CARD_AMD_RADEON_HD4600 = 0x9495,
2257c2c66affSColin Finck CARD_AMD_RADEON_HD4700 = 0x944e,
2258c2c66affSColin Finck CARD_AMD_RADEON_HD4800 = 0x944c,
2259c2c66affSColin Finck CARD_AMD_RADEON_HD5400 = 0x68f9,
2260c2c66affSColin Finck CARD_AMD_RADEON_HD5600 = 0x68d8,
2261c2c66affSColin Finck CARD_AMD_RADEON_HD5700 = 0x68be,
2262c2c66affSColin Finck CARD_AMD_RADEON_HD5800 = 0x6898,
2263c2c66affSColin Finck CARD_AMD_RADEON_HD5900 = 0x689c,
2264c2c66affSColin Finck CARD_AMD_RADEON_HD6300 = 0x9803,
2265c2c66affSColin Finck CARD_AMD_RADEON_HD6400 = 0x6770,
2266c2c66affSColin Finck CARD_AMD_RADEON_HD6410D = 0x9644,
2267c2c66affSColin Finck CARD_AMD_RADEON_HD6480G = 0x9648,
2268c2c66affSColin Finck CARD_AMD_RADEON_HD6550D = 0x9640,
2269c2c66affSColin Finck CARD_AMD_RADEON_HD6600 = 0x6758,
2270c2c66affSColin Finck CARD_AMD_RADEON_HD6600M = 0x6741,
2271c2c66affSColin Finck CARD_AMD_RADEON_HD6700 = 0x68ba,
2272c2c66affSColin Finck CARD_AMD_RADEON_HD6800 = 0x6739,
2273c2c66affSColin Finck CARD_AMD_RADEON_HD6900 = 0x6719,
2274c2c66affSColin Finck CARD_AMD_RADEON_HD7660D = 0x9901,
2275c2c66affSColin Finck CARD_AMD_RADEON_HD7700 = 0x683d,
2276c2c66affSColin Finck CARD_AMD_RADEON_HD7800 = 0x6819,
2277c2c66affSColin Finck CARD_AMD_RADEON_HD7900 = 0x679a,
2278c2c66affSColin Finck CARD_AMD_RADEON_HD8600M = 0x6660,
2279c2c66affSColin Finck CARD_AMD_RADEON_HD8670 = 0x6610,
2280c2c66affSColin Finck CARD_AMD_RADEON_HD8770 = 0x665c,
2281c2c66affSColin Finck CARD_AMD_RADEON_R3 = 0x9830,
2282c2c66affSColin Finck CARD_AMD_RADEON_R7 = 0x130f,
2283c2c66affSColin Finck CARD_AMD_RADEON_R9_285 = 0x6939,
2284c2c66affSColin Finck CARD_AMD_RADEON_R9_290 = 0x67b1,
2285c2c66affSColin Finck CARD_AMD_RADEON_R9_FURY = 0x7300,
2286c2c66affSColin Finck CARD_AMD_RADEON_RX_460 = 0x67ef,
2287c2c66affSColin Finck CARD_AMD_RADEON_RX_480 = 0x67df,
2288c2c66affSColin Finck
2289c2c66affSColin Finck CARD_NVIDIA_RIVA_128 = 0x0018,
2290c2c66affSColin Finck CARD_NVIDIA_RIVA_TNT = 0x0020,
2291c2c66affSColin Finck CARD_NVIDIA_RIVA_TNT2 = 0x0028,
2292c2c66affSColin Finck CARD_NVIDIA_GEFORCE = 0x0100,
2293c2c66affSColin Finck CARD_NVIDIA_GEFORCE2_MX = 0x0110,
2294c2c66affSColin Finck CARD_NVIDIA_GEFORCE2 = 0x0150,
2295c2c66affSColin Finck CARD_NVIDIA_GEFORCE3 = 0x0200,
2296c2c66affSColin Finck CARD_NVIDIA_GEFORCE4_MX = 0x0170,
2297c2c66affSColin Finck CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
2298c2c66affSColin Finck CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
2299c2c66affSColin Finck CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
2300c2c66affSColin Finck CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
2301c2c66affSColin Finck CARD_NVIDIA_GEFORCE_6200 = 0x014f,
2302c2c66affSColin Finck CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
2303c2c66affSColin Finck CARD_NVIDIA_GEFORCE_6800 = 0x0041,
2304c2c66affSColin Finck CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2305c2c66affSColin Finck CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
2306c2c66affSColin Finck CARD_NVIDIA_GEFORCE_7600 = 0x0391,
2307c2c66affSColin Finck CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
2308c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2309c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
2310c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8400GS = 0x0404,
2311c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8500GT = 0x0421,
2312c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
2313c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
2314c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
2315c2c66affSColin Finck CARD_NVIDIA_GEFORCE_8800GTX = 0x0191,
2316c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9200 = 0x086d,
2317c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9300 = 0x086c,
2318c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9400M = 0x0863,
2319c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
2320c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
2321c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
2322c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9700MGT = 0x064a,
2323c2c66affSColin Finck CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
2324c2c66affSColin Finck CARD_NVIDIA_GEFORCE_210 = 0x0a23,
2325c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT220 = 0x0a20,
2326c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT240 = 0x0ca3,
2327c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTS250 = 0x0615,
2328c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
2329c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
2330c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
2331c2c66affSColin Finck CARD_NVIDIA_GEFORCE_315M = 0x0a7a,
2332c2c66affSColin Finck CARD_NVIDIA_GEFORCE_320M = 0x08a3,
2333c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT320M = 0x0a2d,
2334c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT325M = 0x0a35,
2335c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT330 = 0x0ca0,
2336c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTS350M = 0x0cb0,
2337c2c66affSColin Finck CARD_NVIDIA_GEFORCE_410M = 0x1055,
2338c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT420 = 0x0de2,
2339c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT425M = 0x0df0,
2340c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT430 = 0x0de1,
2341c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT440 = 0x0de0,
2342c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTS450 = 0x0dc4,
2343c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX460 = 0x0e22,
2344c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX460M = 0x0dd1,
2345c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX465 = 0x06c4,
2346c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX470 = 0x06cd,
2347c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX480 = 0x06c0,
2348c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT520 = 0x1040,
2349c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT525M = 0x0dec,
2350c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT540M = 0x0df4,
2351c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX550 = 0x1244,
2352c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT555M = 0x04b8,
2353c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX560TI = 0x1200,
23549987f029SAmine Khaldi CARD_NVIDIA_GEFORCE_GTX560M = 0x1251,
2355c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX560 = 0x1201,
2356c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX570 = 0x1081,
2357c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX580 = 0x1080,
2358c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT610 = 0x104a,
2359c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT630 = 0x0f00,
2360c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT630M = 0x0de9,
2361c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT640M = 0x0fd2,
2362c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT650M = 0x0fd1,
2363c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX650 = 0x0fc6,
2364c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX650TI = 0x11c6,
2365c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX660 = 0x11c0,
2366c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX660M = 0x0fd4,
2367c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX660TI = 0x1183,
2368c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX670 = 0x1189,
2369c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX670MX = 0x11a1,
2370c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX675MX = 0x11a7,
2371c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX680 = 0x1180,
2372c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX690 = 0x1188,
2373c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT730 = 0x1287,
2374c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT730M = 0x0fe1,
2375c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT740M = 0x1292,
2376c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GT750M = 0x0fe9,
2377c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX750 = 0x1381,
2378c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX750TI = 0x1380,
2379c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX760 = 0x1187,
2380c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX760TI = 0x1193,
2381c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX765M = 0x11e2,
2382c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX770M = 0x11e0,
2383c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX770 = 0x1184,
2384c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX780 = 0x1004,
2385c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX780TI = 0x100a,
2386c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTXTITAN = 0x1005,
2387c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTXTITANB = 0x100c,
2388c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTXTITANX = 0x17c2,
2389c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTXTITANZ = 0x1001,
2390c2c66affSColin Finck CARD_NVIDIA_GEFORCE_820M = 0x0fed,
2391c2c66affSColin Finck CARD_NVIDIA_GEFORCE_830M = 0x1340,
2392c2c66affSColin Finck CARD_NVIDIA_GEFORCE_840M = 0x1341,
2393c2c66affSColin Finck CARD_NVIDIA_GEFORCE_845M = 0x1344,
2394c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX850M = 0x1391,
2395c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
2396c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX870M = 0x1199,
2397c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX880M = 0x1198,
2398c2c66affSColin Finck CARD_NVIDIA_GEFORCE_940M = 0x1347,
2399c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX950 = 0x1402,
2400c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX950M = 0x139a,
2401c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX960 = 0x1401,
2402c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX960M = 0x139b,
2403c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX970 = 0x13c2,
2404c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX970M = 0x13d8,
2405c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX980 = 0x13c0,
2406c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX980TI = 0x17c8,
2407c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX1050 = 0x1c81,
2408c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX1060 = 0x1c03,
2409c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX1070 = 0x1b81,
2410c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX1080 = 0x1b80,
2411c2c66affSColin Finck CARD_NVIDIA_GEFORCE_GTX1080TI = 0x1b06,
2412c2c66affSColin Finck CARD_NVIDIA_TITANX_PASCAL = 0x1b00,
2413c2c66affSColin Finck
2414c2c66affSColin Finck CARD_VMWARE_SVGA3D = 0x0405,
2415c2c66affSColin Finck
2416c2c66affSColin Finck CARD_INTEL_830M = 0x3577,
2417c2c66affSColin Finck CARD_INTEL_855GM = 0x3582,
2418c2c66affSColin Finck CARD_INTEL_845G = 0x2562,
2419c2c66affSColin Finck CARD_INTEL_865G = 0x2572,
2420c2c66affSColin Finck CARD_INTEL_915G = 0x2582,
2421c2c66affSColin Finck CARD_INTEL_E7221G = 0x258a,
2422c2c66affSColin Finck CARD_INTEL_915GM = 0x2592,
2423c2c66affSColin Finck CARD_INTEL_945G = 0x2772,
2424c2c66affSColin Finck CARD_INTEL_945GM = 0x27a2,
2425c2c66affSColin Finck CARD_INTEL_945GME = 0x27ae,
2426c2c66affSColin Finck CARD_INTEL_Q35 = 0x29b2,
2427c2c66affSColin Finck CARD_INTEL_G33 = 0x29c2,
2428c2c66affSColin Finck CARD_INTEL_Q33 = 0x29d2,
2429c2c66affSColin Finck CARD_INTEL_PNVG = 0xa001,
2430c2c66affSColin Finck CARD_INTEL_PNVM = 0xa011,
2431c2c66affSColin Finck CARD_INTEL_965Q = 0x2992,
2432c2c66affSColin Finck CARD_INTEL_965G = 0x2982,
2433c2c66affSColin Finck CARD_INTEL_946GZ = 0x2972,
2434c2c66affSColin Finck CARD_INTEL_965GM = 0x2a02,
2435c2c66affSColin Finck CARD_INTEL_965GME = 0x2a12,
2436c2c66affSColin Finck CARD_INTEL_GM45 = 0x2a42,
2437c2c66affSColin Finck CARD_INTEL_IGD = 0x2e02,
2438c2c66affSColin Finck CARD_INTEL_Q45 = 0x2e12,
2439c2c66affSColin Finck CARD_INTEL_G45 = 0x2e22,
2440c2c66affSColin Finck CARD_INTEL_G41 = 0x2e32,
2441c2c66affSColin Finck CARD_INTEL_B43 = 0x2e92,
2442c2c66affSColin Finck CARD_INTEL_ILKD = 0x0042,
2443c2c66affSColin Finck CARD_INTEL_ILKM = 0x0046,
2444c2c66affSColin Finck CARD_INTEL_SNBD = 0x0122,
2445c2c66affSColin Finck CARD_INTEL_SNBM = 0x0126,
2446c2c66affSColin Finck CARD_INTEL_SNBS = 0x010a,
2447c2c66affSColin Finck CARD_INTEL_IVBD = 0x0162,
2448c2c66affSColin Finck CARD_INTEL_IVBM = 0x0166,
2449c2c66affSColin Finck CARD_INTEL_IVBS = 0x015a,
2450c2c66affSColin Finck CARD_INTEL_HWD = 0x0412,
2451c2c66affSColin Finck CARD_INTEL_HWM = 0x0416,
2452d6ac0a71SAmine Khaldi CARD_INTEL_HD5000 = 0x0a26,
2453c2c66affSColin Finck CARD_INTEL_I5100_1 = 0x0a22,
2454c2c66affSColin Finck CARD_INTEL_I5100_2 = 0x0a2a,
2455c2c66affSColin Finck CARD_INTEL_I5100_3 = 0x0a2b,
2456c2c66affSColin Finck CARD_INTEL_I5100_4 = 0x0a2e,
2457c2c66affSColin Finck CARD_INTEL_IP5200_1 = 0x0d22,
2458c2c66affSColin Finck CARD_INTEL_IP5200_2 = 0x0d26,
2459c2c66affSColin Finck CARD_INTEL_IP5200_3 = 0x0d2a,
2460c2c66affSColin Finck CARD_INTEL_IP5200_4 = 0x0d2b,
2461c2c66affSColin Finck CARD_INTEL_IP5200_5 = 0x0d2e,
2462c2c66affSColin Finck CARD_INTEL_HD5300 = 0x161e,
2463c2c66affSColin Finck CARD_INTEL_HD5500 = 0x1616,
2464c2c66affSColin Finck CARD_INTEL_HD5600 = 0x1612,
2465c2c66affSColin Finck CARD_INTEL_HD6000 = 0x1626,
2466c2c66affSColin Finck CARD_INTEL_I6100 = 0x162b,
2467c2c66affSColin Finck CARD_INTEL_IP6200 = 0x1622,
2468c2c66affSColin Finck CARD_INTEL_IPP6300 = 0x162a,
2469c2c66affSColin Finck CARD_INTEL_HD510_1 = 0x1902,
2470c2c66affSColin Finck CARD_INTEL_HD510_2 = 0x1906,
2471c2c66affSColin Finck CARD_INTEL_HD510_3 = 0x190b,
2472c2c66affSColin Finck CARD_INTEL_HD515 = 0x191e,
2473c2c66affSColin Finck CARD_INTEL_HD520_1 = 0x1916,
2474c2c66affSColin Finck CARD_INTEL_HD520_2 = 0x1921,
2475c2c66affSColin Finck CARD_INTEL_HD530_1 = 0x1912,
2476c2c66affSColin Finck CARD_INTEL_HD530_2 = 0x191b,
2477c2c66affSColin Finck CARD_INTEL_HDP530 = 0x191d,
2478c2c66affSColin Finck CARD_INTEL_I540 = 0x1926,
2479c2c66affSColin Finck CARD_INTEL_I550 = 0x1927,
2480c2c66affSColin Finck CARD_INTEL_I555 = 0x192b,
2481c2c66affSColin Finck CARD_INTEL_IP555 = 0x192d,
2482c2c66affSColin Finck CARD_INTEL_IP580_1 = 0x1932,
2483c2c66affSColin Finck CARD_INTEL_IP580_2 = 0x193b,
2484c2c66affSColin Finck CARD_INTEL_IPP580_1 = 0x193a,
2485c2c66affSColin Finck CARD_INTEL_IPP580_2 = 0x193d,
2486c2c66affSColin Finck };
2487c2c66affSColin Finck
2488c2c66affSColin Finck struct wined3d_fbo_ops
2489c2c66affSColin Finck {
2490c2c66affSColin Finck GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
2491c2c66affSColin Finck void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
2492c2c66affSColin Finck void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
2493c2c66affSColin Finck void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
2494c2c66affSColin Finck void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
2495c2c66affSColin Finck GLsizei width, GLsizei height);
2496c2c66affSColin Finck void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
2497c2c66affSColin Finck GLenum internalformat, GLsizei width, GLsizei height);
2498c2c66affSColin Finck void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
2499c2c66affSColin Finck GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
2500c2c66affSColin Finck void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
2501c2c66affSColin Finck void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
2502c2c66affSColin Finck void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
2503c2c66affSColin Finck GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
2504c2c66affSColin Finck void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
2505c2c66affSColin Finck GLuint texture, GLint level);
2506c2c66affSColin Finck void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
2507c2c66affSColin Finck GLenum textarget, GLuint texture, GLint level);
2508c2c66affSColin Finck void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
2509c2c66affSColin Finck GLenum textarget, GLuint texture, GLint level);
2510c2c66affSColin Finck void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
2511c2c66affSColin Finck GLenum textarget, GLuint texture, GLint level, GLint layer);
2512c2c66affSColin Finck void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
2513c2c66affSColin Finck GLuint texture, GLint level, GLint layer);
2514c2c66affSColin Finck void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
2515c2c66affSColin Finck GLenum renderbuffertarget, GLuint renderbuffer);
2516c2c66affSColin Finck void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
2517c2c66affSColin Finck GLenum pname, GLint *params);
2518c2c66affSColin Finck void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2519c2c66affSColin Finck GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
2520c2c66affSColin Finck void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
2521c2c66affSColin Finck };
2522c2c66affSColin Finck
2523c2c66affSColin Finck struct wined3d_gl_limits
2524c2c66affSColin Finck {
2525c2c66affSColin Finck UINT buffers;
25269987f029SAmine Khaldi UINT dual_buffers;
2527c2c66affSColin Finck UINT lights;
2528c2c66affSColin Finck UINT textures;
2529c2c66affSColin Finck UINT texture_coords;
2530c2c66affSColin Finck unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
2531c2c66affSColin Finck unsigned int samplers[WINED3D_SHADER_TYPE_COUNT];
2532c2c66affSColin Finck unsigned int graphics_samplers;
2533c2c66affSColin Finck unsigned int combined_samplers;
2534c2c66affSColin Finck UINT general_combiners;
2535c2c66affSColin Finck UINT user_clip_distances;
2536c2c66affSColin Finck UINT texture_size;
2537c2c66affSColin Finck UINT texture3d_size;
2538c2c66affSColin Finck float pointsize_max;
2539c2c66affSColin Finck float pointsize_min;
2540*81cffd76SJoachim Henze UINT blends;
2541c2c66affSColin Finck UINT anisotropy;
2542c2c66affSColin Finck float shininess;
2543c2c66affSColin Finck UINT samples;
2544c2c66affSColin Finck UINT vertex_attribs;
2545c2c66affSColin Finck
2546c2c66affSColin Finck unsigned int texture_buffer_offset_alignment;
2547c2c66affSColin Finck
25489987f029SAmine Khaldi unsigned int framebuffer_width;
25499987f029SAmine Khaldi unsigned int framebuffer_height;
25509987f029SAmine Khaldi
2551c2c66affSColin Finck UINT glsl_varyings;
2552c2c66affSColin Finck UINT glsl_vs_float_constants;
2553c2c66affSColin Finck UINT glsl_ps_float_constants;
2554c2c66affSColin Finck
2555c2c66affSColin Finck UINT arb_vs_float_constants;
2556c2c66affSColin Finck UINT arb_vs_native_constants;
2557c2c66affSColin Finck UINT arb_vs_instructions;
2558c2c66affSColin Finck UINT arb_vs_temps;
2559c2c66affSColin Finck UINT arb_ps_float_constants;
2560c2c66affSColin Finck UINT arb_ps_local_constants;
2561c2c66affSColin Finck UINT arb_ps_native_constants;
2562c2c66affSColin Finck UINT arb_ps_instructions;
2563c2c66affSColin Finck UINT arb_ps_temps;
2564c2c66affSColin Finck };
2565c2c66affSColin Finck
2566c2c66affSColin Finck void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
2567c2c66affSColin Finck enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2568c2c66affSColin Finck void wined3d_gl_limits_get_uniform_block_range(const struct wined3d_gl_limits *gl_limits,
2569c2c66affSColin Finck enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2570c2c66affSColin Finck
2571c2c66affSColin Finck struct wined3d_gl_info
2572c2c66affSColin Finck {
2573c2c66affSColin Finck DWORD selected_gl_version;
2574c2c66affSColin Finck DWORD glsl_version;
2575c2c66affSColin Finck struct wined3d_gl_limits limits;
2576c2c66affSColin Finck DWORD reserved_glsl_constants, reserved_arb_constants;
2577c2c66affSColin Finck DWORD quirks;
2578c2c66affSColin Finck BOOL supported[WINED3D_GL_EXT_COUNT];
2579c2c66affSColin Finck GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP + 1];
2580c2c66affSColin Finck
2581c2c66affSColin Finck HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
2582c2c66affSColin Finck struct opengl_funcs gl_ops;
2583c2c66affSColin Finck struct wined3d_fbo_ops fbo_ops;
2584c2c66affSColin Finck
2585c2c66affSColin Finck struct wined3d_format *formats;
2586c2c66affSColin Finck unsigned int format_count;
2587c2c66affSColin Finck };
2588c2c66affSColin Finck
2589c2c66affSColin Finck struct wined3d_driver_info
2590c2c66affSColin Finck {
2591c2c66affSColin Finck enum wined3d_pci_vendor vendor;
2592c2c66affSColin Finck enum wined3d_pci_device device;
2593c2c66affSColin Finck const char *name;
2594c2c66affSColin Finck const char *description;
2595c2c66affSColin Finck UINT64 vram_bytes;
2596c2c66affSColin Finck DWORD version_high;
2597c2c66affSColin Finck DWORD version_low;
2598c2c66affSColin Finck };
2599c2c66affSColin Finck
2600c2c66affSColin Finck /* The adapter structure */
2601c2c66affSColin Finck struct wined3d_adapter
2602c2c66affSColin Finck {
2603c2c66affSColin Finck UINT ordinal;
2604c2c66affSColin Finck POINT monitor_position;
2605c2c66affSColin Finck enum wined3d_format_id screen_format;
2606c2c66affSColin Finck
2607c2c66affSColin Finck struct wined3d_gl_info gl_info;
2608c2c66affSColin Finck struct wined3d_d3d_info d3d_info;
2609c2c66affSColin Finck struct wined3d_driver_info driver_info;
2610c2c66affSColin Finck WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
2611c2c66affSColin Finck unsigned int cfg_count;
2612c2c66affSColin Finck struct wined3d_pixel_format *cfgs;
2613c2c66affSColin Finck UINT64 vram_bytes;
2614c2c66affSColin Finck UINT64 vram_bytes_used;
2615c2c66affSColin Finck LUID luid;
2616c2c66affSColin Finck
2617c2c66affSColin Finck const struct wined3d_vertex_pipe_ops *vertex_pipe;
2618c2c66affSColin Finck const struct fragment_pipeline *fragment_pipe;
2619c2c66affSColin Finck const struct wined3d_shader_backend_ops *shader_backend;
2620c2c66affSColin Finck };
2621c2c66affSColin Finck
2622c2c66affSColin Finck struct wined3d_caps_gl_ctx
2623c2c66affSColin Finck {
2624c2c66affSColin Finck HDC dc;
2625c2c66affSColin Finck HWND wnd;
2626c2c66affSColin Finck HGLRC gl_ctx;
2627c2c66affSColin Finck HDC restore_dc;
2628c2c66affSColin Finck HGLRC restore_gl_ctx;
2629c2c66affSColin Finck
2630c2c66affSColin Finck const struct wined3d_gl_info *gl_info;
2631c2c66affSColin Finck GLuint test_vbo;
2632c2c66affSColin Finck GLuint test_program_id;
2633c2c66affSColin Finck };
2634c2c66affSColin Finck
2635c2c66affSColin Finck BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter,
2636c2c66affSColin Finck struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
2637c2c66affSColin Finck UINT64 adapter_adjust_memory(struct wined3d_adapter *adapter, INT64 amount) DECLSPEC_HIDDEN;
2638c2c66affSColin Finck
2639c2c66affSColin Finck BOOL wined3d_caps_gl_ctx_test_viewport_subpixel_bits(struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
2640c2c66affSColin Finck
2641c2c66affSColin Finck void install_gl_compat_wrapper(struct wined3d_gl_info *gl_info, enum wined3d_gl_extension ext) DECLSPEC_HIDDEN;
2642c2c66affSColin Finck
2643*81cffd76SJoachim Henze enum projection_types
2644c2c66affSColin Finck {
2645*81cffd76SJoachim Henze proj_none = 0,
2646*81cffd76SJoachim Henze proj_count3 = 1,
2647*81cffd76SJoachim Henze proj_count4 = 2
2648*81cffd76SJoachim Henze };
2649*81cffd76SJoachim Henze
2650*81cffd76SJoachim Henze enum dst_arg
2651*81cffd76SJoachim Henze {
2652*81cffd76SJoachim Henze resultreg = 0,
2653*81cffd76SJoachim Henze tempreg = 1
2654c2c66affSColin Finck };
2655c2c66affSColin Finck
2656c2c66affSColin Finck /*****************************************************************************
2657c2c66affSColin Finck * Fixed function pipeline replacements
2658c2c66affSColin Finck */
2659c2c66affSColin Finck #define ARG_UNUSED 0xff
2660c2c66affSColin Finck struct texture_stage_op
2661c2c66affSColin Finck {
2662c2c66affSColin Finck unsigned cop : 8;
2663c2c66affSColin Finck unsigned carg1 : 8;
2664c2c66affSColin Finck unsigned carg2 : 8;
2665c2c66affSColin Finck unsigned carg0 : 8;
2666c2c66affSColin Finck
2667c2c66affSColin Finck unsigned aop : 8;
2668c2c66affSColin Finck unsigned aarg1 : 8;
2669c2c66affSColin Finck unsigned aarg2 : 8;
2670c2c66affSColin Finck unsigned aarg0 : 8;
2671c2c66affSColin Finck
2672c2c66affSColin Finck struct color_fixup_desc color_fixup;
2673c2c66affSColin Finck unsigned tex_type : 3;
2674*81cffd76SJoachim Henze unsigned dst : 1;
2675c2c66affSColin Finck unsigned projected : 2;
2676c2c66affSColin Finck unsigned padding : 10;
2677c2c66affSColin Finck };
2678c2c66affSColin Finck
2679c2c66affSColin Finck struct ffp_frag_settings
2680c2c66affSColin Finck {
2681c2c66affSColin Finck struct texture_stage_op op[MAX_TEXTURES];
2682c2c66affSColin Finck enum wined3d_ffp_ps_fog_mode fog;
2683c2c66affSColin Finck unsigned char sRGB_write;
2684c2c66affSColin Finck unsigned char emul_clipplanes;
2685c2c66affSColin Finck unsigned char texcoords_initialized;
2686c2c66affSColin Finck unsigned char color_key_enabled : 1;
2687c2c66affSColin Finck unsigned char pointsprite : 1;
2688c2c66affSColin Finck unsigned char flatshading : 1;
2689c2c66affSColin Finck unsigned char alpha_test_func : 3;
2690c2c66affSColin Finck unsigned char padding : 2;
2691c2c66affSColin Finck };
2692c2c66affSColin Finck
2693c2c66affSColin Finck struct ffp_frag_desc
2694c2c66affSColin Finck {
2695c2c66affSColin Finck struct wine_rb_entry entry;
2696c2c66affSColin Finck struct ffp_frag_settings settings;
2697c2c66affSColin Finck };
2698c2c66affSColin Finck
2699c2c66affSColin Finck int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
2700c2c66affSColin Finck int wined3d_ffp_vertex_program_key_compare(const void *key, const struct wine_rb_entry *entry) DECLSPEC_HIDDEN;
2701c2c66affSColin Finck
2702c2c66affSColin Finck extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
2703c2c66affSColin Finck
2704c2c66affSColin Finck unsigned int wined3d_max_compat_varyings(const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2705c2c66affSColin Finck void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
2706c2c66affSColin Finck struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
2707c2c66affSColin Finck const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
2708c2c66affSColin Finck const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
2709c2c66affSColin Finck void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
2710c2c66affSColin Finck void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
2711c2c66affSColin Finck
2712c2c66affSColin Finck extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN;
2713c2c66affSColin Finck extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
2714c2c66affSColin Finck
2715c2c66affSColin Finck enum wined3d_ffp_vs_fog_mode
2716c2c66affSColin Finck {
2717c2c66affSColin Finck WINED3D_FFP_VS_FOG_OFF = 0,
2718c2c66affSColin Finck WINED3D_FFP_VS_FOG_FOGCOORD = 1,
2719c2c66affSColin Finck WINED3D_FFP_VS_FOG_DEPTH = 2,
2720c2c66affSColin Finck WINED3D_FFP_VS_FOG_RANGE = 3,
2721c2c66affSColin Finck };
2722c2c66affSColin Finck
2723c2c66affSColin Finck #define WINED3D_FFP_TCI_SHIFT 16
2724c2c66affSColin Finck #define WINED3D_FFP_TCI_MASK 0xffu
2725c2c66affSColin Finck
2726c2c66affSColin Finck #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
2727c2c66affSColin Finck #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
2728c2c66affSColin Finck
2729c2c66affSColin Finck struct wined3d_ffp_vs_settings
2730c2c66affSColin Finck {
2731c2c66affSColin Finck DWORD point_light_count : 4;
2732c2c66affSColin Finck DWORD spot_light_count : 4;
2733c2c66affSColin Finck DWORD directional_light_count : 4;
2734c2c66affSColin Finck DWORD parallel_point_light_count : 4;
2735c2c66affSColin Finck DWORD diffuse_source : 2;
2736c2c66affSColin Finck DWORD emissive_source : 2;
2737c2c66affSColin Finck DWORD ambient_source : 2;
2738c2c66affSColin Finck DWORD specular_source : 2;
2739c2c66affSColin Finck DWORD transformed : 1;
2740c2c66affSColin Finck DWORD vertexblends : 2;
2741c2c66affSColin Finck DWORD clipping : 1;
2742c2c66affSColin Finck DWORD normal : 1;
2743c2c66affSColin Finck DWORD normalize : 1;
2744c2c66affSColin Finck DWORD lighting : 1;
2745c2c66affSColin Finck DWORD localviewer : 1;
2746c2c66affSColin Finck
2747c2c66affSColin Finck DWORD point_size : 1;
2748c2c66affSColin Finck DWORD per_vertex_point_size : 1;
2749c2c66affSColin Finck DWORD fog_mode : 2;
2750c2c66affSColin Finck DWORD texcoords : 8; /* MAX_TEXTURES */
2751c2c66affSColin Finck DWORD ortho_fog : 1;
2752c2c66affSColin Finck DWORD flatshading : 1;
2753c2c66affSColin Finck DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
27549987f029SAmine Khaldi DWORD vb_indices : 1;
27559987f029SAmine Khaldi DWORD sw_blending : 1;
2756c2c66affSColin Finck
2757c2c66affSColin Finck DWORD texgen[MAX_TEXTURES];
2758c2c66affSColin Finck };
2759c2c66affSColin Finck
2760c2c66affSColin Finck struct wined3d_ffp_vs_desc
2761c2c66affSColin Finck {
2762c2c66affSColin Finck struct wine_rb_entry entry;
2763c2c66affSColin Finck struct wined3d_ffp_vs_settings settings;
2764c2c66affSColin Finck };
2765c2c66affSColin Finck
2766c2c66affSColin Finck void wined3d_ffp_get_vs_settings(const struct wined3d_context *context,
2767c2c66affSColin Finck const struct wined3d_state *state, struct wined3d_ffp_vs_settings *settings) DECLSPEC_HIDDEN;
2768c2c66affSColin Finck
2769c2c66affSColin Finck struct wined3d
2770c2c66affSColin Finck {
2771c2c66affSColin Finck LONG ref;
2772c2c66affSColin Finck DWORD flags;
2773c2c66affSColin Finck UINT adapter_count;
2774c2c66affSColin Finck struct wined3d_adapter adapters[1];
2775c2c66affSColin Finck };
2776c2c66affSColin Finck
2777c2c66affSColin Finck HRESULT wined3d_init(struct wined3d *wined3d, DWORD flags) DECLSPEC_HIDDEN;
2778c2c66affSColin Finck BOOL wined3d_register_window(HWND window, struct wined3d_device *device) DECLSPEC_HIDDEN;
2779c2c66affSColin Finck void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
2780c2c66affSColin Finck
27819987f029SAmine Khaldi struct wined3d_blend_state
27829987f029SAmine Khaldi {
27839987f029SAmine Khaldi LONG refcount;
27849987f029SAmine Khaldi struct wined3d_blend_state_desc desc;
27859987f029SAmine Khaldi
27869987f029SAmine Khaldi void *parent;
27879987f029SAmine Khaldi const struct wined3d_parent_ops *parent_ops;
27889987f029SAmine Khaldi
27899987f029SAmine Khaldi struct wined3d_device *device;
27909987f029SAmine Khaldi };
27919987f029SAmine Khaldi
2792c2c66affSColin Finck struct wined3d_rasterizer_state
2793c2c66affSColin Finck {
2794c2c66affSColin Finck LONG refcount;
2795c2c66affSColin Finck struct wined3d_rasterizer_state_desc desc;
2796c2c66affSColin Finck
2797c2c66affSColin Finck void *parent;
2798c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
2799c2c66affSColin Finck
2800c2c66affSColin Finck struct wined3d_device *device;
2801c2c66affSColin Finck };
2802c2c66affSColin Finck
2803c2c66affSColin Finck struct wined3d_stream_output
2804c2c66affSColin Finck {
2805c2c66affSColin Finck struct wined3d_buffer *buffer;
2806c2c66affSColin Finck UINT offset;
2807c2c66affSColin Finck };
2808c2c66affSColin Finck
2809c2c66affSColin Finck struct wined3d_stream_state
2810c2c66affSColin Finck {
2811c2c66affSColin Finck struct wined3d_buffer *buffer;
2812c2c66affSColin Finck UINT offset;
2813c2c66affSColin Finck UINT stride;
2814c2c66affSColin Finck UINT frequency;
2815c2c66affSColin Finck UINT flags;
2816c2c66affSColin Finck };
2817c2c66affSColin Finck
2818c2c66affSColin Finck #define WINED3D_STATE_NO_REF 0x00000001
2819c2c66affSColin Finck #define WINED3D_STATE_INIT_DEFAULT 0x00000002
2820c2c66affSColin Finck
2821c2c66affSColin Finck struct wined3d_state
2822c2c66affSColin Finck {
2823c2c66affSColin Finck DWORD flags;
2824c2c66affSColin Finck const struct wined3d_fb_state *fb;
2825c2c66affSColin Finck
2826c2c66affSColin Finck struct wined3d_vertex_declaration *vertex_declaration;
2827c2c66affSColin Finck struct wined3d_stream_output stream_output[WINED3D_MAX_STREAM_OUTPUT_BUFFERS];
2828c2c66affSColin Finck struct wined3d_stream_state streams[MAX_STREAMS + 1 /* tesselated pseudo-stream */];
2829c2c66affSColin Finck struct wined3d_buffer *index_buffer;
2830c2c66affSColin Finck enum wined3d_format_id index_format;
2831c2c66affSColin Finck unsigned int index_offset;
2832c2c66affSColin Finck int base_vertex_index;
2833c2c66affSColin Finck int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
2834c2c66affSColin Finck GLenum gl_primitive_type;
2835c2c66affSColin Finck GLint gl_patch_vertices;
2836c2c66affSColin Finck struct wined3d_query *predicate;
2837c2c66affSColin Finck BOOL predicate_value;
2838c2c66affSColin Finck
2839c2c66affSColin Finck struct wined3d_shader *shader[WINED3D_SHADER_TYPE_COUNT];
2840c2c66affSColin Finck struct wined3d_buffer *cb[WINED3D_SHADER_TYPE_COUNT][MAX_CONSTANT_BUFFERS];
2841c2c66affSColin Finck struct wined3d_sampler *sampler[WINED3D_SHADER_TYPE_COUNT][MAX_SAMPLER_OBJECTS];
2842c2c66affSColin Finck struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS];
2843c2c66affSColin Finck struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
2844c2c66affSColin Finck
2845c2c66affSColin Finck BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
2846c2c66affSColin Finck struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I];
2847c2c66affSColin Finck struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
2848c2c66affSColin Finck
2849c2c66affSColin Finck BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
2850c2c66affSColin Finck struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I];
2851c2c66affSColin Finck struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
2852c2c66affSColin Finck
2853c2c66affSColin Finck struct wined3d_texture *textures[MAX_COMBINED_SAMPLERS];
2854c2c66affSColin Finck DWORD sampler_states[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
2855c2c66affSColin Finck DWORD texture_states[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
2856c2c66affSColin Finck
2857c2c66affSColin Finck struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
2858c2c66affSColin Finck struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES];
2859c2c66affSColin Finck struct wined3d_material material;
2860*81cffd76SJoachim Henze struct wined3d_viewport viewport;
2861*81cffd76SJoachim Henze RECT scissor_rect;
2862c2c66affSColin Finck
2863c2c66affSColin Finck /* Light hashmap. Collisions are handled using linked lists. */
2864c2c66affSColin Finck #define LIGHTMAP_SIZE 43
2865c2c66affSColin Finck #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
2866c2c66affSColin Finck struct list light_map[LIGHTMAP_SIZE];
2867c2c66affSColin Finck const struct wined3d_light_info *lights[MAX_ACTIVE_LIGHTS];
2868c2c66affSColin Finck
2869c2c66affSColin Finck DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
28709987f029SAmine Khaldi struct wined3d_blend_state *blend_state;
2871c2c66affSColin Finck struct wined3d_rasterizer_state *rasterizer_state;
2872c2c66affSColin Finck };
2873c2c66affSColin Finck
wined3d_dualblend_enabled(const struct wined3d_state * state,const struct wined3d_gl_info * gl_info)28749987f029SAmine Khaldi static inline BOOL wined3d_dualblend_enabled(const struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
28759987f029SAmine Khaldi {
28769987f029SAmine Khaldi if (!state->fb->render_targets[0]) return FALSE;
28779987f029SAmine Khaldi if (!state->render_states[WINED3D_RS_ALPHABLENDENABLE]) return FALSE;
28789987f029SAmine Khaldi if (!gl_info->supported[ARB_BLEND_FUNC_EXTENDED]) return FALSE;
28799987f029SAmine Khaldi
28809987f029SAmine Khaldi #define IS_DUAL_SOURCE_BLEND(x) ((x) >= WINED3D_BLEND_SRC1COLOR && (x) <= WINED3D_BLEND_INVSRC1ALPHA)
28819987f029SAmine Khaldi if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_SRCBLEND])) return TRUE;
28829987f029SAmine Khaldi if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_DESTBLEND])) return TRUE;
28839987f029SAmine Khaldi if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_SRCBLENDALPHA])) return TRUE;
28849987f029SAmine Khaldi if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_DESTBLENDALPHA])) return TRUE;
28859987f029SAmine Khaldi #undef IS_DUAL_SOURCE_BLEND
28869987f029SAmine Khaldi
28879987f029SAmine Khaldi return FALSE;
28889987f029SAmine Khaldi }
28899987f029SAmine Khaldi
28909987f029SAmine Khaldi struct wined3d_dummy_textures
28919987f029SAmine Khaldi {
28927af3969eSAmine Khaldi GLuint tex_2d;
2893*81cffd76SJoachim Henze GLuint tex_1d;
28949987f029SAmine Khaldi GLuint tex_rect;
28959987f029SAmine Khaldi GLuint tex_3d;
28969987f029SAmine Khaldi GLuint tex_cube;
28979987f029SAmine Khaldi GLuint tex_cube_array;
28987af3969eSAmine Khaldi GLuint tex_2d_array;
2899*81cffd76SJoachim Henze GLuint tex_1d_array;
29009987f029SAmine Khaldi GLuint tex_buffer;
29019987f029SAmine Khaldi GLuint tex_2d_ms;
29029987f029SAmine Khaldi GLuint tex_2d_ms_array;
29039987f029SAmine Khaldi };
29049987f029SAmine Khaldi
2905*81cffd76SJoachim Henze #if defined(STAGING_CSMT)
2906*81cffd76SJoachim Henze struct wined3d_gl_bo
2907*81cffd76SJoachim Henze {
2908*81cffd76SJoachim Henze GLuint name;
2909*81cffd76SJoachim Henze GLenum usage;
2910*81cffd76SJoachim Henze GLenum type_hint;
2911*81cffd76SJoachim Henze UINT size;
2912*81cffd76SJoachim Henze };
2913*81cffd76SJoachim Henze
2914*81cffd76SJoachim Henze #endif /* STAGING_CSMT */
2915c2c66affSColin Finck #define WINED3D_UNMAPPED_STAGE ~0u
2916c2c66affSColin Finck
2917c2c66affSColin Finck /* Multithreaded flag. Removed from the public header to signal that
2918c2c66affSColin Finck * wined3d_device_create() ignores it. */
2919c2c66affSColin Finck #define WINED3DCREATE_MULTITHREADED 0x00000004
2920c2c66affSColin Finck
2921c2c66affSColin Finck struct wined3d_device
2922c2c66affSColin Finck {
2923c2c66affSColin Finck LONG ref;
2924c2c66affSColin Finck
2925c2c66affSColin Finck /* WineD3D Information */
2926c2c66affSColin Finck struct wined3d_device_parent *device_parent;
2927c2c66affSColin Finck struct wined3d *wined3d;
2928c2c66affSColin Finck struct wined3d_adapter *adapter;
2929c2c66affSColin Finck
2930c2c66affSColin Finck /* Window styles to restore when switching fullscreen mode */
2931c2c66affSColin Finck LONG style;
2932c2c66affSColin Finck LONG exStyle;
2933c2c66affSColin Finck
2934c2c66affSColin Finck const struct wined3d_shader_backend_ops *shader_backend;
2935c2c66affSColin Finck void *shader_priv;
2936c2c66affSColin Finck void *fragment_priv;
2937c2c66affSColin Finck void *vertex_priv;
2938c2c66affSColin Finck struct StateEntry StateTable[STATE_HIGHEST + 1];
2939c2c66affSColin Finck /* Array of functions for states which are handled by more than one pipeline part */
2940c2c66affSColin Finck APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
2941c2c66affSColin Finck struct wined3d_blitter *blitter;
2942c2c66affSColin Finck
2943*81cffd76SJoachim Henze BYTE vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */
2944c2c66affSColin Finck BYTE bCursorVisible : 1;
2945c2c66affSColin Finck BYTE d3d_initialized : 1;
2946c2c66affSColin Finck BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
2947c2c66affSColin Finck BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
2948c2c66affSColin Finck BYTE filter_messages : 1;
2949*81cffd76SJoachim Henze BYTE padding : 2;
2950c2c66affSColin Finck
2951c2c66affSColin Finck unsigned char surface_alignment; /* Line Alignment of surfaces */
2952c2c66affSColin Finck
2953c2c66affSColin Finck WORD padding2 : 16;
2954c2c66affSColin Finck
2955c2c66affSColin Finck struct wined3d_state state;
2956c2c66affSColin Finck struct wined3d_state *update_state;
2957c2c66affSColin Finck struct wined3d_stateblock *recording;
2958c2c66affSColin Finck
2959c2c66affSColin Finck /* Internal use fields */
2960c2c66affSColin Finck struct wined3d_device_creation_parameters create_parms;
2961c2c66affSColin Finck HWND focus_window;
2962c2c66affSColin Finck
2963c2c66affSColin Finck struct wined3d_rendertarget_view *back_buffer_view;
2964c2c66affSColin Finck struct wined3d_swapchain **swapchains;
2965c2c66affSColin Finck UINT swapchain_count;
2966c2c66affSColin Finck
2967c2c66affSColin Finck struct list resources; /* a linked list to track resources created by the device */
2968c2c66affSColin Finck struct list shaders; /* a linked list to track shaders (pixel and vertex) */
2969c2c66affSColin Finck struct wine_rb_tree samplers;
2970c2c66affSColin Finck
2971c2c66affSColin Finck /* Render Target Support */
2972c2c66affSColin Finck struct wined3d_fb_state fb;
2973c2c66affSColin Finck struct wined3d_rendertarget_view *auto_depth_stencil_view;
2974c2c66affSColin Finck
2975c2c66affSColin Finck /* Cursor management */
2976c2c66affSColin Finck UINT xHotSpot;
2977c2c66affSColin Finck UINT yHotSpot;
2978c2c66affSColin Finck UINT xScreenSpace;
2979c2c66affSColin Finck UINT yScreenSpace;
2980c2c66affSColin Finck UINT cursorWidth, cursorHeight;
2981c2c66affSColin Finck struct wined3d_texture *cursor_texture;
2982c2c66affSColin Finck HCURSOR hardwareCursor;
2983c2c66affSColin Finck
2984c2c66affSColin Finck /* The Wine logo texture */
2985c2c66affSColin Finck struct wined3d_texture *logo_texture;
2986c2c66affSColin Finck
2987c2c66affSColin Finck /* Textures for when no other textures are mapped */
29889987f029SAmine Khaldi struct wined3d_dummy_textures dummy_textures;
2989c2c66affSColin Finck
2990c2c66affSColin Finck /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
2991c2c66affSColin Finck struct wined3d_sampler *default_sampler;
2992c2c66affSColin Finck struct wined3d_sampler *null_sampler;
2993c2c66affSColin Finck
2994c2c66affSColin Finck /* Command stream */
2995c2c66affSColin Finck struct wined3d_cs *cs;
2996c2c66affSColin Finck
2997c2c66affSColin Finck /* Context management */
2998c2c66affSColin Finck struct wined3d_context **contexts;
2999c2c66affSColin Finck UINT context_count;
3000c2c66affSColin Finck };
3001c2c66affSColin Finck
3002c2c66affSColin Finck void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb,
3003c2c66affSColin Finck UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags,
3004c2c66affSColin Finck const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
3005c2c66affSColin Finck BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3006c2c66affSColin Finck void device_context_remove(struct wined3d_device *device, struct wined3d_context *context) DECLSPEC_HIDDEN;
3007c2c66affSColin Finck HRESULT device_init(struct wined3d_device *device, struct wined3d *wined3d,
3008c2c66affSColin Finck UINT adapter_idx, enum wined3d_device_type device_type, HWND focus_window, DWORD flags,
3009c2c66affSColin Finck BYTE surface_alignment, struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3010c2c66affSColin Finck LRESULT device_process_message(struct wined3d_device *device, HWND window, BOOL unicode,
3011c2c66affSColin Finck UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
3012c2c66affSColin Finck void device_resource_add(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3013c2c66affSColin Finck void device_resource_released(struct wined3d_device *device, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3014c2c66affSColin Finck void device_invalidate_state(const struct wined3d_device *device, DWORD state) DECLSPEC_HIDDEN;
3015*81cffd76SJoachim Henze #if defined(STAGING_CSMT)
3016*81cffd76SJoachim Henze struct wined3d_gl_bo *wined3d_device_get_bo(struct wined3d_device *device, UINT size, GLenum gl_usage,
3017*81cffd76SJoachim Henze GLenum type_hint, struct wined3d_context *context) DECLSPEC_HIDDEN;
3018*81cffd76SJoachim Henze void wined3d_device_release_bo(struct wined3d_device *device, struct wined3d_gl_bo *bo,
3019*81cffd76SJoachim Henze const struct wined3d_context *context) DECLSPEC_HIDDEN;
3020*81cffd76SJoachim Henze #endif /* STAGING_CSMT */
3021c2c66affSColin Finck
isStateDirty(const struct wined3d_context * context,DWORD state)3022c2c66affSColin Finck static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
3023c2c66affSColin Finck {
3024c2c66affSColin Finck DWORD idx = state / (sizeof(*context->isStateDirty) * CHAR_BIT);
3025c2c66affSColin Finck BYTE shift = state & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
3026c2c66affSColin Finck return context->isStateDirty[idx] & (1u << shift);
3027c2c66affSColin Finck }
3028c2c66affSColin Finck
30299987f029SAmine Khaldi const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN;
30309987f029SAmine Khaldi
wined3d_resource_access_is_managed(unsigned int access)30319987f029SAmine Khaldi static inline BOOL wined3d_resource_access_is_managed(unsigned int access)
30329987f029SAmine Khaldi {
30339987f029SAmine Khaldi return !(~access & (WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_CPU));
30349987f029SAmine Khaldi }
3035c2c66affSColin Finck
3036c2c66affSColin Finck struct wined3d_resource_ops
3037c2c66affSColin Finck {
3038c2c66affSColin Finck ULONG (*resource_incref)(struct wined3d_resource *resource);
3039c2c66affSColin Finck ULONG (*resource_decref)(struct wined3d_resource *resource);
3040c2c66affSColin Finck void (*resource_preload)(struct wined3d_resource *resource);
3041c2c66affSColin Finck void (*resource_unload)(struct wined3d_resource *resource);
3042c2c66affSColin Finck HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
3043c2c66affSColin Finck struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
30449987f029SAmine Khaldi HRESULT (*resource_map_info)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
30459987f029SAmine Khaldi struct wined3d_map_info *info, DWORD flags);
3046c2c66affSColin Finck HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
3047c2c66affSColin Finck };
3048c2c66affSColin Finck
3049c2c66affSColin Finck struct wined3d_resource
3050c2c66affSColin Finck {
3051c2c66affSColin Finck LONG ref;
3052c2c66affSColin Finck LONG bind_count;
3053c2c66affSColin Finck LONG map_count;
3054c2c66affSColin Finck LONG access_count;
3055c2c66affSColin Finck struct wined3d_device *device;
3056c2c66affSColin Finck enum wined3d_resource_type type;
3057c2c66affSColin Finck enum wined3d_gl_resource_type gl_type;
3058c2c66affSColin Finck const struct wined3d_format *format;
3059c2c66affSColin Finck unsigned int format_flags;
3060c2c66affSColin Finck enum wined3d_multisample_type multisample_type;
3061c2c66affSColin Finck UINT multisample_quality;
3062c2c66affSColin Finck DWORD usage;
30639987f029SAmine Khaldi unsigned int access;
3064c2c66affSColin Finck WORD draw_binding;
3065c2c66affSColin Finck WORD map_binding;
3066c2c66affSColin Finck UINT width;
3067c2c66affSColin Finck UINT height;
3068c2c66affSColin Finck UINT depth;
3069c2c66affSColin Finck UINT size;
3070c2c66affSColin Finck DWORD priority;
3071c2c66affSColin Finck void *heap_memory;
3072c2c66affSColin Finck
3073c2c66affSColin Finck void *parent;
3074c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3075c2c66affSColin Finck const struct wined3d_resource_ops *resource_ops;
3076c2c66affSColin Finck
3077c2c66affSColin Finck struct list resource_list_entry;
3078c2c66affSColin Finck };
3079c2c66affSColin Finck
wined3d_resource_incref(struct wined3d_resource * resource)3080c2c66affSColin Finck static inline ULONG wined3d_resource_incref(struct wined3d_resource *resource)
3081c2c66affSColin Finck {
3082c2c66affSColin Finck return resource->resource_ops->resource_incref(resource);
3083c2c66affSColin Finck }
3084c2c66affSColin Finck
wined3d_resource_decref(struct wined3d_resource * resource)3085c2c66affSColin Finck static inline ULONG wined3d_resource_decref(struct wined3d_resource *resource)
3086c2c66affSColin Finck {
3087c2c66affSColin Finck return resource->resource_ops->resource_decref(resource);
3088c2c66affSColin Finck }
3089c2c66affSColin Finck
wined3d_resource_acquire(struct wined3d_resource * resource)3090c2c66affSColin Finck static inline void wined3d_resource_acquire(struct wined3d_resource *resource)
3091c2c66affSColin Finck {
3092c2c66affSColin Finck InterlockedIncrement(&resource->access_count);
3093c2c66affSColin Finck }
3094c2c66affSColin Finck
wined3d_resource_release(struct wined3d_resource * resource)3095c2c66affSColin Finck static inline void wined3d_resource_release(struct wined3d_resource *resource)
3096c2c66affSColin Finck {
3097c2c66affSColin Finck InterlockedDecrement(&resource->access_count);
3098c2c66affSColin Finck }
3099c2c66affSColin Finck
3100c2c66affSColin Finck void resource_cleanup(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3101c2c66affSColin Finck HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *device,
3102c2c66affSColin Finck enum wined3d_resource_type type, const struct wined3d_format *format,
31039987f029SAmine Khaldi enum wined3d_multisample_type multisample_type, unsigned int multisample_quality,
31049987f029SAmine Khaldi unsigned int usage, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
31059987f029SAmine Khaldi unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
3106c2c66affSColin Finck const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
3107c2c66affSColin Finck void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3108c2c66affSColin Finck BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3109c2c66affSColin Finck void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3110c2c66affSColin Finck GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3111c2c66affSColin Finck GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
3112c2c66affSColin Finck BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3113c2c66affSColin Finck void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3114c2c66affSColin Finck
3115c2c66affSColin Finck /* Tests show that the start address of resources is 32 byte aligned */
3116c2c66affSColin Finck #define RESOURCE_ALIGNMENT 16
3117c2c66affSColin Finck #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3118c2c66affSColin Finck
3119c2c66affSColin Finck struct gl_texture
3120c2c66affSColin Finck {
3121c2c66affSColin Finck struct wined3d_sampler_desc sampler_desc;
3122c2c66affSColin Finck unsigned int base_level;
3123c2c66affSColin Finck GLuint name;
3124c2c66affSColin Finck };
3125c2c66affSColin Finck
3126c2c66affSColin Finck struct wined3d_texture_ops
3127c2c66affSColin Finck {
3128*81cffd76SJoachim Henze void (*texture_upload_data)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3129*81cffd76SJoachim Henze const struct wined3d_context *context, const struct wined3d_box *box,
3130*81cffd76SJoachim Henze const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch);
3131c2c66affSColin Finck BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3132c2c66affSColin Finck struct wined3d_context *context, DWORD location);
3133*81cffd76SJoachim Henze void (*texture_prepare_texture)(struct wined3d_texture *texture,
3134*81cffd76SJoachim Henze struct wined3d_context *context, BOOL srgb);
3135*81cffd76SJoachim Henze void (*texture_cleanup_sub_resources)(struct wined3d_texture *texture);
3136c2c66affSColin Finck };
3137c2c66affSColin Finck
3138c2c66affSColin Finck #define WINED3D_TEXTURE_COND_NP2 0x00000001
3139c2c66affSColin Finck #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3140c2c66affSColin Finck #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3141c2c66affSColin Finck #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3142c2c66affSColin Finck #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3143c2c66affSColin Finck #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3144c2c66affSColin Finck #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3145c2c66affSColin Finck #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3146c2c66affSColin Finck #define WINED3D_TEXTURE_CONVERTED 0x00000100
3147c2c66affSColin Finck #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
3148c2c66affSColin Finck #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3149c2c66affSColin Finck #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3150c2c66affSColin Finck #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3151c2c66affSColin Finck #define WINED3D_TEXTURE_DISCARD 0x00002000
3152c2c66affSColin Finck #define WINED3D_TEXTURE_GET_DC 0x00004000
3153d6ac0a71SAmine Khaldi #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3154c2c66affSColin Finck
3155c2c66affSColin Finck #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3156c2c66affSColin Finck
3157c2c66affSColin Finck struct wined3d_texture
3158c2c66affSColin Finck {
3159c2c66affSColin Finck struct wined3d_resource resource;
3160c2c66affSColin Finck const struct wined3d_texture_ops *texture_ops;
3161c2c66affSColin Finck struct gl_texture texture_rgb, texture_srgb;
3162c2c66affSColin Finck struct wined3d_swapchain *swapchain;
3163c2c66affSColin Finck unsigned int pow2_width;
3164c2c66affSColin Finck unsigned int pow2_height;
3165c2c66affSColin Finck UINT layer_count;
3166c2c66affSColin Finck UINT level_count;
3167c2c66affSColin Finck unsigned int download_count;
3168c2c66affSColin Finck unsigned int sysmem_count;
3169c2c66affSColin Finck float pow2_matrix[16];
3170c2c66affSColin Finck UINT lod;
3171c2c66affSColin Finck DWORD sampler;
3172c2c66affSColin Finck DWORD flags;
3173c2c66affSColin Finck GLenum target;
3174c2c66affSColin Finck DWORD update_map_binding;
3175c2c66affSColin Finck
3176c2c66affSColin Finck GLuint rb_multisample;
3177c2c66affSColin Finck GLuint rb_resolved;
3178c2c66affSColin Finck
3179c2c66affSColin Finck void *user_memory;
3180c2c66affSColin Finck unsigned int row_pitch;
3181c2c66affSColin Finck unsigned int slice_pitch;
3182c2c66affSColin Finck
3183c2c66affSColin Finck /* May only be accessed from the command stream worker thread. */
3184c2c66affSColin Finck struct wined3d_texture_async
3185c2c66affSColin Finck {
3186c2c66affSColin Finck DWORD flags;
3187c2c66affSColin Finck
3188c2c66affSColin Finck /* Color keys for DDraw */
3189c2c66affSColin Finck struct wined3d_color_key dst_blt_color_key;
3190c2c66affSColin Finck struct wined3d_color_key src_blt_color_key;
3191c2c66affSColin Finck struct wined3d_color_key dst_overlay_color_key;
3192c2c66affSColin Finck struct wined3d_color_key src_overlay_color_key;
3193c2c66affSColin Finck struct wined3d_color_key gl_color_key;
3194c2c66affSColin Finck DWORD color_key_flags;
3195c2c66affSColin Finck } async;
3196c2c66affSColin Finck
31979987f029SAmine Khaldi struct wined3d_overlay_info
31989987f029SAmine Khaldi {
31999987f029SAmine Khaldi struct list entry;
32009987f029SAmine Khaldi struct list overlays;
3201*81cffd76SJoachim Henze struct wined3d_surface *dst;
32029987f029SAmine Khaldi RECT src_rect;
32039987f029SAmine Khaldi RECT dst_rect;
32049987f029SAmine Khaldi } *overlay_info;
32059987f029SAmine Khaldi
3206c2c66affSColin Finck struct wined3d_texture_sub_resource
3207c2c66affSColin Finck {
3208c2c66affSColin Finck void *parent;
3209c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3210c2c66affSColin Finck
3211*81cffd76SJoachim Henze union
3212*81cffd76SJoachim Henze {
3213*81cffd76SJoachim Henze struct wined3d_surface *surface;
3214*81cffd76SJoachim Henze } u;
3215c2c66affSColin Finck unsigned int offset;
3216c2c66affSColin Finck unsigned int size;
3217c2c66affSColin Finck
3218c2c66affSColin Finck unsigned int map_count;
3219c2c66affSColin Finck DWORD locations;
3220*81cffd76SJoachim Henze #if !defined(STAGING_CSMT)
3221c2c66affSColin Finck GLuint buffer_object;
3222*81cffd76SJoachim Henze #else /* STAGING_CSMT */
3223*81cffd76SJoachim Henze struct wined3d_gl_bo *buffer;
3224*81cffd76SJoachim Henze #endif /* STAGING_CSMT */
3225c2c66affSColin Finck } sub_resources[1];
3226c2c66affSColin Finck };
3227c2c66affSColin Finck
texture_from_resource(struct wined3d_resource * resource)3228c2c66affSColin Finck static inline struct wined3d_texture *texture_from_resource(struct wined3d_resource *resource)
3229c2c66affSColin Finck {
3230c2c66affSColin Finck return CONTAINING_RECORD(resource, struct wined3d_texture, resource);
3231c2c66affSColin Finck }
3232c2c66affSColin Finck
wined3d_texture_get_sub_resource_target(const struct wined3d_texture * texture,unsigned int sub_resource_idx)32339987f029SAmine Khaldi static inline GLenum wined3d_texture_get_sub_resource_target(const struct wined3d_texture *texture,
32349987f029SAmine Khaldi unsigned int sub_resource_idx)
32359987f029SAmine Khaldi {
32369987f029SAmine Khaldi static const GLenum cube_targets[] =
32379987f029SAmine Khaldi {
32389987f029SAmine Khaldi GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
32399987f029SAmine Khaldi GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
32409987f029SAmine Khaldi GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
32419987f029SAmine Khaldi GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
32429987f029SAmine Khaldi GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
32439987f029SAmine Khaldi GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
32449987f029SAmine Khaldi };
32459987f029SAmine Khaldi
32469987f029SAmine Khaldi return texture->resource.usage & WINED3DUSAGE_LEGACY_CUBEMAP
32479987f029SAmine Khaldi ? cube_targets[sub_resource_idx / texture->level_count] : texture->target;
32489987f029SAmine Khaldi }
32499987f029SAmine Khaldi
wined3d_texture_get_gl_texture(struct wined3d_texture * texture,BOOL srgb)3250c2c66affSColin Finck static inline struct gl_texture *wined3d_texture_get_gl_texture(struct wined3d_texture *texture,
3251c2c66affSColin Finck BOOL srgb)
3252c2c66affSColin Finck {
3253c2c66affSColin Finck return srgb ? &texture->texture_srgb : &texture->texture_rgb;
3254c2c66affSColin Finck }
3255c2c66affSColin Finck
wined3d_texture_get_level_width(const struct wined3d_texture * texture,unsigned int level)3256c2c66affSColin Finck static inline unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture,
3257c2c66affSColin Finck unsigned int level)
3258c2c66affSColin Finck {
3259c2c66affSColin Finck return max(1, texture->resource.width >> level);
3260c2c66affSColin Finck }
3261c2c66affSColin Finck
wined3d_texture_get_level_height(const struct wined3d_texture * texture,unsigned int level)3262c2c66affSColin Finck static inline unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture,
3263c2c66affSColin Finck unsigned int level)
3264c2c66affSColin Finck {
3265c2c66affSColin Finck return max(1, texture->resource.height >> level);
3266c2c66affSColin Finck }
3267c2c66affSColin Finck
wined3d_texture_get_level_depth(const struct wined3d_texture * texture,unsigned int level)3268c2c66affSColin Finck static inline unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture,
3269c2c66affSColin Finck unsigned int level)
3270c2c66affSColin Finck {
3271c2c66affSColin Finck return max(1, texture->resource.depth >> level);
3272c2c66affSColin Finck }
3273c2c66affSColin Finck
wined3d_texture_get_level_pow2_width(const struct wined3d_texture * texture,unsigned int level)3274c2c66affSColin Finck static inline unsigned int wined3d_texture_get_level_pow2_width(const struct wined3d_texture *texture,
3275c2c66affSColin Finck unsigned int level)
3276c2c66affSColin Finck {
3277c2c66affSColin Finck return max(1, texture->pow2_width >> level);
3278c2c66affSColin Finck }
3279c2c66affSColin Finck
wined3d_texture_get_level_pow2_height(const struct wined3d_texture * texture,unsigned int level)3280c2c66affSColin Finck static inline unsigned int wined3d_texture_get_level_pow2_height(const struct wined3d_texture *texture,
3281c2c66affSColin Finck unsigned int level)
3282c2c66affSColin Finck {
3283c2c66affSColin Finck return max(1, texture->pow2_height >> level);
3284c2c66affSColin Finck }
3285c2c66affSColin Finck
3286c2c66affSColin Finck void wined3d_texture_apply_sampler_desc(struct wined3d_texture *texture,
3287c2c66affSColin Finck const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context *context) DECLSPEC_HIDDEN;
3288c2c66affSColin Finck void wined3d_texture_bind(struct wined3d_texture *texture,
3289c2c66affSColin Finck struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
3290c2c66affSColin Finck void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
3291c2c66affSColin Finck struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
3292c2c66affSColin Finck HRESULT wined3d_texture_check_box_dimensions(const struct wined3d_texture *texture,
3293c2c66affSColin Finck unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
3294c2c66affSColin Finck GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3295c2c66affSColin Finck void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3296c2c66affSColin Finck struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
3297c2c66affSColin Finck void wined3d_texture_invalidate_location(struct wined3d_texture *texture,
3298c2c66affSColin Finck unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
3299c2c66affSColin Finck void wined3d_texture_load(struct wined3d_texture *texture,
3300c2c66affSColin Finck struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
3301c2c66affSColin Finck BOOL wined3d_texture_load_location(struct wined3d_texture *texture,
3302c2c66affSColin Finck unsigned int sub_resource_idx, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3303c2c66affSColin Finck BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3304c2c66affSColin Finck struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3305c2c66affSColin Finck void wined3d_texture_prepare_texture(struct wined3d_texture *texture,
3306c2c66affSColin Finck struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
3307c2c66affSColin Finck void wined3d_texture_set_map_binding(struct wined3d_texture *texture, DWORD map_binding) DECLSPEC_HIDDEN;
3308c2c66affSColin Finck void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
3309c2c66affSColin Finck struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3310c2c66affSColin Finck void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3311*81cffd76SJoachim Henze const struct wined3d_context *context, const struct wined3d_box *box,
3312*81cffd76SJoachim Henze const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN;
3313c2c66affSColin Finck void wined3d_texture_validate_location(struct wined3d_texture *texture,
3314c2c66affSColin Finck unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
3315c2c66affSColin Finck
3316c2c66affSColin Finck #define WINED3D_LOCATION_DISCARDED 0x00000001
3317c2c66affSColin Finck #define WINED3D_LOCATION_SYSMEM 0x00000002
3318c2c66affSColin Finck #define WINED3D_LOCATION_USER_MEMORY 0x00000004
3319c2c66affSColin Finck #define WINED3D_LOCATION_BUFFER 0x00000008
3320c2c66affSColin Finck #define WINED3D_LOCATION_TEXTURE_RGB 0x00000010
3321c2c66affSColin Finck #define WINED3D_LOCATION_TEXTURE_SRGB 0x00000020
3322c2c66affSColin Finck #define WINED3D_LOCATION_DRAWABLE 0x00000040
3323c2c66affSColin Finck #define WINED3D_LOCATION_RB_MULTISAMPLE 0x00000080
3324c2c66affSColin Finck #define WINED3D_LOCATION_RB_RESOLVED 0x00000100
3325c2c66affSColin Finck
3326c2c66affSColin Finck const char *wined3d_debug_location(DWORD location) DECLSPEC_HIDDEN;
3327c2c66affSColin Finck
3328c2c66affSColin Finck struct wined3d_renderbuffer_entry
3329c2c66affSColin Finck {
3330c2c66affSColin Finck struct list entry;
3331c2c66affSColin Finck GLuint id;
3332c2c66affSColin Finck UINT width;
3333c2c66affSColin Finck UINT height;
3334c2c66affSColin Finck };
3335c2c66affSColin Finck
3336c2c66affSColin Finck struct wined3d_fbo_resource
3337c2c66affSColin Finck {
3338c2c66affSColin Finck GLuint object;
3339c2c66affSColin Finck GLenum target;
3340c2c66affSColin Finck GLuint level, layer;
3341c2c66affSColin Finck };
3342c2c66affSColin Finck
3343c2c66affSColin Finck #define WINED3D_FBO_ENTRY_FLAG_ATTACHED 0x1
3344c2c66affSColin Finck #define WINED3D_FBO_ENTRY_FLAG_DEPTH 0x2
3345c2c66affSColin Finck #define WINED3D_FBO_ENTRY_FLAG_STENCIL 0x4
3346c2c66affSColin Finck
3347c2c66affSColin Finck struct fbo_entry
3348c2c66affSColin Finck {
3349c2c66affSColin Finck struct list entry;
3350c2c66affSColin Finck DWORD flags;
3351c2c66affSColin Finck DWORD rt_mask;
3352c2c66affSColin Finck GLuint id;
3353c2c66affSColin Finck struct wined3d_fbo_entry_key
3354c2c66affSColin Finck {
3355c2c66affSColin Finck DWORD rb_namespace;
33569987f029SAmine Khaldi struct wined3d_fbo_resource objects[MAX_RENDER_TARGET_VIEWS + 1];
3357c2c66affSColin Finck } key;
3358c2c66affSColin Finck };
3359c2c66affSColin Finck
3360*81cffd76SJoachim Henze struct wined3d_surface
3361*81cffd76SJoachim Henze {
3362*81cffd76SJoachim Henze struct wined3d_texture *container;
3363*81cffd76SJoachim Henze
3364*81cffd76SJoachim Henze unsigned int texture_level;
3365*81cffd76SJoachim Henze unsigned int texture_layer;
3366*81cffd76SJoachim Henze
3367*81cffd76SJoachim Henze /* For GetDC */
3368*81cffd76SJoachim Henze HBITMAP bitmap;
3369*81cffd76SJoachim Henze HDC dc;
3370*81cffd76SJoachim Henze
3371*81cffd76SJoachim Henze struct list renderbuffers;
3372*81cffd76SJoachim Henze const struct wined3d_renderbuffer_entry *current_renderbuffer;
3373*81cffd76SJoachim Henze };
3374*81cffd76SJoachim Henze
surface_get_sub_resource_idx(const struct wined3d_surface * surface)3375*81cffd76SJoachim Henze static inline unsigned int surface_get_sub_resource_idx(const struct wined3d_surface *surface)
3376*81cffd76SJoachim Henze {
3377*81cffd76SJoachim Henze return surface->texture_layer * surface->container->level_count + surface->texture_level;
3378*81cffd76SJoachim Henze }
3379*81cffd76SJoachim Henze
surface_get_sub_resource(struct wined3d_surface * surface)3380*81cffd76SJoachim Henze static inline struct wined3d_texture_sub_resource *surface_get_sub_resource(struct wined3d_surface *surface)
3381*81cffd76SJoachim Henze {
3382*81cffd76SJoachim Henze return &surface->container->sub_resources[surface_get_sub_resource_idx(surface)];
3383*81cffd76SJoachim Henze }
3384*81cffd76SJoachim Henze
3385*81cffd76SJoachim Henze HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
3386*81cffd76SJoachim Henze struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
3387*81cffd76SJoachim Henze const struct wined3d_blt_fx *blt_fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
3388*81cffd76SJoachim Henze void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
3389*81cffd76SJoachim Henze struct wined3d_context *context) DECLSPEC_HIDDEN;
3390*81cffd76SJoachim Henze BOOL surface_load_location(struct wined3d_surface *surface,
3391*81cffd76SJoachim Henze struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3392*81cffd76SJoachim Henze void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
3393*81cffd76SJoachim Henze const struct wined3d_rendertarget_info *rt) DECLSPEC_HIDDEN;
3394*81cffd76SJoachim Henze void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
3395*81cffd76SJoachim Henze void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info,
3396*81cffd76SJoachim Henze const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point,
3397*81cffd76SJoachim Henze BOOL srgb, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
3398*81cffd76SJoachim Henze
3399*81cffd76SJoachim Henze void draw_textured_quad(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3400*81cffd76SJoachim Henze struct wined3d_context *context, const RECT *src_rect, const RECT *dst_rect,
3401*81cffd76SJoachim Henze enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
3402*81cffd76SJoachim Henze
3403c2c66affSColin Finck struct wined3d_sampler
3404c2c66affSColin Finck {
3405c2c66affSColin Finck struct wine_rb_entry entry;
3406c2c66affSColin Finck LONG refcount;
3407c2c66affSColin Finck GLuint name;
3408c2c66affSColin Finck struct wined3d_device *device;
3409c2c66affSColin Finck void *parent;
3410c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3411c2c66affSColin Finck struct wined3d_sampler_desc desc;
3412c2c66affSColin Finck };
3413c2c66affSColin Finck
3414c2c66affSColin Finck void wined3d_sampler_bind(struct wined3d_sampler *sampler, unsigned int unit,
3415c2c66affSColin Finck struct wined3d_texture *texture, const struct wined3d_context *context) DECLSPEC_HIDDEN;
3416c2c66affSColin Finck
3417c2c66affSColin Finck struct wined3d_vertex_declaration_element
3418c2c66affSColin Finck {
3419c2c66affSColin Finck const struct wined3d_format *format;
3420c2c66affSColin Finck BOOL ffp_valid;
3421c2c66affSColin Finck unsigned int input_slot;
3422c2c66affSColin Finck unsigned int offset;
3423c2c66affSColin Finck unsigned int output_slot;
3424c2c66affSColin Finck enum wined3d_input_classification input_slot_class;
3425c2c66affSColin Finck unsigned int instance_data_step_rate;
3426c2c66affSColin Finck BYTE method;
3427c2c66affSColin Finck BYTE usage;
3428c2c66affSColin Finck BYTE usage_idx;
3429c2c66affSColin Finck };
3430c2c66affSColin Finck
3431c2c66affSColin Finck struct wined3d_vertex_declaration
3432c2c66affSColin Finck {
3433c2c66affSColin Finck LONG ref;
3434c2c66affSColin Finck void *parent;
3435c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3436c2c66affSColin Finck struct wined3d_device *device;
3437c2c66affSColin Finck
3438c2c66affSColin Finck struct wined3d_vertex_declaration_element *elements;
3439c2c66affSColin Finck UINT element_count;
3440c2c66affSColin Finck
3441c2c66affSColin Finck BOOL position_transformed;
3442c2c66affSColin Finck BOOL half_float_conv_needed;
3443c2c66affSColin Finck };
3444c2c66affSColin Finck
3445c2c66affSColin Finck struct wined3d_saved_states
3446c2c66affSColin Finck {
3447c2c66affSColin Finck DWORD transform[(HIGHEST_TRANSFORMSTATE >> 5) + 1];
3448c2c66affSColin Finck WORD streamSource; /* MAX_STREAMS, 16 */
3449c2c66affSColin Finck WORD streamFreq; /* MAX_STREAMS, 16 */
3450c2c66affSColin Finck DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
3451c2c66affSColin Finck DWORD textureState[MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
3452c2c66affSColin Finck WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
3453d6ac0a71SAmine Khaldi DWORD clipplane; /* WINED3D_MAX_USER_CLIP_PLANES, 32 */
3454c2c66affSColin Finck WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
3455c2c66affSColin Finck WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
3456c2c66affSColin Finck BOOL ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3457c2c66affSColin Finck WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */
3458c2c66affSColin Finck WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */
3459c2c66affSColin Finck BOOL vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3460c2c66affSColin Finck DWORD textures : 20; /* MAX_COMBINED_SAMPLERS, 20 */
3461c2c66affSColin Finck DWORD indices : 1;
3462c2c66affSColin Finck DWORD material : 1;
3463c2c66affSColin Finck DWORD viewport : 1;
3464c2c66affSColin Finck DWORD vertexDecl : 1;
3465c2c66affSColin Finck DWORD pixelShader : 1;
3466c2c66affSColin Finck DWORD vertexShader : 1;
3467c2c66affSColin Finck DWORD scissorRect : 1;
3468c2c66affSColin Finck DWORD padding : 5;
3469c2c66affSColin Finck };
3470c2c66affSColin Finck
3471c2c66affSColin Finck struct StageState {
3472c2c66affSColin Finck DWORD stage;
3473c2c66affSColin Finck DWORD state;
3474c2c66affSColin Finck };
3475c2c66affSColin Finck
3476c2c66affSColin Finck struct wined3d_stateblock
3477c2c66affSColin Finck {
3478c2c66affSColin Finck LONG ref; /* Note: Ref counting not required */
3479c2c66affSColin Finck struct wined3d_device *device;
3480c2c66affSColin Finck
3481c2c66affSColin Finck /* Array indicating whether things have been set or changed */
3482c2c66affSColin Finck struct wined3d_saved_states changed;
3483c2c66affSColin Finck struct wined3d_state state;
3484c2c66affSColin Finck
3485c2c66affSColin Finck /* Contained state management */
3486c2c66affSColin Finck DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
3487c2c66affSColin Finck unsigned int num_contained_render_states;
3488c2c66affSColin Finck DWORD contained_transform_states[HIGHEST_TRANSFORMSTATE + 1];
3489c2c66affSColin Finck unsigned int num_contained_transform_states;
3490c2c66affSColin Finck DWORD contained_vs_consts_i[WINED3D_MAX_CONSTS_I];
3491c2c66affSColin Finck unsigned int num_contained_vs_consts_i;
3492c2c66affSColin Finck DWORD contained_vs_consts_b[WINED3D_MAX_CONSTS_B];
3493c2c66affSColin Finck unsigned int num_contained_vs_consts_b;
3494c2c66affSColin Finck DWORD contained_vs_consts_f[WINED3D_MAX_VS_CONSTS_F];
3495c2c66affSColin Finck unsigned int num_contained_vs_consts_f;
3496c2c66affSColin Finck DWORD contained_ps_consts_i[WINED3D_MAX_CONSTS_I];
3497c2c66affSColin Finck unsigned int num_contained_ps_consts_i;
3498c2c66affSColin Finck DWORD contained_ps_consts_b[WINED3D_MAX_CONSTS_B];
3499c2c66affSColin Finck unsigned int num_contained_ps_consts_b;
3500c2c66affSColin Finck DWORD contained_ps_consts_f[WINED3D_MAX_PS_CONSTS_F];
3501c2c66affSColin Finck unsigned int num_contained_ps_consts_f;
3502c2c66affSColin Finck struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
3503c2c66affSColin Finck unsigned int num_contained_tss_states;
3504c2c66affSColin Finck struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
3505c2c66affSColin Finck unsigned int num_contained_sampler_states;
3506c2c66affSColin Finck };
3507c2c66affSColin Finck
3508c2c66affSColin Finck void stateblock_init_contained_states(struct wined3d_stateblock *stateblock) DECLSPEC_HIDDEN;
3509c2c66affSColin Finck
3510c2c66affSColin Finck void state_cleanup(struct wined3d_state *state) DECLSPEC_HIDDEN;
3511c2c66affSColin Finck void wined3d_state_enable_light(struct wined3d_state *state, const struct wined3d_d3d_info *d3d_info,
3512c2c66affSColin Finck struct wined3d_light_info *light_info, BOOL enable) DECLSPEC_HIDDEN;
3513c2c66affSColin Finck struct wined3d_light_info *wined3d_state_get_light(const struct wined3d_state *state,
3514c2c66affSColin Finck unsigned int idx) DECLSPEC_HIDDEN;
3515c2c66affSColin Finck void state_init(struct wined3d_state *state, struct wined3d_fb_state *fb,
3516c2c66affSColin Finck const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info,
3517c2c66affSColin Finck DWORD flags) DECLSPEC_HIDDEN;
3518c2c66affSColin Finck void state_unbind_resources(struct wined3d_state *state) DECLSPEC_HIDDEN;
3519c2c66affSColin Finck
3520c2c66affSColin Finck enum wined3d_cs_queue_id
3521c2c66affSColin Finck {
3522c2c66affSColin Finck WINED3D_CS_QUEUE_DEFAULT = 0,
3523c2c66affSColin Finck WINED3D_CS_QUEUE_MAP,
3524c2c66affSColin Finck WINED3D_CS_QUEUE_COUNT,
3525c2c66affSColin Finck };
3526c2c66affSColin Finck
3527c2c66affSColin Finck enum wined3d_push_constants
3528c2c66affSColin Finck {
3529c2c66affSColin Finck WINED3D_PUSH_CONSTANTS_VS_F,
3530c2c66affSColin Finck WINED3D_PUSH_CONSTANTS_PS_F,
3531c2c66affSColin Finck WINED3D_PUSH_CONSTANTS_VS_I,
3532c2c66affSColin Finck WINED3D_PUSH_CONSTANTS_PS_I,
3533c2c66affSColin Finck WINED3D_PUSH_CONSTANTS_VS_B,
3534c2c66affSColin Finck WINED3D_PUSH_CONSTANTS_PS_B,
3535c2c66affSColin Finck };
3536c2c66affSColin Finck
3537c2c66affSColin Finck #define WINED3D_CS_QUERY_POLL_INTERVAL 10u
3538c2c66affSColin Finck #define WINED3D_CS_QUEUE_SIZE 0x100000u
3539adfbefdeSThomas Faber #ifdef __REACTOS__
3540adfbefdeSThomas Faber #define WINED3D_CS_SPIN_COUNT 1u
3541adfbefdeSThomas Faber #else
3542c2c66affSColin Finck #define WINED3D_CS_SPIN_COUNT 10000000u
3543adfbefdeSThomas Faber #endif
3544c2c66affSColin Finck
3545c2c66affSColin Finck struct wined3d_cs_queue
3546c2c66affSColin Finck {
3547c2c66affSColin Finck LONG head, tail;
3548c2c66affSColin Finck BYTE data[WINED3D_CS_QUEUE_SIZE];
3549c2c66affSColin Finck };
3550c2c66affSColin Finck
3551c2c66affSColin Finck struct wined3d_cs_ops
3552c2c66affSColin Finck {
3553*81cffd76SJoachim Henze #if defined(STAGING_CSMT)
35549987f029SAmine Khaldi BOOL (*check_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
3555*81cffd76SJoachim Henze #endif /* STAGING_CSMT */
3556c2c66affSColin Finck void *(*require_space)(struct wined3d_cs *cs, size_t size, enum wined3d_cs_queue_id queue_id);
3557c2c66affSColin Finck void (*submit)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
3558c2c66affSColin Finck void (*finish)(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id);
3559c2c66affSColin Finck void (*push_constants)(struct wined3d_cs *cs, enum wined3d_push_constants p,
3560c2c66affSColin Finck unsigned int start_idx, unsigned int count, const void *constants);
3561c2c66affSColin Finck };
3562c2c66affSColin Finck
3563c2c66affSColin Finck struct wined3d_cs
3564c2c66affSColin Finck {
3565c2c66affSColin Finck const struct wined3d_cs_ops *ops;
3566c2c66affSColin Finck struct wined3d_device *device;
3567c2c66affSColin Finck struct wined3d_fb_state fb;
3568c2c66affSColin Finck struct wined3d_state state;
3569c2c66affSColin Finck HMODULE wined3d_module;
3570c2c66affSColin Finck HANDLE thread;
3571c2c66affSColin Finck DWORD thread_id;
3572c2c66affSColin Finck
3573c2c66affSColin Finck struct wined3d_cs_queue queue[WINED3D_CS_QUEUE_COUNT];
3574c2c66affSColin Finck size_t data_size, start, end;
3575c2c66affSColin Finck void *data;
3576c2c66affSColin Finck struct list query_poll_list;
3577d6ac0a71SAmine Khaldi BOOL queries_flushed;
3578c2c66affSColin Finck
3579c2c66affSColin Finck HANDLE event;
3580c2c66affSColin Finck BOOL waiting_for_event;
3581c2c66affSColin Finck LONG pending_presents;
3582c2c66affSColin Finck };
3583c2c66affSColin Finck
3584c2c66affSColin Finck struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN;
3585c2c66affSColin Finck void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
3586c2c66affSColin Finck void wined3d_cs_destroy_object(struct wined3d_cs *cs,
3587c2c66affSColin Finck void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
3588c2c66affSColin Finck void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs,
3589c2c66affSColin Finck struct wined3d_texture *texture, unsigned int layer) DECLSPEC_HIDDEN;
3590c2c66affSColin Finck void wined3d_cs_emit_blt_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *dst_resource,
3591c2c66affSColin Finck unsigned int dst_sub_resource_idx, const struct wined3d_box *dst_box, struct wined3d_resource *src_resource,
3592c2c66affSColin Finck unsigned int src_sub_resource_idx, const struct wined3d_box *src_box, DWORD flags,
3593c2c66affSColin Finck const struct wined3d_blt_fx *fx, enum wined3d_texture_filter_type filter) DECLSPEC_HIDDEN;
3594c2c66affSColin Finck void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *rects,
3595c2c66affSColin Finck DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
3596c2c66affSColin Finck void wined3d_cs_emit_clear_rendertarget_view(struct wined3d_cs *cs, struct wined3d_rendertarget_view *view,
3597c2c66affSColin Finck const RECT *rect, DWORD flags, const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
3598c2c66affSColin Finck void wined3d_cs_emit_clear_unordered_access_view_uint(struct wined3d_cs *cs,
3599c2c66affSColin Finck struct wined3d_unordered_access_view *view, const struct wined3d_uvec4 *clear_value) DECLSPEC_HIDDEN;
3600c2c66affSColin Finck void wined3d_cs_emit_copy_uav_counter(struct wined3d_cs *cs, struct wined3d_buffer *dst_buffer,
3601c2c66affSColin Finck unsigned int offset, struct wined3d_unordered_access_view *uav) DECLSPEC_HIDDEN;
3602c2c66affSColin Finck void wined3d_cs_emit_dispatch(struct wined3d_cs *cs,
3603c2c66affSColin Finck unsigned int group_count_x, unsigned int group_count_y, unsigned int group_count_z) DECLSPEC_HIDDEN;
3604c2c66affSColin Finck void wined3d_cs_emit_dispatch_indirect(struct wined3d_cs *cs,
3605c2c66affSColin Finck struct wined3d_buffer *buffer, unsigned int offset) DECLSPEC_HIDDEN;
3606c2c66affSColin Finck void wined3d_cs_emit_draw(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
3607c2c66affSColin Finck int base_vertex_idx, unsigned int start_idx, unsigned int index_count,
3608c2c66affSColin Finck unsigned int start_instance, unsigned int instance_count, BOOL indexed) DECLSPEC_HIDDEN;
3609c2c66affSColin Finck void wined3d_cs_emit_draw_indirect(struct wined3d_cs *cs, GLenum primitive_type, unsigned int patch_vertex_count,
3610c2c66affSColin Finck struct wined3d_buffer *buffer, unsigned int offset, BOOL indexed) DECLSPEC_HIDDEN;
3611c2c66affSColin Finck void wined3d_cs_emit_flush(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
3612d6ac0a71SAmine Khaldi void wined3d_cs_emit_generate_mipmaps(struct wined3d_cs *cs, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
3613c2c66affSColin Finck void wined3d_cs_emit_preload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
36149987f029SAmine Khaldi void wined3d_cs_emit_present(struct wined3d_cs *cs, struct wined3d_swapchain *swapchain, const RECT *src_rect,
3615*81cffd76SJoachim Henze const RECT *dst_rect, HWND dst_window_override, DWORD swap_interval, DWORD flags) DECLSPEC_HIDDEN;
3616c2c66affSColin Finck void wined3d_cs_emit_query_issue(struct wined3d_cs *cs, struct wined3d_query *query, DWORD flags) DECLSPEC_HIDDEN;
3617c2c66affSColin Finck void wined3d_cs_emit_reset_state(struct wined3d_cs *cs) DECLSPEC_HIDDEN;
36189987f029SAmine Khaldi void wined3d_cs_emit_set_blend_state(struct wined3d_cs *cs, struct wined3d_blend_state *state) DECLSPEC_HIDDEN;
3619c2c66affSColin Finck void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx,
3620c2c66affSColin Finck const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN;
3621c2c66affSColin Finck void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture,
3622c2c66affSColin Finck WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN;
3623c2c66affSColin Finck void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type,
3624c2c66affSColin Finck UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN;
3625c2c66affSColin Finck void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs,
3626c2c66affSColin Finck struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
3627c2c66affSColin Finck void wined3d_cs_emit_set_index_buffer(struct wined3d_cs *cs, struct wined3d_buffer *buffer,
3628c2c66affSColin Finck enum wined3d_format_id format_id, unsigned int offset) DECLSPEC_HIDDEN;
3629c2c66affSColin Finck void wined3d_cs_emit_set_light(struct wined3d_cs *cs, const struct wined3d_light_info *light) DECLSPEC_HIDDEN;
3630c2c66affSColin Finck void wined3d_cs_emit_set_light_enable(struct wined3d_cs *cs, unsigned int idx, BOOL enable) DECLSPEC_HIDDEN;
3631c2c66affSColin Finck void wined3d_cs_emit_set_material(struct wined3d_cs *cs, const struct wined3d_material *material) DECLSPEC_HIDDEN;
3632c2c66affSColin Finck void wined3d_cs_emit_set_predication(struct wined3d_cs *cs,
3633c2c66affSColin Finck struct wined3d_query *predicate, BOOL value) DECLSPEC_HIDDEN;
3634c2c66affSColin Finck void wined3d_cs_emit_set_rasterizer_state(struct wined3d_cs *cs,
3635c2c66affSColin Finck struct wined3d_rasterizer_state *rasterizer_state) DECLSPEC_HIDDEN;
3636c2c66affSColin Finck void wined3d_cs_emit_set_render_state(struct wined3d_cs *cs,
3637c2c66affSColin Finck enum wined3d_render_state state, DWORD value) DECLSPEC_HIDDEN;
3638c2c66affSColin Finck void wined3d_cs_emit_set_rendertarget_view(struct wined3d_cs *cs, unsigned int view_idx,
3639c2c66affSColin Finck struct wined3d_rendertarget_view *view) DECLSPEC_HIDDEN;
3640c2c66affSColin Finck void wined3d_cs_emit_set_shader_resource_view(struct wined3d_cs *cs, enum wined3d_shader_type type,
3641c2c66affSColin Finck UINT view_idx, struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
3642c2c66affSColin Finck void wined3d_cs_emit_set_sampler(struct wined3d_cs *cs, enum wined3d_shader_type type,
3643c2c66affSColin Finck UINT sampler_idx, struct wined3d_sampler *sampler) DECLSPEC_HIDDEN;
3644c2c66affSColin Finck void wined3d_cs_emit_set_sampler_state(struct wined3d_cs *cs, UINT sampler_idx,
3645c2c66affSColin Finck enum wined3d_sampler_state state, DWORD value) DECLSPEC_HIDDEN;
3646*81cffd76SJoachim Henze void wined3d_cs_emit_set_scissor_rect(struct wined3d_cs *cs, const RECT *rect) DECLSPEC_HIDDEN;
3647c2c66affSColin Finck void wined3d_cs_emit_set_shader(struct wined3d_cs *cs, enum wined3d_shader_type type,
3648c2c66affSColin Finck struct wined3d_shader *shader) DECLSPEC_HIDDEN;
3649c2c66affSColin Finck void wined3d_cs_emit_set_stream_output(struct wined3d_cs *cs, UINT stream_idx,
3650c2c66affSColin Finck struct wined3d_buffer *buffer, UINT offset) DECLSPEC_HIDDEN;
3651c2c66affSColin Finck void wined3d_cs_emit_set_stream_source(struct wined3d_cs *cs, UINT stream_idx,
3652c2c66affSColin Finck struct wined3d_buffer *buffer, UINT offset, UINT stride) DECLSPEC_HIDDEN;
3653c2c66affSColin Finck void wined3d_cs_emit_set_stream_source_freq(struct wined3d_cs *cs, UINT stream_idx,
3654c2c66affSColin Finck UINT frequency, UINT flags) DECLSPEC_HIDDEN;
3655c2c66affSColin Finck void wined3d_cs_emit_set_texture(struct wined3d_cs *cs, UINT stage, struct wined3d_texture *texture) DECLSPEC_HIDDEN;
3656c2c66affSColin Finck void wined3d_cs_emit_set_texture_state(struct wined3d_cs *cs, UINT stage,
3657c2c66affSColin Finck enum wined3d_texture_stage_state state, DWORD value) DECLSPEC_HIDDEN;
3658c2c66affSColin Finck void wined3d_cs_emit_set_transform(struct wined3d_cs *cs, enum wined3d_transform_state state,
3659c2c66affSColin Finck const struct wined3d_matrix *matrix) DECLSPEC_HIDDEN;
3660c2c66affSColin Finck void wined3d_cs_emit_set_unordered_access_view(struct wined3d_cs *cs, enum wined3d_pipeline pipeline,
3661c2c66affSColin Finck unsigned int view_idx, struct wined3d_unordered_access_view *view,
3662c2c66affSColin Finck unsigned int initial_count) DECLSPEC_HIDDEN;
3663c2c66affSColin Finck void wined3d_cs_emit_set_vertex_declaration(struct wined3d_cs *cs,
3664c2c66affSColin Finck struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
3665*81cffd76SJoachim Henze void wined3d_cs_emit_set_viewport(struct wined3d_cs *cs, const struct wined3d_viewport *viewport) DECLSPEC_HIDDEN;
3666c2c66affSColin Finck void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resource *resource) DECLSPEC_HIDDEN;
3667c2c66affSColin Finck void wined3d_cs_emit_update_sub_resource(struct wined3d_cs *cs, struct wined3d_resource *resource,
3668c2c66affSColin Finck unsigned int sub_resource_idx, const struct wined3d_box *box, const void *data, unsigned int row_pitch,
3669c2c66affSColin Finck unsigned int slice_pitch) DECLSPEC_HIDDEN;
3670c2c66affSColin Finck void wined3d_cs_init_object(struct wined3d_cs *cs,
3671c2c66affSColin Finck void (*callback)(void *object), void *object) DECLSPEC_HIDDEN;
3672c2c66affSColin Finck HRESULT wined3d_cs_map(struct wined3d_cs *cs, struct wined3d_resource *resource, unsigned int sub_resource_idx,
3673c2c66affSColin Finck struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
3674c2c66affSColin Finck HRESULT wined3d_cs_unmap(struct wined3d_cs *cs, struct wined3d_resource *resource,
3675c2c66affSColin Finck unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
3676c2c66affSColin Finck
wined3d_cs_push_constants(struct wined3d_cs * cs,enum wined3d_push_constants p,unsigned int start_idx,unsigned int count,const void * constants)3677c2c66affSColin Finck static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d_push_constants p,
3678c2c66affSColin Finck unsigned int start_idx, unsigned int count, const void *constants)
3679c2c66affSColin Finck {
3680c2c66affSColin Finck cs->ops->push_constants(cs, p, start_idx, count, constants);
3681c2c66affSColin Finck }
3682c2c66affSColin Finck
wined3d_resource_wait_idle(struct wined3d_resource * resource)3683c2c66affSColin Finck static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
3684c2c66affSColin Finck {
3685c2c66affSColin Finck const struct wined3d_cs *cs = resource->device->cs;
3686c2c66affSColin Finck
3687c2c66affSColin Finck if (!cs->thread || cs->thread_id == GetCurrentThreadId())
3688c2c66affSColin Finck return;
3689c2c66affSColin Finck
3690c2c66affSColin Finck while (InterlockedCompareExchange(&resource->access_count, 0, 0))
3691c2c66affSColin Finck wined3d_pause();
3692c2c66affSColin Finck }
3693c2c66affSColin Finck
3694c2c66affSColin Finck /* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
3695c2c66affSColin Finck * fixed function semantics as D3DCOLOR or FLOAT16 */
3696c2c66affSColin Finck enum wined3d_buffer_conversion_type
3697c2c66affSColin Finck {
3698c2c66affSColin Finck CONV_NONE,
3699c2c66affSColin Finck CONV_D3DCOLOR,
3700c2c66affSColin Finck CONV_POSITIONT,
3701c2c66affSColin Finck };
3702c2c66affSColin Finck
3703c2c66affSColin Finck struct wined3d_map_range
3704c2c66affSColin Finck {
3705c2c66affSColin Finck UINT offset;
3706c2c66affSColin Finck UINT size;
3707c2c66affSColin Finck };
3708c2c66affSColin Finck
3709c2c66affSColin Finck struct wined3d_buffer
3710c2c66affSColin Finck {
3711c2c66affSColin Finck struct wined3d_resource resource;
3712c2c66affSColin Finck
3713c2c66affSColin Finck struct wined3d_buffer_desc desc;
3714c2c66affSColin Finck
3715c2c66affSColin Finck GLuint buffer_object;
3716c2c66affSColin Finck GLenum buffer_object_usage;
3717c2c66affSColin Finck GLenum buffer_type_hint;
3718c2c66affSColin Finck unsigned int bind_flags;
3719c2c66affSColin Finck DWORD flags;
3720c2c66affSColin Finck DWORD locations;
3721c2c66affSColin Finck void *map_ptr;
3722c2c66affSColin Finck
3723c2c66affSColin Finck struct wined3d_map_range *maps;
3724c2c66affSColin Finck SIZE_T maps_size, modified_areas;
3725c2c66affSColin Finck struct wined3d_fence *fence;
3726c2c66affSColin Finck
3727c2c66affSColin Finck /* conversion stuff */
3728c2c66affSColin Finck UINT decl_change_count, full_conversion_count;
3729c2c66affSColin Finck UINT draw_count;
3730c2c66affSColin Finck UINT stride; /* 0 if no conversion */
3731c2c66affSColin Finck enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
3732c2c66affSColin Finck UINT conversion_stride; /* 0 if no shifted conversion */
3733c2c66affSColin Finck };
3734c2c66affSColin Finck
buffer_from_resource(struct wined3d_resource * resource)3735c2c66affSColin Finck static inline struct wined3d_buffer *buffer_from_resource(struct wined3d_resource *resource)
3736c2c66affSColin Finck {
3737c2c66affSColin Finck return CONTAINING_RECORD(resource, struct wined3d_buffer, resource);
3738c2c66affSColin Finck }
3739c2c66affSColin Finck
3740c2c66affSColin Finck DWORD wined3d_buffer_get_memory(struct wined3d_buffer *buffer,
3741c2c66affSColin Finck struct wined3d_bo_address *data, DWORD locations) DECLSPEC_HIDDEN;
3742c2c66affSColin Finck void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, DWORD location) DECLSPEC_HIDDEN;
3743c2c66affSColin Finck void wined3d_buffer_load(struct wined3d_buffer *buffer, struct wined3d_context *context,
3744c2c66affSColin Finck const struct wined3d_state *state) DECLSPEC_HIDDEN;
3745c2c66affSColin Finck BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
3746c2c66affSColin Finck struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3747c2c66affSColin Finck BYTE *wined3d_buffer_load_sysmem(struct wined3d_buffer *buffer, struct wined3d_context *context) DECLSPEC_HIDDEN;
3748c2c66affSColin Finck void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_offset,
3749c2c66affSColin Finck struct wined3d_buffer *src_buffer, unsigned int src_offset, unsigned int size) DECLSPEC_HIDDEN;
3750d6ac0a71SAmine Khaldi void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context,
3751c2c66affSColin Finck const struct wined3d_box *box, const void *data) DECLSPEC_HIDDEN;
3752c2c66affSColin Finck
3753c2c66affSColin Finck struct wined3d_rendertarget_view
3754c2c66affSColin Finck {
3755c2c66affSColin Finck LONG refcount;
3756c2c66affSColin Finck
3757c2c66affSColin Finck struct wined3d_resource *resource;
3758c2c66affSColin Finck void *parent;
3759c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3760c2c66affSColin Finck
3761c2c66affSColin Finck struct wined3d_gl_view gl_view;
3762c2c66affSColin Finck const struct wined3d_format *format;
3763c2c66affSColin Finck unsigned int format_flags;
3764c2c66affSColin Finck unsigned int sub_resource_idx;
3765c2c66affSColin Finck unsigned int layer_count;
3766c2c66affSColin Finck
3767c2c66affSColin Finck unsigned int width;
3768c2c66affSColin Finck unsigned int height;
3769c2c66affSColin Finck
3770c2c66affSColin Finck struct wined3d_view_desc desc;
3771c2c66affSColin Finck };
3772c2c66affSColin Finck
wined3d_rendertarget_view_get_surface(const struct wined3d_rendertarget_view * view)3773*81cffd76SJoachim Henze static inline struct wined3d_surface *wined3d_rendertarget_view_get_surface(
3774*81cffd76SJoachim Henze const struct wined3d_rendertarget_view *view)
3775*81cffd76SJoachim Henze {
3776*81cffd76SJoachim Henze struct wined3d_texture *texture;
3777*81cffd76SJoachim Henze
3778*81cffd76SJoachim Henze if (!view || view->resource->type != WINED3D_RTYPE_TEXTURE_2D)
3779*81cffd76SJoachim Henze return NULL;
3780*81cffd76SJoachim Henze
3781*81cffd76SJoachim Henze texture = texture_from_resource(view->resource);
3782*81cffd76SJoachim Henze
3783*81cffd76SJoachim Henze return texture->sub_resources[view->sub_resource_idx].u.surface;
3784*81cffd76SJoachim Henze }
3785*81cffd76SJoachim Henze
3786c2c66affSColin Finck void wined3d_rendertarget_view_get_drawable_size(const struct wined3d_rendertarget_view *view,
3787c2c66affSColin Finck const struct wined3d_context *context, unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
3788c2c66affSColin Finck void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view,
3789c2c66affSColin Finck DWORD location) DECLSPEC_HIDDEN;
3790c2c66affSColin Finck void wined3d_rendertarget_view_load_location(struct wined3d_rendertarget_view *view,
3791c2c66affSColin Finck struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3792c2c66affSColin Finck void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view,
3793c2c66affSColin Finck struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
3794c2c66affSColin Finck void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view,
3795c2c66affSColin Finck DWORD location) DECLSPEC_HIDDEN;
3796c2c66affSColin Finck
3797c2c66affSColin Finck struct wined3d_shader_resource_view
3798c2c66affSColin Finck {
3799c2c66affSColin Finck LONG refcount;
3800c2c66affSColin Finck
3801c2c66affSColin Finck struct wined3d_resource *resource;
3802c2c66affSColin Finck void *parent;
3803c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3804c2c66affSColin Finck
3805c2c66affSColin Finck struct wined3d_gl_view gl_view;
3806c2c66affSColin Finck const struct wined3d_format *format;
3807c2c66affSColin Finck
3808c2c66affSColin Finck struct wined3d_view_desc desc;
3809c2c66affSColin Finck };
3810c2c66affSColin Finck
3811d6ac0a71SAmine Khaldi void shader_resource_view_generate_mipmaps(struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
3812c2c66affSColin Finck void wined3d_shader_resource_view_bind(struct wined3d_shader_resource_view *view, unsigned int unit,
3813c2c66affSColin Finck struct wined3d_sampler *sampler, struct wined3d_context *context) DECLSPEC_HIDDEN;
3814c2c66affSColin Finck
3815c2c66affSColin Finck struct wined3d_unordered_access_view
3816c2c66affSColin Finck {
3817c2c66affSColin Finck LONG refcount;
3818c2c66affSColin Finck
3819c2c66affSColin Finck struct wined3d_resource *resource;
3820c2c66affSColin Finck void *parent;
3821c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3822c2c66affSColin Finck
3823c2c66affSColin Finck struct wined3d_gl_view gl_view;
3824c2c66affSColin Finck const struct wined3d_format *format;
3825c2c66affSColin Finck GLuint counter_bo;
3826c2c66affSColin Finck
3827c2c66affSColin Finck struct wined3d_view_desc desc;
3828c2c66affSColin Finck };
3829c2c66affSColin Finck
3830c2c66affSColin Finck void wined3d_unordered_access_view_clear_uint(struct wined3d_unordered_access_view *view,
3831c2c66affSColin Finck const struct wined3d_uvec4 *clear_value, struct wined3d_context *context) DECLSPEC_HIDDEN;
3832c2c66affSColin Finck void wined3d_unordered_access_view_copy_counter(struct wined3d_unordered_access_view *view,
3833c2c66affSColin Finck struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context) DECLSPEC_HIDDEN;
3834c2c66affSColin Finck void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view,
3835c2c66affSColin Finck DWORD location) DECLSPEC_HIDDEN;
3836c2c66affSColin Finck void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view,
3837c2c66affSColin Finck unsigned int value) DECLSPEC_HIDDEN;
3838c2c66affSColin Finck
3839c2c66affSColin Finck struct wined3d_swapchain_ops
3840c2c66affSColin Finck {
3841c2c66affSColin Finck void (*swapchain_present)(struct wined3d_swapchain *swapchain,
3842c2c66affSColin Finck const RECT *src_rect, const RECT *dst_rect, DWORD flags);
3843c2c66affSColin Finck void (*swapchain_frontbuffer_updated)(struct wined3d_swapchain *swapchain);
3844c2c66affSColin Finck };
3845c2c66affSColin Finck
3846c2c66affSColin Finck struct wined3d_swapchain
3847c2c66affSColin Finck {
3848c2c66affSColin Finck LONG ref;
3849c2c66affSColin Finck void *parent;
3850c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
3851c2c66affSColin Finck const struct wined3d_swapchain_ops *swapchain_ops;
3852c2c66affSColin Finck struct wined3d_device *device;
3853c2c66affSColin Finck
3854c2c66affSColin Finck struct wined3d_texture **back_buffers;
3855c2c66affSColin Finck struct wined3d_texture *front_buffer;
3856c2c66affSColin Finck struct wined3d_swapchain_desc desc;
3857c2c66affSColin Finck struct wined3d_display_mode original_mode, d3d_mode;
3858c2c66affSColin Finck RECT original_window_rect;
3859c2c66affSColin Finck struct wined3d_gamma_ramp orig_gamma;
3860c2c66affSColin Finck BOOL render_to_fbo, reapply_mode;
3861c2c66affSColin Finck const struct wined3d_format *ds_format;
3862c2c66affSColin Finck struct wined3d_palette *palette;
3863c2c66affSColin Finck RECT front_buffer_update;
3864c2c66affSColin Finck
3865c2c66affSColin Finck LONG prev_time, frames; /* Performance tracking */
3866c2c66affSColin Finck
3867c2c66affSColin Finck struct wined3d_context **context;
3868c2c66affSColin Finck unsigned int num_contexts;
3869c2c66affSColin Finck
3870c2c66affSColin Finck HWND win_handle;
3871c2c66affSColin Finck HWND device_window;
3872c2c66affSColin Finck
3873c2c66affSColin Finck HDC backup_dc;
3874c2c66affSColin Finck HWND backup_wnd;
3875c2c66affSColin Finck };
3876c2c66affSColin Finck
3877c2c66affSColin Finck void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate) DECLSPEC_HIDDEN;
3878c2c66affSColin Finck struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3879c2c66affSColin Finck void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3880c2c66affSColin Finck HDC swapchain_get_backup_dc(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3881c2c66affSColin Finck void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3882*81cffd76SJoachim Henze void swapchain_update_swap_interval(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
3883c2c66affSColin Finck
3884c2c66affSColin Finck /*****************************************************************************
3885c2c66affSColin Finck * Utility function prototypes
3886c2c66affSColin Finck */
3887c2c66affSColin Finck
3888c2c66affSColin Finck /* Trace routines */
3889c2c66affSColin Finck const char *debug_box(const struct wined3d_box *box) DECLSPEC_HIDDEN;
3890c2c66affSColin Finck const char *debug_color(const struct wined3d_color *color) DECLSPEC_HIDDEN;
3891c2c66affSColin Finck const char *debug_d3dshaderinstructionhandler(enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx) DECLSPEC_HIDDEN;
3892c2c66affSColin Finck const char *debug_d3dformat(enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
3893c2c66affSColin Finck const char *debug_d3ddevicetype(enum wined3d_device_type device_type) DECLSPEC_HIDDEN;
3894c2c66affSColin Finck const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type) DECLSPEC_HIDDEN;
3895c2c66affSColin Finck const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
3896c2c66affSColin Finck const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
3897c2c66affSColin Finck const char *debug_d3ddeclmethod(enum wined3d_decl_method method) DECLSPEC_HIDDEN;
3898c2c66affSColin Finck const char *debug_d3ddeclusage(enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
3899c2c66affSColin Finck const char *debug_d3dinput_classification(enum wined3d_input_classification classification) DECLSPEC_HIDDEN;
3900c2c66affSColin Finck const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
3901c2c66affSColin Finck const char *debug_d3drenderstate(enum wined3d_render_state state) DECLSPEC_HIDDEN;
3902c2c66affSColin Finck const char *debug_d3dsamplerstate(enum wined3d_sampler_state state) DECLSPEC_HIDDEN;
3903c2c66affSColin Finck const char *debug_d3dstate(DWORD state) DECLSPEC_HIDDEN;
3904c2c66affSColin Finck const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type) DECLSPEC_HIDDEN;
3905c2c66affSColin Finck const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state) DECLSPEC_HIDDEN;
3906c2c66affSColin Finck const char *debug_d3dtop(enum wined3d_texture_op d3dtop) DECLSPEC_HIDDEN;
3907c2c66affSColin Finck const char *debug_d3dtstype(enum wined3d_transform_state tstype) DECLSPEC_HIDDEN;
3908c2c66affSColin Finck const char *debug_fboattachment(GLenum attachment) DECLSPEC_HIDDEN;
3909c2c66affSColin Finck const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
3910c2c66affSColin Finck const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
3911c2c66affSColin Finck const char *debug_ivec4(const struct wined3d_ivec4 *v) DECLSPEC_HIDDEN;
3912c2c66affSColin Finck const char *debug_uvec4(const struct wined3d_uvec4 *v) DECLSPEC_HIDDEN;
3913c2c66affSColin Finck const char *debug_shader_type(enum wined3d_shader_type shader_type) DECLSPEC_HIDDEN;
3914c2c66affSColin Finck const char *debug_vec4(const struct wined3d_vec4 *v) DECLSPEC_HIDDEN;
3915c2c66affSColin Finck void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
3916c2c66affSColin Finck
3917c2c66affSColin Finck BOOL is_invalid_op(const struct wined3d_state *state, int stage,
3918c2c66affSColin Finck enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
3919c2c66affSColin Finck void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
3920c2c66affSColin Finck BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
3921c2c66affSColin Finck INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
3922c2c66affSColin Finck void texture_activate_dimensions(const struct wined3d_texture *texture,
3923c2c66affSColin Finck const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
3924c2c66affSColin Finck void sampler_texdim(struct wined3d_context *context,
3925c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3926c2c66affSColin Finck void tex_alphaop(struct wined3d_context *context,
3927c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3928c2c66affSColin Finck void apply_pixelshader(struct wined3d_context *context,
3929c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3930c2c66affSColin Finck void state_alpha_test(struct wined3d_context *context,
3931c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3932c2c66affSColin Finck void state_fogcolor(struct wined3d_context *context,
3933c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3934c2c66affSColin Finck void state_fogdensity(struct wined3d_context *context,
3935c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3936c2c66affSColin Finck void state_fogstartend(struct wined3d_context *context,
3937c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3938c2c66affSColin Finck void state_fog_fragpart(struct wined3d_context *context,
3939c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3940c2c66affSColin Finck void state_nop(struct wined3d_context *context,
3941c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3942c2c66affSColin Finck void state_srgbwrite(struct wined3d_context *context,
3943c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3944c2c66affSColin Finck
3945c2c66affSColin Finck void state_clipping(struct wined3d_context *context,
3946c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3947c2c66affSColin Finck void clipplane(struct wined3d_context *context,
3948c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3949c2c66affSColin Finck void state_pointsprite_w(struct wined3d_context *context,
3950c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3951c2c66affSColin Finck void state_pointsprite(struct wined3d_context *context,
3952c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3953c2c66affSColin Finck void state_shademode(struct wined3d_context *context,
3954c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
3955c2c66affSColin Finck
3956c2c66affSColin Finck GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type) DECLSPEC_HIDDEN;
3957c2c66affSColin Finck
3958c2c66affSColin Finck /* Math utils */
3959c2c66affSColin Finck void multiply_matrix(struct wined3d_matrix *dest, const struct wined3d_matrix *src1,
3960c2c66affSColin Finck const struct wined3d_matrix *src2) DECLSPEC_HIDDEN;
39619987f029SAmine Khaldi BOOL invert_matrix_3d(struct wined3d_matrix *out, const struct wined3d_matrix *in) DECLSPEC_HIDDEN;
39629987f029SAmine Khaldi BOOL invert_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
39639987f029SAmine Khaldi void transpose_matrix(struct wined3d_matrix *out, const struct wined3d_matrix *m) DECLSPEC_HIDDEN;
3964c2c66affSColin Finck
3965c2c66affSColin Finck void wined3d_release_dc(HWND window, HDC dc) DECLSPEC_HIDDEN;
3966c2c66affSColin Finck
3967c2c66affSColin Finck struct wined3d_shader_lconst
3968c2c66affSColin Finck {
3969c2c66affSColin Finck struct list entry;
3970c2c66affSColin Finck unsigned int idx;
3971c2c66affSColin Finck DWORD value[4];
3972c2c66affSColin Finck };
3973c2c66affSColin Finck
3974c2c66affSColin Finck struct wined3d_shader_limits
3975c2c66affSColin Finck {
3976c2c66affSColin Finck unsigned int sampler;
3977c2c66affSColin Finck unsigned int constant_int;
3978c2c66affSColin Finck unsigned int constant_float;
3979c2c66affSColin Finck unsigned int constant_bool;
3980c2c66affSColin Finck unsigned int packed_output;
3981c2c66affSColin Finck unsigned int packed_input;
3982c2c66affSColin Finck };
3983c2c66affSColin Finck
3984c2c66affSColin Finck #ifdef __GNUC__
3985c2c66affSColin Finck #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
3986c2c66affSColin Finck #else
3987c2c66affSColin Finck #define PRINTF_ATTR(fmt,args)
3988c2c66affSColin Finck #endif
3989c2c66affSColin Finck
3990c2c66affSColin Finck struct wined3d_string_buffer_list
3991c2c66affSColin Finck {
3992c2c66affSColin Finck struct list list;
3993c2c66affSColin Finck };
3994c2c66affSColin Finck
3995c2c66affSColin Finck struct wined3d_string_buffer *string_buffer_get(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
3996c2c66affSColin Finck void string_buffer_sprintf(struct wined3d_string_buffer *buffer, const char *format, ...) PRINTF_ATTR(2, 3) DECLSPEC_HIDDEN;
3997c2c66affSColin Finck void string_buffer_release(struct wined3d_string_buffer_list *list, struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
3998c2c66affSColin Finck void string_buffer_list_init(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
3999c2c66affSColin Finck void string_buffer_list_cleanup(struct wined3d_string_buffer_list *list) DECLSPEC_HIDDEN;
4000c2c66affSColin Finck
4001c2c66affSColin Finck int shader_addline(struct wined3d_string_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
4002c2c66affSColin Finck BOOL string_buffer_resize(struct wined3d_string_buffer *buffer, int rc) DECLSPEC_HIDDEN;
4003c2c66affSColin Finck int shader_vaddline(struct wined3d_string_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
4004c2c66affSColin Finck
4005c2c66affSColin Finck struct wined3d_shader_phase
4006c2c66affSColin Finck {
4007c2c66affSColin Finck const DWORD *start;
4008c2c66affSColin Finck const DWORD *end;
4009c2c66affSColin Finck unsigned int instance_count;
4010c2c66affSColin Finck unsigned int temporary_count;
4011c2c66affSColin Finck };
4012c2c66affSColin Finck
4013c2c66affSColin Finck struct wined3d_vertex_shader
4014c2c66affSColin Finck {
4015c2c66affSColin Finck struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
4016c2c66affSColin Finck };
4017c2c66affSColin Finck
4018c2c66affSColin Finck struct wined3d_hull_shader
4019c2c66affSColin Finck {
4020c2c66affSColin Finck struct
4021c2c66affSColin Finck {
4022c2c66affSColin Finck struct wined3d_shader_phase *control_point;
4023c2c66affSColin Finck unsigned int fork_count;
4024c2c66affSColin Finck unsigned int join_count;
4025c2c66affSColin Finck struct wined3d_shader_phase *fork;
4026c2c66affSColin Finck SIZE_T fork_size;
4027c2c66affSColin Finck struct wined3d_shader_phase *join;
4028c2c66affSColin Finck SIZE_T join_size;
4029c2c66affSColin Finck } phases;
4030c2c66affSColin Finck unsigned int output_vertex_count;
4031c2c66affSColin Finck enum wined3d_tessellator_output_primitive tessellator_output_primitive;
4032c2c66affSColin Finck enum wined3d_tessellator_partitioning tessellator_partitioning;
4033c2c66affSColin Finck };
4034c2c66affSColin Finck
4035c2c66affSColin Finck struct wined3d_domain_shader
4036c2c66affSColin Finck {
4037c2c66affSColin Finck enum wined3d_tessellator_domain tessellator_domain;
4038c2c66affSColin Finck };
4039c2c66affSColin Finck
4040c2c66affSColin Finck struct wined3d_geometry_shader
4041c2c66affSColin Finck {
4042c2c66affSColin Finck enum wined3d_primitive_type input_type;
4043c2c66affSColin Finck enum wined3d_primitive_type output_type;
4044c2c66affSColin Finck unsigned int vertices_out;
4045c2c66affSColin Finck unsigned int instance_count;
4046c2c66affSColin Finck
4047c2c66affSColin Finck struct wined3d_stream_output_desc so_desc;
4048c2c66affSColin Finck };
4049c2c66affSColin Finck
4050c2c66affSColin Finck struct wined3d_pixel_shader
4051c2c66affSColin Finck {
4052c2c66affSColin Finck /* Pixel shader input semantics */
4053c2c66affSColin Finck DWORD input_reg_map[MAX_REG_INPUT];
4054c2c66affSColin Finck DWORD input_reg_used; /* MAX_REG_INPUT, 32 */
4055c2c66affSColin Finck unsigned int declared_in_count;
4056c2c66affSColin Finck
4057c2c66affSColin Finck /* Some information about the shader behavior */
4058c2c66affSColin Finck BOOL color0_mov;
4059c2c66affSColin Finck DWORD color0_reg;
4060c2c66affSColin Finck
4061c2c66affSColin Finck BOOL force_early_depth_stencil;
4062d6ac0a71SAmine Khaldi enum wined3d_shader_register_type depth_output;
4063d6ac0a71SAmine Khaldi DWORD interpolation_mode[WINED3D_PACKED_INTERPOLATION_SIZE];
4064c2c66affSColin Finck };
4065c2c66affSColin Finck
4066c2c66affSColin Finck struct wined3d_compute_shader
4067c2c66affSColin Finck {
4068c2c66affSColin Finck struct wined3d_shader_thread_group_size thread_group_size;
4069c2c66affSColin Finck };
4070c2c66affSColin Finck
4071c2c66affSColin Finck struct wined3d_shader
4072c2c66affSColin Finck {
4073c2c66affSColin Finck LONG ref;
4074c2c66affSColin Finck const struct wined3d_shader_limits *limits;
4075c2c66affSColin Finck DWORD *function;
4076c2c66affSColin Finck UINT functionLength;
4077c2c66affSColin Finck BOOL load_local_constsF;
4078c2c66affSColin Finck const struct wined3d_shader_frontend *frontend;
4079c2c66affSColin Finck void *frontend_data;
4080c2c66affSColin Finck void *backend_data;
4081c2c66affSColin Finck
4082c2c66affSColin Finck void *parent;
4083c2c66affSColin Finck const struct wined3d_parent_ops *parent_ops;
4084c2c66affSColin Finck
4085c2c66affSColin Finck /* Programs this shader is linked with */
4086c2c66affSColin Finck struct list linked_programs;
4087c2c66affSColin Finck
4088c2c66affSColin Finck /* Immediate constants (override global ones) */
4089c2c66affSColin Finck struct list constantsB;
4090c2c66affSColin Finck struct list constantsF;
4091c2c66affSColin Finck struct list constantsI;
4092c2c66affSColin Finck struct wined3d_shader_reg_maps reg_maps;
4093c2c66affSColin Finck BOOL lconst_inf_or_nan;
4094c2c66affSColin Finck
4095c2c66affSColin Finck struct wined3d_shader_signature input_signature;
4096c2c66affSColin Finck struct wined3d_shader_signature output_signature;
4097c2c66affSColin Finck struct wined3d_shader_signature patch_constant_signature;
4098c2c66affSColin Finck char *signature_strings;
4099c2c66affSColin Finck
4100c2c66affSColin Finck /* Pointer to the parent device */
4101c2c66affSColin Finck struct wined3d_device *device;
4102c2c66affSColin Finck struct list shader_list_entry;
4103c2c66affSColin Finck
4104c2c66affSColin Finck union
4105c2c66affSColin Finck {
4106c2c66affSColin Finck struct wined3d_vertex_shader vs;
4107c2c66affSColin Finck struct wined3d_hull_shader hs;
4108c2c66affSColin Finck struct wined3d_domain_shader ds;
4109c2c66affSColin Finck struct wined3d_geometry_shader gs;
4110c2c66affSColin Finck struct wined3d_pixel_shader ps;
4111c2c66affSColin Finck struct wined3d_compute_shader cs;
4112c2c66affSColin Finck } u;
4113c2c66affSColin Finck };
4114c2c66affSColin Finck
4115c2c66affSColin Finck void pixelshader_update_resource_types(struct wined3d_shader *shader, WORD tex_types) DECLSPEC_HIDDEN;
4116c2c66affSColin Finck void find_ps_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4117c2c66affSColin Finck BOOL position_transformed, struct ps_compile_args *args,
4118c2c66affSColin Finck const struct wined3d_context *context) DECLSPEC_HIDDEN;
4119c2c66affSColin Finck
4120c2c66affSColin Finck BOOL vshader_get_input(const struct wined3d_shader *shader,
4121c2c66affSColin Finck BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
4122c2c66affSColin Finck void find_vs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4123c2c66affSColin Finck WORD swizzle_map, struct vs_compile_args *args,
4124d6ac0a71SAmine Khaldi const struct wined3d_context *context) DECLSPEC_HIDDEN;
4125c2c66affSColin Finck
4126c2c66affSColin Finck void find_ds_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4127c2c66affSColin Finck struct ds_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
4128c2c66affSColin Finck
4129c2c66affSColin Finck void find_gs_compile_args(const struct wined3d_state *state, const struct wined3d_shader *shader,
4130d6ac0a71SAmine Khaldi struct gs_compile_args *args, const struct wined3d_context *context) DECLSPEC_HIDDEN;
4131c2c66affSColin Finck
4132c2c66affSColin Finck void string_buffer_clear(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4133c2c66affSColin Finck BOOL string_buffer_init(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4134c2c66affSColin Finck void string_buffer_free(struct wined3d_string_buffer *buffer) DECLSPEC_HIDDEN;
4135c2c66affSColin Finck unsigned int shader_find_free_input_register(const struct wined3d_shader_reg_maps *reg_maps,
4136c2c66affSColin Finck unsigned int max) DECLSPEC_HIDDEN;
4137c2c66affSColin Finck HRESULT shader_generate_code(const struct wined3d_shader *shader, struct wined3d_string_buffer *buffer,
4138c2c66affSColin Finck const struct wined3d_shader_reg_maps *reg_maps, void *backend_ctx,
4139c2c66affSColin Finck const DWORD *start, const DWORD *end) DECLSPEC_HIDDEN;
4140c2c66affSColin Finck BOOL shader_match_semantic(const char *semantic_name, enum wined3d_decl_usage usage) DECLSPEC_HIDDEN;
4141c2c66affSColin Finck
shader_is_scalar(const struct wined3d_shader_register * reg)4142c2c66affSColin Finck static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
4143c2c66affSColin Finck {
4144c2c66affSColin Finck switch (reg->type)
4145c2c66affSColin Finck {
4146c2c66affSColin Finck case WINED3DSPR_RASTOUT:
4147c2c66affSColin Finck /* oFog & oPts */
4148c2c66affSColin Finck if (reg->idx[0].offset)
4149c2c66affSColin Finck return TRUE;
4150c2c66affSColin Finck /* oPos */
4151c2c66affSColin Finck return FALSE;
4152c2c66affSColin Finck
4153c2c66affSColin Finck case WINED3DSPR_DEPTHOUT: /* oDepth */
4154d6ac0a71SAmine Khaldi case WINED3DSPR_DEPTHOUTGE:
4155d6ac0a71SAmine Khaldi case WINED3DSPR_DEPTHOUTLE:
4156*81cffd76SJoachim Henze case WINED3DSPR_CONSTBOOL: /* b# */
4157c2c66affSColin Finck case WINED3DSPR_LOOP: /* aL */
4158c2c66affSColin Finck case WINED3DSPR_PREDICATE: /* p0 */
4159c2c66affSColin Finck case WINED3DSPR_PRIMID: /* primID */
4160c2c66affSColin Finck return TRUE;
4161c2c66affSColin Finck
4162c2c66affSColin Finck case WINED3DSPR_MISCTYPE:
4163c2c66affSColin Finck switch (reg->idx[0].offset)
4164c2c66affSColin Finck {
4165c2c66affSColin Finck case 0: /* vPos */
4166c2c66affSColin Finck return FALSE;
4167c2c66affSColin Finck case 1: /* vFace */
4168c2c66affSColin Finck return TRUE;
4169c2c66affSColin Finck default:
4170c2c66affSColin Finck return FALSE;
4171c2c66affSColin Finck }
4172c2c66affSColin Finck
4173c2c66affSColin Finck case WINED3DSPR_IMMCONST:
4174c2c66affSColin Finck return reg->immconst_type == WINED3D_IMMCONST_SCALAR;
4175c2c66affSColin Finck
4176c2c66affSColin Finck default:
4177c2c66affSColin Finck return FALSE;
4178c2c66affSColin Finck }
4179c2c66affSColin Finck }
4180c2c66affSColin Finck
shader_get_position_fixup(const struct wined3d_context * context,const struct wined3d_state * state,float * position_fixup)4181c2c66affSColin Finck static inline void shader_get_position_fixup(const struct wined3d_context *context,
4182*81cffd76SJoachim Henze const struct wined3d_state *state, float *position_fixup)
4183c2c66affSColin Finck {
4184c2c66affSColin Finck float center_offset;
4185c2c66affSColin Finck
4186c2c66affSColin Finck if (context->d3d_info->wined3d_creation_flags & WINED3D_PIXEL_CENTER_INTEGER)
4187c2c66affSColin Finck center_offset = 63.0f / 64.0f;
4188c2c66affSColin Finck else
4189c2c66affSColin Finck center_offset = -1.0f / 64.0f;
4190c2c66affSColin Finck
4191*81cffd76SJoachim Henze position_fixup[0] = 1.0f;
4192*81cffd76SJoachim Henze position_fixup[1] = 1.0f;
4193*81cffd76SJoachim Henze position_fixup[2] = center_offset / state->viewport.width;
4194*81cffd76SJoachim Henze position_fixup[3] = -center_offset / state->viewport.height;
4195c2c66affSColin Finck
4196c2c66affSColin Finck if (context->render_offscreen)
4197c2c66affSColin Finck {
4198*81cffd76SJoachim Henze position_fixup[1] *= -1.0f;
4199*81cffd76SJoachim Henze position_fixup[3] *= -1.0f;
4200c2c66affSColin Finck }
4201c2c66affSColin Finck }
4202c2c66affSColin Finck
shader_constant_is_local(const struct wined3d_shader * shader,DWORD reg)4203c2c66affSColin Finck static inline BOOL shader_constant_is_local(const struct wined3d_shader *shader, DWORD reg)
4204c2c66affSColin Finck {
4205c2c66affSColin Finck struct wined3d_shader_lconst *lconst;
4206c2c66affSColin Finck
4207c2c66affSColin Finck if (shader->load_local_constsF)
4208c2c66affSColin Finck return FALSE;
4209c2c66affSColin Finck
4210c2c66affSColin Finck LIST_FOR_EACH_ENTRY(lconst, &shader->constantsF, struct wined3d_shader_lconst, entry)
4211c2c66affSColin Finck {
4212c2c66affSColin Finck if (lconst->idx == reg)
4213c2c66affSColin Finck return TRUE;
4214c2c66affSColin Finck }
4215c2c66affSColin Finck
4216c2c66affSColin Finck return FALSE;
4217c2c66affSColin Finck }
4218c2c66affSColin Finck
4219c2c66affSColin Finck void get_identity_matrix(struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4220c2c66affSColin Finck void get_modelview_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4221c2c66affSColin Finck unsigned int index, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4222c2c66affSColin Finck void get_projection_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4223c2c66affSColin Finck struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4224c2c66affSColin Finck void get_texture_matrix(const struct wined3d_context *context, const struct wined3d_state *state,
4225c2c66affSColin Finck unsigned int tex, struct wined3d_matrix *mat) DECLSPEC_HIDDEN;
4226c2c66affSColin Finck void get_pointsize_minmax(const struct wined3d_context *context, const struct wined3d_state *state,
4227c2c66affSColin Finck float *out_min, float *out_max) DECLSPEC_HIDDEN;
4228c2c66affSColin Finck void get_pointsize(const struct wined3d_context *context, const struct wined3d_state *state,
4229c2c66affSColin Finck float *out_pointsize, float *out_att) DECLSPEC_HIDDEN;
4230c2c66affSColin Finck void get_fog_start_end(const struct wined3d_context *context, const struct wined3d_state *state,
4231c2c66affSColin Finck float *start, float *end) DECLSPEC_HIDDEN;
4232c2c66affSColin Finck
4233c2c66affSColin Finck /* Using additional shader constants (uniforms in GLSL / program environment
4234c2c66affSColin Finck * or local parameters in ARB) is costly:
4235c2c66affSColin Finck * ARB only knows float4 parameters and GLSL compiler are not really smart
4236c2c66affSColin Finck * when it comes to efficiently pack float2 uniforms, so no space is wasted
4237c2c66affSColin Finck * (in fact most compilers map a float2 to a full float4 uniform).
4238c2c66affSColin Finck *
4239c2c66affSColin Finck * For NP2 texcoord fixup we only need 2 floats (width and height) for each
4240c2c66affSColin Finck * 2D texture used in the shader. We therefore pack fixup info for 2 textures
4241c2c66affSColin Finck * into a single shader constant (uniform / program parameter).
4242c2c66affSColin Finck *
4243c2c66affSColin Finck * This structure is shared between the GLSL and the ARB backend.*/
4244c2c66affSColin Finck struct ps_np2fixup_info {
4245c2c66affSColin Finck unsigned char idx[MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
4246c2c66affSColin Finck WORD active; /* bitfield indicating if we can apply the fixup */
4247c2c66affSColin Finck WORD num_consts;
4248c2c66affSColin Finck };
4249c2c66affSColin Finck
4250c2c66affSColin Finck void print_glsl_info_log(const struct wined3d_gl_info *gl_info, GLuint id, BOOL program) DECLSPEC_HIDDEN;
4251c2c66affSColin Finck void shader_glsl_validate_link(const struct wined3d_gl_info *gl_info, GLuint program) DECLSPEC_HIDDEN;
4252c2c66affSColin Finck
4253c2c66affSColin Finck struct wined3d_palette
4254c2c66affSColin Finck {
4255c2c66affSColin Finck LONG ref;
4256c2c66affSColin Finck struct wined3d_device *device;
4257c2c66affSColin Finck
4258c2c66affSColin Finck unsigned int size;
4259c2c66affSColin Finck RGBQUAD colors[256];
4260c2c66affSColin Finck DWORD flags;
4261c2c66affSColin Finck };
4262c2c66affSColin Finck
4263c2c66affSColin Finck /* DirectDraw utility functions */
4264c2c66affSColin Finck extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
4265c2c66affSColin Finck
4266c2c66affSColin Finck /*****************************************************************************
4267c2c66affSColin Finck * Pixel format management
4268c2c66affSColin Finck */
4269c2c66affSColin Finck
4270c2c66affSColin Finck /* WineD3D pixel format flags */
4271c2c66affSColin Finck #define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x00000001
4272c2c66affSColin Finck #define WINED3DFMT_FLAG_FILTERING 0x00000002
4273c2c66affSColin Finck #define WINED3DFMT_FLAG_DEPTH 0x00000004
4274c2c66affSColin Finck #define WINED3DFMT_FLAG_STENCIL 0x00000008
4275c2c66affSColin Finck #define WINED3DFMT_FLAG_RENDERTARGET 0x00000010
4276d6ac0a71SAmine Khaldi #define WINED3DFMT_FLAG_EXTENSION 0x00000020
4277c2c66affSColin Finck #define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x00000040
4278c2c66affSColin Finck #define WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB 0x00000080
4279c2c66affSColin Finck #define WINED3DFMT_FLAG_FLOAT 0x00000200
4280c2c66affSColin Finck #define WINED3DFMT_FLAG_BUMPMAP 0x00000400
4281c2c66affSColin Finck #define WINED3DFMT_FLAG_SRGB_READ 0x00000800
4282c2c66affSColin Finck #define WINED3DFMT_FLAG_SRGB_WRITE 0x00001000
4283c2c66affSColin Finck #define WINED3DFMT_FLAG_VTF 0x00002000
4284c2c66affSColin Finck #define WINED3DFMT_FLAG_SHADOW 0x00004000
4285c2c66affSColin Finck #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
4286c2c66affSColin Finck #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
4287c2c66affSColin Finck #define WINED3DFMT_FLAG_BLOCKS 0x00020000
4288c2c66affSColin Finck #define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
4289c2c66affSColin Finck #define WINED3DFMT_FLAG_TEXTURE 0x00080000
4290c2c66affSColin Finck #define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
4291c2c66affSColin Finck #define WINED3DFMT_FLAG_INTEGER 0x00200000
42929987f029SAmine Khaldi #define WINED3DFMT_FLAG_GEN_MIPMAP 0x00400000
4293c2c66affSColin Finck
4294c2c66affSColin Finck struct wined3d_rational
4295c2c66affSColin Finck {
4296c2c66affSColin Finck UINT numerator;
4297c2c66affSColin Finck UINT denominator;
4298c2c66affSColin Finck };
4299c2c66affSColin Finck
4300c2c66affSColin Finck struct wined3d_color_key_conversion
4301c2c66affSColin Finck {
4302c2c66affSColin Finck enum wined3d_format_id dst_format;
4303*81cffd76SJoachim Henze void (*convert)(const BYTE *src, unsigned int src_pitch, BYTE *dst, unsigned int dst_pitch, unsigned int width,
4304*81cffd76SJoachim Henze unsigned int height, const struct wined3d_palette *palette, const struct wined3d_color_key *color_key);
4305c2c66affSColin Finck };
4306c2c66affSColin Finck
4307c2c66affSColin Finck struct wined3d_format
4308c2c66affSColin Finck {
4309c2c66affSColin Finck enum wined3d_format_id id;
4310c2c66affSColin Finck
4311c2c66affSColin Finck D3DDDIFORMAT ddi_format;
4312c2c66affSColin Finck DWORD red_size;
4313c2c66affSColin Finck DWORD green_size;
4314c2c66affSColin Finck DWORD blue_size;
4315c2c66affSColin Finck DWORD alpha_size;
4316c2c66affSColin Finck DWORD red_offset;
4317c2c66affSColin Finck DWORD green_offset;
4318c2c66affSColin Finck DWORD blue_offset;
4319c2c66affSColin Finck DWORD alpha_offset;
4320c2c66affSColin Finck UINT byte_count;
4321c2c66affSColin Finck BYTE depth_size;
4322c2c66affSColin Finck BYTE stencil_size;
4323c2c66affSColin Finck
4324c2c66affSColin Finck UINT block_width;
4325c2c66affSColin Finck UINT block_height;
4326c2c66affSColin Finck UINT block_byte_count;
4327c2c66affSColin Finck
4328c2c66affSColin Finck enum wined3d_ffp_emit_idx emit_idx;
4329c2c66affSColin Finck GLint component_count;
4330c2c66affSColin Finck GLenum gl_vtx_type;
4331c2c66affSColin Finck GLint gl_vtx_format;
4332c2c66affSColin Finck GLboolean gl_normalized;
4333c2c66affSColin Finck unsigned int attribute_size;
4334c2c66affSColin Finck
4335c2c66affSColin Finck GLint glInternal;
4336c2c66affSColin Finck GLint glGammaInternal;
4337c2c66affSColin Finck GLint rtInternal;
4338c2c66affSColin Finck GLint glFormat;
4339c2c66affSColin Finck GLint glType;
4340c2c66affSColin Finck UINT conv_byte_count;
4341c2c66affSColin Finck DWORD multisample_types;
4342c2c66affSColin Finck unsigned int flags[WINED3D_GL_RES_TYPE_COUNT];
4343d6ac0a71SAmine Khaldi float depth_bias_scale;
4344c2c66affSColin Finck struct wined3d_rational height_scale;
4345c2c66affSColin Finck struct color_fixup_desc color_fixup;
4346d6ac0a71SAmine Khaldi void (*upload)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4347d6ac0a71SAmine Khaldi unsigned int dst_row_pitch, unsigned dst_slice_pitch,
4348d6ac0a71SAmine Khaldi unsigned int width, unsigned int height, unsigned int depth);
4349d6ac0a71SAmine Khaldi void (*download)(const BYTE *src, BYTE *dst, unsigned int src_row_pitch, unsigned int src_slice_pitch,
4350d6ac0a71SAmine Khaldi unsigned int dst_row_pitch, unsigned dst_slice_pitch,
4351d6ac0a71SAmine Khaldi unsigned int width, unsigned int height, unsigned int depth);
4352c2c66affSColin Finck
4353c2c66affSColin Finck enum wined3d_format_id typeless_id;
4354c2c66affSColin Finck GLenum gl_view_class;
4355c2c66affSColin Finck };
4356c2c66affSColin Finck
4357c2c66affSColin Finck const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,
4358c2c66affSColin Finck enum wined3d_format_id format_id, unsigned int resource_usage) DECLSPEC_HIDDEN;
4359c2c66affSColin Finck void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
4360c2c66affSColin Finck unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
4361c2c66affSColin Finck UINT wined3d_format_calculate_size(const struct wined3d_format *format,
4362c2c66affSColin Finck UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
4363c2c66affSColin Finck DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
4364c2c66affSColin Finck const struct wined3d_color *color) DECLSPEC_HIDDEN;
4365c2c66affSColin Finck void wined3d_format_get_float_color_key(const struct wined3d_format *format,
4366c2c66affSColin Finck const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
4367d6ac0a71SAmine Khaldi BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
4368d6ac0a71SAmine Khaldi enum wined3d_format_id view_format_id) DECLSPEC_HIDDEN;
4369c2c66affSColin Finck const struct wined3d_color_key_conversion * wined3d_format_get_color_key_conversion(
4370c2c66affSColin Finck const struct wined3d_texture *texture, BOOL need_alpha_ck) DECLSPEC_HIDDEN;
4371d6ac0a71SAmine Khaldi BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1,
4372d6ac0a71SAmine Khaldi enum wined3d_format_id format2) DECLSPEC_HIDDEN;
4373c2c66affSColin Finck
4374c2c66affSColin Finck BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size) DECLSPEC_HIDDEN;
4375c2c66affSColin Finck
wined3d_format_is_typeless(const struct wined3d_format * format)4376c2c66affSColin Finck static inline BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
4377c2c66affSColin Finck {
4378c2c66affSColin Finck return format->id == format->typeless_id && format->id != WINED3DFMT_UNKNOWN;
4379c2c66affSColin Finck }
4380c2c66affSColin Finck
use_indexed_vertex_blending(const struct wined3d_state * state,const struct wined3d_stream_info * si)43819987f029SAmine Khaldi static inline BOOL use_indexed_vertex_blending(const struct wined3d_state *state, const struct wined3d_stream_info *si)
4382c2c66affSColin Finck {
43839987f029SAmine Khaldi if (!state->render_states[WINED3D_RS_INDEXEDVERTEXBLENDENABLE])
43849987f029SAmine Khaldi return FALSE;
43859987f029SAmine Khaldi
43869987f029SAmine Khaldi if (state->render_states[WINED3D_RS_VERTEXBLEND] == WINED3D_VBF_DISABLE)
43879987f029SAmine Khaldi return FALSE;
43889987f029SAmine Khaldi
43899987f029SAmine Khaldi if (!(si->use_map & (1 << WINED3D_FFP_BLENDINDICES)) || !(si->use_map & (1 << WINED3D_FFP_BLENDWEIGHT)))
43909987f029SAmine Khaldi return FALSE;
43919987f029SAmine Khaldi
43929987f029SAmine Khaldi return TRUE;
43939987f029SAmine Khaldi }
43949987f029SAmine Khaldi
use_software_vertex_processing(const struct wined3d_device * device)43959987f029SAmine Khaldi static inline BOOL use_software_vertex_processing(const struct wined3d_device *device)
43969987f029SAmine Khaldi {
43979987f029SAmine Khaldi if (device->shader_backend != &glsl_shader_backend)
43989987f029SAmine Khaldi return FALSE;
43999987f029SAmine Khaldi
44009987f029SAmine Khaldi if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING)
44019987f029SAmine Khaldi return TRUE;
44029987f029SAmine Khaldi
44039987f029SAmine Khaldi if (!(device->create_parms.flags & WINED3DCREATE_MIXED_VERTEXPROCESSING))
44049987f029SAmine Khaldi return FALSE;
44059987f029SAmine Khaldi
44069987f029SAmine Khaldi return device->softwareVertexProcessing;
4407c2c66affSColin Finck }
4408c2c66affSColin Finck
use_vs(const struct wined3d_state * state)4409c2c66affSColin Finck static inline BOOL use_vs(const struct wined3d_state *state)
4410c2c66affSColin Finck {
4411c2c66affSColin Finck /* Check state->vertex_declaration to allow this to be used before the
4412c2c66affSColin Finck * stream info is validated, for example in device_update_tex_unit_map(). */
4413c2c66affSColin Finck return state->shader[WINED3D_SHADER_TYPE_VERTEX]
4414c2c66affSColin Finck && (!state->vertex_declaration || !state->vertex_declaration->position_transformed);
4415c2c66affSColin Finck }
4416c2c66affSColin Finck
use_ps(const struct wined3d_state * state)4417c2c66affSColin Finck static inline BOOL use_ps(const struct wined3d_state *state)
4418c2c66affSColin Finck {
4419c2c66affSColin Finck return !!state->shader[WINED3D_SHADER_TYPE_PIXEL];
4420c2c66affSColin Finck }
4421c2c66affSColin Finck
context_apply_state(struct wined3d_context * context,const struct wined3d_state * state,DWORD state_id)4422c2c66affSColin Finck static inline void context_apply_state(struct wined3d_context *context,
4423c2c66affSColin Finck const struct wined3d_state *state, DWORD state_id)
4424c2c66affSColin Finck {
4425c2c66affSColin Finck const struct StateEntry *state_table = context->state_table;
4426c2c66affSColin Finck DWORD rep = state_table[state_id].representative;
4427c2c66affSColin Finck state_table[rep].apply(context, state, rep);
4428c2c66affSColin Finck }
4429c2c66affSColin Finck
needs_separate_srgb_gl_texture(const struct wined3d_context * context,const struct wined3d_texture * texture)4430c2c66affSColin Finck static inline BOOL needs_separate_srgb_gl_texture(const struct wined3d_context *context,
4431c2c66affSColin Finck const struct wined3d_texture *texture)
4432c2c66affSColin Finck {
4433c2c66affSColin Finck unsigned int flags = texture->resource.format_flags
4434c2c66affSColin Finck & (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE);
4435c2c66affSColin Finck
4436c2c66affSColin Finck return (!context->gl_info->supported[EXT_TEXTURE_SRGB_DECODE]
4437c2c66affSColin Finck || (flags && flags != (WINED3DFMT_FLAG_SRGB_READ | WINED3DFMT_FLAG_SRGB_WRITE)))
4438c2c66affSColin Finck && context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL;
4439c2c66affSColin Finck }
4440c2c66affSColin Finck
needs_srgb_write(const struct wined3d_context * context,const struct wined3d_state * state,const struct wined3d_fb_state * fb)4441c2c66affSColin Finck static inline BOOL needs_srgb_write(const struct wined3d_context *context,
4442c2c66affSColin Finck const struct wined3d_state *state, const struct wined3d_fb_state *fb)
4443c2c66affSColin Finck {
4444c2c66affSColin Finck return (!(context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
4445c2c66affSColin Finck || state->render_states[WINED3D_RS_SRGBWRITEENABLE])
4446c2c66affSColin Finck && fb->render_targets[0] && fb->render_targets[0]->format_flags & WINED3DFMT_FLAG_SRGB_WRITE;
4447c2c66affSColin Finck }
4448c2c66affSColin Finck
wined3d_texture_get_texture_name(const struct wined3d_texture * texture,const struct wined3d_context * context,BOOL srgb)4449c2c66affSColin Finck static inline GLuint wined3d_texture_get_texture_name(const struct wined3d_texture *texture,
4450c2c66affSColin Finck const struct wined3d_context *context, BOOL srgb)
4451c2c66affSColin Finck {
4452c2c66affSColin Finck return srgb && needs_separate_srgb_gl_texture(context, texture)
4453c2c66affSColin Finck ? texture->texture_srgb.name : texture->texture_rgb.name;
4454c2c66affSColin Finck }
4455c2c66affSColin Finck
can_use_texture_swizzle(const struct wined3d_gl_info * gl_info,const struct wined3d_format * format)4456c2c66affSColin Finck static inline BOOL can_use_texture_swizzle(const struct wined3d_gl_info *gl_info, const struct wined3d_format *format)
4457c2c66affSColin Finck {
4458c2c66affSColin Finck return gl_info->supported[ARB_TEXTURE_SWIZZLE] && !is_complex_fixup(format->color_fixup)
4459c2c66affSColin Finck && !is_scaling_fixup(format->color_fixup);
4460c2c66affSColin Finck }
4461c2c66affSColin Finck
needs_interpolation_qualifiers_for_shader_outputs(const struct wined3d_gl_info * gl_info)4462d6ac0a71SAmine Khaldi static inline BOOL needs_interpolation_qualifiers_for_shader_outputs(const struct wined3d_gl_info *gl_info)
4463d6ac0a71SAmine Khaldi {
4464d6ac0a71SAmine Khaldi /* In GLSL 4.40+ it is fine to specify interpolation qualifiers only in
4465d6ac0a71SAmine Khaldi * fragment shaders. In older GLSL versions interpolation qualifiers must
4466d6ac0a71SAmine Khaldi * match between shader stages.
4467d6ac0a71SAmine Khaldi */
4468d6ac0a71SAmine Khaldi return gl_info->glsl_version < MAKEDWORD_VERSION(4, 40);
4469d6ac0a71SAmine Khaldi }
4470d6ac0a71SAmine Khaldi
is_rasterization_disabled(const struct wined3d_shader * geometry_shader)4471d6ac0a71SAmine Khaldi static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geometry_shader)
4472d6ac0a71SAmine Khaldi {
4473d6ac0a71SAmine Khaldi return geometry_shader
4474d6ac0a71SAmine Khaldi && geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM;
4475d6ac0a71SAmine Khaldi }
4476d6ac0a71SAmine Khaldi
wined3d_bit_scan(unsigned int * x)44779987f029SAmine Khaldi static inline int wined3d_bit_scan(unsigned int *x)
44789987f029SAmine Khaldi {
44799987f029SAmine Khaldi int bit_offset = ffs(*x) - 1;
44809987f029SAmine Khaldi *x ^= 1u << bit_offset;
44819987f029SAmine Khaldi return bit_offset;
44829987f029SAmine Khaldi }
44839987f029SAmine Khaldi
wined3d_extract_bits(const DWORD * bitstream,unsigned int offset,unsigned int count)4484d6ac0a71SAmine Khaldi static inline DWORD wined3d_extract_bits(const DWORD *bitstream,
4485d6ac0a71SAmine Khaldi unsigned int offset, unsigned int count)
4486d6ac0a71SAmine Khaldi {
4487d6ac0a71SAmine Khaldi const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
4488d6ac0a71SAmine Khaldi const unsigned int idx = offset / word_bit_count;
4489d6ac0a71SAmine Khaldi const unsigned int shift = offset % word_bit_count;
4490d6ac0a71SAmine Khaldi DWORD mask = (1u << count) - 1;
4491d6ac0a71SAmine Khaldi DWORD ret;
4492d6ac0a71SAmine Khaldi
4493d6ac0a71SAmine Khaldi ret = (bitstream[idx] >> shift) & mask;
4494d6ac0a71SAmine Khaldi if (shift + count > word_bit_count)
4495d6ac0a71SAmine Khaldi {
4496d6ac0a71SAmine Khaldi const unsigned int extracted_bit_count = word_bit_count - shift;
4497d6ac0a71SAmine Khaldi const unsigned int remaining_bit_count = count - extracted_bit_count;
4498d6ac0a71SAmine Khaldi mask = (1u << remaining_bit_count) - 1;
4499d6ac0a71SAmine Khaldi ret |= (bitstream[idx + 1] & mask) << extracted_bit_count;
4500d6ac0a71SAmine Khaldi }
4501d6ac0a71SAmine Khaldi return ret;
4502d6ac0a71SAmine Khaldi }
4503d6ac0a71SAmine Khaldi
wined3d_insert_bits(DWORD * bitstream,unsigned int offset,unsigned int count,DWORD bits)4504d6ac0a71SAmine Khaldi static inline void wined3d_insert_bits(DWORD *bitstream,
4505d6ac0a71SAmine Khaldi unsigned int offset, unsigned int count, DWORD bits)
4506d6ac0a71SAmine Khaldi {
4507d6ac0a71SAmine Khaldi const unsigned int word_bit_count = sizeof(*bitstream) * CHAR_BIT;
4508d6ac0a71SAmine Khaldi const unsigned int idx = offset / word_bit_count;
4509d6ac0a71SAmine Khaldi const unsigned int shift = offset % word_bit_count;
4510d6ac0a71SAmine Khaldi DWORD mask = (1u << count) - 1;
4511d6ac0a71SAmine Khaldi
4512d6ac0a71SAmine Khaldi bitstream[idx] |= (bits & mask) << shift;
4513d6ac0a71SAmine Khaldi if (shift + count > word_bit_count)
4514d6ac0a71SAmine Khaldi {
4515d6ac0a71SAmine Khaldi const unsigned int inserted_bit_count = word_bit_count - shift;
4516d6ac0a71SAmine Khaldi const unsigned int remaining_bit_count = count - inserted_bit_count;
4517d6ac0a71SAmine Khaldi mask = (1u << remaining_bit_count) - 1;
4518d6ac0a71SAmine Khaldi bitstream[idx + 1] |= (bits >> inserted_bit_count) & mask;
4519d6ac0a71SAmine Khaldi }
4520d6ac0a71SAmine Khaldi }
4521d6ac0a71SAmine Khaldi
context_get_rt_surface(const struct wined3d_context * context)4522*81cffd76SJoachim Henze static inline struct wined3d_surface *context_get_rt_surface(const struct wined3d_context *context)
4523*81cffd76SJoachim Henze {
4524*81cffd76SJoachim Henze struct wined3d_texture *texture = context->current_rt.texture;
4525*81cffd76SJoachim Henze
4526*81cffd76SJoachim Henze if (!texture)
4527*81cffd76SJoachim Henze return NULL;
4528*81cffd76SJoachim Henze return texture->sub_resources[context->current_rt.sub_resource_idx].u.surface;
4529*81cffd76SJoachim Henze }
4530*81cffd76SJoachim Henze
wined3d_from_cs(const struct wined3d_cs * cs)4531c2c66affSColin Finck static inline void wined3d_from_cs(const struct wined3d_cs *cs)
4532c2c66affSColin Finck {
4533c2c66affSColin Finck if (cs->thread)
4534c2c66affSColin Finck assert(cs->thread_id == GetCurrentThreadId());
4535c2c66affSColin Finck }
4536c2c66affSColin Finck
wined3d_not_from_cs(struct wined3d_cs * cs)4537c2c66affSColin Finck static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
4538c2c66affSColin Finck {
4539c2c66affSColin Finck assert(cs->thread_id != GetCurrentThreadId());
4540c2c66affSColin Finck }
4541c2c66affSColin Finck
45429987f029SAmine Khaldi BOOL wined3d_dxtn_init(void) DECLSPEC_HIDDEN;
45439987f029SAmine Khaldi void wined3d_dxtn_free(void) DECLSPEC_HIDDEN;
45449987f029SAmine Khaldi
4545c2c66affSColin Finck /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
4546c2c66affSColin Finck #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
4547c2c66affSColin Finck
4548c2c66affSColin Finck #endif
4549