2 * Utility functions for the WineD3D Library
4 * Copyright 2002-2004 Jason Edmeades
5 * Copyright 2003-2004 Raphael Junqueira
6 * Copyright 2004 Christian Costa
7 * Copyright 2005 Oliver Stieber
8 * Copyright 2006-2008 Henri Verbeet
9 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
10 * Copyright 2009-2010 Henri Verbeet for CodeWeavers
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Lesser General Public
14 * License as published by the Free Software Foundation; either
15 * version 2.1 of the License, or (at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/port.h"
32 #include "wined3d_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
36 struct wined3d_format_channels
38 enum wined3d_format_id id
;
39 DWORD red_size
, green_size
, blue_size
, alpha_size
;
40 DWORD red_offset
, green_offset
, blue_offset
, alpha_offset
;
42 BYTE depth_size
, stencil_size
;
45 static const struct wined3d_format_channels formats
[] =
48 * format id r g b a r g b a bpp depth stencil */
49 {WINED3DFMT_UNKNOWN
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
51 {WINED3DFMT_UYVY
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
52 {WINED3DFMT_YUY2
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
53 {WINED3DFMT_YV12
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
54 {WINED3DFMT_NV12
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
55 {WINED3DFMT_DXT1
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
56 {WINED3DFMT_DXT2
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
57 {WINED3DFMT_DXT3
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
58 {WINED3DFMT_DXT4
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
59 {WINED3DFMT_DXT5
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
60 {WINED3DFMT_MULTI2_ARGB8
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
61 {WINED3DFMT_G8R8_G8B8
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
62 {WINED3DFMT_R8G8_B8G8
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
64 {WINED3DFMT_R32_FLOAT
, 32, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0},
65 {WINED3DFMT_R32G32_FLOAT
, 32, 32, 0, 0, 0, 32, 0, 0, 8, 0, 0},
66 {WINED3DFMT_R32G32B32_FLOAT
, 32, 32, 32, 0, 0, 32, 64, 0, 12, 0, 0},
67 {WINED3DFMT_R32G32B32A32_FLOAT
, 32, 32, 32, 32, 0, 32, 64, 96, 16, 0, 0},
69 {WINED3DFMT_R8G8_SNORM_Cx
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
71 {WINED3DFMT_R16_FLOAT
, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
72 {WINED3DFMT_R16G16_FLOAT
, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
73 {WINED3DFMT_R16G16_SINT
, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
74 {WINED3DFMT_R16G16B16A16_FLOAT
, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
75 {WINED3DFMT_R16G16B16A16_SINT
, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
76 /* Palettized formats */
77 {WINED3DFMT_P8_UINT_A8_UNORM
, 0, 0, 0, 8, 0, 0, 0, 8, 2, 0, 0},
78 {WINED3DFMT_P8_UINT
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
79 /* Standard ARGB formats. */
80 {WINED3DFMT_B8G8R8_UNORM
, 8, 8, 8, 0, 16, 8, 0, 0, 3, 0, 0},
81 {WINED3DFMT_B8G8R8A8_UNORM
, 8, 8, 8, 8, 16, 8, 0, 24, 4, 0, 0},
82 {WINED3DFMT_B8G8R8X8_UNORM
, 8, 8, 8, 0, 16, 8, 0, 0, 4, 0, 0},
83 {WINED3DFMT_B5G6R5_UNORM
, 5, 6, 5, 0, 11, 5, 0, 0, 2, 0, 0},
84 {WINED3DFMT_B5G5R5X1_UNORM
, 5, 5, 5, 0, 10, 5, 0, 0, 2, 0, 0},
85 {WINED3DFMT_B5G5R5A1_UNORM
, 5, 5, 5, 1, 10, 5, 0, 15, 2, 0, 0},
86 {WINED3DFMT_B4G4R4A4_UNORM
, 4, 4, 4, 4, 8, 4, 0, 12, 2, 0, 0},
87 {WINED3DFMT_B2G3R3_UNORM
, 3, 3, 2, 0, 5, 2, 0, 0, 1, 0, 0},
88 {WINED3DFMT_R8_UNORM
, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
89 {WINED3DFMT_A8_UNORM
, 0, 0, 0, 8, 0, 0, 0, 0, 1, 0, 0},
90 {WINED3DFMT_B2G3R3A8_UNORM
, 3, 3, 2, 8, 5, 2, 0, 8, 2, 0, 0},
91 {WINED3DFMT_B4G4R4X4_UNORM
, 4, 4, 4, 0, 8, 4, 0, 0, 2, 0, 0},
92 {WINED3DFMT_R10G10B10A2_UNORM
, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
93 {WINED3DFMT_R10G10B10A2_UINT
, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
94 {WINED3DFMT_R10G10B10A2_SNORM
, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
95 {WINED3DFMT_R8G8B8A8_UNORM
, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
96 {WINED3DFMT_R8G8B8A8_UINT
, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
97 {WINED3DFMT_R8G8B8X8_UNORM
, 8, 8, 8, 0, 0, 8, 16, 0, 4, 0, 0},
98 {WINED3DFMT_R16G16_UNORM
, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
99 {WINED3DFMT_B10G10R10A2_UNORM
, 10, 10, 10, 2, 20, 10, 0, 30, 4, 0, 0},
100 {WINED3DFMT_R16G16B16A16_UNORM
, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
102 {WINED3DFMT_L8_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
103 {WINED3DFMT_L8A8_UNORM
, 0, 0, 0, 8, 0, 0, 0, 8, 2, 0, 0},
104 {WINED3DFMT_L4A4_UNORM
, 0, 0, 0, 4, 0, 0, 0, 4, 1, 0, 0},
105 {WINED3DFMT_L16_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
106 /* Bump mapping stuff */
107 {WINED3DFMT_R8G8_SNORM
, 8, 8, 0, 0, 0, 8, 0, 0, 2, 0, 0},
108 {WINED3DFMT_R5G5_SNORM_L6_UNORM
, 5, 5, 0, 0, 0, 5, 0, 0, 2, 0, 0},
109 {WINED3DFMT_R8G8_SNORM_L8X8_UNORM
, 8, 8, 0, 0, 0, 8, 0, 0, 4, 0, 0},
110 {WINED3DFMT_R8G8B8A8_SNORM
, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
111 {WINED3DFMT_R16G16_SNORM
, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
112 {WINED3DFMT_R10G11B11_SNORM
, 10, 11, 11, 0, 0, 10, 21, 0, 4, 0, 0},
113 {WINED3DFMT_R10G10B10_SNORM_A2_UNORM
, 10, 10, 10, 2, 0, 10, 20, 30, 4, 0, 0},
114 /* Depth stencil formats */
115 {WINED3DFMT_D16_LOCKABLE
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 0},
116 {WINED3DFMT_D32_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 0},
117 {WINED3DFMT_S1_UINT_D15_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 15, 1},
118 {WINED3DFMT_D24_UNORM_S8_UINT
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
119 {WINED3DFMT_X8D24_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 0},
120 {WINED3DFMT_S4X4_UINT_D24_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 4},
121 {WINED3DFMT_D16_UNORM
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 16, 0},
122 {WINED3DFMT_D32_FLOAT
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 0},
123 {WINED3DFMT_S8_UINT_D24_FLOAT
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
124 {WINED3DFMT_VERTEXDATA
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
125 {WINED3DFMT_R16_UINT
, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
126 {WINED3DFMT_R32_UINT
, 32, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0},
127 {WINED3DFMT_R32G32_UINT
, 32, 32, 0, 0, 0, 32, 0, 0, 8, 0, 0},
128 {WINED3DFMT_R32G32B32_UINT
, 32, 32, 32, 0, 0, 32, 64, 0, 12, 0, 0},
129 {WINED3DFMT_R32G32B32A32_UINT
, 32, 32, 32, 32, 0, 32, 64, 96, 16, 0, 0},
130 {WINED3DFMT_R16G16B16A16_SNORM
, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
131 /* Vendor-specific formats */
132 {WINED3DFMT_ATI1N
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
133 {WINED3DFMT_ATI2N
, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
134 {WINED3DFMT_NVDB
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
135 {WINED3DFMT_INST
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
136 {WINED3DFMT_INTZ
, 0, 0, 0, 0, 0, 0, 0, 0, 4, 24, 8},
137 {WINED3DFMT_RESZ
, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
138 {WINED3DFMT_NVHU
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
139 {WINED3DFMT_NVHS
, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
140 {WINED3DFMT_NULL
, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
141 /* Unsure about them, could not find a Windows driver that supports them */
142 {WINED3DFMT_R16
, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
143 {WINED3DFMT_AL16
, 0, 0, 0, 16, 0, 0, 0, 16, 4, 0, 0},
145 {WINED3DFMT_R8_TYPELESS
, 8, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},
146 {WINED3DFMT_R8G8_TYPELESS
, 8, 8, 0, 0, 0, 8, 0, 0, 2, 0, 0},
147 {WINED3DFMT_R8G8B8A8_TYPELESS
, 8, 8, 8, 8, 0, 8, 16, 24, 4, 0, 0},
148 {WINED3DFMT_R16_TYPELESS
, 16, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
149 {WINED3DFMT_R16G16_TYPELESS
, 16, 16, 0, 0, 0, 16, 0, 0, 4, 0, 0},
150 {WINED3DFMT_R16G16B16A16_TYPELESS
, 16, 16, 16, 16, 0, 16, 32, 48, 8, 0, 0},
151 {WINED3DFMT_R32_TYPELESS
, 32, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0},
152 {WINED3DFMT_R32G32_TYPELESS
, 32, 32, 0, 0, 0, 32, 0, 0, 8, 0, 0},
153 {WINED3DFMT_R32G32B32_TYPELESS
, 32, 32, 32, 0, 0, 32, 64, 0, 12, 0, 0},
154 {WINED3DFMT_R32G32B32A32_TYPELESS
, 32, 32, 32, 32, 0, 32, 64, 96, 16, 0, 0},
157 struct wined3d_format_base_flags
159 enum wined3d_format_id id
;
163 /* The ATI2N format behaves like an uncompressed format in LockRect(), but
164 * still needs to use the correct block based calculation for e.g. the
166 static const struct wined3d_format_base_flags format_base_flags
[] =
168 {WINED3DFMT_P8_UINT
, WINED3DFMT_FLAG_GETDC
},
169 {WINED3DFMT_B8G8R8_UNORM
, WINED3DFMT_FLAG_GETDC
},
170 {WINED3DFMT_B8G8R8A8_UNORM
, WINED3DFMT_FLAG_GETDC
},
171 {WINED3DFMT_B8G8R8X8_UNORM
, WINED3DFMT_FLAG_GETDC
},
172 {WINED3DFMT_B5G6R5_UNORM
, WINED3DFMT_FLAG_GETDC
},
173 {WINED3DFMT_B5G5R5X1_UNORM
, WINED3DFMT_FLAG_GETDC
},
174 {WINED3DFMT_B5G5R5A1_UNORM
, WINED3DFMT_FLAG_GETDC
},
175 {WINED3DFMT_B4G4R4A4_UNORM
, WINED3DFMT_FLAG_GETDC
},
176 {WINED3DFMT_B4G4R4X4_UNORM
, WINED3DFMT_FLAG_GETDC
},
177 {WINED3DFMT_R8G8B8A8_UNORM
, WINED3DFMT_FLAG_GETDC
},
178 {WINED3DFMT_R8G8B8X8_UNORM
, WINED3DFMT_FLAG_GETDC
},
179 {WINED3DFMT_ATI1N
, WINED3DFMT_FLAG_BROKEN_PITCH
},
180 {WINED3DFMT_ATI2N
, WINED3DFMT_FLAG_BROKEN_PITCH
},
181 {WINED3DFMT_R32_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
182 {WINED3DFMT_R32G32_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
183 {WINED3DFMT_R32G32B32_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
184 {WINED3DFMT_R32G32B32A32_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
185 {WINED3DFMT_R16_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
186 {WINED3DFMT_R16G16_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
187 {WINED3DFMT_R16G16B16A16_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
188 {WINED3DFMT_D32_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
189 {WINED3DFMT_S8_UINT_D24_FLOAT
, WINED3DFMT_FLAG_FLOAT
},
192 struct wined3d_format_block_info
194 enum wined3d_format_id id
;
197 UINT block_byte_count
;
201 static const struct wined3d_format_block_info format_block_info
[] =
203 {WINED3DFMT_DXT1
, 4, 4, 8, TRUE
},
204 {WINED3DFMT_DXT2
, 4, 4, 16, TRUE
},
205 {WINED3DFMT_DXT3
, 4, 4, 16, TRUE
},
206 {WINED3DFMT_DXT4
, 4, 4, 16, TRUE
},
207 {WINED3DFMT_DXT5
, 4, 4, 16, TRUE
},
208 {WINED3DFMT_ATI1N
, 4, 4, 8, FALSE
},
209 {WINED3DFMT_ATI2N
, 4, 4, 16, FALSE
},
210 {WINED3DFMT_YUY2
, 2, 1, 4, FALSE
},
211 {WINED3DFMT_UYVY
, 2, 1, 4, FALSE
},
214 struct wined3d_format_vertex_info
216 enum wined3d_format_id id
;
217 enum wined3d_ffp_emit_idx emit_idx
;
218 GLint component_count
;
221 GLboolean gl_normalized
;
222 unsigned int component_size
;
225 static const struct wined3d_format_vertex_info format_vertex_info
[] =
227 {WINED3DFMT_R32_FLOAT
, WINED3D_FFP_EMIT_FLOAT1
, 1, GL_FLOAT
, 1, GL_FALSE
, sizeof(float)},
228 {WINED3DFMT_R32G32_FLOAT
, WINED3D_FFP_EMIT_FLOAT2
, 2, GL_FLOAT
, 2, GL_FALSE
, sizeof(float)},
229 {WINED3DFMT_R32G32B32_FLOAT
, WINED3D_FFP_EMIT_FLOAT3
, 3, GL_FLOAT
, 3, GL_FALSE
, sizeof(float)},
230 {WINED3DFMT_R32G32B32A32_FLOAT
, WINED3D_FFP_EMIT_FLOAT4
, 4, GL_FLOAT
, 4, GL_FALSE
, sizeof(float)},
231 {WINED3DFMT_B8G8R8A8_UNORM
, WINED3D_FFP_EMIT_D3DCOLOR
, 4, GL_UNSIGNED_BYTE
, 4, GL_TRUE
, sizeof(BYTE
)},
232 {WINED3DFMT_R8G8B8A8_UINT
, WINED3D_FFP_EMIT_UBYTE4
, 4, GL_UNSIGNED_BYTE
, 4, GL_FALSE
, sizeof(BYTE
)},
233 {WINED3DFMT_R16G16_SINT
, WINED3D_FFP_EMIT_SHORT2
, 2, GL_SHORT
, 2, GL_FALSE
, sizeof(short int)},
234 {WINED3DFMT_R16G16B16A16_SINT
, WINED3D_FFP_EMIT_SHORT4
, 4, GL_SHORT
, 4, GL_FALSE
, sizeof(short int)},
235 {WINED3DFMT_R8G8B8A8_UNORM
, WINED3D_FFP_EMIT_UBYTE4N
, 4, GL_UNSIGNED_BYTE
, 4, GL_TRUE
, sizeof(BYTE
)},
236 {WINED3DFMT_R16G16_SNORM
, WINED3D_FFP_EMIT_SHORT2N
, 2, GL_SHORT
, 2, GL_TRUE
, sizeof(short int)},
237 {WINED3DFMT_R16G16B16A16_SNORM
, WINED3D_FFP_EMIT_SHORT4N
, 4, GL_SHORT
, 4, GL_TRUE
, sizeof(short int)},
238 {WINED3DFMT_R16G16_UNORM
, WINED3D_FFP_EMIT_USHORT2N
, 2, GL_UNSIGNED_SHORT
, 2, GL_TRUE
, sizeof(short int)},
239 {WINED3DFMT_R16G16B16A16_UNORM
, WINED3D_FFP_EMIT_USHORT4N
, 4, GL_UNSIGNED_SHORT
, 4, GL_TRUE
, sizeof(short int)},
240 {WINED3DFMT_R10G10B10A2_UINT
, WINED3D_FFP_EMIT_UDEC3
, 3, GL_UNSIGNED_SHORT
, 3, GL_FALSE
, sizeof(short int)},
241 {WINED3DFMT_R10G10B10A2_SNORM
, WINED3D_FFP_EMIT_DEC3N
, 3, GL_SHORT
, 3, GL_TRUE
, sizeof(short int)},
242 {WINED3DFMT_R16G16_FLOAT
, WINED3D_FFP_EMIT_FLOAT16_2
, 2, GL_FLOAT
, 2, GL_FALSE
, sizeof(GLhalfNV
)},
243 {WINED3DFMT_R16G16B16A16_FLOAT
, WINED3D_FFP_EMIT_FLOAT16_4
, 4, GL_FLOAT
, 4, GL_FALSE
, sizeof(GLhalfNV
)},
244 {WINED3DFMT_R32_UINT
, WINED3D_FFP_EMIT_INVALID
, 1, GL_UNSIGNED_INT
, 1, GL_FALSE
, sizeof(UINT
)},
245 {WINED3DFMT_R32G32_UINT
, WINED3D_FFP_EMIT_INVALID
, 2, GL_UNSIGNED_INT
, 2, GL_FALSE
, sizeof(UINT
)},
246 {WINED3DFMT_R32G32B32_UINT
, WINED3D_FFP_EMIT_INVALID
, 3, GL_UNSIGNED_INT
, 3, GL_FALSE
, sizeof(UINT
)},
247 {WINED3DFMT_R32G32B32A32_UINT
, WINED3D_FFP_EMIT_INVALID
, 4, GL_UNSIGNED_INT
, 4, GL_FALSE
, sizeof(UINT
)},
250 struct wined3d_format_texture_info
252 enum wined3d_format_id id
;
254 GLint gl_srgb_internal
;
255 GLint gl_rt_internal
;
258 unsigned int conv_byte_count
;
260 enum wined3d_gl_extension extension
;
261 void (*convert
)(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
262 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
);
265 static void convert_l4a4_unorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
266 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
268 /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not
269 * format+type combination to load it. Thus convert it to A8L8, then load it
270 * with A4L4 internal, but A8L8 format+type
272 unsigned int x
, y
, z
;
273 const unsigned char *Source
;
276 for (z
= 0; z
< depth
; z
++)
278 for (y
= 0; y
< height
; y
++)
280 Source
= src
+ z
* src_slice_pitch
+ y
* src_row_pitch
;
281 Dest
= dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
;
282 for (x
= 0; x
< width
; x
++ )
284 unsigned char color
= (*Source
++);
285 /* A */ Dest
[1] = (color
& 0xf0) << 0;
286 /* L */ Dest
[0] = (color
& 0x0f) << 4;
293 static void convert_r5g5_snorm_l6_unorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
294 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
296 unsigned int x
, y
, z
;
299 for (z
= 0; z
< depth
; z
++)
301 for (y
= 0; y
< height
; y
++)
303 unsigned short *Dest_s
= (unsigned short *) (dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
304 Source
= (const WORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
305 for (x
= 0; x
< width
; x
++ )
307 short color
= (*Source
++);
308 unsigned char l
= ((color
>> 10) & 0xfc);
309 short v
= ((color
>> 5) & 0x3e);
310 short u
= ((color
) & 0x1f);
311 short v_conv
= v
+ 16;
312 short u_conv
= u
+ 16;
314 *Dest_s
= ((v_conv
<< 11) & 0xf800) | ((l
<< 5) & 0x7e0) | (u_conv
& 0x1f);
321 static void convert_r5g5_snorm_l6_unorm_nv(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
322 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
324 unsigned int x
, y
, z
;
328 /* This makes the gl surface bigger(24 bit instead of 16), but it works with
329 * fixed function and shaders without further conversion once the surface is
332 for (z
= 0; z
< depth
; z
++)
334 for (y
= 0; y
< height
; y
++)
336 Source
= (const WORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
337 Dest
= dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
;
338 for (x
= 0; x
< width
; x
++ )
340 short color
= (*Source
++);
341 unsigned char l
= ((color
>> 10) & 0xfc);
342 char v
= ((color
>> 5) & 0x3e);
343 char u
= ((color
) & 0x1f);
345 /* 8 bits destination, 6 bits source, 8th bit is the sign. gl ignores the sign
346 * and doubles the positive range. Thus shift left only once, gl does the 2nd
347 * shift. GL reads a signed value and converts it into an unsigned value.
349 /* M */ Dest
[2] = l
<< 1;
351 /* Those are read as signed, but kept signed. Just left-shift 3 times to scale
352 * from 5 bit values to 8 bit values.
354 /* V */ Dest
[1] = v
<< 3;
355 /* U */ Dest
[0] = u
<< 3;
362 static void convert_r8g8_snorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
363 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
365 unsigned int x
, y
, z
;
369 for (z
= 0; z
< depth
; z
++)
371 for (y
= 0; y
< height
; y
++)
373 Source
= (const short *)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
374 Dest
= dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
;
375 for (x
= 0; x
< width
; x
++ )
377 const short color
= (*Source
++);
378 /* B */ Dest
[0] = 0xff;
379 /* G */ Dest
[1] = (color
>> 8) + 128; /* V */
380 /* R */ Dest
[2] = (color
& 0xff) + 128; /* U */
387 static void convert_r8g8_snorm_l8x8_unorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
388 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
390 unsigned int x
, y
, z
;
394 /* Doesn't work correctly with the fixed function pipeline, but can work in
395 * shaders if the shader is adjusted. (There's no use for this format in gl's
396 * standard fixed function pipeline anyway).
398 for (z
= 0; z
< depth
; z
++)
400 for (y
= 0; y
< height
; y
++)
402 Source
= (const DWORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
403 Dest
= dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
;
404 for (x
= 0; x
< width
; x
++ )
406 LONG color
= (*Source
++);
407 /* B */ Dest
[0] = ((color
>> 16) & 0xff); /* L */
408 /* G */ Dest
[1] = ((color
>> 8 ) & 0xff) + 128; /* V */
409 /* R */ Dest
[2] = (color
& 0xff) + 128; /* U */
416 static void convert_r8g8_snorm_l8x8_unorm_nv(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
417 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
419 unsigned int x
, y
, z
;
423 /* This implementation works with the fixed function pipeline and shaders
424 * without further modification after converting the surface.
426 for (z
= 0; z
< depth
; z
++)
428 for (y
= 0; y
< height
; y
++)
430 Source
= (const DWORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
431 Dest
= dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
;
432 for (x
= 0; x
< width
; x
++ )
434 LONG color
= (*Source
++);
435 /* L */ Dest
[2] = ((color
>> 16) & 0xff); /* L */
436 /* V */ Dest
[1] = ((color
>> 8 ) & 0xff); /* V */
437 /* U */ Dest
[0] = (color
& 0xff); /* U */
438 /* I */ Dest
[3] = 255; /* X */
445 static void convert_r8g8b8a8_snorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
446 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
448 unsigned int x
, y
, z
;
452 for (z
= 0; z
< depth
; z
++)
454 for (y
= 0; y
< height
; y
++)
456 Source
= (const DWORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
457 Dest
= dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
;
458 for (x
= 0; x
< width
; x
++ )
460 LONG color
= (*Source
++);
461 /* B */ Dest
[0] = ((color
>> 16) & 0xff) + 128; /* W */
462 /* G */ Dest
[1] = ((color
>> 8 ) & 0xff) + 128; /* V */
463 /* R */ Dest
[2] = (color
& 0xff) + 128; /* U */
464 /* A */ Dest
[3] = ((color
>> 24) & 0xff) + 128; /* Q */
471 static void convert_r16g16_snorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
472 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
474 unsigned int x
, y
, z
;
476 unsigned short *Dest
;
478 for (z
= 0; z
< depth
; z
++)
480 for (y
= 0; y
< height
; y
++)
482 Source
= (const DWORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
483 Dest
= (unsigned short *) (dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
484 for (x
= 0; x
< width
; x
++ )
486 const DWORD color
= (*Source
++);
487 /* B */ Dest
[0] = 0xffff;
488 /* G */ Dest
[1] = (color
>> 16) + 32768; /* V */
489 /* R */ Dest
[2] = (color
& 0xffff) + 32768; /* U */
496 static void convert_r16g16(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
497 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
499 unsigned int x
, y
, z
;
503 for (z
= 0; z
< depth
; z
++)
505 for (y
= 0; y
< height
; y
++)
507 Source
= (const WORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
508 Dest
= (WORD
*) (dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
509 for (x
= 0; x
< width
; x
++ )
511 WORD green
= (*Source
++);
512 WORD red
= (*Source
++);
515 /* Strictly speaking not correct for R16G16F, but it doesn't matter because the
516 * shader overwrites it anyway */
524 static void convert_r32g32_float(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
525 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
527 unsigned int x
, y
, z
;
531 for (z
= 0; z
< depth
; z
++)
533 for (y
= 0; y
< height
; y
++)
535 Source
= (const float *)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
536 Dest
= (float *) (dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
537 for (x
= 0; x
< width
; x
++ )
539 float green
= (*Source
++);
540 float red
= (*Source
++);
550 static void convert_s1_uint_d15_unorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
551 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
553 unsigned int x
, y
, z
;
555 for (z
= 0; z
< depth
; z
++)
557 for (y
= 0; y
< height
; ++y
)
559 const WORD
*source
= (const WORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
560 DWORD
*dest
= (DWORD
*)(dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
562 for (x
= 0; x
< width
; ++x
)
564 /* The depth data is normalized, so needs to be scaled,
565 * the stencil data isn't. Scale depth data by
566 * (2^24-1)/(2^15-1) ~~ (2^9 + 2^-6). */
567 WORD d15
= source
[x
] >> 1;
568 DWORD d24
= (d15
<< 9) + (d15
>> 6);
569 dest
[x
] = (d24
<< 8) | (source
[x
] & 0x1);
575 static void convert_s4x4_uint_d24_unorm(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
576 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
578 unsigned int x
, y
, z
;
580 for (z
= 0; z
< depth
; z
++)
582 for (y
= 0; y
< height
; ++y
)
584 const DWORD
*source
= (const DWORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
585 DWORD
*dest
= (DWORD
*)(dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
587 for (x
= 0; x
< width
; ++x
)
589 /* Just need to clear out the X4 part. */
590 dest
[x
] = source
[x
] & ~0xf0;
596 static void convert_s8_uint_d24_float(const BYTE
*src
, BYTE
*dst
, UINT src_row_pitch
, UINT src_slice_pitch
,
597 UINT dst_row_pitch
, UINT dst_slice_pitch
, UINT width
, UINT height
, UINT depth
)
599 unsigned int x
, y
, z
;
601 for (z
= 0; z
< depth
; z
++)
603 for (y
= 0; y
< height
; ++y
)
605 const DWORD
*source
= (const DWORD
*)(src
+ z
* src_slice_pitch
+ y
* src_row_pitch
);
606 float *dest_f
= (float *)(dst
+ z
* dst_slice_pitch
+ y
* dst_row_pitch
);
607 DWORD
*dest_s
= (DWORD
*)dest_f
;
609 for (x
= 0; x
< width
; ++x
)
611 dest_f
[x
* 2] = float_24_to_32((source
[x
] & 0xffffff00) >> 8);
612 dest_s
[x
* 2 + 1] = source
[x
] & 0xff;
618 static BOOL
color_in_range(const struct wined3d_color_key
*color_key
, DWORD color
)
620 /* FIXME: Is this really how color keys are supposed to work? I think it
621 * makes more sense to compare the individual channels. */
622 return color
>= color_key
->color_space_low_value
623 && color
<= color_key
->color_space_high_value
;
626 static void convert_p8_uint_b8g8r8a8_unorm(const BYTE
*src
, unsigned int src_pitch
,
627 BYTE
*dst
, unsigned int dst_pitch
, unsigned int width
, unsigned int height
,
628 const struct wined3d_palette
*palette
, const struct wined3d_color_key
*color_key
)
636 /* FIXME: This should probably use the system palette. */
637 FIXME("P8 surface loaded without a palette.\n");
639 for (y
= 0; y
< height
; ++y
)
641 memset(&dst
[dst_pitch
* y
], 0, width
* 4);
647 for (y
= 0; y
< height
; ++y
)
649 src_row
= &src
[src_pitch
* y
];
650 dst_row
= (DWORD
*)&dst
[dst_pitch
* y
];
651 for (x
= 0; x
< width
; ++x
)
653 BYTE src_color
= src_row
[x
];
654 dst_row
[x
] = 0xff000000
655 | (palette
->colors
[src_color
].rgbRed
<< 16)
656 | (palette
->colors
[src_color
].rgbGreen
<< 8)
657 | palette
->colors
[src_color
].rgbBlue
;
662 static void convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key(const BYTE
*src
, unsigned int src_pitch
,
663 BYTE
*dst
, unsigned int dst_pitch
, unsigned int width
, unsigned int height
,
664 const struct wined3d_palette
*palette
, const struct wined3d_color_key
*color_key
)
670 for (y
= 0; y
< height
; ++y
)
672 src_row
= (WORD
*)&src
[src_pitch
* y
];
673 dst_row
= (WORD
*)&dst
[dst_pitch
* y
];
674 for (x
= 0; x
< width
; ++x
)
676 WORD src_color
= src_row
[x
];
677 if (!color_in_range(color_key
, src_color
))
678 dst_row
[x
] = 0x8000 | ((src_color
& 0xffc0) >> 1) | (src_color
& 0x1f);
680 dst_row
[x
] = ((src_color
& 0xffc0) >> 1) | (src_color
& 0x1f);
685 static void convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key(const BYTE
*src
, unsigned int src_pitch
,
686 BYTE
*dst
, unsigned int dst_pitch
, unsigned int width
, unsigned int height
,
687 const struct wined3d_palette
*palette
, const struct wined3d_color_key
*color_key
)
693 for (y
= 0; y
< height
; ++y
)
695 src_row
= (WORD
*)&src
[src_pitch
* y
];
696 dst_row
= (WORD
*)&dst
[dst_pitch
* y
];
697 for (x
= 0; x
< width
; ++x
)
699 WORD src_color
= src_row
[x
];
700 if (color_in_range(color_key
, src_color
))
701 dst_row
[x
] = src_color
& ~0x8000;
703 dst_row
[x
] = src_color
| 0x8000;
708 static void convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key(const BYTE
*src
, unsigned int src_pitch
,
709 BYTE
*dst
, unsigned int dst_pitch
, unsigned int width
, unsigned int height
,
710 const struct wined3d_palette
*palette
, const struct wined3d_color_key
*color_key
)
716 for (y
= 0; y
< height
; ++y
)
718 src_row
= &src
[src_pitch
* y
];
719 dst_row
= (DWORD
*)&dst
[dst_pitch
* y
];
720 for (x
= 0; x
< width
; ++x
)
722 DWORD src_color
= (src_row
[x
* 3 + 2] << 16) | (src_row
[x
* 3 + 1] << 8) | src_row
[x
* 3];
723 if (!color_in_range(color_key
, src_color
))
724 dst_row
[x
] = src_color
| 0xff000000;
729 static void convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key(const BYTE
*src
, unsigned int src_pitch
,
730 BYTE
*dst
, unsigned int dst_pitch
, unsigned int width
, unsigned int height
,
731 const struct wined3d_palette
*palette
, const struct wined3d_color_key
*color_key
)
733 const DWORD
*src_row
;
737 for (y
= 0; y
< height
; ++y
)
739 src_row
= (DWORD
*)&src
[src_pitch
* y
];
740 dst_row
= (DWORD
*)&dst
[dst_pitch
* y
];
741 for (x
= 0; x
< width
; ++x
)
743 DWORD src_color
= src_row
[x
];
744 if (color_in_range(color_key
, src_color
))
745 dst_row
[x
] = src_color
& ~0xff000000;
747 dst_row
[x
] = src_color
| 0xff000000;
752 static void convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key(const BYTE
*src
, unsigned int src_pitch
,
753 BYTE
*dst
, unsigned int dst_pitch
, unsigned int width
, unsigned int height
,
754 const struct wined3d_palette
*palette
, const struct wined3d_color_key
*color_key
)
756 const DWORD
*src_row
;
760 for (y
= 0; y
< height
; ++y
)
762 src_row
= (DWORD
*)&src
[src_pitch
* y
];
763 dst_row
= (DWORD
*)&dst
[dst_pitch
* y
];
764 for (x
= 0; x
< width
; ++x
)
766 DWORD src_color
= src_row
[x
];
767 if (color_in_range(color_key
, src_color
))
768 src_color
&= ~0xff000000;
769 dst_row
[x
] = src_color
;
774 const struct wined3d_color_key_conversion
* wined3d_format_get_color_key_conversion(
775 const struct wined3d_texture
*texture
, BOOL need_alpha_ck
)
777 const struct wined3d_format
*format
= texture
->resource
.format
;
782 enum wined3d_format_id src_format
;
783 struct wined3d_color_key_conversion conversion
;
787 {WINED3DFMT_B5G6R5_UNORM
, {WINED3DFMT_B5G5R5A1_UNORM
, convert_b5g6r5_unorm_b5g5r5a1_unorm_color_key
}},
788 {WINED3DFMT_B5G5R5X1_UNORM
, {WINED3DFMT_B5G5R5A1_UNORM
, convert_b5g5r5x1_unorm_b5g5r5a1_unorm_color_key
}},
789 {WINED3DFMT_B8G8R8_UNORM
, {WINED3DFMT_B8G8R8A8_UNORM
, convert_b8g8r8_unorm_b8g8r8a8_unorm_color_key
}},
790 {WINED3DFMT_B8G8R8X8_UNORM
, {WINED3DFMT_B8G8R8A8_UNORM
, convert_b8g8r8x8_unorm_b8g8r8a8_unorm_color_key
}},
791 {WINED3DFMT_B8G8R8A8_UNORM
, {WINED3DFMT_B8G8R8A8_UNORM
, convert_b8g8r8a8_unorm_b8g8r8a8_unorm_color_key
}},
793 static const struct wined3d_color_key_conversion convert_p8
=
795 WINED3DFMT_B8G8R8A8_UNORM
, convert_p8_uint_b8g8r8a8_unorm
798 if (need_alpha_ck
&& (texture
->flags
& WINED3D_TEXTURE_COLOR_KEY
))
800 for (i
= 0; i
< sizeof(color_key_info
) / sizeof(*color_key_info
); ++i
)
802 if (color_key_info
[i
].src_format
== format
->id
)
803 return &color_key_info
[i
].conversion
;
806 FIXME("Color-keying not supported with format %s.\n", debug_d3dformat(format
->id
));
809 /* FIXME: This should check if the blitter backend can do P8 conversion,
810 * instead of checking for ARB_fragment_program. */
811 if (format
->id
== WINED3DFMT_P8_UINT
812 && !(texture
->resource
.device
->adapter
->gl_info
.supported
[ARB_FRAGMENT_PROGRAM
]
813 && texture
->swapchain
&& texture
== texture
->swapchain
->front_buffer
))
819 /* The following formats explicitly don't have WINED3DFMT_FLAG_TEXTURE set:
821 * These are never supported on native.
822 * WINED3DFMT_B8G8R8_UNORM
823 * WINED3DFMT_B2G3R3_UNORM
824 * WINED3DFMT_L4A4_UNORM
825 * WINED3DFMT_S1_UINT_D15_UNORM
826 * WINED3DFMT_S4X4_UINT_D24_UNORM
828 * Only some Geforce/Voodoo3/G400 cards offer 8-bit textures in case of ddraw.
829 * Since it is not widely available, don't offer it. Further no Windows driver
830 * offers WINED3DFMT_P8_UINT_A8_NORM, so don't offer it either.
832 * WINED3DFMT_P8_UINT_A8_UNORM
834 * These formats seem to be similar to the HILO formats in
835 * GL_NV_texture_shader. NVHU is said to be GL_UNSIGNED_HILO16,
836 * NVHS GL_SIGNED_HILO16. Rumours say that D3D computes a 3rd channel
837 * similarly to D3DFMT_CxV8U8 (So NVHS could be called D3DFMT_CxV16U16). ATI
838 * refused to support formats which can easily be emulated with pixel shaders,
839 * so applications have to deal with not having NVHS and NVHU.
842 static const struct wined3d_format_texture_info format_texture_info
[] =
844 /* format id gl_internal gl_srgb_internal gl_rt_internal
845 gl_format gl_type conv_byte_count
849 /* GL_APPLE_ycbcr_422 claims that its '2YUV' format, which is supported via the UNSIGNED_SHORT_8_8_REV_APPLE type
850 * is equivalent to 'UYVY' format on Windows, and the 'YUVS' via UNSIGNED_SHORT_8_8_APPLE equates to 'YUY2'. The
851 * d3d9 test however shows that the opposite is true. Since the extension is from 2002, it predates the x86 based
852 * Macs, so probably the endianness differs. This could be tested as soon as we have a Windows and MacOS on a big
855 {WINED3DFMT_UYVY
, GL_LUMINANCE_ALPHA
, GL_LUMINANCE_ALPHA
, 0,
856 GL_LUMINANCE_ALPHA
, GL_UNSIGNED_BYTE
, 0,
857 WINED3DFMT_FLAG_FILTERING
,
858 WINED3D_GL_EXT_NONE
, NULL
},
859 {WINED3DFMT_UYVY
, GL_RGB
, GL_RGB
, 0,
860 GL_YCBCR_422_APPLE
, GL_UNSIGNED_SHORT_8_8_APPLE
, 0,
861 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_FILTERING
,
862 APPLE_YCBCR_422
, NULL
},
863 {WINED3DFMT_YUY2
, GL_LUMINANCE_ALPHA
, GL_LUMINANCE_ALPHA
, 0,
864 GL_LUMINANCE_ALPHA
, GL_UNSIGNED_BYTE
, 0,
865 WINED3DFMT_FLAG_FILTERING
,
866 WINED3D_GL_EXT_NONE
, NULL
},
867 {WINED3DFMT_YUY2
, GL_RGB
, GL_RGB
, 0,
868 GL_YCBCR_422_APPLE
, GL_UNSIGNED_SHORT_8_8_REV_APPLE
, 0,
869 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_FILTERING
,
870 APPLE_YCBCR_422
, NULL
},
871 {WINED3DFMT_YV12
, GL_ALPHA
, GL_ALPHA
, 0,
872 GL_ALPHA
, GL_UNSIGNED_BYTE
, 0,
873 WINED3DFMT_FLAG_FILTERING
,
874 WINED3D_GL_EXT_NONE
, NULL
},
875 {WINED3DFMT_NV12
, GL_ALPHA
, GL_ALPHA
, 0,
876 GL_ALPHA
, GL_UNSIGNED_BYTE
, 0,
877 WINED3DFMT_FLAG_FILTERING
,
878 WINED3D_GL_EXT_NONE
, NULL
},
879 {WINED3DFMT_DXT1
, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
, 0,
880 GL_RGBA
, GL_UNSIGNED_BYTE
, 0,
881 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
882 | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED
,
883 EXT_TEXTURE_COMPRESSION_S3TC
, NULL
},
884 {WINED3DFMT_DXT2
, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
, 0,
885 GL_RGBA
, GL_UNSIGNED_BYTE
, 0,
886 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
887 | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED
,
888 EXT_TEXTURE_COMPRESSION_S3TC
, NULL
},
889 {WINED3DFMT_DXT3
, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
, 0,
890 GL_RGBA
, GL_UNSIGNED_BYTE
, 0,
891 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
892 | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED
,
893 EXT_TEXTURE_COMPRESSION_S3TC
, NULL
},
894 {WINED3DFMT_DXT4
, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
, 0,
895 GL_RGBA
, GL_UNSIGNED_BYTE
, 0,
896 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
897 | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED
,
898 EXT_TEXTURE_COMPRESSION_S3TC
, NULL
},
899 {WINED3DFMT_DXT5
, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
, 0,
900 GL_RGBA
, GL_UNSIGNED_BYTE
, 0,
901 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
902 | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED
,
903 EXT_TEXTURE_COMPRESSION_S3TC
, NULL
},
905 {WINED3DFMT_R32_FLOAT
, GL_RGB32F_ARB
, GL_RGB32F_ARB
, 0,
907 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
908 ARB_TEXTURE_FLOAT
, NULL
},
909 {WINED3DFMT_R32_FLOAT
, GL_R32F
, GL_R32F
, 0,
911 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
912 ARB_TEXTURE_RG
, NULL
},
913 {WINED3DFMT_R32G32_FLOAT
, GL_RGB32F_ARB
, GL_RGB32F_ARB
, 0,
914 GL_RGB
, GL_FLOAT
, 12,
915 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
916 ARB_TEXTURE_FLOAT
, convert_r32g32_float
},
917 {WINED3DFMT_R32G32_FLOAT
, GL_RG32F
, GL_RG32F
, 0,
919 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
920 ARB_TEXTURE_RG
, NULL
},
921 {WINED3DFMT_R32G32B32A32_FLOAT
, GL_RGBA32F_ARB
, GL_RGBA32F_ARB
, 0,
922 GL_RGBA
, GL_FLOAT
, 0,
923 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
924 ARB_TEXTURE_FLOAT
, NULL
},
926 {WINED3DFMT_R16_FLOAT
, GL_RGB16F_ARB
, GL_RGB16F_ARB
, 0,
927 GL_RED
, GL_HALF_FLOAT_ARB
, 0,
928 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
929 ARB_TEXTURE_FLOAT
, NULL
},
930 {WINED3DFMT_R16_FLOAT
, GL_R16F
, GL_R16F
, 0,
931 GL_RED
, GL_HALF_FLOAT_ARB
, 0,
932 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
933 ARB_TEXTURE_RG
, NULL
},
934 {WINED3DFMT_R16G16_FLOAT
, GL_RGB16F_ARB
, GL_RGB16F_ARB
, 0,
935 GL_RGB
, GL_HALF_FLOAT_ARB
, 6,
936 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
937 ARB_TEXTURE_FLOAT
, convert_r16g16
},
938 {WINED3DFMT_R16G16_FLOAT
, GL_RG16F
, GL_RG16F
, 0,
939 GL_RG
, GL_HALF_FLOAT_ARB
, 0,
940 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
941 ARB_TEXTURE_RG
, NULL
},
942 {WINED3DFMT_R16G16B16A16_FLOAT
, GL_RGBA16F_ARB
, GL_RGBA16F_ARB
, 0,
943 GL_RGBA
, GL_HALF_FLOAT_ARB
, 0,
944 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_RENDERTARGET
945 | WINED3DFMT_FLAG_VTF
,
946 ARB_TEXTURE_FLOAT
, NULL
},
947 /* Palettized formats */
948 {WINED3DFMT_P8_UINT
, GL_ALPHA8
, GL_ALPHA8
, 0,
949 GL_ALPHA
, GL_UNSIGNED_BYTE
, 0,
952 /* Standard ARGB formats */
953 {WINED3DFMT_B8G8R8_UNORM
, GL_RGB8
, GL_RGB8
, 0,
954 GL_BGR
, GL_UNSIGNED_BYTE
, 0,
955 WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
| WINED3DFMT_FLAG_RENDERTARGET
,
956 WINED3D_GL_EXT_NONE
, NULL
},
957 {WINED3DFMT_B8G8R8A8_UNORM
, GL_RGBA8
, GL_SRGB8_ALPHA8_EXT
, 0,
958 GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0,
959 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
960 | WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_SRGB_WRITE
961 | WINED3DFMT_FLAG_VTF
,
962 WINED3D_GL_EXT_NONE
, NULL
},
963 {WINED3DFMT_B8G8R8X8_UNORM
, GL_RGB8
, GL_SRGB8_EXT
, 0,
964 GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0,
965 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
966 | WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_SRGB_WRITE
,
967 WINED3D_GL_EXT_NONE
, NULL
},
968 {WINED3DFMT_B5G6R5_UNORM
, GL_RGB5
, GL_RGB5
, GL_RGB8
,
969 GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
, 0,
970 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
971 | WINED3DFMT_FLAG_RENDERTARGET
,
972 WINED3D_GL_EXT_NONE
, NULL
},
973 {WINED3DFMT_B5G5R5X1_UNORM
, GL_RGB5
, GL_RGB5_A1
, 0,
974 GL_BGRA
, GL_UNSIGNED_SHORT_1_5_5_5_REV
, 0,
975 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
976 WINED3D_GL_EXT_NONE
, NULL
},
977 {WINED3DFMT_B5G5R5A1_UNORM
, GL_RGB5_A1
, GL_RGB5_A1
, 0,
978 GL_BGRA
, GL_UNSIGNED_SHORT_1_5_5_5_REV
, 0,
979 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
980 WINED3D_GL_EXT_NONE
, NULL
},
981 {WINED3DFMT_B4G4R4A4_UNORM
, GL_RGBA4
, GL_SRGB8_ALPHA8_EXT
, 0,
982 GL_BGRA
, GL_UNSIGNED_SHORT_4_4_4_4_REV
, 0,
983 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
984 | WINED3DFMT_FLAG_SRGB_READ
,
985 WINED3D_GL_EXT_NONE
, NULL
},
986 {WINED3DFMT_B2G3R3_UNORM
, GL_R3_G3_B2
, GL_R3_G3_B2
, 0,
987 GL_RGB
, GL_UNSIGNED_BYTE_3_3_2
, 0,
988 WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
989 WINED3D_GL_EXT_NONE
, NULL
},
990 {WINED3DFMT_R8_UNORM
, GL_R8
, GL_R8
, 0,
991 GL_RED
, GL_UNSIGNED_BYTE
, 0,
992 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
993 | WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_VTF
,
994 ARB_TEXTURE_RG
, NULL
},
995 {WINED3DFMT_A8_UNORM
, GL_ALPHA8
, GL_ALPHA8
, 0,
996 GL_ALPHA
, GL_UNSIGNED_BYTE
, 0,
997 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
998 WINED3D_GL_EXT_NONE
, NULL
},
999 {WINED3DFMT_B4G4R4X4_UNORM
, GL_RGB4
, GL_RGB4
, 0,
1000 GL_BGRA
, GL_UNSIGNED_SHORT_4_4_4_4_REV
, 0,
1001 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
1002 WINED3D_GL_EXT_NONE
, NULL
},
1003 {WINED3DFMT_R10G10B10A2_UNORM
, GL_RGB10_A2
, GL_RGB10_A2
, 0,
1004 GL_RGBA
, GL_UNSIGNED_INT_2_10_10_10_REV
, 0,
1005 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1006 | WINED3DFMT_FLAG_RENDERTARGET
,
1007 WINED3D_GL_EXT_NONE
, NULL
},
1008 {WINED3DFMT_R8G8B8A8_UNORM
, GL_RGBA8
, GL_SRGB8_ALPHA8_EXT
, 0,
1009 GL_RGBA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0,
1010 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1011 | WINED3DFMT_FLAG_RENDERTARGET
| WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_SRGB_WRITE
1012 | WINED3DFMT_FLAG_VTF
,
1013 WINED3D_GL_EXT_NONE
, NULL
},
1014 {WINED3DFMT_R8G8B8X8_UNORM
, GL_RGB8
, GL_RGB8
, 0,
1015 GL_RGBA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0,
1016 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
1017 WINED3D_GL_EXT_NONE
, NULL
},
1018 {WINED3DFMT_R16G16_UNORM
, GL_RGB16
, GL_RGB16
, GL_RGBA16
,
1019 GL_RGB
, GL_UNSIGNED_SHORT
, 6,
1020 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
1021 WINED3D_GL_EXT_NONE
, convert_r16g16
},
1022 {WINED3DFMT_R16G16_UNORM
, GL_RG16
, GL_RG16
, 0,
1023 GL_RG
, GL_UNSIGNED_SHORT
, 0,
1024 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1025 | WINED3DFMT_FLAG_RENDERTARGET
,
1026 ARB_TEXTURE_RG
, NULL
},
1027 {WINED3DFMT_B10G10R10A2_UNORM
, GL_RGB10_A2
, GL_RGB10_A2
, 0,
1028 GL_BGRA
, GL_UNSIGNED_INT_2_10_10_10_REV
, 0,
1029 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1030 | WINED3DFMT_FLAG_RENDERTARGET
,
1031 WINED3D_GL_EXT_NONE
, NULL
},
1032 {WINED3DFMT_R16G16B16A16_UNORM
, GL_RGBA16
, GL_RGBA16
, 0,
1033 GL_RGBA
, GL_UNSIGNED_SHORT
, 0,
1034 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1035 | WINED3DFMT_FLAG_RENDERTARGET
,
1036 WINED3D_GL_EXT_NONE
, NULL
},
1038 {WINED3DFMT_L8_UNORM
, GL_LUMINANCE8
, GL_SLUMINANCE8_EXT
, 0,
1039 GL_LUMINANCE
, GL_UNSIGNED_BYTE
, 0,
1040 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1041 | WINED3DFMT_FLAG_SRGB_READ
,
1042 WINED3D_GL_EXT_NONE
, NULL
},
1043 {WINED3DFMT_L8A8_UNORM
, GL_LUMINANCE8_ALPHA8
, GL_SLUMINANCE8_ALPHA8_EXT
, 0,
1044 GL_LUMINANCE_ALPHA
, GL_UNSIGNED_BYTE
, 0,
1045 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1046 | WINED3DFMT_FLAG_SRGB_READ
,
1047 WINED3D_GL_EXT_NONE
, NULL
},
1048 {WINED3DFMT_L4A4_UNORM
, GL_LUMINANCE4_ALPHA4
, GL_LUMINANCE4_ALPHA4
, 0,
1049 GL_LUMINANCE_ALPHA
, GL_UNSIGNED_BYTE
, 2,
1050 WINED3DFMT_FLAG_FILTERING
,
1051 WINED3D_GL_EXT_NONE
, convert_l4a4_unorm
},
1052 /* Bump mapping stuff */
1053 {WINED3DFMT_R8G8_SNORM
, GL_RGB8
, GL_RGB8
, 0,
1054 GL_BGR
, GL_UNSIGNED_BYTE
, 3,
1055 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1056 | WINED3DFMT_FLAG_BUMPMAP
,
1057 WINED3D_GL_EXT_NONE
, convert_r8g8_snorm
},
1058 {WINED3DFMT_R8G8_SNORM
, GL_DSDT8_NV
, GL_DSDT8_NV
, 0,
1059 GL_DSDT_NV
, GL_BYTE
, 0,
1060 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1061 | WINED3DFMT_FLAG_BUMPMAP
,
1062 NV_TEXTURE_SHADER
, NULL
},
1063 {WINED3DFMT_R5G5_SNORM_L6_UNORM
, GL_RGB5
, GL_RGB5
, 0,
1064 GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
, 2,
1065 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1066 | WINED3DFMT_FLAG_BUMPMAP
,
1067 WINED3D_GL_EXT_NONE
, convert_r5g5_snorm_l6_unorm
},
1068 {WINED3DFMT_R5G5_SNORM_L6_UNORM
, GL_DSDT8_MAG8_NV
, GL_DSDT8_MAG8_NV
, 0,
1069 GL_DSDT_MAG_NV
, GL_BYTE
, 3,
1070 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1071 | WINED3DFMT_FLAG_BUMPMAP
,
1072 NV_TEXTURE_SHADER
, convert_r5g5_snorm_l6_unorm_nv
},
1073 {WINED3DFMT_R8G8_SNORM_L8X8_UNORM
, GL_RGB8
, GL_RGB8
, 0,
1074 GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 4,
1075 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1076 | WINED3DFMT_FLAG_BUMPMAP
,
1077 WINED3D_GL_EXT_NONE
, convert_r8g8_snorm_l8x8_unorm
},
1078 {WINED3DFMT_R8G8_SNORM_L8X8_UNORM
, GL_DSDT8_MAG8_INTENSITY8_NV
, GL_DSDT8_MAG8_INTENSITY8_NV
, 0,
1079 GL_DSDT_MAG_VIB_NV
, GL_UNSIGNED_INT_8_8_S8_S8_REV_NV
, 4,
1080 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1081 | WINED3DFMT_FLAG_BUMPMAP
,
1082 NV_TEXTURE_SHADER
, convert_r8g8_snorm_l8x8_unorm_nv
},
1083 {WINED3DFMT_R8G8B8A8_SNORM
, GL_RGBA8
, GL_RGBA8
, 0,
1084 GL_BGRA
, GL_UNSIGNED_BYTE
, 4,
1085 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1086 | WINED3DFMT_FLAG_BUMPMAP
,
1087 WINED3D_GL_EXT_NONE
, convert_r8g8b8a8_snorm
},
1088 {WINED3DFMT_R8G8B8A8_SNORM
, GL_SIGNED_RGBA8_NV
, GL_SIGNED_RGBA8_NV
, 0,
1089 GL_RGBA
, GL_BYTE
, 0,
1090 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1091 | WINED3DFMT_FLAG_BUMPMAP
,
1092 NV_TEXTURE_SHADER
, NULL
},
1093 {WINED3DFMT_R16G16_SNORM
, GL_RGB16
, GL_RGB16
, 0,
1094 GL_BGR
, GL_UNSIGNED_SHORT
, 6,
1095 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1096 | WINED3DFMT_FLAG_BUMPMAP
,
1097 WINED3D_GL_EXT_NONE
, convert_r16g16_snorm
},
1098 {WINED3DFMT_R16G16_SNORM
, GL_SIGNED_HILO16_NV
, GL_SIGNED_HILO16_NV
, 0,
1099 GL_HILO_NV
, GL_SHORT
, 0,
1100 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1101 | WINED3DFMT_FLAG_BUMPMAP
,
1102 NV_TEXTURE_SHADER
, NULL
},
1103 /* Depth stencil formats */
1104 {WINED3DFMT_D16_LOCKABLE
, GL_DEPTH_COMPONENT
, GL_DEPTH_COMPONENT
, 0,
1105 GL_DEPTH_COMPONENT
, GL_UNSIGNED_SHORT
, 0,
1106 WINED3DFMT_FLAG_DEPTH
,
1107 WINED3D_GL_EXT_NONE
, NULL
},
1108 {WINED3DFMT_D16_LOCKABLE
, GL_DEPTH_COMPONENT24_ARB
, GL_DEPTH_COMPONENT24_ARB
, 0,
1109 GL_DEPTH_COMPONENT
, GL_UNSIGNED_SHORT
, 0,
1110 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1111 ARB_DEPTH_TEXTURE
, NULL
},
1112 {WINED3DFMT_D32_UNORM
, GL_DEPTH_COMPONENT
, GL_DEPTH_COMPONENT
, 0,
1113 GL_DEPTH_COMPONENT
, GL_UNSIGNED_INT
, 0,
1114 WINED3DFMT_FLAG_DEPTH
,
1115 WINED3D_GL_EXT_NONE
, NULL
},
1116 {WINED3DFMT_D32_UNORM
, GL_DEPTH_COMPONENT32_ARB
, GL_DEPTH_COMPONENT32_ARB
, 0,
1117 GL_DEPTH_COMPONENT
, GL_UNSIGNED_INT
, 0,
1118 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1119 ARB_DEPTH_TEXTURE
, NULL
},
1120 {WINED3DFMT_S1_UINT_D15_UNORM
, GL_DEPTH_COMPONENT24_ARB
, GL_DEPTH_COMPONENT24_ARB
, 0,
1121 GL_DEPTH_COMPONENT
, GL_UNSIGNED_SHORT
, 0,
1122 WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1123 ARB_DEPTH_TEXTURE
, NULL
},
1124 {WINED3DFMT_S1_UINT_D15_UNORM
, GL_DEPTH24_STENCIL8_EXT
, GL_DEPTH24_STENCIL8_EXT
, 0,
1125 GL_DEPTH_STENCIL_EXT
, GL_UNSIGNED_INT_24_8_EXT
, 4,
1126 WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1127 EXT_PACKED_DEPTH_STENCIL
, convert_s1_uint_d15_unorm
},
1128 {WINED3DFMT_S1_UINT_D15_UNORM
, GL_DEPTH24_STENCIL8
, GL_DEPTH24_STENCIL8
, 0,
1129 GL_DEPTH_STENCIL
, GL_UNSIGNED_INT_24_8
, 4,
1130 WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1131 ARB_FRAMEBUFFER_OBJECT
, convert_s1_uint_d15_unorm
},
1132 {WINED3DFMT_D24_UNORM_S8_UINT
, GL_DEPTH_COMPONENT24_ARB
, GL_DEPTH_COMPONENT24_ARB
, 0,
1133 GL_DEPTH_COMPONENT
, GL_UNSIGNED_INT
, 0,
1134 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1135 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1136 ARB_DEPTH_TEXTURE
, NULL
},
1137 {WINED3DFMT_D24_UNORM_S8_UINT
, GL_DEPTH24_STENCIL8_EXT
, GL_DEPTH24_STENCIL8_EXT
, 0,
1138 GL_DEPTH_STENCIL_EXT
, GL_UNSIGNED_INT_24_8_EXT
, 0,
1139 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1140 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1141 EXT_PACKED_DEPTH_STENCIL
, NULL
},
1142 {WINED3DFMT_D24_UNORM_S8_UINT
, GL_DEPTH24_STENCIL8
, GL_DEPTH24_STENCIL8
, 0,
1143 GL_DEPTH_STENCIL
, GL_UNSIGNED_INT_24_8
, 0,
1144 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1145 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1146 ARB_FRAMEBUFFER_OBJECT
, NULL
},
1147 {WINED3DFMT_X8D24_UNORM
, GL_DEPTH_COMPONENT
, GL_DEPTH_COMPONENT
, 0,
1148 GL_DEPTH_COMPONENT
, GL_UNSIGNED_INT
, 0,
1149 WINED3DFMT_FLAG_DEPTH
,
1150 WINED3D_GL_EXT_NONE
, NULL
},
1151 {WINED3DFMT_X8D24_UNORM
, GL_DEPTH_COMPONENT24_ARB
, GL_DEPTH_COMPONENT24_ARB
, 0,
1152 GL_DEPTH_COMPONENT
, GL_UNSIGNED_INT
, 0,
1153 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1154 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1155 ARB_DEPTH_TEXTURE
, NULL
},
1156 {WINED3DFMT_S4X4_UINT_D24_UNORM
, GL_DEPTH_COMPONENT24_ARB
, GL_DEPTH_COMPONENT24_ARB
, 0,
1157 GL_DEPTH_COMPONENT
, GL_UNSIGNED_INT
, 0,
1158 WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1159 ARB_DEPTH_TEXTURE
, NULL
},
1160 {WINED3DFMT_S4X4_UINT_D24_UNORM
, GL_DEPTH24_STENCIL8_EXT
, GL_DEPTH24_STENCIL8_EXT
, 0,
1161 GL_DEPTH_STENCIL_EXT
, GL_UNSIGNED_INT_24_8_EXT
, 4,
1162 WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1163 EXT_PACKED_DEPTH_STENCIL
, convert_s4x4_uint_d24_unorm
},
1164 {WINED3DFMT_S4X4_UINT_D24_UNORM
, GL_DEPTH24_STENCIL8
, GL_DEPTH24_STENCIL8
, 0,
1165 GL_DEPTH_STENCIL
, GL_UNSIGNED_INT_24_8
, 4,
1166 WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1167 ARB_FRAMEBUFFER_OBJECT
, convert_s4x4_uint_d24_unorm
},
1168 {WINED3DFMT_D16_UNORM
, GL_DEPTH_COMPONENT
, GL_DEPTH_COMPONENT
, 0,
1169 GL_DEPTH_COMPONENT
, GL_UNSIGNED_SHORT
, 0,
1170 WINED3DFMT_FLAG_DEPTH
,
1171 WINED3D_GL_EXT_NONE
, NULL
},
1172 {WINED3DFMT_D16_UNORM
, GL_DEPTH_COMPONENT24_ARB
, GL_DEPTH_COMPONENT24_ARB
, 0,
1173 GL_DEPTH_COMPONENT
, GL_UNSIGNED_SHORT
, 0,
1174 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1175 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1176 ARB_DEPTH_TEXTURE
, NULL
},
1177 {WINED3DFMT_L16_UNORM
, GL_LUMINANCE16
, GL_LUMINANCE16
, 0,
1178 GL_LUMINANCE
, GL_UNSIGNED_SHORT
, 0,
1179 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
,
1180 WINED3D_GL_EXT_NONE
, NULL
},
1181 {WINED3DFMT_D32_FLOAT
, GL_DEPTH_COMPONENT32F
, GL_DEPTH_COMPONENT32F
, 0,
1182 GL_DEPTH_COMPONENT
, GL_FLOAT
, 0,
1183 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_SHADOW
,
1184 ARB_DEPTH_BUFFER_FLOAT
, NULL
},
1185 {WINED3DFMT_S8_UINT_D24_FLOAT
, GL_DEPTH32F_STENCIL8
, GL_DEPTH32F_STENCIL8
, 0,
1186 GL_DEPTH_STENCIL
, GL_FLOAT_32_UNSIGNED_INT_24_8_REV
, 8,
1187 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
| WINED3DFMT_FLAG_SHADOW
,
1188 ARB_DEPTH_BUFFER_FLOAT
, convert_s8_uint_d24_float
},
1189 /* Vendor-specific formats */
1190 {WINED3DFMT_ATI1N
, GL_COMPRESSED_RED_RGTC1
, GL_COMPRESSED_RED_RGTC1
, 0,
1191 GL_RED
, GL_UNSIGNED_BYTE
, 0,
1192 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1193 | WINED3DFMT_FLAG_COMPRESSED
,
1194 ARB_TEXTURE_COMPRESSION_RGTC
, NULL
},
1195 {WINED3DFMT_ATI2N
, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI
, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI
, 0,
1196 GL_LUMINANCE_ALPHA
, GL_UNSIGNED_BYTE
, 0,
1197 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1198 | WINED3DFMT_FLAG_COMPRESSED
,
1199 ATI_TEXTURE_COMPRESSION_3DC
, NULL
},
1200 {WINED3DFMT_ATI2N
, GL_COMPRESSED_RG_RGTC2
, GL_COMPRESSED_RG_RGTC2
, 0,
1201 GL_LUMINANCE_ALPHA
, GL_UNSIGNED_BYTE
, 0,
1202 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1203 | WINED3DFMT_FLAG_COMPRESSED
,
1204 ARB_TEXTURE_COMPRESSION_RGTC
, NULL
},
1205 {WINED3DFMT_INTZ
, GL_DEPTH24_STENCIL8_EXT
, GL_DEPTH24_STENCIL8_EXT
, 0,
1206 GL_DEPTH_STENCIL_EXT
, GL_UNSIGNED_INT_24_8_EXT
, 0,
1207 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1208 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
,
1209 EXT_PACKED_DEPTH_STENCIL
, NULL
},
1210 {WINED3DFMT_INTZ
, GL_DEPTH24_STENCIL8
, GL_DEPTH24_STENCIL8
, 0,
1211 GL_DEPTH_STENCIL
, GL_UNSIGNED_INT_24_8
, 0,
1212 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
| WINED3DFMT_FLAG_FILTERING
1213 | WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
,
1214 ARB_FRAMEBUFFER_OBJECT
, NULL
},
1215 {WINED3DFMT_NULL
, 0, 0, 0,
1216 GL_RGBA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0,
1217 WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
,
1218 ARB_FRAMEBUFFER_OBJECT
, NULL
},
1221 static inline int getFmtIdx(enum wined3d_format_id format_id
)
1223 /* First check if the format is at the position of its value.
1224 * This will catch the argb formats before the loop is entered. */
1225 if (format_id
< (sizeof(formats
) / sizeof(*formats
))
1226 && formats
[format_id
].id
== format_id
)
1234 for (i
= 0; i
< (sizeof(formats
) / sizeof(*formats
)); ++i
)
1236 if (formats
[i
].id
== format_id
) return i
;
1242 static BOOL
init_format_base_info(struct wined3d_gl_info
*gl_info
)
1244 UINT format_count
= sizeof(formats
) / sizeof(*formats
);
1247 gl_info
->formats
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, format_count
* sizeof(*gl_info
->formats
));
1248 if (!gl_info
->formats
)
1250 ERR("Failed to allocate memory.\n");
1254 for (i
= 0; i
< format_count
; ++i
)
1256 struct wined3d_format
*format
= &gl_info
->formats
[i
];
1257 format
->id
= formats
[i
].id
;
1258 format
->red_size
= formats
[i
].red_size
;
1259 format
->green_size
= formats
[i
].green_size
;
1260 format
->blue_size
= formats
[i
].blue_size
;
1261 format
->alpha_size
= formats
[i
].alpha_size
;
1262 format
->red_offset
= formats
[i
].red_offset
;
1263 format
->green_offset
= formats
[i
].green_offset
;
1264 format
->blue_offset
= formats
[i
].blue_offset
;
1265 format
->alpha_offset
= formats
[i
].alpha_offset
;
1266 format
->byte_count
= formats
[i
].bpp
;
1267 format
->depth_size
= formats
[i
].depth_size
;
1268 format
->stencil_size
= formats
[i
].stencil_size
;
1269 format
->block_width
= 1;
1270 format
->block_height
= 1;
1271 format
->block_byte_count
= formats
[i
].bpp
;
1274 for (i
= 0; i
< (sizeof(format_base_flags
) / sizeof(*format_base_flags
)); ++i
)
1276 int fmt_idx
= getFmtIdx(format_base_flags
[i
].id
);
1280 ERR("Format %s (%#x) not found.\n",
1281 debug_d3dformat(format_base_flags
[i
].id
), format_base_flags
[i
].id
);
1282 HeapFree(GetProcessHeap(), 0, gl_info
->formats
);
1286 gl_info
->formats
[fmt_idx
].flags
|= format_base_flags
[i
].flags
;
1292 static BOOL
init_format_block_info(struct wined3d_gl_info
*gl_info
)
1296 for (i
= 0; i
< (sizeof(format_block_info
) / sizeof(*format_block_info
)); ++i
)
1298 struct wined3d_format
*format
;
1299 int fmt_idx
= getFmtIdx(format_block_info
[i
].id
);
1303 ERR("Format %s (%#x) not found.\n",
1304 debug_d3dformat(format_block_info
[i
].id
), format_block_info
[i
].id
);
1308 format
= &gl_info
->formats
[fmt_idx
];
1309 format
->block_width
= format_block_info
[i
].block_width
;
1310 format
->block_height
= format_block_info
[i
].block_height
;
1311 format
->block_byte_count
= format_block_info
[i
].block_byte_count
;
1312 format
->flags
|= WINED3DFMT_FLAG_BLOCKS
;
1313 if (!format_block_info
[i
].verify
)
1314 format
->flags
|= WINED3DFMT_FLAG_BLOCKS_NO_VERIFY
;
1320 /* Context activation is done by the caller. */
1321 static void check_fbo_compat(const struct wined3d_gl_info
*gl_info
, struct wined3d_format
*format
)
1323 /* Check if the default internal format is supported as a frame buffer
1324 * target, otherwise fall back to the render target internal.
1326 * Try to stick to the standard format if possible, this limits precision differences. */
1330 while (gl_info
->gl_ops
.gl
.p_glGetError());
1331 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
1333 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
1334 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
1336 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, format
->glInternal
, 16, 16, 0,
1337 format
->glFormat
, format
->glType
, NULL
);
1338 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
1339 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1341 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
1343 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
1344 checkGLcall("Framebuffer format check");
1346 if (status
== GL_FRAMEBUFFER_COMPLETE
)
1348 TRACE("Format %s is supported as FBO color attachment.\n", debug_d3dformat(format
->id
));
1349 format
->flags
|= WINED3DFMT_FLAG_FBO_ATTACHABLE
;
1350 format
->rtInternal
= format
->glInternal
;
1354 if (!format
->rtInternal
)
1356 if (format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
1358 FIXME("Format %s with rendertarget flag is not supported as FBO color attachment,"
1359 " and no fallback specified.\n", debug_d3dformat(format
->id
));
1360 format
->flags
&= ~WINED3DFMT_FLAG_RENDERTARGET
;
1364 TRACE("Format %s is not supported as FBO color attachment.\n", debug_d3dformat(format
->id
));
1366 format
->rtInternal
= format
->glInternal
;
1370 TRACE("Format %s is not supported as FBO color attachment, trying rtInternal format as fallback.\n",
1371 debug_d3dformat(format
->id
));
1373 while (gl_info
->gl_ops
.gl
.p_glGetError());
1375 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
1377 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, format
->rtInternal
, 16, 16, 0,
1378 format
->glFormat
, format
->glType
, NULL
);
1379 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
1380 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1382 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
1384 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
1385 checkGLcall("Framebuffer format check");
1387 if (status
== GL_FRAMEBUFFER_COMPLETE
)
1389 TRACE("Format %s rtInternal format is supported as FBO color attachment.\n",
1390 debug_d3dformat(format
->id
));
1394 FIXME("Format %s rtInternal format is not supported as FBO color attachment.\n",
1395 debug_d3dformat(format
->id
));
1396 format
->flags
&= ~WINED3DFMT_FLAG_RENDERTARGET
;
1401 if (status
== GL_FRAMEBUFFER_COMPLETE
&& ((format
->flags
& WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
)
1402 || !(gl_info
->quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
))
1403 && format
->id
!= WINED3DFMT_NULL
&& format
->id
!= WINED3DFMT_P8_UINT
1404 && format
->glFormat
!= GL_LUMINANCE
&& format
->glFormat
!= GL_LUMINANCE_ALPHA
1405 && (format
->red_size
|| format
->alpha_size
))
1407 DWORD readback
[16 * 16], color
, r_range
, a_range
;
1412 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
]
1413 || gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
])
1415 gl_info
->fbo_ops
.glGenRenderbuffers(1, &rb
);
1416 gl_info
->fbo_ops
.glBindRenderbuffer(GL_RENDERBUFFER
, rb
);
1417 gl_info
->fbo_ops
.glRenderbufferStorage(GL_RENDERBUFFER
, GL_DEPTH24_STENCIL8
, 16, 16);
1418 gl_info
->fbo_ops
.glFramebufferRenderbuffer(GL_FRAMEBUFFER
, GL_DEPTH_ATTACHMENT
, GL_RENDERBUFFER
, rb
);
1419 gl_info
->fbo_ops
.glFramebufferRenderbuffer(GL_FRAMEBUFFER
, GL_STENCIL_ATTACHMENT
, GL_RENDERBUFFER
, rb
);
1420 checkGLcall("RB attachment");
1423 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
1424 gl_info
->gl_ops
.gl
.p_glClearColor(0.0f
, 0.0f
, 0.0f
, 1.0f
);
1425 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
1426 if (gl_info
->gl_ops
.gl
.p_glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION
)
1428 while (gl_info
->gl_ops
.gl
.p_glGetError());
1429 TRACE("Format doesn't support post-pixelshader blending.\n");
1430 format
->flags
&= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
;
1434 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
1435 gl_info
->gl_ops
.gl
.p_glViewport(0, 0, 16, 16);
1436 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHTING
);
1437 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
1438 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
1439 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
1440 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
1442 gl_info
->gl_ops
.gl
.p_glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1444 /* Draw a full-black quad */
1445 gl_info
->gl_ops
.gl
.p_glBegin(GL_TRIANGLE_STRIP
);
1446 gl_info
->gl_ops
.gl
.p_glColor4f(0.0f
, 0.0f
, 0.0f
, 1.0f
);
1447 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, -1.0f
, 0.0f
);
1448 gl_info
->gl_ops
.gl
.p_glVertex3f(1.0f
, -1.0f
, 0.0f
);
1449 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, 1.0f
, 0.0f
);
1450 gl_info
->gl_ops
.gl
.p_glVertex3f(1.0f
, 1.0f
, 0.0f
);
1451 gl_info
->gl_ops
.gl
.p_glEnd();
1453 gl_info
->gl_ops
.gl
.p_glEnable(GL_BLEND
);
1454 /* Draw a half-transparent red quad */
1455 gl_info
->gl_ops
.gl
.p_glBegin(GL_TRIANGLE_STRIP
);
1456 gl_info
->gl_ops
.gl
.p_glColor4f(1.0f
, 0.0f
, 0.0f
, 0.5f
);
1457 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, -1.0f
, 0.0f
);
1458 gl_info
->gl_ops
.gl
.p_glVertex3f(1.0f
, -1.0f
, 0.0f
);
1459 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, 1.0f
, 0.0f
);
1460 gl_info
->gl_ops
.gl
.p_glVertex3f(1.0f
, 1.0f
, 0.0f
);
1461 gl_info
->gl_ops
.gl
.p_glEnd();
1463 gl_info
->gl_ops
.gl
.p_glDisable(GL_BLEND
);
1465 /* Rebinding texture to workaround a fglrx bug. */
1466 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
1467 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, readback
);
1468 checkGLcall("Post-pixelshader blending check");
1470 color
= readback
[7 * 16 + 7];
1472 r
= (color
& 0x00ff0000) >> 16;
1474 r_range
= format
->red_size
< 8 ? 1 << (8 - format
->red_size
) : 1;
1475 a_range
= format
->alpha_size
< 8 ? 1 << (8 - format
->alpha_size
) : 1;
1476 if (format
->red_size
&& (r
< 0x7f - r_range
|| r
> 0x7f + r_range
))
1478 else if (format
->alpha_size
> 1 && (a
< 0xbf - a_range
|| a
> 0xbf + a_range
))
1482 TRACE("Format doesn't support post-pixelshader blending.\n");
1483 TRACE("Color output: %#x\n", color
);
1484 format
->flags
&= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
;
1488 TRACE("Format supports post-pixelshader blending.\n");
1489 TRACE("Color output: %#x\n", color
);
1490 format
->flags
|= WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
;
1494 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
]
1495 || gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
])
1497 gl_info
->fbo_ops
.glFramebufferRenderbuffer(GL_FRAMEBUFFER
, GL_DEPTH_ATTACHMENT
, GL_RENDERBUFFER
, 0);
1498 gl_info
->fbo_ops
.glFramebufferRenderbuffer(GL_FRAMEBUFFER
, GL_STENCIL_ATTACHMENT
, GL_RENDERBUFFER
, 0);
1499 gl_info
->fbo_ops
.glDeleteRenderbuffers(1, &rb
);
1500 checkGLcall("RB cleanup");
1504 if (format
->glInternal
!= format
->glGammaInternal
)
1506 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, format
->glGammaInternal
, 16, 16, 0,
1507 format
->glFormat
, format
->glType
, NULL
);
1508 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
1510 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
1511 checkGLcall("Framebuffer format check");
1513 if (status
== GL_FRAMEBUFFER_COMPLETE
)
1515 TRACE("Format %s's sRGB format is FBO attachable.\n", debug_d3dformat(format
->id
));
1516 format
->flags
|= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB
;
1520 WARN("Format %s's sRGB format is not FBO attachable.\n", debug_d3dformat(format
->id
));
1523 else if (status
== GL_FRAMEBUFFER_COMPLETE
)
1524 format
->flags
|= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB
;
1526 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
1529 static void query_format_flag(struct wined3d_gl_info
*gl_info
, struct wined3d_format
*format
,
1530 GLint internal
, GLenum pname
, DWORD flag
, const char *string
)
1534 gl_info
->gl_ops
.ext
.p_glGetInternalformativ(GL_TEXTURE_2D
, internal
, pname
, 1, &value
);
1535 if (value
== GL_FULL_SUPPORT
)
1537 TRACE("Format %s supports %s.\n", debug_d3dformat(format
->id
), string
);
1538 format
->flags
|= flag
;
1542 TRACE("Format %s doesn't support %s.\n", debug_d3dformat(format
->id
), string
);
1543 format
->flags
&= ~flag
;
1547 /* Context activation is done by the caller. */
1548 static void init_format_fbo_compat_info(struct wined3d_gl_info
*gl_info
)
1553 if (gl_info
->supported
[ARB_INTERNALFORMAT_QUERY2
])
1555 for (i
= 0; i
< sizeof(formats
) / sizeof(*formats
); ++i
)
1558 struct wined3d_format
*format
= &gl_info
->formats
[i
];
1560 if (!format
->glInternal
)
1562 if (format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
))
1565 gl_info
->gl_ops
.ext
.p_glGetInternalformativ(GL_TEXTURE_2D
, format
->glInternal
,
1566 GL_FRAMEBUFFER_RENDERABLE
, 1, &value
);
1567 if (value
== GL_FULL_SUPPORT
)
1569 TRACE("Format %s is supported as FBO color attachment.\n", debug_d3dformat(format
->id
));
1570 format
->flags
|= WINED3DFMT_FLAG_FBO_ATTACHABLE
;
1571 format
->rtInternal
= format
->glInternal
;
1573 query_format_flag(gl_info
, format
, format
->glInternal
, GL_FRAMEBUFFER_BLEND
,
1574 WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING
, "post-pixelshader blending");
1578 if (!format
->rtInternal
)
1580 if (format
->flags
& WINED3DFMT_FLAG_RENDERTARGET
)
1582 WARN("Format %s with rendertarget flag is not supported as FBO color attachment"
1583 " and no fallback specified.\n", debug_d3dformat(format
->id
));
1584 format
->flags
&= ~WINED3DFMT_FLAG_RENDERTARGET
;
1587 TRACE("Format %s is not supported as FBO color attachment.\n", debug_d3dformat(format
->id
));
1588 format
->rtInternal
= format
->glInternal
;
1592 gl_info
->gl_ops
.ext
.p_glGetInternalformativ(GL_TEXTURE_2D
, format
->rtInternal
,
1593 GL_FRAMEBUFFER_RENDERABLE
, 1, &value
);
1594 if (value
== GL_FULL_SUPPORT
)
1596 TRACE("Format %s rtInternal format is supported as FBO color attachment.\n",
1597 debug_d3dformat(format
->id
));
1601 WARN("Format %s rtInternal format is not supported as FBO color attachment.\n",
1602 debug_d3dformat(format
->id
));
1603 format
->flags
&= ~WINED3DFMT_FLAG_RENDERTARGET
;
1608 if (format
->glInternal
!= format
->glGammaInternal
)
1610 gl_info
->gl_ops
.ext
.p_glGetInternalformativ(GL_TEXTURE_2D
, format
->glGammaInternal
,
1611 GL_FRAMEBUFFER_RENDERABLE
, 1, &value
);
1612 if (value
== GL_FULL_SUPPORT
)
1614 TRACE("Format %s's sRGB format is FBO attachable.\n", debug_d3dformat(format
->id
));
1615 format
->flags
|= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB
;
1619 WARN("Format %s's sRGB format is not FBO attachable.\n", debug_d3dformat(format
->id
));
1622 else if (format
->flags
& WINED3DFMT_FLAG_FBO_ATTACHABLE
)
1623 format
->flags
|= WINED3DFMT_FLAG_FBO_ATTACHABLE_SRGB
;
1628 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
1630 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
1631 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
1632 gl_info
->gl_ops
.gl
.p_glDrawBuffer(GL_COLOR_ATTACHMENT0
);
1633 gl_info
->gl_ops
.gl
.p_glReadBuffer(GL_COLOR_ATTACHMENT0
);
1636 for (i
= 0; i
< sizeof(formats
) / sizeof(*formats
); ++i
)
1638 struct wined3d_format
*format
= &gl_info
->formats
[i
];
1640 if (!format
->glInternal
) continue;
1642 if (format
->flags
& (WINED3DFMT_FLAG_DEPTH
| WINED3DFMT_FLAG_STENCIL
))
1644 TRACE("Skipping format %s because it's a depth/stencil format.\n",
1645 debug_d3dformat(format
->id
));
1649 if (format
->flags
& WINED3DFMT_FLAG_COMPRESSED
)
1651 TRACE("Skipping format %s because it's a compressed format.\n",
1652 debug_d3dformat(format
->id
));
1656 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
1658 TRACE("Checking if format %s is supported as FBO color attachment...\n", debug_d3dformat(format
->id
));
1659 check_fbo_compat(gl_info
, format
);
1663 format
->rtInternal
= format
->glInternal
;
1667 if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
1668 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
1671 static BOOL
init_format_texture_info(struct wined3d_adapter
*adapter
, struct wined3d_gl_info
*gl_info
)
1673 struct fragment_caps fragment_caps
;
1674 struct shader_caps shader_caps
;
1678 adapter
->fragment_pipe
->get_caps(gl_info
, &fragment_caps
);
1679 adapter
->shader_backend
->shader_get_caps(gl_info
, &shader_caps
);
1680 srgb_write
= (fragment_caps
.wined3d_caps
& WINED3D_FRAGMENT_CAP_SRGB_WRITE
)
1681 && (shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_SRGB_WRITE
);
1683 for (i
= 0; i
< sizeof(format_texture_info
) / sizeof(*format_texture_info
); ++i
)
1685 int fmt_idx
= getFmtIdx(format_texture_info
[i
].id
);
1686 struct wined3d_format
*format
;
1690 ERR("Format %s (%#x) not found.\n",
1691 debug_d3dformat(format_texture_info
[i
].id
), format_texture_info
[i
].id
);
1695 if (!gl_info
->supported
[format_texture_info
[i
].extension
]) continue;
1697 format
= &gl_info
->formats
[fmt_idx
];
1699 /* ARB_texture_rg defines floating point formats, but only if
1700 * ARB_texture_float is also supported. */
1701 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
]
1702 && (format
->flags
& WINED3DFMT_FLAG_FLOAT
))
1705 format
->glInternal
= format_texture_info
[i
].gl_internal
;
1706 format
->glGammaInternal
= format_texture_info
[i
].gl_srgb_internal
;
1707 format
->rtInternal
= format_texture_info
[i
].gl_rt_internal
;
1708 format
->glFormat
= format_texture_info
[i
].gl_format
;
1709 format
->glType
= format_texture_info
[i
].gl_type
;
1710 format
->color_fixup
= COLOR_FIXUP_IDENTITY
;
1711 format
->flags
|= format_texture_info
[i
].flags
;
1712 format
->height_scale
.numerator
= 1;
1713 format
->height_scale
.denominator
= 1;
1715 if (gl_info
->supported
[ARB_INTERNALFORMAT_QUERY2
])
1717 query_format_flag(gl_info
, format
, format
->glInternal
, GL_VERTEX_TEXTURE
,
1718 WINED3DFMT_FLAG_VTF
, "vertex texture usage");
1719 query_format_flag(gl_info
, format
, format
->glInternal
, GL_FILTER
,
1720 WINED3DFMT_FLAG_FILTERING
, "filtering");
1722 if (format
->glGammaInternal
!= format
->glInternal
)
1724 query_format_flag(gl_info
, format
, format
->glGammaInternal
, GL_SRGB_READ
,
1725 WINED3DFMT_FLAG_SRGB_READ
, "sRGB read");
1728 query_format_flag(gl_info
, format
, format
->glGammaInternal
, GL_SRGB_WRITE
,
1729 WINED3DFMT_FLAG_SRGB_WRITE
, "sRGB write");
1731 format
->flags
&= ~WINED3DFMT_FLAG_SRGB_WRITE
;
1733 if (!(format
->flags
& (WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_SRGB_WRITE
)))
1734 format
->glGammaInternal
= format
->glInternal
;
1735 else if (gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
])
1736 format
->glInternal
= format
->glGammaInternal
;
1741 if (!gl_info
->limits
.vertex_samplers
)
1742 format
->flags
&= ~WINED3DFMT_FLAG_VTF
;
1744 if (!(gl_info
->quirks
& WINED3D_QUIRK_LIMITED_TEX_FILTERING
))
1745 format
->flags
|= WINED3DFMT_FLAG_FILTERING
;
1746 else if (format
->id
!= WINED3DFMT_R32G32B32A32_FLOAT
&& format
->id
!= WINED3DFMT_R32_FLOAT
)
1747 format
->flags
&= ~WINED3DFMT_FLAG_VTF
;
1749 if (format
->glGammaInternal
!= format
->glInternal
)
1751 /* Filter sRGB capabilities if EXT_texture_sRGB is not supported. */
1752 if (!gl_info
->supported
[EXT_TEXTURE_SRGB
])
1754 format
->glGammaInternal
= format
->glInternal
;
1755 format
->flags
&= ~(WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_SRGB_WRITE
);
1757 else if (gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
])
1759 format
->glInternal
= format
->glGammaInternal
;
1763 if ((format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
) && !srgb_write
)
1764 format
->flags
&= ~WINED3DFMT_FLAG_SRGB_WRITE
;
1767 /* Texture conversion stuff */
1768 format
->convert
= format_texture_info
[i
].convert
;
1769 format
->conv_byte_count
= format_texture_info
[i
].conv_byte_count
;
1775 static BOOL
color_match(DWORD c1
, DWORD c2
, BYTE max_diff
)
1777 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
1779 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
1781 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
1783 if (abs((c1
& 0xff) - (c2
& 0xff)) > max_diff
) return FALSE
;
1787 /* A context is provided by the caller */
1788 static BOOL
check_filter(const struct wined3d_gl_info
*gl_info
, GLenum internal
)
1790 static const DWORD data
[] = {0x00000000, 0xffffffff};
1791 GLuint tex
, fbo
, buffer
;
1792 DWORD readback
[16 * 1];
1795 /* Render a filtered texture and see what happens. This is intended to detect the lack of
1796 * float16 filtering on ATI X1000 class cards. The drivers disable filtering instead of
1797 * falling back to software. If this changes in the future this code will get fooled and
1798 * apps might hit the software path due to incorrectly advertised caps.
1800 * Its unlikely that this changes however. GL Games like Mass Effect depend on the filter
1801 * disable fallback, if Apple or ATI ever change the driver behavior they will break more
1802 * than Wine. The Linux binary <= r500 driver is not maintained any more anyway
1805 while (gl_info
->gl_ops
.gl
.p_glGetError());
1807 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &buffer
);
1808 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, buffer
);
1809 memset(readback
, 0x7e, sizeof(readback
));
1810 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 16, 1, 0,
1811 GL_RGBA
, GL_UNSIGNED_INT_8_8_8_8
, readback
);
1812 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
1813 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1814 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
1815 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
1816 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_R
, GL_CLAMP_TO_EDGE
);
1818 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
1819 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
1820 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, internal
, 2, 1, 0,
1821 GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
1822 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
1823 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
1824 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
1825 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
1826 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_WRAP_R
, GL_CLAMP_TO_EDGE
);
1827 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_2D
);
1829 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
1830 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
1831 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, buffer
, 0);
1832 gl_info
->gl_ops
.gl
.p_glDrawBuffer(GL_COLOR_ATTACHMENT0
);
1834 gl_info
->gl_ops
.gl
.p_glViewport(0, 0, 16, 1);
1835 gl_info
->gl_ops
.gl
.p_glDisable(GL_LIGHTING
);
1836 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_MODELVIEW
);
1837 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
1838 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_PROJECTION
);
1839 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
1841 gl_info
->gl_ops
.gl
.p_glClearColor(0, 1, 0, 0);
1842 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
1844 gl_info
->gl_ops
.gl
.p_glBegin(GL_TRIANGLE_STRIP
);
1845 gl_info
->gl_ops
.gl
.p_glTexCoord2f(0.0, 0.0);
1846 gl_info
->gl_ops
.gl
.p_glVertex2f(-1.0f
, -1.0f
);
1847 gl_info
->gl_ops
.gl
.p_glTexCoord2f(1.0, 0.0);
1848 gl_info
->gl_ops
.gl
.p_glVertex2f(1.0f
, -1.0f
);
1849 gl_info
->gl_ops
.gl
.p_glTexCoord2f(0.0, 1.0);
1850 gl_info
->gl_ops
.gl
.p_glVertex2f(-1.0f
, 1.0f
);
1851 gl_info
->gl_ops
.gl
.p_glTexCoord2f(1.0, 1.0);
1852 gl_info
->gl_ops
.gl
.p_glVertex2f(1.0f
, 1.0f
);
1853 gl_info
->gl_ops
.gl
.p_glEnd();
1855 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, buffer
);
1856 memset(readback
, 0x7f, sizeof(readback
));
1857 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, readback
);
1858 if (color_match(readback
[6], 0xffffffff, 5) || color_match(readback
[6], 0x00000000, 5)
1859 || color_match(readback
[9], 0xffffffff, 5) || color_match(readback
[9], 0x00000000, 5))
1861 TRACE("Read back colors 0x%08x and 0x%08x close to unfiltered color, assuming no filtering\n",
1862 readback
[6], readback
[9]);
1867 TRACE("Read back colors are 0x%08x and 0x%08x, assuming texture is filtered\n",
1868 readback
[6], readback
[9]);
1872 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
1873 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
1874 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
1875 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &buffer
);
1877 if (gl_info
->gl_ops
.gl
.p_glGetError())
1879 FIXME("Error during filtering test for format %x, returning no filtering\n", internal
);
1886 static void init_format_filter_info(struct wined3d_gl_info
*gl_info
, enum wined3d_pci_vendor vendor
)
1888 struct wined3d_format
*format
;
1889 unsigned int fmt_idx
, i
;
1890 static const enum wined3d_format_id fmts16
[] =
1892 WINED3DFMT_R16_FLOAT
,
1893 WINED3DFMT_R16G16_FLOAT
,
1894 WINED3DFMT_R16G16B16A16_FLOAT
,
1898 if (gl_info
->supported
[ARB_INTERNALFORMAT_QUERY2
])
1899 /* This was already handled by init_format_texture_info(). */
1902 if(wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
1904 WARN("No FBO support, or no FBO ORM, guessing filter info from GL caps\n");
1905 if (vendor
== HW_VENDOR_NVIDIA
&& gl_info
->supported
[ARB_TEXTURE_FLOAT
])
1907 TRACE("Nvidia card with texture_float support: Assuming float16 blending\n");
1910 else if (gl_info
->limits
.glsl_varyings
> 44)
1912 TRACE("More than 44 GLSL varyings - assuming d3d10 card with float16 blending\n");
1917 TRACE("Assuming no float16 blending\n");
1923 for(i
= 0; i
< (sizeof(fmts16
) / sizeof(*fmts16
)); i
++)
1925 fmt_idx
= getFmtIdx(fmts16
[i
]);
1926 gl_info
->formats
[fmt_idx
].flags
|= WINED3DFMT_FLAG_FILTERING
;
1932 for(i
= 0; i
< (sizeof(fmts16
) / sizeof(*fmts16
)); i
++)
1934 fmt_idx
= getFmtIdx(fmts16
[i
]);
1935 format
= &gl_info
->formats
[fmt_idx
];
1936 if (!format
->glInternal
) continue; /* Not supported by GL */
1938 filtered
= check_filter(gl_info
, gl_info
->formats
[fmt_idx
].glInternal
);
1941 TRACE("Format %s supports filtering\n", debug_d3dformat(fmts16
[i
]));
1942 format
->flags
|= WINED3DFMT_FLAG_FILTERING
;
1946 TRACE("Format %s does not support filtering\n", debug_d3dformat(fmts16
[i
]));
1951 static void apply_format_fixups(struct wined3d_adapter
*adapter
, struct wined3d_gl_info
*gl_info
)
1956 idx
= getFmtIdx(WINED3DFMT_R16_FLOAT
);
1957 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1958 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_W
);
1960 idx
= getFmtIdx(WINED3DFMT_R32_FLOAT
);
1961 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1962 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_W
);
1964 idx
= getFmtIdx(WINED3DFMT_R16G16_UNORM
);
1965 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1966 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_W
);
1968 idx
= getFmtIdx(WINED3DFMT_R16G16_FLOAT
);
1969 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1970 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_W
);
1972 idx
= getFmtIdx(WINED3DFMT_R32G32_FLOAT
);
1973 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1974 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_W
);
1976 /* V8U8 is supported natively by GL_ATI_envmap_bumpmap and GL_NV_texture_shader.
1977 * V16U16 is only supported by GL_NV_texture_shader. The formats need fixup if
1978 * their extensions are not available. GL_ATI_envmap_bumpmap is not used because
1979 * the only driver that implements it(fglrx) has a buggy implementation.
1981 * V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL
1982 * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
1983 * conversion for this format.
1985 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
1987 idx
= getFmtIdx(WINED3DFMT_R8G8_SNORM
);
1988 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1989 1, CHANNEL_SOURCE_X
, 1, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
);
1990 idx
= getFmtIdx(WINED3DFMT_R16G16_SNORM
);
1991 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1992 1, CHANNEL_SOURCE_X
, 1, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
);
1996 idx
= getFmtIdx(WINED3DFMT_R8G8_SNORM
);
1997 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
1998 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
);
2000 idx
= getFmtIdx(WINED3DFMT_R16G16_SNORM
);
2001 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2002 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
);
2005 if (!gl_info
->supported
[NV_TEXTURE_SHADER
])
2007 /* If GL_NV_texture_shader is not supported, those formats are converted, incompatibly
2010 idx
= getFmtIdx(WINED3DFMT_R5G5_SNORM_L6_UNORM
);
2011 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2012 1, CHANNEL_SOURCE_X
, 1, CHANNEL_SOURCE_Z
, 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_ONE
);
2013 idx
= getFmtIdx(WINED3DFMT_R8G8_SNORM_L8X8_UNORM
);
2014 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2015 1, CHANNEL_SOURCE_X
, 1, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_Z
, 0, CHANNEL_SOURCE_W
);
2016 idx
= getFmtIdx(WINED3DFMT_R8G8B8A8_SNORM
);
2017 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2018 1, CHANNEL_SOURCE_X
, 1, CHANNEL_SOURCE_Y
, 1, CHANNEL_SOURCE_Z
, 1, CHANNEL_SOURCE_W
);
2022 /* If GL_NV_texture_shader is supported, WINED3DFMT_L6V5U5 and WINED3DFMT_X8L8V8U8
2023 * are converted at surface loading time, but they do not need any modification in
2024 * the shader, thus they are compatible with all WINED3DFMT_UNKNOWN group formats.
2025 * WINED3DFMT_Q8W8V8U8 doesn't even need load-time conversion
2029 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
2031 idx
= getFmtIdx(WINED3DFMT_ATI1N
);
2032 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2033 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_X
);
2035 idx
= getFmtIdx(WINED3DFMT_ATI2N
);
2036 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2037 0, CHANNEL_SOURCE_Y
, 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
);
2039 else if (gl_info
->supported
[ATI_TEXTURE_COMPRESSION_3DC
])
2041 idx
= getFmtIdx(WINED3DFMT_ATI2N
);
2042 gl_info
->formats
[idx
].color_fixup
= create_color_fixup_desc(
2043 0, CHANNEL_SOURCE_X
, 0, CHANNEL_SOURCE_W
, 0, CHANNEL_SOURCE_ONE
, 0, CHANNEL_SOURCE_ONE
);
2046 if (!gl_info
->supported
[APPLE_YCBCR_422
])
2048 idx
= getFmtIdx(WINED3DFMT_YUY2
);
2049 gl_info
->formats
[idx
].color_fixup
= create_complex_fixup_desc(COMPLEX_FIXUP_YUY2
);
2051 idx
= getFmtIdx(WINED3DFMT_UYVY
);
2052 gl_info
->formats
[idx
].color_fixup
= create_complex_fixup_desc(COMPLEX_FIXUP_UYVY
);
2055 idx
= getFmtIdx(WINED3DFMT_YV12
);
2056 gl_info
->formats
[idx
].flags
|= WINED3DFMT_FLAG_HEIGHT_SCALE
;
2057 gl_info
->formats
[idx
].height_scale
.numerator
= 3;
2058 gl_info
->formats
[idx
].height_scale
.denominator
= 2;
2059 gl_info
->formats
[idx
].color_fixup
= create_complex_fixup_desc(COMPLEX_FIXUP_YV12
);
2061 idx
= getFmtIdx(WINED3DFMT_NV12
);
2062 gl_info
->formats
[idx
].flags
|= WINED3DFMT_FLAG_HEIGHT_SCALE
;
2063 gl_info
->formats
[idx
].height_scale
.numerator
= 3;
2064 gl_info
->formats
[idx
].height_scale
.denominator
= 2;
2065 gl_info
->formats
[idx
].color_fixup
= create_complex_fixup_desc(COMPLEX_FIXUP_NV12
);
2067 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2069 idx
= getFmtIdx(WINED3DFMT_P8_UINT
);
2070 gl_info
->formats
[idx
].color_fixup
= create_complex_fixup_desc(COMPLEX_FIXUP_P8
);
2073 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
2075 idx
= getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM
);
2076 gl_info
->formats
[idx
].gl_vtx_format
= GL_BGRA
;
2079 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
2081 /* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though.
2082 * It is the job of the vertex buffer code to make sure that the vbos have the right format */
2083 idx
= getFmtIdx(WINED3DFMT_R16G16_FLOAT
);
2084 gl_info
->formats
[idx
].gl_vtx_type
= GL_HALF_FLOAT
; /* == GL_HALF_FLOAT_NV */
2086 idx
= getFmtIdx(WINED3DFMT_R16G16B16A16_FLOAT
);
2087 gl_info
->formats
[idx
].gl_vtx_type
= GL_HALF_FLOAT
;
2090 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
2092 idx
= getFmtIdx(WINED3DFMT_R16_FLOAT
);
2093 gl_info
->formats
[idx
].flags
&= ~WINED3DFMT_FLAG_TEXTURE
;
2095 idx
= getFmtIdx(WINED3DFMT_R16G16_FLOAT
);
2096 gl_info
->formats
[idx
].flags
&= ~WINED3DFMT_FLAG_TEXTURE
;
2098 idx
= getFmtIdx(WINED3DFMT_R16G16B16A16_FLOAT
);
2099 gl_info
->formats
[idx
].flags
&= ~WINED3DFMT_FLAG_TEXTURE
;
2102 if (gl_info
->quirks
& WINED3D_QUIRK_BROKEN_RGBA16
)
2104 idx
= getFmtIdx(WINED3DFMT_R16G16B16A16_UNORM
);
2105 gl_info
->formats
[idx
].flags
&= ~WINED3DFMT_FLAG_TEXTURE
;
2108 /* ATI instancing hack: Although ATI cards do not support Shader Model
2109 * 3.0, they support instancing. To query if the card supports instancing
2110 * CheckDeviceFormat() with the special format MAKEFOURCC('I','N','S','T')
2111 * is used. Should an application check for this, provide a proper return
2112 * value. We can do instancing with all shader versions, but we need
2115 * Additionally applications have to set the D3DRS_POINTSIZE render state
2116 * to MAKEFOURCC('I','N','S','T') once to enable instancing. Wined3d
2117 * doesn't need that and just ignores it.
2119 * With Shader Model 3.0 capable cards Instancing 'just works' in Windows. */
2120 /* FIXME: This should just check the shader backend caps. */
2121 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_VERTEX_SHADER
])
2123 idx
= getFmtIdx(WINED3DFMT_INST
);
2124 gl_info
->formats
[idx
].flags
|= WINED3DFMT_FLAG_TEXTURE
;
2127 /* Depth bound test. To query if the card supports it CheckDeviceFormat()
2128 * with the special format MAKEFOURCC('N','V','D','B') is used. It is
2129 * enabled by setting D3DRS_ADAPTIVETESS_X render state to
2130 * MAKEFOURCC('N','V','D','B') and then controlled by setting
2131 * D3DRS_ADAPTIVETESS_Z (zMin) and D3DRS_ADAPTIVETESS_W (zMax) to test
2133 if (gl_info
->supported
[EXT_DEPTH_BOUNDS_TEST
])
2135 idx
= getFmtIdx(WINED3DFMT_NVDB
);
2136 gl_info
->formats
[idx
].flags
|= WINED3DFMT_FLAG_TEXTURE
;
2139 /* RESZ aka AMD DX9-level hack for multisampled depth buffer resolve. You query for RESZ
2140 * support by checking for availability of MAKEFOURCC('R','E','S','Z') surfaces with
2141 * RENDERTARGET usage. */
2142 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
2144 idx
= getFmtIdx(WINED3DFMT_RESZ
);
2145 gl_info
->formats
[idx
].flags
|= WINED3DFMT_FLAG_TEXTURE
| WINED3DFMT_FLAG_RENDERTARGET
;
2148 for (i
= 0; i
< sizeof(formats
) / sizeof(*formats
); ++i
)
2150 struct wined3d_format
*format
= &gl_info
->formats
[i
];
2152 if (!(format
->flags
& WINED3DFMT_FLAG_TEXTURE
))
2155 if (!adapter
->shader_backend
->shader_color_fixup_supported(format
->color_fixup
)
2156 || !adapter
->fragment_pipe
->color_fixup_supported(format
->color_fixup
))
2157 format
->flags
&= ~WINED3DFMT_FLAG_TEXTURE
;
2161 static BOOL
init_format_vertex_info(struct wined3d_gl_info
*gl_info
)
2165 for (i
= 0; i
< (sizeof(format_vertex_info
) / sizeof(*format_vertex_info
)); ++i
)
2167 struct wined3d_format
*format
;
2168 int fmt_idx
= getFmtIdx(format_vertex_info
[i
].id
);
2172 ERR("Format %s (%#x) not found.\n",
2173 debug_d3dformat(format_vertex_info
[i
].id
), format_vertex_info
[i
].id
);
2177 format
= &gl_info
->formats
[fmt_idx
];
2178 format
->emit_idx
= format_vertex_info
[i
].emit_idx
;
2179 format
->component_count
= format_vertex_info
[i
].component_count
;
2180 format
->gl_vtx_type
= format_vertex_info
[i
].gl_vtx_type
;
2181 format
->gl_vtx_format
= format_vertex_info
[i
].gl_vtx_format
;
2182 format
->gl_normalized
= format_vertex_info
[i
].gl_normalized
;
2183 format
->component_size
= format_vertex_info
[i
].component_size
;
2189 BOOL
initPixelFormatsNoGL(struct wined3d_gl_info
*gl_info
)
2191 if (!init_format_base_info(gl_info
)) return FALSE
;
2193 if (!init_format_block_info(gl_info
))
2195 HeapFree(GetProcessHeap(), 0, gl_info
->formats
);
2196 gl_info
->formats
= NULL
;
2203 /* Context activation is done by the caller. */
2204 BOOL
wined3d_adapter_init_format_info(struct wined3d_adapter
*adapter
)
2206 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
2208 if (!init_format_base_info(gl_info
)) return FALSE
;
2210 if (!init_format_block_info(gl_info
)) goto fail
;
2211 if (!init_format_texture_info(adapter
, gl_info
)) goto fail
;
2212 if (!init_format_vertex_info(gl_info
)) goto fail
;
2214 apply_format_fixups(adapter
, gl_info
);
2215 init_format_fbo_compat_info(gl_info
);
2216 init_format_filter_info(gl_info
, adapter
->driver_info
.vendor
);
2221 HeapFree(GetProcessHeap(), 0, gl_info
->formats
);
2222 gl_info
->formats
= NULL
;
2226 const struct wined3d_format
*wined3d_get_format(const struct wined3d_gl_info
*gl_info
,
2227 enum wined3d_format_id format_id
)
2229 int idx
= getFmtIdx(format_id
);
2233 FIXME("Can't find format %s (%#x) in the format lookup table\n",
2234 debug_d3dformat(format_id
), format_id
);
2235 /* Get the caller a valid pointer */
2236 idx
= getFmtIdx(WINED3DFMT_UNKNOWN
);
2239 return &gl_info
->formats
[idx
];
2242 UINT
wined3d_format_calculate_pitch(const struct wined3d_format
*format
, UINT width
)
2244 /* For block based formats, pitch means the amount of bytes to the next
2245 * row of blocks rather than the next row of pixels. */
2246 if (format
->flags
& WINED3DFMT_FLAG_BLOCKS
)
2247 return format
->block_byte_count
* ((width
+ format
->block_width
- 1) / format
->block_width
);
2249 return format
->byte_count
* width
;
2252 UINT
wined3d_format_calculate_size(const struct wined3d_format
*format
, UINT alignment
,
2253 UINT width
, UINT height
, UINT depth
)
2255 UINT pitch
= wined3d_format_calculate_pitch(format
, width
);
2258 if (format
->id
== WINED3DFMT_UNKNOWN
)
2262 else if (format
->flags
& WINED3DFMT_FLAG_BLOCKS
)
2264 UINT row_count
= (height
+ format
->block_height
- 1) / format
->block_height
;
2265 size
= row_count
* ((pitch
+ alignment
- 1) & ~(alignment
- 1));
2269 size
= height
* ((pitch
+ alignment
- 1) & ~(alignment
- 1));
2272 if (format
->flags
& WINED3DFMT_FLAG_HEIGHT_SCALE
)
2274 /* The D3D format requirements make sure that the resulting format is an integer again */
2275 size
*= format
->height_scale
.numerator
;
2276 size
/= format
->height_scale
.denominator
;
2284 /*****************************************************************************
2285 * Trace formatting of useful values
2287 const char *debug_d3dformat(enum wined3d_format_id format_id
)
2291 #define FMT_TO_STR(format_id) case format_id: return #format_id
2292 FMT_TO_STR(WINED3DFMT_UNKNOWN
);
2293 FMT_TO_STR(WINED3DFMT_B8G8R8_UNORM
);
2294 FMT_TO_STR(WINED3DFMT_B5G5R5X1_UNORM
);
2295 FMT_TO_STR(WINED3DFMT_B4G4R4A4_UNORM
);
2296 FMT_TO_STR(WINED3DFMT_B2G3R3_UNORM
);
2297 FMT_TO_STR(WINED3DFMT_B2G3R3A8_UNORM
);
2298 FMT_TO_STR(WINED3DFMT_B4G4R4X4_UNORM
);
2299 FMT_TO_STR(WINED3DFMT_R8G8B8X8_UNORM
);
2300 FMT_TO_STR(WINED3DFMT_B10G10R10A2_UNORM
);
2301 FMT_TO_STR(WINED3DFMT_P8_UINT_A8_UNORM
);
2302 FMT_TO_STR(WINED3DFMT_P8_UINT
);
2303 FMT_TO_STR(WINED3DFMT_L8_UNORM
);
2304 FMT_TO_STR(WINED3DFMT_L8A8_UNORM
);
2305 FMT_TO_STR(WINED3DFMT_L4A4_UNORM
);
2306 FMT_TO_STR(WINED3DFMT_R5G5_SNORM_L6_UNORM
);
2307 FMT_TO_STR(WINED3DFMT_R8G8_SNORM_L8X8_UNORM
);
2308 FMT_TO_STR(WINED3DFMT_R10G11B11_SNORM
);
2309 FMT_TO_STR(WINED3DFMT_R10G10B10_SNORM_A2_UNORM
);
2310 FMT_TO_STR(WINED3DFMT_UYVY
);
2311 FMT_TO_STR(WINED3DFMT_YUY2
);
2312 FMT_TO_STR(WINED3DFMT_YV12
);
2313 FMT_TO_STR(WINED3DFMT_NV12
);
2314 FMT_TO_STR(WINED3DFMT_DXT1
);
2315 FMT_TO_STR(WINED3DFMT_DXT2
);
2316 FMT_TO_STR(WINED3DFMT_DXT3
);
2317 FMT_TO_STR(WINED3DFMT_DXT4
);
2318 FMT_TO_STR(WINED3DFMT_DXT5
);
2319 FMT_TO_STR(WINED3DFMT_MULTI2_ARGB8
);
2320 FMT_TO_STR(WINED3DFMT_G8R8_G8B8
);
2321 FMT_TO_STR(WINED3DFMT_R8G8_B8G8
);
2322 FMT_TO_STR(WINED3DFMT_D16_LOCKABLE
);
2323 FMT_TO_STR(WINED3DFMT_D32_UNORM
);
2324 FMT_TO_STR(WINED3DFMT_S1_UINT_D15_UNORM
);
2325 FMT_TO_STR(WINED3DFMT_X8D24_UNORM
);
2326 FMT_TO_STR(WINED3DFMT_S4X4_UINT_D24_UNORM
);
2327 FMT_TO_STR(WINED3DFMT_L16_UNORM
);
2328 FMT_TO_STR(WINED3DFMT_S8_UINT_D24_FLOAT
);
2329 FMT_TO_STR(WINED3DFMT_VERTEXDATA
);
2330 FMT_TO_STR(WINED3DFMT_R8G8_SNORM_Cx
);
2331 FMT_TO_STR(WINED3DFMT_ATI1N
);
2332 FMT_TO_STR(WINED3DFMT_ATI2N
);
2333 FMT_TO_STR(WINED3DFMT_NVDB
);
2334 FMT_TO_STR(WINED3DFMT_NVHU
);
2335 FMT_TO_STR(WINED3DFMT_NVHS
);
2336 FMT_TO_STR(WINED3DFMT_R32G32B32A32_TYPELESS
);
2337 FMT_TO_STR(WINED3DFMT_R32G32B32A32_FLOAT
);
2338 FMT_TO_STR(WINED3DFMT_R32G32B32A32_UINT
);
2339 FMT_TO_STR(WINED3DFMT_R32G32B32A32_SINT
);
2340 FMT_TO_STR(WINED3DFMT_R32G32B32_TYPELESS
);
2341 FMT_TO_STR(WINED3DFMT_R32G32B32_FLOAT
);
2342 FMT_TO_STR(WINED3DFMT_R32G32B32_UINT
);
2343 FMT_TO_STR(WINED3DFMT_R32G32B32_SINT
);
2344 FMT_TO_STR(WINED3DFMT_R16G16B16A16_TYPELESS
);
2345 FMT_TO_STR(WINED3DFMT_R16G16B16A16_FLOAT
);
2346 FMT_TO_STR(WINED3DFMT_R16G16B16A16_UNORM
);
2347 FMT_TO_STR(WINED3DFMT_R16G16B16A16_UINT
);
2348 FMT_TO_STR(WINED3DFMT_R16G16B16A16_SNORM
);
2349 FMT_TO_STR(WINED3DFMT_R16G16B16A16_SINT
);
2350 FMT_TO_STR(WINED3DFMT_R32G32_TYPELESS
);
2351 FMT_TO_STR(WINED3DFMT_R32G32_FLOAT
);
2352 FMT_TO_STR(WINED3DFMT_R32G32_UINT
);
2353 FMT_TO_STR(WINED3DFMT_R32G32_SINT
);
2354 FMT_TO_STR(WINED3DFMT_R32G8X24_TYPELESS
);
2355 FMT_TO_STR(WINED3DFMT_D32_FLOAT_S8X24_UINT
);
2356 FMT_TO_STR(WINED3DFMT_R32_FLOAT_X8X24_TYPELESS
);
2357 FMT_TO_STR(WINED3DFMT_X32_TYPELESS_G8X24_UINT
);
2358 FMT_TO_STR(WINED3DFMT_R10G10B10A2_TYPELESS
);
2359 FMT_TO_STR(WINED3DFMT_R10G10B10A2_UNORM
);
2360 FMT_TO_STR(WINED3DFMT_R10G10B10A2_UINT
);
2361 FMT_TO_STR(WINED3DFMT_R10G10B10A2_SNORM
);
2362 FMT_TO_STR(WINED3DFMT_R11G11B10_FLOAT
);
2363 FMT_TO_STR(WINED3DFMT_R8G8B8A8_TYPELESS
);
2364 FMT_TO_STR(WINED3DFMT_R8G8B8A8_UNORM
);
2365 FMT_TO_STR(WINED3DFMT_R8G8B8A8_UNORM_SRGB
);
2366 FMT_TO_STR(WINED3DFMT_R8G8B8A8_UINT
);
2367 FMT_TO_STR(WINED3DFMT_R8G8B8A8_SNORM
);
2368 FMT_TO_STR(WINED3DFMT_R8G8B8A8_SINT
);
2369 FMT_TO_STR(WINED3DFMT_R16G16_TYPELESS
);
2370 FMT_TO_STR(WINED3DFMT_R16G16_FLOAT
);
2371 FMT_TO_STR(WINED3DFMT_R16G16_UNORM
);
2372 FMT_TO_STR(WINED3DFMT_R16G16_UINT
);
2373 FMT_TO_STR(WINED3DFMT_R16G16_SNORM
);
2374 FMT_TO_STR(WINED3DFMT_R16G16_SINT
);
2375 FMT_TO_STR(WINED3DFMT_R32_TYPELESS
);
2376 FMT_TO_STR(WINED3DFMT_D32_FLOAT
);
2377 FMT_TO_STR(WINED3DFMT_R32_FLOAT
);
2378 FMT_TO_STR(WINED3DFMT_R32_UINT
);
2379 FMT_TO_STR(WINED3DFMT_R32_SINT
);
2380 FMT_TO_STR(WINED3DFMT_R24G8_TYPELESS
);
2381 FMT_TO_STR(WINED3DFMT_D24_UNORM_S8_UINT
);
2382 FMT_TO_STR(WINED3DFMT_R24_UNORM_X8_TYPELESS
);
2383 FMT_TO_STR(WINED3DFMT_X24_TYPELESS_G8_UINT
);
2384 FMT_TO_STR(WINED3DFMT_R8G8_TYPELESS
);
2385 FMT_TO_STR(WINED3DFMT_R8G8_UNORM
);
2386 FMT_TO_STR(WINED3DFMT_R8G8_UINT
);
2387 FMT_TO_STR(WINED3DFMT_R8G8_SNORM
);
2388 FMT_TO_STR(WINED3DFMT_R8G8_SINT
);
2389 FMT_TO_STR(WINED3DFMT_R16_TYPELESS
);
2390 FMT_TO_STR(WINED3DFMT_R16_FLOAT
);
2391 FMT_TO_STR(WINED3DFMT_D16_UNORM
);
2392 FMT_TO_STR(WINED3DFMT_R16_UNORM
);
2393 FMT_TO_STR(WINED3DFMT_R16_UINT
);
2394 FMT_TO_STR(WINED3DFMT_R16_SNORM
);
2395 FMT_TO_STR(WINED3DFMT_R16_SINT
);
2396 FMT_TO_STR(WINED3DFMT_R8_TYPELESS
);
2397 FMT_TO_STR(WINED3DFMT_R8_UNORM
);
2398 FMT_TO_STR(WINED3DFMT_R8_UINT
);
2399 FMT_TO_STR(WINED3DFMT_R8_SNORM
);
2400 FMT_TO_STR(WINED3DFMT_R8_SINT
);
2401 FMT_TO_STR(WINED3DFMT_A8_UNORM
);
2402 FMT_TO_STR(WINED3DFMT_R1_UNORM
);
2403 FMT_TO_STR(WINED3DFMT_R9G9B9E5_SHAREDEXP
);
2404 FMT_TO_STR(WINED3DFMT_R8G8_B8G8_UNORM
);
2405 FMT_TO_STR(WINED3DFMT_G8R8_G8B8_UNORM
);
2406 FMT_TO_STR(WINED3DFMT_BC1_TYPELESS
);
2407 FMT_TO_STR(WINED3DFMT_BC1_UNORM
);
2408 FMT_TO_STR(WINED3DFMT_BC1_UNORM_SRGB
);
2409 FMT_TO_STR(WINED3DFMT_BC2_TYPELESS
);
2410 FMT_TO_STR(WINED3DFMT_BC2_UNORM
);
2411 FMT_TO_STR(WINED3DFMT_BC2_UNORM_SRGB
);
2412 FMT_TO_STR(WINED3DFMT_BC3_TYPELESS
);
2413 FMT_TO_STR(WINED3DFMT_BC3_UNORM
);
2414 FMT_TO_STR(WINED3DFMT_BC3_UNORM_SRGB
);
2415 FMT_TO_STR(WINED3DFMT_BC4_TYPELESS
);
2416 FMT_TO_STR(WINED3DFMT_BC4_UNORM
);
2417 FMT_TO_STR(WINED3DFMT_BC4_SNORM
);
2418 FMT_TO_STR(WINED3DFMT_BC5_TYPELESS
);
2419 FMT_TO_STR(WINED3DFMT_BC5_UNORM
);
2420 FMT_TO_STR(WINED3DFMT_BC5_SNORM
);
2421 FMT_TO_STR(WINED3DFMT_B5G6R5_UNORM
);
2422 FMT_TO_STR(WINED3DFMT_B5G5R5A1_UNORM
);
2423 FMT_TO_STR(WINED3DFMT_B8G8R8A8_UNORM
);
2424 FMT_TO_STR(WINED3DFMT_B8G8R8X8_UNORM
);
2425 FMT_TO_STR(WINED3DFMT_INTZ
);
2426 FMT_TO_STR(WINED3DFMT_RESZ
);
2427 FMT_TO_STR(WINED3DFMT_NULL
);
2428 FMT_TO_STR(WINED3DFMT_R16
);
2429 FMT_TO_STR(WINED3DFMT_AL16
);
2434 fourcc
[0] = (char)(format_id
);
2435 fourcc
[1] = (char)(format_id
>> 8);
2436 fourcc
[2] = (char)(format_id
>> 16);
2437 fourcc
[3] = (char)(format_id
>> 24);
2439 if (isprint(fourcc
[0]) && isprint(fourcc
[1]) && isprint(fourcc
[2]) && isprint(fourcc
[3]))
2440 FIXME("Unrecognized %#x (as fourcc: %s) WINED3DFORMAT!\n", format_id
, fourcc
);
2442 FIXME("Unrecognized %#x WINED3DFORMAT!\n", format_id
);
2444 return "unrecognized";
2448 const char *debug_d3ddevicetype(enum wined3d_device_type device_type
)
2450 switch (device_type
)
2452 #define DEVTYPE_TO_STR(dev) case dev: return #dev
2453 DEVTYPE_TO_STR(WINED3D_DEVICE_TYPE_HAL
);
2454 DEVTYPE_TO_STR(WINED3D_DEVICE_TYPE_REF
);
2455 DEVTYPE_TO_STR(WINED3D_DEVICE_TYPE_SW
);
2456 #undef DEVTYPE_TO_STR
2458 FIXME("Unrecognized device type %#x.\n", device_type
);
2459 return "unrecognized";
2463 const char *debug_d3dusage(DWORD usage
)
2468 #define WINED3DUSAGE_TO_STR(u) if (usage & u) { strcat(buf, " | "#u); usage &= ~u; }
2469 WINED3DUSAGE_TO_STR(WINED3DUSAGE_RENDERTARGET
);
2470 WINED3DUSAGE_TO_STR(WINED3DUSAGE_DEPTHSTENCIL
);
2471 WINED3DUSAGE_TO_STR(WINED3DUSAGE_WRITEONLY
);
2472 WINED3DUSAGE_TO_STR(WINED3DUSAGE_SOFTWAREPROCESSING
);
2473 WINED3DUSAGE_TO_STR(WINED3DUSAGE_DONOTCLIP
);
2474 WINED3DUSAGE_TO_STR(WINED3DUSAGE_POINTS
);
2475 WINED3DUSAGE_TO_STR(WINED3DUSAGE_RTPATCHES
);
2476 WINED3DUSAGE_TO_STR(WINED3DUSAGE_NPATCHES
);
2477 WINED3DUSAGE_TO_STR(WINED3DUSAGE_DYNAMIC
);
2478 WINED3DUSAGE_TO_STR(WINED3DUSAGE_AUTOGENMIPMAP
);
2479 WINED3DUSAGE_TO_STR(WINED3DUSAGE_DMAP
);
2480 WINED3DUSAGE_TO_STR(WINED3DUSAGE_STATICDECL
);
2481 WINED3DUSAGE_TO_STR(WINED3DUSAGE_OVERLAY
);
2482 #undef WINED3DUSAGE_TO_STR
2483 if (usage
) FIXME("Unrecognized usage flag(s) %#x\n", usage
);
2485 return buf
[0] ? wine_dbg_sprintf("%s", &buf
[3]) : "0";
2488 const char *debug_d3dusagequery(DWORD usagequery
)
2493 #define WINED3DUSAGEQUERY_TO_STR(u) if (usagequery & u) { strcat(buf, " | "#u); usagequery &= ~u; }
2494 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_FILTER
);
2495 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_LEGACYBUMPMAP
);
2496 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
);
2497 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_SRGBREAD
);
2498 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_SRGBWRITE
);
2499 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_VERTEXTEXTURE
);
2500 WINED3DUSAGEQUERY_TO_STR(WINED3DUSAGE_QUERY_WRAPANDMIP
);
2501 #undef WINED3DUSAGEQUERY_TO_STR
2502 if (usagequery
) FIXME("Unrecognized usage query flag(s) %#x\n", usagequery
);
2504 return buf
[0] ? wine_dbg_sprintf("%s", &buf
[3]) : "0";
2507 const char *debug_d3ddeclmethod(enum wined3d_decl_method method
)
2511 #define WINED3DDECLMETHOD_TO_STR(u) case u: return #u
2512 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_DEFAULT
);
2513 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_PARTIAL_U
);
2514 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_PARTIAL_V
);
2515 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_CROSS_UV
);
2516 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_UV
);
2517 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_LOOKUP
);
2518 WINED3DDECLMETHOD_TO_STR(WINED3D_DECL_METHOD_LOOKUP_PRESAMPLED
);
2519 #undef WINED3DDECLMETHOD_TO_STR
2521 FIXME("Unrecognized declaration method %#x.\n", method
);
2522 return "unrecognized";
2526 const char *debug_d3ddeclusage(enum wined3d_decl_usage usage
)
2530 #define WINED3DDECLUSAGE_TO_STR(u) case u: return #u
2531 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_POSITION
);
2532 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_BLEND_WEIGHT
);
2533 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_BLEND_INDICES
);
2534 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_NORMAL
);
2535 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_PSIZE
);
2536 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_TEXCOORD
);
2537 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_TANGENT
);
2538 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_BINORMAL
);
2539 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_TESS_FACTOR
);
2540 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_POSITIONT
);
2541 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_COLOR
);
2542 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_FOG
);
2543 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_DEPTH
);
2544 WINED3DDECLUSAGE_TO_STR(WINED3D_DECL_USAGE_SAMPLE
);
2545 #undef WINED3DDECLUSAGE_TO_STR
2547 FIXME("Unrecognized %u declaration usage!\n", usage
);
2548 return "unrecognized";
2552 const char *debug_d3dresourcetype(enum wined3d_resource_type resource_type
)
2554 switch (resource_type
)
2556 #define RES_TO_STR(res) case res: return #res
2557 RES_TO_STR(WINED3D_RTYPE_SURFACE
);
2558 RES_TO_STR(WINED3D_RTYPE_VOLUME
);
2559 RES_TO_STR(WINED3D_RTYPE_TEXTURE
);
2560 RES_TO_STR(WINED3D_RTYPE_VOLUME_TEXTURE
);
2561 RES_TO_STR(WINED3D_RTYPE_CUBE_TEXTURE
);
2562 RES_TO_STR(WINED3D_RTYPE_BUFFER
);
2565 FIXME("Unrecognized resource type %#x.\n", resource_type
);
2566 return "unrecognized";
2570 const char *debug_d3dprimitivetype(enum wined3d_primitive_type primitive_type
)
2572 switch (primitive_type
)
2574 #define PRIM_TO_STR(prim) case prim: return #prim
2575 PRIM_TO_STR(WINED3D_PT_UNDEFINED
);
2576 PRIM_TO_STR(WINED3D_PT_POINTLIST
);
2577 PRIM_TO_STR(WINED3D_PT_LINELIST
);
2578 PRIM_TO_STR(WINED3D_PT_LINESTRIP
);
2579 PRIM_TO_STR(WINED3D_PT_TRIANGLELIST
);
2580 PRIM_TO_STR(WINED3D_PT_TRIANGLESTRIP
);
2581 PRIM_TO_STR(WINED3D_PT_TRIANGLEFAN
);
2582 PRIM_TO_STR(WINED3D_PT_LINELIST_ADJ
);
2583 PRIM_TO_STR(WINED3D_PT_LINESTRIP_ADJ
);
2584 PRIM_TO_STR(WINED3D_PT_TRIANGLELIST_ADJ
);
2585 PRIM_TO_STR(WINED3D_PT_TRIANGLESTRIP_ADJ
);
2588 FIXME("Unrecognized %u primitive type!\n", primitive_type
);
2589 return "unrecognized";
2593 const char *debug_d3drenderstate(enum wined3d_render_state state
)
2597 #define D3DSTATE_TO_STR(u) case u: return #u
2598 D3DSTATE_TO_STR(WINED3D_RS_ANTIALIAS
);
2599 D3DSTATE_TO_STR(WINED3D_RS_TEXTUREPERSPECTIVE
);
2600 D3DSTATE_TO_STR(WINED3D_RS_WRAPU
);
2601 D3DSTATE_TO_STR(WINED3D_RS_WRAPV
);
2602 D3DSTATE_TO_STR(WINED3D_RS_ZENABLE
);
2603 D3DSTATE_TO_STR(WINED3D_RS_FILLMODE
);
2604 D3DSTATE_TO_STR(WINED3D_RS_SHADEMODE
);
2605 D3DSTATE_TO_STR(WINED3D_RS_LINEPATTERN
);
2606 D3DSTATE_TO_STR(WINED3D_RS_MONOENABLE
);
2607 D3DSTATE_TO_STR(WINED3D_RS_ROP2
);
2608 D3DSTATE_TO_STR(WINED3D_RS_PLANEMASK
);
2609 D3DSTATE_TO_STR(WINED3D_RS_ZWRITEENABLE
);
2610 D3DSTATE_TO_STR(WINED3D_RS_ALPHATESTENABLE
);
2611 D3DSTATE_TO_STR(WINED3D_RS_LASTPIXEL
);
2612 D3DSTATE_TO_STR(WINED3D_RS_SRCBLEND
);
2613 D3DSTATE_TO_STR(WINED3D_RS_DESTBLEND
);
2614 D3DSTATE_TO_STR(WINED3D_RS_CULLMODE
);
2615 D3DSTATE_TO_STR(WINED3D_RS_ZFUNC
);
2616 D3DSTATE_TO_STR(WINED3D_RS_ALPHAREF
);
2617 D3DSTATE_TO_STR(WINED3D_RS_ALPHAFUNC
);
2618 D3DSTATE_TO_STR(WINED3D_RS_DITHERENABLE
);
2619 D3DSTATE_TO_STR(WINED3D_RS_ALPHABLENDENABLE
);
2620 D3DSTATE_TO_STR(WINED3D_RS_FOGENABLE
);
2621 D3DSTATE_TO_STR(WINED3D_RS_SPECULARENABLE
);
2622 D3DSTATE_TO_STR(WINED3D_RS_ZVISIBLE
);
2623 D3DSTATE_TO_STR(WINED3D_RS_SUBPIXEL
);
2624 D3DSTATE_TO_STR(WINED3D_RS_SUBPIXELX
);
2625 D3DSTATE_TO_STR(WINED3D_RS_STIPPLEDALPHA
);
2626 D3DSTATE_TO_STR(WINED3D_RS_FOGCOLOR
);
2627 D3DSTATE_TO_STR(WINED3D_RS_FOGTABLEMODE
);
2628 D3DSTATE_TO_STR(WINED3D_RS_FOGSTART
);
2629 D3DSTATE_TO_STR(WINED3D_RS_FOGEND
);
2630 D3DSTATE_TO_STR(WINED3D_RS_FOGDENSITY
);
2631 D3DSTATE_TO_STR(WINED3D_RS_STIPPLEENABLE
);
2632 D3DSTATE_TO_STR(WINED3D_RS_EDGEANTIALIAS
);
2633 D3DSTATE_TO_STR(WINED3D_RS_COLORKEYENABLE
);
2634 D3DSTATE_TO_STR(WINED3D_RS_MIPMAPLODBIAS
);
2635 D3DSTATE_TO_STR(WINED3D_RS_RANGEFOGENABLE
);
2636 D3DSTATE_TO_STR(WINED3D_RS_ANISOTROPY
);
2637 D3DSTATE_TO_STR(WINED3D_RS_FLUSHBATCH
);
2638 D3DSTATE_TO_STR(WINED3D_RS_TRANSLUCENTSORTINDEPENDENT
);
2639 D3DSTATE_TO_STR(WINED3D_RS_STENCILENABLE
);
2640 D3DSTATE_TO_STR(WINED3D_RS_STENCILFAIL
);
2641 D3DSTATE_TO_STR(WINED3D_RS_STENCILZFAIL
);
2642 D3DSTATE_TO_STR(WINED3D_RS_STENCILPASS
);
2643 D3DSTATE_TO_STR(WINED3D_RS_STENCILFUNC
);
2644 D3DSTATE_TO_STR(WINED3D_RS_STENCILREF
);
2645 D3DSTATE_TO_STR(WINED3D_RS_STENCILMASK
);
2646 D3DSTATE_TO_STR(WINED3D_RS_STENCILWRITEMASK
);
2647 D3DSTATE_TO_STR(WINED3D_RS_TEXTUREFACTOR
);
2648 D3DSTATE_TO_STR(WINED3D_RS_WRAP0
);
2649 D3DSTATE_TO_STR(WINED3D_RS_WRAP1
);
2650 D3DSTATE_TO_STR(WINED3D_RS_WRAP2
);
2651 D3DSTATE_TO_STR(WINED3D_RS_WRAP3
);
2652 D3DSTATE_TO_STR(WINED3D_RS_WRAP4
);
2653 D3DSTATE_TO_STR(WINED3D_RS_WRAP5
);
2654 D3DSTATE_TO_STR(WINED3D_RS_WRAP6
);
2655 D3DSTATE_TO_STR(WINED3D_RS_WRAP7
);
2656 D3DSTATE_TO_STR(WINED3D_RS_CLIPPING
);
2657 D3DSTATE_TO_STR(WINED3D_RS_LIGHTING
);
2658 D3DSTATE_TO_STR(WINED3D_RS_EXTENTS
);
2659 D3DSTATE_TO_STR(WINED3D_RS_AMBIENT
);
2660 D3DSTATE_TO_STR(WINED3D_RS_FOGVERTEXMODE
);
2661 D3DSTATE_TO_STR(WINED3D_RS_COLORVERTEX
);
2662 D3DSTATE_TO_STR(WINED3D_RS_LOCALVIEWER
);
2663 D3DSTATE_TO_STR(WINED3D_RS_NORMALIZENORMALS
);
2664 D3DSTATE_TO_STR(WINED3D_RS_COLORKEYBLENDENABLE
);
2665 D3DSTATE_TO_STR(WINED3D_RS_DIFFUSEMATERIALSOURCE
);
2666 D3DSTATE_TO_STR(WINED3D_RS_SPECULARMATERIALSOURCE
);
2667 D3DSTATE_TO_STR(WINED3D_RS_AMBIENTMATERIALSOURCE
);
2668 D3DSTATE_TO_STR(WINED3D_RS_EMISSIVEMATERIALSOURCE
);
2669 D3DSTATE_TO_STR(WINED3D_RS_VERTEXBLEND
);
2670 D3DSTATE_TO_STR(WINED3D_RS_CLIPPLANEENABLE
);
2671 D3DSTATE_TO_STR(WINED3D_RS_SOFTWAREVERTEXPROCESSING
);
2672 D3DSTATE_TO_STR(WINED3D_RS_POINTSIZE
);
2673 D3DSTATE_TO_STR(WINED3D_RS_POINTSIZE_MIN
);
2674 D3DSTATE_TO_STR(WINED3D_RS_POINTSPRITEENABLE
);
2675 D3DSTATE_TO_STR(WINED3D_RS_POINTSCALEENABLE
);
2676 D3DSTATE_TO_STR(WINED3D_RS_POINTSCALE_A
);
2677 D3DSTATE_TO_STR(WINED3D_RS_POINTSCALE_B
);
2678 D3DSTATE_TO_STR(WINED3D_RS_POINTSCALE_C
);
2679 D3DSTATE_TO_STR(WINED3D_RS_MULTISAMPLEANTIALIAS
);
2680 D3DSTATE_TO_STR(WINED3D_RS_MULTISAMPLEMASK
);
2681 D3DSTATE_TO_STR(WINED3D_RS_PATCHEDGESTYLE
);
2682 D3DSTATE_TO_STR(WINED3D_RS_PATCHSEGMENTS
);
2683 D3DSTATE_TO_STR(WINED3D_RS_DEBUGMONITORTOKEN
);
2684 D3DSTATE_TO_STR(WINED3D_RS_POINTSIZE_MAX
);
2685 D3DSTATE_TO_STR(WINED3D_RS_INDEXEDVERTEXBLENDENABLE
);
2686 D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE
);
2687 D3DSTATE_TO_STR(WINED3D_RS_TWEENFACTOR
);
2688 D3DSTATE_TO_STR(WINED3D_RS_BLENDOP
);
2689 D3DSTATE_TO_STR(WINED3D_RS_POSITIONDEGREE
);
2690 D3DSTATE_TO_STR(WINED3D_RS_NORMALDEGREE
);
2691 D3DSTATE_TO_STR(WINED3D_RS_SCISSORTESTENABLE
);
2692 D3DSTATE_TO_STR(WINED3D_RS_SLOPESCALEDEPTHBIAS
);
2693 D3DSTATE_TO_STR(WINED3D_RS_ANTIALIASEDLINEENABLE
);
2694 D3DSTATE_TO_STR(WINED3D_RS_MINTESSELLATIONLEVEL
);
2695 D3DSTATE_TO_STR(WINED3D_RS_MAXTESSELLATIONLEVEL
);
2696 D3DSTATE_TO_STR(WINED3D_RS_ADAPTIVETESS_X
);
2697 D3DSTATE_TO_STR(WINED3D_RS_ADAPTIVETESS_Y
);
2698 D3DSTATE_TO_STR(WINED3D_RS_ADAPTIVETESS_Z
);
2699 D3DSTATE_TO_STR(WINED3D_RS_ADAPTIVETESS_W
);
2700 D3DSTATE_TO_STR(WINED3D_RS_ENABLEADAPTIVETESSELLATION
);
2701 D3DSTATE_TO_STR(WINED3D_RS_TWOSIDEDSTENCILMODE
);
2702 D3DSTATE_TO_STR(WINED3D_RS_CCW_STENCILFAIL
);
2703 D3DSTATE_TO_STR(WINED3D_RS_CCW_STENCILZFAIL
);
2704 D3DSTATE_TO_STR(WINED3D_RS_CCW_STENCILPASS
);
2705 D3DSTATE_TO_STR(WINED3D_RS_CCW_STENCILFUNC
);
2706 D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE1
);
2707 D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE2
);
2708 D3DSTATE_TO_STR(WINED3D_RS_COLORWRITEENABLE3
);
2709 D3DSTATE_TO_STR(WINED3D_RS_BLENDFACTOR
);
2710 D3DSTATE_TO_STR(WINED3D_RS_SRGBWRITEENABLE
);
2711 D3DSTATE_TO_STR(WINED3D_RS_DEPTHBIAS
);
2712 D3DSTATE_TO_STR(WINED3D_RS_WRAP8
);
2713 D3DSTATE_TO_STR(WINED3D_RS_WRAP9
);
2714 D3DSTATE_TO_STR(WINED3D_RS_WRAP10
);
2715 D3DSTATE_TO_STR(WINED3D_RS_WRAP11
);
2716 D3DSTATE_TO_STR(WINED3D_RS_WRAP12
);
2717 D3DSTATE_TO_STR(WINED3D_RS_WRAP13
);
2718 D3DSTATE_TO_STR(WINED3D_RS_WRAP14
);
2719 D3DSTATE_TO_STR(WINED3D_RS_WRAP15
);
2720 D3DSTATE_TO_STR(WINED3D_RS_SEPARATEALPHABLENDENABLE
);
2721 D3DSTATE_TO_STR(WINED3D_RS_SRCBLENDALPHA
);
2722 D3DSTATE_TO_STR(WINED3D_RS_DESTBLENDALPHA
);
2723 D3DSTATE_TO_STR(WINED3D_RS_BLENDOPALPHA
);
2724 #undef D3DSTATE_TO_STR
2726 FIXME("Unrecognized %u render state!\n", state
);
2727 return "unrecognized";
2731 const char *debug_d3dsamplerstate(enum wined3d_sampler_state state
)
2735 #define D3DSTATE_TO_STR(u) case u: return #u
2736 D3DSTATE_TO_STR(WINED3D_SAMP_BORDER_COLOR
);
2737 D3DSTATE_TO_STR(WINED3D_SAMP_ADDRESS_U
);
2738 D3DSTATE_TO_STR(WINED3D_SAMP_ADDRESS_V
);
2739 D3DSTATE_TO_STR(WINED3D_SAMP_ADDRESS_W
);
2740 D3DSTATE_TO_STR(WINED3D_SAMP_MAG_FILTER
);
2741 D3DSTATE_TO_STR(WINED3D_SAMP_MIN_FILTER
);
2742 D3DSTATE_TO_STR(WINED3D_SAMP_MIP_FILTER
);
2743 D3DSTATE_TO_STR(WINED3D_SAMP_MIPMAP_LOD_BIAS
);
2744 D3DSTATE_TO_STR(WINED3D_SAMP_MAX_MIP_LEVEL
);
2745 D3DSTATE_TO_STR(WINED3D_SAMP_MAX_ANISOTROPY
);
2746 D3DSTATE_TO_STR(WINED3D_SAMP_SRGB_TEXTURE
);
2747 D3DSTATE_TO_STR(WINED3D_SAMP_ELEMENT_INDEX
);
2748 D3DSTATE_TO_STR(WINED3D_SAMP_DMAP_OFFSET
);
2749 #undef D3DSTATE_TO_STR
2751 FIXME("Unrecognized %u sampler state!\n", state
);
2752 return "unrecognized";
2756 const char *debug_d3dtexturefiltertype(enum wined3d_texture_filter_type filter_type
)
2758 switch (filter_type
)
2760 #define D3DTEXTUREFILTERTYPE_TO_STR(u) case u: return #u
2761 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_NONE
);
2762 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_POINT
);
2763 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_LINEAR
);
2764 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_ANISOTROPIC
);
2765 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_FLAT_CUBIC
);
2766 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_GAUSSIAN_CUBIC
);
2767 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_PYRAMIDAL_QUAD
);
2768 D3DTEXTUREFILTERTYPE_TO_STR(WINED3D_TEXF_GAUSSIAN_QUAD
);
2769 #undef D3DTEXTUREFILTERTYPE_TO_STR
2771 FIXME("Unrecognied texture filter type 0x%08x.\n", filter_type
);
2772 return "unrecognized";
2776 const char *debug_d3dtexturestate(enum wined3d_texture_stage_state state
)
2780 #define D3DSTATE_TO_STR(u) case u: return #u
2781 D3DSTATE_TO_STR(WINED3D_TSS_COLOR_OP
);
2782 D3DSTATE_TO_STR(WINED3D_TSS_COLOR_ARG1
);
2783 D3DSTATE_TO_STR(WINED3D_TSS_COLOR_ARG2
);
2784 D3DSTATE_TO_STR(WINED3D_TSS_ALPHA_OP
);
2785 D3DSTATE_TO_STR(WINED3D_TSS_ALPHA_ARG1
);
2786 D3DSTATE_TO_STR(WINED3D_TSS_ALPHA_ARG2
);
2787 D3DSTATE_TO_STR(WINED3D_TSS_BUMPENV_MAT00
);
2788 D3DSTATE_TO_STR(WINED3D_TSS_BUMPENV_MAT01
);
2789 D3DSTATE_TO_STR(WINED3D_TSS_BUMPENV_MAT10
);
2790 D3DSTATE_TO_STR(WINED3D_TSS_BUMPENV_MAT11
);
2791 D3DSTATE_TO_STR(WINED3D_TSS_TEXCOORD_INDEX
);
2792 D3DSTATE_TO_STR(WINED3D_TSS_BUMPENV_LSCALE
);
2793 D3DSTATE_TO_STR(WINED3D_TSS_BUMPENV_LOFFSET
);
2794 D3DSTATE_TO_STR(WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
);
2795 D3DSTATE_TO_STR(WINED3D_TSS_COLOR_ARG0
);
2796 D3DSTATE_TO_STR(WINED3D_TSS_ALPHA_ARG0
);
2797 D3DSTATE_TO_STR(WINED3D_TSS_RESULT_ARG
);
2798 D3DSTATE_TO_STR(WINED3D_TSS_CONSTANT
);
2799 #undef D3DSTATE_TO_STR
2801 FIXME("Unrecognized %u texture state!\n", state
);
2802 return "unrecognized";
2806 const char *debug_d3dtop(enum wined3d_texture_op d3dtop
)
2810 #define D3DTOP_TO_STR(u) case u: return #u
2811 D3DTOP_TO_STR(WINED3D_TOP_DISABLE
);
2812 D3DTOP_TO_STR(WINED3D_TOP_SELECT_ARG1
);
2813 D3DTOP_TO_STR(WINED3D_TOP_SELECT_ARG2
);
2814 D3DTOP_TO_STR(WINED3D_TOP_MODULATE
);
2815 D3DTOP_TO_STR(WINED3D_TOP_MODULATE_2X
);
2816 D3DTOP_TO_STR(WINED3D_TOP_MODULATE_4X
);
2817 D3DTOP_TO_STR(WINED3D_TOP_ADD
);
2818 D3DTOP_TO_STR(WINED3D_TOP_ADD_SIGNED
);
2819 D3DTOP_TO_STR(WINED3D_TOP_ADD_SIGNED_2X
);
2820 D3DTOP_TO_STR(WINED3D_TOP_SUBTRACT
);
2821 D3DTOP_TO_STR(WINED3D_TOP_ADD_SMOOTH
);
2822 D3DTOP_TO_STR(WINED3D_TOP_BLEND_DIFFUSE_ALPHA
);
2823 D3DTOP_TO_STR(WINED3D_TOP_BLEND_TEXTURE_ALPHA
);
2824 D3DTOP_TO_STR(WINED3D_TOP_BLEND_FACTOR_ALPHA
);
2825 D3DTOP_TO_STR(WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM
);
2826 D3DTOP_TO_STR(WINED3D_TOP_BLEND_CURRENT_ALPHA
);
2827 D3DTOP_TO_STR(WINED3D_TOP_PREMODULATE
);
2828 D3DTOP_TO_STR(WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR
);
2829 D3DTOP_TO_STR(WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA
);
2830 D3DTOP_TO_STR(WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR
);
2831 D3DTOP_TO_STR(WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA
);
2832 D3DTOP_TO_STR(WINED3D_TOP_BUMPENVMAP
);
2833 D3DTOP_TO_STR(WINED3D_TOP_BUMPENVMAP_LUMINANCE
);
2834 D3DTOP_TO_STR(WINED3D_TOP_DOTPRODUCT3
);
2835 D3DTOP_TO_STR(WINED3D_TOP_MULTIPLY_ADD
);
2836 D3DTOP_TO_STR(WINED3D_TOP_LERP
);
2837 #undef D3DTOP_TO_STR
2839 FIXME("Unrecognized texture op %#x.\n", d3dtop
);
2840 return "unrecognized";
2844 const char *debug_d3dtstype(enum wined3d_transform_state tstype
)
2848 #define TSTYPE_TO_STR(tstype) case tstype: return #tstype
2849 TSTYPE_TO_STR(WINED3D_TS_VIEW
);
2850 TSTYPE_TO_STR(WINED3D_TS_PROJECTION
);
2851 TSTYPE_TO_STR(WINED3D_TS_TEXTURE0
);
2852 TSTYPE_TO_STR(WINED3D_TS_TEXTURE1
);
2853 TSTYPE_TO_STR(WINED3D_TS_TEXTURE2
);
2854 TSTYPE_TO_STR(WINED3D_TS_TEXTURE3
);
2855 TSTYPE_TO_STR(WINED3D_TS_TEXTURE4
);
2856 TSTYPE_TO_STR(WINED3D_TS_TEXTURE5
);
2857 TSTYPE_TO_STR(WINED3D_TS_TEXTURE6
);
2858 TSTYPE_TO_STR(WINED3D_TS_TEXTURE7
);
2859 TSTYPE_TO_STR(WINED3D_TS_WORLD_MATRIX(0));
2860 #undef TSTYPE_TO_STR
2862 if (tstype
> 256 && tstype
< 512)
2864 FIXME("WINED3D_TS_WORLD_MATRIX(%u). 1..255 not currently supported.\n", tstype
);
2865 return ("WINED3D_TS_WORLD_MATRIX > 0");
2867 FIXME("Unrecognized transform state %#x.\n", tstype
);
2868 return "unrecognized";
2872 static const char *debug_shader_type(enum wined3d_shader_type type
)
2876 #define WINED3D_TO_STR(type) case type: return #type
2877 WINED3D_TO_STR(WINED3D_SHADER_TYPE_PIXEL
);
2878 WINED3D_TO_STR(WINED3D_SHADER_TYPE_VERTEX
);
2879 WINED3D_TO_STR(WINED3D_SHADER_TYPE_GEOMETRY
);
2880 #undef WINED3D_TO_STR
2882 FIXME("Unrecognized shader type %#x.\n", type
);
2883 return "unrecognized";
2887 const char *debug_d3dstate(DWORD state
)
2889 if (STATE_IS_RENDER(state
))
2890 return wine_dbg_sprintf("STATE_RENDER(%s)", debug_d3drenderstate(state
- STATE_RENDER(0)));
2891 if (STATE_IS_TEXTURESTAGE(state
))
2893 DWORD texture_stage
= (state
- STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE
+ 1);
2894 DWORD texture_state
= state
- STATE_TEXTURESTAGE(texture_stage
, 0);
2895 return wine_dbg_sprintf("STATE_TEXTURESTAGE(%#x, %s)",
2896 texture_stage
, debug_d3dtexturestate(texture_state
));
2898 if (STATE_IS_SAMPLER(state
))
2899 return wine_dbg_sprintf("STATE_SAMPLER(%#x)", state
- STATE_SAMPLER(0));
2900 if (STATE_IS_SHADER(state
))
2901 return wine_dbg_sprintf("STATE_SHADER(%s)", debug_shader_type(state
- STATE_SHADER(0)));
2902 if (STATE_IS_CONSTANT_BUFFER(state
))
2903 return wine_dbg_sprintf("STATE_CONSTANT_BUFFER(%s)", debug_shader_type(state
- STATE_CONSTANT_BUFFER(0)));
2904 if (STATE_IS_SHADER_RESOURCE_BINDING(state
))
2905 return "STATE_SHADER_RESOURCE_BINDING";
2906 if (STATE_IS_TRANSFORM(state
))
2907 return wine_dbg_sprintf("STATE_TRANSFORM(%s)", debug_d3dtstype(state
- STATE_TRANSFORM(0)));
2908 if (STATE_IS_STREAMSRC(state
))
2909 return "STATE_STREAMSRC";
2910 if (STATE_IS_INDEXBUFFER(state
))
2911 return "STATE_INDEXBUFFER";
2912 if (STATE_IS_VDECL(state
))
2913 return "STATE_VDECL";
2914 if (STATE_IS_VIEWPORT(state
))
2915 return "STATE_VIEWPORT";
2916 if (STATE_IS_LIGHT_TYPE(state
))
2917 return "STATE_LIGHT_TYPE";
2918 if (STATE_IS_ACTIVELIGHT(state
))
2919 return wine_dbg_sprintf("STATE_ACTIVELIGHT(%#x)", state
- STATE_ACTIVELIGHT(0));
2920 if (STATE_IS_SCISSORRECT(state
))
2921 return "STATE_SCISSORRECT";
2922 if (STATE_IS_CLIPPLANE(state
))
2923 return wine_dbg_sprintf("STATE_CLIPPLANE(%#x)", state
- STATE_CLIPPLANE(0));
2924 if (STATE_IS_MATERIAL(state
))
2925 return "STATE_MATERIAL";
2926 if (STATE_IS_FRONTFACE(state
))
2927 return "STATE_FRONTFACE";
2928 if (STATE_IS_POINTSPRITECOORDORIGIN(state
))
2929 return "STATE_POINTSPRITECOORDORIGIN";
2930 if (STATE_IS_BASEVERTEXINDEX(state
))
2931 return "STATE_BASEVERTEXINDEX";
2932 if (STATE_IS_FRAMEBUFFER(state
))
2933 return "STATE_FRAMEBUFFER";
2934 if (STATE_IS_POINT_SIZE_ENABLE(state
))
2935 return "STATE_POINT_SIZE_ENABLE";
2937 return wine_dbg_sprintf("UNKNOWN_STATE(%#x)", state
);
2940 const char *debug_d3dpool(enum wined3d_pool pool
)
2944 #define POOL_TO_STR(p) case p: return #p
2945 POOL_TO_STR(WINED3D_POOL_DEFAULT
);
2946 POOL_TO_STR(WINED3D_POOL_MANAGED
);
2947 POOL_TO_STR(WINED3D_POOL_SYSTEM_MEM
);
2948 POOL_TO_STR(WINED3D_POOL_SCRATCH
);
2951 FIXME("Unrecognized pool %#x.\n", pool
);
2952 return "unrecognized";
2956 const char *debug_fbostatus(GLenum status
) {
2958 #define FBOSTATUS_TO_STR(u) case u: return #u
2959 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_COMPLETE
);
2960 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
);
2961 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
);
2962 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
);
2963 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
);
2964 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER
);
2965 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER
);
2966 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
);
2967 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_UNSUPPORTED
);
2968 FBOSTATUS_TO_STR(GL_FRAMEBUFFER_UNDEFINED
);
2969 #undef FBOSTATUS_TO_STR
2971 FIXME("Unrecognied FBO status 0x%08x\n", status
);
2972 return "unrecognized";
2976 const char *debug_glerror(GLenum error
) {
2978 #define GLERROR_TO_STR(u) case u: return #u
2979 GLERROR_TO_STR(GL_NO_ERROR
);
2980 GLERROR_TO_STR(GL_INVALID_ENUM
);
2981 GLERROR_TO_STR(GL_INVALID_VALUE
);
2982 GLERROR_TO_STR(GL_INVALID_OPERATION
);
2983 GLERROR_TO_STR(GL_STACK_OVERFLOW
);
2984 GLERROR_TO_STR(GL_STACK_UNDERFLOW
);
2985 GLERROR_TO_STR(GL_OUT_OF_MEMORY
);
2986 GLERROR_TO_STR(GL_INVALID_FRAMEBUFFER_OPERATION
);
2987 #undef GLERROR_TO_STR
2989 FIXME("Unrecognied GL error 0x%08x\n", error
);
2990 return "unrecognized";
2994 static const char *debug_fixup_channel_source(enum fixup_channel_source source
)
2998 #define WINED3D_TO_STR(x) case x: return #x
2999 WINED3D_TO_STR(CHANNEL_SOURCE_ZERO
);
3000 WINED3D_TO_STR(CHANNEL_SOURCE_ONE
);
3001 WINED3D_TO_STR(CHANNEL_SOURCE_X
);
3002 WINED3D_TO_STR(CHANNEL_SOURCE_Y
);
3003 WINED3D_TO_STR(CHANNEL_SOURCE_Z
);
3004 WINED3D_TO_STR(CHANNEL_SOURCE_W
);
3005 WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX0
);
3006 WINED3D_TO_STR(CHANNEL_SOURCE_COMPLEX1
);
3007 #undef WINED3D_TO_STR
3009 FIXME("Unrecognized fixup_channel_source %#x\n", source
);
3010 return "unrecognized";
3014 static const char *debug_complex_fixup(enum complex_fixup fixup
)
3018 #define WINED3D_TO_STR(x) case x: return #x
3019 WINED3D_TO_STR(COMPLEX_FIXUP_YUY2
);
3020 WINED3D_TO_STR(COMPLEX_FIXUP_UYVY
);
3021 WINED3D_TO_STR(COMPLEX_FIXUP_YV12
);
3022 WINED3D_TO_STR(COMPLEX_FIXUP_NV12
);
3023 WINED3D_TO_STR(COMPLEX_FIXUP_P8
);
3024 #undef WINED3D_TO_STR
3026 FIXME("Unrecognized complex fixup %#x\n", fixup
);
3027 return "unrecognized";
3031 void dump_color_fixup_desc(struct color_fixup_desc fixup
)
3033 if (is_complex_fixup(fixup
))
3035 TRACE("\tComplex: %s\n", debug_complex_fixup(get_complex_fixup(fixup
)));
3039 TRACE("\tX: %s%s\n", debug_fixup_channel_source(fixup
.x_source
), fixup
.x_sign_fixup
? ", SIGN_FIXUP" : "");
3040 TRACE("\tY: %s%s\n", debug_fixup_channel_source(fixup
.y_source
), fixup
.y_sign_fixup
? ", SIGN_FIXUP" : "");
3041 TRACE("\tZ: %s%s\n", debug_fixup_channel_source(fixup
.z_source
), fixup
.z_sign_fixup
? ", SIGN_FIXUP" : "");
3042 TRACE("\tW: %s%s\n", debug_fixup_channel_source(fixup
.w_source
), fixup
.w_sign_fixup
? ", SIGN_FIXUP" : "");
3045 BOOL
is_invalid_op(const struct wined3d_state
*state
, int stage
,
3046 enum wined3d_texture_op op
, DWORD arg1
, DWORD arg2
, DWORD arg3
)
3048 if (op
== WINED3D_TOP_DISABLE
)
3050 if (state
->textures
[stage
])
3053 if ((arg1
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
3054 && op
!= WINED3D_TOP_SELECT_ARG2
)
3056 if ((arg2
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
3057 && op
!= WINED3D_TOP_SELECT_ARG1
)
3059 if ((arg3
& WINED3DTA_SELECTMASK
) == WINED3DTA_TEXTURE
3060 && (op
== WINED3D_TOP_MULTIPLY_ADD
|| op
== WINED3D_TOP_LERP
))
3066 /* Setup this textures matrix according to the texture flags. */
3067 /* Context activation is done by the caller (state handler). */
3068 void set_texture_matrix(const struct wined3d_gl_info
*gl_info
, const float *smat
, DWORD flags
,
3069 BOOL calculatedCoords
, BOOL transformed
, enum wined3d_format_id vtx_fmt
, BOOL ffp_proj_control
)
3073 gl_info
->gl_ops
.gl
.p_glMatrixMode(GL_TEXTURE
);
3074 checkGLcall("glMatrixMode(GL_TEXTURE)");
3076 if (flags
== WINED3D_TTFF_DISABLE
|| flags
== WINED3D_TTFF_COUNT1
|| transformed
)
3078 gl_info
->gl_ops
.gl
.p_glLoadIdentity();
3079 checkGLcall("glLoadIdentity()");
3083 if (flags
== (WINED3D_TTFF_COUNT1
| WINED3D_TTFF_PROJECTED
))
3085 ERR("Invalid texture transform flags: WINED3D_TTFF_COUNT1 | WINED3D_TTFF_PROJECTED.\n");
3089 memcpy(mat
, smat
, 16 * sizeof(float));
3091 if (flags
& WINED3D_TTFF_PROJECTED
)
3093 if (!ffp_proj_control
)
3095 switch (flags
& ~WINED3D_TTFF_PROJECTED
)
3097 case WINED3D_TTFF_COUNT2
:
3102 mat
[ 1] = mat
[ 5] = mat
[ 9] = mat
[13] = 0.0f
;
3104 case WINED3D_TTFF_COUNT3
:
3109 mat
[ 2] = mat
[ 6] = mat
[10] = mat
[14] = 0.0f
;
3113 } else { /* under directx the R/Z coord can be used for translation, under opengl we use the Q coord instead */
3114 if(!calculatedCoords
) {
3117 case WINED3DFMT_R32_FLOAT
:
3118 /* Direct3D passes the default 1.0 in the 2nd coord, while gl passes it in the 4th.
3119 * swap 2nd and 4th coord. No need to store the value of mat[12] in mat[4] because
3120 * the input value to the transformation will be 0, so the matrix value is irrelevant
3127 case WINED3DFMT_R32G32_FLOAT
:
3128 /* See above, just 3rd and 4th coord
3135 case WINED3DFMT_R32G32B32_FLOAT
: /* Opengl defaults match dx defaults */
3136 case WINED3DFMT_R32G32B32A32_FLOAT
: /* No defaults apply, all app defined */
3138 /* This is to prevent swapping the matrix lines and put the default 4th coord = 1.0
3139 * into a bad place. The division elimination below will apply to make sure the
3140 * 1.0 doesn't do anything bad. The caller will set this value if the stride is 0
3142 case WINED3DFMT_UNKNOWN
: /* No texture coords, 0/0/0/1 defaults are passed */
3145 FIXME("Unexpected fixed function texture coord input\n");
3148 if (!ffp_proj_control
)
3150 switch (flags
& ~WINED3D_TTFF_PROJECTED
)
3152 /* case WINED3D_TTFF_COUNT1: Won't ever get here. */
3153 case WINED3D_TTFF_COUNT2
:
3154 mat
[2] = mat
[6] = mat
[10] = mat
[14] = 0;
3155 /* OpenGL divides the first 3 vertex coord by the 4th by default,
3156 * which is essentially the same as D3DTTFF_PROJECTED. Make sure that
3157 * the 4th coord evaluates to 1.0 to eliminate that.
3159 * If the fixed function pipeline is used, the 4th value remains unused,
3160 * so there is no danger in doing this. With vertex shaders we have a
3161 * problem. Should an app hit that problem, the code here would have to
3162 * check for pixel shaders, and the shader has to undo the default gl divide.
3164 * A more serious problem occurs if the app passes 4 coordinates in, and the
3165 * 4th is != 1.0(opengl default). This would have to be fixed in drawStridedSlow
3166 * or a replacement shader. */
3168 mat
[3] = mat
[7] = mat
[11] = 0; mat
[15] = 1;
3173 gl_info
->gl_ops
.gl
.p_glLoadMatrixf(mat
);
3174 checkGLcall("glLoadMatrixf(mat)");
3177 /* This small helper function is used to convert a bitmask into the number of masked bits */
3178 unsigned int count_bits(unsigned int mask
)
3181 for (count
= 0; mask
; ++count
)
3188 /* Helper function for retrieving color info for ChoosePixelFormat and wglChoosePixelFormatARB.
3189 * The later function requires individual color components. */
3190 BOOL
getColorBits(const struct wined3d_format
*format
,
3191 BYTE
*redSize
, BYTE
*greenSize
, BYTE
*blueSize
, BYTE
*alphaSize
, BYTE
*totalSize
)
3193 TRACE("format %s.\n", debug_d3dformat(format
->id
));
3197 case WINED3DFMT_B10G10R10A2_UNORM
:
3198 case WINED3DFMT_R10G10B10A2_UNORM
:
3199 case WINED3DFMT_B8G8R8X8_UNORM
:
3200 case WINED3DFMT_B8G8R8_UNORM
:
3201 case WINED3DFMT_B8G8R8A8_UNORM
:
3202 case WINED3DFMT_R8G8B8A8_UNORM
:
3203 case WINED3DFMT_B5G5R5X1_UNORM
:
3204 case WINED3DFMT_B5G5R5A1_UNORM
:
3205 case WINED3DFMT_B5G6R5_UNORM
:
3206 case WINED3DFMT_B4G4R4X4_UNORM
:
3207 case WINED3DFMT_B4G4R4A4_UNORM
:
3208 case WINED3DFMT_B2G3R3_UNORM
:
3209 case WINED3DFMT_P8_UINT_A8_UNORM
:
3210 case WINED3DFMT_P8_UINT
:
3213 FIXME("Unsupported format %s.\n", debug_d3dformat(format
->id
));
3217 *redSize
= format
->red_size
;
3218 *greenSize
= format
->green_size
;
3219 *blueSize
= format
->blue_size
;
3220 *alphaSize
= format
->alpha_size
;
3221 *totalSize
= *redSize
+ *greenSize
+ *blueSize
+ *alphaSize
;
3223 TRACE("Returning red: %d, green: %d, blue: %d, alpha: %d, total: %d for format %s.\n",
3224 *redSize
, *greenSize
, *blueSize
, *alphaSize
, *totalSize
, debug_d3dformat(format
->id
));
3228 /* Helper function for retrieving depth/stencil info for ChoosePixelFormat and wglChoosePixelFormatARB */
3229 BOOL
getDepthStencilBits(const struct wined3d_format
*format
, BYTE
*depthSize
, BYTE
*stencilSize
)
3231 TRACE("format %s.\n", debug_d3dformat(format
->id
));
3235 case WINED3DFMT_D16_LOCKABLE
:
3236 case WINED3DFMT_D16_UNORM
:
3237 case WINED3DFMT_S1_UINT_D15_UNORM
:
3238 case WINED3DFMT_X8D24_UNORM
:
3239 case WINED3DFMT_S4X4_UINT_D24_UNORM
:
3240 case WINED3DFMT_D24_UNORM_S8_UINT
:
3241 case WINED3DFMT_S8_UINT_D24_FLOAT
:
3242 case WINED3DFMT_D32_UNORM
:
3243 case WINED3DFMT_D32_FLOAT
:
3244 case WINED3DFMT_INTZ
:
3247 FIXME("Unsupported depth/stencil format %s.\n", debug_d3dformat(format
->id
));
3251 *depthSize
= format
->depth_size
;
3252 *stencilSize
= format
->stencil_size
;
3254 TRACE("Returning depthSize: %d and stencilSize: %d for format %s.\n",
3255 *depthSize
, *stencilSize
, debug_d3dformat(format
->id
));
3259 /* Note: It's the caller's responsibility to ensure values can be expressed
3260 * in the requested format. UNORM formats for example can only express values
3261 * in the range 0.0f -> 1.0f. */
3262 DWORD
wined3d_format_convert_from_float(const struct wined3d_surface
*surface
, const struct wined3d_color
*color
)
3266 enum wined3d_format_id format_id
;
3278 {WINED3DFMT_B8G8R8A8_UNORM
, 255.0f
, 255.0f
, 255.0f
, 255.0f
, 16, 8, 0, 24},
3279 {WINED3DFMT_B8G8R8X8_UNORM
, 255.0f
, 255.0f
, 255.0f
, 255.0f
, 16, 8, 0, 24},
3280 {WINED3DFMT_B8G8R8_UNORM
, 255.0f
, 255.0f
, 255.0f
, 255.0f
, 16, 8, 0, 24},
3281 {WINED3DFMT_B5G6R5_UNORM
, 31.0f
, 63.0f
, 31.0f
, 0.0f
, 11, 5, 0, 0},
3282 {WINED3DFMT_B5G5R5A1_UNORM
, 31.0f
, 31.0f
, 31.0f
, 1.0f
, 10, 5, 0, 15},
3283 {WINED3DFMT_B5G5R5X1_UNORM
, 31.0f
, 31.0f
, 31.0f
, 1.0f
, 10, 5, 0, 15},
3284 {WINED3DFMT_R8_UNORM
, 255.0f
, 0.0f
, 0.0f
, 0.0f
, 0, 0, 0, 0},
3285 {WINED3DFMT_A8_UNORM
, 0.0f
, 0.0f
, 0.0f
, 255.0f
, 0, 0, 0, 0},
3286 {WINED3DFMT_B4G4R4A4_UNORM
, 15.0f
, 15.0f
, 15.0f
, 15.0f
, 8, 4, 0, 12},
3287 {WINED3DFMT_B4G4R4X4_UNORM
, 15.0f
, 15.0f
, 15.0f
, 15.0f
, 8, 4, 0, 12},
3288 {WINED3DFMT_B2G3R3_UNORM
, 7.0f
, 7.0f
, 3.0f
, 0.0f
, 5, 2, 0, 0},
3289 {WINED3DFMT_R8G8B8A8_UNORM
, 255.0f
, 255.0f
, 255.0f
, 255.0f
, 0, 8, 16, 24},
3290 {WINED3DFMT_R8G8B8X8_UNORM
, 255.0f
, 255.0f
, 255.0f
, 255.0f
, 0, 8, 16, 24},
3291 {WINED3DFMT_B10G10R10A2_UNORM
, 1023.0f
, 1023.0f
, 1023.0f
, 3.0f
, 20, 10, 0, 30},
3292 {WINED3DFMT_R10G10B10A2_UNORM
, 1023.0f
, 1023.0f
, 1023.0f
, 3.0f
, 0, 10, 20, 30},
3293 {WINED3DFMT_P8_UINT
, 0.0f
, 0.0f
, 0.0f
, 255.0f
, 0, 0, 0, 0},
3295 const struct wined3d_format
*format
= surface
->resource
.format
;
3298 TRACE("Converting color {%.8e %.8e %.8e %.8e} to format %s.\n",
3299 color
->r
, color
->g
, color
->b
, color
->a
, debug_d3dformat(format
->id
));
3301 for (i
= 0; i
< sizeof(conv
) / sizeof(*conv
); ++i
)
3305 if (format
->id
!= conv
[i
].format_id
) continue;
3307 ret
= ((DWORD
)((color
->r
* conv
[i
].r_mul
) + 0.5f
)) << conv
[i
].r_shift
;
3308 ret
|= ((DWORD
)((color
->g
* conv
[i
].g_mul
) + 0.5f
)) << conv
[i
].g_shift
;
3309 ret
|= ((DWORD
)((color
->b
* conv
[i
].b_mul
) + 0.5f
)) << conv
[i
].b_shift
;
3310 ret
|= ((DWORD
)((color
->a
* conv
[i
].a_mul
) + 0.5f
)) << conv
[i
].a_shift
;
3312 TRACE("Returning 0x%08x.\n", ret
);
3317 FIXME("Conversion for format %s not implemented.\n", debug_d3dformat(format
->id
));
3322 /* DirectDraw stuff */
3323 enum wined3d_format_id
pixelformat_for_depth(DWORD depth
)
3327 case 8: return WINED3DFMT_P8_UINT
;
3328 case 15: return WINED3DFMT_B5G5R5X1_UNORM
;
3329 case 16: return WINED3DFMT_B5G6R5_UNORM
;
3330 case 24: return WINED3DFMT_B8G8R8X8_UNORM
; /* Robots needs 24bit to be WINED3DFMT_B8G8R8X8_UNORM */
3331 case 32: return WINED3DFMT_B8G8R8X8_UNORM
; /* EVE online and the Fur demo need 32bit AdapterDisplayMode to return WINED3DFMT_B8G8R8X8_UNORM */
3332 default: return WINED3DFMT_UNKNOWN
;
3336 void multiply_matrix(struct wined3d_matrix
*dest
, const struct wined3d_matrix
*src1
,
3337 const struct wined3d_matrix
*src2
)
3339 struct wined3d_matrix temp
;
3341 /* Now do the multiplication 'by hand'.
3342 I know that all this could be optimised, but this will be done later :-) */
3343 temp
.u
.s
._11
= (src1
->u
.s
._11
* src2
->u
.s
._11
) + (src1
->u
.s
._21
* src2
->u
.s
._12
) + (src1
->u
.s
._31
* src2
->u
.s
._13
) + (src1
->u
.s
._41
* src2
->u
.s
._14
);
3344 temp
.u
.s
._21
= (src1
->u
.s
._11
* src2
->u
.s
._21
) + (src1
->u
.s
._21
* src2
->u
.s
._22
) + (src1
->u
.s
._31
* src2
->u
.s
._23
) + (src1
->u
.s
._41
* src2
->u
.s
._24
);
3345 temp
.u
.s
._31
= (src1
->u
.s
._11
* src2
->u
.s
._31
) + (src1
->u
.s
._21
* src2
->u
.s
._32
) + (src1
->u
.s
._31
* src2
->u
.s
._33
) + (src1
->u
.s
._41
* src2
->u
.s
._34
);
3346 temp
.u
.s
._41
= (src1
->u
.s
._11
* src2
->u
.s
._41
) + (src1
->u
.s
._21
* src2
->u
.s
._42
) + (src1
->u
.s
._31
* src2
->u
.s
._43
) + (src1
->u
.s
._41
* src2
->u
.s
._44
);
3348 temp
.u
.s
._12
= (src1
->u
.s
._12
* src2
->u
.s
._11
) + (src1
->u
.s
._22
* src2
->u
.s
._12
) + (src1
->u
.s
._32
* src2
->u
.s
._13
) + (src1
->u
.s
._42
* src2
->u
.s
._14
);
3349 temp
.u
.s
._22
= (src1
->u
.s
._12
* src2
->u
.s
._21
) + (src1
->u
.s
._22
* src2
->u
.s
._22
) + (src1
->u
.s
._32
* src2
->u
.s
._23
) + (src1
->u
.s
._42
* src2
->u
.s
._24
);
3350 temp
.u
.s
._32
= (src1
->u
.s
._12
* src2
->u
.s
._31
) + (src1
->u
.s
._22
* src2
->u
.s
._32
) + (src1
->u
.s
._32
* src2
->u
.s
._33
) + (src1
->u
.s
._42
* src2
->u
.s
._34
);
3351 temp
.u
.s
._42
= (src1
->u
.s
._12
* src2
->u
.s
._41
) + (src1
->u
.s
._22
* src2
->u
.s
._42
) + (src1
->u
.s
._32
* src2
->u
.s
._43
) + (src1
->u
.s
._42
* src2
->u
.s
._44
);
3353 temp
.u
.s
._13
= (src1
->u
.s
._13
* src2
->u
.s
._11
) + (src1
->u
.s
._23
* src2
->u
.s
._12
) + (src1
->u
.s
._33
* src2
->u
.s
._13
) + (src1
->u
.s
._43
* src2
->u
.s
._14
);
3354 temp
.u
.s
._23
= (src1
->u
.s
._13
* src2
->u
.s
._21
) + (src1
->u
.s
._23
* src2
->u
.s
._22
) + (src1
->u
.s
._33
* src2
->u
.s
._23
) + (src1
->u
.s
._43
* src2
->u
.s
._24
);
3355 temp
.u
.s
._33
= (src1
->u
.s
._13
* src2
->u
.s
._31
) + (src1
->u
.s
._23
* src2
->u
.s
._32
) + (src1
->u
.s
._33
* src2
->u
.s
._33
) + (src1
->u
.s
._43
* src2
->u
.s
._34
);
3356 temp
.u
.s
._43
= (src1
->u
.s
._13
* src2
->u
.s
._41
) + (src1
->u
.s
._23
* src2
->u
.s
._42
) + (src1
->u
.s
._33
* src2
->u
.s
._43
) + (src1
->u
.s
._43
* src2
->u
.s
._44
);
3358 temp
.u
.s
._14
= (src1
->u
.s
._14
* src2
->u
.s
._11
) + (src1
->u
.s
._24
* src2
->u
.s
._12
) + (src1
->u
.s
._34
* src2
->u
.s
._13
) + (src1
->u
.s
._44
* src2
->u
.s
._14
);
3359 temp
.u
.s
._24
= (src1
->u
.s
._14
* src2
->u
.s
._21
) + (src1
->u
.s
._24
* src2
->u
.s
._22
) + (src1
->u
.s
._34
* src2
->u
.s
._23
) + (src1
->u
.s
._44
* src2
->u
.s
._24
);
3360 temp
.u
.s
._34
= (src1
->u
.s
._14
* src2
->u
.s
._31
) + (src1
->u
.s
._24
* src2
->u
.s
._32
) + (src1
->u
.s
._34
* src2
->u
.s
._33
) + (src1
->u
.s
._44
* src2
->u
.s
._34
);
3361 temp
.u
.s
._44
= (src1
->u
.s
._14
* src2
->u
.s
._41
) + (src1
->u
.s
._24
* src2
->u
.s
._42
) + (src1
->u
.s
._34
* src2
->u
.s
._43
) + (src1
->u
.s
._44
* src2
->u
.s
._44
);
3363 /* And copy the new matrix in the good storage.. */
3364 memcpy(dest
, &temp
, 16 * sizeof(float));
3367 DWORD
get_flexible_vertex_size(DWORD d3dvtVertexType
) {
3370 int numTextures
= (d3dvtVertexType
& WINED3DFVF_TEXCOUNT_MASK
) >> WINED3DFVF_TEXCOUNT_SHIFT
;
3372 if (d3dvtVertexType
& WINED3DFVF_NORMAL
) size
+= 3 * sizeof(float);
3373 if (d3dvtVertexType
& WINED3DFVF_DIFFUSE
) size
+= sizeof(DWORD
);
3374 if (d3dvtVertexType
& WINED3DFVF_SPECULAR
) size
+= sizeof(DWORD
);
3375 if (d3dvtVertexType
& WINED3DFVF_PSIZE
) size
+= sizeof(DWORD
);
3376 switch (d3dvtVertexType
& WINED3DFVF_POSITION_MASK
) {
3377 case WINED3DFVF_XYZ
: size
+= 3 * sizeof(float); break;
3378 case WINED3DFVF_XYZRHW
: size
+= 4 * sizeof(float); break;
3379 case WINED3DFVF_XYZB1
: size
+= 4 * sizeof(float); break;
3380 case WINED3DFVF_XYZB2
: size
+= 5 * sizeof(float); break;
3381 case WINED3DFVF_XYZB3
: size
+= 6 * sizeof(float); break;
3382 case WINED3DFVF_XYZB4
: size
+= 7 * sizeof(float); break;
3383 case WINED3DFVF_XYZB5
: size
+= 8 * sizeof(float); break;
3384 case WINED3DFVF_XYZW
: size
+= 4 * sizeof(float); break;
3385 default: ERR("Unexpected position mask\n");
3387 for (i
= 0; i
< numTextures
; i
++) {
3388 size
+= GET_TEXCOORD_SIZE_FROM_FVF(d3dvtVertexType
, i
) * sizeof(float);
3394 void gen_ffp_frag_op(const struct wined3d_context
*context
, const struct wined3d_state
*state
,
3395 struct ffp_frag_settings
*settings
, BOOL ignore_textype
)
3400 static const unsigned char args
[WINED3D_TOP_LERP
+ 1] =
3403 /* D3DTOP_DISABLE */ 0,
3404 /* D3DTOP_SELECTARG1 */ ARG1
,
3405 /* D3DTOP_SELECTARG2 */ ARG2
,
3406 /* D3DTOP_MODULATE */ ARG1
| ARG2
,
3407 /* D3DTOP_MODULATE2X */ ARG1
| ARG2
,
3408 /* D3DTOP_MODULATE4X */ ARG1
| ARG2
,
3409 /* D3DTOP_ADD */ ARG1
| ARG2
,
3410 /* D3DTOP_ADDSIGNED */ ARG1
| ARG2
,
3411 /* D3DTOP_ADDSIGNED2X */ ARG1
| ARG2
,
3412 /* D3DTOP_SUBTRACT */ ARG1
| ARG2
,
3413 /* D3DTOP_ADDSMOOTH */ ARG1
| ARG2
,
3414 /* D3DTOP_BLENDDIFFUSEALPHA */ ARG1
| ARG2
,
3415 /* D3DTOP_BLENDTEXTUREALPHA */ ARG1
| ARG2
,
3416 /* D3DTOP_BLENDFACTORALPHA */ ARG1
| ARG2
,
3417 /* D3DTOP_BLENDTEXTUREALPHAPM */ ARG1
| ARG2
,
3418 /* D3DTOP_BLENDCURRENTALPHA */ ARG1
| ARG2
,
3419 /* D3DTOP_PREMODULATE */ ARG1
| ARG2
,
3420 /* D3DTOP_MODULATEALPHA_ADDCOLOR */ ARG1
| ARG2
,
3421 /* D3DTOP_MODULATECOLOR_ADDALPHA */ ARG1
| ARG2
,
3422 /* D3DTOP_MODULATEINVALPHA_ADDCOLOR */ ARG1
| ARG2
,
3423 /* D3DTOP_MODULATEINVCOLOR_ADDALPHA */ ARG1
| ARG2
,
3424 /* D3DTOP_BUMPENVMAP */ ARG1
| ARG2
,
3425 /* D3DTOP_BUMPENVMAPLUMINANCE */ ARG1
| ARG2
,
3426 /* D3DTOP_DOTPRODUCT3 */ ARG1
| ARG2
,
3427 /* D3DTOP_MULTIPLYADD */ ARG1
| ARG2
| ARG0
,
3428 /* D3DTOP_LERP */ ARG1
| ARG2
| ARG0
3432 DWORD cop
, aop
, carg0
, carg1
, carg2
, aarg0
, aarg1
, aarg2
;
3433 const struct wined3d_format
*rt_format
= state
->fb
->render_targets
[0]->format
;
3434 const struct wined3d_gl_info
*gl_info
= context
->gl_info
;
3435 const struct wined3d_d3d_info
*d3d_info
= context
->d3d_info
;
3437 for (i
= 0; i
< d3d_info
->limits
.ffp_blend_stages
; ++i
)
3439 const struct wined3d_texture
*texture
;
3441 settings
->op
[i
].padding
= 0;
3442 if (state
->texture_states
[i
][WINED3D_TSS_COLOR_OP
] == WINED3D_TOP_DISABLE
)
3444 settings
->op
[i
].cop
= WINED3D_TOP_DISABLE
;
3445 settings
->op
[i
].aop
= WINED3D_TOP_DISABLE
;
3446 settings
->op
[i
].carg0
= settings
->op
[i
].carg1
= settings
->op
[i
].carg2
= ARG_UNUSED
;
3447 settings
->op
[i
].aarg0
= settings
->op
[i
].aarg1
= settings
->op
[i
].aarg2
= ARG_UNUSED
;
3448 settings
->op
[i
].color_fixup
= COLOR_FIXUP_IDENTITY
;
3449 settings
->op
[i
].dst
= resultreg
;
3450 settings
->op
[i
].tex_type
= tex_1d
;
3451 settings
->op
[i
].projected
= proj_none
;
3456 if ((texture
= state
->textures
[i
]))
3458 settings
->op
[i
].color_fixup
= texture
->resource
.format
->color_fixup
;
3461 settings
->op
[i
].tex_type
= tex_1d
;
3465 switch (texture
->target
)
3468 settings
->op
[i
].tex_type
= tex_1d
;
3471 settings
->op
[i
].tex_type
= tex_2d
;
3474 settings
->op
[i
].tex_type
= tex_3d
;
3476 case GL_TEXTURE_CUBE_MAP_ARB
:
3477 settings
->op
[i
].tex_type
= tex_cube
;
3479 case GL_TEXTURE_RECTANGLE_ARB
:
3480 settings
->op
[i
].tex_type
= tex_rect
;
3485 settings
->op
[i
].color_fixup
= COLOR_FIXUP_IDENTITY
;
3486 settings
->op
[i
].tex_type
= tex_1d
;
3489 cop
= state
->texture_states
[i
][WINED3D_TSS_COLOR_OP
];
3490 aop
= state
->texture_states
[i
][WINED3D_TSS_ALPHA_OP
];
3492 carg1
= (args
[cop
] & ARG1
) ? state
->texture_states
[i
][WINED3D_TSS_COLOR_ARG1
] : ARG_UNUSED
;
3493 carg2
= (args
[cop
] & ARG2
) ? state
->texture_states
[i
][WINED3D_TSS_COLOR_ARG2
] : ARG_UNUSED
;
3494 carg0
= (args
[cop
] & ARG0
) ? state
->texture_states
[i
][WINED3D_TSS_COLOR_ARG0
] : ARG_UNUSED
;
3496 if (is_invalid_op(state
, i
, cop
, carg1
, carg2
, carg0
))
3500 carg1
= WINED3DTA_CURRENT
;
3501 cop
= WINED3D_TOP_SELECT_ARG1
;
3504 if (cop
== WINED3D_TOP_DOTPRODUCT3
)
3506 /* A dotproduct3 on the colorop overwrites the alphaop operation and replicates
3507 * the color result to the alpha component of the destination
3516 aarg1
= (args
[aop
] & ARG1
) ? state
->texture_states
[i
][WINED3D_TSS_ALPHA_ARG1
] : ARG_UNUSED
;
3517 aarg2
= (args
[aop
] & ARG2
) ? state
->texture_states
[i
][WINED3D_TSS_ALPHA_ARG2
] : ARG_UNUSED
;
3518 aarg0
= (args
[aop
] & ARG0
) ? state
->texture_states
[i
][WINED3D_TSS_ALPHA_ARG0
] : ARG_UNUSED
;
3521 if (!i
&& state
->textures
[0] && state
->render_states
[WINED3D_RS_COLORKEYENABLE
])
3523 GLenum texture_dimensions
;
3525 texture
= state
->textures
[0];
3526 texture_dimensions
= texture
->target
;
3528 if (texture_dimensions
== GL_TEXTURE_2D
|| texture_dimensions
== GL_TEXTURE_RECTANGLE_ARB
)
3530 if (texture
->color_key_flags
& WINED3D_CKEY_SRC_BLT
&& !texture
->resource
.format
->alpha_size
)
3532 if (aop
== WINED3D_TOP_DISABLE
)
3534 aarg1
= WINED3DTA_TEXTURE
;
3535 aop
= WINED3D_TOP_SELECT_ARG1
;
3537 else if (aop
== WINED3D_TOP_SELECT_ARG1
&& aarg1
!= WINED3DTA_TEXTURE
)
3539 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3541 aarg2
= WINED3DTA_TEXTURE
;
3542 aop
= WINED3D_TOP_MODULATE
;
3544 else aarg1
= WINED3DTA_TEXTURE
;
3546 else if (aop
== WINED3D_TOP_SELECT_ARG2
&& aarg2
!= WINED3DTA_TEXTURE
)
3548 if (state
->render_states
[WINED3D_RS_ALPHABLENDENABLE
])
3550 aarg1
= WINED3DTA_TEXTURE
;
3551 aop
= WINED3D_TOP_MODULATE
;
3553 else aarg2
= WINED3DTA_TEXTURE
;
3559 if (is_invalid_op(state
, i
, aop
, aarg1
, aarg2
, aarg0
))
3563 aarg1
= WINED3DTA_CURRENT
;
3564 aop
= WINED3D_TOP_SELECT_ARG1
;
3567 if (carg1
== WINED3DTA_TEXTURE
|| carg2
== WINED3DTA_TEXTURE
|| carg0
== WINED3DTA_TEXTURE
3568 || aarg1
== WINED3DTA_TEXTURE
|| aarg2
== WINED3DTA_TEXTURE
|| aarg0
== WINED3DTA_TEXTURE
)
3570 ttff
= state
->texture_states
[i
][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS
];
3571 if (ttff
== (WINED3D_TTFF_PROJECTED
| WINED3D_TTFF_COUNT3
))
3572 settings
->op
[i
].projected
= proj_count3
;
3573 else if (ttff
& WINED3D_TTFF_PROJECTED
)
3574 settings
->op
[i
].projected
= proj_count4
;
3576 settings
->op
[i
].projected
= proj_none
;
3580 settings
->op
[i
].projected
= proj_none
;
3583 settings
->op
[i
].cop
= cop
;
3584 settings
->op
[i
].aop
= aop
;
3585 settings
->op
[i
].carg0
= carg0
;
3586 settings
->op
[i
].carg1
= carg1
;
3587 settings
->op
[i
].carg2
= carg2
;
3588 settings
->op
[i
].aarg0
= aarg0
;
3589 settings
->op
[i
].aarg1
= aarg1
;
3590 settings
->op
[i
].aarg2
= aarg2
;
3592 if (state
->texture_states
[i
][WINED3D_TSS_RESULT_ARG
] == WINED3DTA_TEMP
)
3593 settings
->op
[i
].dst
= tempreg
;
3595 settings
->op
[i
].dst
= resultreg
;
3598 /* Clear unsupported stages */
3599 for(; i
< MAX_TEXTURES
; i
++) {
3600 memset(&settings
->op
[i
], 0xff, sizeof(settings
->op
[i
]));
3603 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
3605 settings
->fog
= WINED3D_FFP_PS_FOG_OFF
;
3607 else if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] == WINED3D_FOG_NONE
)
3609 if (use_vs(state
) || state
->vertex_declaration
->position_transformed
)
3611 settings
->fog
= WINED3D_FFP_PS_FOG_LINEAR
;
3615 switch (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
])
3617 case WINED3D_FOG_NONE
:
3618 case WINED3D_FOG_LINEAR
:
3619 settings
->fog
= WINED3D_FFP_PS_FOG_LINEAR
;
3621 case WINED3D_FOG_EXP
:
3622 settings
->fog
= WINED3D_FFP_PS_FOG_EXP
;
3624 case WINED3D_FOG_EXP2
:
3625 settings
->fog
= WINED3D_FFP_PS_FOG_EXP2
;
3632 switch (state
->render_states
[WINED3D_RS_FOGTABLEMODE
])
3634 case WINED3D_FOG_LINEAR
:
3635 settings
->fog
= WINED3D_FFP_PS_FOG_LINEAR
;
3637 case WINED3D_FOG_EXP
:
3638 settings
->fog
= WINED3D_FFP_PS_FOG_EXP
;
3640 case WINED3D_FOG_EXP2
:
3641 settings
->fog
= WINED3D_FFP_PS_FOG_EXP2
;
3645 if (!gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
]
3646 && state
->render_states
[WINED3D_RS_SRGBWRITEENABLE
]
3647 && rt_format
->flags
& WINED3DFMT_FLAG_SRGB_WRITE
)
3649 settings
->sRGB_write
= 1;
3651 settings
->sRGB_write
= 0;
3653 if (d3d_info
->vs_clipping
|| !use_vs(state
) || !state
->render_states
[WINED3D_RS_CLIPPING
]
3654 || !state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
])
3656 /* No need to emulate clipplanes if GL supports native vertex shader clipping or if
3657 * the fixed function vertex pipeline is used(which always supports clipplanes), or
3658 * if no clipplane is enabled
3660 settings
->emul_clipplanes
= 0;
3662 settings
->emul_clipplanes
= 1;
3666 const struct ffp_frag_desc
*find_ffp_frag_shader(const struct wine_rb_tree
*fragment_shaders
,
3667 const struct ffp_frag_settings
*settings
)
3669 struct wine_rb_entry
*entry
= wine_rb_get(fragment_shaders
, settings
);
3670 return entry
? WINE_RB_ENTRY_VALUE(entry
, struct ffp_frag_desc
, entry
) : NULL
;
3673 void add_ffp_frag_shader(struct wine_rb_tree
*shaders
, struct ffp_frag_desc
*desc
)
3675 /* Note that the key is the implementation independent part of the ffp_frag_desc structure,
3676 * whereas desc points to an extended structure with implementation specific parts. */
3677 if (wine_rb_put(shaders
, &desc
->settings
, &desc
->entry
) == -1)
3679 ERR("Failed to insert ffp frag shader.\n");
3683 /* Activates the texture dimension according to the bound D3D texture. Does
3684 * not care for the colorop or correct gl texture unit (when using nvrc).
3685 * Requires the caller to activate the correct unit. */
3686 /* Context activation is done by the caller (state handler). */
3687 void texture_activate_dimensions(const struct wined3d_texture
*texture
, const struct wined3d_gl_info
*gl_info
)
3691 switch (texture
->target
)
3694 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3695 checkGLcall("glDisable(GL_TEXTURE_3D)");
3696 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3698 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3699 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3701 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3703 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3704 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3706 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_2D
);
3707 checkGLcall("glEnable(GL_TEXTURE_2D)");
3709 case GL_TEXTURE_RECTANGLE_ARB
:
3710 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3711 checkGLcall("glDisable(GL_TEXTURE_2D)");
3712 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3713 checkGLcall("glDisable(GL_TEXTURE_3D)");
3714 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3716 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3717 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3719 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_RECTANGLE_ARB
);
3720 checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)");
3723 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3725 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3726 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3728 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3730 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3731 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3733 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3734 checkGLcall("glDisable(GL_TEXTURE_2D)");
3735 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_3D
);
3736 checkGLcall("glEnable(GL_TEXTURE_3D)");
3738 case GL_TEXTURE_CUBE_MAP_ARB
:
3739 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_2D
);
3740 checkGLcall("glDisable(GL_TEXTURE_2D)");
3741 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3742 checkGLcall("glDisable(GL_TEXTURE_3D)");
3743 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3745 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3746 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3748 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_CUBE_MAP_ARB
);
3749 checkGLcall("glEnable(GL_TEXTURE_CUBE_MAP_ARB)");
3755 gl_info
->gl_ops
.gl
.p_glEnable(GL_TEXTURE_2D
);
3756 checkGLcall("glEnable(GL_TEXTURE_2D)");
3757 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_3D
);
3758 checkGLcall("glDisable(GL_TEXTURE_3D)");
3759 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3761 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_CUBE_MAP_ARB
);
3762 checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)");
3764 if (gl_info
->supported
[ARB_TEXTURE_RECTANGLE
])
3766 gl_info
->gl_ops
.gl
.p_glDisable(GL_TEXTURE_RECTANGLE_ARB
);
3767 checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)");
3769 /* Binding textures is done by samplers. A dummy texture will be bound */
3773 /* Context activation is done by the caller (state handler). */
3774 void sampler_texdim(struct wined3d_context
*context
, const struct wined3d_state
*state
, DWORD state_id
)
3776 DWORD sampler
= state_id
- STATE_SAMPLER(0);
3777 DWORD mapped_stage
= context
->tex_unit_map
[sampler
];
3779 /* No need to enable / disable anything here for unused samplers. The
3780 * tex_colorop handler takes care. Also no action is needed with pixel
3781 * shaders, or if tex_colorop will take care of this business. */
3782 if (mapped_stage
== WINED3D_UNMAPPED_STAGE
|| mapped_stage
>= context
->gl_info
->limits
.textures
)
3784 if (sampler
>= context
->lowest_disabled_stage
)
3786 if (isStateDirty(context
, STATE_TEXTURESTAGE(sampler
, WINED3D_TSS_COLOR_OP
)))
3789 texture_activate_dimensions(state
->textures
[sampler
], context
->gl_info
);
3792 void *wined3d_rb_alloc(size_t size
)
3794 return HeapAlloc(GetProcessHeap(), 0, size
);
3797 void *wined3d_rb_realloc(void *ptr
, size_t size
)
3799 return HeapReAlloc(GetProcessHeap(), 0, ptr
, size
);
3802 void wined3d_rb_free(void *ptr
)
3804 HeapFree(GetProcessHeap(), 0, ptr
);
3807 static int ffp_frag_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
)
3809 const struct ffp_frag_settings
*ka
= key
;
3810 const struct ffp_frag_settings
*kb
= &WINE_RB_ENTRY_VALUE(entry
, const struct ffp_frag_desc
, entry
)->settings
;
3812 return memcmp(ka
, kb
, sizeof(*ka
));
3815 const struct wine_rb_functions wined3d_ffp_frag_program_rb_functions
=
3820 ffp_frag_program_key_compare
,
3823 void wined3d_ffp_get_vs_settings(const struct wined3d_state
*state
, const struct wined3d_stream_info
*si
,
3824 struct wined3d_ffp_vs_settings
*settings
)
3826 unsigned int coord_idx
, i
;
3828 if (si
->position_transformed
)
3830 memset(settings
, 0, sizeof(*settings
));
3832 settings
->transformed
= 1;
3833 settings
->point_size
= state
->gl_primitive_type
== GL_POINTS
;
3834 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
3835 settings
->fog_mode
= WINED3D_FFP_VS_FOG_OFF
;
3836 else if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
3837 settings
->fog_mode
= WINED3D_FFP_VS_FOG_DEPTH
;
3839 settings
->fog_mode
= WINED3D_FFP_VS_FOG_FOGCOORD
;
3841 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
3843 coord_idx
= state
->texture_states
[i
][WINED3D_TSS_TEXCOORD_INDEX
];
3844 if (coord_idx
< MAX_TEXTURES
&& (si
->use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coord_idx
))))
3845 settings
->texcoords
|= 1 << i
;
3846 settings
->texgen
[i
] = (state
->texture_states
[i
][WINED3D_TSS_TEXCOORD_INDEX
] >> WINED3D_FFP_TCI_SHIFT
)
3847 & WINED3D_FFP_TCI_MASK
;
3852 settings
->transformed
= 0;
3853 settings
->clipping
= state
->render_states
[WINED3D_RS_CLIPPING
]
3854 && state
->render_states
[WINED3D_RS_CLIPPLANEENABLE
];
3855 settings
->normal
= !!(si
->use_map
& (1 << WINED3D_FFP_NORMAL
));
3856 settings
->normalize
= settings
->normal
&& state
->render_states
[WINED3D_RS_NORMALIZENORMALS
];
3857 settings
->lighting
= !!state
->render_states
[WINED3D_RS_LIGHTING
];
3858 settings
->localviewer
= !!state
->render_states
[WINED3D_RS_LOCALVIEWER
];
3859 settings
->point_size
= state
->gl_primitive_type
== GL_POINTS
;
3861 if (state
->render_states
[WINED3D_RS_COLORVERTEX
] && (si
->use_map
& (1 << WINED3D_FFP_DIFFUSE
)))
3863 settings
->diffuse_source
= state
->render_states
[WINED3D_RS_DIFFUSEMATERIALSOURCE
];
3864 settings
->emission_source
= state
->render_states
[WINED3D_RS_EMISSIVEMATERIALSOURCE
];
3865 settings
->ambient_source
= state
->render_states
[WINED3D_RS_AMBIENTMATERIALSOURCE
];
3866 settings
->specular_source
= state
->render_states
[WINED3D_RS_SPECULARMATERIALSOURCE
];
3870 settings
->diffuse_source
= WINED3D_MCS_MATERIAL
;
3871 settings
->emission_source
= WINED3D_MCS_MATERIAL
;
3872 settings
->ambient_source
= WINED3D_MCS_MATERIAL
;
3873 settings
->specular_source
= WINED3D_MCS_MATERIAL
;
3876 settings
->texcoords
= 0;
3877 for (i
= 0; i
< MAX_TEXTURES
; ++i
)
3879 coord_idx
= state
->texture_states
[i
][WINED3D_TSS_TEXCOORD_INDEX
];
3880 if (coord_idx
< MAX_TEXTURES
&& (si
->use_map
& (1 << (WINED3D_FFP_TEXCOORD0
+ coord_idx
))))
3881 settings
->texcoords
|= 1 << i
;
3882 settings
->texgen
[i
] = (state
->texture_states
[i
][WINED3D_TSS_TEXCOORD_INDEX
] >> WINED3D_FFP_TCI_SHIFT
)
3883 & WINED3D_FFP_TCI_MASK
;
3886 settings
->light_type
= 0;
3887 for (i
= 0; i
< MAX_ACTIVE_LIGHTS
; ++i
)
3889 if (state
->lights
[i
])
3890 settings
->light_type
|= (state
->lights
[i
]->OriginalParms
.type
3891 & WINED3D_FFP_LIGHT_TYPE_MASK
) << WINED3D_FFP_LIGHT_TYPE_SHIFT(i
);
3894 settings
->ortho_fog
= 0;
3895 if (!state
->render_states
[WINED3D_RS_FOGENABLE
])
3896 settings
->fog_mode
= WINED3D_FFP_VS_FOG_OFF
;
3897 else if (state
->render_states
[WINED3D_RS_FOGTABLEMODE
] != WINED3D_FOG_NONE
)
3899 settings
->fog_mode
= WINED3D_FFP_VS_FOG_DEPTH
;
3901 if (state
->transforms
[WINED3D_TS_PROJECTION
].u
.m
[0][3] == 0.0f
3902 && state
->transforms
[WINED3D_TS_PROJECTION
].u
.m
[1][3] == 0.0f
3903 && state
->transforms
[WINED3D_TS_PROJECTION
].u
.m
[2][3] == 0.0f
3904 && state
->transforms
[WINED3D_TS_PROJECTION
].u
.m
[3][3] == 1.0f
)
3905 settings
->ortho_fog
= 1;
3907 else if (state
->render_states
[WINED3D_RS_FOGVERTEXMODE
] == WINED3D_FOG_NONE
)
3908 settings
->fog_mode
= WINED3D_FFP_VS_FOG_FOGCOORD
;
3909 else if (state
->render_states
[WINED3D_RS_RANGEFOGENABLE
])
3910 settings
->fog_mode
= WINED3D_FFP_VS_FOG_RANGE
;
3912 settings
->fog_mode
= WINED3D_FFP_VS_FOG_DEPTH
;
3914 settings
->padding
= 0;
3917 static int wined3d_ffp_vertex_program_key_compare(const void *key
, const struct wine_rb_entry
*entry
)
3919 const struct wined3d_ffp_vs_settings
*ka
= key
;
3920 const struct wined3d_ffp_vs_settings
*kb
= &WINE_RB_ENTRY_VALUE(entry
,
3921 const struct wined3d_ffp_vs_desc
, entry
)->settings
;
3923 return memcmp(ka
, kb
, sizeof(*ka
));
3926 const struct wine_rb_functions wined3d_ffp_vertex_program_rb_functions
=
3931 wined3d_ffp_vertex_program_key_compare
,
3934 const struct blit_shader
*wined3d_select_blitter(const struct wined3d_gl_info
*gl_info
, enum wined3d_blit_op blit_op
,
3935 const RECT
*src_rect
, DWORD src_usage
, enum wined3d_pool src_pool
, const struct wined3d_format
*src_format
,
3936 const RECT
*dst_rect
, DWORD dst_usage
, enum wined3d_pool dst_pool
, const struct wined3d_format
*dst_format
)
3938 static const struct blit_shader
* const blitters
[] =
3946 for (i
= 0; i
< sizeof(blitters
) / sizeof(*blitters
); ++i
)
3948 if (blitters
[i
]->blit_supported(gl_info
, blit_op
,
3949 src_rect
, src_usage
, src_pool
, src_format
,
3950 dst_rect
, dst_usage
, dst_pool
, dst_format
))
3957 void wined3d_get_draw_rect(const struct wined3d_state
*state
, RECT
*rect
)
3959 const struct wined3d_viewport
*vp
= &state
->viewport
;
3961 SetRect(rect
, vp
->x
, vp
->y
, vp
->x
+ vp
->width
, vp
->y
+ vp
->height
);
3963 if (state
->render_states
[WINED3D_RS_SCISSORTESTENABLE
])
3964 IntersectRect(rect
, rect
, &state
->scissor_rect
);
3967 const char *wined3d_debug_location(DWORD location
)
3972 #define LOCATION_TO_STR(u) if (location & u) { strcat(buf, " | "#u); location &= ~u; }
3973 LOCATION_TO_STR(WINED3D_LOCATION_DISCARDED
);
3974 LOCATION_TO_STR(WINED3D_LOCATION_SYSMEM
);
3975 LOCATION_TO_STR(WINED3D_LOCATION_USER_MEMORY
);
3976 LOCATION_TO_STR(WINED3D_LOCATION_DIB
);
3977 LOCATION_TO_STR(WINED3D_LOCATION_BUFFER
);
3978 LOCATION_TO_STR(WINED3D_LOCATION_TEXTURE_RGB
);
3979 LOCATION_TO_STR(WINED3D_LOCATION_TEXTURE_SRGB
);
3980 LOCATION_TO_STR(WINED3D_LOCATION_DRAWABLE
);
3981 LOCATION_TO_STR(WINED3D_LOCATION_RB_MULTISAMPLE
);
3982 LOCATION_TO_STR(WINED3D_LOCATION_RB_RESOLVED
);
3983 #undef LOCATION_TO_STR
3984 if (location
) FIXME("Unrecognized location flag(s) %#x.\n", location
);
3986 return buf
[0] ? wine_dbg_sprintf("%s", &buf
[3]) : "0";
3989 /* Print a floating point value with the %.8e format specifier, always using
3990 * '.' as decimal separator. */
3991 void wined3d_ftoa(float value
, char *s
)
3995 if (copysignf(1.0f
, value
) < 0.0f
)
3998 /* Be sure to allocate a buffer of at least 17 characters for the result
3999 as sprintf may return a 3 digit exponent when using the MSVC runtime
4000 instead of a 2 digit exponent. */
4001 sprintf(s
, "%.8e", value
);
4002 if (isfinite(value
))
4006 void wined3d_release_dc(HWND window
, HDC dc
)
4008 /* You'd figure ReleaseDC() would fail if the DC doesn't match the window.
4009 * However, that's not what actually happens, and there are user32 tests
4010 * that confirm ReleaseDC() with the wrong window is supposed to succeed.
4011 * So explicitly check that the DC belongs to the window, since we want to
4012 * avoid releasing a DC that belongs to some other window if the original
4013 * window was already destroyed. */
4014 if (WindowFromDC(dc
) != window
)
4015 WARN("DC %p does not belong to window %p.\n", dc
, window
);
4016 else if (!ReleaseDC(window
, dc
))
4017 ERR("Failed to release device context %p, last error %#x.\n", dc
, GetLastError());