ReactOS  0.4.13-dev-79-gcd489d8
wined3d_private.h
Go to the documentation of this file.
1 /*
2  * Direct3D wine internal private include file
3  *
4  * Copyright 2002-2003 The wine-d3d team
5  * Copyright 2002-2003 Raphael Junqueira
6  * Copyright 2002-2003, 2004 Jason Edmeades
7  * Copyright 2005 Oliver Stieber
8  * Copyright 2006-2011, 2013 Stefan Dösinger for CodeWeavers
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef __WINE_WINED3D_PRIVATE_H
26 #define __WINE_WINED3D_PRIVATE_H
27 
28 #ifdef USE_WIN32_OPENGL
29 #define WINE_GLAPI __stdcall
30 #else
31 #define WINE_GLAPI
32 #endif
33 
34 #include <assert.h>
35 #include <stdarg.h>
36 #include <math.h>
37 #include <limits.h>
38 #include "ntstatus.h"
39 #define WIN32_NO_STATUS
40 #define NONAMELESSUNION
41 #define NONAMELESSSTRUCT
42 #define COBJMACROS
43 #include "windef.h"
44 #include "winbase.h"
45 #include "winreg.h"
46 #include "wingdi.h"
47 #include "winuser.h"
48 #include "winternl.h"
49 #include "ddk/d3dkmthk.h"
50 #include "wine/debug.h"
51 #include "wine/heap.h"
52 #include "wine/unicode.h"
53 
54 #include "objbase.h"
55 #include "wine/wined3d.h"
56 #include "wined3d_gl.h"
57 #include "wine/list.h"
58 #include "wine/rbtree.h"
59 #include "wine/wgl_driver.h"
60 
61 #ifndef ARRAY_SIZE
62 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
63 #endif
64 
65 #define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
66 
67 /* Driver quirks */
68 #define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
69 #define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
70 #define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
71 #define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
72 #define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
73 #define WINED3D_QUIRK_FBO_TEX_UPDATE 0x00000020
74 #define WINED3D_QUIRK_BROKEN_RGBA16 0x00000040
75 #define WINED3D_QUIRK_INFO_LOG_SPAM 0x00000080
76 #define WINED3D_QUIRK_LIMITED_TEX_FILTERING 0x00000100
77 #define WINED3D_QUIRK_BROKEN_ARB_FOG 0x00000200
78 
80 {
97 };
98 
100 {
120 };
121 
122 /* Texture format fixups */
123 
125 {
134 };
135 
137 {
144 };
145 
146 #include <pshpack2.h>
148 {
149  unsigned short x_sign_fixup : 1;
150  unsigned short x_source : 3;
151  unsigned short y_sign_fixup : 1;
152  unsigned short y_source : 3;
153  unsigned short z_sign_fixup : 1;
154  unsigned short z_source : 3;
155  unsigned short w_sign_fixup : 1;
156  unsigned short w_source : 3;
157 };
158 #include <poppack.h>
159 
161 {
165  unsigned int varying_count;
166  unsigned int ffp_textures;
167  unsigned int ffp_blend_stages;
169  unsigned int active_light_count;
170 };
171 
172 typedef void (WINE_GLAPI *wined3d_ffp_attrib_func)(const void *data);
175 extern wined3d_ffp_attrib_func specular_func_3ubv DECLSPEC_HIDDEN;
176 
178 {
185 };
186 
188 {
189  struct wined3d_d3d_limits limits;
190  struct wined3d_ffp_attrib_ops ffp_attrib_ops;
200 };
201 
204 
206  int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1,
207  int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)
208 {
209  struct color_fixup_desc fixup =
210  {
211  sign0, src0,
212  sign1, src1,
213  sign2, src2,
214  sign3, src3,
215  };
216  return fixup;
217 }
218 
220 {
221  struct color_fixup_desc fixup =
222  {
227  };
228  return fixup;
229 }
230 
231 static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
232 {
233  return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
234 }
235 
236 static inline BOOL is_complex_fixup(struct color_fixup_desc fixup)
237 {
239 }
240 
241 static inline BOOL is_scaling_fixup(struct color_fixup_desc fixup)
242 {
243  return fixup.x_sign_fixup || fixup.y_sign_fixup || fixup.z_sign_fixup || fixup.w_sign_fixup;
244 }
245 
247 {
248  return f1.x_sign_fixup == f2.x_sign_fixup && f1.x_source == f2.x_source
249  && f1.y_sign_fixup == f2.y_sign_fixup && f1.y_source == f2.y_source
250  && f1.z_sign_fixup == f2.z_sign_fixup && f1.z_source == f2.z_source
251  && f1.w_sign_fixup == f2.w_sign_fixup && f1.w_source == f2.w_source;
252 }
253 
254 static inline enum complex_fixup get_complex_fixup(struct color_fixup_desc fixup)
255 {
256  enum complex_fixup complex_fixup = 0;
257  if (fixup.x_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 0);
258  if (fixup.y_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 1);
259  if (fixup.z_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 2);
260  if (fixup.w_source == CHANNEL_SOURCE_COMPLEX1) complex_fixup |= (1u << 3);
261  return complex_fixup;
262 }
263 
264 /* Device caps */
265 #define MAX_STREAMS 16
266 #define MAX_TEXTURES 8
267 #define MAX_FRAGMENT_SAMPLERS 16
268 #define MAX_VERTEX_SAMPLERS 4
269 #define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
270 #define MAX_ACTIVE_LIGHTS 8
271 #define MAX_CLIP_DISTANCES 8
272 #define MAX_CONSTANT_BUFFERS 15
273 #define MAX_SAMPLER_OBJECTS 16
274 #define MAX_SHADER_RESOURCE_VIEWS 128
275 #define MAX_RENDER_TARGET_VIEWS 8
276 #define MAX_UNORDERED_ACCESS_VIEWS 8
277 #define MAX_TGSM_REGISTERS 8192
278 #define MAX_VERTEX_BLENDS 4
279 #define MAX_VERTEX_INDEX_BLENDS 9
280 #define MAX_RENDER_TARGETS 8
281 
283 {
285 };
286 
289 
291 
293 {
295  return WINED3D_CMP_ALWAYS;
296  return func;
297 }
298 
300 {
301  return magLookup[mag_filter];
302 }
303 
305  enum wined3d_texture_filter_type mip_filter)
306 {
307  return minMipLookup[min_filter].mip[mip_filter];
308 }
309 
310 /* float_16_to_32() and float_32_to_16() (see implementation in
311  * surface_base.c) convert 16 bit floats in the FLOAT16 data type
312  * to standard C floats and vice versa. They do not depend on the encoding
313  * of the C float, so they are platform independent, but slow. On x86 and
314  * other IEEE 754 compliant platforms the conversion can be accelerated by
315  * bit shifting the exponent and mantissa. There are also some SSE-based
316  * assembly routines out there.
317  *
318  * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
319  */
320 static inline float float_16_to_32(const unsigned short *in)
321 {
322  const unsigned short s = ((*in) & 0x8000u);
323  const unsigned short e = ((*in) & 0x7c00u) >> 10;
324  const unsigned short m = (*in) & 0x3ffu;
325  const float sgn = (s ? -1.0f : 1.0f);
326 
327  if(e == 0) {
328  if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
329  else return sgn * powf(2, -14.0f) * ((float)m / 1024.0f);
330  } else if(e < 31) {
331  return sgn * powf(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
332  } else {
333  if(m == 0) return sgn * INFINITY;
334  else return NAN;
335  }
336 }
337 
338 static inline float float_24_to_32(DWORD in)
339 {
340  const float sgn = in & 0x800000u ? -1.0f : 1.0f;
341  const unsigned short e = (in & 0x780000u) >> 19;
342  const unsigned int m = in & 0x7ffffu;
343 
344  if (e == 0)
345  {
346  if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
347  else return sgn * powf(2, -6.0f) * ((float)m / 524288.0f);
348  }
349  else if (e < 15)
350  {
351  return sgn * powf(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
352  }
353  else
354  {
355  if (m == 0) return sgn * INFINITY;
356  else return NAN;
357  }
358 }
359 
360 static inline unsigned int wined3d_popcount(unsigned int x)
361 {
362 #ifdef HAVE___BUILTIN_POPCOUNT
363  return __builtin_popcount(x);
364 #else
365  x -= x >> 1 & 0x55555555;
366  x = (x & 0x33333333) + (x >> 2 & 0x33333333);
367  return ((x + (x >> 4)) & 0x0f0f0f0f) * 0x01010101 >> 24;
368 #endif
369 }
370 
371 static inline void wined3d_pause(void)
372 {
373 #ifdef __REACTOS__
374  Sleep(0);
375 #else
376 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
377  __asm__ __volatile__( "rep;nop" : : : "memory" );
378 #endif
379 #endif
380 }
381 
382 #define ORM_BACKBUFFER 0
383 #define ORM_FBO 1
384 
385 #define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
386 #define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
387 
388 /* NOTE: When adding fields to this structure, make sure to update the default
389  * values in wined3d_main.c as well. */
391 {
392  unsigned int cs_multithreaded;
397  unsigned short pci_vendor_id;
398  unsigned short pci_device_id;
399  /* Memory tracking and object counting. */
401  char *logo;
402  unsigned int multisample_textures;
403  unsigned int sample_count;
405  unsigned int max_sm_vs;
406  unsigned int max_sm_hs;
407  unsigned int max_sm_ds;
408  unsigned int max_sm_gs;
409  unsigned int max_sm_ps;
410  unsigned int max_sm_cs;
412 };
413 
415 
417 {
429 };
430 
431 #define WINED3D_SHADER_CONST_VS_F 0x00000001
432 #define WINED3D_SHADER_CONST_VS_I 0x00000002
433 #define WINED3D_SHADER_CONST_VS_B 0x00000004
434 #define WINED3D_SHADER_CONST_VS_CLIP_PLANES 0x00000008
435 #define WINED3D_SHADER_CONST_VS_POINTSIZE 0x00000010
436 #define WINED3D_SHADER_CONST_POS_FIXUP 0x00000020
437 #define WINED3D_SHADER_CONST_PS_F 0x00000040
438 #define WINED3D_SHADER_CONST_PS_I 0x00000080
439 #define WINED3D_SHADER_CONST_PS_B 0x00000100
440 #define WINED3D_SHADER_CONST_PS_BUMP_ENV 0x00000200
441 #define WINED3D_SHADER_CONST_PS_FOG 0x00000400
442 #define WINED3D_SHADER_CONST_PS_ALPHA_TEST 0x00000800
443 #define WINED3D_SHADER_CONST_PS_Y_CORR 0x00001000
444 #define WINED3D_SHADER_CONST_PS_NP2_FIXUP 0x00002000
445 #define WINED3D_SHADER_CONST_FFP_MODELVIEW 0x00004000
446 #define WINED3D_SHADER_CONST_FFP_PROJ 0x00010000
447 #define WINED3D_SHADER_CONST_FFP_TEXMATRIX 0x00020000
448 #define WINED3D_SHADER_CONST_FFP_MATERIAL 0x00040000
449 #define WINED3D_SHADER_CONST_FFP_LIGHTS 0x00080000
450 #define WINED3D_SHADER_CONST_FFP_PS 0x00100000
451 #define WINED3D_SHADER_CONST_FFP_COLOR_KEY 0x00200000
452 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND 0xff000000
453 #define WINED3D_SHADER_CONST_FFP_VERTEXBLEND_INDEX(i) (0x01000000 << ((i) - 1))
454 
456 {
508 };
509 
511 {
521 };
522 
524 {
527 };
528 
529 #define WINED3DSP_NOSWIZZLE (0u | (1u << 2) | (2u << 4) | (3u << 6))
530 
532 {
547 };
548 
549 #define WINED3DSP_WRITEMASK_0 0x1u /* .x r */
550 #define WINED3DSP_WRITEMASK_1 0x2u /* .y g */
551 #define WINED3DSP_WRITEMASK_2 0x4u /* .z b */
552 #define WINED3DSP_WRITEMASK_3 0x8u /* .w a */
553 #define WINED3DSP_WRITEMASK_ALL 0xfu /* all */
554 
556 {
561 };
562 
564 {
573 };
574 
575 #define WINED3D_PACKED_INTERPOLATION_SIZE 3
576 #define WINED3D_PACKED_INTERPOLATION_BIT_COUNT 3
577 
579 {
583 };
584 
586 {
589 };
590 
592 {
595 };
596 
598 {
602 };
603 
605 {
610 };
611 
613 {
618 };
619 
620 /* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
621 #define WINED3DSI_TEXLD_PROJECT 0x1
622 #define WINED3DSI_TEXLD_BIAS 0x2
623 #define WINED3DSI_INDEXED_DYNAMIC 0x4
624 #define WINED3DSI_RESINFO_RCP_FLOAT 0x1
625 #define WINED3DSI_RESINFO_UINT 0x2
626 #define WINED3DSI_SAMPLE_INFO_UINT 0x1
627 #define WINED3DSI_SAMPLER_COMPARISON_MODE 0x1
628 
629 #define WINED3DSI_PRECISE_X 0x100
630 #define WINED3DSI_PRECISE_Y 0x200
631 #define WINED3DSI_PRECISE_Z 0x400
632 #define WINED3DSI_PRECISE_W 0x800
633 #define WINED3DSI_PRECISE_XYZW (WINED3DSI_PRECISE_X | WINED3DSI_PRECISE_Y \
634  | WINED3DSI_PRECISE_Z | WINED3DSI_PRECISE_W)
635 #define WINED3DSI_PRECISE_SHIFT 8
636 
638 {
645 };
646 
648 {
651 };
652 
653 #define WINED3D_SM1_VS 0xfffeu
654 #define WINED3D_SM1_PS 0xffffu
655 #define WINED3D_SM4_PS 0x0000u
656 #define WINED3D_SM4_VS 0x0001u
657 #define WINED3D_SM4_GS 0x0002u
658 #define WINED3D_SM5_HS 0x0003u
659 #define WINED3D_SM5_DS 0x0004u
660 #define WINED3D_SM5_CS 0x0005u
661 
662 /* Shader version tokens, and shader end tokens */
663 #define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
664 #define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
665 
666 /* Shader backends */
667 
668 /* TODO: Make this dynamic, based on shader limits ? */
669 #define MAX_ATTRIBS 16
670 #define MAX_REG_ADDR 1
671 #define MAX_REG_TEXCRD 8
672 #define MAX_REG_INPUT 32
673 #define MAX_REG_OUTPUT 32
674 #define WINED3D_MAX_CBS 15
675 #define WINED3D_MAX_CONSTS_B 16
676 #define WINED3D_MAX_CONSTS_I 16
677 #define WINED3D_MAX_VS_CONSTS_F 256
678 #define WINED3D_MAX_PS_CONSTS_F 224
679 
680 /* FIXME: This needs to go up to 2048 for
681  * Shader model 3 according to msdn (and for software shaders) */
682 #define MAX_LABELS 16
683 
684 #define MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE 4096
685 
687 {
688  struct list entry;
689  char *buffer;
690  unsigned int buffer_size;
691  unsigned int content_size;
692 };
693 
695 {
935 };
936 
938 {
945 
949 };
950 
952 {
956 };
957 
959 {
961  enum wined3d_data_type data_type;
962  unsigned int flags;
963  unsigned int stride;
964 };
965 
966 #define WINED3D_SAMPLER_DEFAULT ~0x0u
967 
969 {
970  unsigned int resource_idx;
971  unsigned int sampler_idx;
972  unsigned int bind_idx;
973 };
974 
976 {
978  size_t size;
979  size_t count;
980 };
981 
983 {
984  unsigned int vec4_count;
986 };
987 
989 {
990  struct list entry;
991  unsigned int register_idx;
992  unsigned int register_size;
993  unsigned int component_count;
994 };
995 
996 #define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
997 
999 {
1000  struct wined3d_shader_version shader_version;
1001  BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
1002  BYTE address; /* MAX_REG_ADDR, 1 */
1003  WORD labels; /* MAX_LABELS, 16 */
1004  DWORD temporary; /* 32 */
1005  unsigned int temporary_count;
1006  DWORD *constf; /* pixel, vertex */
1007  struct list indexable_temps;
1009  union
1010  {
1011  DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
1012  BYTE output_registers_mask[MAX_REG_OUTPUT]; /* vertex >= 3.0 */
1013  } u;
1014  DWORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 32 */
1015  DWORD output_registers; /* MAX_REG_OUTPUT, 32 */
1016  WORD integer_constants; /* WINED3D_MAX_CONSTS_I, 16 */
1017  WORD boolean_constants; /* WINED3D_MAX_CONSTS_B, 16 */
1018  WORD local_int_consts; /* WINED3D_MAX_CONSTS_I, 16 */
1019  WORD local_bool_consts; /* WINED3D_MAX_CONSTS_B, 16 */
1021 
1023  struct wined3d_shader_sampler_map sampler_map;
1025  BYTE bumpmat; /* MAX_TEXTURES, 8 */
1026  BYTE luminanceparams; /* MAX_TEXTURES, 8 */
1028  DWORD uav_read_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1029  DWORD uav_counter_mask : 8; /* MAX_UNORDERED_ACCESS_VIEWS, 8 */
1030 
1031  DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
1032  DWORD cull_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
1041  DWORD fog : 1;
1052 
1053  DWORD rt_mask; /* Used render targets, 32 max. */
1054 
1055  /* Whether or not loops are used in this shader, and nesting depth */
1056  unsigned int loop_depth;
1057  unsigned int min_rel_offset, max_rel_offset;
1058 
1061  unsigned int tgsm_count;
1062 };
1063 
1064 /* Keeps track of details for TEX_M#x# instructions which need to maintain
1065  * state information between multiple instructions. */
1067 {
1068  unsigned int current_row;
1069  DWORD texcoord_w[2];
1070 };
1071 
1073 {
1074  unsigned int current_loop_depth;
1075  unsigned int current_loop_reg;
1077 };
1078 
1080 {
1081  const struct wined3d_shader *shader;
1082  const struct wined3d_gl_info *gl_info;
1088 };
1089 
1091 {
1093  unsigned int offset;
1094 };
1095 
1097 {
1099  enum wined3d_data_type data_type;
1101  enum wined3d_immconst_type immconst_type;
1102  union
1103  {
1104  DWORD immconst_data[4];
1105  unsigned fp_body_idx;
1106  } u;
1107 };
1108 
1110 {
1115 };
1116 
1118 {
1122 };
1123 
1125 {
1126  struct wined3d_shader_dst_param first_register;
1127  unsigned int last_register;
1128 };
1129 
1131 {
1134  enum wined3d_shader_resource_type resource_type;
1135  enum wined3d_data_type resource_data_type;
1137 };
1138 
1140 {
1163 };
1164 
1166 {
1169 };
1170 
1172 {
1174  unsigned int byte_stride;
1175 };
1176 
1178 {
1179  unsigned int size;
1180  unsigned int stride;
1181 };
1182 
1184 {
1186  unsigned int byte_count;
1187 };
1188 
1190 {
1192  unsigned int byte_stride;
1193  unsigned int structure_count;
1194 };
1195 
1197 {
1198  unsigned int x, y, z;
1199 };
1200 
1202 {
1203  unsigned int index;
1204  unsigned int array_size;
1205  unsigned int body_count;
1206  unsigned int table_count;
1207 };
1208 
1210 {
1211  signed char u, v, w;
1212 };
1213 
1215 {
1217  unsigned int patch_vertex_count;
1218 };
1219 
1221 {
1225  unsigned int dst_count;
1226  unsigned int src_count;
1229  struct wined3d_shader_texel_offset texel_offset;
1232  union
1233  {
1234  struct wined3d_shader_semantic semantic;
1235  struct wined3d_shader_register_semantic register_semantic;
1236  struct wined3d_shader_primitive_type primitive_type;
1239  unsigned int count;
1240  unsigned int index;
1242  struct wined3d_shader_structured_resource structured_resource;
1243  struct wined3d_shader_tgsm_raw tgsm_raw;
1244  struct wined3d_shader_tgsm_structured tgsm_structured;
1245  struct wined3d_shader_thread_group_size thread_group_size;
1246  enum wined3d_tessellator_domain tessellator_domain;
1247  enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1248  enum wined3d_tessellator_partitioning tessellator_partitioning;
1250  struct wined3d_shader_index_range index_range;
1251  struct wined3d_shader_indexable_temp indexable_temp;
1253  } declaration;
1254 };
1255 
1257 {
1258  return ins->texel_offset.u || ins->texel_offset.v || ins->texel_offset.w;
1259 }
1260 
1262 {
1265 };
1266 
1268 {
1269  unsigned int count;
1270  unsigned int start;
1271  int step;
1272 };
1273 
1275 {
1276  void *(*shader_init)(const DWORD *byte_code, size_t byte_code_size,
1277  const struct wined3d_shader_signature *output_signature);
1278  void (*shader_free)(void *data);
1279  void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
1280  void (*shader_read_instruction)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins);
1281  BOOL (*shader_is_end)(void *data, const DWORD **ptr);
1282 };
1283 
1286 
1288  size_t byte_code_size) DECLSPEC_HIDDEN;
1289 
1291 
1292 #define WINED3D_SHADER_CAP_VS_CLIPPING 0x00000001
1293 #define WINED3D_SHADER_CAP_SRGB_WRITE 0x00000002
1294 #define WINED3D_SHADER_CAP_DOUBLE_PRECISION 0x00000004
1295 
1297 {
1298  unsigned int vs_version;
1299  unsigned int hs_version;
1300  unsigned int ds_version;
1301  unsigned int gs_version;
1302  unsigned int ps_version;
1303  unsigned int cs_version;
1304 
1309 
1311 };
1312 
1314 {
1323 };
1324 
1326 {
1330 };
1331 
1332 #define WINED3D_CONST_NUM_UNUSED ~0U
1333 
1335 {
1340 };
1341 
1342 /* Stateblock dependent parameters which have to be hardcoded
1343  * into the shader code
1344  */
1345 
1346 #define WINED3D_PSARGS_PROJECTED (1u << 3)
1347 #define WINED3D_PSARGS_TEXTRANSFORM_SHIFT 4
1348 #define WINED3D_PSARGS_TEXTRANSFORM_MASK 0xfu
1349 #define WINED3D_PSARGS_TEXTYPE_SHIFT 2
1350 #define WINED3D_PSARGS_TEXTYPE_MASK 0x3u
1351 
1352 /* Used for Shader Model 1 pixel shaders to track the bound texture
1353  * type. 2D and RECT textures are separated through NP2 fixup. */
1355 {
1359 };
1360 
1362 {
1366  WORD tex_transform; /* ps 1.0-1.3, 4 textures */
1367  WORD tex_types; /* ps 1.0 - 1.4, 6 textures */
1369  /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
1370  D3D9 has a limit of 16 samplers and the fixup is superfluous
1371  in D3D10 (unconditional NP2 support mandatory). */
1373  WORD shadow; /* MAX_FRAGMENT_SAMPLERS, 16 */
1374  WORD texcoords_initialized; /* MAX_TEXTURES, 8 */
1381 };
1382 
1384 {
1387 };
1388 
1390 {
1398  WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1401 };
1402 
1404 {
1405  enum wined3d_tessellator_output_primitive tessellator_output_primitive;
1406  enum wined3d_tessellator_partitioning tessellator_partitioning;
1407  unsigned int output_count : 16;
1408  unsigned int next_shader_type : 3;
1409  unsigned int render_offscreen : 1;
1410  unsigned int padding : 12;
1412 };
1413 
1415 {
1416  unsigned int output_count;
1417  enum wined3d_primitive_type primitive_type;
1419 };
1420 
1421 struct wined3d_context;
1422 struct wined3d_state;
1423 struct fragment_pipeline;
1425 
1427 {
1428  void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
1429  void (*shader_precompile)(void *shader_priv, struct wined3d_shader *shader);
1430  void (*shader_select)(void *shader_priv, struct wined3d_context *context,
1431  const struct wined3d_state *state);
1432  void (*shader_select_compute)(void *shader_priv, struct wined3d_context *context,
1433  const struct wined3d_state *state);
1434  void (*shader_disable)(void *shader_priv, struct wined3d_context *context);
1435  void (*shader_update_float_vertex_constants)(struct wined3d_device *device, UINT start, UINT count);
1436  void (*shader_update_float_pixel_constants)(struct wined3d_device *device, UINT start, UINT count);
1437  void (*shader_load_constants)(void *shader_priv, struct wined3d_context *context,
1438  const struct wined3d_state *state);
1439  void (*shader_destroy)(struct wined3d_shader *shader);
1440  HRESULT (*shader_alloc_private)(struct wined3d_device *device, const struct wined3d_vertex_pipe_ops *vertex_pipe,
1441  const struct fragment_pipeline *fragment_pipe);
1442  void (*shader_free_private)(struct wined3d_device *device);
1443  BOOL (*shader_allocate_context_data)(struct wined3d_context *context);
1444  void (*shader_free_context_data)(struct wined3d_context *context);
1445  void (*shader_init_context_state)(struct wined3d_context *context);
1446  void (*shader_get_caps)(const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
1447  BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
1448  BOOL (*shader_has_ffp_proj_control)(void *shader_priv);
1449 };
1450 
1454 
1455 #define GL_EXTCALL(f) (gl_info->gl_ops.ext.p_##f)
1456 
1457 #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xff)
1458 #define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xff)
1459 #define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xff)
1460 #define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xff)
1461 
1462 static inline void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
1463 {
1464  wined3d_color->r = D3DCOLOR_B_R(d3d_color) / 255.0f;
1465  wined3d_color->g = D3DCOLOR_B_G(d3d_color) / 255.0f;
1466  wined3d_color->b = D3DCOLOR_B_B(d3d_color) / 255.0f;
1467  wined3d_color->a = D3DCOLOR_B_A(d3d_color) / 255.0f;
1468 }
1469 
1470 #define HIGHEST_TRANSFORMSTATE WINED3D_TS_WORLD_MATRIX(255) /* Highest value in wined3d_transform_state. */
1471 
1472 void wined3d_check_gl_call(const struct wined3d_gl_info *gl_info,
1473  const char *file, unsigned int line, const char *name) DECLSPEC_HIDDEN;
1474 
1475 /* Checking of API calls */
1476 /* --------------------- */
1477 #ifndef WINE_NO_DEBUG_MSGS
1478 #define checkGLcall(A) \
1479 do { \
1480  if (__WINE_IS_DEBUG_ON(_ERR, &__wine_dbch_d3d) \
1481  && !gl_info->supported[ARB_DEBUG_OUTPUT]) \
1482  wined3d_check_gl_call(gl_info, __FILE__, __LINE__, A); \
1483 } while(0)
1484 #else
1485 #define checkGLcall(A) do {} while(0)
1486 #endif
1487 
1489 {
1492 };
1493 
1495 {
1497  const BYTE *addr;
1498 };
1499 
1501 {
1502  return (struct wined3d_const_bo_address *)data;
1503 }
1504 
1506 {
1507  const struct wined3d_format *format;
1510  unsigned int stream_idx;
1511  unsigned int divisor;
1512 };
1513 
1515 {
1519  WORD swizzle_map; /* MAX_ATTRIBS, 16 */
1520  WORD use_map; /* MAX_ATTRIBS, 16 */
1521 };
1522 
1524  const struct wined3d_state *state, const struct wined3d_gl_info *gl_info,
1525  const struct wined3d_d3d_info *d3d_info) DECLSPEC_HIDDEN;
1526 
1528 {
1529  unsigned int group_count_x;
1530  unsigned int group_count_y;
1531  unsigned int group_count_z;
1532 };
1533 
1535 {
1537  unsigned int offset;
1538 };
1539 
1541 {
1543  union
1544  {
1547  } u;
1548 };
1549 
1551 {
1553  unsigned int start_idx;
1554  unsigned int index_count;
1555  unsigned int start_instance;
1556  unsigned int instance_count;
1557 };
1558 
1560 {
1562  unsigned int offset;
1563 };
1564 
1566 {
1568  union
1569  {
1572  } u;
1574 };
1575 
1576 void draw_primitive(struct wined3d_device *device, const struct wined3d_state *state,
1577  const struct wined3d_draw_parameters *draw_parameters) DECLSPEC_HIDDEN;
1578 void dispatch_compute(struct wined3d_device *device, const struct wined3d_state *state,
1579  const struct wined3d_dispatch_parameters *dispatch_parameters) DECLSPEC_HIDDEN;
1581 
1582 #define eps 1e-8f
1583 
1584 #define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
1585  (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
1586 
1588 {
1592 };
1593 
1594 /* Routines and structures related to state management */
1595 
1596 #define STATE_RENDER(a) (a)
1597 #define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
1598 
1599 #define STATE_TEXTURESTAGE(stage, num) \
1600  (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
1601 #define STATE_IS_TEXTURESTAGE(a) \
1602  ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
1603 
1604 /* + 1 because samplers start with 0 */
1605 #define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
1606 #define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
1607 
1608 #define STATE_GRAPHICS_SHADER(a) (STATE_SAMPLER(MAX_COMBINED_SAMPLERS) + (a))
1609 #define STATE_IS_GRAPHICS_SHADER(a) \
1610  ((a) >= STATE_GRAPHICS_SHADER(0) && (a) < STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1611 
1612 #define STATE_GRAPHICS_CONSTANT_BUFFER(a) (STATE_GRAPHICS_SHADER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT) + (a))
1613 #define STATE_IS_GRAPHICS_CONSTANT_BUFFER(a) \
1614  ((a) >= STATE_GRAPHICS_CONSTANT_BUFFER(0) \
1615  && (a) < STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1616 
1617 #define STATE_GRAPHICS_SHADER_RESOURCE_BINDING (STATE_GRAPHICS_CONSTANT_BUFFER(WINED3D_SHADER_TYPE_GRAPHICS_COUNT))
1618 #define STATE_IS_GRAPHICS_SHADER_RESOURCE_BINDING(a) ((a) == STATE_GRAPHICS_SHADER_RESOURCE_BINDING)
1619 
1620 #define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING (STATE_GRAPHICS_SHADER_RESOURCE_BINDING + 1)
1621 #define STATE_IS_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING)
1622 
1623 #define STATE_TRANSFORM(a) (STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING + (a))
1624 #define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)))
1625 
1626 #define STATE_STREAMSRC (STATE_TRANSFORM(WINED3D_TS_WORLD_MATRIX(255)) + 1)
1627 #define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
1628 #define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
1629 #define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
1630 
1631 #define STATE_VDECL (STATE_INDEXBUFFER + 1)
1632 #define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
1633 
1634 #define STATE_VIEWPORT (STATE_VDECL + 1)
1635 #define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
1636 
1637 #define STATE_LIGHT_TYPE (STATE_VIEWPORT + 1)
1638 #define STATE_IS_LIGHT_TYPE(a) ((a) == STATE_LIGHT_TYPE)
1639 #define STATE_ACTIVELIGHT(a) (STATE_LIGHT_TYPE + 1 + (a))
1640 #define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS))
1641 
1642 #define STATE_SCISSORRECT (STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS - 1) + 1)
1643 #define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
1644 
1645 #define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
1646 #define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIP_DISTANCES - 1))
1647 
1648 #define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIP_DISTANCES))
1649 #define STATE_IS_MATERIAL(a) ((a) == STATE_MATERIAL)
1650 
1651 #define STATE_RASTERIZER (STATE_MATERIAL + 1)
1652 #define STATE_IS_RASTERIZER(a) ((a) == STATE_RASTERIZER)
1653 
1654 #define STATE_POINTSPRITECOORDORIGIN (STATE_RASTERIZER + 1)
1655 #define STATE_IS_POINTSPRITECOORDORIGIN(a) ((a) == STATE_POINTSPRITECOORDORIGIN)
1656 
1657 #define STATE_BASEVERTEXINDEX (STATE_POINTSPRITECOORDORIGIN + 1)
1658 #define STATE_IS_BASEVERTEXINDEX(a) ((a) == STATE_BASEVERTEXINDEX)
1659 
1660 #define STATE_FRAMEBUFFER (STATE_BASEVERTEXINDEX + 1)
1661 #define STATE_IS_FRAMEBUFFER(a) ((a) == STATE_FRAMEBUFFER)
1662 
1663 #define STATE_POINT_ENABLE (STATE_FRAMEBUFFER + 1)
1664 #define STATE_IS_POINT_ENABLE(a) ((a) == STATE_POINT_ENABLE)
1665 
1666 #define STATE_COLOR_KEY (STATE_POINT_ENABLE + 1)
1667 #define STATE_IS_COLOR_KEY(a) ((a) == STATE_COLOR_KEY)
1668 
1669 #define STATE_STREAM_OUTPUT (STATE_COLOR_KEY + 1)
1670 #define STATE_IS_STREAM_OUTPUT(a) ((a) == STATE_STREAM_OUTPUT)
1671 
1672 #define STATE_BLEND (STATE_STREAM_OUTPUT + 1)
1673 #define STATE_IS_BLEND(a) ((a) == STATE_BLEND)
1674 
1675 #define STATE_COMPUTE_OFFSET (STATE_BLEND + 1)
1676 
1677 #define STATE_COMPUTE_SHADER (STATE_COMPUTE_OFFSET)
1678 #define STATE_IS_COMPUTE_SHADER(a) ((a) == STATE_COMPUTE_SHADER)
1679 
1680 #define STATE_COMPUTE_CONSTANT_BUFFER (STATE_COMPUTE_SHADER + 1)
1681 #define STATE_IS_COMPUTE_CONSTANT_BUFFER(a) ((a) == STATE_COMPUTE_CONSTANT_BUFFER)
1682 
1683 #define STATE_COMPUTE_SHADER_RESOURCE_BINDING (STATE_COMPUTE_CONSTANT_BUFFER + 1)
1684 #define STATE_IS_COMPUTE_SHADER_RESOURCE_BINDING(a) ((a) == STATE_COMPUTE_SHADER_RESOURCE_BINDING)
1685 
1686 #define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING (STATE_COMPUTE_SHADER_RESOURCE_BINDING + 1)
1687 #define STATE_IS_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1688 
1689 #define STATE_COMPUTE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1690 #define STATE_HIGHEST (STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1691 
1692 #define STATE_IS_COMPUTE(a) ((a) >= STATE_COMPUTE_OFFSET && (a) <= STATE_COMPUTE_HIGHEST)
1693 #define STATE_COMPUTE_COUNT (STATE_COMPUTE_HIGHEST - STATE_COMPUTE_OFFSET + 1)
1694 
1695 #define STATE_SHADER(a) ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_SHADER(a) : STATE_COMPUTE_SHADER)
1696 #define STATE_CONSTANT_BUFFER(a) \
1697  ((a) != WINED3D_SHADER_TYPE_COMPUTE ? STATE_GRAPHICS_CONSTANT_BUFFER(a) : STATE_COMPUTE_CONSTANT_BUFFER)
1698 #define STATE_UNORDERED_ACCESS_VIEW_BINDING(a) ((a) == WINED3D_PIPELINE_GRAPHICS ? \
1699  STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING : STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING)
1700 
1705 };
1706 
1708 {
1711 };
1712 
1714 {
1720 };
1721 
1723 {
1724  struct list entry;
1727 };
1728 
1731 void wined3d_fence_issue(struct wined3d_fence *fence, const struct wined3d_device *device) DECLSPEC_HIDDEN;
1732 enum wined3d_fence_result wined3d_fence_wait(const struct wined3d_fence *fence,
1733  const struct wined3d_device *device) DECLSPEC_HIDDEN;
1734 
1735 /* Direct3D terminology with little modifications. We do not have an issued
1736  * state because only the driver knows about it, but we have a created state
1737  * because D3D allows GetData() on a created query, but OpenGL doesn't. */
1739 {
1743 };
1744 
1746 {
1747  BOOL (*query_poll)(struct wined3d_query *query, DWORD flags);
1748  BOOL (*query_issue)(struct wined3d_query *query, DWORD flags);
1749  void (*query_destroy)(struct wined3d_query *query);
1750 };
1751 
1753 {
1755 
1756  void *parent;
1761  const void *data;
1764 
1765  LONG counter_main, counter_retrieved;
1766  struct list poll_list_entry;
1767 };
1768 
1770 {
1772 
1773  struct wined3d_fence fence;
1775 };
1776 
1778 {
1780 
1781  struct list entry;
1786 };
1787 
1789 {
1791 
1792  struct list entry;
1796 };
1797 
1800 
1802 {
1803  GLuint id[2];
1804  struct
1805  {
1808  } query;
1809 };
1810 
1812 {
1814 
1815  struct list entry;
1818  unsigned int stream_idx;
1821 };
1822 
1826 
1828 {
1829  GLuint id[11];
1830  struct
1831  {
1843  } query;
1844 };
1845 
1847 {
1849 
1850  struct list entry;
1855 };
1856 
1860 
1862 {
1865 };
1866 
1868 {
1869  struct wined3d_gl_view gl_view;
1871  unsigned int sub_resource_idx;
1872  unsigned int layer_count;
1873 };
1874 
1875 #define MAX_GL_FRAGMENT_SAMPLERS 32
1876 
1878 {
1879  const struct wined3d_gl_info *gl_info;
1881  const struct StateEntry *state_table;
1882  /* State dirtification
1883  * dirtyArray is an array that contains markers for dirty states. numDirtyEntries states are dirty, their numbers are in indices
1884  * 0...numDirtyEntries - 1. isStateDirty is a redundant copy of the dirtyArray. Technically only one of them would be needed,
1885  * 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
1886  * only numDirtyEntries array elements have to be checked, not STATE_HIGHEST states.
1887  */
1888  DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */
1890  DWORD isStateDirty[STATE_HIGHEST / (sizeof(DWORD) * CHAR_BIT) + 1]; /* Bitmap to find out quickly if a state is dirty */
1891  unsigned int dirty_compute_states[STATE_COMPUTE_COUNT / (sizeof(unsigned int) * CHAR_BIT) + 1];
1892 
1895  struct
1896  {
1898  unsigned int sub_resource_idx;
1899  } current_rt;
1900  DWORD tid; /* Thread ID which owns this context at the moment */
1901 
1902  /* Stores some information about the context state for optimization */
1904  DWORD last_was_rhw : 1; /* true iff last draw_primitive was in xyzrhw mode */
1905  DWORD last_swizzle_map : 16; /* MAX_ATTRIBS, 16 */
1915  DWORD num_untracked_materials : 2; /* Max value 2 */
1919 
1920  DWORD texShaderBumpMap : 8; /* MAX_TEXTURES, 8 */
1921  DWORD lastWasPow2Texture : 8; /* MAX_TEXTURES, 8 */
1922  DWORD fixed_function_usage_map : 8; /* MAX_TEXTURES, 8 */
1923  DWORD lowest_disabled_stage : 4; /* Max MAX_TEXTURES, 8 */
1928 
1929  DWORD hdc_has_format : 1; /* only meaningful if hdc_is_private */
1938  DWORD shader_update_mask : 6; /* WINED3D_SHADER_TYPE_COUNT, 6 */
1939  DWORD clip_distance_mask : 8; /* MAX_CLIP_DISTANCES, 8 */
1942 
1945  GLenum tracking_parm; /* Which source is tracking current colour */
1946  GLenum untracked_materials[2];
1947  UINT blit_w, blit_h;
1948  enum fogsource fog_source;
1951 
1953 
1954  /* The actual opengl context */
1965 
1968 
1969  /* FBOs */
1971  struct list fbo_list;
1972  struct list fbo_destroy_list;
1977  DWORD draw_buffers_mask; /* Enabled draw buffers, 31 max. */
1978 
1979  /* Queries */
1983  struct list occlusion_queries;
1984 
1987  unsigned int free_fence_count;
1988  struct list fences;
1989 
1993  struct list timestamp_queries;
1994 
1998  struct list so_statistics_queries;
1999 
2003  struct list pipeline_statistics_queries;
2004 
2006 
2007  /* Fences for GL_APPLE_flush_buffer_range */
2008  struct wined3d_fence *buffer_fences[MAX_ATTRIBS];
2009  unsigned int buffer_fence_count;
2010 
2012 
2015 
2016  /* Extension emulation */
2019  GLfloat color[4], fogstart, fogend, fogcolor[4];
2021 
2022  unsigned int viewport_count;
2023  unsigned int scissor_rect_count;
2024 };
2025 
2027 {
2030 };
2031 
2032 typedef void (*APPLYSTATEFUNC)(struct wined3d_context *ctx, const struct wined3d_state *state, DWORD state_id);
2033 
2035 {
2038 };
2039 
2041 {
2044  enum wined3d_gl_extension extension;
2045 };
2046 
2047 #define WINED3D_FRAGMENT_CAP_PROJ_CONTROL 0x00000001
2048 #define WINED3D_FRAGMENT_CAP_SRGB_WRITE 0x00000002
2049 #define WINED3D_FRAGMENT_CAP_COLOR_KEY 0x00000004
2050 
2052 {
2058 };
2059 
2060 #define GL_EXT_EMUL_ARB_MULTITEXTURE 0x00000001
2061 #define GL_EXT_EMUL_EXT_FOG_COORD 0x00000002
2062 
2064 {
2065  void (*enable_extension)(const struct wined3d_gl_info *gl_info, BOOL enable);
2066  void (*get_caps)(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
2067  DWORD (*get_emul_mask)(const struct wined3d_gl_info *gl_info);
2068  void *(*alloc_private)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2069  void (*free_private)(struct wined3d_device *device);
2070  BOOL (*allocate_context_data)(struct wined3d_context *context);
2071  void (*free_context_data)(struct wined3d_context *context);
2072  BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
2074 };
2075 
2077 {
2088 };
2089 
2091 {
2092  void (*vp_enable)(const struct wined3d_gl_info *gl_info, BOOL enable);
2093  void (*vp_get_caps)(const struct wined3d_gl_info *gl_info, struct wined3d_vertex_caps *caps);
2094  DWORD (*vp_get_emul_mask)(const struct wined3d_gl_info *gl_info);
2095  void *(*vp_alloc)(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv);
2096  void (*vp_free)(struct wined3d_device *device);
2098 };
2099 
2108 
2112 
2113 /* "Base" state table */
2114 HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
2115  const struct wined3d_gl_info *gl_info, const struct wined3d_d3d_info *d3d_info,
2116  const struct wined3d_vertex_pipe_ops *vertex, const struct fragment_pipeline *fragment,
2117  const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
2118 
2120 {
2128 };
2129 
2131 {
2132  const struct wined3d_blitter_ops *ops;
2134 };
2135 
2137 {
2138  void (*blitter_destroy)(struct wined3d_blitter *blitter, struct wined3d_context *context);
2139  void (*blitter_clear)(struct wined3d_blitter *blitter, struct wined3d_device *device,
2140  unsigned int rt_count, const struct wined3d_fb_state *fb, unsigned int rect_count, const RECT *clear_rects,
2141  const RECT *draw_rect, DWORD flags, const struct wined3d_color *colour, float depth, DWORD stencil);
2142  DWORD (*blitter_blit)(struct wined3d_blitter *blitter, enum wined3d_blit_op op, struct wined3d_context *context,
2143  struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx, DWORD src_location,
2144  const RECT *src_rect, struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx,
2145  DWORD dst_location, const RECT *dst_rect, const struct wined3d_color_key *colour_key,
2147 };
2148 
2150  const struct wined3d_device *device) DECLSPEC_HIDDEN;
2153  const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2155  const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2157  const struct wined3d_device *device) DECLSPEC_HIDDEN;
2159  const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2160 
2162 
2164  struct wined3d_texture *texture, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2170  UINT rt_count, const struct wined3d_fb_state *fb) DECLSPEC_HIDDEN;
2172  struct wined3d_resource *rt, unsigned int rt_sub_resource_idx,
2173  struct wined3d_resource *ds, unsigned int ds_sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
2175  const struct wined3d_device *device) DECLSPEC_HIDDEN;
2176 void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info,
2177  unsigned int unit) DECLSPEC_HIDDEN;
2180  const struct wined3d_context *context) DECLSPEC_HIDDEN;
2184  const struct wined3d_bo_address *dst, GLenum dst_binding,
2185  const struct wined3d_bo_address *src, GLenum src_binding, size_t size) DECLSPEC_HIDDEN;
2186 struct wined3d_context *context_create(struct wined3d_swapchain *swapchain, struct wined3d_texture *target,
2187  const struct wined3d_format *ds_format) DECLSPEC_HIDDEN;
2188 HGLRC context_create_wgl_attribs(const struct wined3d_gl_info *gl_info, HDC hdc, HGLRC share_ctx) DECLSPEC_HIDDEN;
2191  unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2194  unsigned int sub_resource_idx, const RECT *src_rect, const RECT *dst_rect,
2203  const struct wined3d_shader_version *shader_version, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2206  GLuint name, BOOL rb_namespace) DECLSPEC_HIDDEN;
2209 void context_load_tex_coords(const struct wined3d_context *context, const struct wined3d_stream_info *si,
2210  GLuint *current_bo, const struct wined3d_state *state) DECLSPEC_HIDDEN;
2212  size_t size, GLenum binding, DWORD flags) DECLSPEC_HIDDEN;
2218  unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
2223  const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2225  const struct wined3d_state *state, DWORD state_id) DECLSPEC_HIDDEN;
2229  const struct wined3d_bo_address *data, GLenum binding) DECLSPEC_HIDDEN;
2231  const struct wined3d_state *state) DECLSPEC_HIDDEN;
2232 
2233 /*****************************************************************************
2234  * Internal representation of a light
2235  */
2237 {
2238  struct wined3d_light OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
2242 
2243  /* Converted parms to speed up swapping lights */
2244  struct wined3d_vec4 position;
2245  struct wined3d_vec4 direction;
2246  float exponent;
2247  float cutoff;
2248 
2249  struct list entry;
2250 };
2251 
2252 /* The default light parameters */
2254 
2256 {
2257  int iPixelFormat; /* WGL pixel format */
2258  int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
2259  int redSize, greenSize, blueSize, alphaSize, colorSize;
2260  int depthSize, stencilSize;
2265 };
2266 
2268 {
2270  HW_VENDOR_AMD = 0x1002,
2274 };
2275 
2277 {
2278  CARD_WINE = 0x0000,
2279 
2326 
2342  CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
2346  CARD_NVIDIA_GEFORCE_8200 = 0x0849, /* Other PCI ID 0x084b */
2433  CARD_NVIDIA_GEFORCE_GTX860M = 0x1392, /* Other PCI ID 0x119a */
2453 
2455 
2466  CARD_INTEL_Q35 = 0x29b2,
2467  CARD_INTEL_G33 = 0x29c2,
2468  CARD_INTEL_Q33 = 0x29d2,
2477  CARD_INTEL_IGD = 0x2e02,
2478  CARD_INTEL_Q45 = 0x2e12,
2479  CARD_INTEL_G45 = 0x2e22,
2480  CARD_INTEL_G41 = 0x2e32,
2481  CARD_INTEL_B43 = 0x2e92,
2490  CARD_INTEL_HWD = 0x0412,
2491  CARD_INTEL_HWM = 0x0416,
2526 };
2527 
2529 {
2530  GLboolean (WINE_GLAPI *glIsRenderbuffer)(GLuint renderbuffer);
2531  void (WINE_GLAPI *glBindRenderbuffer)(GLenum target, GLuint renderbuffer);
2532  void (WINE_GLAPI *glDeleteRenderbuffers)(GLsizei n, const GLuint *renderbuffers);
2533  void (WINE_GLAPI *glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers);
2534  void (WINE_GLAPI *glRenderbufferStorage)(GLenum target, GLenum internalformat,
2536  void (WINE_GLAPI *glRenderbufferStorageMultisample)(GLenum target, GLsizei samples,
2538  void (WINE_GLAPI *glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint *params);
2539  GLboolean (WINE_GLAPI *glIsFramebuffer)(GLuint framebuffer);
2540  void (WINE_GLAPI *glBindFramebuffer)(GLenum target, GLuint framebuffer);
2541  void (WINE_GLAPI *glDeleteFramebuffers)(GLsizei n, const GLuint *framebuffers);
2542  void (WINE_GLAPI *glGenFramebuffers)(GLsizei n, GLuint *framebuffers);
2543  GLenum (WINE_GLAPI *glCheckFramebufferStatus)(GLenum target);
2544  void (WINE_GLAPI *glFramebufferTexture)(GLenum target, GLenum attachment,
2546  void (WINE_GLAPI *glFramebufferTexture1D)(GLenum target, GLenum attachment,
2548  void (WINE_GLAPI *glFramebufferTexture2D)(GLenum target, GLenum attachment,
2550  void (WINE_GLAPI *glFramebufferTexture3D)(GLenum target, GLenum attachment,
2552  void (WINE_GLAPI *glFramebufferTextureLayer)(GLenum target, GLenum attachment,
2554  void (WINE_GLAPI *glFramebufferRenderbuffer)(GLenum target, GLenum attachment,
2556  void (WINE_GLAPI *glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment,
2557  GLenum pname, GLint *params);
2558  void (WINE_GLAPI *glBlitFramebuffer)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
2560  void (WINE_GLAPI *glGenerateMipmap)(GLenum target);
2561 };
2562 
2564 {
2570  unsigned int uniform_blocks[WINED3D_SHADER_TYPE_COUNT];
2572  unsigned int graphics_samplers;
2573  unsigned int combined_samplers;
2581  float shininess;
2584 
2586 
2587  unsigned int framebuffer_width;
2588  unsigned int framebuffer_height;
2589 
2593 
2603 };
2604 
2605 void wined3d_gl_limits_get_texture_unit_range(const struct wined3d_gl_limits *gl_limits,
2606  enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2608  enum wined3d_shader_type shader_type, unsigned int *base, unsigned int *count) DECLSPEC_HIDDEN;
2609 
2611 {
2614  struct wined3d_gl_limits limits;
2615  DWORD reserved_glsl_constants, reserved_arb_constants;
2619 
2620  HGLRC (WINAPI *p_wglCreateContextAttribsARB)(HDC dc, HGLRC share, const GLint *attribs);
2621  struct opengl_funcs gl_ops;
2622  struct wined3d_fbo_ops fbo_ops;
2623 
2625  unsigned int format_count;
2626 };
2627 
2629 {
2632  const char *name;
2633  const char *description;
2637 };
2638 
2639 /* The adapter structure */
2641 {
2644  enum wined3d_format_id screen_format;
2645 
2646  struct wined3d_gl_info gl_info;
2647  struct wined3d_d3d_info d3d_info;
2648  struct wined3d_driver_info driver_info;
2649  WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
2650  unsigned int cfg_count;
2655 
2659 };
2660 
2662 {
2668 
2669  const struct wined3d_gl_info *gl_info;
2672 };
2673 
2675  struct wined3d_caps_gl_ctx *ctx) DECLSPEC_HIDDEN;
2677 
2679 
2681 
2683 {
2687 };
2688 
2689 /*****************************************************************************
2690  * Fixed function pipeline replacements
2691  */
2692 #define ARG_UNUSED 0xff
2694 {
2695  unsigned cop : 8;
2696  unsigned carg1 : 8;
2697  unsigned carg2 : 8;
2698  unsigned carg0 : 8;
2699 
2700  unsigned aop : 8;
2701  unsigned aarg1 : 8;
2702  unsigned aarg2 : 8;
2703  unsigned aarg0 : 8;
2704 
2705  struct color_fixup_desc color_fixup;
2706  unsigned tex_type : 3;
2707  unsigned tmp_dst : 1;
2708  unsigned projected : 2;
2709  unsigned padding : 10;
2710 };
2711 
2713 {
2716  unsigned char sRGB_write;
2717  unsigned char emul_clipplanes;
2718  unsigned char texcoords_initialized;
2719  unsigned char color_key_enabled : 1;
2720  unsigned char pointsprite : 1;
2721  unsigned char flatshading : 1;
2722  unsigned char alpha_test_func : 3;
2723  unsigned char padding : 2;
2724 };
2725 
2727 {
2730 };
2731 
2734 
2736 
2737 unsigned int wined3d_max_compat_varyings(const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
2738 void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state,
2739  struct ffp_frag_settings *settings, BOOL ignore_textype) DECLSPEC_HIDDEN;
2740 const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
2743 void wined3d_ftoa(float value, char *s) DECLSPEC_HIDDEN;
2744 
2745 extern const float wined3d_srgb_const0[] DECLSPEC_HIDDEN;
2746 extern const float wined3d_srgb_const1[] DECLSPEC_HIDDEN;
2747 
2749 {
2754 };
2755 
2756 #define WINED3D_FFP_TCI_SHIFT 16
2757 #define WINED3D_FFP_TCI_MASK 0xffu
2758 
2759 #define WINED3D_FFP_LIGHT_TYPE_SHIFT(idx) (3 * (idx))
2760 #define WINED3D_FFP_LIGHT_TYPE_MASK 0x7u
2761 
2763 {
2779 
2783  DWORD texcoords : 8; /* MAX_TEXTURES */
2786  DWORD swizzle_map : 16; /* MAX_ATTRIBS, 16 */
2789 
2791 };
2792 
2794 {
2797 };
2798 
2801 
2802 struct wined3d
2803 {
2807  struct wined3d_adapter adapters[1];
2808 };
2809 
2813 
2815 {
2818 
2819  void *parent;
2821 
2823 };
2824 
2826 {
2829 
2830  void *parent;
2832 
2834 };
2835 
2837 {
2840 };
2841 
2843 {
2849 };
2850 
2851 #define WINED3D_STATE_NO_REF 0x00000001
2852 #define WINED3D_STATE_INIT_DEFAULT 0x00000002
2853 
2855 {
2857  const struct wined3d_fb_state *fb;
2858 
2861  struct wined3d_stream_state streams[MAX_STREAMS + 1 /* tesselated pseudo-stream */];
2863  enum wined3d_format_id index_format;
2864  unsigned int index_offset;
2866  int load_base_vertex_index; /* Non-indexed drawing needs 0 here, indexed needs base_vertex_index. */
2871 
2877 
2881 
2885 
2889 
2890  struct wined3d_matrix transforms[HIGHEST_TRANSFORMSTATE + 1];
2891  struct wined3d_vec4 clip_planes[MAX_CLIP_DISTANCES];
2892  struct wined3d_material material;
2894  unsigned int viewport_count;
2895  RECT scissor_rects[WINED3D_MAX_VIEWPORTS];
2896  unsigned int scissor_rect_count;
2897 
2898  /* Light hashmap. Collisions are handled using linked lists. */
2899 #define LIGHTMAP_SIZE 43
2900 #define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE)
2901  struct list light_map[LIGHTMAP_SIZE];
2902  const struct wined3d_light_info *lights[MAX_ACTIVE_LIGHTS];
2903 
2904  DWORD render_states[WINEHIGHEST_RENDER_STATE + 1];
2907 };
2908 
2909 static inline BOOL wined3d_dualblend_enabled(const struct wined3d_state *state, const struct wined3d_gl_info *gl_info)
2910 {
2911  if (!state->fb->render_targets[0]) return FALSE;
2912  if (!state->render_states[WINED3D_RS_ALPHABLENDENABLE]) return FALSE;
2913  if (!gl_info->supported[ARB_BLEND_FUNC_EXTENDED]) return FALSE;
2914 
2915 #define IS_DUAL_SOURCE_BLEND(x) ((x) >= WINED3D_BLEND_SRC1COLOR && (x) <= WINED3D_BLEND_INVSRC1ALPHA)
2916  if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_SRCBLEND])) return TRUE;
2917  if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_DESTBLEND])) return TRUE;
2918  if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_SRCBLENDALPHA])) return TRUE;
2919  if (IS_DUAL_SOURCE_BLEND(state->render_states[WINED3D_RS_DESTBLENDALPHA])) return TRUE;
2920 #undef IS_DUAL_SOURCE_BLEND
2921 
2922  return FALSE;
2923 }
2924 
2926 {
2938 };
2939 
2940 #define WINED3D_UNMAPPED_STAGE ~0u
2941 
2942 /* Multithreaded flag. Removed from the public header to signal that
2943  * wined3d_device_create() ignores it. */
2944 #define WINED3DCREATE_MULTITHREADED 0x00000004
2945 
2947 {
2949 
2950  /* WineD3D Information */
2952  struct wined3d *wined3d;
2954 
2955  /* Window styles to restore when switching fullscreen mode */
2958 
2963  struct StateEntry StateTable[STATE_HIGHEST + 1];
2964  /* Array of functions for states which are handled by more than one pipeline part */
2965  APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
2967 
2970  BYTE inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
2971  BYTE softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
2974 
2975  unsigned char surface_alignment; /* Line Alignment of surfaces */
2976 
2978 
2982 
2983  /* Internal use fields */
2986 
2990  unsigned int max_frame_latency;
2991 
2992  struct list resources; /* a linked list to track resources created by the device */
2993  struct list shaders; /* a linked list to track shaders (pixel and vertex) */
2995 
2996  /* Render Target Support */
2997  struct wined3d_fb_state fb;
2999 
3000  /* Cursor management */
3005  UINT cursorWidth, cursorHeight;
3008 
3009  /* The Wine logo texture */
3011 
3012  /* Textures for when no other textures are mapped */
3013  struct wined3d_dummy_textures dummy_textures;
3014 
3015  /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
3018 
3019  /* Command stream */
3020  struct wined3d_cs *cs;
3021 
3022  /* Context management */
3025 };
3026 
3027 void device_clear_render_targets(struct wined3d_device *device, UINT rt_count, const struct wined3d_fb_state *fb,
3028  UINT rect_count, const RECT *rects, const RECT *draw_rect, DWORD flags,
3029  const struct wined3d_color *color, float depth, DWORD stencil) DECLSPEC_HIDDEN;
3033  UINT adapter_idx, enum wined3d_device_type device_type, HWND focus_window, DWORD flags,
3034  BYTE surface_alignment, struct wined3d_device_parent *device_parent) DECLSPEC_HIDDEN;
3040 
3041 static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
3042 {
3043  DWORD idx = state / (sizeof(*context->isStateDirty) * CHAR_BIT);
3044  BYTE shift = state & ((sizeof(*context->isStateDirty) * CHAR_BIT) - 1);
3045  return context->isStateDirty[idx] & (1u << shift);
3046 }
3047 
3049 
3051 {
3053 }
3054 
3056 {
3057  ULONG (*resource_incref)(struct wined3d_resource *resource);
3058  ULONG (*resource_decref)(struct wined3d_resource *resource);
3059  void (*resource_preload)(struct wined3d_resource *resource);
3061  HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
3062  struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);
3063  HRESULT (*resource_map_info)(struct wined3d_resource *resource, unsigned int sub_resource_idx,
3064  struct wined3d_map_info *info, DWORD flags);
3065  HRESULT (*resource_sub_resource_unmap)(struct wined3d_resource *resource, unsigned int sub_resource_idx);
3066 };
3067 
3069 {
3077  const struct wined3d_format *format;
3078  unsigned int format_flags;
3079  enum wined3d_multisample_type multisample_type;
3082  unsigned int access;
3091 
3092  void *parent;
3095 
3096  struct list resource_list_entry;
3097 };
3098 
3100 {
3101  return resource->resource_ops->resource_incref(resource);
3102 }
3103 
3105 {
3106  return resource->resource_ops->resource_decref(resource);
3107 }
3108 
3110 {
3111  InterlockedIncrement(&resource->access_count);
3112 }
3113 
3115 {
3116  InterlockedDecrement(&resource->access_count);
3117 }
3118 
3121  enum wined3d_resource_type type, const struct wined3d_format *format,
3122  enum wined3d_multisample_type multisample_type, unsigned int multisample_quality,
3123  unsigned int usage, unsigned int access, unsigned int width, unsigned int height, unsigned int depth,
3124  unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
3125  const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
3133 
3134 /* Tests show that the start address of resources is 32 byte aligned */
3135 #define RESOURCE_ALIGNMENT 16
3136 #define WINED3D_CONSTANT_BUFFER_ALIGNMENT 16
3137 
3139 {
3140  struct wined3d_sampler_desc sampler_desc;
3141  unsigned int base_level;
3143 };
3144 
3146 {
3148  struct wined3d_vec3 texcoords[4];
3149 };
3150 
3152 {
3153  BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
3155 };
3156 
3157 #define WINED3D_TEXTURE_COND_NP2 0x00000001
3158 #define WINED3D_TEXTURE_COND_NP2_EMULATED 0x00000002
3159 #define WINED3D_TEXTURE_POW2_MAT_IDENT 0x00000004
3160 #define WINED3D_TEXTURE_IS_SRGB 0x00000008
3161 #define WINED3D_TEXTURE_RGB_ALLOCATED 0x00000010
3162 #define WINED3D_TEXTURE_RGB_VALID 0x00000020
3163 #define WINED3D_TEXTURE_SRGB_ALLOCATED 0x00000040
3164 #define WINED3D_TEXTURE_SRGB_VALID 0x00000080
3165 #define WINED3D_TEXTURE_CONVERTED 0x00000100
3166 #define WINED3D_TEXTURE_PIN_SYSMEM 0x00000200
3167 #define WINED3D_TEXTURE_NORMALIZED_COORDS 0x00000400
3168 #define WINED3D_TEXTURE_GET_DC_LENIENT 0x00000800
3169 #define WINED3D_TEXTURE_DC_IN_USE 0x00001000
3170 #define WINED3D_TEXTURE_DISCARD 0x00002000
3171 #define WINED3D_TEXTURE_GET_DC 0x00004000
3172 #define WINED3D_TEXTURE_GENERATE_MIPMAPS 0x00008000
3173 
3174 #define WINED3D_TEXTURE_ASYNC_COLOR_KEY 0x00000001
3175 
3177 {
3180  struct gl_texture texture_rgb, texture_srgb;
3182  unsigned int pow2_width;
3183  unsigned int pow2_height;
3186  unsigned int download_count;
3187  unsigned int sysmem_count;
3188  float pow2_matrix[16];