blob: 3af27030f6ad0d06e1dac41886d157cab321ceb4 [file] [log] [blame]
Raphael Junqueira01968612003-11-14 03:50:35 +00001/*
2 * Direct3D wine internal private include file
3 *
4 * Copyright 2002-2003 The wine-d3d team
5 * Copyright 2002-2003 Raphael Junqueira
Henri Verbeet7420a962009-05-01 09:13:54 +02006 * Copyright 2002-2003, 2004 Jason Edmeades
Oliver Stieber46e7c302005-06-23 11:05:24 +00007 * Copyright 2005 Oliver Stieber
Raphael Junqueira01968612003-11-14 03:50:35 +00008 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
Jonathan Ernst360a3f92006-05-18 14:49:52 +020021 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
Raphael Junqueira01968612003-11-14 03:50:35 +000022 */
23
24#ifndef __WINE_WINED3D_PRIVATE_H
25#define __WINE_WINED3D_PRIVATE_H
26
27#include <stdarg.h>
Jason Edmeades0a944ae2004-11-29 17:53:42 +000028#include <math.h>
Jason Edmeades24ab49e2004-09-23 04:34:27 +000029#define NONAMELESSUNION
30#define NONAMELESSSTRUCT
Jason Edmeades289562e2004-11-23 13:52:46 +000031#define COBJMACROS
Raphael Junqueira01968612003-11-14 03:50:35 +000032#include "windef.h"
33#include "winbase.h"
Jason Edmeades24ab49e2004-09-23 04:34:27 +000034#include "winreg.h"
Raphael Junqueira01968612003-11-14 03:50:35 +000035#include "wingdi.h"
36#include "winuser.h"
37#include "wine/debug.h"
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +000038#include "wine/unicode.h"
Raphael Junqueira01968612003-11-14 03:50:35 +000039
Henri Verbeeta6917b12008-11-25 11:57:39 +010040#include "objbase.h"
Henri Verbeeta6917b12008-11-25 11:57:39 +010041#include "wine/wined3d.h"
Henri Verbeet8899f342008-11-20 13:32:00 +010042#include "wined3d_gl.h"
Jason Green0c59ca62006-06-09 03:33:01 -040043#include "wine/list.h"
Henri Verbeetad6279d2009-06-03 10:47:26 +020044#include "wine/rbtree.h"
Raphael Junqueira01968612003-11-14 03:50:35 +000045
Henri Verbeet40bc4792009-07-01 09:46:19 +020046/* Driver quirks */
47#define WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT 0x00000001
48#define WINED3D_QUIRK_SET_TEXCOORD_W 0x00000002
49#define WINED3D_QUIRK_GLSL_CLIP_VARYING 0x00000004
Stefan Dösinger8a6553d2009-07-10 11:28:49 +020050#define WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA 0x00000008
Stefan Dösinger404aecb2009-09-28 12:30:48 +020051#define WINED3D_QUIRK_NV_CLIP_BROKEN 0x00000010
Henri Verbeet40bc4792009-07-01 09:46:19 +020052
Henri Verbeet89139b72008-12-03 14:53:43 +010053/* Texture format fixups */
54
55enum fixup_channel_source
56{
57 CHANNEL_SOURCE_ZERO = 0,
58 CHANNEL_SOURCE_ONE = 1,
59 CHANNEL_SOURCE_X = 2,
60 CHANNEL_SOURCE_Y = 3,
61 CHANNEL_SOURCE_Z = 4,
62 CHANNEL_SOURCE_W = 5,
63 CHANNEL_SOURCE_YUV0 = 6,
64 CHANNEL_SOURCE_YUV1 = 7,
65};
66
67enum yuv_fixup
68{
69 YUV_FIXUP_YUY2 = 0,
70 YUV_FIXUP_UYVY = 1,
71 YUV_FIXUP_YV12 = 2,
72};
73
74#include <pshpack2.h>
75struct color_fixup_desc
76{
77 unsigned x_sign_fixup : 1;
78 unsigned x_source : 3;
79 unsigned y_sign_fixup : 1;
80 unsigned y_source : 3;
81 unsigned z_sign_fixup : 1;
82 unsigned z_source : 3;
83 unsigned w_sign_fixup : 1;
84 unsigned w_source : 3;
85};
86#include <poppack.h>
87
88static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
89 {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
90
91static inline struct color_fixup_desc create_color_fixup_desc(
92 int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1,
93 int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)
94{
95 struct color_fixup_desc fixup =
96 {
97 sign0, src0,
98 sign1, src1,
99 sign2, src2,
100 sign3, src3,
101 };
102 return fixup;
103}
104
105static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup)
106{
107 struct color_fixup_desc fixup =
108 {
109 0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
110 0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
111 0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
112 0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
113 };
114 return fixup;
115}
116
117static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
118{
119 return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
120}
121
122static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup)
123{
124 return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1;
125}
126
127static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup)
128{
129 enum yuv_fixup yuv_fixup = 0;
130 if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0);
131 if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1);
132 if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2);
133 if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3);
134 return yuv_fixup;
135}
136
Henri Verbeet689984b2009-09-11 19:01:19 +0200137void *wined3d_rb_alloc(size_t size) DECLSPEC_HIDDEN;
138void *wined3d_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN;
139void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN;
H. Verbeet2a82ed82007-02-27 20:51:48 +0100140
Oliver Stieber18857f12005-06-24 11:53:07 +0000141/* Device caps */
Alexander Dorofeyev16597092008-03-27 00:23:04 +0200142#define MAX_PALETTES 65536
H. Verbeet5b7758f2007-06-25 22:45:40 +0200143#define MAX_STREAMS 16
144#define MAX_TEXTURES 8
145#define MAX_FRAGMENT_SAMPLERS 16
146#define MAX_VERTEX_SAMPLERS 4
147#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
148#define MAX_ACTIVE_LIGHTS 8
149#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
Oliver Stieber18857f12005-06-24 11:53:07 +0000150
Henri Verbeet342a71b2009-10-23 10:26:10 +0200151extern GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1] DECLSPEC_HIDDEN;
Oliver Stieberbb6f9b02005-08-03 11:00:28 +0000152
Henri Verbeetc7880e82008-11-26 16:14:40 +0100153struct min_lookup
154{
155 GLenum mip[WINED3DTEXF_LINEAR + 1];
156};
Stefan Dösingera22203a2008-04-06 00:31:39 +0200157
Henri Verbeet689984b2009-09-11 19:01:19 +0200158const struct min_lookup minMipLookup[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
159const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
160const struct min_lookup minMipLookup_noMip[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
161const GLenum magLookup[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
162const GLenum magLookup_noFilter[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
Henri Verbeetc7880e82008-11-26 16:14:40 +0100163
Henri Verbeet351d6de2009-08-05 09:00:59 +0200164static inline GLenum wined3d_gl_mag_filter(const GLenum mag_lookup[], WINED3DTEXTUREFILTERTYPE mag_filter)
165{
166 return mag_lookup[mag_filter];
167}
168
169static inline GLenum wined3d_gl_min_mip_filter(const struct min_lookup min_mip_lookup[],
170 WINED3DTEXTUREFILTERTYPE min_filter, WINED3DTEXTUREFILTERTYPE mip_filter)
171{
172 return min_mip_lookup[min_filter].mip[mip_filter];
173}
174
Francois Gouget8320d212008-07-10 00:23:07 +0200175/* float_16_to_32() and float_32_to_16() (see implementation in
176 * surface_base.c) convert 16 bit floats in the FLOAT16 data type
Stefan Dösinger825506d2008-02-25 11:18:03 +0100177 * to standard C floats and vice versa. They do not depend on the encoding
178 * of the C float, so they are platform independent, but slow. On x86 and
Austin English6e59cd22008-04-22 01:18:14 -0500179 * other IEEE 754 compliant platforms the conversion can be accelerated by
180 * bit shifting the exponent and mantissa. There are also some SSE-based
181 * assembly routines out there.
Stefan Dösinger825506d2008-02-25 11:18:03 +0100182 *
183 * See GL_NV_half_float for a reference of the FLOAT16 / GL_HALF format
184 */
Stefan Dösingerb5f925c2007-12-19 17:18:39 +0100185static inline float float_16_to_32(const unsigned short *in) {
186 const unsigned short s = ((*in) & 0x8000);
187 const unsigned short e = ((*in) & 0x7C00) >> 10;
188 const unsigned short m = (*in) & 0x3FF;
Henri Verbeet2ac34bf2009-07-07 11:08:01 +0200189 const float sgn = (s ? -1.0f : 1.0f);
Stefan Dösingerb5f925c2007-12-19 17:18:39 +0100190
191 if(e == 0) {
Henri Verbeet2ac34bf2009-07-07 11:08:01 +0200192 if(m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
193 else return sgn * pow(2, -14.0f) * ((float)m / 1024.0f);
Stefan Dösingerb5f925c2007-12-19 17:18:39 +0100194 } else if(e < 31) {
Henri Verbeet2ac34bf2009-07-07 11:08:01 +0200195 return sgn * pow(2, (float)e - 15.0f) * (1.0f + ((float)m / 1024.0f));
Stefan Dösingerb5f925c2007-12-19 17:18:39 +0100196 } else {
Henri Verbeet2ac34bf2009-07-07 11:08:01 +0200197 if(m == 0) return sgn / 0.0f; /* +INF / -INF */
198 else return 0.0f / 0.0f; /* NAN */
Stefan Dösingerb5f925c2007-12-19 17:18:39 +0100199 }
200}
201
Henri Verbeet23231d52009-06-16 09:38:25 +0200202static inline float float_24_to_32(DWORD in)
203{
204 const float sgn = in & 0x800000 ? -1.0f : 1.0f;
205 const unsigned short e = (in & 0x780000) >> 19;
206 const unsigned short m = in & 0x7ffff;
207
208 if (e == 0)
209 {
210 if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */
211 else return sgn * pow(2, -6.0f) * ((float)m / 524288.0f);
212 }
213 else if (e < 15)
214 {
215 return sgn * pow(2, (float)e - 7.0f) * (1.0f + ((float)m / 524288.0f));
216 }
217 else
218 {
Henri Verbeet2ac34bf2009-07-07 11:08:01 +0200219 if (m == 0) return sgn / 0.0f; /* +INF / -INF */
220 else return 0.0f / 0.0f; /* NAN */
Henri Verbeet23231d52009-06-16 09:38:25 +0200221 }
222}
223
Raphael Junqueiracc8762a2005-07-24 17:11:33 +0000224/**
Henri Verbeet560d6352009-08-27 10:04:56 +0200225 * Settings
Raphael Junqueiracc8762a2005-07-24 17:11:33 +0000226 */
Oliver Stieber9e6957b2005-09-23 11:08:03 +0000227#define VS_NONE 0
228#define VS_HW 1
Raphael Junqueira01968612003-11-14 03:50:35 +0000229
Oliver Stieber9e6957b2005-09-23 11:08:03 +0000230#define PS_NONE 0
231#define PS_HW 1
Jason Edmeades24ab49e2004-09-23 04:34:27 +0000232
Oliver Stieber9e6957b2005-09-23 11:08:03 +0000233#define VBO_NONE 0
234#define VBO_HW 1
235
H. Verbeetad4c2bd2006-11-17 13:23:53 +0100236#define ORM_BACKBUFFER 0
237#define ORM_PBUFFER 1
H. Verbeet6d660852006-11-17 13:24:00 +0100238#define ORM_FBO 2
H. Verbeetad4c2bd2006-11-17 13:23:53 +0100239
Jason Greend2045402006-05-23 18:22:59 -0400240#define SHADER_ARB 1
241#define SHADER_GLSL 2
Stefan Dösinger4640be82008-03-22 14:31:52 +0100242#define SHADER_ATI 3
243#define SHADER_NONE 4
Jason Greend2045402006-05-23 18:22:59 -0400244
Stefan Dösinger739d5652006-07-17 20:14:25 +0200245#define RTL_DISABLE -1
Stefan Dösinger739d5652006-07-17 20:14:25 +0200246#define RTL_READDRAW 1
247#define RTL_READTEX 2
Stefan Dösinger739d5652006-07-17 20:14:25 +0200248
Roderick Colenbrander27335722008-11-23 22:51:03 +0100249#define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
Roderick Colenbrander52d59712008-11-23 22:33:29 +0100250#define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
251
H. Verbeetba8a6a32006-09-26 20:31:41 +0200252/* NOTE: When adding fields to this structure, make sure to update the default
253 * values in wined3d_main.c as well. */
Raphael Junqueiracc8762a2005-07-24 17:11:33 +0000254typedef struct wined3d_settings_s {
255/* vertex and pixel shader modes */
256 int vs_mode;
257 int ps_mode;
Jason Greend2045402006-05-23 18:22:59 -0400258/* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
259 we should use it. However, until it's fully implemented, we'll leave it as a registry
260 setting for developers. */
Phil Costin1b320432006-05-18 02:24:08 +0100261 BOOL glslRequested;
H. Verbeetad4c2bd2006-11-17 13:23:53 +0100262 int offscreen_rendering_mode;
Stefan Dösinger739d5652006-07-17 20:14:25 +0200263 int rendertargetlock_mode;
Roderick Colenbrander27335722008-11-23 22:51:03 +0100264 unsigned short pci_vendor_id;
Roderick Colenbrander52d59712008-11-23 22:33:29 +0100265 unsigned short pci_device_id;
Jan Zerebecki4d6cfb62006-08-08 00:03:06 +0200266/* Memory tracking and object counting */
267 unsigned int emulated_textureram;
Stefan Dösinger271fb002007-09-01 21:22:32 +0200268 char *logo;
Roderick Colenbrander042d0392008-06-02 21:06:01 +0000269 int allow_multisampling;
Raphael Junqueiracc8762a2005-07-24 17:11:33 +0000270} wined3d_settings_t;
271
Henri Verbeet689984b2009-09-11 19:01:19 +0200272extern wined3d_settings_t wined3d_settings DECLSPEC_HIDDEN;
Raphael Junqueiracc8762a2005-07-24 17:11:33 +0000273
Henri Verbeet7420a962009-05-01 09:13:54 +0200274typedef enum _WINED3DSAMPLER_TEXTURE_TYPE
275{
276 WINED3DSTT_UNKNOWN = 0,
277 WINED3DSTT_1D = 1,
278 WINED3DSTT_2D = 2,
279 WINED3DSTT_CUBE = 3,
280 WINED3DSTT_VOLUME = 4,
281} WINED3DSAMPLER_TEXTURE_TYPE;
282
283typedef enum _WINED3DSHADER_PARAM_REGISTER_TYPE
284{
285 WINED3DSPR_TEMP = 0,
286 WINED3DSPR_INPUT = 1,
287 WINED3DSPR_CONST = 2,
288 WINED3DSPR_ADDR = 3,
289 WINED3DSPR_TEXTURE = 3,
290 WINED3DSPR_RASTOUT = 4,
291 WINED3DSPR_ATTROUT = 5,
292 WINED3DSPR_TEXCRDOUT = 6,
293 WINED3DSPR_OUTPUT = 6,
294 WINED3DSPR_CONSTINT = 7,
295 WINED3DSPR_COLOROUT = 8,
296 WINED3DSPR_DEPTHOUT = 9,
297 WINED3DSPR_SAMPLER = 10,
298 WINED3DSPR_CONST2 = 11,
299 WINED3DSPR_CONST3 = 12,
300 WINED3DSPR_CONST4 = 13,
301 WINED3DSPR_CONSTBOOL = 14,
302 WINED3DSPR_LOOP = 15,
303 WINED3DSPR_TEMPFLOAT16 = 16,
304 WINED3DSPR_MISCTYPE = 17,
305 WINED3DSPR_LABEL = 18,
306 WINED3DSPR_PREDICATE = 19,
Henri Verbeet9381a412009-05-06 10:05:46 +0200307 WINED3DSPR_IMMCONST,
Henri Verbeetd6ffe002009-07-16 13:08:22 +0200308 WINED3DSPR_CONSTBUFFER,
Henri Verbeet7420a962009-05-01 09:13:54 +0200309} WINED3DSHADER_PARAM_REGISTER_TYPE;
310
Henri Verbeet9381a412009-05-06 10:05:46 +0200311enum wined3d_immconst_type
312{
313 WINED3D_IMMCONST_FLOAT,
314 WINED3D_IMMCONST_FLOAT4,
315};
316
Henri Verbeet7420a962009-05-01 09:13:54 +0200317#define WINED3DSP_NOSWIZZLE (0 | (1 << 2) | (2 << 4) | (3 << 6))
318
319typedef enum _WINED3DSHADER_PARAM_SRCMOD_TYPE
320{
321 WINED3DSPSM_NONE = 0,
322 WINED3DSPSM_NEG = 1,
323 WINED3DSPSM_BIAS = 2,
324 WINED3DSPSM_BIASNEG = 3,
325 WINED3DSPSM_SIGN = 4,
326 WINED3DSPSM_SIGNNEG = 5,
327 WINED3DSPSM_COMP = 6,
328 WINED3DSPSM_X2 = 7,
329 WINED3DSPSM_X2NEG = 8,
330 WINED3DSPSM_DZ = 9,
331 WINED3DSPSM_DW = 10,
332 WINED3DSPSM_ABS = 11,
333 WINED3DSPSM_ABSNEG = 12,
334 WINED3DSPSM_NOT = 13,
335} WINED3DSHADER_PARAM_SRCMOD_TYPE;
336
Henri Verbeet699eae02009-05-06 10:05:45 +0200337#define WINED3DSP_WRITEMASK_0 0x1 /* .x r */
338#define WINED3DSP_WRITEMASK_1 0x2 /* .y g */
339#define WINED3DSP_WRITEMASK_2 0x4 /* .z b */
340#define WINED3DSP_WRITEMASK_3 0x8 /* .w a */
341#define WINED3DSP_WRITEMASK_ALL 0xf /* all */
Henri Verbeet7420a962009-05-01 09:13:54 +0200342
343typedef enum _WINED3DSHADER_PARAM_DSTMOD_TYPE
344{
345 WINED3DSPDM_NONE = 0,
346 WINED3DSPDM_SATURATE = 1,
347 WINED3DSPDM_PARTIALPRECISION = 2,
348 WINED3DSPDM_MSAMPCENTROID = 4,
349} WINED3DSHADER_PARAM_DSTMOD_TYPE;
350
Henri Verbeet7420a962009-05-01 09:13:54 +0200351/* Undocumented opcode control to identify projective texture lookups in ps 2.0 and later */
352#define WINED3DSI_TEXLD_PROJECT 1
353#define WINED3DSI_TEXLD_BIAS 2
354
355typedef enum COMPARISON_TYPE
356{
357 COMPARISON_GT = 1,
358 COMPARISON_EQ = 2,
359 COMPARISON_GE = 3,
360 COMPARISON_LT = 4,
361 COMPARISON_NE = 5,
362 COMPARISON_LE = 6,
363} COMPARISON_TYPE;
364
Henri Verbeet2a5a6a32009-05-05 09:38:03 +0200365#define WINED3D_SM1_VS 0xfffe
366#define WINED3D_SM1_PS 0xffff
367#define WINED3D_SM4_PS 0x0000
368#define WINED3D_SM4_VS 0x0001
369#define WINED3D_SM4_GS 0x0002
370
Henri Verbeet7420a962009-05-01 09:13:54 +0200371/* Shader version tokens, and shader end tokens */
Henri Verbeet2a5a6a32009-05-05 09:38:03 +0200372#define WINED3DPS_VERSION(major, minor) ((WINED3D_SM1_PS << 16) | ((major) << 8) | (minor))
373#define WINED3DVS_VERSION(major, minor) ((WINED3D_SM1_VS << 16) | ((major) << 8) | (minor))
Henri Verbeet7420a962009-05-01 09:13:54 +0200374
H. Verbeetdf6f4822006-11-27 20:50:37 +0100375/* Shader backends */
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200376
377/* TODO: Make this dynamic, based on shader limits ? */
378#define MAX_ATTRIBS 16
379#define MAX_REG_ADDR 1
380#define MAX_REG_TEMP 32
381#define MAX_REG_TEXCRD 8
382#define MAX_REG_INPUT 12
383#define MAX_REG_OUTPUT 12
384#define MAX_CONST_I 16
385#define MAX_CONST_B 16
386
387/* FIXME: This needs to go up to 2048 for
388 * Shader model 3 according to msdn (and for software shaders) */
389#define MAX_LABELS 16
H. Verbeetdf6f4822006-11-27 20:50:37 +0100390
Stefan Dösingera66fb402008-03-18 19:19:16 +0100391#define SHADER_PGMSIZE 65535
Henri Verbeet40b41192009-07-09 09:56:08 +0200392
393struct wined3d_shader_buffer
394{
395 char *buffer;
Stefan Dösingera66fb402008-03-18 19:19:16 +0100396 unsigned int bsize;
397 unsigned int lineNo;
398 BOOL newline;
Henri Verbeet40b41192009-07-09 09:56:08 +0200399};
Stefan Dösingera66fb402008-03-18 19:19:16 +0100400
Henri Verbeet2e769542008-09-23 17:39:34 +0200401enum WINED3D_SHADER_INSTRUCTION_HANDLER
402{
403 WINED3DSIH_ABS,
404 WINED3DSIH_ADD,
405 WINED3DSIH_BEM,
406 WINED3DSIH_BREAK,
407 WINED3DSIH_BREAKC,
408 WINED3DSIH_BREAKP,
409 WINED3DSIH_CALL,
410 WINED3DSIH_CALLNZ,
411 WINED3DSIH_CMP,
412 WINED3DSIH_CND,
413 WINED3DSIH_CRS,
414 WINED3DSIH_DCL,
415 WINED3DSIH_DEF,
416 WINED3DSIH_DEFB,
417 WINED3DSIH_DEFI,
418 WINED3DSIH_DP2ADD,
419 WINED3DSIH_DP3,
420 WINED3DSIH_DP4,
421 WINED3DSIH_DST,
422 WINED3DSIH_DSX,
423 WINED3DSIH_DSY,
424 WINED3DSIH_ELSE,
425 WINED3DSIH_ENDIF,
426 WINED3DSIH_ENDLOOP,
427 WINED3DSIH_ENDREP,
428 WINED3DSIH_EXP,
429 WINED3DSIH_EXPP,
430 WINED3DSIH_FRC,
431 WINED3DSIH_IF,
432 WINED3DSIH_IFC,
433 WINED3DSIH_LABEL,
434 WINED3DSIH_LIT,
435 WINED3DSIH_LOG,
436 WINED3DSIH_LOGP,
437 WINED3DSIH_LOOP,
438 WINED3DSIH_LRP,
439 WINED3DSIH_M3x2,
440 WINED3DSIH_M3x3,
441 WINED3DSIH_M3x4,
442 WINED3DSIH_M4x3,
443 WINED3DSIH_M4x4,
444 WINED3DSIH_MAD,
445 WINED3DSIH_MAX,
446 WINED3DSIH_MIN,
447 WINED3DSIH_MOV,
448 WINED3DSIH_MOVA,
449 WINED3DSIH_MUL,
450 WINED3DSIH_NOP,
451 WINED3DSIH_NRM,
452 WINED3DSIH_PHASE,
453 WINED3DSIH_POW,
454 WINED3DSIH_RCP,
455 WINED3DSIH_REP,
456 WINED3DSIH_RET,
457 WINED3DSIH_RSQ,
458 WINED3DSIH_SETP,
459 WINED3DSIH_SGE,
460 WINED3DSIH_SGN,
461 WINED3DSIH_SINCOS,
462 WINED3DSIH_SLT,
463 WINED3DSIH_SUB,
464 WINED3DSIH_TEX,
465 WINED3DSIH_TEXBEM,
466 WINED3DSIH_TEXBEML,
467 WINED3DSIH_TEXCOORD,
468 WINED3DSIH_TEXDEPTH,
469 WINED3DSIH_TEXDP3,
470 WINED3DSIH_TEXDP3TEX,
471 WINED3DSIH_TEXKILL,
472 WINED3DSIH_TEXLDD,
473 WINED3DSIH_TEXLDL,
474 WINED3DSIH_TEXM3x2DEPTH,
475 WINED3DSIH_TEXM3x2PAD,
476 WINED3DSIH_TEXM3x2TEX,
477 WINED3DSIH_TEXM3x3,
478 WINED3DSIH_TEXM3x3DIFF,
479 WINED3DSIH_TEXM3x3PAD,
480 WINED3DSIH_TEXM3x3SPEC,
481 WINED3DSIH_TEXM3x3TEX,
482 WINED3DSIH_TEXM3x3VSPEC,
483 WINED3DSIH_TEXREG2AR,
484 WINED3DSIH_TEXREG2GB,
485 WINED3DSIH_TEXREG2RGB,
486 WINED3DSIH_TABLE_SIZE
487};
488
Henri Verbeet65622a02009-05-06 17:59:21 +0200489enum wined3d_shader_type
490{
491 WINED3D_SHADER_TYPE_PIXEL,
492 WINED3D_SHADER_TYPE_VERTEX,
493 WINED3D_SHADER_TYPE_GEOMETRY,
494};
495
496struct wined3d_shader_version
497{
498 enum wined3d_shader_type type;
499 BYTE major;
500 BYTE minor;
501};
502
503#define WINED3D_SHADER_VERSION(major, minor) (((major) << 8) | (minor))
504
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200505typedef struct shader_reg_maps
506{
Henri Verbeet65622a02009-05-06 17:59:21 +0200507 struct wined3d_shader_version shader_version;
Henri Verbeet50853e22009-08-11 09:42:15 +0200508 BYTE texcoord; /* MAX_REG_TEXCRD, 8 */
Henri Verbeet270f57e2009-08-12 09:44:23 +0200509 BYTE address; /* MAX_REG_ADDR, 1 */
Henri Verbeet3d718d62009-08-12 09:44:24 +0200510 WORD labels; /* MAX_LABELS, 16 */
Henri Verbeet6fa9fa12009-08-11 09:42:16 +0200511 DWORD temporary; /* MAX_REG_TEMP, 32 */
Stefan Dösingerf9276a62009-05-07 17:31:20 +0200512 DWORD *constf; /* pixel, vertex */
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200513 DWORD texcoord_mask[MAX_REG_TEXCRD]; /* vertex < 3.0 */
Henri Verbeet10fadad2009-05-27 10:24:49 +0200514 WORD input_registers; /* max(MAX_REG_INPUT, MAX_ATTRIBS), 16 */
Henri Verbeete6efb792009-05-27 10:24:50 +0200515 WORD output_registers; /* MAX_REG_OUTPUT, 12 */
Henri Verbeete0018762009-04-28 09:53:28 +0200516 WORD integer_constants; /* MAX_CONST_I, 16 */
517 WORD boolean_constants; /* MAX_CONST_B, 16 */
Stefan Doesingerc220baf2009-06-16 07:36:59 +0200518 WORD local_int_consts; /* MAX_CONST_I, 16 */
Stefan Dösingere70c80a2009-05-27 18:23:59 +0200519 WORD local_bool_consts; /* MAX_CONST_B, 16 */
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200520
Henri Verbeet8d4c9042009-04-29 09:55:06 +0200521 WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
Henri Verbeet95bb4c02009-08-12 09:44:25 +0200522 BYTE bumpmat; /* MAX_TEXTURES, 8 */
Henri Verbeetf7918b92009-08-12 09:44:26 +0200523 BYTE luminanceparams; /* MAX_TEXTURES, 8 */
Stefan Doesingercd348ac2009-05-29 17:29:57 +0200524
Henri Verbeeta2823802009-08-11 09:42:14 +0200525 WORD usesnrm : 1;
526 WORD vpos : 1;
527 WORD usesdsx : 1;
528 WORD usesdsy : 1;
529 WORD usestexldd : 1;
530 WORD usesmova : 1;
531 WORD usesfacing : 1;
532 WORD usesrelconstF : 1;
533 WORD fog : 1;
534 WORD usestexldl : 1;
535 WORD usesifc : 1;
536 WORD usescall : 1;
537 WORD padding : 4;
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200538
539 /* Whether or not loops are used in this shader, and nesting depth */
540 unsigned loop_depth;
Stefan Dösinger26d17fe2009-06-18 18:10:15 +0200541 unsigned highest_render_target;
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200542
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200543} shader_reg_maps;
544
Henri Verbeet463de242009-04-15 10:06:28 +0200545struct wined3d_shader_context
546{
547 IWineD3DBaseShader *shader;
548 const struct shader_reg_maps *reg_maps;
Henri Verbeet40b41192009-07-09 09:56:08 +0200549 struct wined3d_shader_buffer *buffer;
Stefan Dösinger7b1d4872009-05-15 13:56:40 +0200550 void *backend_data;
Henri Verbeet463de242009-04-15 10:06:28 +0200551};
552
Henri Verbeet5e473cb2009-05-07 16:36:07 +0200553struct wined3d_shader_register
554{
555 WINED3DSHADER_PARAM_REGISTER_TYPE type;
556 UINT idx;
Henri Verbeetc4f88452009-07-16 13:08:21 +0200557 UINT array_idx;
Henri Verbeet5e473cb2009-05-07 16:36:07 +0200558 const struct wined3d_shader_src_param *rel_addr;
559 enum wined3d_immconst_type immconst_type;
560 DWORD immconst_data[4];
561};
562
Henri Verbeet7245cd22009-04-03 10:36:38 +0200563struct wined3d_shader_dst_param
564{
Henri Verbeet5e473cb2009-05-07 16:36:07 +0200565 struct wined3d_shader_register reg;
Henri Verbeet6f66c1d2009-04-07 11:09:11 +0200566 DWORD write_mask;
Henri Verbeetf0de1622009-04-06 10:10:08 +0200567 DWORD modifiers;
Henri Verbeet22e57d02009-04-10 09:15:06 +0200568 DWORD shift;
Henri Verbeet7245cd22009-04-03 10:36:38 +0200569};
570
Henri Verbeetff62cab2009-04-15 10:06:28 +0200571struct wined3d_shader_src_param
572{
Henri Verbeet5e473cb2009-05-07 16:36:07 +0200573 struct wined3d_shader_register reg;
Henri Verbeetdb5ab972009-04-21 09:35:05 +0200574 DWORD swizzle;
Henri Verbeet8ac4c982009-04-15 10:06:28 +0200575 DWORD modifiers;
Henri Verbeetff62cab2009-04-15 10:06:28 +0200576};
577
Henri Verbeetc3a01b32009-04-01 12:23:01 +0200578struct wined3d_shader_instruction
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200579{
Henri Verbeet463de242009-04-15 10:06:28 +0200580 const struct wined3d_shader_context *ctx;
Henri Verbeet44648b22009-04-02 10:41:00 +0200581 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx;
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200582 DWORD flags;
583 BOOL coissue;
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200584 DWORD predicate;
Henri Verbeet7bde2792009-04-02 10:41:00 +0200585 UINT dst_count;
Henri Verbeet7245cd22009-04-03 10:36:38 +0200586 const struct wined3d_shader_dst_param *dst;
Henri Verbeet7bde2792009-04-02 10:41:00 +0200587 UINT src_count;
Henri Verbeetff62cab2009-04-15 10:06:28 +0200588 const struct wined3d_shader_src_param *src;
Henri Verbeetc3a01b32009-04-01 12:23:01 +0200589};
Henri Verbeetde4e8cf2009-04-01 12:23:01 +0200590
Henri Verbeetd12e4892009-04-08 08:35:06 +0200591struct wined3d_shader_semantic
592{
Henri Verbeet9ec0b092009-04-08 08:35:07 +0200593 WINED3DDECLUSAGE usage;
594 UINT usage_idx;
Henri Verbeet65321dd2009-04-29 09:55:07 +0200595 WINED3DSAMPLER_TEXTURE_TYPE sampler_type;
Henri Verbeetd12e4892009-04-08 08:35:06 +0200596 struct wined3d_shader_dst_param reg;
597};
598
Henri Verbeet19cb4592009-05-27 10:24:50 +0200599struct wined3d_shader_attribute
600{
601 WINED3DDECLUSAGE usage;
602 UINT usage_idx;
603};
604
Henri Verbeet8d746c32009-08-10 09:30:48 +0200605struct wined3d_shader_loop_control
606{
607 unsigned int count;
608 unsigned int start;
609 int step;
610};
611
Henri Verbeet23781082009-05-04 09:49:27 +0200612struct wined3d_shader_frontend
613{
Henri Verbeet9a579a42009-05-08 17:44:25 +0200614 void *(*shader_init)(const DWORD *ptr, const struct wined3d_shader_signature *output_signature);
Henri Verbeet2a5a6a32009-05-05 09:38:03 +0200615 void (*shader_free)(void *data);
Henri Verbeet65622a02009-05-06 17:59:21 +0200616 void (*shader_read_header)(void *data, const DWORD **ptr, struct wined3d_shader_version *shader_version);
Henri Verbeet5c63d932009-05-06 17:59:21 +0200617 void (*shader_read_opcode)(void *data, const DWORD **ptr, struct wined3d_shader_instruction *ins, UINT *param_size);
618 void (*shader_read_src_param)(void *data, const DWORD **ptr, struct wined3d_shader_src_param *src_param,
619 struct wined3d_shader_src_param *src_rel_addr);
620 void (*shader_read_dst_param)(void *data, const DWORD **ptr, struct wined3d_shader_dst_param *dst_param,
621 struct wined3d_shader_src_param *dst_rel_addr);
Henri Verbeet23781082009-05-04 09:49:27 +0200622 void (*shader_read_semantic)(const DWORD **ptr, struct wined3d_shader_semantic *semantic);
623 void (*shader_read_comment)(const DWORD **ptr, const char **comment);
Henri Verbeet454dd2e2009-05-05 09:38:03 +0200624 BOOL (*shader_is_end)(void *data, const DWORD **ptr);
Henri Verbeet23781082009-05-04 09:49:27 +0200625};
626
Henri Verbeet689984b2009-09-11 19:01:19 +0200627extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
628extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
Henri Verbeet23781082009-05-04 09:49:27 +0200629
Henri Verbeetc3a01b32009-04-01 12:23:01 +0200630typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
Henri Verbeet2e769542008-09-23 17:39:34 +0200631
Stefan Dösinger5ab52022008-03-18 19:39:26 +0100632struct shader_caps {
Stefan Dösinger5ab52022008-03-18 19:39:26 +0100633 DWORD VertexShaderVersion;
634 DWORD MaxVertexShaderConst;
635
636 DWORD PixelShaderVersion;
637 float PixelShader1xMaxValue;
Stefan Dösinger754b5cf2009-03-22 12:24:28 +0100638 DWORD MaxPixelShaderConst;
Stefan Dösinger5ab52022008-03-18 19:39:26 +0100639
640 WINED3DVSHADERCAPS2_0 VS20Caps;
641 WINED3DPSHADERCAPS2_0 PS20Caps;
642
643 DWORD MaxVShaderInstructionsExecuted;
644 DWORD MaxPShaderInstructionsExecuted;
645 DWORD MaxVertexShader30InstructionSlots;
646 DWORD MaxPixelShader30InstructionSlots;
Stefan Dösinger2cb8f422009-05-08 17:24:01 +0200647
648 BOOL VSClipping;
Stefan Dösinger5ab52022008-03-18 19:39:26 +0100649};
650
Henri Verbeet57401fc2008-10-27 18:31:31 +0100651enum tex_types
652{
653 tex_1d = 0,
654 tex_2d = 1,
655 tex_3d = 2,
656 tex_cube = 3,
657 tex_rect = 4,
658 tex_type_count = 5,
659};
660
Stefan Dösinger61e581a2008-12-14 15:40:07 +0100661enum vertexprocessing_mode {
662 fixedfunction,
663 vertexshader,
664 pretransformed
665};
666
Henri Verbeet362bc0d2009-03-09 14:31:28 +0100667#define WINED3D_CONST_NUM_UNUSED ~0U
668
Stefan Dösinger690cbe72008-12-15 19:35:40 +0100669enum fogmode {
670 FOG_OFF,
671 FOG_LINEAR,
672 FOG_EXP,
673 FOG_EXP2
674};
675
Stefan Dösinger61e581a2008-12-14 15:40:07 +0100676/* Stateblock dependent parameters which have to be hardcoded
677 * into the shader code
678 */
679struct ps_compile_args {
680 struct color_fixup_desc color_fixup[MAX_FRAGMENT_SAMPLERS];
Stefan Dösinger61e581a2008-12-14 15:40:07 +0100681 enum vertexprocessing_mode vp_mode;
Stefan Dösinger690cbe72008-12-15 19:35:40 +0100682 enum fogmode fog;
Stefan Dösinger61e581a2008-12-14 15:40:07 +0100683 /* Projected textures(ps 1.0-1.3) */
684 /* Texture types(2D, Cube, 3D) in ps 1.x */
Tobias Jakobi1b335df2009-03-26 03:15:21 +0100685 BOOL srgb_correction;
Tobias Jakobi0c2514b2009-04-09 19:14:03 +0200686 WORD np2_fixup;
687 /* Bitmap for NP2 texcoord fixups (16 samplers max currently).
Tobias Jakobi1b335df2009-03-26 03:15:21 +0100688 D3D9 has a limit of 16 samplers and the fixup is superfluous
689 in D3D10 (unconditional NP2 support mandatory). */
Stefan Dösinger61e581a2008-12-14 15:40:07 +0100690};
691
Stefan Dösinger8dcd5122009-02-05 19:44:32 +0100692enum fog_src_type {
693 VS_FOG_Z = 0,
694 VS_FOG_COORD = 1
695};
696
697struct vs_compile_args {
698 WORD fog_src;
699 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
700};
701
Henri Verbeet03686cb2009-08-06 08:12:20 +0200702struct wined3d_context;
703
H. Verbeetdf6f4822006-11-27 20:50:37 +0100704typedef struct {
Stefan Dösingere492dd82009-05-27 18:23:16 +0200705 void (*shader_handle_instruction)(const struct wined3d_shader_instruction *);
Henri Verbeet3bf0ad42009-08-07 08:51:18 +0200706 void (*shader_select)(const struct wined3d_context *context, BOOL usePS, BOOL useVS);
Henri Verbeet57401fc2008-10-27 18:31:31 +0100707 void (*shader_select_depth_blt)(IWineD3DDevice *iface, enum tex_types tex_type);
H. Verbeetb37cc082008-07-10 17:57:35 +0200708 void (*shader_deselect_depth_blt)(IWineD3DDevice *iface);
Henri Verbeetd099dde2008-12-17 17:07:25 +0100709 void (*shader_update_float_vertex_constants)(IWineD3DDevice *iface, UINT start, UINT count);
710 void (*shader_update_float_pixel_constants)(IWineD3DDevice *iface, UINT start, UINT count);
Henri Verbeet03686cb2009-08-06 08:12:20 +0200711 void (*shader_load_constants)(const struct wined3d_context *context, char usePS, char useVS);
Tobias Jakobi9b067a62009-04-09 00:55:38 +0200712 void (*shader_load_np2fixup_constants)(IWineD3DDevice *iface, char usePS, char useVS);
Stefan Dösingercfc57252007-11-20 17:40:54 +0100713 void (*shader_destroy)(IWineD3DBaseShader *iface);
Stefan Dösingerf912f182008-02-24 11:23:53 +0100714 HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
715 void (*shader_free_private)(IWineD3DDevice *iface);
Stefan Dösinger107e80a2008-03-04 02:30:23 +0100716 BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface);
Henri Verbeet43e66862009-07-17 10:34:01 +0200717 void (*shader_get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct shader_caps *caps);
Henri Verbeet89139b72008-12-03 14:53:43 +0100718 BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
Stefan Dösinger2fd485a2009-05-03 18:17:07 +0200719 void (*shader_add_instruction_modifiers)(const struct wined3d_shader_instruction *ins);
H. Verbeetdf6f4822006-11-27 20:50:37 +0100720} shader_backend_t;
721
Henri Verbeet689984b2009-09-11 19:01:19 +0200722extern const shader_backend_t glsl_shader_backend DECLSPEC_HIDDEN;
723extern const shader_backend_t arb_program_shader_backend DECLSPEC_HIDDEN;
724extern const shader_backend_t none_shader_backend DECLSPEC_HIDDEN;
H. Verbeetdf6f4822006-11-27 20:50:37 +0100725
Jason Edmeadesc3421ea2004-09-29 21:26:47 +0000726/* X11 locking */
727
Henri Verbeet689984b2009-09-11 19:01:19 +0200728extern void (* CDECL wine_tsx11_lock_ptr)(void) DECLSPEC_HIDDEN;
729extern void (* CDECL wine_tsx11_unlock_ptr)(void) DECLSPEC_HIDDEN;
Jason Edmeadesc3421ea2004-09-29 21:26:47 +0000730
731/* As GLX relies on X, this is needed */
Henri Verbeet689984b2009-09-11 19:01:19 +0200732extern int num_lock DECLSPEC_HIDDEN;
Jason Edmeadesc3421ea2004-09-29 21:26:47 +0000733
734#if 0
735#define ENTER_GL() ++num_lock; if (num_lock > 1) FIXME("Recursive use of GL lock to: %d\n", num_lock); wine_tsx11_lock_ptr()
736#define LEAVE_GL() if (num_lock != 1) FIXME("Recursive use of GL lock: %d\n", num_lock); --num_lock; wine_tsx11_unlock_ptr()
737#else
738#define ENTER_GL() wine_tsx11_lock_ptr()
739#define LEAVE_GL() wine_tsx11_unlock_ptr()
740#endif
741
742/*****************************************************************************
743 * Defines
744 */
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000745
746/* GL related defines */
747/* ------------------ */
Jason Edmeadesf738c142004-12-09 11:42:34 +0000748#define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName)
Jason Edmeadesb5198932004-10-06 00:05:29 +0000749
Raphael Junqueira705aec52005-11-15 12:03:13 +0000750#define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)
751#define D3DCOLOR_B_G(dw) (((dw) >> 8) & 0xFF)
752#define D3DCOLOR_B_B(dw) (((dw) >> 0) & 0xFF)
753#define D3DCOLOR_B_A(dw) (((dw) >> 24) & 0xFF)
754
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000755#define D3DCOLOR_R(dw) (((float) (((dw) >> 16) & 0xFF)) / 255.0f)
756#define D3DCOLOR_G(dw) (((float) (((dw) >> 8) & 0xFF)) / 255.0f)
757#define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
758#define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
759
Alexandre Julliard6800d3d2008-12-03 10:03:26 +0100760#define D3DCOLORTOGLFLOAT4(dw, vec) do { \
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000761 (vec)[0] = D3DCOLOR_R(dw); \
762 (vec)[1] = D3DCOLOR_G(dw); \
763 (vec)[2] = D3DCOLOR_B(dw); \
Alexandre Julliard6800d3d2008-12-03 10:03:26 +0100764 (vec)[3] = D3DCOLOR_A(dw); \
765} while(0)
Roderick Colenbrander54e5f9c2006-05-25 13:54:03 +0200766
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000767/* DirectX Device Limits */
768/* --------------------- */
Henri Verbeet2dcfdd52009-04-24 09:17:58 +0200769#define MAX_MIP_LEVELS 32 /* Maximum number of mipmap levels. */
Henri Verbeet457037f2008-12-31 16:57:10 +0100770#define HIGHEST_TRANSFORMSTATE WINED3DTS_WORLDMATRIX(255) /* Highest value in WINED3DTRANSFORMSTATETYPE */
Jason Edmeades41427852005-01-09 17:37:02 +0000771
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000772/* Checking of API calls */
773/* --------------------- */
Henri Verbeet5284fce2008-12-02 18:41:33 +0100774#ifndef WINE_NO_DEBUG_MSGS
Stefan Dösinger6a04c2d2009-07-15 18:45:03 +0200775#define checkGLcall(A) \
776do { \
777 GLint err; \
778 if(!__WINE_IS_DEBUG_ON(_FIXME, __wine_dbch___default)) break; \
779 err = glGetError(); \
780 if (err == GL_NO_ERROR) { \
781 TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
782 \
783 } else do { \
784 FIXME(">>>>>>>>>>>>>>>>> %s (%#x) from %s @ %s / %d\n", \
785 debug_glerror(err), err, A, __FILE__, __LINE__); \
786 err = glGetError(); \
787 } while (err != GL_NO_ERROR); \
Alexandre Julliard6800d3d2008-12-03 10:03:26 +0100788} while(0)
Henri Verbeet5284fce2008-12-02 18:41:33 +0100789#else
Alexandre Julliard6800d3d2008-12-03 10:03:26 +0100790#define checkGLcall(A) do {} while(0)
Henri Verbeet5284fce2008-12-02 18:41:33 +0100791#endif
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +0000792
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000793/* Trace routines / diagnostics */
794/* ---------------------------- */
795
796/* Dump out a matrix and copy it */
Jason Edmeadeseba27af2004-11-28 15:04:41 +0000797#define conv_mat(mat,gl_mat) \
798do { \
799 TRACE("%f %f %f %f\n", (mat)->u.s._11, (mat)->u.s._12, (mat)->u.s._13, (mat)->u.s._14); \
800 TRACE("%f %f %f %f\n", (mat)->u.s._21, (mat)->u.s._22, (mat)->u.s._23, (mat)->u.s._24); \
801 TRACE("%f %f %f %f\n", (mat)->u.s._31, (mat)->u.s._32, (mat)->u.s._33, (mat)->u.s._34); \
802 TRACE("%f %f %f %f\n", (mat)->u.s._41, (mat)->u.s._42, (mat)->u.s._43, (mat)->u.s._44); \
803 memcpy(gl_mat, (mat), 16 * sizeof(float)); \
804} while (0)
805
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000806/* Trace vector and strided data information */
Henri Verbeet0c4201d2009-08-21 09:12:30 +0200807#define TRACE_STRIDED(si, name) do { if (si->use_map & (1 << name)) \
808 TRACE( #name "=(data:%p, stride:%d, format:%#x, vbo %d, stream %u)\n", \
Henri Verbeetef2d7042009-03-30 11:24:54 +0200809 si->elements[name].data, si->elements[name].stride, si->elements[name].format_desc->format, \
Henri Verbeet0c4201d2009-08-21 09:12:30 +0200810 si->elements[name].buffer_object, si->elements[name].stream_idx); } while(0)
Jason Edmeadesf738c142004-12-09 11:42:34 +0000811
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000812/* Advance declaration of structures to satisfy compiler */
Jason Edmeades447d5ed2004-10-21 20:59:12 +0000813typedef struct IWineD3DStateBlockImpl IWineD3DStateBlockImpl;
Jason Edmeades41427852005-01-09 17:37:02 +0000814typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
Stefan Dösingercff4e1e2006-04-17 17:04:59 +0200815typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
Stefan Dösingerc1623d42007-02-12 19:18:36 +0100816typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
Jason Edmeades447d5ed2004-10-21 20:59:12 +0000817
Jason Edmeades2003c7a2004-12-13 13:35:38 +0000818/* Global variables */
Henri Verbeet689984b2009-09-11 19:01:19 +0200819extern const float identity[16] DECLSPEC_HIDDEN;
Jason Edmeadeseba27af2004-11-28 15:04:41 +0000820
Jason Edmeades24ab49e2004-09-23 04:34:27 +0000821/*****************************************************************************
Jason Edmeadesf738c142004-12-09 11:42:34 +0000822 * Compilable extra diagnostics
823 */
824
825/* Trace information per-vertex: (extremely high amount of trace) */
826#if 0 /* NOTE: Must be 0 in cvs */
827# define VTRACE(A) TRACE A
Henri Verbeet560d6352009-08-27 10:04:56 +0200828#else
829# define VTRACE(A)
Jason Edmeadesf738c142004-12-09 11:42:34 +0000830#endif
831
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000832/* TODO: Confirm each of these works when wined3d move completed */
833#if 0 /* NOTE: Must be 0 in cvs */
834 /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
Francois Gougetef998ea2006-10-15 17:05:01 +0200835 of each frame, a check is made for the existence of C:\D3DTRACE, and if it exists d3d trace
836 is enabled, and if it doesn't exist it is disabled. */
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000837# define FRAME_DEBUGGING
838 /* Adding in the SINGLE_FRAME_DEBUGGING gives a trace of just what makes up a single frame, before
839 the file is deleted */
840# if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
841# define SINGLE_FRAME_DEBUGGING
Henri Verbeet560d6352009-08-27 10:04:56 +0200842# endif
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000843 /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
Henri Verbeet560d6352009-08-27 10:04:56 +0200844 It can only be enabled when FRAME_DEBUGGING is also enabled
845 The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000846 array is drawn. */
Henri Verbeet560d6352009-08-27 10:04:56 +0200847# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000848# define SHOW_FRAME_MAKEUP 1
Henri Verbeet560d6352009-08-27 10:04:56 +0200849# endif
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000850 /* The following, when enabled, lets you see the makeup of the all the textures used during each
851 of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
Henri Verbeet560d6352009-08-27 10:04:56 +0200852 The contents of the textures assigned to each stage are written into
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000853 /tmp/texture_*_<Stage>.ppm after each primitive array is drawn. */
854# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
855# define SHOW_TEXTURE_MAKEUP 0
Henri Verbeet560d6352009-08-27 10:04:56 +0200856# endif
Jason Edmeadesc4de9522004-12-14 11:54:27 +0000857extern BOOL isOn;
858extern BOOL isDumpingFrames;
859extern LONG primCounter;
860#endif
861
Henri Verbeetd7c7c762009-03-27 10:25:55 +0100862enum wined3d_ffp_idx
863{
864 WINED3D_FFP_POSITION = 0,
865 WINED3D_FFP_BLENDWEIGHT = 1,
866 WINED3D_FFP_BLENDINDICES = 2,
867 WINED3D_FFP_NORMAL = 3,
868 WINED3D_FFP_PSIZE = 4,
869 WINED3D_FFP_DIFFUSE = 5,
870 WINED3D_FFP_SPECULAR = 6,
871 WINED3D_FFP_TEXCOORD0 = 7,
872 WINED3D_FFP_TEXCOORD1 = 8,
873 WINED3D_FFP_TEXCOORD2 = 9,
874 WINED3D_FFP_TEXCOORD3 = 10,
875 WINED3D_FFP_TEXCOORD4 = 11,
876 WINED3D_FFP_TEXCOORD5 = 12,
877 WINED3D_FFP_TEXCOORD6 = 13,
878 WINED3D_FFP_TEXCOORD7 = 14,
879};
880
Henri Verbeet4434d002009-03-27 10:25:56 +0100881enum wined3d_ffp_emit_idx
882{
883 WINED3D_FFP_EMIT_FLOAT1 = 0,
884 WINED3D_FFP_EMIT_FLOAT2 = 1,
885 WINED3D_FFP_EMIT_FLOAT3 = 2,
886 WINED3D_FFP_EMIT_FLOAT4 = 3,
887 WINED3D_FFP_EMIT_D3DCOLOR = 4,
888 WINED3D_FFP_EMIT_UBYTE4 = 5,
889 WINED3D_FFP_EMIT_SHORT2 = 6,
890 WINED3D_FFP_EMIT_SHORT4 = 7,
891 WINED3D_FFP_EMIT_UBYTE4N = 8,
892 WINED3D_FFP_EMIT_SHORT2N = 9,
893 WINED3D_FFP_EMIT_SHORT4N = 10,
894 WINED3D_FFP_EMIT_USHORT2N = 11,
895 WINED3D_FFP_EMIT_USHORT4N = 12,
896 WINED3D_FFP_EMIT_UDEC3 = 13,
897 WINED3D_FFP_EMIT_DEC3N = 14,
898 WINED3D_FFP_EMIT_FLOAT16_2 = 15,
899 WINED3D_FFP_EMIT_FLOAT16_4 = 16,
900 WINED3D_FFP_EMIT_COUNT = 17
901};
902
Henri Verbeetd7c7c762009-03-27 10:25:55 +0100903struct wined3d_stream_info_element
904{
Henri Verbeetef2d7042009-03-30 11:24:54 +0200905 const struct GlPixelFormatDesc *format_desc;
Henri Verbeetd7c7c762009-03-27 10:25:55 +0100906 GLsizei stride;
Henri Verbeetd7c7c762009-03-27 10:25:55 +0100907 const BYTE *data;
Henri Verbeetd7c7c762009-03-27 10:25:55 +0100908 UINT stream_idx;
909 GLuint buffer_object;
910};
911
912struct wined3d_stream_info
913{
914 struct wined3d_stream_info_element elements[MAX_ATTRIBS];
915 BOOL position_transformed;
916 WORD swizzle_map; /* MAX_ATTRIBS, 16 */
917 WORD use_map; /* MAX_ATTRIBS, 16 */
918};
919
Jason Edmeadesf738c142004-12-09 11:42:34 +0000920/*****************************************************************************
921 * Prototypes
922 */
923
924/* Routine common to the draw primitive and draw indexed primitive routines */
Henri Verbeet689984b2009-09-11 19:01:19 +0200925void drawPrimitive(IWineD3DDevice *iface, UINT index_count,
926 UINT start_idx, UINT idxBytes, const void *idxData) DECLSPEC_HIDDEN;
927DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
Stefan Dösinger9abdac62006-05-12 22:21:31 +0200928
Henri Verbeet50ebf262008-11-28 15:30:11 +0100929typedef void (WINE_GLAPI *glAttribFunc)(const void *data);
930typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, const void *data);
Henri Verbeet689984b2009-09-11 19:01:19 +0200931extern glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
932extern glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
933extern glAttribFunc specular_func_3ubv DECLSPEC_HIDDEN;
934extern glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
935extern glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
936extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
Stefan Dösinger2d904492007-12-19 17:10:02 +0100937
Stefan Dösinger10ff0d82006-05-09 18:16:13 +0200938#define eps 1e-8
939
Stefan Dösinger9abdac62006-05-12 22:21:31 +0200940#define GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType, tex_num) \
941 (((((d3dvtVertexType) >> (16 + (2 * (tex_num)))) + 1) & 0x03) + 1)
942
Stefan Dösingerc0268c72006-12-05 23:36:10 +0100943/* Routines and structures related to state management */
Stefan Dösingerc0268c72006-12-05 23:36:10 +0100944
Stefan Dösinger2a24e842006-12-06 13:22:12 +0100945#define STATE_RENDER(a) (a)
946#define STATE_IS_RENDER(a) ((a) >= STATE_RENDER(1) && (a) <= STATE_RENDER(WINEHIGHEST_RENDER_STATE))
947
Henri Verbeeta8697d92009-01-06 11:43:45 +0100948#define STATE_TEXTURESTAGE(stage, num) (STATE_RENDER(WINEHIGHEST_RENDER_STATE) + 1 + (stage) * (WINED3D_HIGHEST_TEXTURE_STATE + 1) + (num))
Stefan Dösinger569a2fa2006-12-19 22:43:49 +0100949#define STATE_IS_TEXTURESTAGE(a) ((a) >= STATE_TEXTURESTAGE(0, 1) && (a) <= STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE))
950
Stefan Dösinger2d1aeb42006-12-19 23:14:07 +0100951/* + 1 because samplers start with 0 */
952#define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
H. Verbeet5b7758f2007-06-25 22:45:40 +0200953#define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
Stefan Dösinger2d1aeb42006-12-19 23:14:07 +0100954
H. Verbeet5b7758f2007-06-25 22:45:40 +0200955#define STATE_PIXELSHADER (STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1) + 1)
Stefan Dösinger22e2a5a2006-12-19 23:22:19 +0100956#define STATE_IS_PIXELSHADER(a) ((a) == STATE_PIXELSHADER)
957
Stefan Dösingerb58715e2006-12-28 18:57:16 +0100958#define STATE_TRANSFORM(a) (STATE_PIXELSHADER + (a))
959#define STATE_IS_TRANSFORM(a) ((a) >= STATE_TRANSFORM(1) && (a) <= STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)))
960
Stefan Dösingeref1ebb62007-01-02 00:35:07 +0100961#define STATE_STREAMSRC (STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(255)) + 1)
962#define STATE_IS_STREAMSRC(a) ((a) == STATE_STREAMSRC)
Stefan Dösinger59ae2a52007-02-19 15:25:32 +0100963#define STATE_INDEXBUFFER (STATE_STREAMSRC + 1)
964#define STATE_IS_INDEXBUFFER(a) ((a) == STATE_INDEXBUFFER)
Stefan Dösingeref1ebb62007-01-02 00:35:07 +0100965
Stefan Dösinger59ae2a52007-02-19 15:25:32 +0100966#define STATE_VDECL (STATE_INDEXBUFFER + 1)
Stefan Dösingeref1ebb62007-01-02 00:35:07 +0100967#define STATE_IS_VDECL(a) ((a) == STATE_VDECL)
968
969#define STATE_VSHADER (STATE_VDECL + 1)
970#define STATE_IS_VSHADER(a) ((a) == STATE_VSHADER)
971
Stefan Dösingera48bbc32007-01-02 21:40:59 +0100972#define STATE_VIEWPORT (STATE_VSHADER + 1)
973#define STATE_IS_VIEWPORT(a) ((a) == STATE_VIEWPORT)
974
Stefan Dösinger8e37fcd2007-01-06 18:17:27 +0100975#define STATE_VERTEXSHADERCONSTANT (STATE_VIEWPORT + 1)
976#define STATE_PIXELSHADERCONSTANT (STATE_VERTEXSHADERCONSTANT + 1)
977#define STATE_IS_VERTEXSHADERCONSTANT(a) ((a) == STATE_VERTEXSHADERCONSTANT)
978#define STATE_IS_PIXELSHADERCONSTANT(a) ((a) == STATE_PIXELSHADERCONSTANT)
979
Stefan Dösinger174b6322007-02-14 17:48:52 +0100980#define STATE_ACTIVELIGHT(a) (STATE_PIXELSHADERCONSTANT + (a) + 1)
H. Verbeetcb4c9b62007-07-15 23:46:06 +0200981#define STATE_IS_ACTIVELIGHT(a) ((a) >= STATE_ACTIVELIGHT(0) && (a) < STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS))
Stefan Dösinger174b6322007-02-14 17:48:52 +0100982
Stefan Dösingerecfd4cb2007-02-19 15:25:16 +0100983#define STATE_SCISSORRECT (STATE_ACTIVELIGHT(MAX_ACTIVE_LIGHTS - 1) + 1)
984#define STATE_IS_SCISSORRECT(a) ((a) == STATE_SCISSORRECT)
985
Stefan Dösinger409aa732007-02-28 14:36:36 +0100986#define STATE_CLIPPLANE(a) (STATE_SCISSORRECT + 1 + (a))
987#define STATE_IS_CLIPPLANE(a) ((a) >= STATE_CLIPPLANE(0) && (a) <= STATE_CLIPPLANE(MAX_CLIPPLANES - 1))
988
Stefan Dösinger2f4b9e42007-06-15 21:33:54 +0200989#define STATE_MATERIAL (STATE_CLIPPLANE(MAX_CLIPPLANES))
990
Stefan Dösinger5a63b792007-09-18 11:43:09 +0200991#define STATE_FRONTFACE (STATE_MATERIAL + 1)
992
993#define STATE_HIGHEST (STATE_FRONTFACE)
Stefan Dösinger7532c752006-12-19 13:00:03 +0100994
Stefan Dösinger1deafcb2008-12-15 19:37:36 +0100995enum fogsource {
996 FOGSOURCE_FFP,
997 FOGSOURCE_VS,
998 FOGSOURCE_COORD,
999};
1000
Henri Verbeet0d446052009-05-11 16:43:49 +02001001#define WINED3D_MAX_FBO_ENTRIES 64
1002
Henri Verbeet4ab7af62009-07-24 10:44:13 +02001003struct wined3d_occlusion_query
1004{
1005 struct list entry;
1006 GLuint id;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001007 struct wined3d_context *context;
Henri Verbeet4ab7af62009-07-24 10:44:13 +02001008};
1009
Henri Verbeetfb776782009-07-24 10:44:14 +02001010struct wined3d_event_query
1011{
1012 struct list entry;
1013 GLuint id;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001014 struct wined3d_context *context;
Henri Verbeetfb776782009-07-24 10:44:14 +02001015};
1016
Henri Verbeetda1e5572009-08-03 08:06:51 +02001017struct wined3d_context
Henri Verbeeta01616a2009-07-17 10:34:02 +02001018{
1019 const struct wined3d_gl_info *gl_info;
Stefan Dösinger380930d2007-02-12 19:18:31 +01001020 /* State dirtification
1021 * dirtyArray is an array that contains markers for dirty states. numDirtyEntries states are dirty, their numbers are in indices
1022 * 0...numDirtyEntries - 1. isStateDirty is a redundant copy of the dirtyArray. Technically only one of them would be needed,
1023 * 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
1024 * only numDirtyEntries array elements have to be checked, not STATE_HIGHEST states.
1025 */
1026 DWORD dirtyArray[STATE_HIGHEST + 1]; /* Won't get bigger than that, a state is never marked dirty 2 times */
1027 DWORD numDirtyEntries;
1028 DWORD isStateDirty[STATE_HIGHEST/32 + 1]; /* Bitmap to find out quickly if a state is dirty */
1029
Stefan Dösinger12252d02007-02-12 19:21:10 +01001030 IWineD3DSurface *surface;
Henri Verbeet6c0c1672009-07-21 11:51:08 +02001031 IWineD3DSurface *current_rt;
Stefan Dösinger90fe64c2007-03-04 17:31:06 +01001032 DWORD tid; /* Thread ID which owns this context at the moment */
Stefan Dösinger380930d2007-02-12 19:18:31 +01001033
Austin English3471f842008-01-09 13:37:05 -06001034 /* Stores some information about the context state for optimization */
Henri Verbeeta7251f02009-08-06 08:12:19 +02001035 WORD render_offscreen : 1;
Henri Verbeet3f12f592008-12-30 14:56:49 +01001036 WORD draw_buffer_dirty : 1;
1037 WORD last_was_rhw : 1; /* true iff last draw_primitive was in xyzrhw mode */
1038 WORD last_was_pshader : 1;
1039 WORD last_was_vshader : 1;
Henri Verbeet3f12f592008-12-30 14:56:49 +01001040 WORD namedArraysLoaded : 1;
1041 WORD numberedArraysLoaded : 1;
1042 WORD last_was_blit : 1;
1043 WORD last_was_ckey : 1;
1044 WORD fog_coord : 1;
Henri Verbeet3f12f592008-12-30 14:56:49 +01001045 WORD fog_enabled : 1;
1046 WORD num_untracked_materials : 2; /* Max value 2 */
Henri Verbeet377cda92009-07-22 10:41:06 +02001047 WORD current : 1;
1048 WORD destroyed : 1;
Henri Verbeet43aaaa82009-10-20 11:05:04 +02001049 WORD valid : 1;
Henri Verbeet3f12f592008-12-30 14:56:49 +01001050 BYTE texShaderBumpMap; /* MAX_TEXTURES, 8 */
1051 BYTE lastWasPow2Texture; /* MAX_TEXTURES, 8 */
Henri Verbeet5ad3bba2008-12-08 10:30:02 +01001052 DWORD numbered_array_mask;
Stefan Dösinger380930d2007-02-12 19:18:31 +01001053 GLenum tracking_parm; /* Which source is tracking current colour */
Stefan Dösingerb081cba2007-06-20 14:36:32 +02001054 GLenum untracked_materials[2];
Stefan Dösinger74c56842008-06-17 01:41:49 +02001055 UINT blit_w, blit_h;
Stefan Dösinger1deafcb2008-12-15 19:37:36 +01001056 enum fogsource fog_source;
Stefan Dösinger12252d02007-02-12 19:21:10 +01001057
Stefan Dösinger107e80a2008-03-04 02:30:23 +01001058 char *vshader_const_dirty, *pshader_const_dirty;
1059
Stefan Dösinger12252d02007-02-12 19:21:10 +01001060 /* The actual opengl context */
Henri Verbeeteeb54b92009-10-28 11:00:11 +01001061 UINT level;
Henri Verbeetc0050b82009-10-28 11:00:13 +01001062 HGLRC restore_ctx;
1063 HDC restore_dc;
Roderick Colenbranderac3927a2007-08-08 03:09:38 +02001064 HGLRC glCtx;
1065 HWND win_handle;
1066 HDC hdc;
1067 HPBUFFERARB pbuffer;
Stefan Dösinger67e09432008-04-08 14:20:27 +02001068 GLint aux_buffers;
H. Verbeet05931f42008-08-21 18:34:55 +02001069
1070 /* FBOs */
Henri Verbeet0d446052009-05-11 16:43:49 +02001071 UINT fbo_entry_count;
Henri Verbeet45820042008-09-18 14:57:53 +02001072 struct list fbo_list;
Henri Verbeet94d33d32009-10-20 11:05:06 +02001073 struct list fbo_destroy_list;
Henri Verbeet45820042008-09-18 14:57:53 +02001074 struct fbo_entry *current_fbo;
H. Verbeet05931f42008-08-21 18:34:55 +02001075 GLuint src_fbo;
1076 GLuint dst_fbo;
Henri Verbeeta80247f2009-07-17 10:34:05 +02001077 GLuint fbo_read_binding;
1078 GLuint fbo_draw_binding;
Stefan Dösinger31da3c02008-12-15 19:21:37 +01001079
Henri Verbeet4ab7af62009-07-24 10:44:13 +02001080 /* Queries */
1081 GLuint *free_occlusion_queries;
1082 UINT free_occlusion_query_size;
1083 UINT free_occlusion_query_count;
1084 struct list occlusion_queries;
1085
Henri Verbeetfb776782009-07-24 10:44:14 +02001086 GLuint *free_event_queries;
1087 UINT free_event_query_size;
1088 UINT free_event_query_count;
1089 struct list event_queries;
1090
Stefan Dösinger31da3c02008-12-15 19:21:37 +01001091 /* Extension emulation */
Stefan Dösinger31da3c02008-12-15 19:21:37 +01001092 GLint gl_fog_source;
1093 GLfloat fog_coord_value;
1094 GLfloat color[4], fogstart, fogend, fogcolor[4];
Stefan Dösinger06295852009-05-07 11:40:44 +02001095 GLuint dummy_arbfp_prog;
Stefan Dösinger380930d2007-02-12 19:18:31 +01001096};
1097
Henri Verbeetda1e5572009-08-03 08:06:51 +02001098typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *ctx);
1099
1100struct StateEntry
1101{
1102 DWORD representative;
1103 APPLYSTATEFUNC apply;
1104};
1105
1106struct StateEntryTemplate
1107{
1108 DWORD state;
1109 struct StateEntry content;
1110 GL_SupportedExt extension;
1111};
1112
1113struct fragment_caps
1114{
1115 DWORD PrimitiveMiscCaps;
1116 DWORD TextureOpCaps;
1117 DWORD MaxTextureBlendStages;
1118 DWORD MaxSimultaneousTextures;
1119};
1120
1121struct fragment_pipeline
1122{
1123 void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);
1124 void (*get_caps)(WINED3DDEVTYPE devtype, const struct wined3d_gl_info *gl_info, struct fragment_caps *caps);
1125 HRESULT (*alloc_private)(IWineD3DDevice *iface);
1126 void (*free_private)(IWineD3DDevice *iface);
1127 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
1128 const struct StateEntryTemplate *states;
1129 BOOL ffp_proj_control;
1130};
1131
Henri Verbeet689984b2009-09-11 19:01:19 +02001132extern const struct StateEntryTemplate misc_state_template[] DECLSPEC_HIDDEN;
1133extern const struct StateEntryTemplate ffp_vertexstate_template[] DECLSPEC_HIDDEN;
1134extern const struct fragment_pipeline ffp_fragment_pipeline DECLSPEC_HIDDEN;
1135extern const struct fragment_pipeline atifs_fragment_pipeline DECLSPEC_HIDDEN;
1136extern const struct fragment_pipeline arbfp_fragment_pipeline DECLSPEC_HIDDEN;
1137extern const struct fragment_pipeline nvts_fragment_pipeline DECLSPEC_HIDDEN;
1138extern const struct fragment_pipeline nvrc_fragment_pipeline DECLSPEC_HIDDEN;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001139
1140/* "Base" state table */
1141HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
1142 const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex,
Henri Verbeet689984b2009-09-11 19:01:19 +02001143 const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001144
1145/* Shaders for color conversions in blits */
1146struct blit_shader
1147{
1148 HRESULT (*alloc_private)(IWineD3DDevice *iface);
1149 void (*free_private)(IWineD3DDevice *iface);
1150 HRESULT (*set_shader)(IWineD3DDevice *iface, const struct GlPixelFormatDesc *format_desc,
1151 GLenum textype, UINT width, UINT height);
1152 void (*unset_shader)(IWineD3DDevice *iface);
1153 BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
1154};
1155
Henri Verbeet689984b2009-09-11 19:01:19 +02001156extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
1157extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001158
Stefan Dösingerc1623d42007-02-12 19:18:36 +01001159typedef enum ContextUsage {
1160 CTXUSAGE_RESOURCELOAD = 1, /* Only loads textures: No State is applied */
Austin English3471f842008-01-09 13:37:05 -06001161 CTXUSAGE_DRAWPRIM = 2, /* OpenGL states are set up for blitting DirectDraw surfaces */
Stefan Dösingerc1623d42007-02-12 19:18:36 +01001162 CTXUSAGE_BLIT = 3, /* OpenGL states are set up 3D drawing */
Stefan Dösingerfdadf262007-07-09 16:57:58 +02001163 CTXUSAGE_CLEAR = 4, /* Drawable and states are set up for clearing */
Stefan Dösingerc1623d42007-02-12 19:18:36 +01001164} ContextUsage;
1165
Henri Verbeeteeb54b92009-10-28 11:00:11 +01001166struct wined3d_context *context_acquire(IWineD3DDeviceImpl *This,
1167 IWineD3DSurface *target, enum ContextUsage usage) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02001168void context_alloc_event_query(struct wined3d_context *context,
1169 struct wined3d_event_query *query) DECLSPEC_HIDDEN;
1170void context_alloc_occlusion_query(struct wined3d_context *context,
1171 struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
1172void context_resource_released(IWineD3DDevice *iface,
1173 IWineD3DResource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
1174void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo) DECLSPEC_HIDDEN;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001175void context_attach_depth_stencil_fbo(struct wined3d_context *context,
Henri Verbeet689984b2009-09-11 19:01:19 +02001176 GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001177void context_attach_surface_fbo(const struct wined3d_context *context,
Henri Verbeet689984b2009-09-11 19:01:19 +02001178 GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
Henri Verbeet98027cb2009-10-28 11:00:12 +01001179struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win,
1180 BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
Henri Verbeete6ca1762009-10-28 11:00:14 +01001181void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02001182void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
1183void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
1184struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
1185DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
Henri Verbeeteeb54b92009-10-28 11:00:11 +01001186void context_release(struct wined3d_context *context) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02001187BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN;
1188void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
Stefan Dösingerc1623d42007-02-12 19:18:36 +01001189
Henri Verbeet689984b2009-09-11 19:01:19 +02001190void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
1191HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
Stefan Dösinger7f2b8f92008-07-29 12:09:34 -05001192
Roderick Colenbranderde97fa72006-08-19 11:58:23 +02001193/* Macros for doing basic GPU detection based on opengl capabilities */
1194#define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE])
1195#define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
1196#define WINE_D3D8_CAPABLE(gl_info) WINE_D3D7_CAPABLE(gl_info) && (gl_info->supported[ARB_MULTISAMPLE] && gl_info->supported[ARB_TEXTURE_BORDER_CLAMP])
1197#define WINE_D3D9_CAPABLE(gl_info) WINE_D3D8_CAPABLE(gl_info) && (gl_info->supported[ARB_FRAGMENT_PROGRAM] && gl_info->supported[ARB_VERTEX_SHADER])
1198
Jason Edmeadesf738c142004-12-09 11:42:34 +00001199/*****************************************************************************
Jason Edmeades0a944ae2004-11-29 17:53:42 +00001200 * Internal representation of a light
1201 */
Henri Verbeet3bc9d182009-10-14 10:55:16 +02001202struct wined3d_light_info
1203{
Jason Edmeades0a944ae2004-11-29 17:53:42 +00001204 WINED3DLIGHT OriginalParms; /* Note D3D8LIGHT == D3D9LIGHT */
1205 DWORD OriginalIndex;
1206 LONG glIndex;
Stefan Dösinger3cc253c2007-11-29 13:22:47 +01001207 BOOL enabled;
Jason Edmeades0a944ae2004-11-29 17:53:42 +00001208
1209 /* Converted parms to speed up swapping lights */
1210 float lightPosn[4];
1211 float lightDirn[4];
1212 float exponent;
1213 float cutoff;
1214
Stefan Dösingeracadf3f2007-02-14 17:46:54 +01001215 struct list entry;
Jason Edmeades0a944ae2004-11-29 17:53:42 +00001216};
1217
Ivan Gyurdiev4d666152006-06-06 23:37:05 -04001218/* The default light parameters */
Henri Verbeet689984b2009-09-11 19:01:19 +02001219extern const WINED3DLIGHT WINED3D_default_light DECLSPEC_HIDDEN;
Ivan Gyurdiev4d666152006-06-06 23:37:05 -04001220
Roderick Colenbranderd391c112007-08-11 16:25:58 +02001221typedef struct WineD3D_PixelFormat
1222{
1223 int iPixelFormat; /* WGL pixel format */
Roderick Colenbrander51a81622008-03-21 14:52:15 +01001224 int iPixelType; /* WGL pixel type e.g. WGL_TYPE_RGBA_ARB, WGL_TYPE_RGBA_FLOAT_ARB or WGL_TYPE_COLORINDEX_ARB */
Roderick Colenbranderd391c112007-08-11 16:25:58 +02001225 int redSize, greenSize, blueSize, alphaSize;
1226 int depthSize, stencilSize;
Roderick Colenbranderd44c2952008-03-16 16:37:38 +00001227 BOOL windowDrawable;
1228 BOOL pbufferDrawable;
Roderick Colenbrander31dc00a2008-04-27 17:36:34 +00001229 BOOL doubleBuffer;
1230 int auxBuffers;
Roderick Colenbrander628e4ee2008-04-28 21:44:21 +00001231 int numSamples;
Roderick Colenbranderd391c112007-08-11 16:25:58 +02001232} WineD3D_PixelFormat;
1233
Henri Verbeet2447c8b2009-10-27 10:10:39 +01001234enum wined3d_pci_vendor
1235{
1236 VENDOR_WINE = 0x0000,
1237 VENDOR_MESA = 0x0001,
1238 VENDOR_ATI = 0x1002,
1239 VENDOR_NVIDIA = 0x10de,
1240 VENDOR_INTEL = 0x8086,
1241};
1242
1243enum wined3d_pci_device
1244{
1245 CARD_WINE = 0x0000,
1246
1247 CARD_ATI_RAGE_128PRO = 0x5246,
1248 CARD_ATI_RADEON_7200 = 0x5144,
1249 CARD_ATI_RADEON_8500 = 0x514c,
1250 CARD_ATI_RADEON_9500 = 0x4144,
1251 CARD_ATI_RADEON_XPRESS_200M = 0x5955,
1252 CARD_ATI_RADEON_X700 = 0x5e4c,
1253 CARD_ATI_RADEON_X1600 = 0x71c2,
1254 CARD_ATI_RADEON_HD2300 = 0x7210,
1255 CARD_ATI_RADEON_HD2600 = 0x9581,
1256 CARD_ATI_RADEON_HD2900 = 0x9400,
1257 CARD_ATI_RADEON_HD3200 = 0x9620,
1258 CARD_ATI_RADEON_HD4350 = 0x954f,
1259 CARD_ATI_RADEON_HD4550 = 0x9540,
1260 CARD_ATI_RADEON_HD4600 = 0x9495,
1261 CARD_ATI_RADEON_HD4650 = 0x9498,
1262 CARD_ATI_RADEON_HD4670 = 0x9490,
1263 CARD_ATI_RADEON_HD4700 = 0x944e,
1264 CARD_ATI_RADEON_HD4770 = 0x94b3,
1265 CARD_ATI_RADEON_HD4800 = 0x944c, /* Picked one value between 9440, 944c, 9442, 9460 */
1266 CARD_ATI_RADEON_HD4830 = 0x944c,
1267 CARD_ATI_RADEON_HD4850 = 0x9442,
1268 CARD_ATI_RADEON_HD4870 = 0x9440,
1269 CARD_ATI_RADEON_HD4890 = 0x9460,
1270
1271 CARD_NVIDIA_RIVA_128 = 0x0018,
1272 CARD_NVIDIA_RIVA_TNT = 0x0020,
1273 CARD_NVIDIA_RIVA_TNT2 = 0x0028,
1274 CARD_NVIDIA_GEFORCE = 0x0100,
1275 CARD_NVIDIA_GEFORCE2_MX = 0x0110,
1276 CARD_NVIDIA_GEFORCE2 = 0x0150,
1277 CARD_NVIDIA_GEFORCE3 = 0x0200,
1278 CARD_NVIDIA_GEFORCE4_MX = 0x0170,
1279 CARD_NVIDIA_GEFORCE4_TI4200 = 0x0253,
1280 CARD_NVIDIA_GEFORCEFX_5200 = 0x0320,
1281 CARD_NVIDIA_GEFORCEFX_5600 = 0x0312,
1282 CARD_NVIDIA_GEFORCEFX_5800 = 0x0302,
1283 CARD_NVIDIA_GEFORCE_6200 = 0x014f,
1284 CARD_NVIDIA_GEFORCE_6600GT = 0x0140,
1285 CARD_NVIDIA_GEFORCE_6800 = 0x0041,
1286 CARD_NVIDIA_GEFORCE_7400 = 0x01d8,
1287 CARD_NVIDIA_GEFORCE_7300 = 0x01d7, /* GeForce Go 7300 */
1288 CARD_NVIDIA_GEFORCE_7600 = 0x0391,
1289 CARD_NVIDIA_GEFORCE_7800GT = 0x0092,
1290 CARD_NVIDIA_GEFORCE_8300GS = 0x0423,
1291 CARD_NVIDIA_GEFORCE_8600GT = 0x0402,
1292 CARD_NVIDIA_GEFORCE_8600MGT = 0x0407,
1293 CARD_NVIDIA_GEFORCE_8800GTS = 0x0193,
1294 CARD_NVIDIA_GEFORCE_9200 = 0x086d,
1295 CARD_NVIDIA_GEFORCE_9400GT = 0x042c,
1296 CARD_NVIDIA_GEFORCE_9500GT = 0x0640,
1297 CARD_NVIDIA_GEFORCE_9600GT = 0x0622,
1298 CARD_NVIDIA_GEFORCE_9800GT = 0x0614,
1299 CARD_NVIDIA_GEFORCE_GTX260 = 0x05e2,
1300 CARD_NVIDIA_GEFORCE_GTX275 = 0x05e6,
1301 CARD_NVIDIA_GEFORCE_GTX280 = 0x05e1,
1302
1303 CARD_INTEL_845G = 0x2562,
1304 CARD_INTEL_I830G = 0x3577,
1305 CARD_INTEL_I855G = 0x3582,
1306 CARD_INTEL_I865G = 0x2572,
1307 CARD_INTEL_I915G = 0x2582,
1308 CARD_INTEL_I915GM = 0x2592,
1309 CARD_INTEL_I945GM = 0x27a2, /* Same as GMA 950? */
1310 CARD_INTEL_X3100 = 0x2a02, /* Found in Macs. Same as GMA 965? */
1311};
1312
Henri Verbeet5fbe5ee2009-10-26 10:12:16 +01001313struct wined3d_driver_info
1314{
Henri Verbeet2447c8b2009-10-27 10:10:39 +01001315 enum wined3d_pci_vendor vendor;
1316 enum wined3d_pci_device device;
Henri Verbeet5fbe5ee2009-10-26 10:12:16 +01001317 const char *name;
1318 const char *description;
1319 DWORD version_high;
1320 DWORD version_low;
1321};
1322
Stefan Dösingera460a2d2007-06-09 14:27:41 +02001323/* The adapter structure */
Henri Verbeetf2aaca22009-10-21 10:33:58 +02001324struct wined3d_adapter
Stefan Dösingera460a2d2007-06-09 14:27:41 +02001325{
Stefan Dösinger7f10ee42007-12-06 23:43:25 +01001326 UINT num;
Stefan Dösinger9e831a82008-03-28 23:04:17 +01001327 BOOL opengl;
Stefan Dösingera460a2d2007-06-09 14:27:41 +02001328 POINT monitorPoint;
Henri Verbeet43e66862009-07-17 10:34:01 +02001329 struct wined3d_gl_info gl_info;
Henri Verbeet5fbe5ee2009-10-26 10:12:16 +01001330 struct wined3d_driver_info driver_info;
Roderick Colenbrander6b177c42007-08-13 16:47:17 +02001331 WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
Stefan Dösingerefbdd512007-06-08 14:16:37 +02001332 int nCfgs;
Roderick Colenbranderd391c112007-08-11 16:25:58 +02001333 WineD3D_PixelFormat *cfgs;
Roderick Colenbrander7b5561c2008-05-03 14:37:09 +00001334 BOOL brokenStencil; /* Set on cards which only offer mixed depth+stencil */
Roderick Colenbrander243ac3e2007-09-23 00:46:21 +02001335 unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */
1336 unsigned int UsedTextureRam;
Stefan Dösingera460a2d2007-06-09 14:27:41 +02001337};
1338
Henri Verbeet2447c8b2009-10-27 10:10:39 +01001339BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor vendor) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02001340BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
1341extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram) DECLSPEC_HIDDEN;
1342extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
Stefan Dösingera460a2d2007-06-09 14:27:41 +02001343
Jason Edmeades0a944ae2004-11-29 17:53:42 +00001344/*****************************************************************************
Stefan Dösinger26ebe392007-07-04 17:57:45 +02001345 * High order patch management
1346 */
1347struct WineD3DRectPatch
1348{
1349 UINT Handle;
1350 float *mem;
1351 WineDirect3DVertexStridedData strided;
1352 WINED3DRECTPATCH_INFO RectPatchInfo;
1353 float numSegs[4];
1354 char has_normals, has_texcoords;
1355 struct list entry;
1356};
1357
Henri Verbeet689984b2009-09-11 19:01:19 +02001358HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, struct WineD3DRectPatch *patch) DECLSPEC_HIDDEN;
Stefan Dösinger26ebe392007-07-04 17:57:45 +02001359
Stefan Dösinger4640be82008-03-22 14:31:52 +01001360enum projection_types
1361{
Stefan Dösingerd4d133f2008-07-30 10:57:32 -05001362 proj_none = 0,
1363 proj_count3 = 1,
1364 proj_count4 = 2
1365};
1366
Stefan Dösingerd4d133f2008-07-30 10:57:32 -05001367enum dst_arg
1368{
1369 resultreg = 0,
1370 tempreg = 1
Stefan Dösinger4640be82008-03-22 14:31:52 +01001371};
1372
1373/*****************************************************************************
1374 * Fixed function pipeline replacements
1375 */
Stefan Dösingerf2f90b62008-12-09 20:02:18 +01001376#define ARG_UNUSED 0xff
Stefan Dösinger4640be82008-03-22 14:31:52 +01001377struct texture_stage_op
1378{
Henri Verbeet89139b72008-12-03 14:53:43 +01001379 unsigned cop : 8;
1380 unsigned carg1 : 8;
1381 unsigned carg2 : 8;
1382 unsigned carg0 : 8;
1383
1384 unsigned aop : 8;
1385 unsigned aarg1 : 8;
1386 unsigned aarg2 : 8;
1387 unsigned aarg0 : 8;
1388
Henri Verbeet4aa00e82008-12-10 10:04:40 +01001389 struct color_fixup_desc color_fixup;
Stefan Dösingerd4d133f2008-07-30 10:57:32 -05001390 unsigned tex_type : 3;
Henri Verbeet89139b72008-12-03 14:53:43 +01001391 unsigned dst : 1;
Stefan Dösingerd4d133f2008-07-30 10:57:32 -05001392 unsigned projected : 2;
Henri Verbeet89139b72008-12-03 14:53:43 +01001393 unsigned padding : 10;
Stefan Dösinger4640be82008-03-22 14:31:52 +01001394};
1395
Stefan Dösinger5c79a9f2008-11-07 17:15:29 +01001396struct ffp_frag_settings {
Stefan Dösinger294f1b42008-07-11 21:18:06 -05001397 struct texture_stage_op op[MAX_TEXTURES];
Stefan Dösinger690cbe72008-12-15 19:35:40 +01001398 enum fogmode fog;
Stefan Dösinger85af0b22009-06-22 16:25:37 +02001399 /* Use shorts instead of chars to get dword alignment */
1400 unsigned short sRGB_write;
1401 unsigned short emul_clipplanes;
Stefan Dösinger294f1b42008-07-11 21:18:06 -05001402};
1403
Stefan Dösinger5c79a9f2008-11-07 17:15:29 +01001404struct ffp_frag_desc
Stefan Dösinger4640be82008-03-22 14:31:52 +01001405{
Henri Verbeetad6279d2009-06-03 10:47:26 +02001406 struct wine_rb_entry entry;
Stefan Dösinger5c79a9f2008-11-07 17:15:29 +01001407 struct ffp_frag_settings settings;
Stefan Dösinger4640be82008-03-22 14:31:52 +01001408};
1409
Henri Verbeet689984b2009-09-11 19:01:19 +02001410extern const struct wine_rb_functions wined3d_ffp_frag_program_rb_functions DECLSPEC_HIDDEN;
Henri Verbeeta5214c32009-09-16 08:37:15 +02001411extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
Henri Verbeetad6279d2009-06-03 10:47:26 +02001412
Henri Verbeet689984b2009-09-11 19:01:19 +02001413void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings,
1414 BOOL ignore_textype) DECLSPEC_HIDDEN;
Henri Verbeetad6279d2009-06-03 10:47:26 +02001415const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
Henri Verbeet689984b2009-09-11 19:01:19 +02001416 const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
1417void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
Stefan Dösinger4640be82008-03-22 14:31:52 +01001418
Stefan Dösinger26ebe392007-07-04 17:57:45 +02001419/*****************************************************************************
Jason Edmeades24ab49e2004-09-23 04:34:27 +00001420 * IWineD3D implementation structure
1421 */
1422typedef struct IWineD3DImpl
1423{
1424 /* IUnknown fields */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001425 const IWineD3DVtbl *lpVtbl;
Mike McCormack8955ac42005-07-28 10:16:21 +00001426 LONG ref; /* Note: Ref counting not required */
Jason Edmeades24ab49e2004-09-23 04:34:27 +00001427
1428 /* WineD3D Information */
Jason Edmeades289562e2004-11-23 13:52:46 +00001429 IUnknown *parent;
Jason Edmeades24ab49e2004-09-23 04:34:27 +00001430 UINT dxVersion;
Henri Verbeet2cc43392009-03-11 10:15:09 +01001431
1432 UINT adapter_count;
Henri Verbeetf2aaca22009-10-21 10:33:58 +02001433 struct wined3d_adapter adapters[1];
Jason Edmeades24ab49e2004-09-23 04:34:27 +00001434} IWineD3DImpl;
1435
Henri Verbeet689984b2009-09-11 19:01:19 +02001436extern const IWineD3DVtbl IWineD3D_Vtbl DECLSPEC_HIDDEN;
Jason Edmeades24ab49e2004-09-23 04:34:27 +00001437
Henri Verbeet689984b2009-09-11 19:01:19 +02001438BOOL InitAdapters(IWineD3DImpl *This) DECLSPEC_HIDDEN;
Henri Verbeet2cc43392009-03-11 10:15:09 +01001439
Stefan Dösingere0c87732006-04-10 19:39:53 +02001440/* A helper function that dumps a resource list */
Henri Verbeet689984b2009-09-11 19:01:19 +02001441void dumpResources(struct list *list) DECLSPEC_HIDDEN;
Stefan Dösingere0c87732006-04-10 19:39:53 +02001442
Jason Edmeadesac490fa2004-10-07 04:22:21 +00001443/*****************************************************************************
1444 * IWineD3DDevice implementation structure
1445 */
Henri Verbeet4ff57362009-03-09 14:31:28 +01001446#define WINED3D_UNMAPPED_STAGE ~0U
1447
Henri Verbeet7420a962009-05-01 09:13:54 +02001448/* Multithreaded flag. Removed from the public header to signal that IWineD3D::CreateDevice ignores it */
1449#define WINED3DCREATE_MULTITHREADED 0x00000004
1450
Stefan Dösingerc1623d42007-02-12 19:18:36 +01001451struct IWineD3DDeviceImpl
Jason Edmeadesac490fa2004-10-07 04:22:21 +00001452{
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001453 /* IUnknown fields */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001454 const IWineD3DDeviceVtbl *lpVtbl;
Mike McCormack8955ac42005-07-28 10:16:21 +00001455 LONG ref; /* Note: Ref counting not required */
Jason Edmeadesac490fa2004-10-07 04:22:21 +00001456
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001457 /* WineD3D Information */
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001458 IUnknown *parent;
Henri Verbeeta9662932009-01-16 10:14:24 +01001459 IWineD3DDeviceParent *device_parent;
Jason Edmeadeseba27af2004-11-28 15:04:41 +00001460 IWineD3D *wineD3D;
Henri Verbeetf2aaca22009-10-21 10:33:58 +02001461 struct wined3d_adapter *adapter;
Jason Edmeadesac490fa2004-10-07 04:22:21 +00001462
H. Verbeet61125222007-01-18 23:41:36 +01001463 /* Window styles to restore when switching fullscreen mode */
1464 LONG style;
1465 LONG exStyle;
1466
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001467 /* X and GL Information */
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001468 GLint maxConcurrentLights;
Stefan Dösinger8d9a5532007-02-27 21:32:15 +01001469 GLenum offscreenBuffer;
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001470
Ivan Gyurdieve020ece2006-10-07 23:25:01 -04001471 /* Selected capabilities */
1472 int vs_selected_mode;
1473 int ps_selected_mode;
H. Verbeet8a7f4272006-11-27 20:50:43 +01001474 const shader_backend_t *shader_backend;
Stefan Dösingerf912f182008-02-24 11:23:53 +01001475 void *shader_priv;
Stefan Dösingere7733ea2008-07-11 09:41:28 -05001476 void *fragment_priv;
Stefan Dösingerfc6b9772008-08-01 13:21:10 -05001477 void *blit_priv;
Stefan Dösinger98faed82008-07-01 18:23:44 -05001478 struct StateEntry StateTable[STATE_HIGHEST + 1];
Stefan Dösinger68dec9d2008-07-01 19:43:52 -05001479 /* Array of functions for states which are handled by more than one pipeline part */
1480 APPLYSTATEFUNC *multistate_funcs[STATE_HIGHEST + 1];
Stefan Dösingerc48195e2008-07-04 15:09:49 -05001481 const struct fragment_pipeline *frag_pipe;
Stefan Dösingerfc6b9772008-08-01 13:21:10 -05001482 const struct blit_shader *blitter;
Ivan Gyurdieve020ece2006-10-07 23:25:01 -04001483
Stefan Dösinger462ddaa2008-08-21 13:23:38 -05001484 unsigned int max_ffp_textures, max_ffp_texture_stages;
Stefan Dösinger754b5cf2009-03-22 12:24:28 +01001485 DWORD d3d_vshader_constantF, d3d_pshader_constantF; /* Advertised d3d caps, not GL ones */
Stefan Dösinger2cb8f422009-05-08 17:24:01 +02001486 DWORD vs_clipping;
Stefan Dösinger9a6bc682008-08-17 23:46:47 +02001487
Henri Verbeet29a0d062008-12-30 14:56:49 +01001488 WORD view_ident : 1; /* true iff view matrix is identity */
1489 WORD untransformed : 1;
1490 WORD vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */
1491 WORD isRecordingState : 1;
1492 WORD isInDraw : 1;
Henri Verbeet29a0d062008-12-30 14:56:49 +01001493 WORD bCursorVisible : 1;
1494 WORD haveHardwareCursor : 1;
1495 WORD d3d_initialized : 1;
1496 WORD inScene : 1; /* A flag to check for proper BeginScene / EndScene call pairs */
1497 WORD softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
1498 WORD useDrawStridedSlow : 1;
1499 WORD instancedDraw : 1;
Henri Verbeeta7251f02009-08-06 08:12:19 +02001500 WORD padding : 4;
Henri Verbeet29a0d062008-12-30 14:56:49 +01001501
1502 BYTE fixed_function_usage_map; /* MAX_TEXTURES, 8 */
1503
Stefan Dösinger399825c2008-08-02 18:06:01 -05001504#define DDRAW_PITCH_ALIGNMENT 8
1505#define D3D8_PITCH_ALIGNMENT 4
Stefan Dösinger6e5a5d22007-06-08 22:28:04 +02001506 unsigned char surface_alignment; /* Line Alignment of surfaces */
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001507
Jason Edmeades447d5ed2004-10-21 20:59:12 +00001508 /* State block related */
Jason Edmeades447d5ed2004-10-21 20:59:12 +00001509 IWineD3DStateBlockImpl *stateBlock;
1510 IWineD3DStateBlockImpl *updateStateBlock;
1511
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001512 /* Internal use fields */
Stefan Dösingerf6ed7042006-04-03 14:54:16 +02001513 WINED3DDEVICE_CREATION_PARAMETERS createParms;
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001514 UINT adapterNo;
Ivan Gyurdiev19c55342006-10-10 21:52:00 -04001515 WINED3DDEVTYPE devType;
Jason Edmeadesb9e2bed2004-10-08 20:52:33 +00001516
Stefan Dösingere902cd12006-05-24 11:34:30 +02001517 IWineD3DSwapChain **swapchains;
Roderick Colenbranderf3af04a2007-08-06 16:38:00 +02001518 UINT NumberOfSwapChains;
Oliver Stieber46e7c302005-06-23 11:05:24 +00001519
Stefan Dösinger1fc1fe32007-11-16 20:28:45 +01001520 struct list resources; /* a linked list to track resources created by the device */
Stefan Dösinger09bf3d52008-01-08 20:45:59 +01001521 struct list shaders; /* a linked list to track shaders (pixel and vertex) */
Stefan Dösinger107e80a2008-03-04 02:30:23 +01001522 unsigned int highest_dirty_ps_const, highest_dirty_vs_const;
Oliver Stieberea6189e2005-07-26 10:34:15 +00001523
Jason Edmeades41427852005-01-09 17:37:02 +00001524 /* Render Target Support */
H. Verbeet8355b1a2006-12-19 19:25:22 +01001525 IWineD3DSurface **render_targets;
Stefan Dösingere4f8a2d2007-11-10 00:19:19 +01001526 IWineD3DSurface *auto_depth_stencil_buffer;
Oliver Stieberba5eb142005-03-14 10:12:52 +00001527 IWineD3DSurface *stencilBufferTarget;
Jason Edmeades41427852005-01-09 17:37:02 +00001528
1529 /* palettes texture management */
Alexander Dorofeyev16597092008-03-27 00:23:04 +02001530 UINT NumberOfPalettes;
1531 PALETTEENTRY **palettes;
Oliver Stieberba5eb142005-03-14 10:12:52 +00001532 UINT currentPalette;
Roderick Colenbrander134aa672007-10-11 23:11:37 +02001533 UINT paletteConversionShader;
Jason Edmeades41427852005-01-09 17:37:02 +00001534
Jason Edmeadesf738c142004-12-09 11:42:34 +00001535 /* For rendering to a texture using glCopyTexImage */
H. Verbeet299c1e62006-12-19 19:25:35 +01001536 GLenum *draw_buffers;
Stefan Dösinger3d2aa7a2008-01-27 14:32:40 +01001537 GLuint depth_blt_texture;
H. Verbeete7d0ef72008-07-02 23:00:11 +02001538 GLuint depth_blt_rb;
1539 UINT depth_blt_rb_w;
1540 UINT depth_blt_rb_h;
Jason Edmeadesf738c142004-12-09 11:42:34 +00001541
Oliver Stieber2121f782005-03-02 12:16:10 +00001542 /* Cursor management */
Oliver Stieber2121f782005-03-02 12:16:10 +00001543 UINT xHotSpot;
1544 UINT yHotSpot;
1545 UINT xScreenSpace;
1546 UINT yScreenSpace;
Stefan Dösinger65e5ed62006-07-27 17:39:03 +02001547 UINT cursorWidth, cursorHeight;
1548 GLuint cursorTexture;
Andrew Riedia9c2e152007-05-14 15:37:53 -07001549 HCURSOR hardwareCursor;
Oliver Stieber2121f782005-03-02 12:16:10 +00001550
Stefan Dösinger271fb002007-09-01 21:22:32 +02001551 /* The Wine logo surface */
1552 IWineD3DSurface *logo_surface;
1553
Jason Edmeades2003c7a2004-12-13 13:35:38 +00001554 /* Textures for when no other textures are mapped */
Oliver Stieberabb11f32005-07-05 14:05:18 +00001555 UINT dummyTextureName[MAX_TEXTURES];
Jason Edmeades2003c7a2004-12-13 13:35:38 +00001556
Oliver Stieber329d0172005-09-21 10:55:03 +00001557 /* Device state management */
1558 HRESULT state;
Stefan Dösinger04da3ce2006-04-18 23:39:52 +02001559
1560 /* DirectDraw stuff */
Stefan Dösinger566cdcf2006-05-18 22:42:22 +02001561 DWORD ddraw_width, ddraw_height;
1562 WINED3DFORMAT ddraw_format;
Stefan Dösinger04da3ce2006-04-18 23:39:52 +02001563
Stefan Dösinger96bce8d2006-09-23 19:09:06 +02001564 /* Final position fixup constant */
1565 float posFixup[4];
Stefan Dösinger7532c752006-12-19 13:00:03 +01001566
Stefan Dösingerdf97fd32006-12-19 23:33:34 +01001567 /* With register combiners we can skip junk texture stages */
H. Verbeet5b7758f2007-06-25 22:45:40 +02001568 DWORD texUnitMap[MAX_COMBINED_SAMPLERS];
1569 DWORD rev_tex_unit_map[MAX_COMBINED_SAMPLERS];
Stefan Dösingerdf97fd32006-12-19 23:33:34 +01001570
Stefan Dösinger091f9c22007-01-02 00:21:26 +01001571 /* Stream source management */
Henri Verbeetd7c7c762009-03-27 10:25:55 +01001572 struct wined3d_stream_info strided_streams;
Henri Verbeet5532c992008-12-01 15:32:15 +01001573 const WineDirect3DVertexStridedData *up_strided;
Stefan Dösinger091f9c22007-01-02 00:21:26 +01001574
Stefan Dösingerc739c382007-02-12 19:18:22 +01001575 /* Context management */
Henri Verbeetda1e5572009-08-03 08:06:51 +02001576 struct wined3d_context **contexts;
Stefan Dösinger13f24c32007-06-02 20:20:17 +00001577 UINT numContexts;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001578 struct wined3d_context *pbufferContext; /* The context that has a pbuffer as drawable */
Stefan Dösinger12252d02007-02-12 19:21:10 +01001579 DWORD pbufferWidth, pbufferHeight; /* Size of the buffer drawable */
Stefan Dösinger26ebe392007-07-04 17:57:45 +02001580
1581 /* High level patch management */
1582#define PATCHMAP_SIZE 43
1583#define PATCHMAP_HASHFUNC(x) ((x) % PATCHMAP_SIZE) /* Primitive and simple function */
1584 struct list patches[PATCHMAP_SIZE];
1585 struct WineD3DRectPatch *currentPatch;
Stefan Dösingerc1623d42007-02-12 19:18:36 +01001586};
Jason Edmeadesac490fa2004-10-07 04:22:21 +00001587
Henri Verbeet689984b2009-09-11 19:01:19 +02001588extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl DECLSPEC_HIDDEN;
Jason Edmeadesac490fa2004-10-07 04:22:21 +00001589
Henri Verbeet689984b2009-09-11 19:01:19 +02001590void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
1591void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
Henri Verbeetd7c7c762009-03-27 10:25:55 +01001592void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
Henri Verbeet689984b2009-09-11 19:01:19 +02001593 BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
Henri Verbeetbe8026a2009-10-29 10:37:12 +01001594void device_stream_info_from_strided(const struct wined3d_gl_info *gl_info,
Henri Verbeet689984b2009-09-11 19:01:19 +02001595 const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN;
1596HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
1597 const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
1598void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN;
1599void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) DECLSPEC_HIDDEN;
Henri Verbeetda1e5572009-08-03 08:06:51 +02001600static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state)
1601{
Stefan Dösinger7532c752006-12-19 13:00:03 +01001602 DWORD idx = state >> 5;
1603 BYTE shift = state & 0x1f;
Stefan Dösinger380930d2007-02-12 19:18:31 +01001604 return context->isStateDirty[idx] & (1 << shift);
Stefan Dösinger7532c752006-12-19 13:00:03 +01001605}
1606
Stefan Dösingerd08585e2007-05-07 20:46:24 +02001607/* Support for IWineD3DResource ::Set/Get/FreePrivateData. */
Oliver Stieberfe80b4e2005-07-15 09:54:57 +00001608typedef struct PrivateData
1609{
Stefan Dösingerd08585e2007-05-07 20:46:24 +02001610 struct list entry;
Oliver Stieberfe80b4e2005-07-15 09:54:57 +00001611
1612 GUID tag;
1613 DWORD flags; /* DDSPD_* */
Oliver Stieberfe80b4e2005-07-15 09:54:57 +00001614
1615 union
1616 {
1617 LPVOID data;
1618 LPUNKNOWN object;
1619 } ptr;
1620
1621 DWORD size;
1622} PrivateData;
1623
Jason Edmeadesdb7a5052004-10-14 00:32:04 +00001624/*****************************************************************************
1625 * IWineD3DResource implementation structure
1626 */
1627typedef struct IWineD3DResourceClass
1628{
1629 /* IUnknown fields */
Mike McCormack8955ac42005-07-28 10:16:21 +00001630 LONG ref; /* Note: Ref counting not required */
Jason Edmeadesdb7a5052004-10-14 00:32:04 +00001631
1632 /* WineD3DResource Information */
Jason Edmeades289562e2004-11-23 13:52:46 +00001633 IUnknown *parent;
Stefan Dösinger913df5b2006-03-09 23:21:16 +01001634 WINED3DRESOURCETYPE resourceType;
Jason Edmeades41427852005-01-09 17:37:02 +00001635 IWineD3DDeviceImpl *wineD3DDevice;
Stefan Dösingerd75fd752006-03-28 14:20:47 +02001636 WINED3DPOOL pool;
Oliver Stieber67f2ad42005-03-29 19:01:00 +00001637 UINT size;
1638 DWORD usage;
Henri Verbeet38178542009-03-12 09:53:14 +01001639 const struct GlPixelFormatDesc *format_desc;
Kjell Rune Skaaraased96dd72008-09-29 19:52:18 +02001640 DWORD priority;
Stefan Dösinger4d4fce72007-10-22 13:02:03 +02001641 BYTE *allocatedMemory; /* Pointer to the real data location */
1642 BYTE *heapMemory; /* Pointer to the HeapAlloced block of memory */
Stefan Dösingerd08585e2007-05-07 20:46:24 +02001643 struct list privateData;
Stefan Dösinger1fc1fe32007-11-16 20:28:45 +01001644 struct list resource_list_entry;
Henri Verbeetdbc4dfc2009-09-17 23:03:33 +02001645 const struct wined3d_parent_ops *parent_ops;
Jason Edmeadesdb7a5052004-10-14 00:32:04 +00001646} IWineD3DResourceClass;
1647
1648typedef struct IWineD3DResourceImpl
1649{
1650 /* IUnknown & WineD3DResource Information */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001651 const IWineD3DResourceVtbl *lpVtbl;
Jason Edmeadesdb7a5052004-10-14 00:32:04 +00001652 IWineD3DResourceClass resource;
Jason Edmeadesdb7a5052004-10-14 00:32:04 +00001653} IWineD3DResourceImpl;
1654
Henri Verbeet689984b2009-09-11 19:01:19 +02001655void resource_cleanup(IWineD3DResource *iface) DECLSPEC_HIDDEN;
1656HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid) DECLSPEC_HIDDEN;
1657HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice **device) DECLSPEC_HIDDEN;
1658HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent) DECLSPEC_HIDDEN;
1659DWORD resource_get_priority(IWineD3DResource *iface) DECLSPEC_HIDDEN;
Henri Verbeet2acf8d72008-12-02 18:41:33 +01001660HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
Henri Verbeet689984b2009-09-11 19:01:19 +02001661 void *data, DWORD *data_size) DECLSPEC_HIDDEN;
Henri Verbeet56545442009-05-29 09:13:21 +02001662HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
Henri Verbeet2dc7fc22009-03-13 10:44:18 +01001663 IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
Henri Verbeetdbc4dfc2009-09-17 23:03:33 +02001664 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02001665WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface) DECLSPEC_HIDDEN;
1666DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority) DECLSPEC_HIDDEN;
Henri Verbeet2acf8d72008-12-02 18:41:33 +01001667HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
Henri Verbeet689984b2009-09-11 19:01:19 +02001668 const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
Henri Verbeet2acf8d72008-12-02 18:41:33 +01001669
Stefan Dösinger393ed4a2007-10-22 13:30:14 +02001670/* Tests show that the start address of resources is 32 byte aligned */
1671#define RESOURCE_ALIGNMENT 32
Jason Edmeadesdb7a5052004-10-14 00:32:04 +00001672
1673/*****************************************************************************
Oliver Stieberbb6f9b02005-08-03 11:00:28 +00001674 * IWineD3DBaseTexture D3D- > openGL state map lookups
1675 */
Oliver Stieberbb6f9b02005-08-03 11:00:28 +00001676
1677typedef enum winetexturestates {
1678 WINED3DTEXSTA_ADDRESSU = 0,
1679 WINED3DTEXSTA_ADDRESSV = 1,
1680 WINED3DTEXSTA_ADDRESSW = 2,
1681 WINED3DTEXSTA_BORDERCOLOR = 3,
1682 WINED3DTEXSTA_MAGFILTER = 4,
1683 WINED3DTEXSTA_MINFILTER = 5,
1684 WINED3DTEXSTA_MIPFILTER = 6,
1685 WINED3DTEXSTA_MAXMIPLEVEL = 7,
1686 WINED3DTEXSTA_MAXANISOTROPY = 8,
1687 WINED3DTEXSTA_SRGBTEXTURE = 9,
1688 WINED3DTEXSTA_ELEMENTINDEX = 10,
1689 WINED3DTEXSTA_DMAPOFFSET = 11,
1690 WINED3DTEXSTA_TSSADDRESSW = 12,
1691 MAX_WINETEXTURESTATES = 13,
1692} winetexturestates;
1693
Stefan Dösinger4386a822009-02-17 00:25:51 +01001694enum WINED3DSRGB
1695{
1696 SRGB_ANY = 0, /* Uses the cached value(e.g. external calls) */
1697 SRGB_RGB = 1, /* Loads the rgb texture */
1698 SRGB_SRGB = 2, /* Loads the srgb texture */
1699 SRGB_BOTH = 3, /* Loads both textures */
1700};
1701
Stefan Dösinger5b5e3bd2009-09-19 14:59:27 +02001702struct gl_texture
1703{
1704 DWORD states[MAX_WINETEXTURESTATES];
1705 BOOL dirty;
1706 GLuint name;
1707};
1708
Oliver Stieberbb6f9b02005-08-03 11:00:28 +00001709/*****************************************************************************
Jason Edmeades819b0e12004-12-07 14:29:12 +00001710 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
1711 */
1712typedef struct IWineD3DBaseTextureClass
1713{
Stefan Dösinger5b5e3bd2009-09-19 14:59:27 +02001714 struct gl_texture texture_rgb, texture_srgb;
Jason Edmeades819b0e12004-12-07 14:29:12 +00001715 UINT levels;
Henri Verbeet89139b72008-12-03 14:53:43 +01001716 float pow2Matrix[16];
Oliver Stieberba5eb142005-03-14 10:12:52 +00001717 UINT LOD;
Stefan Dösinger63fd9a72006-04-06 19:02:16 +02001718 WINED3DTEXTUREFILTERTYPE filterType;
Stefan Dösinger666b5072006-12-19 23:26:39 +01001719 LONG bindCount;
1720 DWORD sampler;
Phil Costin622f62d2007-06-06 23:13:16 +00001721 BOOL is_srgb;
Tobias Jakobi31f8cd92009-03-26 03:12:50 +01001722 BOOL pow2Matrix_identity;
Henri Verbeetc7880e82008-11-26 16:14:40 +01001723 const struct min_lookup *minMipLookup;
1724 const GLenum *magLookup;
Stefan Dösinger4386a822009-02-17 00:25:51 +01001725 void (*internal_preload)(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb);
Jason Edmeades819b0e12004-12-07 14:29:12 +00001726} IWineD3DBaseTextureClass;
1727
Henri Verbeet689984b2009-09-11 19:01:19 +02001728void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
Stefan Dösinger4386a822009-02-17 00:25:51 +01001729
Jason Edmeades819b0e12004-12-07 14:29:12 +00001730typedef struct IWineD3DBaseTextureImpl
1731{
1732 /* IUnknown & WineD3DResource Information */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001733 const IWineD3DBaseTextureVtbl *lpVtbl;
Jason Edmeades819b0e12004-12-07 14:29:12 +00001734 IWineD3DResourceClass resource;
1735 IWineD3DBaseTextureClass baseTexture;
1736
1737} IWineD3DBaseTextureImpl;
1738
Henri Verbeet4d60b662008-12-02 18:41:32 +01001739void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
1740 const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
Henri Verbeet689984b2009-09-11 19:01:19 +02001741 const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]) DECLSPEC_HIDDEN;
1742HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc) DECLSPEC_HIDDEN;
1743void basetexture_cleanup(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1744void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1745WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1746BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1747DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
1748DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
Henri Verbeet451a4162009-06-02 09:01:17 +02001749HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
1750 IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
Henri Verbeetdbc4dfc2009-09-17 23:03:33 +02001751 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02001752HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
1753 WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
1754BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty) DECLSPEC_HIDDEN;
1755DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod) DECLSPEC_HIDDEN;
1756void basetexture_unload(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
Henri Verbeet4d60b662008-12-02 18:41:32 +01001757
Jason Edmeades819b0e12004-12-07 14:29:12 +00001758/*****************************************************************************
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001759 * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
1760 */
1761typedef struct IWineD3DTextureImpl
1762{
1763 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001764 const IWineD3DTextureVtbl *lpVtbl;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001765 IWineD3DResourceClass resource;
1766 IWineD3DBaseTextureClass baseTexture;
1767
1768 /* IWineD3DTexture */
Henri Verbeet2dcfdd52009-04-24 09:17:58 +02001769 IWineD3DSurface *surfaces[MAX_MIP_LEVELS];
Stefan Dösingerd09cbce2007-11-28 20:35:04 +01001770 UINT target;
Stefan Dösingerc088ede2008-07-08 18:59:10 -05001771 BOOL cond_np2;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001772
1773} IWineD3DTextureImpl;
1774
Henri Verbeeta8e8f762009-09-17 23:03:25 +02001775HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
1776 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
1777 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet5171a652009-06-03 10:47:25 +02001778
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001779/*****************************************************************************
1780 * IWineD3DCubeTexture implementation structure (extends IWineD3DBaseTextureImpl)
1781 */
1782typedef struct IWineD3DCubeTextureImpl
1783{
1784 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001785 const IWineD3DCubeTextureVtbl *lpVtbl;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001786 IWineD3DResourceClass resource;
1787 IWineD3DBaseTextureClass baseTexture;
1788
1789 /* IWineD3DCubeTexture */
Henri Verbeet2dcfdd52009-04-24 09:17:58 +02001790 IWineD3DSurface *surfaces[6][MAX_MIP_LEVELS];
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001791} IWineD3DCubeTextureImpl;
1792
Henri Verbeetde3bd862009-09-17 12:35:25 +02001793HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
1794 IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
1795 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeetb0ba7312009-06-03 10:47:26 +02001796
Ivan Gyurdiev257692e2006-05-10 13:55:02 -04001797typedef struct _WINED3DVOLUMET_DESC
1798{
1799 UINT Width;
1800 UINT Height;
1801 UINT Depth;
1802} WINED3DVOLUMET_DESC;
1803
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001804/*****************************************************************************
1805 * IWineD3DVolume implementation structure (extends IUnknown)
1806 */
1807typedef struct IWineD3DVolumeImpl
1808{
Oliver Stieber67f2ad42005-03-29 19:01:00 +00001809 /* IUnknown & WineD3DResource fields */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001810 const IWineD3DVolumeVtbl *lpVtbl;
Oliver Stieber67f2ad42005-03-29 19:01:00 +00001811 IWineD3DResourceClass resource;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001812
1813 /* WineD3DVolume Information */
Ivan Gyurdiev257692e2006-05-10 13:55:02 -04001814 WINED3DVOLUMET_DESC currentDesc;
H. Verbeete43cfb12006-02-06 11:30:48 +01001815 IWineD3DBase *container;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001816 BOOL lockable;
1817 BOOL locked;
Stefan Dösingercf4b91f2006-04-07 13:12:22 +02001818 WINED3DBOX lockedBox;
1819 WINED3DBOX dirtyBox;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001820 BOOL dirty;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001821} IWineD3DVolumeImpl;
1822
Henri Verbeet689984b2009-09-11 19:01:19 +02001823void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
Henri Verbeete9000d22009-09-16 08:37:19 +02001824HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
1825 UINT height, UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
1826 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeetfd900212009-01-14 10:01:10 +01001827
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001828/*****************************************************************************
1829 * IWineD3DVolumeTexture implementation structure (extends IWineD3DBaseTextureImpl)
1830 */
1831typedef struct IWineD3DVolumeTextureImpl
1832{
1833 /* IUnknown & WineD3DResource/WineD3DBaseTexture Information */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001834 const IWineD3DVolumeTextureVtbl *lpVtbl;
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001835 IWineD3DResourceClass resource;
1836 IWineD3DBaseTextureClass baseTexture;
1837
1838 /* IWineD3DVolumeTexture */
Henri Verbeet2dcfdd52009-04-24 09:17:58 +02001839 IWineD3DVolume *volumes[MAX_MIP_LEVELS];
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001840} IWineD3DVolumeTextureImpl;
1841
Henri Verbeet689984b2009-09-11 19:01:19 +02001842HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height,
Henri Verbeeta2866462009-09-16 08:37:24 +02001843 UINT depth, UINT levels, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
1844 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet97f320a2009-06-03 10:47:26 +02001845
Oliver Stieber2121f782005-03-02 12:16:10 +00001846typedef struct _WINED3DSURFACET_DESC
1847{
Stefan Dösingerb4b295c2006-03-24 17:34:26 +01001848 WINED3DMULTISAMPLE_TYPE MultiSampleType;
1849 DWORD MultiSampleQuality;
1850 UINT Width;
1851 UINT Height;
Oliver Stieber2121f782005-03-02 12:16:10 +00001852} WINED3DSURFACET_DESC;
1853
Jason Edmeadesbcecddc2005-01-17 13:44:57 +00001854/*****************************************************************************
Stefan Dösingeraf462952006-05-06 18:08:33 +02001855 * Structure for DIB Surfaces (GetDC and GDI surfaces)
1856 */
1857typedef struct wineD3DSurface_DIB {
1858 HBITMAP DIBsection;
1859 void* bitmap_data;
Roderick Colenbranderad692f22007-09-11 10:31:54 +02001860 UINT bitmap_size;
Stefan Dösingeraf462952006-05-06 18:08:33 +02001861 HGDIOBJ holdbitmap;
1862 BOOL client_memory;
1863} wineD3DSurface_DIB;
1864
H. Verbeetc9b178b2007-04-09 01:53:32 +02001865typedef struct {
1866 struct list entry;
1867 GLuint id;
1868 UINT width;
1869 UINT height;
1870} renderbuffer_entry_t;
1871
Henri Verbeet45820042008-09-18 14:57:53 +02001872struct fbo_entry
1873{
1874 struct list entry;
1875 IWineD3DSurface **render_targets;
1876 IWineD3DSurface *depth_stencil;
1877 BOOL attached;
1878 GLuint id;
1879};
1880
Stefan Dösingeraf462952006-05-06 18:08:33 +02001881/*****************************************************************************
Stefan Dösingerd93e1612007-04-28 17:59:37 +02001882 * IWineD3DClipp implementation structure
1883 */
1884typedef struct IWineD3DClipperImpl
1885{
1886 const IWineD3DClipperVtbl *lpVtbl;
1887 LONG ref;
1888
1889 IUnknown *Parent;
1890 HWND hWnd;
1891} IWineD3DClipperImpl;
1892
1893
1894/*****************************************************************************
Jason Edmeades41427852005-01-09 17:37:02 +00001895 * IWineD3DSurface implementation structure
1896 */
1897struct IWineD3DSurfaceImpl
1898{
1899 /* IUnknown & IWineD3DResource Information */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00001900 const IWineD3DSurfaceVtbl *lpVtbl;
Jason Edmeades41427852005-01-09 17:37:02 +00001901 IWineD3DResourceClass resource;
1902
1903 /* IWineD3DSurface fields */
H. Verbeete43cfb12006-02-06 11:30:48 +01001904 IWineD3DBase *container;
Oliver Stieber2121f782005-03-02 12:16:10 +00001905 WINED3DSURFACET_DESC currentDesc;
Stefan Dösinger76764622007-02-19 15:23:36 +01001906 IWineD3DPaletteImpl *palette; /* D3D7 style palette handling */
1907 PALETTEENTRY *palette9; /* D3D8/9 style palette handling */
Jason Edmeades41427852005-01-09 17:37:02 +00001908
Oliver Stieber520c2f02005-07-11 14:25:54 +00001909 /* TODO: move this off into a management class(maybe!) */
Stefan Dösingera98ccb52006-07-23 00:03:33 +02001910 DWORD Flags;
Oliver Stieber520c2f02005-07-11 14:25:54 +00001911
1912 UINT pow2Width;
1913 UINT pow2Height;
Oliver Stieber520c2f02005-07-11 14:25:54 +00001914
Stefan Dösinger9bc62002007-11-30 20:22:33 +01001915 /* A method to retrieve the drawable size. Not in the Vtable to make it changeable */
Henri Verbeetda1e5572009-08-03 08:06:51 +02001916 void (*get_drawable_size)(struct wined3d_context *context, UINT *width, UINT *height);
Stefan Dösinger9bc62002007-11-30 20:22:33 +01001917
Stefan Dösingercfcdb652006-05-19 00:13:29 +02001918 /* Oversized texture */
1919 RECT glRect;
1920
Roderick Colenbranderad692f22007-09-11 10:31:54 +02001921 /* PBO */
1922 GLuint pbo;
Henri Verbeet69b76122009-07-10 10:20:13 +02001923 GLuint texture_name;
1924 GLuint texture_name_srgb;
1925 GLint texture_level;
1926 GLenum texture_target;
Roderick Colenbranderad692f22007-09-11 10:31:54 +02001927
Jason Edmeades41427852005-01-09 17:37:02 +00001928 RECT lockedRect;
1929 RECT dirtyRect;
Stefan Dösinger03389ac2007-01-12 18:57:26 +01001930 int lockCount;
1931#define MAXLOCKCOUNT 50 /* After this amount of locks do not free the sysmem copy */
Oliver Stieber13621052005-07-11 20:38:27 +00001932
Stefan Dösingeraf462952006-05-06 18:08:33 +02001933 /* For GetDC */
1934 wineD3DSurface_DIB dib;
1935 HDC hDC;
Stefan Dösinger9b29fb62006-05-09 19:37:38 +02001936
1937 /* Color keys for DDraw */
Stefan Dösinger725057d2007-04-14 22:44:55 +02001938 WINEDDCOLORKEY DestBltCKey;
1939 WINEDDCOLORKEY DestOverlayCKey;
1940 WINEDDCOLORKEY SrcOverlayCKey;
1941 WINEDDCOLORKEY SrcBltCKey;
Stefan Dösinger9b29fb62006-05-09 19:37:38 +02001942 DWORD CKeyFlags;
1943
Stefan Dösinger725057d2007-04-14 22:44:55 +02001944 WINEDDCOLORKEY glCKey;
H. Verbeetc9b178b2007-04-09 01:53:32 +02001945
1946 struct list renderbuffers;
1947 renderbuffer_entry_t *current_renderbuffer;
Stefan Dösingerd93e1612007-04-28 17:59:37 +02001948
1949 /* DirectDraw clippers */
1950 IWineD3DClipper *clipper;
Stefan Dösingere795d842008-08-05 12:19:43 +02001951
1952 /* DirectDraw Overlay handling */
1953 RECT overlay_srcrect;
1954 RECT overlay_destrect;
1955 IWineD3DSurfaceImpl *overlay_dest;
Stefan Dösingerdff3a422008-07-30 15:28:25 -05001956 struct list overlays;
1957 struct list overlay_entry;
Jason Edmeades41427852005-01-09 17:37:02 +00001958};
1959
Henri Verbeet689984b2009-09-11 19:01:19 +02001960extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl DECLSPEC_HIDDEN;
1961extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl DECLSPEC_HIDDEN;
Stefan Dösinger2f724832006-05-13 22:22:16 +02001962
Henri Verbeet689984b2009-09-11 19:01:19 +02001963UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc,
1964 UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
1965void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
Henri Verbeet5f581972009-06-15 09:06:49 +02001966HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
1967 UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
1968 UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
Henri Verbeeta5214c32009-09-16 08:37:15 +02001969 WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet5f581972009-06-15 09:06:49 +02001970
Stefan Dösinger2f724832006-05-13 22:22:16 +02001971/* Predeclare the shared Surface functions */
Henri Verbeet689984b2009-09-11 19:01:19 +02001972HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface,
1973 REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
1974ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1975HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) DECLSPEC_HIDDEN;
1976HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) DECLSPEC_HIDDEN;
1977HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface,
1978 REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags) DECLSPEC_HIDDEN;
1979HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface,
1980 REFGUID refguid, void *pData, DWORD *pSizeOfData) DECLSPEC_HIDDEN;
1981HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) DECLSPEC_HIDDEN;
1982DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) DECLSPEC_HIDDEN;
1983DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1984WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1985HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetContainer(IWineD3DSurface* iface,
1986 REFIID riid, void **ppContainer) DECLSPEC_HIDDEN;
1987HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc) DECLSPEC_HIDDEN;
1988HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
1989HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
1990HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1991HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1992HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) DECLSPEC_HIDDEN;
1993HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) DECLSPEC_HIDDEN;
1994HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface,
1995 DWORD Flags, const WINEDDCOLORKEY *CKey) DECLSPEC_HIDDEN;
1996HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) DECLSPEC_HIDDEN;
1997DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1998HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
1999HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) DECLSPEC_HIDDEN;
2000HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) DECLSPEC_HIDDEN;
2001HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface,
2002 DWORD Flags, IWineD3DSurface *Ref) DECLSPEC_HIDDEN;
Henri Verbeetb4f0b5b2008-11-25 11:57:39 +01002003HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
Henri Verbeet689984b2009-09-11 19:01:19 +02002004 IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX) DECLSPEC_HIDDEN;
2005HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper) DECLSPEC_HIDDEN;
2006HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper) DECLSPEC_HIDDEN;
2007HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) DECLSPEC_HIDDEN;
2008HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
Henri Verbeetb4f0b5b2008-11-25 11:57:39 +01002009HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
Henri Verbeet689984b2009-09-11 19:01:19 +02002010 const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
Henri Verbeetb4f0b5b2008-11-25 11:57:39 +01002011HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
Henri Verbeet689984b2009-09-11 19:01:19 +02002012 IWineD3DSurface *Source, const RECT *rsrc, DWORD trans) DECLSPEC_HIDDEN;
2013HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT *pLockedRect,
2014 const RECT *pRect, DWORD Flags) DECLSPEC_HIDDEN;
2015void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb) DECLSPEC_HIDDEN;
2016const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
Stefan Dösinger9aa56622007-09-16 16:33:23 +02002017
Henri Verbeet689984b2009-09-11 19:01:19 +02002018void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2019void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2020void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
2021void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
Stefan Dösinger9bc62002007-11-30 20:22:33 +01002022
Henri Verbeet689984b2009-09-11 19:01:19 +02002023void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) DECLSPEC_HIDDEN;
Stefan Dösinger851dd732008-07-24 11:38:51 -05002024
Stefan Dösinger1cfbc902006-05-06 16:15:37 +02002025/* Surface flags: */
H. Verbeet4f77c292008-07-02 23:00:41 +02002026#define SFLAG_OVERSIZE 0x00000001 /* Surface is bigger than gl size, blts only */
2027#define SFLAG_CONVERTED 0x00000002 /* Converted for color keying or Palettized */
2028#define SFLAG_DIBSECTION 0x00000004 /* Has a DIB section attached for GetDC */
2029#define SFLAG_LOCKABLE 0x00000008 /* Surface can be locked */
2030#define SFLAG_DISCARD 0x00000010 /* ??? */
2031#define SFLAG_LOCKED 0x00000020 /* Surface is locked atm */
2032#define SFLAG_INTEXTURE 0x00000040 /* The GL texture contains the newest surface content */
Stefan Dösingerc585b4d2009-01-16 16:22:09 +01002033#define SFLAG_INSRGBTEX 0x00000080 /* The GL srgb texture contains the newest surface content */
2034#define SFLAG_INDRAWABLE 0x00000100 /* The gl drawable contains the most up to date data */
2035#define SFLAG_INSYSMEM 0x00000200 /* The system memory copy is most up to date */
2036#define SFLAG_NONPOW2 0x00000400 /* Surface sizes are not a power of 2 */
2037#define SFLAG_DYNLOCK 0x00000800 /* Surface is often locked by the app */
H. Verbeet4f77c292008-07-02 23:00:41 +02002038#define SFLAG_DCINUSE 0x00001000 /* Set between GetDC and ReleaseDC calls */
2039#define SFLAG_LOST 0x00002000 /* Surface lost flag for DDraw */
2040#define SFLAG_USERPTR 0x00004000 /* The application allocated the memory for this surface */
2041#define SFLAG_GLCKEY 0x00008000 /* The gl texture was created with a color key */
2042#define SFLAG_CLIENT 0x00010000 /* GL_APPLE_client_storage is used on that texture */
2043#define SFLAG_ALLOCATED 0x00020000 /* A gl texture is allocated for this surface */
Stefan Dösingerc585b4d2009-01-16 16:22:09 +01002044#define SFLAG_SRGBALLOCATED 0x00040000 /* A srgb gl texture is allocated for this surface */
2045#define SFLAG_PBO 0x00080000 /* Has a PBO attached for speeding up data transfers for dynamically locked surfaces */
2046#define SFLAG_NORMCOORD 0x00100000 /* Set if the GL texture coords are normalized(non-texture rectangle) */
2047#define SFLAG_DS_ONSCREEN 0x00200000 /* Is a depth stencil, last modified onscreen */
2048#define SFLAG_DS_OFFSCREEN 0x00400000 /* Is a depth stencil, last modified offscreen */
2049#define SFLAG_INOVERLAYDRAW 0x00800000 /* Overlay drawing is in progress. Recursion prevention */
Henri Verbeet899df562009-03-25 10:12:27 +01002050#define SFLAG_SWAPCHAIN 0x01000000 /* The surface is part of a swapchain */
Stefan Dösinger1cfbc902006-05-06 16:15:37 +02002051
2052/* In some conditions the surface memory must not be freed:
2053 * SFLAG_OVERSIZE: Not all data can be kept in GL
2054 * SFLAG_CONVERTED: Converting the data back would take too long
2055 * SFLAG_DIBSECTION: The dib code manages the memory
Stefan Dösinger1cfbc902006-05-06 16:15:37 +02002056 * SFLAG_LOCKED: The app requires access to the surface data
Stefan Dösinger1cfbc902006-05-06 16:15:37 +02002057 * SFLAG_DYNLOCK: Avoid freeing the data for performance
Roderick Colenbranderad692f22007-09-11 10:31:54 +02002058 * SFLAG_PBO: PBOs don't use 'normal' memory. It is either allocated by the driver or must be NULL.
Stefan Dösinger4f5d3332007-03-31 23:02:37 +02002059 * SFLAG_CLIENT: OpenGL uses our memory as backup
Stefan Dösinger1cfbc902006-05-06 16:15:37 +02002060 */
H. Verbeet4f77c292008-07-02 23:00:41 +02002061#define SFLAG_DONOTFREE (SFLAG_OVERSIZE | \
2062 SFLAG_CONVERTED | \
2063 SFLAG_DIBSECTION | \
2064 SFLAG_LOCKED | \
2065 SFLAG_DYNLOCK | \
H. Verbeet4f77c292008-07-02 23:00:41 +02002066 SFLAG_USERPTR | \
2067 SFLAG_PBO | \
2068 SFLAG_CLIENT)
Stefan Dösinger1cfbc902006-05-06 16:15:37 +02002069
H. Verbeet4f77c292008-07-02 23:00:41 +02002070#define SFLAG_LOCATIONS (SFLAG_INSYSMEM | \
2071 SFLAG_INTEXTURE | \
Stefan Dösingerc585b4d2009-01-16 16:22:09 +01002072 SFLAG_INDRAWABLE | \
2073 SFLAG_INSRGBTEX)
H. Verbeet4f77c292008-07-02 23:00:41 +02002074
2075#define SFLAG_DS_LOCATIONS (SFLAG_DS_ONSCREEN | \
2076 SFLAG_DS_OFFSCREEN)
Henri Verbeet9d192c62008-09-22 14:52:52 +02002077#define SFLAG_DS_DISCARDED SFLAG_DS_LOCATIONS
H. Verbeet4f77c292008-07-02 23:00:41 +02002078
Henri Verbeet689984b2009-09-11 19:01:19 +02002079BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) DECLSPEC_HIDDEN;
Stefan Dösinger158691e2006-05-23 00:48:54 +02002080
Stefan Dösinger028729d2007-08-11 20:02:01 +02002081typedef enum {
2082 NO_CONVERSION,
2083 CONVERT_PALETTED,
2084 CONVERT_PALETTED_CK,
2085 CONVERT_CK_565,
2086 CONVERT_CK_5551,
2087 CONVERT_CK_4444,
2088 CONVERT_CK_4444_ARGB,
2089 CONVERT_CK_1555,
2090 CONVERT_555,
2091 CONVERT_CK_RGB24,
2092 CONVERT_CK_8888,
2093 CONVERT_CK_8888_ARGB,
2094 CONVERT_RGB32_888,
2095 CONVERT_V8U8,
Stefan Dösinger0ed81b22007-08-31 20:41:03 +02002096 CONVERT_L6V5U5,
Stefan Dösinger028729d2007-08-11 20:02:01 +02002097 CONVERT_X8L8V8U8,
2098 CONVERT_Q8W8V8U8,
2099 CONVERT_V16U16,
Stefan Dösinger86b991c2007-08-12 16:24:29 +02002100 CONVERT_A4L4,
Stefan Dösinger0dc04442008-12-15 19:14:15 +01002101 CONVERT_G16R16,
Stefan Dösinger8513f642009-04-06 15:05:27 +02002102 CONVERT_R16G16F,
2103 CONVERT_R32G32F,
Henri Verbeet23231d52009-06-16 09:38:25 +02002104 CONVERT_D15S1,
2105 CONVERT_D24X4S4,
2106 CONVERT_D24FS8,
Stefan Dösinger028729d2007-08-11 20:02:01 +02002107} CONVERT_TYPES;
2108
Henri Verbeet689984b2009-09-11 19:01:19 +02002109HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format,
2110 GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) DECLSPEC_HIDDEN;
Stefan Dösinger028729d2007-08-11 20:02:01 +02002111
Henri Verbeet689984b2009-09-11 19:01:19 +02002112BOOL palette9_changed(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
Alexander Dorofeyevd6ba0692008-04-03 00:12:16 +03002113
Jason Edmeades41427852005-01-09 17:37:02 +00002114/*****************************************************************************
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002115 * IWineD3DVertexDeclaration implementation structure
2116 */
Stefan Dösinger95921232007-11-20 21:14:10 +01002117
Henri Verbeet9f26fed2009-03-27 10:25:56 +01002118struct wined3d_vertex_declaration_element
2119{
Henri Verbeet4434d002009-03-27 10:25:56 +01002120 const struct GlPixelFormatDesc *format_desc;
Henri Verbeet9f26fed2009-03-27 10:25:56 +01002121 BOOL ffp_valid;
2122 WORD input_slot;
2123 WORD offset;
2124 UINT output_slot;
2125 BYTE method;
2126 BYTE usage;
2127 BYTE usage_idx;
2128};
2129
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002130typedef struct IWineD3DVertexDeclarationImpl {
H. Verbeetee09e8b2007-03-12 23:21:54 +01002131 /* IUnknown Information */
2132 const IWineD3DVertexDeclarationVtbl *lpVtbl;
2133 LONG ref;
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002134
H. Verbeetee09e8b2007-03-12 23:21:54 +01002135 IUnknown *parent;
Henri Verbeet66a72362009-09-23 10:05:52 +02002136 const struct wined3d_parent_ops *parent_ops;
H. Verbeetee09e8b2007-03-12 23:21:54 +01002137 IWineD3DDeviceImpl *wineD3DDevice;
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002138
Henri Verbeet9f26fed2009-03-27 10:25:56 +01002139 struct wined3d_vertex_declaration_element *elements;
2140 UINT element_count;
Stefan Dösinger06e51c22007-08-03 19:53:25 +02002141
2142 DWORD streams[MAX_STREAMS];
2143 UINT num_streams;
Stefan Dösingerb8dd5832007-07-30 12:35:33 +02002144 BOOL position_transformed;
Stefan Dösingera3c2fb92007-12-20 01:34:22 +01002145 BOOL half_float_conv_needed;
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002146} IWineD3DVertexDeclarationImpl;
2147
Henri Verbeet66a72362009-09-23 10:05:52 +02002148HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
2149 const WINED3DVERTEXELEMENT *elements, UINT element_count,
2150 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet4330d202009-03-27 10:25:55 +01002151
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002152/*****************************************************************************
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002153 * IWineD3DStateBlock implementation structure
2154 */
2155
2156/* Internal state Block for Begin/End/Capture/Create/Apply info */
2157/* Note: Very long winded but gl Lists are not flexible enough */
2158/* to resolve everything we need, so doing it manually for now */
2159typedef struct SAVEDSTATES {
Henri Verbeetfc398312009-01-05 10:10:16 +01002160 DWORD transform[(HIGHEST_TRANSFORMSTATE >> 5) + 1];
Henri Verbeetfd33f0f2009-01-05 10:10:16 +01002161 WORD streamSource; /* MAX_STREAMS, 16 */
2162 WORD streamFreq; /* MAX_STREAMS, 16 */
Henri Verbeetc33b3812009-01-05 10:10:16 +01002163 DWORD renderState[(WINEHIGHEST_RENDER_STATE >> 5) + 1];
Henri Verbeetbddf5e72009-01-06 11:43:45 +01002164 DWORD textureState[MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */
2165 WORD samplerState[MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */
Henri Verbeetfd33f0f2009-01-05 10:10:16 +01002166 DWORD clipplane; /* WINED3DMAXUSERCLIPPLANES, 32 */
2167 WORD pixelShaderConstantsB; /* MAX_CONST_B, 16 */
2168 WORD pixelShaderConstantsI; /* MAX_CONST_I, 16 */
Henri Verbeet3920d422008-12-30 14:56:49 +01002169 BOOL *pixelShaderConstantsF;
Henri Verbeetfd33f0f2009-01-05 10:10:16 +01002170 WORD vertexShaderConstantsB; /* MAX_CONST_B, 16 */
2171 WORD vertexShaderConstantsI; /* MAX_CONST_I, 16 */
Henri Verbeet3920d422008-12-30 14:56:49 +01002172 BOOL *vertexShaderConstantsF;
Henri Verbeetbac64862009-10-14 10:55:19 +02002173 DWORD textures : 20; /* MAX_COMBINED_SAMPLERS, 20 */
2174 DWORD primitive_type : 1;
2175 DWORD indices : 1;
2176 DWORD material : 1;
2177 DWORD viewport : 1;
2178 DWORD vertexDecl : 1;
2179 DWORD pixelShader : 1;
2180 DWORD vertexShader : 1;
2181 DWORD scissorRect : 1;
2182 DWORD padding : 4;
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002183} SAVEDSTATES;
2184
Stefan Dösinger03ffb732007-08-09 17:45:29 +02002185struct StageState {
2186 DWORD stage;
2187 DWORD state;
2188};
2189
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002190struct IWineD3DStateBlockImpl
2191{
2192 /* IUnknown fields */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00002193 const IWineD3DStateBlockVtbl *lpVtbl;
Mike McCormack8955ac42005-07-28 10:16:21 +00002194 LONG ref; /* Note: Ref counting not required */
Oliver Stieberabb11f32005-07-05 14:05:18 +00002195
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002196 /* IWineD3DStateBlock information */
Jason Edmeades289562e2004-11-23 13:52:46 +00002197 IUnknown *parent;
Jason Edmeades41427852005-01-09 17:37:02 +00002198 IWineD3DDeviceImpl *wineD3DDevice;
Oliver Stieber7cb748f2005-07-26 18:49:30 +00002199 WINED3DSTATEBLOCKTYPE blockType;
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002200
2201 /* Array indicating whether things have been set or changed */
2202 SAVEDSTATES changed;
Oliver Stieberabb11f32005-07-05 14:05:18 +00002203
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002204 /* Vertex Shader Declaration */
Oliver Stieber2c0e97e2005-08-17 11:34:03 +00002205 IWineD3DVertexDeclaration *vertexDecl;
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002206
Oliver Stieberb3563da2005-09-28 10:13:00 +00002207 IWineD3DVertexShader *vertexShader;
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002208
Oliver Stieber9b0b8032005-08-17 10:27:01 +00002209 /* Vertex Shader Constants */
Jason Green718716b2006-07-19 00:06:07 -04002210 BOOL vertexShaderConstantB[MAX_CONST_B];
2211 INT vertexShaderConstantI[MAX_CONST_I * 4];
2212 float *vertexShaderConstantF;
Oliver Stieber9b0b8032005-08-17 10:27:01 +00002213
Henri Verbeet702eeb62009-03-05 12:30:43 +01002214 /* primitive type */
2215 GLenum gl_primitive_type;
2216
Jason Edmeades289562e2004-11-23 13:52:46 +00002217 /* Stream Source */
Raphael Junqueira4f02b522005-01-19 19:34:49 +00002218 BOOL streamIsUP;
Oliver Stieberabb11f32005-07-05 14:05:18 +00002219 UINT streamStride[MAX_STREAMS];
Stefan Dösinger26ebe392007-07-04 17:57:45 +02002220 UINT streamOffset[MAX_STREAMS + 1 /* tesselated pseudo-stream */ ];
Henri Verbeetaa3027a2009-03-06 14:56:23 +01002221 IWineD3DBuffer *streamSource[MAX_STREAMS];
Stefan Dösinger26ebe392007-07-04 17:57:45 +02002222 UINT streamFreq[MAX_STREAMS + 1];
2223 UINT streamFlags[MAX_STREAMS + 1]; /*0 | WINED3DSTREAMSOURCE_INSTANCEDATA | WINED3DSTREAMSOURCE_INDEXEDDATA */
Jason Edmeadeseba27af2004-11-28 15:04:41 +00002224
Jason Edmeadesf738c142004-12-09 11:42:34 +00002225 /* Indices */
Stefan Dösinger513a4932009-04-06 16:46:12 +02002226 IWineD3DBuffer* pIndexData;
Stefan Dösingercb1c9dc2009-04-09 10:50:31 +02002227 WINED3DFORMAT IndexFmt;
Stefan Dösinger6ec6c942007-08-25 00:09:33 +02002228 INT baseVertexIndex;
2229 INT loadBaseVertexIndex; /* non-indexed drawing needs 0 here, indexed baseVertexIndex */
Jason Edmeadesf738c142004-12-09 11:42:34 +00002230
Jason Edmeadeseba27af2004-11-28 15:04:41 +00002231 /* Transform */
Ivan Gyurdievac371632006-10-12 02:21:39 -04002232 WINED3DMATRIX transforms[HIGHEST_TRANSFORMSTATE + 1];
Jason Edmeadeseba27af2004-11-28 15:04:41 +00002233
Stefan Dösingeracadf3f2007-02-14 17:46:54 +01002234 /* Light hashmap . Collisions are handled using standard wine double linked lists */
2235#define LIGHTMAP_SIZE 43 /* Use of a prime number recommended. Set to 1 for a linked list! */
2236#define LIGHTMAP_HASHFUNC(x) ((x) % LIGHTMAP_SIZE) /* Primitive and simple function */
Henri Verbeet6a7b97b2009-09-29 11:09:03 +02002237 struct list lightMap[LIGHTMAP_SIZE]; /* Hash map containing the lights */
Henri Verbeet3bc9d182009-10-14 10:55:16 +02002238 const struct wined3d_light_info *activeLights[MAX_ACTIVE_LIGHTS]; /* Map of opengl lights to d3d lights */
Oliver Stieberabb11f32005-07-05 14:05:18 +00002239
Jason Edmeades0a944ae2004-11-29 17:53:42 +00002240 /* Clipping */
2241 double clipplane[MAX_CLIPPLANES][4];
2242 WINED3DCLIPSTATUS clip_status;
2243
Jason Edmeadesf738c142004-12-09 11:42:34 +00002244 /* ViewPort */
2245 WINED3DVIEWPORT viewport;
2246
Jason Edmeades0a944ae2004-11-29 17:53:42 +00002247 /* Material */
2248 WINED3DMATERIAL material;
2249
Oliver Stieberabb11f32005-07-05 14:05:18 +00002250 /* Pixel Shader */
Oliver Stieberb3563da2005-09-28 10:13:00 +00002251 IWineD3DPixelShader *pixelShader;
Oliver Stieber2af36c62005-08-25 19:24:21 +00002252
2253 /* Pixel Shader Constants */
Jason Green718716b2006-07-19 00:06:07 -04002254 BOOL pixelShaderConstantB[MAX_CONST_B];
2255 INT pixelShaderConstantI[MAX_CONST_I * 4];
2256 float *pixelShaderConstantF;
Oliver Stieberabb11f32005-07-05 14:05:18 +00002257
Jason Edmeades2003c7a2004-12-13 13:35:38 +00002258 /* RenderState */
Oliver Stieberabb11f32005-07-05 14:05:18 +00002259 DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
Jason Edmeades2003c7a2004-12-13 13:35:38 +00002260
Jason Edmeadesf738c142004-12-09 11:42:34 +00002261 /* Texture */
H. Verbeet5b7758f2007-06-25 22:45:40 +02002262 IWineD3DBaseTexture *textures[MAX_COMBINED_SAMPLERS];
Jason Edmeades2003c7a2004-12-13 13:35:38 +00002263
2264 /* Texture State Stage */
Oliver Stieber7cb748f2005-07-26 18:49:30 +00002265 DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
Stefan Dösinger762af472006-12-19 23:00:58 +01002266 DWORD lowest_disabled_stage;
Oliver Stieber18857f12005-06-24 11:53:07 +00002267 /* Sampler States */
H. Verbeet5b7758f2007-06-25 22:45:40 +02002268 DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
Oliver Stieber18857f12005-06-24 11:53:07 +00002269
Stefan Dösingerd4b63bb2007-01-10 11:28:42 +01002270 /* Scissor test rectangle */
2271 RECT scissorRect;
Stefan Dösinger93155ea2007-07-31 15:04:56 +02002272
2273 /* Contained state management */
2274 DWORD contained_render_states[WINEHIGHEST_RENDER_STATE + 1];
2275 unsigned int num_contained_render_states;
Stefan Dösinger6e7a10f2007-08-14 23:44:25 +02002276 DWORD contained_transform_states[HIGHEST_TRANSFORMSTATE + 1];
Stefan Dösinger92ce0282007-07-31 15:44:13 +02002277 unsigned int num_contained_transform_states;
Stefan Dösinger4673b1c2007-08-03 20:07:30 +02002278 DWORD contained_vs_consts_i[MAX_CONST_I];
2279 unsigned int num_contained_vs_consts_i;
2280 DWORD contained_vs_consts_b[MAX_CONST_B];
2281 unsigned int num_contained_vs_consts_b;
Stefan Dösingerb21c7852007-08-03 20:26:29 +02002282 DWORD *contained_vs_consts_f;
2283 unsigned int num_contained_vs_consts_f;
Stefan Dösinger865b82a2007-08-03 20:12:54 +02002284 DWORD contained_ps_consts_i[MAX_CONST_I];
2285 unsigned int num_contained_ps_consts_i;
2286 DWORD contained_ps_consts_b[MAX_CONST_B];
2287 unsigned int num_contained_ps_consts_b;
Stefan Dösingerb21c7852007-08-03 20:26:29 +02002288 DWORD *contained_ps_consts_f;
2289 unsigned int num_contained_ps_consts_f;
Henri Verbeeta8697d92009-01-06 11:43:45 +01002290 struct StageState contained_tss_states[MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1)];
Stefan Dösinger03ffb732007-08-09 17:45:29 +02002291 unsigned int num_contained_tss_states;
Stefan Dösinger59fb2922007-08-03 20:23:52 +02002292 struct StageState contained_sampler_states[MAX_COMBINED_SAMPLERS * WINED3D_HIGHEST_SAMPLER_STATE];
2293 unsigned int num_contained_sampler_states;
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002294};
2295
Henri Verbeet664057c2009-09-29 11:09:04 +02002296HRESULT stateblock_init(IWineD3DStateBlockImpl *stateblock, IWineD3DDeviceImpl *device,
2297 WINED3DSTATEBLOCKTYPE type, IUnknown *parent) DECLSPEC_HIDDEN;
Henri Verbeetbe0b7352009-09-30 10:49:13 +02002298void stateblock_init_contained_states(IWineD3DStateBlockImpl *object) DECLSPEC_HIDDEN;
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002299
Stefan Dösinger0e8c13e2007-12-04 01:43:24 +01002300/* Direct3D terminology with little modifications. We do not have an issued state
2301 * because only the driver knows about it, but we have a created state because d3d
2302 * allows GetData on a created issue, but opengl doesn't
2303 */
2304enum query_state {
2305 QUERY_CREATED,
2306 QUERY_SIGNALLED,
2307 QUERY_BUILDING
2308};
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002309/*****************************************************************************
Oliver Stieber7b261652005-03-03 13:57:15 +00002310 * IWineD3DQueryImpl implementation structure (extends IUnknown)
2311 */
2312typedef struct IWineD3DQueryImpl
2313{
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00002314 const IWineD3DQueryVtbl *lpVtbl;
Mike McCormack8955ac42005-07-28 10:16:21 +00002315 LONG ref; /* Note: Ref counting not required */
Henri Verbeet560d6352009-08-27 10:04:56 +02002316
Oliver Stieber7b261652005-03-03 13:57:15 +00002317 IUnknown *parent;
Oliver Stieber7b261652005-03-03 13:57:15 +00002318 IWineD3DDeviceImpl *wineD3DDevice;
Oliver Stieber7b261652005-03-03 13:57:15 +00002319
Ivan Gyurdievf0d5b352006-10-10 21:53:30 -04002320 /* IWineD3DQuery fields */
Stefan Dösinger0e8c13e2007-12-04 01:43:24 +01002321 enum query_state state;
Ivan Gyurdievf0d5b352006-10-10 21:53:30 -04002322 WINED3DQUERYTYPE type;
Oliver Stieber5ea96a82005-09-21 09:43:13 +00002323 /* TODO: Think about using a IUnknown instead of a void* */
Oliver Stieber7b261652005-03-03 13:57:15 +00002324 void *extendedData;
Oliver Stieber7b261652005-03-03 13:57:15 +00002325} IWineD3DQueryImpl;
2326
Henri Verbeet689984b2009-09-11 19:01:19 +02002327extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl DECLSPEC_HIDDEN;
2328extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl DECLSPEC_HIDDEN;
2329extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl DECLSPEC_HIDDEN;
Oliver Stieber7b261652005-03-03 13:57:15 +00002330
Henri Verbeet399d9922009-02-23 09:16:02 +01002331/* IWineD3DBuffer */
Henri Verbeetaa3027a2009-03-06 14:56:23 +01002332
2333/* TODO: Add tests and support for FLOAT16_4 POSITIONT, D3DCOLOR position, other
2334 * fixed function semantics as D3DCOLOR or FLOAT16 */
2335enum wined3d_buffer_conversion_type
2336{
2337 CONV_NONE,
2338 CONV_D3DCOLOR,
2339 CONV_POSITIONT,
2340 CONV_FLOAT16_2, /* Also handles FLOAT16_4 */
2341};
2342
2343#define WINED3D_BUFFER_OPTIMIZED 0x01 /* Optimize has been called for the buffer */
2344#define WINED3D_BUFFER_DIRTY 0x02 /* Buffer data has been modified */
2345#define WINED3D_BUFFER_HASDESC 0x04 /* A vertex description has been found */
2346#define WINED3D_BUFFER_CREATEBO 0x08 /* Attempt to create a buffer object next PreLoad */
Stefan Dösinger014c4bf2009-04-09 18:40:57 +02002347#define WINED3D_BUFFER_DOUBLEBUFFER 0x10 /* Use a vbo and local allocated memory */
Henri Verbeetaa3027a2009-03-06 14:56:23 +01002348
Henri Verbeet399d9922009-02-23 09:16:02 +01002349struct wined3d_buffer
2350{
2351 const struct IWineD3DBufferVtbl *vtbl;
2352 IWineD3DResourceClass resource;
2353
2354 struct wined3d_buffer_desc desc;
Henri Verbeetaa3027a2009-03-06 14:56:23 +01002355
2356 GLuint buffer_object;
2357 GLenum buffer_object_usage;
Stefan Dösinger2a7a2372009-04-06 13:38:56 +02002358 GLenum buffer_type_hint;
Henri Verbeetaa3027a2009-03-06 14:56:23 +01002359 UINT buffer_object_size;
2360 LONG bind_count;
2361 DWORD flags;
2362
2363 UINT dirty_start;
2364 UINT dirty_end;
2365 LONG lock_count;
2366
Henri Verbeetaa3027a2009-03-06 14:56:23 +01002367 /* conversion stuff */
2368 UINT conversion_count;
2369 UINT draw_count;
2370 UINT stride; /* 0 if no conversion */
2371 UINT conversion_stride; /* 0 if no shifted conversion */
2372 enum wined3d_buffer_conversion_type *conversion_map; /* NULL if no conversion */
2373 /* Extra load offsets, for FLOAT16 conversion */
2374 UINT *conversion_shift; /* NULL if no shifted conversion */
Henri Verbeet399d9922009-02-23 09:16:02 +01002375};
2376
Henri Verbeet689984b2009-09-11 19:01:19 +02002377const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object) DECLSPEC_HIDDEN;
2378BYTE *buffer_get_sysmem(struct wined3d_buffer *This) DECLSPEC_HIDDEN;
Henri Verbeet93b06002009-09-17 23:03:32 +02002379HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
2380 UINT size, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, GLenum bind_hint,
2381 const char *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet399d9922009-02-23 09:16:02 +01002382
Henri Verbeetc796f762009-02-24 07:43:02 +01002383/* IWineD3DRendertargetView */
2384struct wined3d_rendertarget_view
2385{
2386 const struct IWineD3DRendertargetViewVtbl *vtbl;
2387 LONG refcount;
2388
2389 IWineD3DResource *resource;
2390 IUnknown *parent;
2391};
2392
Henri Verbeet689984b2009-09-11 19:01:19 +02002393extern const IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl DECLSPEC_HIDDEN;
Henri Verbeetc796f762009-02-24 07:43:02 +01002394
Oliver Stieber7b261652005-03-03 13:57:15 +00002395/*****************************************************************************
Oliver Stieber46e7c302005-06-23 11:05:24 +00002396 * IWineD3DSwapChainImpl implementation structure (extends IUnknown)
2397 */
2398
2399typedef struct IWineD3DSwapChainImpl
2400{
2401 /*IUnknown part*/
Dmitry Timoshkov47ffd7a2006-12-14 22:47:59 +08002402 const IWineD3DSwapChainVtbl *lpVtbl;
Mike McCormack8955ac42005-07-28 10:16:21 +00002403 LONG ref; /* Note: Ref counting not required */
Oliver Stieber46e7c302005-06-23 11:05:24 +00002404
2405 IUnknown *parent;
2406 IWineD3DDeviceImpl *wineD3DDevice;
2407
2408 /* IWineD3DSwapChain fields */
Stefan Dösinger3862f8e2006-06-15 12:54:19 +02002409 IWineD3DSurface **backBuffer;
Oliver Stieber46e7c302005-06-23 11:05:24 +00002410 IWineD3DSurface *frontBuffer;
H. Verbeeta4bc52a2007-02-15 22:36:50 +01002411 WINED3DPRESENT_PARAMETERS presentParms;
Stefan Dösingerd30f1522006-12-08 16:13:15 +01002412 DWORD orig_width, orig_height;
Stefan Dösinger8e841272007-02-15 13:53:33 +01002413 WINED3DFORMAT orig_fmt;
Stefan Dösinger8d930f62008-07-01 11:17:38 -05002414 WINED3DGAMMARAMP orig_gamma;
Oliver Stieber46e7c302005-06-23 11:05:24 +00002415
Stefan Dösinger222c5312007-01-10 11:27:26 +01002416 long prev_time, frames; /* Performance tracking */
Stefan Dösingerc9b8a792007-06-03 13:20:27 +02002417 unsigned int vSyncCounter;
Stefan Dösinger222c5312007-01-10 11:27:26 +01002418
Henri Verbeetda1e5572009-08-03 08:06:51 +02002419 struct wined3d_context **context;
Stefan Dösinger90fe64c2007-03-04 17:31:06 +01002420 unsigned int num_contexts;
Oliver Stieber46e7c302005-06-23 11:05:24 +00002421
2422 HWND win_handle;
Oliver Stieber46e7c302005-06-23 11:05:24 +00002423} IWineD3DSwapChainImpl;
2424
Henri Verbeet689984b2009-09-11 19:01:19 +02002425extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl DECLSPEC_HIDDEN;
2426const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl DECLSPEC_HIDDEN;
2427void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc) DECLSPEC_HIDDEN;
Oliver Stieber46e7c302005-06-23 11:05:24 +00002428
Henri Verbeet689984b2009-09-11 19:01:19 +02002429HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface,
2430 REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
2431ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
2432ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
2433HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown **ppParent) DECLSPEC_HIDDEN;
2434HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface,
2435 IWineD3DSurface *pDestSurface) DECLSPEC_HIDDEN;
2436HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer,
2437 WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) DECLSPEC_HIDDEN;
2438HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface,
2439 WINED3DRASTER_STATUS *pRasterStatus) DECLSPEC_HIDDEN;
2440HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface,
2441 WINED3DDISPLAYMODE *pMode) DECLSPEC_HIDDEN;
2442HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface,
2443 IWineD3DDevice **ppDevice) DECLSPEC_HIDDEN;
2444HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface,
2445 WINED3DPRESENT_PARAMETERS *pPresentationParameters) DECLSPEC_HIDDEN;
2446HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
2447 DWORD Flags, const WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
2448HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
2449 WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
Stefan Dösingere5de2fc2008-07-27 18:04:16 -05002450
Henri Verbeet98027cb2009-10-28 11:00:12 +01002451struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
Stefan Dösingerb462ff02007-06-02 20:21:57 +00002452
Stefan Dösinger21f4e422009-08-26 10:24:09 +02002453#define DEFAULT_REFRESH_RATE 0
2454
Oliver Stieber46e7c302005-06-23 11:05:24 +00002455/*****************************************************************************
Henri Verbeet560d6352009-08-27 10:04:56 +02002456 * Utility function prototypes
Jason Edmeades447d5ed2004-10-21 20:59:12 +00002457 */
Jason Edmeades2003c7a2004-12-13 13:35:38 +00002458
2459/* Trace routines */
Henri Verbeet689984b2009-09-11 19:01:19 +02002460const char *debug_d3dformat(WINED3DFORMAT fmt) DECLSPEC_HIDDEN;
2461const char *debug_d3ddevicetype(WINED3DDEVTYPE devtype) DECLSPEC_HIDDEN;
2462const char *debug_d3dresourcetype(WINED3DRESOURCETYPE res) DECLSPEC_HIDDEN;
2463const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
2464const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
2465const char *debug_d3ddeclmethod(WINED3DDECLMETHOD method) DECLSPEC_HIDDEN;
2466const char *debug_d3ddeclusage(BYTE usage) DECLSPEC_HIDDEN;
2467const char *debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) DECLSPEC_HIDDEN;
2468const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN;
2469const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN;
2470const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
2471const char *debug_d3dtexturestate(DWORD state) DECLSPEC_HIDDEN;
2472const char *debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) DECLSPEC_HIDDEN;
2473const char *debug_d3dpool(WINED3DPOOL pool) DECLSPEC_HIDDEN;
2474const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
2475const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
2476const char *debug_d3dbasis(WINED3DBASISTYPE basis) DECLSPEC_HIDDEN;
2477const char *debug_d3ddegree(WINED3DDEGREETYPE order) DECLSPEC_HIDDEN;
2478const char *debug_d3dtop(WINED3DTEXTUREOP d3dtop) DECLSPEC_HIDDEN;
2479void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
2480const char *debug_surflocation(DWORD flag) DECLSPEC_HIDDEN;
Jason Edmeades2003c7a2004-12-13 13:35:38 +00002481
2482/* Routines for GL <-> D3D values */
Henri Verbeet689984b2009-09-11 19:01:19 +02002483GLenum StencilOp(DWORD op) DECLSPEC_HIDDEN;
2484GLenum CompareFunc(DWORD func) DECLSPEC_HIDDEN;
2485BOOL is_invalid_op(IWineD3DDeviceImpl *This, int stage, WINED3DTEXTUREOP op,
2486 DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
2487void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op,
2488 DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
2489void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords,
Jeff Zaroykoa1126242009-10-10 18:30:47 +11002490 BOOL transformed, WINED3DFORMAT coordtype, BOOL ffp_can_disable_proj) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02002491void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock,
2492 struct wined3d_context *context) DECLSPEC_HIDDEN;
2493void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock,
2494 struct wined3d_context *context) DECLSPEC_HIDDEN;
2495void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock,
2496 struct wined3d_context *context) DECLSPEC_HIDDEN;
2497void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock,
2498 struct wined3d_context *context) DECLSPEC_HIDDEN;
2499void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock,
2500 struct wined3d_context *context) DECLSPEC_HIDDEN;
2501void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock,
2502 struct wined3d_context *context) DECLSPEC_HIDDEN;
2503void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock,
2504 struct wined3d_context *context) DECLSPEC_HIDDEN;
2505void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
2506 struct wined3d_context *context) DECLSPEC_HIDDEN;
Jason Edmeadesae5a4362004-09-28 02:12:12 +00002507
Henri Verbeet689984b2009-09-11 19:01:19 +02002508void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect) DECLSPEC_HIDDEN;
2509GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
2510void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
2511void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location) DECLSPEC_HIDDEN;
2512void surface_set_compatible_renderbuffer(IWineD3DSurface *iface,
2513 unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
2514void surface_set_texture_name(IWineD3DSurface *iface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
2515void surface_set_texture_target(IWineD3DSurface *iface, GLenum target) DECLSPEC_HIDDEN;
H. Verbeetc9b178b2007-04-09 01:53:32 +02002516
Henri Verbeetdd1f0d92009-03-24 10:09:24 +01002517BOOL getColorBits(const struct GlPixelFormatDesc *format_desc,
Henri Verbeet689984b2009-09-11 19:01:19 +02002518 short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize) DECLSPEC_HIDDEN;
2519BOOL getDepthStencilBits(const struct GlPixelFormatDesc *format_desc,
2520 short *depthSize, short *stencilSize) DECLSPEC_HIDDEN;
Roderick Colenbrander4647cbb2007-08-09 01:04:30 +02002521
Stefan Dösinger9abdac62006-05-12 22:21:31 +02002522/* Math utils */
Henri Verbeet689984b2009-09-11 19:01:19 +02002523void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2) DECLSPEC_HIDDEN;
2524UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN;
2525unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN;
Oliver Stieber8a6799d2005-07-07 20:35:05 +00002526
Ivan Gyurdieve9de5632006-07-09 22:51:03 -06002527typedef struct local_constant {
2528 struct list entry;
2529 unsigned int idx;
2530 DWORD value[4];
2531} local_constant;
2532
Ivan Gyurdievc93239d2006-05-08 17:09:21 -04002533typedef struct SHADER_LIMITS {
2534 unsigned int temporary;
Ivan Gyurdiev0d083162006-06-12 02:59:16 -04002535 unsigned int texcoord;
2536 unsigned int sampler;
Ivan Gyurdievc93239d2006-05-08 17:09:21 -04002537 unsigned int constant_int;
2538 unsigned int constant_float;
2539 unsigned int constant_bool;
2540 unsigned int address;
Ivan Gyurdieva1f4dfe2006-06-12 02:57:07 -04002541 unsigned int packed_output;
2542 unsigned int packed_input;
Jason Green473ce802006-05-26 11:52:33 -04002543 unsigned int attributes;
Ivan Gyurdiev33293df2006-07-10 04:35:15 -06002544 unsigned int label;
Ivan Gyurdievc93239d2006-05-08 17:09:21 -04002545} SHADER_LIMITS;
2546
Henri Verbeet560d6352009-08-27 10:04:56 +02002547/* Keeps track of details for TEX_M#x# shader opcodes which need to
2548 * maintain state information between multiple codes */
Jason Green653e71d2006-05-09 22:30:11 -04002549typedef struct SHADER_PARSE_STATE {
2550 unsigned int current_row;
2551 DWORD texcoord_w[2];
2552} SHADER_PARSE_STATE;
2553
Alexandre Julliard57d15482007-11-28 12:55:11 +01002554#ifdef __GNUC__
2555#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
2556#else
2557#define PRINTF_ATTR(fmt,args)
2558#endif
2559
Henri Verbeet40b41192009-07-09 09:56:08 +02002560/* Base Shader utility functions. */
Henri Verbeet689984b2009-09-11 19:01:19 +02002561int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
2562int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
Ivan Gyurdiev5f105602006-05-08 15:44:25 -04002563
Ivan Gyurdiev5b3c5002006-07-07 00:27:38 -06002564/* Vertex shader utility functions */
Henri Verbeet689984b2009-09-11 19:01:19 +02002565extern BOOL vshader_get_input(IWineD3DVertexShader *iface,
2566 BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
Ivan Gyurdiev5b3c5002006-07-07 00:27:38 -06002567
Henri Verbeet689984b2009-09-11 19:01:19 +02002568extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) DECLSPEC_HIDDEN;
Jason Green718716b2006-07-19 00:06:07 -04002569
Raphael Junqueira01968612003-11-14 03:50:35 +00002570/*****************************************************************************
H. Verbeet59af5c42006-03-30 19:14:31 +02002571 * IDirect3DBaseShader implementation structure
2572 */
2573typedef struct IWineD3DBaseShaderClass
2574{
Stefan Dösingerbd975802007-11-16 21:01:33 +01002575 LONG ref;
Ivan Gyurdievc93239d2006-05-08 17:09:21 -04002576 SHADER_LIMITS limits;
Jason Green653e71d2006-05-09 22:30:11 -04002577 SHADER_PARSE_STATE parse_state;
Stefan Dösinger7a97d4e2007-11-16 21:02:29 +01002578 DWORD *function;
H. Verbeet59af5c42006-03-30 19:14:31 +02002579 UINT functionLength;
Stefan Dösinger3f16f022007-09-14 13:21:52 +02002580 UINT cur_loop_depth, cur_loop_regno;
Stefan Dösingeredb78182007-11-09 14:48:47 +01002581 BOOL load_local_constsF;
Henri Verbeet2a5a6a32009-05-05 09:38:03 +02002582 const struct wined3d_shader_frontend *frontend;
2583 void *frontend_data;
Henri Verbeetf88c6e52009-09-25 13:31:44 +02002584 void *backend_data;
2585
2586 IUnknown *parent;
2587 const struct wined3d_parent_ops *parent_ops;
Ivan Gyurdiev77162362006-07-04 01:21:53 -06002588
H. Verbeet2c85e5e2007-02-27 20:51:53 +01002589 /* Programs this shader is linked with */
2590 struct list linked_programs;
2591
Ivan Gyurdieve9de5632006-07-09 22:51:03 -06002592 /* Immediate constants (override global ones) */
2593 struct list constantsB;
2594 struct list constantsF;
2595 struct list constantsI;
H. Verbeetef87a402006-08-05 18:15:35 +02002596 shader_reg_maps reg_maps;
Ivan Gyurdieve9de5632006-07-09 22:51:03 -06002597
Ivan Gyurdievd0032a12006-09-27 07:14:46 -04002598 /* Pointer to the parent device */
2599 IWineD3DDevice *device;
Stefan Dösinger09bf3d52008-01-08 20:45:59 +01002600 struct list shader_list_entry;
Ivan Gyurdievd0032a12006-09-27 07:14:46 -04002601
H. Verbeet59af5c42006-03-30 19:14:31 +02002602} IWineD3DBaseShaderClass;
2603
2604typedef struct IWineD3DBaseShaderImpl {
2605 /* IUnknown */
2606 const IWineD3DBaseShaderVtbl *lpVtbl;
H. Verbeet59af5c42006-03-30 19:14:31 +02002607
2608 /* IWineD3DBaseShader */
2609 IWineD3DBaseShaderClass baseShader;
2610} IWineD3DBaseShaderImpl;
2611
Henri Verbeet689984b2009-09-11 19:01:19 +02002612void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
2613BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
2614void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
2615void shader_cleanup(IWineD3DBaseShader *iface) DECLSPEC_HIDDEN;
Henri Verbeet65622a02009-05-06 17:59:21 +02002616void shader_dump_src_param(const struct wined3d_shader_src_param *param,
Henri Verbeet689984b2009-09-11 19:01:19 +02002617 const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
Henri Verbeet65622a02009-05-06 17:59:21 +02002618void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
Henri Verbeet689984b2009-09-11 19:01:19 +02002619 const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
2620unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN;
Henri Verbeet40b41192009-07-09 09:56:08 +02002621void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
Henri Verbeet689984b2009-09-11 19:01:19 +02002622 const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
Henri Verbeet23781082009-05-04 09:49:27 +02002623HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
Henri Verbeet19cb4592009-05-27 10:24:50 +02002624 struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
Henri Verbeet2ee0d472009-05-27 10:24:50 +02002625 struct wined3d_shader_signature_element *input_signature,
Henri Verbeet689984b2009-09-11 19:01:19 +02002626 struct wined3d_shader_signature_element *output_signature,
2627 const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN;
Henri Verbeetf88c6e52009-09-25 13:31:44 +02002628void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
2629 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02002630BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN;
2631const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN;
2632void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN;
Jason Green36b0b9c2006-05-09 22:33:24 -04002633
Henri Verbeet65622a02009-05-06 17:59:21 +02002634static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
2635{
2636 return type == WINED3D_SHADER_TYPE_PIXEL;
Ivan Gyurdiev8b7401c2006-05-14 09:43:31 -04002637}
2638
Henri Verbeet65622a02009-05-06 17:59:21 +02002639static inline BOOL shader_is_vshader_version(enum wined3d_shader_type type)
2640{
2641 return type == WINED3D_SHADER_TYPE_VERTEX;
Ivan Gyurdiev8b7401c2006-05-14 09:43:31 -04002642}
2643
Henri Verbeet96005c02009-05-07 16:36:08 +02002644static inline BOOL shader_is_scalar(const struct wined3d_shader_register *reg)
Henri Verbeetf7f61a52009-04-07 11:09:11 +02002645{
Henri Verbeet96005c02009-05-07 16:36:08 +02002646 switch (reg->type)
Henri Verbeetf7f61a52009-04-07 11:09:11 +02002647 {
H. Verbeeta79654d2007-04-12 23:55:31 +02002648 case WINED3DSPR_RASTOUT:
Henri Verbeetf7f61a52009-04-07 11:09:11 +02002649 /* oFog & oPts */
Henri Verbeet96005c02009-05-07 16:36:08 +02002650 if (reg->idx != 0) return TRUE;
H. Verbeeta79654d2007-04-12 23:55:31 +02002651 /* oPos */
2652 return FALSE;
2653
2654 case WINED3DSPR_DEPTHOUT: /* oDepth */
2655 case WINED3DSPR_CONSTBOOL: /* b# */
2656 case WINED3DSPR_LOOP: /* aL */
2657 case WINED3DSPR_PREDICATE: /* p0 */
2658 return TRUE;
2659
Stefan Dösinger81de2fa2008-02-11 12:04:57 +01002660 case WINED3DSPR_MISCTYPE:
Henri Verbeet96005c02009-05-07 16:36:08 +02002661 switch(reg->idx)
Henri Verbeetf7f61a52009-04-07 11:09:11 +02002662 {
Stefan Dösinger81de2fa2008-02-11 12:04:57 +01002663 case 0: /* vPos */
2664 return FALSE;
2665 case 1: /* vFace */
2666 return TRUE;
2667 default:
2668 return FALSE;
2669 }
2670
Henri Verbeet69cbb572009-05-07 16:36:08 +02002671 case WINED3DSPR_IMMCONST:
2672 switch(reg->immconst_type)
2673 {
2674 case WINED3D_IMMCONST_FLOAT:
2675 return TRUE;
2676 default:
2677 return FALSE;
2678 }
2679
H. Verbeeta79654d2007-04-12 23:55:31 +02002680 default:
2681 return FALSE;
2682 }
2683}
2684
Stefan Dösingeraeb0e432008-02-14 14:15:49 +01002685static inline BOOL shader_constant_is_local(IWineD3DBaseShaderImpl* This, DWORD reg) {
2686 local_constant* lconst;
2687
2688 if(This->baseShader.load_local_constsF) return FALSE;
2689 LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
2690 if(lconst->idx == reg) return TRUE;
2691 }
2692 return FALSE;
2693
2694}
2695
H. Verbeet59af5c42006-03-30 19:14:31 +02002696/*****************************************************************************
Stefan Dösinger8dcd5122009-02-05 19:44:32 +01002697 * IDirect3DVertexShader implementation structures
Raphael Junqueira01968612003-11-14 03:50:35 +00002698 */
Oliver Stieber2121f782005-03-02 12:16:10 +00002699typedef struct IWineD3DVertexShaderImpl {
Henri Verbeet560d6352009-08-27 10:04:56 +02002700 /* IUnknown parts */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00002701 const IWineD3DVertexShaderVtbl *lpVtbl;
Raphael Junqueira01968612003-11-14 03:50:35 +00002702
H. Verbeet59af5c42006-03-30 19:14:31 +02002703 /* IWineD3DBaseShader */
2704 IWineD3DBaseShaderClass baseShader;
2705
Ivan Gyurdiev276609e2006-07-04 02:01:46 -06002706 /* Vertex shader input and output semantics */
Henri Verbeet19cb4592009-05-27 10:24:50 +02002707 struct wined3d_shader_attribute attributes[MAX_ATTRIBS];
Henri Verbeet2ee0d472009-05-27 10:24:50 +02002708 struct wined3d_shader_signature_element output_signature[MAX_REG_OUTPUT];
Ivan Gyurdiev276609e2006-07-04 02:01:46 -06002709
Stefan Dösingerfb0dde7b2007-11-07 19:57:49 +01002710 UINT min_rel_offset, max_rel_offset;
2711 UINT rel_offset;
Oliver Stieber2121f782005-03-02 12:16:10 +00002712} IWineD3DVertexShaderImpl;
Stefan Dösinger8dcd5122009-02-05 19:44:32 +01002713
Henri Verbeet689984b2009-09-11 19:01:19 +02002714void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,
2715 struct vs_compile_args *args) DECLSPEC_HIDDEN;
Henri Verbeet462decd2009-09-23 18:42:04 +02002716HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device,
2717 const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
Henri Verbeetca05ef52009-09-23 18:42:08 +02002718 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Raphael Junqueira01968612003-11-14 03:50:35 +00002719
2720/*****************************************************************************
2721 * IDirect3DPixelShader implementation structure
2722 */
Tobias Jakobi79067742009-06-17 23:24:25 +02002723
2724/* Using additional shader constants (uniforms in GLSL / program environment
2725 * or local parameters in ARB) is costly:
2726 * ARB only knows float4 parameters and GLSL compiler are not really smart
2727 * when it comes to efficiently pack float2 uniforms, so no space is wasted
2728 * (in fact most compilers map a float2 to a full float4 uniform).
2729 *
2730 * For NP2 texcoord fixup we only need 2 floats (width and height) for each
2731 * 2D texture used in the shader. We therefore pack fixup info for 2 textures
2732 * into a single shader constant (uniform / program parameter).
2733 *
2734 * This structure is shared between the GLSL and the ARB backend.*/
2735struct ps_np2fixup_info {
2736 unsigned char idx[MAX_FRAGMENT_SAMPLERS]; /* indices to the real constant */
2737 WORD active; /* bitfield indicating if we can apply the fixup */
2738 WORD num_consts;
2739};
2740
Oliver Stieber2121f782005-03-02 12:16:10 +00002741typedef struct IWineD3DPixelShaderImpl {
Oliver Stieberb3563da2005-09-28 10:13:00 +00002742 /* IUnknown parts */
Dmitry Timoshkoveba47f12005-06-06 19:50:35 +00002743 const IWineD3DPixelShaderVtbl *lpVtbl;
Oliver Stieberb3563da2005-09-28 10:13:00 +00002744
H. Verbeet59af5c42006-03-30 19:14:31 +02002745 /* IWineD3DBaseShader */
2746 IWineD3DBaseShaderClass baseShader;
2747
Ivan Gyurdiev276609e2006-07-04 02:01:46 -06002748 /* Pixel shader input semantics */
Henri Verbeet2ee0d472009-05-27 10:24:50 +02002749 struct wined3d_shader_signature_element input_signature[MAX_REG_INPUT];
Stefan Dösinger409103f2007-10-28 00:12:37 +02002750 DWORD input_reg_map[MAX_REG_INPUT];
Stefan Dösinger1b23dd12007-11-06 12:34:22 +01002751 BOOL input_reg_used[MAX_REG_INPUT];
Henri Verbeete4183192009-07-08 09:49:28 +02002752 unsigned int declared_in_count;
Ivan Gyurdiev276609e2006-07-04 02:01:46 -06002753
Stefan Dösinger49a49fc2007-02-15 03:05:17 +01002754 /* Some information about the shader behavior */
Stefan Dösinger9c6cdda2007-09-14 13:11:00 +02002755 char vpos_uniform;
Stefan Dösingerd8e219b2009-05-26 15:53:52 +02002756
2757 BOOL color0_mov;
2758 DWORD color0_reg;
2759
Oliver Stieber2121f782005-03-02 12:16:10 +00002760} IWineD3DPixelShaderImpl;
2761
Henri Verbeet8aea1b12009-09-23 18:42:09 +02002762HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
2763 const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
Henri Verbeet789372a2009-09-23 18:42:13 +02002764 IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
Henri Verbeet689984b2009-09-11 19:01:19 +02002765void pixelshader_update_samplers(struct shader_reg_maps *reg_maps,
2766 IWineD3DBaseTexture * const *textures) DECLSPEC_HIDDEN;
2767void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,
2768 struct ps_compile_args *args) DECLSPEC_HIDDEN;
Stefan Dösingercff4e1e2006-04-17 17:04:59 +02002769
Stefan Dösinger6313e0f2007-09-14 13:02:59 +02002770/* sRGB correction constants */
Henri Verbeet2ac34bf2009-07-07 11:08:01 +02002771static const float srgb_cmp = 0.0031308f;
2772static const float srgb_mul_low = 12.92f;
2773static const float srgb_pow = 0.41666f;
2774static const float srgb_mul_high = 1.055f;
2775static const float srgb_sub_high = 0.055f;
Stefan Dösinger6313e0f2007-09-14 13:02:59 +02002776
Stefan Dösingercff4e1e2006-04-17 17:04:59 +02002777/*****************************************************************************
2778 * IWineD3DPalette implementation structure
2779 */
2780struct IWineD3DPaletteImpl {
2781 /* IUnknown parts */
2782 const IWineD3DPaletteVtbl *lpVtbl;
2783 LONG ref;
Stefan Dösingera6f71af2006-04-21 00:00:30 +02002784
2785 IUnknown *parent;
2786 IWineD3DDeviceImpl *wineD3DDevice;
2787
2788 /* IWineD3DPalette */
2789 HPALETTE hpal;
2790 WORD palVersion; /*| */
2791 WORD palNumEntries; /*| LOGPALETTE */
2792 PALETTEENTRY palents[256]; /*| */
2793 /* This is to store the palette in 'screen format' */
2794 int screen_palents[256];
2795 DWORD Flags;
Stefan Dösingercff4e1e2006-04-17 17:04:59 +02002796};
2797
Henri Verbeet689984b2009-09-11 19:01:19 +02002798extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl DECLSPEC_HIDDEN;
2799DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags) DECLSPEC_HIDDEN;
Stefan Dösingercff4e1e2006-04-17 17:04:59 +02002800
Stefan Dösingera6206832006-04-18 23:04:51 +02002801/* DirectDraw utility functions */
Henri Verbeet689984b2009-09-11 19:01:19 +02002802extern WINED3DFORMAT pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
Stefan Dösingera6206832006-04-18 23:04:51 +02002803
Stefan Dösinger35187472006-06-21 10:36:14 +02002804/*****************************************************************************
2805 * Pixel format management
2806 */
Henri Verbeetb4510482008-12-03 14:53:42 +01002807
Henri Verbeet7420a962009-05-01 09:13:54 +02002808/* WineD3D pixel format flags */
2809#define WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING 0x1
2810#define WINED3DFMT_FLAG_FILTERING 0x2
2811#define WINED3DFMT_FLAG_DEPTH 0x4
2812#define WINED3DFMT_FLAG_STENCIL 0x8
2813#define WINED3DFMT_FLAG_RENDERTARGET 0x10
2814#define WINED3DFMT_FLAG_FOURCC 0x20
Henri Verbeetfb753152009-06-05 14:39:20 +02002815#define WINED3DFMT_FLAG_FBO_ATTACHABLE 0x40
Henri Verbeet61fd8752009-06-10 09:44:04 +02002816#define WINED3DFMT_FLAG_COMPRESSED 0x80
Stefan Dösingere1469962009-09-05 16:37:19 +02002817#define WINED3DFMT_FLAG_GETDC 0x100
Henri Verbeet7420a962009-05-01 09:13:54 +02002818
Henri Verbeetb4510482008-12-03 14:53:42 +01002819struct GlPixelFormatDesc
2820{
Henri Verbeet53bf5c22009-03-13 10:44:17 +01002821 WINED3DFORMAT format;
2822 DWORD red_mask;
2823 DWORD green_mask;
2824 DWORD blue_mask;
2825 DWORD alpha_mask;
2826 UINT byte_count;
2827 WORD depth_size;
2828 WORD stencil_size;
2829
Henri Verbeet61fd8752009-06-10 09:44:04 +02002830 UINT block_width;
2831 UINT block_height;
2832 UINT block_byte_count;
2833
Henri Verbeet4434d002009-03-27 10:25:56 +01002834 enum wined3d_ffp_emit_idx emit_idx;
2835 GLint component_count;
2836 GLenum gl_vtx_type;
2837 GLint gl_vtx_format;
2838 GLboolean gl_normalized;
2839 unsigned int component_size;
2840
Henri Verbeetb4510482008-12-03 14:53:42 +01002841 GLint glInternal;
2842 GLint glGammaInternal;
2843 GLint rtInternal;
2844 GLint glFormat;
2845 GLint glType;
Henri Verbeetb4510482008-12-03 14:53:42 +01002846 unsigned int Flags;
2847 float heightscale;
Henri Verbeet89139b72008-12-03 14:53:43 +01002848 struct color_fixup_desc color_fixup;
Henri Verbeetb4510482008-12-03 14:53:42 +01002849};
2850
Henri Verbeet689984b2009-09-11 19:01:19 +02002851const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
2852 const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
H. Verbeet30ee0712007-03-12 23:22:00 +01002853
Henri Verbeet2b926db2008-12-30 14:56:49 +01002854static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
2855{
Henri Verbeet92b66ac2009-08-19 10:55:35 +02002856 /* Check stateblock->vertexDecl to allow this to be used from
2857 * IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because
2858 * stateblock->vertexShader implies a vertex declaration instead of ddraw
2859 * style strided data. */
Henri Verbeet2b926db2008-12-30 14:56:49 +01002860 return (stateblock->vertexShader
Henri Verbeet92b66ac2009-08-19 10:55:35 +02002861 && !((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed
Henri Verbeet2b926db2008-12-30 14:56:49 +01002862 && stateblock->wineD3DDevice->vs_selected_mode != SHADER_NONE);
H. Verbeet30ee0712007-03-12 23:22:00 +01002863}
2864
Henri Verbeet2b926db2008-12-30 14:56:49 +01002865static inline BOOL use_ps(IWineD3DStateBlockImpl *stateblock)
2866{
2867 return (stateblock->pixelShader
2868 && stateblock->wineD3DDevice->ps_selected_mode != SHADER_NONE);
H. Verbeet30ee0712007-03-12 23:22:00 +01002869}
2870
Henri Verbeet689984b2009-09-11 19:01:19 +02002871void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface,
2872 WINED3DRECT *src_rect, IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect,
2873 const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) DECLSPEC_HIDDEN;
Rico Schüller2ef75182009-05-11 21:43:54 +02002874
2875/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
2876#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
2877
Raphael Junqueira01968612003-11-14 03:50:35 +00002878#endif