2 * Copyright 2002-2004 Jason Edmeades
3 * Copyright 2003-2004 Raphael Junqueira
4 * Copyright 2004 Christian Costa
5 * Copyright 2005 Oliver Stieber
6 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
7 * Copyright 2009-2011, 2018 Henri Verbeet for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wined3d_private.h"
27 #include "wined3d_gl.h"
29 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
30 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf
);
31 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
33 enum wined3d_gl_vendor
42 struct wined3d_extension_map
44 const char *extension_string
;
45 enum wined3d_gl_extension extension
;
48 static const struct wined3d_extension_map gl_extension_map
[] =
51 {"GL_APPLE_fence", APPLE_FENCE
},
52 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
},
53 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
},
54 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER
},
55 {"GL_APPLE_rgb_422", APPLE_RGB_422
},
56 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
},
59 {"GL_ARB_base_instance", ARB_BASE_INSTANCE
},
60 {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED
},
61 {"GL_ARB_buffer_storage", ARB_BUFFER_STORAGE
},
62 {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT
},
63 {"GL_ARB_clear_texture", ARB_CLEAR_TEXTURE
},
64 {"GL_ARB_clip_control", ARB_CLIP_CONTROL
},
65 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
},
66 {"GL_ARB_compute_shader", ARB_COMPUTE_SHADER
},
67 {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH
},
68 {"GL_ARB_copy_buffer", ARB_COPY_BUFFER
},
69 {"GL_ARB_copy_image", ARB_COPY_IMAGE
},
70 {"GL_ARB_cull_distance", ARB_CULL_DISTANCE
},
71 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT
},
72 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
},
73 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
},
74 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
},
75 {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL
},
76 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
},
77 {"GL_ARB_draw_buffers_blend", ARB_DRAW_BUFFERS_BLEND
},
78 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
},
79 {"GL_ARB_draw_indirect", ARB_DRAW_INDIRECT
},
80 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED
},
81 {"GL_ARB_ES2_compatibility", ARB_ES2_COMPATIBILITY
},
82 {"GL_ARB_ES3_compatibility", ARB_ES3_COMPATIBILITY
},
83 {"GL_ARB_explicit_attrib_location", ARB_EXPLICIT_ATTRIB_LOCATION
},
84 {"GL_ARB_fragment_coord_conventions", ARB_FRAGMENT_COORD_CONVENTIONS
},
85 {"GL_ARB_fragment_layer_viewport", ARB_FRAGMENT_LAYER_VIEWPORT
},
86 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
},
87 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
},
88 {"GL_ARB_framebuffer_no_attachments", ARB_FRAMEBUFFER_NO_ATTACHMENTS
},
89 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
},
90 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB
},
91 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
},
92 {"GL_ARB_gpu_shader5", ARB_GPU_SHADER5
},
93 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
},
94 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
},
95 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS
},
96 {"GL_ARB_internalformat_query", ARB_INTERNALFORMAT_QUERY
},
97 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2
},
98 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT
},
99 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
},
100 {"GL_ARB_multisample", ARB_MULTISAMPLE
},
101 {"GL_ARB_multitexture", ARB_MULTITEXTURE
},
102 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
},
103 {"GL_ARB_pipeline_statistics_query", ARB_PIPELINE_STATISTICS_QUERY
},
104 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
},
105 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
},
106 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
},
107 {"GL_ARB_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP
},
108 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
},
109 {"GL_ARB_query_buffer_object", ARB_QUERY_BUFFER_OBJECT
},
110 {"GL_ARB_sample_shading", ARB_SAMPLE_SHADING
},
111 {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS
},
112 {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP
},
113 {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS
},
114 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING
},
115 {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE
},
116 {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE
},
117 {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT
},
118 {"GL_ARB_shader_texture_image_samples", ARB_SHADER_TEXTURE_IMAGE_SAMPLES
},
119 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
},
120 {"GL_ARB_shader_viewport_layer_array", ARB_SHADER_VIEWPORT_LAYER_ARRAY
},
121 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
},
122 {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK
},
123 {"GL_ARB_shading_language_packing", ARB_SHADING_LANGUAGE_PACKING
},
124 {"GL_ARB_shadow", ARB_SHADOW
},
125 {"GL_ARB_stencil_texturing", ARB_STENCIL_TEXTURING
},
126 {"GL_ARB_sync", ARB_SYNC
},
127 {"GL_ARB_tessellation_shader", ARB_TESSELLATION_SHADER
},
128 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
},
129 {"GL_ARB_texture_buffer_object", ARB_TEXTURE_BUFFER_OBJECT
},
130 {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE
},
131 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
},
132 {"GL_ARB_texture_compression_bptc", ARB_TEXTURE_COMPRESSION_BPTC
},
133 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
},
134 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
},
135 {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY
},
136 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
},
137 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
},
138 {"GL_ARB_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC
},
139 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
},
140 {"GL_ARB_texture_gather", ARB_TEXTURE_GATHER
},
141 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
},
142 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
},
143 {"GL_ARB_texture_multisample", ARB_TEXTURE_MULTISAMPLE
},
144 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
},
145 {"GL_ARB_texture_query_levels", ARB_TEXTURE_QUERY_LEVELS
},
146 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
},
147 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
},
148 {"GL_ARB_texture_rgb10_a2ui", ARB_TEXTURE_RGB10_A2UI
},
149 {"GL_ARB_texture_storage", ARB_TEXTURE_STORAGE
},
150 {"GL_ARB_texture_storage_multisample", ARB_TEXTURE_STORAGE_MULTISAMPLE
},
151 {"GL_ARB_texture_swizzle", ARB_TEXTURE_SWIZZLE
},
152 {"GL_ARB_texture_view", ARB_TEXTURE_VIEW
},
153 {"GL_ARB_timer_query", ARB_TIMER_QUERY
},
154 {"GL_ARB_transform_feedback2", ARB_TRANSFORM_FEEDBACK2
},
155 {"GL_ARB_transform_feedback3", ARB_TRANSFORM_FEEDBACK3
},
156 {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT
},
157 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
},
158 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
},
159 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
},
160 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
},
161 {"GL_ARB_vertex_type_10f_11f_11f_rev", ARB_VERTEX_TYPE_10F_11F_11F_REV
},
162 {"GL_ARB_vertex_type_2_10_10_10_rev", ARB_VERTEX_TYPE_2_10_10_10_REV
},
163 {"GL_ARB_viewport_array", ARB_VIEWPORT_ARRAY
},
164 {"GL_ARB_texture_barrier", ARB_TEXTURE_BARRIER
},
167 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
},
168 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
},
169 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
},
170 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
},
171 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
},
174 {"GL_EXT_blend_color", EXT_BLEND_COLOR
},
175 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
},
176 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
},
177 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
},
178 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
},
179 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
},
180 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
},
181 {"GL_EXT_fog_coord", EXT_FOG_COORD
},
182 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
},
183 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
},
184 {"GL_EXT_framebuffer_multisample_blit_scaled",
185 EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED
},
186 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
},
187 {"GL_EXT_memory_object", EXT_MEMORY_OBJECT
},
188 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
},
189 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
},
190 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
},
191 {"GL_EXT_packed_float", EXT_PACKED_FLOAT
},
192 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
},
193 {"GL_EXT_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP
},
194 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
},
195 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
},
196 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
},
197 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
},
198 {"GL_EXT_texture3D", EXT_TEXTURE3D
},
199 {"GL_EXT_texture_array", EXT_TEXTURE_ARRAY
},
200 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
},
201 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
},
202 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
},
203 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
},
204 {"GL_EXT_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC
},
205 {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER
},
206 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
},
207 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP
},
208 {"GL_EXT_texture_shadow_lod", EXT_TEXTURE_SHADOW_LOD
},
209 {"GL_EXT_texture_shared_exponent", EXT_TEXTURE_SHARED_EXPONENT
},
210 {"GL_EXT_texture_snorm", EXT_TEXTURE_SNORM
},
211 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
},
212 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
},
213 {"GL_EXT_texture_swizzle", ARB_TEXTURE_SWIZZLE
},
214 {"GL_EXT_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
},
217 {"GL_NV_fence", NV_FENCE
},
218 {"GL_NV_fog_distance", NV_FOG_DISTANCE
},
219 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
},
220 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
},
221 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
},
222 {"GL_NV_half_float", NV_HALF_FLOAT
},
223 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
},
224 {"GL_NV_point_sprite", NV_POINT_SPRITE
},
225 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
},
226 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
},
227 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
},
228 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
},
229 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
},
230 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
},
231 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
},
232 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
},
233 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
},
234 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
},
235 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
},
236 {"GL_NV_texture_barrier", NV_TEXTURE_BARRIER
},
239 static const struct wined3d_extension_map wgl_extension_map
[] =
241 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT
},
242 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL
},
243 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
},
244 {"WGL_WINE_query_renderer", WGL_WINE_QUERY_RENDERER
},
247 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx
*ctx
)
249 const struct wined3d_gl_info
*gl_info
= ctx
->gl_info
;
251 TRACE("Destroying caps GL context.\n");
253 /* Both glDeleteProgram and glDeleteBuffers silently ignore 0 IDs but
254 * this function might be called before the relevant function pointers
255 * in gl_info are initialized. */
256 if (ctx
->test_program_id
|| ctx
->test_vbo
)
258 GL_EXTCALL(glDeleteProgram(ctx
->test_program_id
));
259 GL_EXTCALL(glDeleteBuffers(1, &ctx
->test_vbo
));
262 if (!wglMakeCurrent(NULL
, NULL
))
263 ERR("Failed to disable caps GL context.\n");
265 if (!wglDeleteContext(ctx
->gl_ctx
))
267 unsigned int err
= GetLastError();
268 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
271 wined3d_release_dc(ctx
->wnd
, ctx
->dc
);
272 DestroyWindow(ctx
->wnd
);
274 if (ctx
->restore_gl_ctx
&& !wglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
275 ERR("Failed to restore previous GL context.\n");
278 static BOOL
wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx
*caps_gl_ctx
,
279 struct wined3d_gl_info
*gl_info
)
283 if (!(gl_info
->p_wglCreateContextAttribsARB
= (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
286 if (!(new_ctx
= context_create_wgl_attribs(gl_info
, caps_gl_ctx
->dc
, NULL
)))
288 gl_info
->p_wglCreateContextAttribsARB
= NULL
;
292 if (!wglMakeCurrent(caps_gl_ctx
->dc
, new_ctx
))
294 ERR("Failed to make new context current, last error %#lx.\n", GetLastError());
295 if (!wglDeleteContext(new_ctx
))
296 ERR("Failed to delete new context, last error %#lx.\n", GetLastError());
297 gl_info
->p_wglCreateContextAttribsARB
= NULL
;
301 if (!wglDeleteContext(caps_gl_ctx
->gl_ctx
))
302 ERR("Failed to delete old context, last error %#lx.\n", GetLastError());
303 caps_gl_ctx
->gl_ctx
= new_ctx
;
308 static BOOL
wined3d_caps_gl_ctx_create(struct wined3d_adapter_gl
*adapter_gl
, struct wined3d_caps_gl_ctx
*ctx
)
310 PIXELFORMATDESCRIPTOR pfd
;
313 TRACE("getting context...\n");
315 ctx
->restore_dc
= wglGetCurrentDC();
316 ctx
->restore_gl_ctx
= wglGetCurrentContext();
318 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
319 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
320 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
323 ERR("Failed to create a window.\n");
327 ctx
->dc
= GetDC(ctx
->wnd
);
330 ERR("Failed to get a DC.\n");
334 /* PixelFormat selection */
335 ZeroMemory(&pfd
, sizeof(pfd
));
336 pfd
.nSize
= sizeof(pfd
);
338 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
339 pfd
.iPixelType
= PFD_TYPE_RGBA
;
341 pfd
.iLayerType
= PFD_MAIN_PLANE
;
343 if (!(iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
)))
345 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
346 ERR("Failed to find a suitable pixel format.\n");
349 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
350 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
352 /* Create a GL context. */
353 if (!(ctx
->gl_ctx
= wglCreateContext(ctx
->dc
)))
355 WARN("Failed to create default context for capabilities initialization.\n");
359 /* Make it the current GL context. */
360 if (!wglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
362 ERR("Failed to make caps GL context current.\n");
366 ctx
->gl_info
= &adapter_gl
->gl_info
;
370 if (ctx
->gl_ctx
) wglDeleteContext(ctx
->gl_ctx
);
372 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
374 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
376 if (ctx
->restore_gl_ctx
&& !wglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
377 ERR("Failed to restore previous GL context.\n");
382 /* Context activation is done by the caller. */
383 static BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
387 static const char testcode
[] =
389 "PARAM C[66] = { program.env[0..65] };\n"
391 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
392 "ARL A0.x, zero.x;\n"
393 "MOV result.position, C[A0.x + 65];\n"
396 while (gl_info
->gl_ops
.gl
.p_glGetError());
397 GL_EXTCALL(glGenProgramsARB(1, &prog
));
399 ERR("Failed to create an ARB offset limit test program\n");
401 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
402 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
403 strlen(testcode
), testcode
));
404 if (gl_info
->gl_ops
.gl
.p_glGetError())
406 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
407 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
409 } else TRACE("OpenGL implementation allows offsets > 63\n");
411 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
412 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
413 checkGLcall("ARB vp offset limit test cleanup");
418 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
419 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
420 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
422 return card_vendor
== HW_VENDOR_AMD
423 && (device
== CARD_AMD_RADEON_9500
424 || device
== CARD_AMD_RADEON_X700
425 || device
== CARD_AMD_RADEON_X1600
);
428 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
429 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
430 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
432 return card_vendor
== HW_VENDOR_NVIDIA
433 && (device
== CARD_NVIDIA_GEFORCEFX_5200
434 || device
== CARD_NVIDIA_GEFORCEFX_5600
435 || device
== CARD_NVIDIA_GEFORCEFX_5800
);
438 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
439 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
440 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
442 /* MacOS has various specialities in the extensions it advertises. Some
443 * have to be loaded from the OpenGL 1.2+ core, while other extensions are
444 * advertised, but software emulated. So try to detect the Apple OpenGL
445 * implementation to apply some extension fixups afterwards.
447 * Detecting this isn't really easy. The vendor string doesn't mention
448 * Apple. Compile-time checks aren't sufficient either because a Linux
449 * binary may display on a macOS X server via remote X11. So try to detect
450 * the OpenGL implementation by looking at certain Apple extensions. Some
451 * extensions like client storage might be supported on other
452 * implementations too, but GL_APPLE_flush_render is specific to the
453 * macOS X window management, and GL_APPLE_ycbcr_422 is QuickTime
454 * specific. So the chance that other implementations support them is
455 * rather small since Win32 QuickTime uses DirectDraw, not OpenGL.
457 * This test has been moved into wined3d_guess_gl_vendor(). */
458 return gl_vendor
== GL_VENDOR_APPLE
;
461 /* Context activation is done by the caller. */
462 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
464 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
465 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
466 * all the texture. This function detects this bug by its symptom and disables PBOs
469 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
470 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
471 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
472 * read back is compared to the original. If they are equal PBOs are assumed to work,
473 * otherwise the PBO extension is disabled. */
475 static const unsigned int pattern
[] =
477 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
478 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
479 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
480 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
482 unsigned int check
[ARRAY_SIZE(pattern
)];
484 /* No PBO -> No point in testing them. */
485 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
487 while (gl_info
->gl_ops
.gl
.p_glGetError());
488 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &texture
);
489 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, texture
);
491 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
492 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, 0);
493 checkGLcall("Specifying the PBO test texture");
495 GL_EXTCALL(glGenBuffers(1, &pbo
));
496 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER
, pbo
));
497 GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER
, sizeof(pattern
), pattern
, GL_STREAM_DRAW
));
498 checkGLcall("Specifying the PBO test pbo");
500 gl_info
->gl_ops
.gl
.p_glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
501 checkGLcall("Loading the PBO test texture");
503 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER
, 0));
505 gl_info
->gl_ops
.gl
.p_glFinish(); /* just to be sure */
507 memset(check
, 0, sizeof(check
));
508 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
509 checkGLcall("Reading back the PBO test texture");
511 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &texture
);
512 GL_EXTCALL(glDeleteBuffers(1, &pbo
));
513 checkGLcall("PBO test cleanup");
515 if (memcmp(check
, pattern
, sizeof(check
)))
517 WARN_(d3d_perf
)("PBO test failed, read back data doesn't match original.\n"
518 "Disabling PBOs. This may result in slower performance.\n");
519 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
523 TRACE("PBO test successful.\n");
527 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
528 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
529 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
531 /* Direct3D 9 cards support 40 single float varyings in hardware, most
532 * drivers report 32. ATI misreports 44 varyings. So assume that if we
533 * have more than 44 varyings we have a Direct3D 10+ card. This detection
534 * is for the gl_ClipPos varying quirk. If a Direct3D 9 card really
535 * supports more than 44 varyings and we subtract one in Direct3D 9
536 * shaders it's not going to hurt us because the Direct3D 9 limit is
539 * Direct3D 10 cards usually have 64 varyings. */
540 return gl_info
->limits
.glsl_varyings
> 44;
543 static BOOL
match_not_dx10_capable(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
544 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
545 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
547 return !match_dx10_capable(gl_info
, ctx
, gl_renderer
, gl_vendor
, card_vendor
, device
);
550 /* A GL context is provided by the caller */
551 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
552 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
553 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
558 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
] || !gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
561 while (gl_info
->gl_ops
.gl
.p_glGetError());
562 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
563 error
= gl_info
->gl_ops
.gl
.p_glGetError();
565 if (error
== GL_NO_ERROR
)
567 TRACE("GL Implementation accepts 4 component specular color pointers\n");
572 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
573 debug_glerror(error
));
578 /* A GL context is provided by the caller */
579 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
580 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
581 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
586 static const char testcode
[] =
588 "OPTION NV_vertex_program2;\n"
589 "MOV result.clip[0], 0.0;\n"
590 "MOV result.position, 0.0;\n"
593 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
595 while (gl_info
->gl_ops
.gl
.p_glGetError());
597 GL_EXTCALL(glGenProgramsARB(1, &prog
));
600 ERR("Failed to create the NVvp clip test program\n");
603 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
604 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
605 strlen(testcode
), testcode
));
606 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
609 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
610 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
612 while (gl_info
->gl_ops
.gl
.p_glGetError());
614 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
616 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
617 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
618 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
623 /* Context activation is done by the caller. */
624 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
625 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
626 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
628 char data
[4 * 4 * 4];
632 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
634 memset(data
, 0xcc, sizeof(data
));
636 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
637 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
638 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
639 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
640 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 4, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
641 checkGLcall("glTexImage2D");
643 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
644 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
645 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
646 checkGLcall("glFramebufferTexture2D");
648 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
649 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
650 checkGLcall("glCheckFramebufferStatus");
652 memset(data
, 0x11, sizeof(data
));
653 gl_info
->gl_ops
.gl
.p_glTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
654 checkGLcall("glTexSubImage2D");
656 gl_info
->gl_ops
.gl
.p_glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
657 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
658 checkGLcall("glClear");
660 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
661 checkGLcall("glGetTexImage");
663 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
664 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
665 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
666 checkGLcall("glBindTexture");
668 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
669 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
670 checkGLcall("glDeleteTextures");
672 return *(DWORD
*)data
== 0x11111111;
675 /* Context activation is done by the caller. */
676 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
677 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
678 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
680 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
681 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
685 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
686 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
687 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
688 checkGLcall("glTexImage2D");
690 gl_info
->gl_ops
.gl
.p_glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
691 checkGLcall("glGetTexLevelParameteriv");
692 TRACE("Real color depth is %d\n", size
);
694 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
695 checkGLcall("glBindTexture");
696 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
697 checkGLcall("glDeleteTextures");
702 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
703 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
704 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
706 return gl_vendor
== GL_VENDOR_FGLRX
;
709 static BOOL
match_r200(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
710 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
711 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
713 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
714 if (device
== CARD_AMD_RADEON_8500
) return TRUE
;
718 static BOOL
match_broken_arb_fog(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
719 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
720 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
722 unsigned int data
[4];
725 float color
[4] = {0.0f
, 1.0f
, 0.0f
, 0.0f
};
728 static const char program_code
[] =
730 "OPTION ARB_fog_linear;\n"
731 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
734 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
736 if (!gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
738 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
741 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
742 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
743 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
744 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
745 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB8
, 4, 1, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, NULL
);
746 checkGLcall("glTexImage2D");
748 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
749 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
750 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
751 checkGLcall("glFramebufferTexture2D");
753 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
754 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
755 checkGLcall("glCheckFramebufferStatus");
757 gl_info
->gl_ops
.gl
.p_glClearColor(0.0f
, 0.0f
, 1.0f
, 0.0f
);
758 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
759 checkGLcall("glClear");
760 gl_info
->gl_ops
.gl
.p_glViewport(0, 0, 4, 1);
761 checkGLcall("glViewport");
763 gl_info
->gl_ops
.gl
.p_glEnable(GL_FOG
);
764 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, 0.5f
);
765 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, 0.5f
);
766 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
767 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
768 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, color
);
769 checkGLcall("fog setup");
771 GL_EXTCALL(glGenProgramsARB(1, &prog
));
772 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, prog
));
773 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
774 strlen(program_code
), program_code
));
775 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAGMENT_PROGRAM_ARB
);
776 checkGLcall("Test fragment program setup");
778 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &err_pos
);
781 const char *error_str
;
782 error_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
);
783 FIXME("Fog test program error at position %d: %s\n\n", err_pos
, debugstr_a(error_str
));
786 gl_info
->gl_ops
.gl
.p_glBegin(GL_TRIANGLE_STRIP
);
787 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, -1.0f
, 0.0f
);
788 gl_info
->gl_ops
.gl
.p_glVertex3f( 1.0f
, -1.0f
, 1.0f
);
789 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, 1.0f
, 0.0f
);
790 gl_info
->gl_ops
.gl
.p_glVertex3f( 1.0f
, 1.0f
, 1.0f
);
791 gl_info
->gl_ops
.gl
.p_glEnd();
792 checkGLcall("ARBfp fog test draw");
794 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
795 checkGLcall("glGetTexImage");
796 data
[0] &= 0x00ffffff;
797 data
[1] &= 0x00ffffff;
798 data
[2] &= 0x00ffffff;
799 data
[3] &= 0x00ffffff;
801 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
802 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
804 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
805 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
806 gl_info
->gl_ops
.gl
.p_glDisable(GL_FOG
);
807 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, 0));
808 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAGMENT_PROGRAM_ARB
);
809 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
810 checkGLcall("ARBfp fog test teardown");
812 TRACE("Fog test data: %08x %08x %08x %08x\n", data
[0], data
[1], data
[2], data
[3]);
813 return data
[0] != 0x00ff0000 || data
[3] != 0x0000ff00;
816 static BOOL
match_broken_viewport_subpixel_bits(const struct wined3d_gl_info
*gl_info
,
817 struct wined3d_caps_gl_ctx
*ctx
, const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
818 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
820 if (!gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
822 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
824 return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx
);
827 static BOOL
match_no_independent_bit_depths(const struct wined3d_gl_info
*gl_info
,
828 struct wined3d_caps_gl_ctx
*ctx
, const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
829 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
834 /* ARB_framebuffer_object allows implementation-dependent internal format
835 * restrictions. The EXT extension explicitly calls out an error in the
837 if (!gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
839 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
842 gl_info
->gl_ops
.gl
.p_glGenTextures(2, tex
);
844 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
[0]);
845 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
846 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
847 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA8
, 4, 1, 0, GL_RGBA
, GL_UNSIGNED_INT_8_8_8_8
, NULL
);
849 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
[1]);
850 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
851 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
852 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB5
, 4, 1, 0, GL_RGB
, GL_UNSIGNED_SHORT_5_6_5
, NULL
);
853 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
855 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
856 gl_info
->fbo_ops
.glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, fbo
);
857 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
[0], 0);
858 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER
, GL_COLOR_ATTACHMENT1
, GL_TEXTURE_2D
, tex
[1], 0);
860 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER
);
862 gl_info
->fbo_ops
.glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, 0);
863 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
864 gl_info
->gl_ops
.gl
.p_glDeleteTextures(2, tex
);
865 checkGLcall("testing multiple framebuffer attachments with different bit depths");
867 return status
!= GL_FRAMEBUFFER_COMPLETE
;
870 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
872 /* MacOS needs uniforms for relative addressing offsets. This can
873 * accumulate to quite a few uniforms. Beyond that the general uniform
874 * isn't optimal, so reserve a number of uniforms. 12 vec4's should allow
875 * 48 different offsets or other helper immediate values. */
876 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
877 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
880 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
882 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and
883 * earlier cards, although these cards only support
884 * GL_ARB_texture_rectangle (D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
886 * If real NP2 textures are used, the driver falls back to software. We
887 * could just disable the extension and use GL_ARB_texture_rectangle
888 * instead, but texture_rectangle is inconvenient due to the
889 * non-normalised texture coordinates. Thus set an internal extension
890 * flag, GL_WINE_normalized_texrect, which signals the code that it can
891 * use non-power-of-two textures as per GL_ARB_texture_non_power_of_two,
892 * but has to stick to the texture_rectangle limits.
894 * Fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it
895 * advertises OpenGL 2.0, which has this extension promoted to core. The
896 * extension loading code sets this extension supported due to that, so
897 * this code works on fglrx as well. */
898 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
900 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
901 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
902 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
906 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
908 /* The NVIDIA GeForce FX series reports OpenGL 2.0 capabilities with the
909 * latest drivers versions, but doesn't explicitly advertise the
910 * ARB_tex_npot extension in the OpenGL extension string. This usually
911 * means that ARB_tex_npot is supported in hardware as long as the
912 * application is staying within the limits enforced by the
913 * ARB_texture_rectangle extension. This however is not true for the
914 * FX series, which instantly falls back to a slower software path as
915 * soon as ARB_tex_npot is used. We therefore completely remove
916 * ARB_tex_npot from the list of supported extensions.
918 * Note that WINE_normalized_texrect can't be used in this case because
919 * internally it uses ARB_tex_npot, triggering the software fallback.
920 * There is not much we can do here apart from disabling the
921 * software-emulated extension and re-enable ARB_tex_rect (which was
922 * previously disabled in wined3d_adapter_init_gl_caps).
924 * This fixup removes performance problems on both the FX 5900 and
925 * FX 5700 (e.g. for framebuffer post-processing effects in the game
926 * "Max Payne 2"). The behaviour can be verified through a simple test
927 * app attached in bugreport #14724. */
928 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
929 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
930 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
933 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
935 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
938 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
940 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
943 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
945 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
948 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
950 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
953 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
955 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
958 static void quirk_infolog_spam(struct wined3d_gl_info
*gl_info
)
960 gl_info
->quirks
|= WINED3D_QUIRK_INFO_LOG_SPAM
;
963 static void quirk_limited_tex_filtering(struct wined3d_gl_info
*gl_info
)
965 /* NVIDIA GeForce 6xxx and 7xxx support accelerated VTF only on a few
966 * selected texture formats. They are apparently the only Direct3D 9 class
967 * GPUs supporting VTF. Also, Direct3D 9-era GPUs are somewhat limited
968 * with float texture filtering and blending. */
969 gl_info
->quirks
|= WINED3D_QUIRK_LIMITED_TEX_FILTERING
;
972 static void quirk_r200_constants(struct wined3d_gl_info
*gl_info
)
974 /* The Mesa r200 driver (and there is no other driver for this GPU Wine
975 * would run on) loads some fog parameters (start, end, exponent, but not
976 * the colour) into the program.
978 * Apparently the fog hardware is only able to handle linear fog with a
979 * range of 0.0;1.0, and it is the responsibility of the vertex pipeline
980 * to handle non-linear fog and linear fog with start and end other than
982 TRACE("Reserving 1 ARB constant for compiler private use.\n");
983 gl_info
->reserved_arb_constants
= max(gl_info
->reserved_arb_constants
, 1);
986 static void quirk_broken_arb_fog(struct wined3d_gl_info
*gl_info
)
988 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_ARB_FOG
;
991 static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info
*gl_info
)
993 gl_info
->limits
.viewport_subpixel_bits
= 0;
994 if (gl_info
->supported
[ARB_CLIP_CONTROL
])
996 TRACE("Disabling ARB_clip_control.\n");
997 gl_info
->supported
[ARB_CLIP_CONTROL
] = FALSE
;
1001 static void quirk_no_independent_bit_depths(struct wined3d_gl_info
*gl_info
)
1003 gl_info
->quirks
|= WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS
;
1006 static const struct wined3d_gpu_description
*query_gpu_description(const struct wined3d_gl_info
*gl_info
,
1009 const struct wined3d_gpu_description
*gpu_description
= NULL
, *gpu_description_override
;
1010 enum wined3d_pci_vendor vendor
= PCI_VENDOR_NONE
;
1011 enum wined3d_pci_device device
= PCI_DEVICE_NONE
;
1014 if (gl_info
->supported
[WGL_WINE_QUERY_RENDERER
])
1016 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VENDOR_ID_WINE
, &value
)))
1018 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_DEVICE_ID_WINE
, &value
)))
1020 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VIDEO_MEMORY_WINE
, &value
)))
1021 *vram_bytes
= (UINT64
)value
* 1024 * 1024;
1023 TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1024 vendor
, device
, wine_dbgstr_longlong(*vram_bytes
));
1026 gpu_description
= wined3d_get_gpu_description(vendor
, device
);
1029 if ((gpu_description_override
= wined3d_get_user_override_gpu_description(vendor
, device
)))
1030 gpu_description
= gpu_description_override
;
1032 return gpu_description
;
1035 /* Context activation is done by the caller. */
1036 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
1037 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
)
1039 enum wined3d_pci_vendor card_vendor
= ctx
->gpu_description
->vendor
;
1040 enum wined3d_pci_device device
= ctx
->gpu_description
->device
;
1043 static const struct driver_quirk
1045 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
1046 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
1047 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
1048 void (*apply
)(struct wined3d_gl_info
*gl_info
);
1049 const char *description
;
1054 match_amd_r300_to_500
,
1056 "AMD normalised texrect quirk"
1060 quirk_apple_glsl_constants
,
1061 "Apple GLSL uniform override"
1066 "Geforce 5 NP2 disable"
1071 "Reserved varying for gl_ClipPos"
1074 /* GL_EXT_secondary_color does not allow 4 component secondary
1075 * colours, but most OpenGL implementations accept it. Apple's
1076 * is the only OpenGL implementation known to reject it.
1078 * If we can pass 4-component specular colours, do it, because
1079 * (a) we don't have to screw around with the data, and (b) the
1080 * Direct3D fixed-function vertex pipeline passes specular alpha
1081 * to the pixel shader if any is used. Otherwise the specular
1082 * alpha is used to pass the fog coordinate, which we pass to
1083 * OpenGL via GL_EXT_fog_coord. */
1084 match_allows_spec_alpha
,
1085 quirk_allows_specular_alpha
,
1086 "Allow specular alpha quirk"
1089 match_broken_nv_clip
,
1090 quirk_disable_nvvp_clip
,
1091 "Apple NV_vertex_program clip bug quirk"
1094 match_fbo_tex_update
,
1095 quirk_fbo_tex_update
,
1096 "FBO rebind for attachment updates"
1099 match_broken_rgba16
,
1100 quirk_broken_rgba16
,
1101 "True RGBA16 is not available"
1106 "Not printing GLSL infolog"
1109 match_not_dx10_capable
,
1110 quirk_limited_tex_filtering
,
1111 "Texture filtering, blending and VTF support is limited"
1115 quirk_r200_constants
,
1116 "r200 vertex shader constants"
1119 match_broken_arb_fog
,
1120 quirk_broken_arb_fog
,
1121 "ARBfp fogstart == fogend workaround"
1124 match_broken_viewport_subpixel_bits
,
1125 quirk_broken_viewport_subpixel_bits
,
1126 "NVIDIA viewport subpixel bits bug"
1129 match_no_independent_bit_depths
,
1130 quirk_no_independent_bit_depths
,
1131 "No support for MRT with independent bit depths"
1135 for (i
= 0; i
< ARRAY_SIZE(quirk_table
); ++i
)
1137 if (!quirk_table
[i
].match(gl_info
, ctx
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1138 TRACE("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1139 quirk_table
[i
].apply(gl_info
);
1142 /* Find out if PBOs work as they are supposed to. */
1143 test_pbo_functionality(gl_info
);
1146 static unsigned int wined3d_parse_gl_version(const char *gl_version
)
1148 const char *ptr
= gl_version
;
1153 ERR("Invalid OpenGL major version %d.\n", major
);
1155 while (isdigit(*ptr
)) ++ptr
;
1157 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version
));
1161 TRACE("Found OpenGL version %d.%d.\n", major
, minor
);
1163 return MAKEDWORD_VERSION(major
, minor
);
1166 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1167 const char *gl_vendor_string
, const char *gl_renderer
, const char *gl_version
)
1169 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1170 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1171 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1173 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1174 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1175 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1176 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1177 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1178 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1179 * DirectDraw, not OpenGL. */
1180 if (gl_info
->supported
[APPLE_FLUSH_RENDER
]
1181 && (gl_info
->supported
[APPLE_YCBCR_422
] || gl_info
->supported
[APPLE_RGB_422
]))
1182 return GL_VENDOR_APPLE
;
1184 if (strstr(gl_vendor_string
, "NVIDIA"))
1185 return GL_VENDOR_NVIDIA
;
1187 if (strstr(gl_vendor_string
, "ATI"))
1188 return GL_VENDOR_FGLRX
;
1190 if (strstr(gl_vendor_string
, "Mesa")
1191 || strstr(gl_vendor_string
, "X.Org")
1192 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1193 || strstr(gl_vendor_string
, "DRI R300 Project")
1194 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1195 || strstr(gl_vendor_string
, "VMware, Inc.")
1196 || strstr(gl_vendor_string
, "Red Hat")
1197 || strstr(gl_vendor_string
, "Intel")
1198 || strstr(gl_renderer
, "Mesa")
1199 || strstr(gl_renderer
, "Gallium")
1200 || strstr(gl_renderer
, "Intel")
1201 || strstr(gl_version
, "Mesa"))
1202 return GL_VENDOR_MESA
;
1204 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1205 debugstr_a(gl_vendor_string
));
1207 return GL_VENDOR_UNKNOWN
;
1210 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1212 if (strstr(gl_vendor_string
, "NVIDIA")
1213 || strstr(gl_vendor_string
, "Nouveau")
1214 || strstr(gl_vendor_string
, "nouveau"))
1215 return HW_VENDOR_NVIDIA
;
1217 if (strstr(gl_vendor_string
, "ATI")
1218 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1219 || strstr(gl_vendor_string
, "X.Org R300 Project")
1220 || strstr(gl_vendor_string
, "AMD")
1221 || strstr(gl_renderer
, "AMD")
1222 || strstr(gl_renderer
, "FirePro")
1223 || strstr(gl_renderer
, "Radeon")
1224 || strstr(gl_renderer
, "R100")
1225 || strstr(gl_renderer
, "R200")
1226 || strstr(gl_renderer
, "R300")
1227 || strstr(gl_renderer
, "R600")
1228 || strstr(gl_renderer
, "R700"))
1229 return HW_VENDOR_AMD
;
1231 if (strstr(gl_vendor_string
, "Intel(R)")
1232 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1233 || strstr(gl_renderer
, "Intel")
1234 || strstr(gl_renderer
, "i915")
1235 || strstr(gl_vendor_string
, "Intel Inc."))
1236 return HW_VENDOR_INTEL
;
1238 if (strstr(gl_vendor_string
, "Red Hat")
1239 || strstr(gl_renderer
, "virgl"))
1240 return HW_VENDOR_REDHAT
;
1242 if (strstr(gl_renderer
, "SVGA3D"))
1243 return HW_VENDOR_VMWARE
;
1245 if (strstr(gl_vendor_string
, "Mesa")
1246 || strstr(gl_vendor_string
, "Brian Paul")
1247 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1248 || strstr(gl_vendor_string
, "VMware, Inc."))
1249 return HW_VENDOR_SOFTWARE
;
1251 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1253 return HW_VENDOR_NVIDIA
;
1256 static enum wined3d_feature_level
feature_level_from_caps(const struct wined3d_gl_info
*gl_info
,
1257 const struct shader_caps
*shader_caps
, const struct fragment_caps
*fragment_caps
)
1259 unsigned int shader_model
;
1261 shader_model
= min(shader_caps
->vs_version
, shader_caps
->ps_version
);
1262 shader_model
= min(shader_model
, max(shader_caps
->gs_version
, 3));
1263 shader_model
= min(shader_model
, max(shader_caps
->hs_version
, 4));
1264 shader_model
= min(shader_model
, max(shader_caps
->ds_version
, 4));
1266 if (gl_info
->supported
[WINED3D_GL_VERSION_3_2
]
1267 && gl_info
->supported
[ARB_POLYGON_OFFSET_CLAMP
]
1268 && gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
1270 if (shader_model
>= 5
1271 && gl_info
->supported
[ARB_DRAW_INDIRECT
]
1272 && gl_info
->supported
[ARB_TEXTURE_COMPRESSION_BPTC
])
1273 return WINED3D_FEATURE_LEVEL_11_1
;
1275 if (shader_model
>= 4)
1277 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP_ARRAY
]
1278 && gl_info
->supported
[ARB_DRAW_BUFFERS_BLEND
])
1279 return WINED3D_FEATURE_LEVEL_10_1
;
1280 return WINED3D_FEATURE_LEVEL_10
;
1284 if (shader_model
>= 3 && gl_info
->limits
.texture_size
>= 4096 && gl_info
->limits
.buffers
>= 4)
1285 return WINED3D_FEATURE_LEVEL_9_3
;
1286 if (shader_model
>= 2)
1288 if (gl_info
->supported
[ARB_OCCLUSION_QUERY
]
1289 && gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
]
1290 && gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
]
1291 && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
1292 return WINED3D_FEATURE_LEVEL_9_2
;
1294 return WINED3D_FEATURE_LEVEL_9_1
;
1296 if (shader_model
>= 1)
1297 return WINED3D_FEATURE_LEVEL_8
;
1299 if (fragment_caps
->TextureOpCaps
& WINED3DTEXOPCAPS_DOTPRODUCT3
)
1300 return WINED3D_FEATURE_LEVEL_7
;
1301 if (fragment_caps
->MaxSimultaneousTextures
> 1)
1302 return WINED3D_FEATURE_LEVEL_6
;
1304 return WINED3D_FEATURE_LEVEL_5
;
1307 static const struct wined3d_renderer_table
1309 const char *renderer
;
1310 enum wined3d_pci_device id
;
1312 cards_nvidia_binary
[] =
1315 {"Tesla T4", CARD_NVIDIA_TESLA_T4
},
1316 {"Ampere A10", CARD_NVIDIA_AMPERE_A10
},
1317 {"RTX 2080 Ti", CARD_NVIDIA_GEFORCE_RTX2080TI
}, /* GeForce 2000 - highend */
1318 {"RTX 2080", CARD_NVIDIA_GEFORCE_RTX2080
}, /* GeForce 2000 - highend */
1319 {"RTX 2070", CARD_NVIDIA_GEFORCE_RTX2070
}, /* GeForce 2000 - highend */
1320 {"RTX 2060", CARD_NVIDIA_GEFORCE_RTX2060
}, /* GeForce 2000 - highend */
1321 {"GTX 1660 Ti", CARD_NVIDIA_GEFORCE_GTX1660TI
}, /* GeForce 1600 - highend */
1322 {"GTX 1660 SUPER", CARD_NVIDIA_GEFORCE_GTX1660SUPER
}, /* GeForce 1600 - highend */
1323 {"GTX 1650 SUPER", CARD_NVIDIA_GEFORCE_GTX1650SUPER
}, /* GeForce 1600 - midend high */
1324 {"TITAN V", CARD_NVIDIA_TITANV
}, /* GeForce 1000 - highend */
1325 {"TITAN X (Pascal)", CARD_NVIDIA_TITANX_PASCAL
}, /* GeForce 1000 - highend */
1326 {"GTX 1080 Ti", CARD_NVIDIA_GEFORCE_GTX1080TI
}, /* GeForce 1000 - highend */
1327 {"GTX 1080", CARD_NVIDIA_GEFORCE_GTX1080
}, /* GeForce 1000 - highend */
1328 {"GTX 1070", CARD_NVIDIA_GEFORCE_GTX1070
}, /* GeForce 1000 - highend */
1329 {"GTX 1060 3GB", CARD_NVIDIA_GEFORCE_GTX1060_3GB
},/* GeForce 1000 - midend high */
1330 {"GTX 1060", CARD_NVIDIA_GEFORCE_GTX1060
}, /* GeForce 1000 - midend high */
1331 {"GTX 1050 Ti", CARD_NVIDIA_GEFORCE_GTX1050TI
}, /* GeForce 1000 - midend */
1332 {"GTX 1050", CARD_NVIDIA_GEFORCE_GTX1050
}, /* GeForce 1000 - midend */
1333 {"GT 1030", CARD_NVIDIA_GEFORCE_GT1030
}, /* GeForce 1000 - lowend */
1334 {"GTX 980 Ti", CARD_NVIDIA_GEFORCE_GTX980TI
}, /* GeForce 900 - highend */
1335 {"GTX 980", CARD_NVIDIA_GEFORCE_GTX980
}, /* GeForce 900 - highend */
1336 {"GTX 970M", CARD_NVIDIA_GEFORCE_GTX970M
}, /* GeForce 900 - highend mobile*/
1337 {"GTX 970", CARD_NVIDIA_GEFORCE_GTX970
}, /* GeForce 900 - highend */
1338 {"GTX TITAN X", CARD_NVIDIA_GEFORCE_GTXTITANX
}, /* Geforce 900 - highend */
1339 {"GTX 960M", CARD_NVIDIA_GEFORCE_GTX960M
}, /* GeForce 900 - midend high mobile */
1340 {"GTX 960", CARD_NVIDIA_GEFORCE_GTX960
}, /* GeForce 900 - midend high */
1341 {"GTX 950M", CARD_NVIDIA_GEFORCE_GTX950M
}, /* GeForce 900 - midend mobile */
1342 {"GTX 950", CARD_NVIDIA_GEFORCE_GTX950
}, /* GeForce 900 - midend */
1343 {"GeForce 940M", CARD_NVIDIA_GEFORCE_940M
}, /* GeForce 900 - midend mobile */
1344 {"GTX 880M", CARD_NVIDIA_GEFORCE_GTX880M
}, /* GeForce 800 - mobile */
1345 {"GTX 870M", CARD_NVIDIA_GEFORCE_GTX870M
}, /* GeForce 800 - mobile */
1346 {"GTX 860M", CARD_NVIDIA_GEFORCE_GTX860M
}, /* GeForce 800 - mobile */
1347 {"GTX 850M", CARD_NVIDIA_GEFORCE_GTX850M
}, /* GeForce 800 - mobile */
1348 {"GeForce 845M", CARD_NVIDIA_GEFORCE_845M
}, /* GeForce 800 - mobile */
1349 {"GeForce 840M", CARD_NVIDIA_GEFORCE_840M
}, /* GeForce 800 - mobile */
1350 {"GeForce 830M", CARD_NVIDIA_GEFORCE_830M
}, /* GeForce 800 - mobile */
1351 {"GeForce 820M", CARD_NVIDIA_GEFORCE_820M
}, /* GeForce 800 - mobile */
1352 {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI
}, /* Geforce 700 - highend */
1353 {"GTX TITAN Black", CARD_NVIDIA_GEFORCE_GTXTITANB
}, /* Geforce 700 - highend */
1354 {"GTX TITAN Z", CARD_NVIDIA_GEFORCE_GTXTITANZ
}, /* Geforce 700 - highend */
1355 {"GTX TITAN", CARD_NVIDIA_GEFORCE_GTXTITAN
}, /* Geforce 700 - highend */
1356 {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780
}, /* Geforce 700 - highend */
1357 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M
}, /* Geforce 700 - midend high mobile */
1358 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770
}, /* Geforce 700 - highend */
1359 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M
}, /* Geforce 700 - midend high mobile */
1360 {"GTX 760 Ti", CARD_NVIDIA_GEFORCE_GTX760TI
}, /* Geforce 700 - midend high */
1361 {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760
}, /* Geforce 700 - midend high */
1362 {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI
}, /* Geforce 700 - midend */
1363 {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750
}, /* Geforce 700 - midend */
1364 {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M
}, /* Geforce 700 - midend mobile */
1365 {"GT 740M", CARD_NVIDIA_GEFORCE_GT740M
}, /* Geforce 700 - midend mobile */
1366 {"GT 730M", CARD_NVIDIA_GEFORCE_GT730M
}, /* Geforce 700 - midend mobile */
1367 {"GT 730", CARD_NVIDIA_GEFORCE_GT730
}, /* Geforce 700 - lowend */
1368 {"GTX 690", CARD_NVIDIA_GEFORCE_GTX690
}, /* Geforce 600 - highend */
1369 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680
}, /* Geforce 600 - highend */
1370 {"GTX 675MX", CARD_NVIDIA_GEFORCE_GTX675MX_1
},/* Geforce 600 - highend */
1371 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX
}, /* Geforce 600 - highend */
1372 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670
}, /* Geforce 600 - midend high */
1373 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI
}, /* Geforce 600 - midend high */
1374 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M
}, /* Geforce 600 - midend high mobile */
1375 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660
}, /* Geforce 600 - midend high */
1376 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI
}, /* Geforce 600 - lowend */
1377 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650
}, /* Geforce 600 - lowend */
1378 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M
}, /* Geforce 600 - midend mobile */
1379 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M
}, /* Geforce 600 - midend mobile */
1380 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M
}, /* Geforce 600 - midend mobile */
1381 {"GT 630", CARD_NVIDIA_GEFORCE_GT630
}, /* Geforce 600 - lowend */
1382 {"GT 610", CARD_NVIDIA_GEFORCE_GT610
}, /* Geforce 600 - lowend */
1383 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1384 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1385 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI
}, /* Geforce 500 - midend */
1386 {"GTX 560M", CARD_NVIDIA_GEFORCE_GTX560M
}, /* Geforce 500 - midend mobile */
1387 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1388 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M
}, /* Geforce 500 - midend mobile */
1389 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1390 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M
}, /* Geforce 500 - midend mobile */
1391 {"GT 525M", CARD_NVIDIA_GEFORCE_GT525M
}, /* Geforce 500 - lowend mobile */
1392 {"GT 520", CARD_NVIDIA_GEFORCE_GT520
}, /* Geforce 500 - lowend */
1393 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1394 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1396 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1397 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M
}, /* Geforce 400 - highend mobile */
1398 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1399 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1400 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1401 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1402 {"GT 425M", CARD_NVIDIA_GEFORCE_GT425M
}, /* Geforce 400 - lowend mobile */
1403 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1404 {"410M", CARD_NVIDIA_GEFORCE_410M
}, /* Geforce 400 - lowend mobile */
1405 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1406 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1407 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1408 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1409 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1410 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1411 {"320M", CARD_NVIDIA_GEFORCE_320M
}, /* Geforce 300 - midend mobile */
1412 {"315M", CARD_NVIDIA_GEFORCE_315M
}, /* Geforce 300 - midend mobile */
1413 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1414 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1415 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1416 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1417 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1418 {"GTS 250", CARD_NVIDIA_GEFORCE_GTS250
}, /* Geforce 200 - midend */
1419 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1420 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1421 {"GeForce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1422 {"GeForce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1423 {"GeForce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1424 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1425 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1426 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1427 {"9700M GT", CARD_NVIDIA_GEFORCE_9700MGT
}, /* Geforce 9 - midend */
1428 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1429 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1430 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1431 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1432 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1433 {"9400M", CARD_NVIDIA_GEFORCE_9400M
}, /* Geforce 9 - lowend */
1434 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1435 {"9300", CARD_NVIDIA_GEFORCE_9300
}, /* Geforce 9 - lowend low */
1436 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1437 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1438 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1439 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1440 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1441 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1442 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1443 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1444 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1445 {"8500", CARD_NVIDIA_GEFORCE_8500GT
}, /* Geforce 8 - mid-lowend */
1446 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1447 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1448 {"8200", CARD_NVIDIA_GEFORCE_8200
}, /* Geforce 8 - lowend */
1449 {"8100", CARD_NVIDIA_GEFORCE_8200
}, /* Geforce 8 - lowend */
1450 /* Direct 3D 9 SM3 */
1451 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1452 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1453 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1454 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1455 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1456 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1457 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1458 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1459 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1460 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1461 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1462 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1463 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1464 /* Direct 3D 9 SM2 */
1465 {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1466 {"5950", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1467 {"5900", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1468 {"5800", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1469 {"5750", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1470 {"5700", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1471 {"5650", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1472 {"5600", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1473 {"5500", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1474 {"5300", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1475 {"5250", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1476 {"5200", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1477 {"5100", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1479 {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200
},
1480 {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200
}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */
1482 {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX
}, /* MX420/MX440/MX460/MX4000 */
1483 {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX
},
1484 {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX
}, /* Geforce2 standard/MX100/MX200/MX400 */
1485 {"Quadro2", CARD_NVIDIA_GEFORCE2
},
1486 {"GeForce2", CARD_NVIDIA_GEFORCE2
}, /* Geforce2 GTS/Pro/Ti/Ultra */
1488 {"TNT2", CARD_NVIDIA_RIVA_TNT2
}, /* Riva TNT2 standard/M64/Pro/Ultra */
1490 /* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/
1492 * Beware: renderer string do not match exact card model,
1493 * e.g. HD 4800 is returned for multiple cards, even for RV790 based ones. */
1494 cards_amd_binary
[] =
1496 {"RX 480", CARD_AMD_RADEON_RX_480
},
1497 {"RX 460", CARD_AMD_RADEON_RX_460
},
1498 {"R9 Fury Series", CARD_AMD_RADEON_R9_FURY
},
1499 /* Southern Islands */
1500 {"HD 7900", CARD_AMD_RADEON_HD7900
},
1501 {"HD 7800", CARD_AMD_RADEON_HD7800
},
1502 {"HD 7700", CARD_AMD_RADEON_HD7700
},
1503 /* Northern Islands */
1504 {"HD 6970", CARD_AMD_RADEON_HD6900
},
1505 {"HD 6900", CARD_AMD_RADEON_HD6900
},
1506 {"HD 6800", CARD_AMD_RADEON_HD6800
},
1507 {"HD 6770M", CARD_AMD_RADEON_HD6600M
},
1508 {"HD 6750M", CARD_AMD_RADEON_HD6600M
},
1509 {"HD 6700", CARD_AMD_RADEON_HD6700
},
1510 {"HD 6670", CARD_AMD_RADEON_HD6600
},
1511 {"HD 6630M", CARD_AMD_RADEON_HD6600M
},
1512 {"HD 6600M", CARD_AMD_RADEON_HD6600M
},
1513 {"HD 6600", CARD_AMD_RADEON_HD6600
},
1514 {"HD 6570", CARD_AMD_RADEON_HD6600
},
1515 {"HD 6500M", CARD_AMD_RADEON_HD6600M
},
1516 {"HD 6500", CARD_AMD_RADEON_HD6600
},
1517 {"HD 6480G", CARD_AMD_RADEON_HD6480G
},
1518 {"HD 6400", CARD_AMD_RADEON_HD6400
},
1519 {"HD 6300", CARD_AMD_RADEON_HD6300
},
1520 {"HD 6200", CARD_AMD_RADEON_HD6300
},
1522 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1523 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1524 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1525 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1526 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1527 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1528 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1529 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1530 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1531 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1532 {"HD 5000", CARD_AMD_RADEON_HD5600
}, /* Defaulting to HD 5600 */
1534 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1535 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1536 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1537 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1538 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1539 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1540 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1541 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1542 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1543 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1544 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1545 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1546 /* R600/R700 integrated */
1547 {"HD 4200M", CARD_AMD_RADEON_HD4200M
},
1548 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1549 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1550 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1552 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1553 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1554 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1555 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1556 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1557 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1558 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1559 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1560 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1561 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1562 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1563 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1564 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1566 {"X1950", CARD_AMD_RADEON_X1600
},
1567 {"X1900", CARD_AMD_RADEON_X1600
},
1568 {"X1800", CARD_AMD_RADEON_X1600
},
1569 {"X1650", CARD_AMD_RADEON_X1600
},
1570 {"X1600", CARD_AMD_RADEON_X1600
},
1571 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1572 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1573 {"HD 2300", CARD_AMD_RADEON_X700
},
1574 {"X2500", CARD_AMD_RADEON_X700
},
1575 {"X2300", CARD_AMD_RADEON_X700
},
1576 {"X1550", CARD_AMD_RADEON_X700
},
1577 {"X1450", CARD_AMD_RADEON_X700
},
1578 {"X1400", CARD_AMD_RADEON_X700
},
1579 {"X1300", CARD_AMD_RADEON_X700
},
1580 {"X850", CARD_AMD_RADEON_X700
},
1581 {"X800", CARD_AMD_RADEON_X700
},
1582 {"X700", CARD_AMD_RADEON_X700
},
1583 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */
1584 {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M
},
1589 {"Iris Pro Graphics P580", CARD_INTEL_IPP580_1
},
1590 {"Skylake", CARD_INTEL_HD520_1
},
1592 {"Iris Pro P6300", CARD_INTEL_IPP6300
},
1593 {"Iris Pro 6200", CARD_INTEL_IP6200
},
1594 {"Iris 6100", CARD_INTEL_I6100
},
1595 {"Iris(TM) Graphics 6100", CARD_INTEL_I6100
}, /* MacOS */
1597 {"Iris Pro 5200", CARD_INTEL_IP5200_1
},
1598 {"Iris 5100", CARD_INTEL_I5100_1
},
1599 {"HD Graphics 5000", CARD_INTEL_HD5000_1
}, /* MacOS */
1600 {"Haswell Mobile", CARD_INTEL_HWM
},
1601 {"Iris OpenGL Engine", CARD_INTEL_HWM
}, /* MacOS */
1603 {"Ivybridge Server", CARD_INTEL_IVBS
},
1604 {"Ivybridge Mobile", CARD_INTEL_IVBM
},
1605 {"Ivybridge Desktop", CARD_INTEL_IVBD
},
1606 {"HD Graphics 4000", CARD_INTEL_IVBD
}, /* MacOS */
1608 {"Sandybridge Server", CARD_INTEL_SNBS
},
1609 {"Sandybridge Mobile", CARD_INTEL_SNBM
},
1610 {"Sandybridge Desktop", CARD_INTEL_SNBD
},
1612 {"Ironlake Mobile", CARD_INTEL_ILKM
},
1613 {"Ironlake Desktop", CARD_INTEL_ILKD
},
1615 {"B43", CARD_INTEL_B43
},
1616 {"G41", CARD_INTEL_G41
},
1617 {"G45", CARD_INTEL_G45
},
1618 {"Q45", CARD_INTEL_Q45
},
1619 {"Integrated Graphics Device", CARD_INTEL_IGD
},
1620 {"GM45", CARD_INTEL_GM45
},
1622 {"965GME", CARD_INTEL_965GME
},
1623 {"965GM", CARD_INTEL_965GM
},
1624 {"X3100", CARD_INTEL_965GM
}, /* MacOS */
1625 {"946GZ", CARD_INTEL_946GZ
},
1626 {"965G", CARD_INTEL_965G
},
1627 {"965Q", CARD_INTEL_965Q
},
1629 {"Pineview M", CARD_INTEL_PNVM
},
1630 {"Pineview G", CARD_INTEL_PNVG
},
1631 {"IGD", CARD_INTEL_PNVG
},
1632 {"Q33", CARD_INTEL_Q33
},
1633 {"G33", CARD_INTEL_G33
},
1634 {"Q35", CARD_INTEL_Q35
},
1635 {"945GME", CARD_INTEL_945GME
},
1636 {"945GM", CARD_INTEL_945GM
},
1637 {"GMA 950", CARD_INTEL_945GM
}, /* MacOS */
1638 {"945G", CARD_INTEL_945G
},
1640 {"915GM", CARD_INTEL_915GM
},
1641 {"E7221G", CARD_INTEL_E7221G
},
1642 {"915G", CARD_INTEL_915G
},
1644 {"865G", CARD_INTEL_865G
},
1645 {"845G", CARD_INTEL_845G
},
1646 {"855GM", CARD_INTEL_855GM
},
1647 {"830M", CARD_INTEL_830M
},
1649 /* 20101109 - These are never returned by current Gallium radeon
1650 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351. */
1654 {"NAVI10", CARD_AMD_RADEON_RX_NAVI_10
},
1655 {"NAVI14", CARD_AMD_RADEON_RX_NAVI_14
},
1657 {"POLARIS10", CARD_AMD_RADEON_RX_480
},
1658 {"POLARIS11", CARD_AMD_RADEON_RX_460
},
1659 /* Volcanic Islands */
1660 {"FIJI", CARD_AMD_RADEON_R9_FURY
},
1661 {"TONGA", CARD_AMD_RADEON_R9_285
},
1663 {"HAWAII", CARD_AMD_RADEON_R9_290
},
1664 {"KAVERI", CARD_AMD_RADEON_R7
},
1665 {"KABINI", CARD_AMD_RADEON_R3
},
1666 {"BONAIRE", CARD_AMD_RADEON_HD8770
},
1667 /* Southern Islands */
1668 {"OLAND", CARD_AMD_RADEON_HD8670
},
1669 {"HAINAN", CARD_AMD_RADEON_HD8600M
},
1670 {"TAHITI", CARD_AMD_RADEON_HD7900
},
1671 {"PITCAIRN", CARD_AMD_RADEON_HD7800
},
1672 {"CAPE VERDE", CARD_AMD_RADEON_HD7700
},
1673 /* Northern Islands */
1674 {"ARUBA", CARD_AMD_RADEON_HD7660D
},
1675 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1676 {"BARTS", CARD_AMD_RADEON_HD6800
},
1677 {"TURKS", CARD_AMD_RADEON_HD6600
},
1678 {"SUMO2", CARD_AMD_RADEON_HD6410D
}, /* SUMO2 first, because we do a strstr(). */
1679 {"SUMO", CARD_AMD_RADEON_HD6550D
},
1680 {"CAICOS", CARD_AMD_RADEON_HD6400
},
1681 {"PALM", CARD_AMD_RADEON_HD6300
},
1683 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1684 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1685 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1686 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1687 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1689 {"R700", CARD_AMD_RADEON_HD4800
},
1690 {"RV790", CARD_AMD_RADEON_HD4800
},
1691 {"RV770", CARD_AMD_RADEON_HD4800
},
1692 {"RV740", CARD_AMD_RADEON_HD4700
},
1693 {"RV730", CARD_AMD_RADEON_HD4600
},
1694 {"RV710", CARD_AMD_RADEON_HD4350
},
1695 /* R600/R700 integrated */
1696 {"RS880", CARD_AMD_RADEON_HD4200M
},
1697 {"RS780", CARD_AMD_RADEON_HD3200
},
1699 {"R680", CARD_AMD_RADEON_HD2900
},
1700 {"R600", CARD_AMD_RADEON_HD2900
},
1701 {"RV670", CARD_AMD_RADEON_HD3850
},
1702 {"RV635", CARD_AMD_RADEON_HD2600
},
1703 {"RV630", CARD_AMD_RADEON_HD2600
},
1704 {"RV620", CARD_AMD_RADEON_HD2350
},
1705 {"RV610", CARD_AMD_RADEON_HD2350
},
1707 {"R580", CARD_AMD_RADEON_X1600
},
1708 {"R520", CARD_AMD_RADEON_X1600
},
1709 {"RV570", CARD_AMD_RADEON_X1600
},
1710 {"RV560", CARD_AMD_RADEON_X1600
},
1711 {"RV535", CARD_AMD_RADEON_X1600
},
1712 {"RV530", CARD_AMD_RADEON_X1600
},
1713 {"RV516", CARD_AMD_RADEON_X700
},
1714 {"RV515", CARD_AMD_RADEON_X700
},
1716 {"R481", CARD_AMD_RADEON_X700
},
1717 {"R480", CARD_AMD_RADEON_X700
},
1718 {"R430", CARD_AMD_RADEON_X700
},
1719 {"R423", CARD_AMD_RADEON_X700
},
1720 {"R420", CARD_AMD_RADEON_X700
},
1721 {"R410", CARD_AMD_RADEON_X700
},
1722 {"RV410", CARD_AMD_RADEON_X700
},
1723 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */
1724 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1725 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1726 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1727 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1728 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1729 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1730 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1731 {"RC410", CARD_AMD_RADEON_XPRESS_200M
},
1733 {"R360", CARD_AMD_RADEON_9500
},
1734 {"R350", CARD_AMD_RADEON_9500
},
1735 {"R300", CARD_AMD_RADEON_9500
},
1736 {"RV380", CARD_AMD_RADEON_9500
},
1737 {"RV370", CARD_AMD_RADEON_9500
},
1738 {"RV360", CARD_AMD_RADEON_9500
},
1739 {"RV351", CARD_AMD_RADEON_9500
},
1740 {"RV350", CARD_AMD_RADEON_9500
},
1742 cards_nvidia_mesa
[] =
1745 {"NV124", CARD_NVIDIA_GEFORCE_GTX970
},
1746 {"NV120", CARD_NVIDIA_GEFORCE_GTX980TI
},
1747 {"NV118", CARD_NVIDIA_GEFORCE_840M
},
1748 {"NV117", CARD_NVIDIA_GEFORCE_GTX750
},
1750 {"NV108", CARD_NVIDIA_GEFORCE_GT740M
},
1751 {"NV106", CARD_NVIDIA_GEFORCE_GT720
},
1752 {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI
},
1753 {"NVF0", CARD_NVIDIA_GEFORCE_GTX780
},
1754 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M
},
1755 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680
}, /* 690 / 675MX / 760TI */
1757 {"NVD9", CARD_NVIDIA_GEFORCE_GT520
},
1758 {"NVD7", CARD_NVIDIA_GEFORCE_820M
},
1759 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550
},
1760 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560
},
1761 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
1762 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
1763 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
1764 {"NVC1", CARD_NVIDIA_GEFORCE_GT420
},
1765 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
1767 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
1768 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
1769 {"NVAA", CARD_NVIDIA_GEFORCE_8200
}, /* 8100 */
1770 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
1771 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
1772 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
1773 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
1774 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
1775 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
1776 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
1777 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
1778 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
1779 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
1780 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
1782 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
1783 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
1784 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
1785 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
1786 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
1787 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
1788 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
1789 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
1790 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
1791 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
1792 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
1793 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
1794 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
1795 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
1796 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
1797 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
1799 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
1800 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
1801 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
1802 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
1803 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
1804 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
1806 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200
},
1807 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200
},
1808 {"nv20", CARD_NVIDIA_GEFORCE3
},
1810 {"nv1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
1811 {"nv1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
1812 {"nv18", CARD_NVIDIA_GEFORCE4_MX
},
1813 {"nv17", CARD_NVIDIA_GEFORCE4_MX
},
1814 {"nv16", CARD_NVIDIA_GEFORCE2
},
1815 {"nv15", CARD_NVIDIA_GEFORCE2
},
1816 {"nv11", CARD_NVIDIA_GEFORCE2_MX
},
1817 {"nv10", CARD_NVIDIA_GEFORCE
},
1819 {"nv05", CARD_NVIDIA_RIVA_TNT2
},
1820 {"nv04", CARD_NVIDIA_RIVA_TNT
},
1821 {"nv03", CARD_NVIDIA_RIVA_128
},
1825 {"virgl", CARD_REDHAT_VIRGL
},
1829 {"SVGA3D", CARD_VMWARE_SVGA3D
},
1832 static const struct gl_vendor_selection
1834 enum wined3d_gl_vendor gl_vendor
;
1835 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
1836 const struct wined3d_renderer_table
*cards
; /* To be used as cards[], pointer to the first member in an array */
1837 size_t cards_size
; /* Number of entries in the array above */
1839 amd_gl_vendor_table
[] =
1841 {GL_VENDOR_APPLE
, "Apple OSX AMD/ATI binary driver", cards_amd_binary
, ARRAY_SIZE(cards_amd_binary
)},
1842 {GL_VENDOR_FGLRX
, "AMD/ATI binary driver", cards_amd_binary
, ARRAY_SIZE(cards_amd_binary
)},
1843 {GL_VENDOR_MESA
, "Mesa AMD/ATI driver", cards_amd_mesa
, ARRAY_SIZE(cards_amd_mesa
)},
1845 nvidia_gl_vendor_table
[] =
1847 {GL_VENDOR_APPLE
, "Apple OSX NVidia binary driver", cards_nvidia_binary
, ARRAY_SIZE(cards_nvidia_binary
)},
1848 {GL_VENDOR_MESA
, "Mesa Nouveau driver", cards_nvidia_mesa
, ARRAY_SIZE(cards_nvidia_mesa
)},
1849 {GL_VENDOR_NVIDIA
, "NVIDIA binary driver", cards_nvidia_binary
, ARRAY_SIZE(cards_nvidia_binary
)},
1851 redhat_gl_vendor_table
[] =
1853 {GL_VENDOR_MESA
, "Red Hat driver", cards_redhat
, ARRAY_SIZE(cards_redhat
)},
1855 vmware_gl_vendor_table
[] =
1857 {GL_VENDOR_MESA
, "VMware driver", cards_vmware
, ARRAY_SIZE(cards_vmware
)},
1859 intel_gl_vendor_table
[] =
1861 {GL_VENDOR_APPLE
, "Apple OSX Intel binary driver", cards_intel
, ARRAY_SIZE(cards_intel
)},
1862 {GL_VENDOR_MESA
, "Mesa Intel driver", cards_intel
, ARRAY_SIZE(cards_intel
)},
1865 static enum wined3d_pci_device
select_card_handler(const struct gl_vendor_selection
*table
,
1866 unsigned int table_size
, enum wined3d_gl_vendor gl_vendor
, const char *gl_renderer
)
1870 for (i
= 0; i
< table_size
; ++i
)
1872 if (table
[i
].gl_vendor
!= gl_vendor
)
1875 TRACE("Applying card selector \"%s\".\n", table
[i
].description
);
1877 for (j
= 0; j
< table
[i
].cards_size
; ++j
)
1879 if (strstr(gl_renderer
, table
[i
].cards
[j
].renderer
))
1880 return table
[i
].cards
[j
].id
;
1882 return PCI_DEVICE_NONE
;
1884 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
1885 gl_vendor
, debugstr_a(gl_renderer
));
1887 return PCI_DEVICE_NONE
;
1892 enum wined3d_pci_vendor card_vendor
;
1893 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
1894 const struct gl_vendor_selection
*gl_vendor_selection
;
1895 unsigned int gl_vendor_count
;
1897 card_vendor_table
[] =
1899 {HW_VENDOR_AMD
, "AMD", amd_gl_vendor_table
, ARRAY_SIZE(amd_gl_vendor_table
)},
1900 {HW_VENDOR_NVIDIA
, "NVIDIA", nvidia_gl_vendor_table
, ARRAY_SIZE(nvidia_gl_vendor_table
)},
1901 {HW_VENDOR_REDHAT
, "Red Hat",redhat_gl_vendor_table
, ARRAY_SIZE(redhat_gl_vendor_table
)},
1902 {HW_VENDOR_VMWARE
, "VMware", vmware_gl_vendor_table
, ARRAY_SIZE(vmware_gl_vendor_table
)},
1903 {HW_VENDOR_INTEL
, "Intel", intel_gl_vendor_table
, ARRAY_SIZE(intel_gl_vendor_table
)},
1906 static enum wined3d_pci_device
wined3d_guess_card(enum wined3d_feature_level feature_level
,
1907 const char *gl_renderer
, enum wined3d_gl_vendor
*gl_vendor
,
1908 enum wined3d_pci_vendor
*card_vendor
)
1910 /* A Direct3D device object contains the PCI id (vendor + device) of the
1911 * videocard which is used for rendering. Various applications use this
1912 * information to get a rough estimation of the features of the card and
1913 * some might use it for enabling 3d effects only on certain types of
1914 * videocards. In some cases games might even use it to work around bugs
1915 * which happen on certain videocards/driver combinations. The problem is
1916 * that OpenGL only exposes a rendering string containing the name of the
1917 * videocard and not the PCI id.
1919 * Various games depend on the PCI id, so somehow we need to provide one.
1920 * A simple option is to parse the renderer string and translate this to
1921 * the right PCI id. This is a lot of work because there are more than 200
1922 * GPUs just for NVIDIA. Various cards share the same renderer string, so
1923 * the amount of code might be 'small' but there are quite a number of
1924 * exceptions which would make this a pain to maintain. Another way would
1925 * be to query the PCI id from the operating system (assuming this is the
1926 * videocard which is used for rendering which is not always the case).
1927 * This would work but it is not very portable. Second it would not work
1928 * well in, let's say, a remote X situation in which the amount of 3d
1929 * features which can be used is limited.
1931 * As said most games only use the PCI id to get an indication of the
1932 * capabilities of the card. It doesn't really matter if the given id is
1933 * the correct one if we return the id of a card with similar 3d features.
1935 * The code below checks the OpenGL capabilities of a videocard and matches
1936 * that to a certain level of Direct3D functionality. Once a card passes
1937 * the Direct3D9 check, we know that the card (in case of NVIDIA) is at
1938 * least a GeforceFX. To give a better estimate we do a basic check on the
1939 * renderer string but if that won't pass we return a default card. This
1940 * way is better than maintaining a full card database as even without a
1941 * full database we can return a card with similar features. Second the
1942 * size of the database can be made quite small because when you know what
1943 * type of 3d functionality a card has, you know to which GPU family the
1944 * GPU must belong. Because of this you only have to check a small part of
1945 * the renderer string to distinguish between different models from that
1948 * The code also selects a default amount of video memory which we will
1949 * use for an estimation of the amount of free texture memory. In case of
1950 * real D3D the amount of texture memory includes video memory and system
1951 * memory (to be specific AGP memory or in case of PCIE TurboCache /
1952 * HyperMemory). We don't know how much system memory can be addressed by
1953 * the system but we can make a reasonable estimation about the amount of
1954 * video memory. If the value is slightly wrong it doesn't matter as we
1955 * didn't include AGP-like memory which makes the amount of addressable
1956 * memory higher and second OpenGL isn't that critical it moves to system
1957 * memory behind our backs if really needed. Note that the amount of video
1958 * memory can be overruled using a registry setting. */
1960 enum wined3d_pci_device device
;
1963 for (i
= 0; i
< ARRAY_SIZE(card_vendor_table
); ++i
)
1965 if (card_vendor_table
[i
].card_vendor
!= *card_vendor
)
1968 TRACE("Applying card selector \"%s\".\n", card_vendor_table
[i
].description
);
1969 device
= select_card_handler(card_vendor_table
[i
].gl_vendor_selection
,
1970 card_vendor_table
[i
].gl_vendor_count
, *gl_vendor
, gl_renderer
);
1971 if (device
!= PCI_DEVICE_NONE
)
1974 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer
));
1976 return wined3d_gpu_from_feature_level(card_vendor
, feature_level
);
1979 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
1980 *card_vendor
, debugstr_a(gl_renderer
));
1982 return wined3d_gpu_from_feature_level(card_vendor
, feature_level
);
1985 static const struct wined3d_vertex_pipe_ops
*select_vertex_implementation(const struct wined3d_gl_info
*gl_info
,
1986 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
1988 if (shader_backend_ops
== &glsl_shader_backend
&& gl_info
->supported
[ARB_VERTEX_SHADER
])
1989 return &glsl_vertex_pipe
;
1990 return &ffp_vertex_pipe
;
1993 static const struct wined3d_fragment_pipe_ops
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
,
1994 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
1996 if (shader_backend_ops
== &glsl_shader_backend
&& gl_info
->supported
[ARB_FRAGMENT_SHADER
])
1997 return &glsl_fragment_pipe
;
1998 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
1999 return &arbfp_fragment_pipeline
;
2000 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
2001 return &atifs_fragment_pipeline
;
2002 if (gl_info
->supported
[NV_REGISTER_COMBINERS
] && gl_info
->supported
[NV_TEXTURE_SHADER2
])
2003 return &nvts_fragment_pipeline
;
2004 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2005 return &nvrc_fragment_pipeline
;
2006 return &ffp_fragment_pipeline
;
2009 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2011 BOOL glsl
= wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_AUTO
2012 || wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_GLSL
;
2013 BOOL arb
= wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_AUTO
2014 || wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_ARB
;
2016 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
] && !glsl
)
2018 ERR_(winediag
)("Ignoring the shader backend registry key. "
2019 "GLSL is the only shader backend available on core profile contexts. "
2020 "You need to explicitly set GL version to use legacy contexts.\n");
2024 glsl
= glsl
&& gl_info
->glsl_version
>= MAKEDWORD_VERSION(1, 20);
2026 if (glsl
&& gl_info
->supported
[ARB_VERTEX_SHADER
] && gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2027 return &glsl_shader_backend
;
2028 if (arb
&& gl_info
->supported
[ARB_VERTEX_PROGRAM
] && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2029 return &arb_program_shader_backend
;
2030 if (glsl
&& (gl_info
->supported
[ARB_VERTEX_SHADER
] || gl_info
->supported
[ARB_FRAGMENT_SHADER
]))
2031 return &glsl_shader_backend
;
2032 if (arb
&& (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]))
2033 return &arb_program_shader_backend
;
2034 return &none_shader_backend
;
2037 static void parse_extension_string(struct wined3d_gl_info
*gl_info
, const char *extensions
,
2038 const struct wined3d_extension_map
*map
, UINT entry_count
)
2046 while (isspace(*extensions
))
2049 while (!isspace(*extensions
) && *extensions
)
2052 len
= extensions
- start
;
2056 TRACE("- %s.\n", debugstr_an(start
, len
));
2058 for (i
= 0; i
< entry_count
; ++i
)
2060 if (len
== strlen(map
[i
].extension_string
)
2061 && !memcmp(start
, map
[i
].extension_string
, len
))
2063 TRACE(" FOUND: %s support.\n", map
[i
].extension_string
);
2064 gl_info
->supported
[map
[i
].extension
] = TRUE
;
2071 static void enumerate_gl_extensions(struct wined3d_gl_info
*gl_info
,
2072 const struct wined3d_extension_map
*map
, unsigned int map_entries_count
)
2074 const char *gl_extension_name
;
2076 GLint extensions_count
;
2078 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_NUM_EXTENSIONS
, &extensions_count
);
2079 for (i
= 0; i
< extensions_count
; ++i
)
2081 gl_extension_name
= (const char *)GL_EXTCALL(glGetStringi(GL_EXTENSIONS
, i
));
2082 TRACE("- %s.\n", debugstr_a(gl_extension_name
));
2083 for (j
= 0; j
< map_entries_count
; ++j
)
2085 if (!strcmp(gl_extension_name
, map
[j
].extension_string
))
2087 TRACE("FOUND: %s support.\n", map
[j
].extension_string
);
2088 gl_info
->supported
[map
[j
].extension
] = TRUE
;
2095 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
)
2097 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2098 /* GL_APPLE_fence */
2099 USE_GL_FUNC(glDeleteFencesAPPLE
)
2100 USE_GL_FUNC(glFinishFenceAPPLE
)
2101 USE_GL_FUNC(glFinishObjectAPPLE
)
2102 USE_GL_FUNC(glGenFencesAPPLE
)
2103 USE_GL_FUNC(glIsFenceAPPLE
)
2104 USE_GL_FUNC(glSetFenceAPPLE
)
2105 USE_GL_FUNC(glTestFenceAPPLE
)
2106 USE_GL_FUNC(glTestObjectAPPLE
)
2107 /* GL_APPLE_flush_buffer_range */
2108 USE_GL_FUNC(glBufferParameteriAPPLE
)
2109 USE_GL_FUNC(glFlushMappedBufferRangeAPPLE
)
2110 /* GL_ARB_base_instance */
2111 USE_GL_FUNC(glDrawArraysInstancedBaseInstance
)
2112 USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance
)
2113 /* GL_ARB_blend_func_extended */
2114 USE_GL_FUNC(glBindFragDataLocationIndexed
)
2115 USE_GL_FUNC(glGetFragDataIndex
)
2116 /* GL_ARB_buffer_storage */
2117 USE_GL_FUNC(glBufferStorage
)
2118 /* GL_ARB_clear_buffer_object */
2119 USE_GL_FUNC(glClearBufferData
)
2120 USE_GL_FUNC(glClearBufferSubData
)
2121 /* GL_ARB_clear_texture */
2122 USE_GL_FUNC(glClearTexImage
)
2123 USE_GL_FUNC(glClearTexSubImage
)
2124 /* GL_ARB_clip_control */
2125 USE_GL_FUNC(glClipControl
)
2126 /* GL_ARB_color_buffer_float */
2127 USE_GL_FUNC(glClampColorARB
)
2128 /* GL_ARB_compute_shader */
2129 USE_GL_FUNC(glDispatchCompute
)
2130 USE_GL_FUNC(glDispatchComputeIndirect
)
2131 /* GL_ARB_copy_buffer */
2132 USE_GL_FUNC(glCopyBufferSubData
)
2133 /* GL_ARB_copy_image */
2134 USE_GL_FUNC(glCopyImageSubData
)
2135 /* GL_ARB_debug_output */
2136 USE_GL_FUNC(glDebugMessageCallbackARB
)
2137 USE_GL_FUNC(glDebugMessageControlARB
)
2138 USE_GL_FUNC(glDebugMessageInsertARB
)
2139 USE_GL_FUNC(glGetDebugMessageLogARB
)
2140 /* GL_ARB_draw_buffers */
2141 USE_GL_FUNC(glDrawBuffersARB
)
2142 /* GL_ARB_draw_buffers_blend */
2143 USE_GL_FUNC(glBlendEquationiARB
)
2144 USE_GL_FUNC(glBlendEquationSeparateiARB
)
2145 USE_GL_FUNC(glBlendFunciARB
)
2146 USE_GL_FUNC(glBlendFuncSeparateiARB
)
2147 /* GL_ARB_draw_elements_base_vertex */
2148 USE_GL_FUNC(glDrawElementsBaseVertex
)
2149 USE_GL_FUNC(glDrawElementsInstancedBaseVertex
)
2150 USE_GL_FUNC(glDrawRangeElementsBaseVertex
)
2151 USE_GL_FUNC(glMultiDrawElementsBaseVertex
)
2152 /* GL_ARB_draw_indirect */
2153 USE_GL_FUNC(glDrawArraysIndirect
)
2154 USE_GL_FUNC(glDrawElementsIndirect
)
2155 /* GL_ARB_draw_instanced */
2156 USE_GL_FUNC(glDrawArraysInstancedARB
)
2157 USE_GL_FUNC(glDrawElementsInstancedARB
)
2158 /* GL_ARB_ES2_compatibility */
2159 USE_GL_FUNC(glReleaseShaderCompiler
)
2160 USE_GL_FUNC(glShaderBinary
)
2161 USE_GL_FUNC(glGetShaderPrecisionFormat
)
2162 USE_GL_FUNC(glDepthRangef
)
2163 USE_GL_FUNC(glClearDepthf
)
2164 /* GL_ARB_framebuffer_no_attachments */
2165 USE_GL_FUNC(glFramebufferParameteri
)
2166 /* GL_ARB_framebuffer_object */
2167 USE_GL_FUNC(glBindFramebuffer
)
2168 USE_GL_FUNC(glBindRenderbuffer
)
2169 USE_GL_FUNC(glBlitFramebuffer
)
2170 USE_GL_FUNC(glCheckFramebufferStatus
)
2171 USE_GL_FUNC(glDeleteFramebuffers
)
2172 USE_GL_FUNC(glDeleteRenderbuffers
)
2173 USE_GL_FUNC(glFramebufferRenderbuffer
)
2174 USE_GL_FUNC(glFramebufferTexture
)
2175 USE_GL_FUNC(glFramebufferTexture1D
)
2176 USE_GL_FUNC(glFramebufferTexture2D
)
2177 USE_GL_FUNC(glFramebufferTexture3D
)
2178 USE_GL_FUNC(glFramebufferTextureLayer
)
2179 USE_GL_FUNC(glGenFramebuffers
)
2180 USE_GL_FUNC(glGenRenderbuffers
)
2181 USE_GL_FUNC(glGenerateMipmap
)
2182 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv
)
2183 USE_GL_FUNC(glGetRenderbufferParameteriv
)
2184 USE_GL_FUNC(glIsFramebuffer
)
2185 USE_GL_FUNC(glIsRenderbuffer
)
2186 USE_GL_FUNC(glRenderbufferStorage
)
2187 USE_GL_FUNC(glRenderbufferStorageMultisample
)
2188 /* GL_ARB_geometry_shader4 */
2189 USE_GL_FUNC(glFramebufferTextureARB
)
2190 USE_GL_FUNC(glFramebufferTextureFaceARB
)
2191 USE_GL_FUNC(glFramebufferTextureLayerARB
)
2192 USE_GL_FUNC(glProgramParameteriARB
)
2193 /* GL_ARB_instanced_arrays */
2194 USE_GL_FUNC(glVertexAttribDivisorARB
)
2195 /* GL_ARB_internalformat_query */
2196 USE_GL_FUNC(glGetInternalformativ
)
2197 /* GL_ARB_internalformat_query2 */
2198 USE_GL_FUNC(glGetInternalformati64v
)
2199 /* GL_ARB_map_buffer_range */
2200 USE_GL_FUNC(glFlushMappedBufferRange
)
2201 USE_GL_FUNC(glMapBufferRange
)
2202 /* GL_ARB_multisample */
2203 USE_GL_FUNC(glSampleCoverageARB
)
2204 /* GL_ARB_multitexture */
2205 USE_GL_FUNC(glActiveTextureARB
)
2206 USE_GL_FUNC(glClientActiveTextureARB
)
2207 USE_GL_FUNC(glMultiTexCoord1fARB
)
2208 USE_GL_FUNC(glMultiTexCoord1fvARB
)
2209 USE_GL_FUNC(glMultiTexCoord2fARB
)
2210 USE_GL_FUNC(glMultiTexCoord2fvARB
)
2211 USE_GL_FUNC(glMultiTexCoord2svARB
)
2212 USE_GL_FUNC(glMultiTexCoord3fARB
)
2213 USE_GL_FUNC(glMultiTexCoord3fvARB
)
2214 USE_GL_FUNC(glMultiTexCoord4fARB
)
2215 USE_GL_FUNC(glMultiTexCoord4fvARB
)
2216 USE_GL_FUNC(glMultiTexCoord4svARB
)
2217 /* GL_ARB_occlusion_query */
2218 USE_GL_FUNC(glBeginQueryARB
)
2219 USE_GL_FUNC(glDeleteQueriesARB
)
2220 USE_GL_FUNC(glEndQueryARB
)
2221 USE_GL_FUNC(glGenQueriesARB
)
2222 USE_GL_FUNC(glGetQueryivARB
)
2223 USE_GL_FUNC(glGetQueryObjectivARB
)
2224 USE_GL_FUNC(glGetQueryObjectuivARB
)
2225 USE_GL_FUNC(glIsQueryARB
)
2226 /* GL_ARB_point_parameters */
2227 USE_GL_FUNC(glPointParameterfARB
)
2228 USE_GL_FUNC(glPointParameterfvARB
)
2229 /* GL_ARB_polgyon_offset_clamp */
2230 USE_GL_FUNC(glPolygonOffsetClamp
)
2231 /* GL_ARB_provoking_vertex */
2232 USE_GL_FUNC(glProvokingVertex
)
2233 /* GL_ARB_sample_shading */
2234 USE_GL_FUNC(glMinSampleShadingARB
)
2235 /* GL_ARB_sampler_objects */
2236 USE_GL_FUNC(glGenSamplers
)
2237 USE_GL_FUNC(glDeleteSamplers
)
2238 USE_GL_FUNC(glIsSampler
)
2239 USE_GL_FUNC(glBindSampler
)
2240 USE_GL_FUNC(glSamplerParameteri
)
2241 USE_GL_FUNC(glSamplerParameterf
)
2242 USE_GL_FUNC(glSamplerParameteriv
)
2243 USE_GL_FUNC(glSamplerParameterfv
)
2244 USE_GL_FUNC(glSamplerParameterIiv
)
2245 USE_GL_FUNC(glSamplerParameterIuiv
)
2246 USE_GL_FUNC(glGetSamplerParameteriv
)
2247 USE_GL_FUNC(glGetSamplerParameterfv
)
2248 USE_GL_FUNC(glGetSamplerParameterIiv
)
2249 USE_GL_FUNC(glGetSamplerParameterIuiv
)
2250 /* GL_ARB_shader_atomic_counters */
2251 USE_GL_FUNC(glGetActiveAtomicCounterBufferiv
)
2252 /* GL_ARB_shader_image_load_store */
2253 USE_GL_FUNC(glBindImageTexture
)
2254 USE_GL_FUNC(glMemoryBarrier
)
2255 /* GL_ARB_shader_objects */
2256 USE_GL_FUNC(glAttachObjectARB
)
2257 USE_GL_FUNC(glBindAttribLocationARB
)
2258 USE_GL_FUNC(glCompileShaderARB
)
2259 USE_GL_FUNC(glCreateProgramObjectARB
)
2260 USE_GL_FUNC(glCreateShaderObjectARB
)
2261 USE_GL_FUNC(glDeleteObjectARB
)
2262 USE_GL_FUNC(glDetachObjectARB
)
2263 USE_GL_FUNC(glGetActiveUniformARB
)
2264 USE_GL_FUNC(glGetAttachedObjectsARB
)
2265 USE_GL_FUNC(glGetAttribLocationARB
)
2266 USE_GL_FUNC(glGetHandleARB
)
2267 USE_GL_FUNC(glGetInfoLogARB
)
2268 USE_GL_FUNC(glGetObjectParameterfvARB
)
2269 USE_GL_FUNC(glGetObjectParameterivARB
)
2270 USE_GL_FUNC(glGetShaderSourceARB
)
2271 USE_GL_FUNC(glGetUniformLocationARB
)
2272 USE_GL_FUNC(glGetUniformfvARB
)
2273 USE_GL_FUNC(glGetUniformivARB
)
2274 USE_GL_FUNC(glLinkProgramARB
)
2275 USE_GL_FUNC(glShaderSourceARB
)
2276 USE_GL_FUNC(glUniform1fARB
)
2277 USE_GL_FUNC(glUniform1fvARB
)
2278 USE_GL_FUNC(glUniform1iARB
)
2279 USE_GL_FUNC(glUniform1ivARB
)
2280 USE_GL_FUNC(glUniform2fARB
)
2281 USE_GL_FUNC(glUniform2fvARB
)
2282 USE_GL_FUNC(glUniform2iARB
)
2283 USE_GL_FUNC(glUniform2ivARB
)
2284 USE_GL_FUNC(glUniform3fARB
)
2285 USE_GL_FUNC(glUniform3fvARB
)
2286 USE_GL_FUNC(glUniform3iARB
)
2287 USE_GL_FUNC(glUniform3ivARB
)
2288 USE_GL_FUNC(glUniform4fARB
)
2289 USE_GL_FUNC(glUniform4fvARB
)
2290 USE_GL_FUNC(glUniform4iARB
)
2291 USE_GL_FUNC(glUniform4ivARB
)
2292 USE_GL_FUNC(glUniformMatrix2fvARB
)
2293 USE_GL_FUNC(glUniformMatrix3fvARB
)
2294 USE_GL_FUNC(glUniformMatrix4fvARB
)
2295 USE_GL_FUNC(glUseProgramObjectARB
)
2296 USE_GL_FUNC(glValidateProgramARB
)
2297 /* GL_ARB_shader_storage_buffer_object */
2298 USE_GL_FUNC(glShaderStorageBlockBinding
)
2300 USE_GL_FUNC(glClientWaitSync
)
2301 USE_GL_FUNC(glDeleteSync
)
2302 USE_GL_FUNC(glFenceSync
)
2303 USE_GL_FUNC(glGetInteger64v
)
2304 USE_GL_FUNC(glGetSynciv
)
2305 USE_GL_FUNC(glIsSync
)
2306 USE_GL_FUNC(glWaitSync
)
2307 /* GL_ARB_tessellation_shader */
2308 USE_GL_FUNC(glPatchParameteri
)
2309 USE_GL_FUNC(glPatchParameterfv
)
2310 /* GL_ARB_texture_buffer_object */
2311 USE_GL_FUNC(glTexBufferARB
)
2312 /* GL_ARB_texture_buffer_range */
2313 USE_GL_FUNC(glTexBufferRange
)
2314 /* GL_ARB_texture_compression */
2315 USE_GL_FUNC(glCompressedTexImage2DARB
)
2316 USE_GL_FUNC(glCompressedTexImage3DARB
)
2317 USE_GL_FUNC(glCompressedTexSubImage2DARB
)
2318 USE_GL_FUNC(glCompressedTexSubImage3DARB
)
2319 USE_GL_FUNC(glGetCompressedTexImageARB
)
2320 /* GL_ARB_texture_multisample */
2321 USE_GL_FUNC(glGetMultisamplefv
);
2322 USE_GL_FUNC(glSampleMaski
);
2323 USE_GL_FUNC(glTexImage2DMultisample
);
2324 USE_GL_FUNC(glTexImage3DMultisample
);
2325 /* GL_ARB_texture_storage */
2326 USE_GL_FUNC(glTexStorage1D
)
2327 USE_GL_FUNC(glTexStorage2D
)
2328 USE_GL_FUNC(glTexStorage3D
)
2329 /* GL_ARB_texture_storage_multisample */
2330 USE_GL_FUNC(glTexStorage2DMultisample
);
2331 USE_GL_FUNC(glTexStorage3DMultisample
);
2332 /* GL_ARB_texture_view */
2333 USE_GL_FUNC(glTextureView
)
2334 /* GL_ARB_timer_query */
2335 USE_GL_FUNC(glQueryCounter
)
2336 USE_GL_FUNC(glGetQueryObjectui64v
)
2337 /* GL_ARB_transform_feedback2 */
2338 USE_GL_FUNC(glBindTransformFeedback
);
2339 USE_GL_FUNC(glDeleteTransformFeedbacks
);
2340 USE_GL_FUNC(glDrawTransformFeedback
);
2341 USE_GL_FUNC(glGenTransformFeedbacks
);
2342 USE_GL_FUNC(glIsTransformFeedback
);
2343 USE_GL_FUNC(glPauseTransformFeedback
);
2344 USE_GL_FUNC(glResumeTransformFeedback
);
2345 /* GL_ARB_transform_feedback3 */
2346 USE_GL_FUNC(glBeginQueryIndexed
);
2347 USE_GL_FUNC(glDrawTransformFeedbackStream
);
2348 USE_GL_FUNC(glEndQueryIndexed
);
2349 USE_GL_FUNC(glGetQueryIndexediv
);
2350 /* GL_ARB_uniform_buffer_object */
2351 USE_GL_FUNC(glBindBufferBase
)
2352 USE_GL_FUNC(glBindBufferRange
)
2353 USE_GL_FUNC(glGetActiveUniformBlockName
)
2354 USE_GL_FUNC(glGetActiveUniformBlockiv
)
2355 USE_GL_FUNC(glGetActiveUniformName
)
2356 USE_GL_FUNC(glGetActiveUniformsiv
)
2357 USE_GL_FUNC(glGetIntegeri_v
)
2358 USE_GL_FUNC(glGetUniformBlockIndex
)
2359 USE_GL_FUNC(glGetUniformIndices
)
2360 USE_GL_FUNC(glUniformBlockBinding
)
2361 /* GL_ARB_vertex_buffer_object */
2362 USE_GL_FUNC(glBindBufferARB
)
2363 USE_GL_FUNC(glBufferDataARB
)
2364 USE_GL_FUNC(glBufferSubDataARB
)
2365 USE_GL_FUNC(glDeleteBuffersARB
)
2366 USE_GL_FUNC(glGenBuffersARB
)
2367 USE_GL_FUNC(glGetBufferParameterivARB
)
2368 USE_GL_FUNC(glGetBufferPointervARB
)
2369 USE_GL_FUNC(glGetBufferSubDataARB
)
2370 USE_GL_FUNC(glIsBufferARB
)
2371 USE_GL_FUNC(glMapBufferARB
)
2372 USE_GL_FUNC(glUnmapBufferARB
)
2373 /* GL_ARB_vertex_program */
2374 USE_GL_FUNC(glBindProgramARB
)
2375 USE_GL_FUNC(glDeleteProgramsARB
)
2376 USE_GL_FUNC(glDisableVertexAttribArrayARB
)
2377 USE_GL_FUNC(glEnableVertexAttribArrayARB
)
2378 USE_GL_FUNC(glGenProgramsARB
)
2379 USE_GL_FUNC(glGetProgramivARB
)
2380 USE_GL_FUNC(glProgramEnvParameter4fvARB
)
2381 USE_GL_FUNC(glProgramLocalParameter4fvARB
)
2382 USE_GL_FUNC(glProgramStringARB
)
2383 USE_GL_FUNC(glVertexAttrib1dARB
)
2384 USE_GL_FUNC(glVertexAttrib1dvARB
)
2385 USE_GL_FUNC(glVertexAttrib1fARB
)
2386 USE_GL_FUNC(glVertexAttrib1fvARB
)
2387 USE_GL_FUNC(glVertexAttrib1sARB
)
2388 USE_GL_FUNC(glVertexAttrib1svARB
)
2389 USE_GL_FUNC(glVertexAttrib2dARB
)
2390 USE_GL_FUNC(glVertexAttrib2dvARB
)
2391 USE_GL_FUNC(glVertexAttrib2fARB
)
2392 USE_GL_FUNC(glVertexAttrib2fvARB
)
2393 USE_GL_FUNC(glVertexAttrib2sARB
)
2394 USE_GL_FUNC(glVertexAttrib2svARB
)
2395 USE_GL_FUNC(glVertexAttrib3dARB
)
2396 USE_GL_FUNC(glVertexAttrib3dvARB
)
2397 USE_GL_FUNC(glVertexAttrib3fARB
)
2398 USE_GL_FUNC(glVertexAttrib3fvARB
)
2399 USE_GL_FUNC(glVertexAttrib3sARB
)
2400 USE_GL_FUNC(glVertexAttrib3svARB
)
2401 USE_GL_FUNC(glVertexAttrib4NbvARB
)
2402 USE_GL_FUNC(glVertexAttrib4NivARB
)
2403 USE_GL_FUNC(glVertexAttrib4NsvARB
)
2404 USE_GL_FUNC(glVertexAttrib4NubARB
)
2405 USE_GL_FUNC(glVertexAttrib4NubvARB
)
2406 USE_GL_FUNC(glVertexAttrib4NuivARB
)
2407 USE_GL_FUNC(glVertexAttrib4NusvARB
)
2408 USE_GL_FUNC(glVertexAttrib4bvARB
)
2409 USE_GL_FUNC(glVertexAttrib4dARB
)
2410 USE_GL_FUNC(glVertexAttrib4dvARB
)
2411 USE_GL_FUNC(glVertexAttrib4fARB
)
2412 USE_GL_FUNC(glVertexAttrib4fvARB
)
2413 USE_GL_FUNC(glVertexAttrib4ivARB
)
2414 USE_GL_FUNC(glVertexAttrib4sARB
)
2415 USE_GL_FUNC(glVertexAttrib4svARB
)
2416 USE_GL_FUNC(glVertexAttrib4ubvARB
)
2417 USE_GL_FUNC(glVertexAttrib4uivARB
)
2418 USE_GL_FUNC(glVertexAttrib4usvARB
)
2419 USE_GL_FUNC(glVertexAttribPointerARB
)
2420 /* GL_ARB_viewport_array */
2421 USE_GL_FUNC(glDepthRangeArrayv
)
2422 USE_GL_FUNC(glDepthRangeIndexed
)
2423 USE_GL_FUNC(glGetDoublei_v
)
2424 USE_GL_FUNC(glGetFloati_v
)
2425 USE_GL_FUNC(glScissorArrayv
)
2426 USE_GL_FUNC(glScissorIndexed
)
2427 USE_GL_FUNC(glScissorIndexedv
)
2428 USE_GL_FUNC(glViewportArrayv
)
2429 USE_GL_FUNC(glViewportIndexedf
)
2430 USE_GL_FUNC(glViewportIndexedfv
)
2431 /* GL_ARB_texture_barrier */
2432 USE_GL_FUNC(glTextureBarrier
);
2433 /* GL_ATI_fragment_shader */
2434 USE_GL_FUNC(glAlphaFragmentOp1ATI
)
2435 USE_GL_FUNC(glAlphaFragmentOp2ATI
)
2436 USE_GL_FUNC(glAlphaFragmentOp3ATI
)
2437 USE_GL_FUNC(glBeginFragmentShaderATI
)
2438 USE_GL_FUNC(glBindFragmentShaderATI
)
2439 USE_GL_FUNC(glColorFragmentOp1ATI
)
2440 USE_GL_FUNC(glColorFragmentOp2ATI
)
2441 USE_GL_FUNC(glColorFragmentOp3ATI
)
2442 USE_GL_FUNC(glDeleteFragmentShaderATI
)
2443 USE_GL_FUNC(glEndFragmentShaderATI
)
2444 USE_GL_FUNC(glGenFragmentShadersATI
)
2445 USE_GL_FUNC(glPassTexCoordATI
)
2446 USE_GL_FUNC(glSampleMapATI
)
2447 USE_GL_FUNC(glSetFragmentShaderConstantATI
)
2448 /* GL_ATI_separate_stencil */
2449 USE_GL_FUNC(glStencilOpSeparateATI
)
2450 USE_GL_FUNC(glStencilFuncSeparateATI
)
2451 /* GL_EXT_blend_color */
2452 USE_GL_FUNC(glBlendColorEXT
)
2453 /* GL_EXT_blend_equation_separate */
2454 USE_GL_FUNC(glBlendFuncSeparateEXT
)
2455 /* GL_EXT_blend_func_separate */
2456 USE_GL_FUNC(glBlendEquationSeparateEXT
)
2457 /* GL_EXT_blend_minmax */
2458 USE_GL_FUNC(glBlendEquationEXT
)
2459 /* GL_EXT_depth_bounds_test */
2460 USE_GL_FUNC(glDepthBoundsEXT
)
2461 /* GL_EXT_draw_buffers2 */
2462 USE_GL_FUNC(glColorMaskIndexedEXT
)
2463 USE_GL_FUNC(glDisableIndexedEXT
)
2464 USE_GL_FUNC(glEnableIndexedEXT
)
2465 USE_GL_FUNC(glGetBooleanIndexedvEXT
)
2466 USE_GL_FUNC(glGetIntegerIndexedvEXT
)
2467 USE_GL_FUNC(glIsEnabledIndexedEXT
)
2468 /* GL_EXT_fog_coord */
2469 USE_GL_FUNC(glFogCoordPointerEXT
)
2470 USE_GL_FUNC(glFogCoorddEXT
)
2471 USE_GL_FUNC(glFogCoorddvEXT
)
2472 USE_GL_FUNC(glFogCoordfEXT
)
2473 USE_GL_FUNC(glFogCoordfvEXT
)
2474 /* GL_EXT_framebuffer_blit */
2475 USE_GL_FUNC(glBlitFramebufferEXT
)
2476 /* GL_EXT_framebuffer_multisample */
2477 USE_GL_FUNC(glRenderbufferStorageMultisampleEXT
)
2478 /* GL_EXT_framebuffer_object */
2479 USE_GL_FUNC(glBindFramebufferEXT
)
2480 USE_GL_FUNC(glBindRenderbufferEXT
)
2481 USE_GL_FUNC(glCheckFramebufferStatusEXT
)
2482 USE_GL_FUNC(glDeleteFramebuffersEXT
)
2483 USE_GL_FUNC(glDeleteRenderbuffersEXT
)
2484 USE_GL_FUNC(glFramebufferRenderbufferEXT
)
2485 USE_GL_FUNC(glFramebufferTexture1DEXT
)
2486 USE_GL_FUNC(glFramebufferTexture2DEXT
)
2487 USE_GL_FUNC(glFramebufferTexture3DEXT
)
2488 USE_GL_FUNC(glGenFramebuffersEXT
)
2489 USE_GL_FUNC(glGenRenderbuffersEXT
)
2490 USE_GL_FUNC(glGenerateMipmapEXT
)
2491 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT
)
2492 USE_GL_FUNC(glGetRenderbufferParameterivEXT
)
2493 USE_GL_FUNC(glIsFramebufferEXT
)
2494 USE_GL_FUNC(glIsRenderbufferEXT
)
2495 USE_GL_FUNC(glRenderbufferStorageEXT
)
2496 /* GL_EXT_gpu_program_parameters */
2497 USE_GL_FUNC(glProgramEnvParameters4fvEXT
)
2498 USE_GL_FUNC(glProgramLocalParameters4fvEXT
)
2499 /* GL_EXT_gpu_shader4 */
2500 USE_GL_FUNC(glBindFragDataLocationEXT
)
2501 USE_GL_FUNC(glGetFragDataLocationEXT
)
2502 USE_GL_FUNC(glGetUniformuivEXT
)
2503 USE_GL_FUNC(glGetVertexAttribIivEXT
)
2504 USE_GL_FUNC(glGetVertexAttribIuivEXT
)
2505 USE_GL_FUNC(glUniform1uiEXT
)
2506 USE_GL_FUNC(glUniform1uivEXT
)
2507 USE_GL_FUNC(glUniform2uiEXT
)
2508 USE_GL_FUNC(glUniform2uivEXT
)
2509 USE_GL_FUNC(glUniform3uiEXT
)
2510 USE_GL_FUNC(glUniform3uivEXT
)
2511 USE_GL_FUNC(glUniform4uiEXT
)
2512 USE_GL_FUNC(glUniform4uivEXT
)
2513 USE_GL_FUNC(glVertexAttribI1iEXT
)
2514 USE_GL_FUNC(glVertexAttribI1ivEXT
)
2515 USE_GL_FUNC(glVertexAttribI1uiEXT
)
2516 USE_GL_FUNC(glVertexAttribI1uivEXT
)
2517 USE_GL_FUNC(glVertexAttribI2iEXT
)
2518 USE_GL_FUNC(glVertexAttribI2ivEXT
)
2519 USE_GL_FUNC(glVertexAttribI2uiEXT
)
2520 USE_GL_FUNC(glVertexAttribI2uivEXT
)
2521 USE_GL_FUNC(glVertexAttribI3iEXT
)
2522 USE_GL_FUNC(glVertexAttribI3ivEXT
)
2523 USE_GL_FUNC(glVertexAttribI3uiEXT
)
2524 USE_GL_FUNC(glVertexAttribI3uivEXT
)
2525 USE_GL_FUNC(glVertexAttribI4bvEXT
)
2526 USE_GL_FUNC(glVertexAttribI4iEXT
)
2527 USE_GL_FUNC(glVertexAttribI4ivEXT
)
2528 USE_GL_FUNC(glVertexAttribI4svEXT
)
2529 USE_GL_FUNC(glVertexAttribI4ubvEXT
)
2530 USE_GL_FUNC(glVertexAttribI4uiEXT
)
2531 USE_GL_FUNC(glVertexAttribI4uivEXT
)
2532 USE_GL_FUNC(glVertexAttribI4usvEXT
)
2533 USE_GL_FUNC(glVertexAttribIPointerEXT
)
2534 /* GL_EXT_memory_object */
2535 USE_GL_FUNC(glGetUnsignedBytei_vEXT
)
2536 USE_GL_FUNC(glGetUnsignedBytevEXT
)
2537 /* GL_EXT_point_parameters */
2538 USE_GL_FUNC(glPointParameterfEXT
)
2539 USE_GL_FUNC(glPointParameterfvEXT
)
2540 /* GL_EXT_polgyon_offset_clamp */
2541 USE_GL_FUNC(glPolygonOffsetClampEXT
)
2542 /* GL_EXT_provoking_vertex */
2543 USE_GL_FUNC(glProvokingVertexEXT
)
2544 /* GL_EXT_secondary_color */
2545 USE_GL_FUNC(glSecondaryColor3fEXT
)
2546 USE_GL_FUNC(glSecondaryColor3fvEXT
)
2547 USE_GL_FUNC(glSecondaryColor3ubEXT
)
2548 USE_GL_FUNC(glSecondaryColor3ubvEXT
)
2549 USE_GL_FUNC(glSecondaryColorPointerEXT
)
2550 /* GL_EXT_stencil_two_side */
2551 USE_GL_FUNC(glActiveStencilFaceEXT
)
2552 /* GL_EXT_texture3D */
2553 USE_GL_FUNC(glTexImage3D
)
2554 USE_GL_FUNC(glTexImage3DEXT
)
2555 USE_GL_FUNC(glTexSubImage3D
)
2556 USE_GL_FUNC(glTexSubImage3DEXT
)
2558 USE_GL_FUNC(glDeleteFencesNV
)
2559 USE_GL_FUNC(glFinishFenceNV
)
2560 USE_GL_FUNC(glGenFencesNV
)
2561 USE_GL_FUNC(glGetFenceivNV
)
2562 USE_GL_FUNC(glIsFenceNV
)
2563 USE_GL_FUNC(glSetFenceNV
)
2564 USE_GL_FUNC(glTestFenceNV
)
2565 /* GL_NV_half_float */
2566 USE_GL_FUNC(glColor3hNV
)
2567 USE_GL_FUNC(glColor3hvNV
)
2568 USE_GL_FUNC(glColor4hNV
)
2569 USE_GL_FUNC(glColor4hvNV
)
2570 USE_GL_FUNC(glFogCoordhNV
)
2571 USE_GL_FUNC(glFogCoordhvNV
)
2572 USE_GL_FUNC(glMultiTexCoord1hNV
)
2573 USE_GL_FUNC(glMultiTexCoord1hvNV
)
2574 USE_GL_FUNC(glMultiTexCoord2hNV
)
2575 USE_GL_FUNC(glMultiTexCoord2hvNV
)
2576 USE_GL_FUNC(glMultiTexCoord3hNV
)
2577 USE_GL_FUNC(glMultiTexCoord3hvNV
)
2578 USE_GL_FUNC(glMultiTexCoord4hNV
)
2579 USE_GL_FUNC(glMultiTexCoord4hvNV
)
2580 USE_GL_FUNC(glNormal3hNV
)
2581 USE_GL_FUNC(glNormal3hvNV
)
2582 USE_GL_FUNC(glSecondaryColor3hNV
)
2583 USE_GL_FUNC(glSecondaryColor3hvNV
)
2584 USE_GL_FUNC(glTexCoord1hNV
)
2585 USE_GL_FUNC(glTexCoord1hvNV
)
2586 USE_GL_FUNC(glTexCoord2hNV
)
2587 USE_GL_FUNC(glTexCoord2hvNV
)
2588 USE_GL_FUNC(glTexCoord3hNV
)
2589 USE_GL_FUNC(glTexCoord3hvNV
)
2590 USE_GL_FUNC(glTexCoord4hNV
)
2591 USE_GL_FUNC(glTexCoord4hvNV
)
2592 USE_GL_FUNC(glVertex2hNV
)
2593 USE_GL_FUNC(glVertex2hvNV
)
2594 USE_GL_FUNC(glVertex3hNV
)
2595 USE_GL_FUNC(glVertex3hvNV
)
2596 USE_GL_FUNC(glVertex4hNV
)
2597 USE_GL_FUNC(glVertex4hvNV
)
2598 USE_GL_FUNC(glVertexAttrib1hNV
)
2599 USE_GL_FUNC(glVertexAttrib1hvNV
)
2600 USE_GL_FUNC(glVertexAttrib2hNV
)
2601 USE_GL_FUNC(glVertexAttrib2hvNV
)
2602 USE_GL_FUNC(glVertexAttrib3hNV
)
2603 USE_GL_FUNC(glVertexAttrib3hvNV
)
2604 USE_GL_FUNC(glVertexAttrib4hNV
)
2605 USE_GL_FUNC(glVertexAttrib4hvNV
)
2606 USE_GL_FUNC(glVertexAttribs1hvNV
)
2607 USE_GL_FUNC(glVertexAttribs2hvNV
)
2608 USE_GL_FUNC(glVertexAttribs3hvNV
)
2609 USE_GL_FUNC(glVertexAttribs4hvNV
)
2610 USE_GL_FUNC(glVertexWeighthNV
)
2611 USE_GL_FUNC(glVertexWeighthvNV
)
2612 /* GL_NV_point_sprite */
2613 USE_GL_FUNC(glPointParameteriNV
)
2614 USE_GL_FUNC(glPointParameterivNV
)
2615 /* GL_NV_register_combiners */
2616 USE_GL_FUNC(glCombinerInputNV
)
2617 USE_GL_FUNC(glCombinerOutputNV
)
2618 USE_GL_FUNC(glCombinerParameterfNV
)
2619 USE_GL_FUNC(glCombinerParameterfvNV
)
2620 USE_GL_FUNC(glCombinerParameteriNV
)
2621 USE_GL_FUNC(glCombinerParameterivNV
)
2622 USE_GL_FUNC(glFinalCombinerInputNV
)
2623 /* GL_NV_texture_barrier */
2624 USE_GL_FUNC(glTextureBarrierNV
);
2625 /* WGL extensions */
2626 USE_GL_FUNC(wglChoosePixelFormatARB
)
2627 USE_GL_FUNC(wglGetExtensionsStringARB
)
2628 USE_GL_FUNC(wglGetPixelFormatAttribfvARB
)
2629 USE_GL_FUNC(wglGetPixelFormatAttribivARB
)
2630 USE_GL_FUNC(wglQueryCurrentRendererIntegerWINE
)
2631 USE_GL_FUNC(wglQueryCurrentRendererStringWINE
)
2632 USE_GL_FUNC(wglQueryRendererIntegerWINE
)
2633 USE_GL_FUNC(wglQueryRendererStringWINE
)
2634 USE_GL_FUNC(wglSetPixelFormatWINE
)
2635 USE_GL_FUNC(wglSwapIntervalEXT
)
2637 /* Newer core functions */
2638 USE_GL_FUNC(glActiveTexture
) /* OpenGL 1.3 */
2639 USE_GL_FUNC(glAttachShader
) /* OpenGL 2.0 */
2640 USE_GL_FUNC(glBeginQuery
) /* OpenGL 1.5 */
2641 USE_GL_FUNC(glBeginTransformFeedback
) /* OpenGL 3.0 */
2642 USE_GL_FUNC(glBindAttribLocation
) /* OpenGL 2.0 */
2643 USE_GL_FUNC(glBindBuffer
) /* OpenGL 1.5 */
2644 USE_GL_FUNC(glBindFragDataLocation
) /* OpenGL 3.0 */
2645 USE_GL_FUNC(glBindVertexArray
) /* OpenGL 3.0 */
2646 USE_GL_FUNC(glBlendColor
) /* OpenGL 1.4 */
2647 USE_GL_FUNC(glBlendEquation
) /* OpenGL 1.4 */
2648 USE_GL_FUNC(glBlendEquationi
) /* OpenGL 4.0 */
2649 USE_GL_FUNC(glBlendEquationSeparate
) /* OpenGL 2.0 */
2650 USE_GL_FUNC(glBlendEquationSeparatei
) /* OpenGL 4.0 */
2651 USE_GL_FUNC(glBlendFunci
) /* OpenGL 4.0 */
2652 USE_GL_FUNC(glBlendFuncSeparate
) /* OpenGL 1.4 */
2653 USE_GL_FUNC(glBlendFuncSeparatei
) /* OpenGL 4.0 */
2654 USE_GL_FUNC(glBufferData
) /* OpenGL 1.5 */
2655 USE_GL_FUNC(glBufferSubData
) /* OpenGL 1.5 */
2656 USE_GL_FUNC(glColorMaski
) /* OpenGL 3.0 */
2657 USE_GL_FUNC(glCompileShader
) /* OpenGL 2.0 */
2658 USE_GL_FUNC(glCompressedTexImage2D
) /* OpenGL 1.3 */
2659 USE_GL_FUNC(glCompressedTexImage3D
) /* OpenGL 1.3 */
2660 USE_GL_FUNC(glCompressedTexSubImage2D
) /* OpenGL 1.3 */
2661 USE_GL_FUNC(glCompressedTexSubImage3D
) /* OpenGL 1.3 */
2662 USE_GL_FUNC(glCreateProgram
) /* OpenGL 2.0 */
2663 USE_GL_FUNC(glCreateShader
) /* OpenGL 2.0 */
2664 USE_GL_FUNC(glDebugMessageCallback
) /* OpenGL 4.3 */
2665 USE_GL_FUNC(glDebugMessageControl
) /* OpenGL 4.3 */
2666 USE_GL_FUNC(glDebugMessageInsert
) /* OpenGL 4.3 */
2667 USE_GL_FUNC(glDeleteBuffers
) /* OpenGL 1.5 */
2668 USE_GL_FUNC(glDeleteProgram
) /* OpenGL 2.0 */
2669 USE_GL_FUNC(glDeleteQueries
) /* OpenGL 1.5 */
2670 USE_GL_FUNC(glDeleteShader
) /* OpenGL 2.0 */
2671 USE_GL_FUNC(glDeleteVertexArrays
) /* OpenGL 3.0 */
2672 USE_GL_FUNC(glDetachShader
) /* OpenGL 2.0 */
2673 USE_GL_FUNC(glDisablei
) /* OpenGL 3.0 */
2674 USE_GL_FUNC(glDisableVertexAttribArray
) /* OpenGL 2.0 */
2675 USE_GL_FUNC(glDrawArraysInstanced
) /* OpenGL 3.1 */
2676 USE_GL_FUNC(glDrawBuffers
) /* OpenGL 2.0 */
2677 USE_GL_FUNC(glDrawElementsInstanced
) /* OpenGL 3.1 */
2678 USE_GL_FUNC(glEnablei
) /* OpenGL 3.0 */
2679 USE_GL_FUNC(glEnableVertexAttribArray
) /* OpenGL 2.0 */
2680 USE_GL_FUNC(glEndQuery
) /* OpenGL 1.5 */
2681 USE_GL_FUNC(glEndTransformFeedback
) /* OpenGL 3.0 */
2682 USE_GL_FUNC(glFramebufferTexture
) /* OpenGL 3.2 */
2683 USE_GL_FUNC(glGenBuffers
) /* OpenGL 1.5 */
2684 USE_GL_FUNC(glGenQueries
) /* OpenGL 1.5 */
2685 USE_GL_FUNC(glGenVertexArrays
) /* OpenGL 3.0 */
2686 USE_GL_FUNC(glGetActiveUniform
) /* OpenGL 2.0 */
2687 USE_GL_FUNC(glGetAttachedShaders
) /* OpenGL 2.0 */
2688 USE_GL_FUNC(glGetAttribLocation
) /* OpenGL 2.0 */
2689 USE_GL_FUNC(glGetBooleani_v
) /* OpenGL 3.0 */
2690 USE_GL_FUNC(glGetBufferSubData
) /* OpenGL 1.5 */
2691 USE_GL_FUNC(glGetCompressedTexImage
) /* OpenGL 1.3 */
2692 USE_GL_FUNC(glGetDebugMessageLog
) /* OpenGL 4.3 */
2693 USE_GL_FUNC(glGetIntegeri_v
) /* OpenGL 3.0 */
2694 USE_GL_FUNC(glGetProgramInfoLog
) /* OpenGL 2.0 */
2695 USE_GL_FUNC(glGetProgramiv
) /* OpenGL 2.0 */
2696 USE_GL_FUNC(glGetQueryiv
) /* OpenGL 1.5 */
2697 USE_GL_FUNC(glGetQueryObjectuiv
) /* OpenGL 1.5 */
2698 USE_GL_FUNC(glGetShaderInfoLog
) /* OpenGL 2.0 */
2699 USE_GL_FUNC(glGetShaderiv
) /* OpenGL 2.0 */
2700 USE_GL_FUNC(glGetShaderSource
) /* OpenGL 2.0 */
2701 USE_GL_FUNC(glGetStringi
) /* OpenGL 3.0 */
2702 USE_GL_FUNC(glGetTextureLevelParameteriv
) /* OpenGL 4.5 */
2703 USE_GL_FUNC(glGetTextureParameteriv
) /* OpenGL 4.5 */
2704 USE_GL_FUNC(glGetUniformfv
) /* OpenGL 2.0 */
2705 USE_GL_FUNC(glGetUniformiv
) /* OpenGL 2.0 */
2706 USE_GL_FUNC(glGetUniformLocation
) /* OpenGL 2.0 */
2707 USE_GL_FUNC(glIsEnabledi
) /* OpenGL 3.0 */
2708 USE_GL_FUNC(glLinkProgram
) /* OpenGL 2.0 */
2709 USE_GL_FUNC(glMapBuffer
) /* OpenGL 1.5 */
2710 USE_GL_FUNC(glMinSampleShading
) /* OpenGL 4.0 */
2711 USE_GL_FUNC(glPointParameteri
) /* OpenGL 1.4 */
2712 USE_GL_FUNC(glPointParameteriv
) /* OpenGL 1.4 */
2713 USE_GL_FUNC(glShaderSource
) /* OpenGL 2.0 */
2714 USE_GL_FUNC(glStencilFuncSeparate
) /* OpenGL 2.0 */
2715 USE_GL_FUNC(glStencilOpSeparate
) /* OpenGL 2.0 */
2716 USE_GL_FUNC(glTexBuffer
) /* OpenGL 3.1 */
2717 USE_GL_FUNC(glTexImage3D
) /* OpenGL 1.2 */
2718 USE_GL_FUNC(glTexSubImage3D
) /* OpenGL 1.2 */
2719 USE_GL_FUNC(glTransformFeedbackVaryings
) /* OpenGL 3.0 */
2720 USE_GL_FUNC(glUniform1f
) /* OpenGL 2.0 */
2721 USE_GL_FUNC(glUniform1fv
) /* OpenGL 2.0 */
2722 USE_GL_FUNC(glUniform1i
) /* OpenGL 2.0 */
2723 USE_GL_FUNC(glUniform1iv
) /* OpenGL 2.0 */
2724 USE_GL_FUNC(glUniform2f
) /* OpenGL 2.0 */
2725 USE_GL_FUNC(glUniform2fv
) /* OpenGL 2.0 */
2726 USE_GL_FUNC(glUniform2i
) /* OpenGL 2.0 */
2727 USE_GL_FUNC(glUniform2iv
) /* OpenGL 2.0 */
2728 USE_GL_FUNC(glUniform3f
) /* OpenGL 2.0 */
2729 USE_GL_FUNC(glUniform3fv
) /* OpenGL 2.0 */
2730 USE_GL_FUNC(glUniform3i
) /* OpenGL 2.0 */
2731 USE_GL_FUNC(glUniform3iv
) /* OpenGL 2.0 */
2732 USE_GL_FUNC(glUniform4f
) /* OpenGL 2.0 */
2733 USE_GL_FUNC(glUniform4fv
) /* OpenGL 2.0 */
2734 USE_GL_FUNC(glUniform4i
) /* OpenGL 2.0 */
2735 USE_GL_FUNC(glUniform4iv
) /* OpenGL 2.0 */
2736 USE_GL_FUNC(glUniformMatrix2fv
) /* OpenGL 2.0 */
2737 USE_GL_FUNC(glUniformMatrix3fv
) /* OpenGL 2.0 */
2738 USE_GL_FUNC(glUniformMatrix4fv
) /* OpenGL 2.0 */
2739 USE_GL_FUNC(glUnmapBuffer
) /* OpenGL 1.5 */
2740 USE_GL_FUNC(glUseProgram
) /* OpenGL 2.0 */
2741 USE_GL_FUNC(glValidateProgram
) /* OpenGL 2.0 */
2742 USE_GL_FUNC(glVertexAttrib1f
) /* OpenGL 2.0 */
2743 USE_GL_FUNC(glVertexAttrib1fv
) /* OpenGL 2.0 */
2744 USE_GL_FUNC(glVertexAttrib2f
) /* OpenGL 2.0 */
2745 USE_GL_FUNC(glVertexAttrib2fv
) /* OpenGL 2.0 */
2746 USE_GL_FUNC(glVertexAttrib3f
) /* OpenGL 2.0 */
2747 USE_GL_FUNC(glVertexAttrib3fv
) /* OpenGL 2.0 */
2748 USE_GL_FUNC(glVertexAttrib4f
) /* OpenGL 2.0 */
2749 USE_GL_FUNC(glVertexAttrib4fv
) /* OpenGL 2.0 */
2750 USE_GL_FUNC(glVertexAttrib4Nsv
) /* OpenGL 2.0 */
2751 USE_GL_FUNC(glVertexAttrib4Nub
) /* OpenGL 2.0 */
2752 USE_GL_FUNC(glVertexAttrib4Nubv
) /* OpenGL 2.0 */
2753 USE_GL_FUNC(glVertexAttrib4Nusv
) /* OpenGL 2.0 */
2754 USE_GL_FUNC(glVertexAttrib4sv
) /* OpenGL 2.0 */
2755 USE_GL_FUNC(glVertexAttrib4ubv
) /* OpenGL 2.0 */
2756 USE_GL_FUNC(glVertexAttribDivisor
) /* OpenGL 3.3 */
2757 USE_GL_FUNC(glVertexAttribIPointer
) /* OpenGL 3.0 */
2758 USE_GL_FUNC(glVertexAttribPointer
) /* OpenGL 2.0 */
2761 #define MAP_GL_FUNCTION(core_func, ext_func) \
2764 if (!gl_info->gl_ops.ext.p_##core_func) \
2765 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
2767 #define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
2770 if (!gl_info->gl_ops.ext.p_##core_func) \
2771 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
2774 MAP_GL_FUNCTION(glActiveTexture
, glActiveTextureARB
);
2775 MAP_GL_FUNCTION(glAttachShader
, glAttachObjectARB
);
2776 MAP_GL_FUNCTION(glBeginQuery
, glBeginQueryARB
);
2777 MAP_GL_FUNCTION(glBindAttribLocation
, glBindAttribLocationARB
);
2778 MAP_GL_FUNCTION(glBindBuffer
, glBindBufferARB
);
2779 MAP_GL_FUNCTION(glBindFragDataLocation
, glBindFragDataLocationEXT
);
2780 MAP_GL_FUNCTION(glBlendColor
, glBlendColorEXT
);
2781 MAP_GL_FUNCTION(glBlendEquation
, glBlendEquationEXT
);
2782 MAP_GL_FUNCTION(glBlendEquationi
, glBlendEquationiARB
);
2783 MAP_GL_FUNCTION(glBlendEquationSeparate
, glBlendEquationSeparateEXT
);
2784 MAP_GL_FUNCTION(glBlendEquationSeparatei
, glBlendEquationSeparateiARB
);
2785 MAP_GL_FUNCTION(glBlendFunci
, glBlendFunciARB
);
2786 MAP_GL_FUNCTION(glBlendFuncSeparate
, glBlendFuncSeparateEXT
);
2787 MAP_GL_FUNCTION(glBlendFuncSeparatei
, glBlendFuncSeparateiARB
);
2788 MAP_GL_FUNCTION(glBufferData
, glBufferDataARB
);
2789 MAP_GL_FUNCTION(glBufferSubData
, glBufferSubDataARB
);
2790 MAP_GL_FUNCTION(glColorMaski
, glColorMaskIndexedEXT
);
2791 MAP_GL_FUNCTION(glCompileShader
, glCompileShaderARB
);
2792 MAP_GL_FUNCTION(glCompressedTexImage2D
, glCompressedTexImage2DARB
);
2793 MAP_GL_FUNCTION(glCompressedTexImage3D
, glCompressedTexImage3DARB
);
2794 MAP_GL_FUNCTION(glCompressedTexSubImage2D
, glCompressedTexSubImage2DARB
);
2795 MAP_GL_FUNCTION(glCompressedTexSubImage3D
, glCompressedTexSubImage3DARB
);
2796 MAP_GL_FUNCTION(glCreateProgram
, glCreateProgramObjectARB
);
2797 MAP_GL_FUNCTION(glCreateShader
, glCreateShaderObjectARB
);
2798 MAP_GL_FUNCTION(glDebugMessageCallback
, glDebugMessageCallbackARB
);
2799 MAP_GL_FUNCTION(glDebugMessageControl
, glDebugMessageControlARB
);
2800 MAP_GL_FUNCTION(glDebugMessageInsert
, glDebugMessageInsertARB
);
2801 MAP_GL_FUNCTION(glDeleteBuffers
, glDeleteBuffersARB
);
2802 MAP_GL_FUNCTION(glDeleteProgram
, glDeleteObjectARB
);
2803 MAP_GL_FUNCTION(glDeleteQueries
, glDeleteQueriesARB
);
2804 MAP_GL_FUNCTION(glDeleteShader
, glDeleteObjectARB
);
2805 MAP_GL_FUNCTION(glDetachShader
, glDetachObjectARB
);
2806 MAP_GL_FUNCTION(glDisablei
, glDisableIndexedEXT
);
2807 MAP_GL_FUNCTION(glDisableVertexAttribArray
, glDisableVertexAttribArrayARB
);
2808 MAP_GL_FUNCTION(glDrawArraysInstanced
, glDrawArraysInstancedARB
);
2809 MAP_GL_FUNCTION(glDrawBuffers
, glDrawBuffersARB
);
2810 MAP_GL_FUNCTION(glDrawElementsInstanced
, glDrawElementsInstancedARB
);
2811 MAP_GL_FUNCTION(glEnablei
, glEnableIndexedEXT
);
2812 MAP_GL_FUNCTION(glEnableVertexAttribArray
, glEnableVertexAttribArrayARB
);
2813 MAP_GL_FUNCTION(glEndQuery
, glEndQueryARB
);
2814 MAP_GL_FUNCTION(glFramebufferTexture
, glFramebufferTextureARB
);
2815 MAP_GL_FUNCTION(glGenBuffers
, glGenBuffersARB
);
2816 MAP_GL_FUNCTION(glGenQueries
, glGenQueriesARB
);
2817 MAP_GL_FUNCTION(glGetActiveUniform
, glGetActiveUniformARB
);
2818 MAP_GL_FUNCTION(glGetAttachedShaders
, glGetAttachedObjectsARB
);
2819 MAP_GL_FUNCTION(glGetAttribLocation
, glGetAttribLocationARB
);
2820 MAP_GL_FUNCTION(glGetBooleani_v
, glGetBooleanIndexedvEXT
);
2821 MAP_GL_FUNCTION(glGetBufferSubData
, glGetBufferSubDataARB
);
2822 MAP_GL_FUNCTION(glGetCompressedTexImage
, glGetCompressedTexImageARB
);
2823 MAP_GL_FUNCTION(glGetDebugMessageLog
, glGetDebugMessageLogARB
);
2824 MAP_GL_FUNCTION(glGetIntegeri_v
, glGetIntegerIndexedvEXT
);
2825 MAP_GL_FUNCTION(glGetProgramInfoLog
, glGetInfoLogARB
);
2826 MAP_GL_FUNCTION(glGetProgramiv
, glGetObjectParameterivARB
);
2827 MAP_GL_FUNCTION(glGetQueryiv
, glGetQueryivARB
);
2828 MAP_GL_FUNCTION(glGetQueryObjectuiv
, glGetQueryObjectuivARB
);
2829 MAP_GL_FUNCTION(glGetShaderInfoLog
, glGetInfoLogARB
);
2830 MAP_GL_FUNCTION(glGetShaderiv
, glGetObjectParameterivARB
);
2831 MAP_GL_FUNCTION(glGetShaderSource
, glGetShaderSourceARB
);
2832 MAP_GL_FUNCTION(glGetUniformfv
, glGetUniformfvARB
);
2833 MAP_GL_FUNCTION(glGetUniformiv
, glGetUniformivARB
);
2834 MAP_GL_FUNCTION(glGetUniformLocation
, glGetUniformLocationARB
);
2835 MAP_GL_FUNCTION(glIsEnabledi
, glIsEnabledIndexedEXT
);
2836 MAP_GL_FUNCTION(glLinkProgram
, glLinkProgramARB
);
2837 MAP_GL_FUNCTION(glMapBuffer
, glMapBufferARB
);
2838 MAP_GL_FUNCTION(glMinSampleShading
, glMinSampleShadingARB
);
2839 MAP_GL_FUNCTION(glPolygonOffsetClamp
, glPolygonOffsetClampEXT
);
2840 MAP_GL_FUNCTION_CAST(glShaderSource
, glShaderSourceARB
);
2841 MAP_GL_FUNCTION(glTexBuffer
, glTexBufferARB
);
2842 MAP_GL_FUNCTION_CAST(glTexImage3D
, glTexImage3DEXT
);
2843 MAP_GL_FUNCTION(glTexSubImage3D
, glTexSubImage3DEXT
);
2844 MAP_GL_FUNCTION(glUniform1f
, glUniform1fARB
);
2845 MAP_GL_FUNCTION(glUniform1fv
, glUniform1fvARB
);
2846 MAP_GL_FUNCTION(glUniform1i
, glUniform1iARB
);
2847 MAP_GL_FUNCTION(glUniform1iv
, glUniform1ivARB
);
2848 MAP_GL_FUNCTION(glUniform2f
, glUniform2fARB
);
2849 MAP_GL_FUNCTION(glUniform2fv
, glUniform2fvARB
);
2850 MAP_GL_FUNCTION(glUniform2i
, glUniform2iARB
);
2851 MAP_GL_FUNCTION(glUniform2iv
, glUniform2ivARB
);
2852 MAP_GL_FUNCTION(glUniform3f
, glUniform3fARB
);
2853 MAP_GL_FUNCTION(glUniform3fv
, glUniform3fvARB
);
2854 MAP_GL_FUNCTION(glUniform3i
, glUniform3iARB
);
2855 MAP_GL_FUNCTION(glUniform3iv
, glUniform3ivARB
);
2856 MAP_GL_FUNCTION(glUniform4f
, glUniform4fARB
);
2857 MAP_GL_FUNCTION(glUniform4fv
, glUniform4fvARB
);
2858 MAP_GL_FUNCTION(glUniform4i
, glUniform4iARB
);
2859 MAP_GL_FUNCTION(glUniform4iv
, glUniform4ivARB
);
2860 MAP_GL_FUNCTION(glUniformMatrix2fv
, glUniformMatrix2fvARB
);
2861 MAP_GL_FUNCTION(glUniformMatrix3fv
, glUniformMatrix3fvARB
);
2862 MAP_GL_FUNCTION(glUniformMatrix4fv
, glUniformMatrix4fvARB
);
2863 MAP_GL_FUNCTION(glUnmapBuffer
, glUnmapBufferARB
);
2864 MAP_GL_FUNCTION(glUseProgram
, glUseProgramObjectARB
);
2865 MAP_GL_FUNCTION(glValidateProgram
, glValidateProgramARB
);
2866 MAP_GL_FUNCTION(glVertexAttrib1f
, glVertexAttrib1fARB
);
2867 MAP_GL_FUNCTION(glVertexAttrib1fv
, glVertexAttrib1fvARB
);
2868 MAP_GL_FUNCTION(glVertexAttrib2f
, glVertexAttrib2fARB
);
2869 MAP_GL_FUNCTION(glVertexAttrib2fv
, glVertexAttrib2fvARB
);
2870 MAP_GL_FUNCTION(glVertexAttrib3f
, glVertexAttrib3fARB
);
2871 MAP_GL_FUNCTION(glVertexAttrib3fv
, glVertexAttrib3fvARB
);
2872 MAP_GL_FUNCTION(glVertexAttrib4f
, glVertexAttrib4fARB
);
2873 MAP_GL_FUNCTION(glVertexAttrib4fv
, glVertexAttrib4fvARB
);
2874 MAP_GL_FUNCTION(glVertexAttrib4Nsv
, glVertexAttrib4NsvARB
);
2875 MAP_GL_FUNCTION(glVertexAttrib4Nub
, glVertexAttrib4NubARB
);
2876 MAP_GL_FUNCTION(glVertexAttrib4Nubv
, glVertexAttrib4NubvARB
);
2877 MAP_GL_FUNCTION(glVertexAttrib4Nusv
, glVertexAttrib4NusvARB
);
2878 MAP_GL_FUNCTION(glVertexAttrib4sv
, glVertexAttrib4svARB
);
2879 MAP_GL_FUNCTION(glVertexAttrib4ubv
, glVertexAttrib4ubvARB
);
2880 MAP_GL_FUNCTION(glVertexAttribDivisor
, glVertexAttribDivisorARB
);
2881 MAP_GL_FUNCTION(glVertexAttribIPointer
, glVertexAttribIPointerEXT
);
2882 MAP_GL_FUNCTION(glVertexAttribPointer
, glVertexAttribPointerARB
);
2883 #undef MAP_GL_FUNCTION
2884 #undef MAP_GL_FUNCTION_CAST
2887 static void wined3d_adapter_init_limits(struct wined3d_gl_info
*gl_info
)
2889 unsigned int i
, sampler_count
;
2892 gl_info
->limits
.buffers
= 1;
2893 gl_info
->limits
.textures
= 0;
2894 gl_info
->limits
.texture_coords
= 0;
2895 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
2897 gl_info
->limits
.uniform_blocks
[i
] = 0;
2898 gl_info
->limits
.samplers
[i
] = 0;
2900 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] = 1;
2901 gl_info
->limits
.combined_samplers
= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
];
2902 gl_info
->limits
.graphics_samplers
= gl_info
->limits
.combined_samplers
;
2903 gl_info
->limits
.vertex_attribs
= 16;
2904 gl_info
->limits
.texture_buffer_offset_alignment
= 1;
2905 gl_info
->limits
.glsl_vs_float_constants
= 0;
2906 gl_info
->limits
.glsl_ps_float_constants
= 0;
2907 gl_info
->limits
.arb_vs_float_constants
= 0;
2908 gl_info
->limits
.arb_vs_native_constants
= 0;
2909 gl_info
->limits
.arb_vs_instructions
= 0;
2910 gl_info
->limits
.arb_vs_temps
= 0;
2911 gl_info
->limits
.arb_ps_float_constants
= 0;
2912 gl_info
->limits
.arb_ps_local_constants
= 0;
2913 gl_info
->limits
.arb_ps_instructions
= 0;
2914 gl_info
->limits
.arb_ps_temps
= 0;
2916 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_CLIP_DISTANCES
, &gl_max
);
2917 gl_info
->limits
.user_clip_distances
= min(WINED3D_MAX_CLIP_DISTANCES
, gl_max
);
2918 TRACE("Clip plane support - max planes %d.\n", gl_max
);
2920 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
2922 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2923 gl_info
->limits
.lights
= gl_max
;
2924 TRACE("Light support - max lights %d.\n", gl_max
);
2927 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2928 gl_info
->limits
.texture_size
= gl_max
;
2929 TRACE("Maximum texture size support - max texture size %d.\n", gl_max
);
2931 if (gl_info
->supported
[ARB_MAP_BUFFER_ALIGNMENT
])
2933 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT
, &gl_max
);
2934 TRACE("Minimum buffer map alignment: %d.\n", gl_max
);
2938 WARN_(d3d_perf
)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2940 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2942 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2943 gl_info
->limits
.general_combiners
= gl_max
;
2944 TRACE("Max general combiners: %d.\n", gl_max
);
2946 if (gl_info
->supported
[ARB_DRAW_BUFFERS
] && wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2948 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2949 gl_info
->limits
.buffers
= min(WINED3D_MAX_RENDER_TARGETS
, gl_max
);
2950 TRACE("Max draw buffers: %u.\n", gl_max
);
2952 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2954 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
2956 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2957 gl_info
->limits
.textures
= min(WINED3D_MAX_TEXTURES
, gl_max
);
2958 TRACE("Max textures: %d.\n", gl_info
->limits
.textures
);
2960 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2962 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &gl_max
);
2963 gl_info
->limits
.texture_coords
= min(WINED3D_MAX_TEXTURES
, gl_max
);
2967 gl_info
->limits
.texture_coords
= gl_info
->limits
.textures
;
2969 TRACE("Max texture coords: %d.\n", gl_info
->limits
.texture_coords
);
2972 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
] || gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2974 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS
, &gl_max
);
2975 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] = gl_max
;
2979 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] = gl_info
->limits
.textures
;
2981 TRACE("Max fragment samplers: %d.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
]);
2983 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2985 unsigned int vertex_sampler_count
;
2987 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &gl_max
);
2988 vertex_sampler_count
= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_VERTEX
] = gl_max
;
2989 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &gl_max
);
2990 gl_info
->limits
.combined_samplers
= gl_max
;
2991 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &gl_max
);
2992 gl_info
->limits
.vertex_attribs
= gl_max
;
2994 /* Loading GLSL sampler uniforms is much simpler if we can assume
2995 * that the sampler setup is known at shader link time. In a
2996 * vertex shader + pixel shader combination this isn't an issue
2997 * because then the sampler setup only depends on the two shaders.
2998 * If a pixel shader is used with fixed-function vertex processing
2999 * we're fine too because fixed-function vertex processing doesn't
3000 * use any samplers. If fixed-function fragment processing is used
3001 * we have to make sure that all vertex sampler setups are valid
3002 * together with all possible fixed-function fragment processing
3003 * setups. This is true if vsamplers + WINED3D_MAX_TEXTURES <= max_samplers.
3004 * This is true on all Direct3D 9 cards that support vertex
3005 * texture fetch (GeForce 6 and GeForce 7 cards). Direct3D 9
3006 * Radeon cards do not support vertex texture fetch. Direct3D 10
3007 * cards have 128 samplers, and Direct3D 9 is limited to 8
3008 * fixed-function texture stages and 4 vertex samplers.
3009 * Direct3D 10 does not have a fixed-function pipeline anymore.
3011 * So this is just a check to check that our assumption holds
3012 * true. If not, write a warning and reduce the number of vertex
3013 * samplers or probably disable vertex texture fetch. */
3014 if (vertex_sampler_count
&& gl_info
->limits
.combined_samplers
< 12
3015 && WINED3D_MAX_TEXTURES
+ vertex_sampler_count
> gl_info
->limits
.combined_samplers
)
3017 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
3018 vertex_sampler_count
, gl_info
->limits
.combined_samplers
);
3019 FIXME("Expected vertex samplers + WINED3D_MAX_TEXTURES(=8) > combined_samplers.\n");
3020 if (gl_info
->limits
.combined_samplers
> WINED3D_MAX_TEXTURES
)
3021 vertex_sampler_count
= gl_info
->limits
.combined_samplers
- WINED3D_MAX_TEXTURES
;
3023 vertex_sampler_count
= 0;
3024 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_VERTEX
] = vertex_sampler_count
;
3029 gl_info
->limits
.combined_samplers
= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
];
3031 TRACE("Max vertex samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_VERTEX
]);
3032 TRACE("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
3033 TRACE("Max vertex attributes: %u.\n", gl_info
->limits
.vertex_attribs
);
3037 gl_info
->limits
.textures
= 1;
3038 gl_info
->limits
.texture_coords
= 1;
3041 if (gl_info
->supported
[EXT_TEXTURE3D
])
3043 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
3044 gl_info
->limits
.texture3d_size
= gl_max
;
3045 TRACE("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
3047 if (gl_info
->supported
[ARB_TEXTURE_FILTER_ANISOTROPIC
])
3049 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY
, &gl_max
);
3050 gl_info
->limits
.anisotropy
= gl_max
;
3051 TRACE("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
3053 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
3055 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
3056 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
3057 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
3058 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
3059 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
3060 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
3061 gl_info
->limits
.arb_ps_native_constants
);
3062 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
3063 gl_info
->limits
.arb_ps_temps
= gl_max
;
3064 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
3065 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
3066 gl_info
->limits
.arb_ps_instructions
= gl_max
;
3067 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
3068 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
3069 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
3070 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
3072 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
3074 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
3075 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
3076 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
3077 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
3078 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
3079 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
3080 gl_info
->limits
.arb_vs_native_constants
);
3081 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
3082 gl_info
->limits
.arb_vs_temps
= gl_max
;
3083 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
3084 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
3085 gl_info
->limits
.arb_vs_instructions
= gl_max
;
3086 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
3088 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
3090 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
3091 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
3092 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
3094 if (gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3096 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS
, &gl_max
);
3097 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_VERTEX
] = min(gl_max
, WINED3D_MAX_CBS
);
3098 TRACE("Max vertex uniform blocks: %u (%d).\n",
3099 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_VERTEX
], gl_max
);
3102 if (gl_info
->supported
[ARB_TESSELLATION_SHADER
])
3104 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS
, &gl_max
);
3105 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_HULL
] = min(gl_max
, WINED3D_MAX_CBS
);
3106 TRACE("Max hull uniform blocks: %u (%d).\n",
3107 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_HULL
], gl_max
);
3108 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS
, &gl_max
);
3109 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_HULL
] = gl_max
;
3110 TRACE("Max hull samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_HULL
]);
3112 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS
, &gl_max
);
3113 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_DOMAIN
] = min(gl_max
, WINED3D_MAX_CBS
);
3114 TRACE("Max domain uniform blocks: %u (%d).\n",
3115 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_DOMAIN
], gl_max
);
3116 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS
, &gl_max
);
3117 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_DOMAIN
] = gl_max
;
3118 TRACE("Max domain samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_DOMAIN
]);
3120 if (gl_info
->supported
[WINED3D_GL_VERSION_3_2
] && gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3122 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS
, &gl_max
);
3123 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_GEOMETRY
] = min(gl_max
, WINED3D_MAX_CBS
);
3124 TRACE("Max geometry uniform blocks: %u (%d).\n",
3125 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_GEOMETRY
], gl_max
);
3126 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS
, &gl_max
);
3127 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_GEOMETRY
] = gl_max
;
3128 TRACE("Max geometry samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_GEOMETRY
]);
3130 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
3132 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
3133 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
3134 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
3135 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3137 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
3138 gl_info
->limits
.glsl_varyings
= gl_max
;
3142 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS
, &gl_max
);
3143 gl_info
->limits
.glsl_varyings
= gl_max
- 4;
3145 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_info
->limits
.glsl_varyings
,
3146 gl_info
->limits
.glsl_varyings
/ 4);
3148 if (gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3150 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS
, &gl_max
);
3151 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_PIXEL
] = min(gl_max
, WINED3D_MAX_CBS
);
3152 TRACE("Max fragment uniform blocks: %u (%d).\n",
3153 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_PIXEL
], gl_max
);
3156 if (gl_info
->supported
[ARB_COMPUTE_SHADER
])
3158 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS
, &gl_max
);
3159 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_COMPUTE
] = min(gl_max
, WINED3D_MAX_CBS
);
3160 TRACE("Max compute uniform blocks: %u (%d).\n",
3161 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_COMPUTE
], gl_max
);
3162 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS
, &gl_max
);
3163 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_COMPUTE
] = gl_max
;
3164 TRACE("Max compute samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_COMPUTE
]);
3166 if (gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3168 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS
, &gl_max
);
3169 TRACE("Max combined uniform blocks: %d.\n", gl_max
);
3170 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS
, &gl_max
);
3171 TRACE("Max uniform buffer bindings: %d.\n", gl_max
);
3173 if (gl_info
->supported
[ARB_TEXTURE_BUFFER_RANGE
])
3175 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT
, &gl_max
);
3176 gl_info
->limits
.texture_buffer_offset_alignment
= gl_max
;
3177 TRACE("Minimum required texture buffer offset alignment %d.\n", gl_max
);
3179 if (gl_info
->supported
[ARB_SHADER_ATOMIC_COUNTERS
])
3181 GLint max_fragment_buffers
, max_combined_buffers
, max_bindings
;
3182 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS
, &max_fragment_buffers
);
3183 TRACE("Max fragment atomic counter buffers: %d.\n", max_fragment_buffers
);
3184 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS
, &max_combined_buffers
);
3185 TRACE("Max combined atomic counter buffers: %d.\n", max_combined_buffers
);
3186 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS
, &max_bindings
);
3187 TRACE("Max atomic counter buffer bindings: %d.\n", max_bindings
);
3188 if (max_fragment_buffers
< MAX_UNORDERED_ACCESS_VIEWS
3189 || max_combined_buffers
< MAX_UNORDERED_ACCESS_VIEWS
3190 || max_bindings
< MAX_UNORDERED_ACCESS_VIEWS
)
3192 WARN("Disabling ARB_shader_atomic_counters.\n");
3193 gl_info
->supported
[ARB_SHADER_ATOMIC_COUNTERS
] = FALSE
;
3196 if (gl_info
->supported
[ARB_TRANSFORM_FEEDBACK3
])
3198 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_STREAMS
, &gl_max
);
3199 TRACE("Max vertex streams: %d.\n", gl_max
);
3202 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
3203 gl_info
->gl_ops
.gl
.p_glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
3205 gl_info
->limits
.shininess
= 128.0f
;
3207 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] || gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
3209 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
3210 gl_info
->limits
.samples
= gl_max
;
3213 if (gl_info
->supported
[ARB_FRAMEBUFFER_NO_ATTACHMENTS
])
3215 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_WIDTH
, &gl_max
);
3216 gl_info
->limits
.framebuffer_width
= gl_max
;
3217 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_HEIGHT
, &gl_max
);
3218 gl_info
->limits
.framebuffer_height
= gl_max
;
3222 gl_info
->limits
.framebuffer_width
= gl_info
->limits
.texture_size
;
3223 gl_info
->limits
.framebuffer_height
= gl_info
->limits
.texture_size
;
3226 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] =
3227 min(gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
], MAX_GL_FRAGMENT_SAMPLERS
);
3229 for (i
= 0; i
< WINED3D_SHADER_TYPE_GRAPHICS_COUNT
; ++i
)
3230 sampler_count
+= gl_info
->limits
.samplers
[i
];
3231 if (gl_info
->supported
[WINED3D_GL_VERSION_3_2
] && gl_info
->limits
.combined_samplers
< sampler_count
)
3233 /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL
3234 * 3.2 is 48 (16 per stage). When tessellation shaders are supported
3235 * the minimum value is increased to 80. */
3236 WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n",
3237 sampler_count
, gl_info
->limits
.combined_samplers
);
3238 for (i
= 0; i
< WINED3D_SHADER_TYPE_GRAPHICS_COUNT
; ++i
)
3239 gl_info
->limits
.samplers
[i
] = min(gl_info
->limits
.samplers
[i
], 16);
3242 /* A majority of OpenGL implementations allow us to statically partition
3243 * the set of texture bindings into six separate sets. */
3244 gl_info
->limits
.graphics_samplers
= gl_info
->limits
.combined_samplers
;
3246 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
3247 sampler_count
+= gl_info
->limits
.samplers
[i
];
3248 if (gl_info
->limits
.combined_samplers
>= sampler_count
)
3249 gl_info
->limits
.graphics_samplers
-= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_COMPUTE
];
3252 /* Context activation is done by the caller. */
3253 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter_gl
*adapter_gl
,
3254 struct wined3d_caps_gl_ctx
*caps_gl_ctx
, unsigned int wined3d_creation_flags
)
3258 enum wined3d_gl_extension extension
;
3259 DWORD min_gl_version
;
3263 {EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2)},
3264 {ARB_MULTISAMPLE
, MAKEDWORD_VERSION(1, 3)},
3265 {ARB_MULTITEXTURE
, MAKEDWORD_VERSION(1, 3)},
3266 {ARB_TEXTURE_BORDER_CLAMP
, MAKEDWORD_VERSION(1, 3)},
3267 {ARB_TEXTURE_COMPRESSION
, MAKEDWORD_VERSION(1, 3)},
3268 {ARB_TEXTURE_CUBE_MAP
, MAKEDWORD_VERSION(1, 3)},
3269 {ARB_DEPTH_TEXTURE
, MAKEDWORD_VERSION(1, 4)},
3270 {ARB_POINT_PARAMETERS
, MAKEDWORD_VERSION(1, 4)},
3271 {ARB_SHADOW
, MAKEDWORD_VERSION(1, 4)},
3272 {ARB_TEXTURE_MIRRORED_REPEAT
, MAKEDWORD_VERSION(1, 4)},
3273 {EXT_BLEND_COLOR
, MAKEDWORD_VERSION(1, 4)},
3274 {EXT_BLEND_FUNC_SEPARATE
, MAKEDWORD_VERSION(1, 4)},
3275 {EXT_BLEND_MINMAX
, MAKEDWORD_VERSION(1, 4)},
3276 {EXT_BLEND_SUBTRACT
, MAKEDWORD_VERSION(1, 4)},
3277 {EXT_STENCIL_WRAP
, MAKEDWORD_VERSION(1, 4)},
3278 {NV_POINT_SPRITE
, MAKEDWORD_VERSION(1, 4)},
3279 {ARB_OCCLUSION_QUERY
, MAKEDWORD_VERSION(1, 5)},
3280 {ARB_VERTEX_BUFFER_OBJECT
, MAKEDWORD_VERSION(1, 5)},
3281 {ARB_DRAW_BUFFERS
, MAKEDWORD_VERSION(2, 0)},
3282 {ARB_FRAGMENT_SHADER
, MAKEDWORD_VERSION(2, 0)},
3283 {ARB_SHADING_LANGUAGE_100
, MAKEDWORD_VERSION(2, 0)},
3284 {ARB_TEXTURE_NON_POWER_OF_TWO
, MAKEDWORD_VERSION(2, 0)},
3285 {ARB_VERTEX_SHADER
, MAKEDWORD_VERSION(2, 0)},
3286 {EXT_BLEND_EQUATION_SEPARATE
, MAKEDWORD_VERSION(2, 0)},
3287 {ARB_PIXEL_BUFFER_OBJECT
, MAKEDWORD_VERSION(2, 1)},
3288 {EXT_TEXTURE_SRGB
, MAKEDWORD_VERSION(2, 1)},
3289 {ARB_COLOR_BUFFER_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3290 {ARB_DEPTH_BUFFER_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3291 {ARB_FRAMEBUFFER_OBJECT
, MAKEDWORD_VERSION(3, 0)},
3292 {ARB_FRAMEBUFFER_SRGB
, MAKEDWORD_VERSION(3, 0)},
3293 {ARB_HALF_FLOAT_PIXEL
, MAKEDWORD_VERSION(3, 0)},
3294 {ARB_HALF_FLOAT_VERTEX
, MAKEDWORD_VERSION(3, 0)},
3295 {ARB_MAP_BUFFER_RANGE
, MAKEDWORD_VERSION(3, 0)},
3296 {ARB_TEXTURE_COMPRESSION_RGTC
, MAKEDWORD_VERSION(3, 0)},
3297 {ARB_TEXTURE_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3298 {ARB_TEXTURE_RG
, MAKEDWORD_VERSION(3, 0)},
3299 {EXT_DRAW_BUFFERS2
, MAKEDWORD_VERSION(3, 0)},
3300 {EXT_PACKED_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3301 {EXT_TEXTURE_ARRAY
, MAKEDWORD_VERSION(3, 0)},
3302 {EXT_TEXTURE_INTEGER
, MAKEDWORD_VERSION(3, 0)},
3303 {EXT_TEXTURE_SHARED_EXPONENT
, MAKEDWORD_VERSION(3, 0)},
3304 /* We don't want to enable EXT_GPU_SHADER4: even though similar
3305 * functionality is available in core GL 3.0 / GLSL 1.30, it's different
3306 * enough that reusing the same flag for the new features hurts more
3308 /* EXT_framebuffer_object, EXT_framebuffer_blit,
3309 * EXT_framebuffer_multisample and EXT_packed_depth_stencil
3310 * are integrated into ARB_framebuffer_object. */
3312 {ARB_COPY_BUFFER
, MAKEDWORD_VERSION(3, 1)},
3313 {ARB_DRAW_INSTANCED
, MAKEDWORD_VERSION(3, 1)},
3314 {ARB_TEXTURE_BUFFER_OBJECT
, MAKEDWORD_VERSION(3, 1)},
3315 {ARB_UNIFORM_BUFFER_OBJECT
, MAKEDWORD_VERSION(3, 1)},
3316 {EXT_TEXTURE_SNORM
, MAKEDWORD_VERSION(3, 1)},
3317 /* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
3319 {ARB_DEPTH_CLAMP
, MAKEDWORD_VERSION(3, 2)},
3320 {ARB_DRAW_ELEMENTS_BASE_VERTEX
, MAKEDWORD_VERSION(3, 2)},
3321 /* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
3322 * core geometry shaders so it's not really correct to expose the
3323 * extension for core-only support. */
3324 {ARB_FRAGMENT_COORD_CONVENTIONS
, MAKEDWORD_VERSION(3, 2)},
3325 {ARB_PROVOKING_VERTEX
, MAKEDWORD_VERSION(3, 2)},
3326 {ARB_SEAMLESS_CUBE_MAP
, MAKEDWORD_VERSION(3, 2)},
3327 {ARB_SYNC
, MAKEDWORD_VERSION(3, 2)},
3328 {ARB_TEXTURE_MULTISAMPLE
, MAKEDWORD_VERSION(3, 2)},
3329 {ARB_VERTEX_ARRAY_BGRA
, MAKEDWORD_VERSION(3, 2)},
3331 {ARB_BLEND_FUNC_EXTENDED
, MAKEDWORD_VERSION(3, 3)},
3332 {ARB_EXPLICIT_ATTRIB_LOCATION
, MAKEDWORD_VERSION(3, 3)},
3333 {ARB_INSTANCED_ARRAYS
, MAKEDWORD_VERSION(3, 3)},
3334 {ARB_SAMPLER_OBJECTS
, MAKEDWORD_VERSION(3, 3)},
3335 {ARB_SHADER_BIT_ENCODING
, MAKEDWORD_VERSION(3, 3)},
3336 {ARB_TEXTURE_RGB10_A2UI
, MAKEDWORD_VERSION(3, 3)},
3337 {ARB_TEXTURE_SWIZZLE
, MAKEDWORD_VERSION(3, 3)},
3338 {ARB_TIMER_QUERY
, MAKEDWORD_VERSION(3, 3)},
3339 {ARB_VERTEX_TYPE_2_10_10_10_REV
, MAKEDWORD_VERSION(3, 3)},
3341 {ARB_DRAW_BUFFERS_BLEND
, MAKEDWORD_VERSION(4, 0)},
3342 {ARB_DRAW_INDIRECT
, MAKEDWORD_VERSION(4, 0)},
3343 {ARB_GPU_SHADER5
, MAKEDWORD_VERSION(4, 0)},
3344 {ARB_SAMPLE_SHADING
, MAKEDWORD_VERSION(4, 0)},
3345 {ARB_TESSELLATION_SHADER
, MAKEDWORD_VERSION(4, 0)},
3346 {ARB_TEXTURE_CUBE_MAP_ARRAY
, MAKEDWORD_VERSION(4, 0)},
3347 {ARB_TEXTURE_GATHER
, MAKEDWORD_VERSION(4, 0)},
3348 {ARB_TRANSFORM_FEEDBACK2
, MAKEDWORD_VERSION(4, 0)},
3349 {ARB_TRANSFORM_FEEDBACK3
, MAKEDWORD_VERSION(4, 0)},
3351 {ARB_ES2_COMPATIBILITY
, MAKEDWORD_VERSION(4, 1)},
3352 {ARB_VIEWPORT_ARRAY
, MAKEDWORD_VERSION(4, 1)},
3354 {ARB_BASE_INSTANCE
, MAKEDWORD_VERSION(4, 2)},
3355 {ARB_CONSERVATIVE_DEPTH
, MAKEDWORD_VERSION(4, 2)},
3356 {ARB_INTERNALFORMAT_QUERY
, MAKEDWORD_VERSION(4, 2)},
3357 {ARB_MAP_BUFFER_ALIGNMENT
, MAKEDWORD_VERSION(4, 2)},
3358 {ARB_SHADER_ATOMIC_COUNTERS
, MAKEDWORD_VERSION(4, 2)},
3359 {ARB_SHADER_IMAGE_LOAD_STORE
, MAKEDWORD_VERSION(4, 2)},
3360 {ARB_SHADING_LANGUAGE_420PACK
, MAKEDWORD_VERSION(4, 2)},
3361 {ARB_SHADING_LANGUAGE_PACKING
, MAKEDWORD_VERSION(4, 2)},
3362 {ARB_TEXTURE_COMPRESSION_BPTC
, MAKEDWORD_VERSION(4, 2)},
3363 {ARB_TEXTURE_STORAGE
, MAKEDWORD_VERSION(4, 2)},
3365 {ARB_CLEAR_BUFFER_OBJECT
, MAKEDWORD_VERSION(4, 3)},
3366 {ARB_COMPUTE_SHADER
, MAKEDWORD_VERSION(4, 3)},
3367 {ARB_COPY_IMAGE
, MAKEDWORD_VERSION(4, 3)},
3368 {ARB_DEBUG_OUTPUT
, MAKEDWORD_VERSION(4, 3)},
3369 {ARB_ES3_COMPATIBILITY
, MAKEDWORD_VERSION(4, 3)},
3370 {ARB_FRAGMENT_LAYER_VIEWPORT
, MAKEDWORD_VERSION(4, 3)},
3371 {ARB_FRAMEBUFFER_NO_ATTACHMENTS
, MAKEDWORD_VERSION(4, 3)},
3372 {ARB_INTERNALFORMAT_QUERY2
, MAKEDWORD_VERSION(4, 3)},
3373 {ARB_SHADER_IMAGE_SIZE
, MAKEDWORD_VERSION(4, 3)},
3374 {ARB_SHADER_STORAGE_BUFFER_OBJECT
, MAKEDWORD_VERSION(4, 3)},
3375 {ARB_STENCIL_TEXTURING
, MAKEDWORD_VERSION(4, 3)},
3376 {ARB_TEXTURE_BUFFER_RANGE
, MAKEDWORD_VERSION(4, 3)},
3377 {ARB_TEXTURE_QUERY_LEVELS
, MAKEDWORD_VERSION(4, 3)},
3378 {ARB_TEXTURE_STORAGE_MULTISAMPLE
, MAKEDWORD_VERSION(4, 3)},
3379 {ARB_TEXTURE_VIEW
, MAKEDWORD_VERSION(4, 3)},
3381 {ARB_BUFFER_STORAGE
, MAKEDWORD_VERSION(4, 4)},
3382 {ARB_CLEAR_TEXTURE
, MAKEDWORD_VERSION(4, 4)},
3383 {ARB_QUERY_BUFFER_OBJECT
, MAKEDWORD_VERSION(4, 4)},
3384 {ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
, MAKEDWORD_VERSION(4, 4)},
3385 {ARB_VERTEX_TYPE_10F_11F_11F_REV
, MAKEDWORD_VERSION(4, 4)},
3387 {ARB_CLIP_CONTROL
, MAKEDWORD_VERSION(4, 5)},
3388 {ARB_CULL_DISTANCE
, MAKEDWORD_VERSION(4, 5)},
3389 {ARB_DERIVATIVE_CONTROL
, MAKEDWORD_VERSION(4, 5)},
3390 {ARB_SHADER_TEXTURE_IMAGE_SAMPLES
, MAKEDWORD_VERSION(4, 5)},
3391 {ARB_TEXTURE_BARRIER
, MAKEDWORD_VERSION(4, 5)},
3393 {ARB_PIPELINE_STATISTICS_QUERY
, MAKEDWORD_VERSION(4, 6)},
3394 {ARB_POLYGON_OFFSET_CLAMP
, MAKEDWORD_VERSION(4, 6)},
3395 {ARB_TEXTURE_FILTER_ANISOTROPIC
, MAKEDWORD_VERSION(4, 6)},
3397 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
3398 struct wined3d_gl_info
*gl_info
= &adapter_gl
->gl_info
;
3399 struct wined3d_adapter
*adapter
= &adapter_gl
->a
;
3400 unsigned int gl_version
;
3401 DWORD gl_ext_emul_mask
;
3402 const char *WGL_Extensions
= NULL
;
3403 enum wined3d_gl_vendor gl_vendor
;
3404 GLint context_profile
= 0;
3408 TRACE("adapter_gl %p.\n", adapter_gl
);
3410 gl_renderer_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_RENDERER
);
3411 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
3412 if (!gl_renderer_str
)
3414 ERR("Received a NULL GL_RENDERER.\n");
3418 gl_vendor_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VENDOR
);
3419 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
3422 ERR("Received a NULL GL_VENDOR.\n");
3426 /* Parse the GL_VERSION field into major and minor information */
3427 gl_version_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VERSION
);
3428 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
3429 if (!gl_version_str
)
3431 ERR("Received a NULL GL_VERSION.\n");
3434 gl_version
= wined3d_parse_gl_version(gl_version_str
);
3436 load_gl_funcs(gl_info
);
3438 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
3439 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
3441 if (gl_version
>= MAKEDWORD_VERSION(3, 2))
3443 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_CONTEXT_PROFILE_MASK
, &context_profile
);
3444 checkGLcall("Querying context profile");
3446 if (context_profile
& GL_CONTEXT_CORE_PROFILE_BIT
)
3447 TRACE("Got a core profile context.\n");
3449 gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
] = TRUE
;
3451 TRACE("GL extensions reported:\n");
3452 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3454 const char *gl_extensions
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_EXTENSIONS
);
3458 ERR("Received a NULL GL_EXTENSIONS.\n");
3461 parse_extension_string(gl_info
, gl_extensions
, gl_extension_map
, ARRAY_SIZE(gl_extension_map
));
3465 enumerate_gl_extensions(gl_info
, gl_extension_map
, ARRAY_SIZE(gl_extension_map
));
3468 hdc
= wglGetCurrentDC();
3469 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
3470 if (GL_EXTCALL(wglGetExtensionsStringARB
))
3471 WGL_Extensions
= (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
3472 if (!WGL_Extensions
)
3473 WARN("WGL extensions not supported.\n");
3475 parse_extension_string(gl_info
, WGL_Extensions
, wgl_extension_map
, ARRAY_SIZE(wgl_extension_map
));
3477 for (i
= 0; i
< ARRAY_SIZE(core_extensions
); ++i
)
3479 if (!gl_info
->supported
[core_extensions
[i
].extension
]
3480 && gl_version
>= core_extensions
[i
].min_gl_version
)
3482 for (j
= 0; j
< ARRAY_SIZE(gl_extension_map
); ++j
)
3483 if (gl_extension_map
[j
].extension
== core_extensions
[i
].extension
)
3486 if (j
< ARRAY_SIZE(gl_extension_map
))
3488 TRACE("GL CORE: %s support.\n", gl_extension_map
[j
].extension_string
);
3489 gl_info
->supported
[core_extensions
[i
].extension
] = TRUE
;
3493 FIXME("GL extension %u not in the GL extensions map.\n", core_extensions
[i
].extension
);
3498 if (gl_info
->supported
[EXT_BLEND_MINMAX
] || gl_info
->supported
[EXT_BLEND_SUBTRACT
])
3499 gl_info
->supported
[WINED3D_GL_BLEND_EQUATION
] = TRUE
;
3501 if (gl_version
>= MAKEDWORD_VERSION(2, 0))
3503 gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
3504 /* We want to use the core APIs for two-sided stencil in GL 2.0. */
3505 gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] = FALSE
;
3507 if (gl_version
>= MAKEDWORD_VERSION(3, 2))
3508 gl_info
->supported
[WINED3D_GL_VERSION_3_2
] = TRUE
;
3510 /* All the points are actually point sprites in core contexts, the APIs from
3511 * ARB_point_sprite are not supported anymore. */
3512 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3513 gl_info
->supported
[ARB_POINT_SPRITE
] = FALSE
;
3515 if (gl_info
->supported
[APPLE_FENCE
])
3517 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
3518 * The apple extension interacts with some other apple exts. Disable the NV
3519 * extension if the apple one is support to prevent confusion in other parts
3521 gl_info
->supported
[NV_FENCE
] = FALSE
;
3523 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
3525 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
3527 * The enums are the same:
3528 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
3529 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
3530 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
3531 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
3532 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
3534 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3536 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
3537 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
3539 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3541 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
3542 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
3545 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
3547 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
3548 * functionality. Prefer the ARB extension */
3549 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
3551 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3553 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
3554 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
3556 if (!gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3558 TRACE(" IMPLIED: EXT_texture_compression_rgtc support (by ARB_texture_compression_rgtc).\n");
3559 gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
3561 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
3563 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
3564 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
3566 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && !gl_info
->supported
[ARB_TEXTURE_RG
])
3568 TRACE("ARB_texture_rg not supported, disabling ARB_texture_compression_rgtc.\n");
3569 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = FALSE
;
3571 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
3573 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3575 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
3576 * are supported. The nv extensions provide the same functionality as the
3577 * ATI one, and a bit more(signed pixelformats). */
3578 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
3581 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
3583 /* If we have full NP2 texture support, disable
3584 * GL_ARB_texture_rectangle because we will never use it.
3585 * This saves a few redundant glDisable calls. */
3586 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
3588 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
3590 /* Disable NV_register_combiners and fragment shader if this is supported.
3591 * generally the NV extensions are preferred over the ATI ones, and this
3592 * extension is disabled if register_combiners and texture_shader2 are both
3593 * supported. So we reach this place only if we have incomplete NV dxlevel 8
3594 * fragment processing support. */
3595 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
3596 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
3597 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
3598 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
3600 if (gl_info
->supported
[NV_HALF_FLOAT
])
3602 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
3603 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
3605 if (gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
] && !gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
])
3607 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
3608 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
3609 * we never render to sRGB surfaces). */
3610 TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n");
3611 gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
] = FALSE
;
3613 if (gl_info
->supported
[ARB_OCCLUSION_QUERY
])
3617 GL_EXTCALL(glGetQueryiv(GL_SAMPLES_PASSED
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3618 TRACE("Occlusion query counter has %d bits.\n", counter_bits
);
3620 gl_info
->supported
[ARB_OCCLUSION_QUERY
] = FALSE
;
3622 if (gl_info
->supported
[ARB_TIMER_QUERY
])
3626 GL_EXTCALL(glGetQueryiv(GL_TIMESTAMP
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3627 TRACE("Timestamp query counter has %d bits.\n", counter_bits
);
3629 gl_info
->supported
[ARB_TIMER_QUERY
] = FALSE
;
3631 if (gl_version
>= MAKEDWORD_VERSION(3, 0))
3635 gl_info
->supported
[WINED3D_GL_PRIMITIVE_QUERY
] = TRUE
;
3637 GL_EXTCALL(glGetQueryiv(GL_PRIMITIVES_GENERATED
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3638 TRACE("Primitives query counter has %d bits.\n", counter_bits
);
3640 gl_info
->supported
[WINED3D_GL_PRIMITIVE_QUERY
] = FALSE
;
3642 GL_EXTCALL(glGetQueryiv(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3643 TRACE("Transform feedback primitives query counter has %d bits.\n", counter_bits
);
3645 gl_info
->supported
[WINED3D_GL_PRIMITIVE_QUERY
] = FALSE
;
3647 if (gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
3649 GLint subpixel_bits
;
3651 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS
, &subpixel_bits
);
3652 TRACE("Viewport supports %d subpixel bits.\n", subpixel_bits
);
3653 if (subpixel_bits
< 8 && gl_info
->supported
[ARB_CLIP_CONTROL
])
3655 TRACE("Disabling ARB_clip_control because viewport subpixel bits < 8.\n");
3656 gl_info
->supported
[ARB_CLIP_CONTROL
] = FALSE
;
3658 gl_info
->limits
.viewport_subpixel_bits
= subpixel_bits
;
3660 if (gl_info
->supported
[ARB_CLIP_CONTROL
] && !gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
3662 /* When using ARB_clip_control we need the float viewport parameters
3663 * introduced by ARB_viewport_array to take care of the shifted pixel
3665 TRACE("Disabling ARB_clip_control because ARB_viewport_array is not supported.\n");
3666 gl_info
->supported
[ARB_CLIP_CONTROL
] = FALSE
;
3668 if (gl_info
->supported
[ARB_STENCIL_TEXTURING
] && !gl_info
->supported
[ARB_TEXTURE_SWIZZLE
])
3670 /* The stencil value needs to be placed in the green channel. */
3671 TRACE("Disabling ARB_stencil_texturing because ARB_texture_swizzle is not supported.\n");
3672 gl_info
->supported
[ARB_STENCIL_TEXTURING
] = FALSE
;
3674 if (!gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] && gl_info
->supported
[EXT_TEXTURE_MIRROR_CLAMP
])
3676 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
3677 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] = TRUE
;
3679 if (!gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] && gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
3681 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
3682 gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] = TRUE
;
3684 if (gl_info
->supported
[ARB_TEXTURE_STORAGE
] && gl_info
->supported
[APPLE_YCBCR_422
])
3686 /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
3687 ERR("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
3688 gl_info
->supported
[APPLE_YCBCR_422
] = FALSE
;
3690 if (gl_info
->supported
[ARB_DRAW_INDIRECT
] && !gl_info
->supported
[ARB_BASE_INSTANCE
])
3692 /* If ARB_base_instance is not supported the baseInstance field
3693 * in indirect draw parameters must be 0 or behavior is undefined.
3695 WARN("Disabling ARB_draw_indirect because ARB_base_instance is not supported.\n");
3696 gl_info
->supported
[ARB_DRAW_INDIRECT
] = FALSE
;
3698 if (gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] && !wined3d_settings
.multisample_textures
)
3699 gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] = FALSE
;
3700 if (gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] && !gl_info
->supported
[ARB_TEXTURE_STORAGE_MULTISAMPLE
])
3702 WARN("Disabling ARB_texture_multisample because immutable storage is not supported.\n");
3703 gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] = FALSE
;
3705 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] && !gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
])
3707 TRACE(" IMPLIED: GL_EXT_packed_depth_stencil (by GL_ARB_framebuffer_object).\n");
3708 gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
] = TRUE
;
3711 wined3d_adapter_init_limits(gl_info
);
3713 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] && test_arb_vs_offset_limit(gl_info
))
3714 gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
3716 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
3718 const char *str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
3719 unsigned int major
, minor
;
3721 TRACE("GLSL version string: %s.\n", debugstr_a(str
));
3723 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
3724 sscanf(str
, "%u.%u", &major
, &minor
);
3725 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
3726 if (gl_info
->glsl_version
> MAKEDWORD_VERSION(1, 30) && gl_version
< MAKEDWORD_VERSION(3, 0))
3728 WARN("OpenGL version %u.%u too low, limiting GLSL version to 1.30.\n",
3729 gl_version
>> 16, gl_version
& 0xffff);
3730 gl_info
->glsl_version
= MAKEDWORD_VERSION(1, 30);
3732 if (gl_info
->glsl_version
>= MAKEDWORD_VERSION(1, 30))
3733 gl_info
->supported
[WINED3D_GLSL_130
] = TRUE
;
3736 checkGLcall("extension detection");
3738 adapter
->shader_backend
= select_shader_backend(gl_info
);
3739 adapter
->vertex_pipe
= select_vertex_implementation(gl_info
, adapter
->shader_backend
);
3740 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
, adapter
->shader_backend
);
3742 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3744 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbuffer
;
3745 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbuffer
;
3746 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffers
;
3747 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffers
;
3748 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorage
;
3749 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisample
;
3750 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameteriv
;
3751 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebuffer
;
3752 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebuffer
;
3753 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffers
;
3754 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffers
;
3755 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatus
;
3756 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1D
;
3757 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2D
;
3758 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3D
;
3759 gl_info
->fbo_ops
.glFramebufferTextureLayer
= gl_info
->gl_ops
.ext
.p_glFramebufferTextureLayer
;
3760 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbuffer
;
3761 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
3762 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameteriv
;
3763 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebuffer
;
3764 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmap
;
3765 gl_info
->fbo_ops
.glFramebufferTexture
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture
;
3769 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
3771 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbufferEXT
;
3772 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbufferEXT
;
3773 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffersEXT
;
3774 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffersEXT
;
3775 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageEXT
;
3776 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameterivEXT
;
3777 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebufferEXT
;
3778 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebufferEXT
;
3779 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffersEXT
;
3780 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffersEXT
;
3781 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatusEXT
;
3782 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1DEXT
;
3783 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2DEXT
;
3784 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3DEXT
;
3785 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbufferEXT
;
3786 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
3787 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameterivEXT
;
3788 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmapEXT
;
3790 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3792 WARN_(d3d_perf
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
3793 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
3796 if (gl_info
->supported
[ARB_GEOMETRY_SHADER4
])
3798 gl_info
->fbo_ops
.glFramebufferTexture
= gl_info
->gl_ops
.ext
.p_glFramebufferTextureARB
;
3799 gl_info
->fbo_ops
.glFramebufferTextureLayer
= gl_info
->gl_ops
.ext
.p_glFramebufferTextureLayerARB
;
3801 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
3803 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebufferEXT
;
3805 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
3807 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
3808 = gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisampleEXT
;
3812 gl_info
->wrap_lookup
[WINED3D_TADDRESS_WRAP
- WINED3D_TADDRESS_WRAP
] = GL_REPEAT
;
3813 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR
- WINED3D_TADDRESS_WRAP
] =
3814 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
3815 gl_info
->wrap_lookup
[WINED3D_TADDRESS_CLAMP
- WINED3D_TADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
3816 gl_info
->wrap_lookup
[WINED3D_TADDRESS_BORDER
- WINED3D_TADDRESS_WRAP
] =
3817 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
3818 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
] =
3819 gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] ? GL_MIRROR_CLAMP_TO_EDGE
: GL_REPEAT
;
3821 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3825 GL_EXTCALL(glGenVertexArrays(1, &vao
));
3826 GL_EXTCALL(glBindVertexArray(vao
));
3827 checkGLcall("creating VAO");
3830 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
, gl_version_str
);
3831 TRACE("Guessed GL vendor %#x.\n", gl_vendor
);
3833 if (!(caps_gl_ctx
->gpu_description
= query_gpu_description(gl_info
, &caps_gl_ctx
->vram_bytes
)))
3835 enum wined3d_feature_level feature_level
;
3836 struct fragment_caps fragment_caps
;
3837 enum wined3d_pci_vendor vendor
;
3838 enum wined3d_pci_device device
;
3839 struct shader_caps shader_caps
;
3841 adapter
->shader_backend
->shader_get_caps(adapter
, &shader_caps
);
3842 adapter
->fragment_pipe
->get_caps(adapter
, &fragment_caps
);
3843 feature_level
= feature_level_from_caps(gl_info
, &shader_caps
, &fragment_caps
);
3845 vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
3846 TRACE("Guessed vendor PCI ID 0x%04x.\n", vendor
);
3848 device
= wined3d_guess_card(feature_level
, gl_renderer_str
, &gl_vendor
, &vendor
);
3849 TRACE("Guessed device PCI ID 0x%04x.\n", device
);
3851 if (!(caps_gl_ctx
->gpu_description
= wined3d_get_gpu_description(vendor
, device
)))
3853 ERR("Card %04x:%04x not found in driver DB.\n", vendor
, device
);
3857 fixup_extensions(gl_info
, caps_gl_ctx
, gl_renderer_str
, gl_vendor
);
3859 adapter
->vram_bytes_used
= 0;
3860 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(caps_gl_ctx
->vram_bytes
));
3862 if (gl_info
->supported
[EXT_MEMORY_OBJECT
])
3864 GLint device_count
= 0;
3866 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_NUM_DEVICE_UUIDS_EXT
, &device_count
);
3867 if (device_count
> 0)
3869 if (device_count
> 1)
3870 FIXME("A set of %d devices is not supported.\n", device_count
);
3872 GL_EXTCALL(glGetUnsignedBytevEXT(GL_DRIVER_UUID_EXT
, (GLubyte
*)&adapter
->driver_uuid
));
3873 GL_EXTCALL(glGetUnsignedBytei_vEXT(GL_DEVICE_UUID_EXT
, 0, (GLubyte
*)&adapter
->device_uuid
));
3875 TRACE("Driver UUID: %s, device UUID %s.\n",
3876 debugstr_guid(&adapter
->driver_uuid
), debugstr_guid(&adapter
->device_uuid
));
3880 WARN("Unexpected device count %d.\n", device_count
);
3884 gl_ext_emul_mask
= adapter
->vertex_pipe
->vp_get_emul_mask(adapter
)
3885 | adapter
->fragment_pipe
->get_emul_mask(adapter
);
3886 if (gl_ext_emul_mask
& GL_EXT_EMUL_ARB_MULTITEXTURE
)
3887 install_gl_compat_wrapper(gl_info
, ARB_MULTITEXTURE
);
3888 if (gl_ext_emul_mask
& GL_EXT_EMUL_EXT_FOG_COORD
)
3889 install_gl_compat_wrapper(gl_info
, EXT_FOG_COORD
);
3894 static void WINE_GLAPI
invalid_func(const void *data
)
3896 ERR("Invalid vertex attribute function called.\n");
3900 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
3902 ERR("Invalid texcoord function called.\n");
3906 static void WINE_GLAPI
invalid_generic_attrib_func(GLuint idx
, const void *data
)
3908 ERR("Invalid attribute function called.\n");
3912 /* Helper functions for providing vertex data to OpenGL. The arrays are
3913 * initialised based on the extension detection and are used in
3914 * draw_primitive_immediate_mode(). */
3915 static void WINE_GLAPI
position_d3dcolor(const void *data
)
3917 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3918 DWORD pos
= *((const DWORD
*)data
);
3920 FIXME("Add a test for fixed function position from d3dcolor type.\n");
3921 gl_info
->gl_ops
.gl
.p_glVertex4s(D3DCOLOR_B_R(pos
),
3927 static void WINE_GLAPI
position_float4(const void *data
)
3929 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3930 const GLfloat
*pos
= data
;
3932 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
3934 float w
= 1.0f
/ pos
[3];
3936 gl_info
->gl_ops
.gl
.p_glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
3940 gl_info
->gl_ops
.gl
.p_glVertex3fv(pos
);
3944 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
3946 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3947 DWORD diffuseColor
= *((const DWORD
*)data
);
3949 gl_info
->gl_ops
.gl
.p_glColor4ub(D3DCOLOR_B_R(diffuseColor
),
3950 D3DCOLOR_B_G(diffuseColor
),
3951 D3DCOLOR_B_B(diffuseColor
),
3952 D3DCOLOR_B_A(diffuseColor
));
3955 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
3957 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3958 DWORD specularColor
= *((const DWORD
*)data
);
3961 D3DCOLOR_B_R(specularColor
),
3962 D3DCOLOR_B_G(specularColor
),
3963 D3DCOLOR_B_B(specularColor
)
3966 gl_info
->gl_ops
.ext
.p_glSecondaryColor3ubvEXT(d
);
3969 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
3971 WARN("GL_EXT_secondary_color not supported.\n");
3974 static void WINE_GLAPI
generic_d3dcolor(GLuint idx
, const void *data
)
3976 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3977 DWORD color
= *((const DWORD
*)data
);
3979 gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nub(idx
,
3980 D3DCOLOR_B_R(color
), D3DCOLOR_B_G(color
),
3981 D3DCOLOR_B_B(color
), D3DCOLOR_B_A(color
));
3984 static void WINE_GLAPI
generic_short2n(GLuint idx
, const void *data
)
3986 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3987 const GLshort s
[] = {((const GLshort
*)data
)[0], ((const GLshort
*)data
)[1], 0, 1};
3989 gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nsv(idx
, s
);
3992 static void WINE_GLAPI
generic_ushort2n(GLuint idx
, const void *data
)
3994 const GLushort s
[] = {((const GLushort
*)data
)[0], ((const GLushort
*)data
)[1], 0, 1};
3995 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3997 gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nusv(idx
, s
);
4000 static void WINE_GLAPI
generic_float16_2(GLuint idx
, const void *data
)
4002 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
4003 float x
= float_16_to_32(((const unsigned short *)data
) + 0);
4004 float y
= float_16_to_32(((const unsigned short *)data
) + 1);
4006 gl_info
->gl_ops
.ext
.p_glVertexAttrib2f(idx
, x
, y
);
4009 static void WINE_GLAPI
generic_float16_4(GLuint idx
, const void *data
)
4011 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
4012 float x
= float_16_to_32(((const unsigned short *)data
) + 0);
4013 float y
= float_16_to_32(((const unsigned short *)data
) + 1);
4014 float z
= float_16_to_32(((const unsigned short *)data
) + 2);
4015 float w
= float_16_to_32(((const unsigned short *)data
) + 3);
4017 gl_info
->gl_ops
.ext
.p_glVertexAttrib4f(idx
, x
, y
, z
, w
);
4020 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter_gl
*adapter_gl
)
4022 const struct wined3d_d3d_info
*d3d_info
= &adapter_gl
->a
.d3d_info
;
4023 struct wined3d_gl_info
*gl_info
= &adapter_gl
->gl_info
;
4024 struct wined3d_ffp_attrib_ops
*ops
= &gl_info
->ffp_attrib_ops
;
4027 for (i
= 0; i
< WINED3D_FFP_EMIT_COUNT
; ++i
)
4029 ops
->position
[i
] = invalid_func
;
4030 ops
->diffuse
[i
] = invalid_func
;
4031 ops
->specular
[i
] = invalid_func
;
4032 ops
->normal
[i
] = invalid_func
;
4033 ops
->texcoord
[i
] = invalid_texcoord_func
;
4034 ops
->generic
[i
] = invalid_generic_attrib_func
;
4037 ops
->position
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex3fv
;
4038 if (!d3d_info
->xyzrhw
)
4039 ops
->position
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
4041 ops
->position
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex4fv
;
4042 ops
->position
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
4043 ops
->position
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex2sv
;
4045 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor3fv
;
4046 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4fv
;
4047 ops
->diffuse
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
4048 ops
->diffuse
[WINED3D_FFP_EMIT_UBYTE4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4ubv
;
4049 ops
->diffuse
[WINED3D_FFP_EMIT_SHORT4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4sv
;
4050 ops
->diffuse
[WINED3D_FFP_EMIT_USHORT4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4usv
;
4052 /* No 4 component entry points here. */
4053 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4054 ops
->specular
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)GL_EXTCALL(glSecondaryColor3fvEXT
);
4056 ops
->specular
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
4057 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4058 ops
->specular
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
4060 ops
->specular
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
4062 /* Only 3 component entry points here. Test how others behave. Float4
4063 * normals are used by one of our tests, trying to pass it to the pixel
4064 * shader, which fails on Windows. */
4065 ops
->normal
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
4066 /* Just ignore the 4th value. */
4067 ops
->normal
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
4069 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT1
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord1fvARB
;
4070 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT2
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2fvARB
;
4071 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord3fvARB
;
4072 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4fvARB
;
4073 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT2
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2svARB
;
4074 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4svARB
;
4075 if (gl_info
->supported
[NV_HALF_FLOAT
])
4077 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
4078 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_2
] =
4079 (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2hvNV
;
4080 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_4
] =
4081 (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4hvNV
;
4084 ops
->generic
[WINED3D_FFP_EMIT_FLOAT1
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib1fv
;
4085 ops
->generic
[WINED3D_FFP_EMIT_FLOAT2
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib2fv
;
4086 ops
->generic
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib3fv
;
4087 ops
->generic
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4fv
;
4088 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4089 ops
->generic
[WINED3D_FFP_EMIT_D3DCOLOR
] = generic_d3dcolor
;
4091 ops
->generic
[WINED3D_FFP_EMIT_D3DCOLOR
] =
4092 (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nubv
;
4093 ops
->generic
[WINED3D_FFP_EMIT_UBYTE4
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4ubv
;
4094 ops
->generic
[WINED3D_FFP_EMIT_SHORT2
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib2sv
;
4095 ops
->generic
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4sv
;
4096 ops
->generic
[WINED3D_FFP_EMIT_UBYTE4N
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nubv
;
4097 ops
->generic
[WINED3D_FFP_EMIT_SHORT2N
] = generic_short2n
;
4098 ops
->generic
[WINED3D_FFP_EMIT_SHORT4N
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nsv
;
4099 ops
->generic
[WINED3D_FFP_EMIT_USHORT2N
] = generic_ushort2n
;
4100 ops
->generic
[WINED3D_FFP_EMIT_USHORT4N
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nusv
;
4101 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4103 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_2
] =
4104 (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib2hvNV
;
4105 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_4
] =
4106 (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4hvNV
;
4110 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_2
] = generic_float16_2
;
4111 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_4
] = generic_float16_4
;
4115 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter_gl
*adapter_gl
, HDC dc
)
4117 const struct wined3d_gl_info
*gl_info
= &adapter_gl
->gl_info
;
4120 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
4122 UINT attrib_count
= 0;
4128 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
4129 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, 0, 0, 1, &attribute
, &cfg_count
));
4131 adapter_gl
->pixel_formats
= heap_calloc(cfg_count
, sizeof(*adapter_gl
->pixel_formats
));
4132 attribs
[attrib_count
++] = WGL_RED_BITS_ARB
;
4133 attribs
[attrib_count
++] = WGL_GREEN_BITS_ARB
;
4134 attribs
[attrib_count
++] = WGL_BLUE_BITS_ARB
;
4135 attribs
[attrib_count
++] = WGL_ALPHA_BITS_ARB
;
4136 attribs
[attrib_count
++] = WGL_COLOR_BITS_ARB
;
4137 attribs
[attrib_count
++] = WGL_DEPTH_BITS_ARB
;
4138 attribs
[attrib_count
++] = WGL_STENCIL_BITS_ARB
;
4139 attribs
[attrib_count
++] = WGL_DRAW_TO_WINDOW_ARB
;
4140 attribs
[attrib_count
++] = WGL_PIXEL_TYPE_ARB
;
4141 attribs
[attrib_count
++] = WGL_DOUBLE_BUFFER_ARB
;
4142 attribs
[attrib_count
++] = WGL_AUX_BUFFERS_ARB
;
4143 attribs
[attrib_count
++] = WGL_SWAP_METHOD_ARB
;
4145 for (i
= 0, adapter_gl
->pixel_format_count
= 0; i
< cfg_count
; ++i
)
4147 struct wined3d_pixel_format
*cfg
= &adapter_gl
->pixel_formats
[adapter_gl
->pixel_format_count
];
4148 int format_id
= i
+ 1;
4150 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, format_id
, 0, attrib_count
, attribs
, values
)))
4153 cfg
->iPixelFormat
= format_id
;
4154 cfg
->redSize
= values
[0];
4155 cfg
->greenSize
= values
[1];
4156 cfg
->blueSize
= values
[2];
4157 cfg
->alphaSize
= values
[3];
4158 cfg
->colorSize
= values
[4];
4159 cfg
->depthSize
= values
[5];
4160 cfg
->stencilSize
= values
[6];
4161 cfg
->windowDrawable
= values
[7];
4162 cfg
->iPixelType
= values
[8];
4163 cfg
->doubleBuffer
= values
[9];
4164 cfg
->auxBuffers
= values
[10];
4165 cfg
->swap_method
= values
[11];
4167 cfg
->numSamples
= 0;
4168 /* Check multisample support. */
4169 if (gl_info
->supported
[ARB_MULTISAMPLE
])
4171 int attribs
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
4174 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, format_id
, 0, 2, attribs
, values
)))
4176 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
4177 * multisampling is supported. values[1] = number of
4178 * multisample buffers. */
4180 cfg
->numSamples
= values
[1];
4184 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4185 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
4186 cfg
->iPixelFormat
, cfg
->iPixelType
, cfg
->doubleBuffer
,
4187 cfg
->redSize
, cfg
->greenSize
, cfg
->blueSize
, cfg
->alphaSize
,
4188 cfg
->depthSize
, cfg
->stencilSize
, cfg
->numSamples
, cfg
->windowDrawable
);
4190 ++adapter_gl
->pixel_format_count
;
4197 cfg_count
= DescribePixelFormat(dc
, 0, 0, 0);
4198 adapter_gl
->pixel_formats
= heap_calloc(cfg_count
, sizeof(*adapter_gl
->pixel_formats
));
4200 for (i
= 0, adapter_gl
->pixel_format_count
= 0; i
< cfg_count
; ++i
)
4202 struct wined3d_pixel_format
*cfg
= &adapter_gl
->pixel_formats
[adapter_gl
->pixel_format_count
];
4203 PIXELFORMATDESCRIPTOR pfd
;
4204 int format_id
= i
+ 1;
4206 if (!DescribePixelFormat(dc
, format_id
, sizeof(pfd
), &pfd
))
4209 /* We only want HW acceleration using an OpenGL ICD driver.
4210 * PFD_GENERIC_FORMAT = slow OpenGL 1.1 GDI software rendering.
4211 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
4212 * driver (e.g. 3dfx minigl). */
4213 if (pfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
4215 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id
);
4219 cfg
->iPixelFormat
= format_id
;
4220 cfg
->redSize
= pfd
.cRedBits
;
4221 cfg
->greenSize
= pfd
.cGreenBits
;
4222 cfg
->blueSize
= pfd
.cBlueBits
;
4223 cfg
->alphaSize
= pfd
.cAlphaBits
;
4224 cfg
->colorSize
= pfd
.cColorBits
;
4225 cfg
->depthSize
= pfd
.cDepthBits
;
4226 cfg
->stencilSize
= pfd
.cStencilBits
;
4227 cfg
->windowDrawable
= (pfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
4228 cfg
->iPixelType
= (pfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
4229 cfg
->doubleBuffer
= (pfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
4230 cfg
->auxBuffers
= pfd
.cAuxBuffers
;
4231 cfg
->swap_method
= WGL_SWAP_UNDEFINED_ARB
;
4232 cfg
->numSamples
= 0;
4234 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4235 "depth=%d, stencil=%d, windowDrawable=%d\n",
4236 cfg
->iPixelFormat
, cfg
->iPixelType
, cfg
->doubleBuffer
,
4237 cfg
->redSize
, cfg
->greenSize
, cfg
->blueSize
, cfg
->alphaSize
,
4238 cfg
->depthSize
, cfg
->stencilSize
, cfg
->windowDrawable
);
4240 ++adapter_gl
->pixel_format_count
;
4245 static void adapter_gl_destroy(struct wined3d_adapter
*adapter
)
4247 struct wined3d_adapter_gl
*adapter_gl
= wined3d_adapter_gl(adapter
);
4249 heap_free(adapter_gl
->pixel_formats
);
4250 wined3d_adapter_cleanup(adapter
);
4251 heap_free(adapter_gl
);
4254 static HRESULT
adapter_gl_create_device(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
4255 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
, BYTE surface_alignment
,
4256 const enum wined3d_feature_level
*levels
, unsigned int level_count
,
4257 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
)
4259 struct wined3d_device_gl
*device_gl
;
4262 if (!(device_gl
= heap_alloc_zero(sizeof(*device_gl
))))
4263 return E_OUTOFMEMORY
;
4265 device_gl
->current_fence_id
= 1;
4267 if (FAILED(hr
= wined3d_device_init(&device_gl
->d
, wined3d
, adapter
->ordinal
, device_type
, focus_window
,
4268 flags
, surface_alignment
, levels
, level_count
,
4269 wined3d_adapter_gl_const(adapter
)->gl_info
.supported
, device_parent
)))
4271 WARN("Failed to initialize device, hr %#lx.\n", hr
);
4272 heap_free(device_gl
);
4276 wined3d_lock_init(&device_gl
->allocator_cs
, "wined3d_device_gl.allocator_cs");
4278 *device
= &device_gl
->d
;
4282 static void adapter_gl_destroy_device(struct wined3d_device
*device
)
4284 struct wined3d_device_gl
*device_gl
= wined3d_device_gl(device
);
4286 wined3d_device_cleanup(&device_gl
->d
);
4287 wined3d_lock_cleanup(&device_gl
->allocator_cs
);
4289 heap_free(device_gl
->retired_blocks
);
4290 heap_free(device_gl
);
4293 static struct wined3d_context
*adapter_gl_acquire_context(struct wined3d_device
*device
,
4294 struct wined3d_texture
*texture
, unsigned int sub_resource_idx
)
4296 return wined3d_context_gl_acquire(device
, texture
, sub_resource_idx
);
4299 static void adapter_gl_release_context(struct wined3d_context
*context
)
4301 return wined3d_context_gl_release(wined3d_context_gl(context
));
4304 static void adapter_gl_get_wined3d_caps(const struct wined3d_adapter
*adapter
, struct wined3d_caps
*caps
)
4306 const struct wined3d_gl_info
*gl_info
= &wined3d_adapter_gl_const(adapter
)->gl_info
;
4307 const struct wined3d_d3d_info
*d3d_info
= &adapter
->d3d_info
;
4309 caps
->ddraw_caps
.dds_caps
|= WINEDDSCAPS_BACKBUFFER
4310 | WINEDDSCAPS_COMPLEX
4311 | WINEDDSCAPS_FRONTBUFFER
4312 | WINEDDSCAPS_3DDEVICE
4313 | WINEDDSCAPS_VIDEOMEMORY
4315 | WINEDDSCAPS_LOCALVIDMEM
4316 | WINEDDSCAPS_NONLOCALVIDMEM
;
4318 caps
->ddraw_caps
.caps
|= WINEDDCAPS_3D
;
4320 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] || gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
4321 caps
->Caps2
|= WINED3DCAPS2_CANGENMIPMAP
;
4323 if (gl_info
->supported
[WINED3D_GL_BLEND_EQUATION
])
4324 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_BLENDOP
;
4325 if (gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
] && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
4326 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_SEPARATEALPHABLEND
;
4327 if (gl_info
->supported
[EXT_DRAW_BUFFERS2
])
4328 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS
;
4329 if (gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
])
4330 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_POSTBLENDSRGBCONVERT
;
4331 if (~gl_info
->quirks
& WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS
)
4332 caps
->PrimitiveMiscCaps
|= WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
;
4334 if (gl_info
->supported
[ARB_SAMPLER_OBJECTS
] || gl_info
->supported
[EXT_TEXTURE_LOD_BIAS
])
4335 caps
->RasterCaps
|= WINED3DPRASTERCAPS_MIPMAPLODBIAS
;
4337 if (gl_info
->supported
[ARB_TEXTURE_FILTER_ANISOTROPIC
])
4339 caps
->RasterCaps
|= WINED3DPRASTERCAPS_ANISOTROPY
;
4341 caps
->TextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
4342 | WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4345 if (gl_info
->supported
[ARB_BLEND_FUNC_EXTENDED
])
4346 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_SRCALPHASAT
;
4348 if (gl_info
->supported
[EXT_BLEND_COLOR
])
4350 caps
->SrcBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4351 caps
->DestBlendCaps
|= WINED3DPBLENDCAPS_BLENDFACTOR
;
4354 if (gl_info
->supported
[EXT_TEXTURE3D
])
4356 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP
4357 | WINED3DPTEXTURECAPS_MIPVOLUMEMAP
;
4358 if (!d3d_info
->texture_npot
)
4359 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_VOLUMEMAP_POW2
;
4361 caps
->VolumeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFLINEAR
4362 | WINED3DPTFILTERCAPS_MAGFPOINT
4363 | WINED3DPTFILTERCAPS_MINFLINEAR
4364 | WINED3DPTFILTERCAPS_MINFPOINT
4365 | WINED3DPTFILTERCAPS_MIPFLINEAR
4366 | WINED3DPTFILTERCAPS_MIPFPOINT
4367 | WINED3DPTFILTERCAPS_LINEAR
4368 | WINED3DPTFILTERCAPS_LINEARMIPLINEAR
4369 | WINED3DPTFILTERCAPS_LINEARMIPNEAREST
4370 | WINED3DPTFILTERCAPS_MIPLINEAR
4371 | WINED3DPTFILTERCAPS_MIPNEAREST
4372 | WINED3DPTFILTERCAPS_NEAREST
;
4374 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_INDEPENDENTUV
4375 | WINED3DPTADDRESSCAPS_CLAMP
4376 | WINED3DPTADDRESSCAPS_WRAP
;
4378 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4380 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4382 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4384 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4386 if (gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
])
4388 caps
->VolumeTextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4391 caps
->MaxVolumeExtent
= gl_info
->limits
.texture3d_size
;
4394 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
4396 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP
4397 | WINED3DPTEXTURECAPS_MIPCUBEMAP
;
4398 if (!d3d_info
->texture_npot
)
4399 caps
->TextureCaps
|= WINED3DPTEXTURECAPS_CUBEMAP_POW2
;
4401 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFLINEAR
4402 | WINED3DPTFILTERCAPS_MAGFPOINT
4403 | WINED3DPTFILTERCAPS_MINFLINEAR
4404 | WINED3DPTFILTERCAPS_MINFPOINT
4405 | WINED3DPTFILTERCAPS_MIPFLINEAR
4406 | WINED3DPTFILTERCAPS_MIPFPOINT
4407 | WINED3DPTFILTERCAPS_LINEAR
4408 | WINED3DPTFILTERCAPS_LINEARMIPLINEAR
4409 | WINED3DPTFILTERCAPS_LINEARMIPNEAREST
4410 | WINED3DPTFILTERCAPS_MIPLINEAR
4411 | WINED3DPTFILTERCAPS_MIPNEAREST
4412 | WINED3DPTFILTERCAPS_NEAREST
;
4414 if (gl_info
->supported
[ARB_TEXTURE_FILTER_ANISOTROPIC
])
4416 caps
->CubeTextureFilterCaps
|= WINED3DPTFILTERCAPS_MAGFANISOTROPIC
4417 | WINED3DPTFILTERCAPS_MINFANISOTROPIC
;
4421 if (gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
])
4423 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_BORDER
;
4425 if (gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
])
4427 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRROR
;
4429 if (gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
])
4431 caps
->TextureAddressCaps
|= WINED3DPTADDRESSCAPS_MIRRORONCE
;
4434 if (gl_info
->supported
[EXT_STENCIL_WRAP
])
4436 caps
->StencilCaps
|= WINED3DSTENCILCAPS_DECR
4437 | WINED3DSTENCILCAPS_INCR
;
4440 if (gl_info
->supported
[WINED3D_GL_VERSION_2_0
]
4441 || gl_info
->supported
[EXT_STENCIL_TWO_SIDE
]
4442 || gl_info
->supported
[ATI_SEPARATE_STENCIL
])
4444 caps
->StencilCaps
|= WINED3DSTENCILCAPS_TWOSIDED
;
4447 caps
->MaxAnisotropy
= gl_info
->limits
.anisotropy
;
4449 if (caps
->VertexShaderVersion
>= 3)
4451 caps
->MaxVertexShader30InstructionSlots
4452 = max(caps
->MaxVertexShader30InstructionSlots
, gl_info
->limits
.arb_vs_instructions
);
4454 if (caps
->VertexShaderVersion
>= 2)
4456 caps
->VS20Caps
.temp_count
= max(caps
->VS20Caps
.temp_count
, gl_info
->limits
.arb_vs_temps
);
4458 if (gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
])
4459 caps
->DeclTypes
|= WINED3DDTCAPS_FLOAT16_2
| WINED3DDTCAPS_FLOAT16_4
;
4462 if (caps
->PixelShaderVersion
>= 3)
4464 caps
->MaxPixelShader30InstructionSlots
4465 = max(caps
->MaxPixelShader30InstructionSlots
, gl_info
->limits
.arb_ps_instructions
);
4467 if (caps
->PixelShaderVersion
>= 2)
4469 caps
->PS20Caps
.temp_count
= max(caps
->PS20Caps
.temp_count
, gl_info
->limits
.arb_ps_temps
);
4473 static BOOL
wined3d_check_pixel_format_color(const struct wined3d_pixel_format
*cfg
,
4474 const struct wined3d_format
*format
)
4476 /* Float formats need FBOs. If FBOs are used this function isn't called */
4477 if (format
->attrs
& WINED3D_FORMAT_ATTR_FLOAT
)
4480 /* Probably a RGBA_float or color index mode. */
4481 if (cfg
->iPixelType
!= WGL_TYPE_RGBA_ARB
)
4484 if (cfg
->redSize
< format
->red_size
4485 || cfg
->greenSize
< format
->green_size
4486 || cfg
->blueSize
< format
->blue_size
4487 || cfg
->alphaSize
< format
->alpha_size
)
4493 static BOOL
wined3d_check_pixel_format_depth(const struct wined3d_pixel_format
*cfg
,
4494 const struct wined3d_format
*format
)
4496 BOOL lockable
= FALSE
;
4498 /* Float formats need FBOs. If FBOs are used this function isn't called */
4499 if (format
->attrs
& WINED3D_FORMAT_ATTR_FLOAT
)
4502 if ((format
->id
== WINED3DFMT_D16_LOCKABLE
) || (format
->id
== WINED3DFMT_D32_FLOAT
))
4505 /* On some modern cards like the Geforce8/9, GLX doesn't offer some
4506 * depth/stencil formats which D3D9 reports. We can safely report
4507 * "compatible" formats (e.g. D24 can be used for D16) as long as we
4508 * aren't dealing with a lockable format. This also helps D3D <= 7 as they
4509 * expect D16 which isn't offered without this on Geforce8 cards. */
4510 if (!(cfg
->depthSize
== format
->depth_size
|| (!lockable
&& cfg
->depthSize
> format
->depth_size
)))
4513 /* Some cards like Intel i915 ones only offer D24S8 but lots of games also
4514 * need a format without stencil. We can allow a mismatch if the format
4515 * doesn't have any stencil bits. If it does have stencil bits the size
4516 * must match, or stencil wrapping would break. */
4517 if (format
->stencil_size
&& cfg
->stencilSize
!= format
->stencil_size
)
4523 static BOOL
adapter_gl_check_format(const struct wined3d_adapter
*adapter
,
4524 const struct wined3d_format
*adapter_format
, const struct wined3d_format
*rt_format
,
4525 const struct wined3d_format
*ds_format
)
4527 const struct wined3d_adapter_gl
*adapter_gl
= wined3d_adapter_gl_const(adapter
);
4530 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_BACKBUFFER
)
4533 if (adapter_format
&& rt_format
)
4535 /* In backbuffer mode the front and backbuffer share the same WGL
4536 * pixelformat. The format must match in RGB, alpha is allowed to be
4537 * different. (Only the backbuffer can have alpha.) */
4538 if (adapter_format
->red_size
!= rt_format
->red_size
4539 || adapter_format
->green_size
!= rt_format
->green_size
4540 || adapter_format
->blue_size
!= rt_format
->blue_size
)
4542 TRACE("Render target format %s doesn't match with adapter format %s.\n",
4543 debug_d3dformat(rt_format
->id
), debug_d3dformat(adapter_format
->id
));
4548 for (i
= 0; i
< adapter_gl
->pixel_format_count
; ++i
)
4550 const struct wined3d_pixel_format
*cfg
= &adapter_gl
->pixel_formats
[i
];
4552 /* Check if there is a WGL pixel format matching the requirements, the format should also be window
4553 * drawable (not offscreen; e.g. Nvidia offers R5G6B5 for pbuffers even when X is running at 24bit) */
4554 if (adapter_format
&& rt_format
&& !cfg
->windowDrawable
)
4557 if ((!adapter_format
|| wined3d_check_pixel_format_color(cfg
, adapter_format
))
4558 && (!rt_format
|| wined3d_check_pixel_format_color(cfg
, rt_format
))
4559 && (!ds_format
|| wined3d_check_pixel_format_depth(cfg
, ds_format
)))
4561 TRACE("Pixel format %d is compatible.\n", cfg
->iPixelFormat
);
4569 static HRESULT
adapter_gl_init_3d(struct wined3d_device
*device
)
4571 TRACE("device %p.\n", device
);
4573 wined3d_cs_init_object(device
->cs
, wined3d_device_gl_create_primary_opengl_context_cs
, wined3d_device_gl(device
));
4574 wined3d_cs_finish(device
->cs
, WINED3D_CS_QUEUE_DEFAULT
);
4575 if (!device
->context_count
)
4581 static void adapter_gl_uninit_3d(struct wined3d_device
*device
)
4583 TRACE("device %p.\n", device
);
4585 wined3d_device_destroy_default_samplers(device
);
4586 wined3d_cs_destroy_object(device
->cs
, wined3d_device_gl_delete_opengl_contexts_cs
, wined3d_device_gl(device
));
4587 wined3d_cs_finish(device
->cs
, WINED3D_CS_QUEUE_DEFAULT
);
4590 static void *adapter_gl_map_bo_address(struct wined3d_context
*context
,
4591 const struct wined3d_bo_address
*data
, size_t size
, uint32_t map_flags
)
4593 return wined3d_context_gl_map_bo_address(wined3d_context_gl(context
), data
, size
, map_flags
);
4596 static void adapter_gl_unmap_bo_address(struct wined3d_context
*context
,
4597 const struct wined3d_bo_address
*data
, unsigned int range_count
, const struct wined3d_range
*ranges
)
4599 wined3d_context_gl_unmap_bo_address(wined3d_context_gl(context
), data
, range_count
, ranges
);
4602 static void adapter_gl_copy_bo_address(struct wined3d_context
*context
,
4603 const struct wined3d_bo_address
*dst
, const struct wined3d_bo_address
*src
,
4604 unsigned int range_count
, const struct wined3d_range
*ranges
, uint32_t map_flags
)
4606 wined3d_context_gl_copy_bo_address(wined3d_context_gl(context
), dst
, src
, range_count
, ranges
, map_flags
);
4609 static void adapter_gl_flush_bo_address(struct wined3d_context
*context
,
4610 const struct wined3d_const_bo_address
*data
, size_t size
)
4612 wined3d_context_gl_flush_bo_address(wined3d_context_gl(context
), data
, size
);
4615 static bool adapter_gl_alloc_bo(struct wined3d_device
*device
, struct wined3d_resource
*resource
,
4616 unsigned int sub_resource_idx
, struct wined3d_bo_address
*addr
)
4618 const struct wined3d_gl_info
*gl_info
= &wined3d_adapter_gl(device
->adapter
)->gl_info
;
4619 struct wined3d_device_gl
*device_gl
= wined3d_device_gl(device
);
4620 struct wined3d_bo_gl
*bo_gl
;
4621 GLenum binding
, usage
;
4622 bool coherent
= true;
4626 wined3d_not_from_cs(device
->cs
);
4627 assert(device
->context_count
);
4629 if (resource
->type
== WINED3D_RTYPE_BUFFER
)
4631 size
= resource
->size
;
4632 binding
= wined3d_buffer_gl_binding_from_bind_flags(gl_info
, resource
->bind_flags
);
4633 usage
= GL_STATIC_DRAW
;
4634 flags
= wined3d_resource_gl_storage_flags(resource
);
4635 if (resource
->usage
& WINED3DUSAGE_DYNAMIC
)
4637 usage
= GL_STREAM_DRAW
;
4643 struct wined3d_texture
*texture
= texture_from_resource(resource
);
4645 size
= texture
->sub_resources
[sub_resource_idx
].size
;
4646 binding
= GL_PIXEL_UNPACK_BUFFER
;
4647 usage
= GL_STREAM_DRAW
;
4648 flags
= GL_MAP_READ_BIT
| GL_MAP_WRITE_BIT
| GL_CLIENT_STORAGE_BIT
;
4651 if (!(bo_gl
= heap_alloc(sizeof(*bo_gl
))))
4654 if (!(wined3d_device_gl_create_bo(device_gl
, NULL
, size
, binding
, usage
, coherent
, flags
, bo_gl
)))
4656 WARN("Failed to create OpenGL buffer.\n");
4663 struct wined3d_allocator_chunk_gl
*chunk
= wined3d_allocator_chunk_gl(bo_gl
->memory
->chunk
);
4665 wined3d_allocator_chunk_gl_lock(chunk
);
4667 if ((bo_gl
->b
.map_ptr
= chunk
->c
.map_ptr
))
4668 ++chunk
->c
.map_count
;
4670 wined3d_allocator_chunk_gl_unlock(chunk
);
4673 addr
->buffer_object
= &bo_gl
->b
;
4676 if (!bo_gl
->b
.map_ptr
)
4678 WARN_(d3d_perf
)("BO %p (chunk %p) is not persistently mapped.\n",
4679 bo_gl
, bo_gl
->memory
? bo_gl
->memory
->chunk
: NULL
);
4680 wined3d_cs_map_bo_address(device
->cs
, addr
, resource
->size
, WINED3D_MAP_WRITE
| WINED3D_MAP_DISCARD
);
4686 static void adapter_gl_destroy_bo(struct wined3d_context
*context
, struct wined3d_bo
*bo
)
4688 wined3d_context_gl_destroy_bo(wined3d_context_gl(context
), wined3d_bo_gl(bo
));
4691 static HRESULT
adapter_gl_create_swapchain(struct wined3d_device
*device
,
4692 const struct wined3d_swapchain_desc
*desc
, struct wined3d_swapchain_state_parent
*state_parent
,
4693 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_swapchain
**swapchain
)
4695 struct wined3d_swapchain_gl
*swapchain_gl
;
4698 TRACE("device %p, desc %p, state_parent %p, parent %p, parent_ops %p, swapchain %p.\n",
4699 device
, desc
, state_parent
, parent
, parent_ops
, swapchain
);
4701 if (!(swapchain_gl
= heap_alloc_zero(sizeof(*swapchain_gl
))))
4702 return E_OUTOFMEMORY
;
4704 if (FAILED(hr
= wined3d_swapchain_gl_init(swapchain_gl
, device
, desc
, state_parent
, parent
, parent_ops
)))
4706 WARN("Failed to initialise swapchain, hr %#lx.\n", hr
);
4707 heap_free(swapchain_gl
);
4711 TRACE("Created swapchain %p.\n", swapchain_gl
);
4712 *swapchain
= &swapchain_gl
->s
;
4717 static void adapter_gl_destroy_swapchain(struct wined3d_swapchain
*swapchain
)
4719 struct wined3d_swapchain_gl
*swapchain_gl
= wined3d_swapchain_gl(swapchain
);
4721 wined3d_swapchain_gl_cleanup(swapchain_gl
);
4722 heap_free(swapchain_gl
);
4725 static HRESULT
adapter_gl_create_buffer(struct wined3d_device
*device
,
4726 const struct wined3d_buffer_desc
*desc
, const struct wined3d_sub_resource_data
*data
,
4727 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_buffer
**buffer
)
4729 struct wined3d_buffer_gl
*buffer_gl
;
4732 TRACE("device %p, desc %p, data %p, parent %p, parent_ops %p, buffer %p.\n",
4733 device
, desc
, data
, parent
, parent_ops
, buffer
);
4735 if (!(buffer_gl
= heap_alloc_zero(sizeof(*buffer_gl
))))
4736 return E_OUTOFMEMORY
;
4738 if (FAILED(hr
= wined3d_buffer_gl_init(buffer_gl
, device
, desc
, data
, parent
, parent_ops
)))
4740 WARN("Failed to initialise buffer, hr %#lx.\n", hr
);
4741 heap_free(buffer_gl
);
4745 TRACE("Created buffer %p.\n", buffer_gl
);
4746 *buffer
= &buffer_gl
->b
;
4751 static void adapter_gl_destroy_buffer(struct wined3d_buffer
*buffer
)
4753 struct wined3d_buffer_gl
*buffer_gl
= wined3d_buffer_gl(buffer
);
4754 struct wined3d_device
*device
= buffer_gl
->b
.resource
.device
;
4755 unsigned int swapchain_count
= device
->swapchain_count
;
4757 TRACE("buffer_gl %p.\n", buffer_gl
);
4759 /* Take a reference to the device, in case releasing the buffer would
4760 * cause the device to be destroyed. However, swapchain resources don't
4761 * take a reference to the device, and we wouldn't want to increment the
4762 * refcount on a device that's in the process of being destroyed. */
4763 if (swapchain_count
)
4764 wined3d_device_incref(device
);
4765 wined3d_buffer_cleanup(&buffer_gl
->b
);
4766 wined3d_cs_destroy_object(device
->cs
, heap_free
, buffer_gl
);
4767 if (swapchain_count
)
4768 wined3d_device_decref(device
);
4771 static HRESULT
adapter_gl_create_texture(struct wined3d_device
*device
,
4772 const struct wined3d_resource_desc
*desc
, unsigned int layer_count
, unsigned int level_count
,
4773 uint32_t flags
, void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_texture
**texture
)
4775 struct wined3d_texture_gl
*texture_gl
;
4778 TRACE("device %p, desc %p, layer_count %u, level_count %u, flags %#x, parent %p, parent_ops %p, texture %p.\n",
4779 device
, desc
, layer_count
, level_count
, flags
, parent
, parent_ops
, texture
);
4781 if (!(texture_gl
= wined3d_texture_allocate_object_memory(sizeof(*texture_gl
), level_count
, layer_count
)))
4782 return E_OUTOFMEMORY
;
4784 if (FAILED(hr
= wined3d_texture_gl_init(texture_gl
, device
, desc
,
4785 layer_count
, level_count
, flags
, parent
, parent_ops
)))
4787 WARN("Failed to initialise texture, hr %#lx.\n", hr
);
4788 heap_free(texture_gl
);
4792 TRACE("Created texture %p.\n", texture_gl
);
4793 *texture
= &texture_gl
->t
;
4798 static void adapter_gl_destroy_texture(struct wined3d_texture
*texture
)
4800 struct wined3d_texture_gl
*texture_gl
= wined3d_texture_gl(texture
);
4801 struct wined3d_device
*device
= texture_gl
->t
.resource
.device
;
4802 unsigned int swapchain_count
= device
->swapchain_count
;
4804 TRACE("texture_gl %p.\n", texture_gl
);
4806 /* Take a reference to the device, in case releasing the texture would
4807 * cause the device to be destroyed. However, swapchain resources don't
4808 * take a reference to the device, and we wouldn't want to increment the
4809 * refcount on a device that's in the process of being destroyed. */
4810 if (swapchain_count
)
4811 wined3d_device_incref(device
);
4813 wined3d_texture_sub_resources_destroyed(texture
);
4814 texture
->resource
.parent_ops
->wined3d_object_destroyed(texture
->resource
.parent
);
4816 wined3d_texture_cleanup(&texture_gl
->t
);
4817 wined3d_cs_destroy_object(device
->cs
, heap_free
, texture_gl
);
4819 if (swapchain_count
)
4820 wined3d_device_decref(device
);
4823 static HRESULT
adapter_gl_create_rendertarget_view(const struct wined3d_view_desc
*desc
,
4824 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
4825 struct wined3d_rendertarget_view
**view
)
4827 struct wined3d_rendertarget_view_gl
*view_gl
;
4830 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
4831 wined3d_debug_view_desc(desc
, resource
), resource
, parent
, parent_ops
, view
);
4833 if (!(view_gl
= heap_alloc_zero(sizeof(*view_gl
))))
4834 return E_OUTOFMEMORY
;
4836 if (FAILED(hr
= wined3d_rendertarget_view_gl_init(view_gl
, desc
, resource
, parent
, parent_ops
)))
4838 WARN("Failed to initialise view, hr %#lx.\n", hr
);
4843 TRACE("Created render target view %p.\n", view_gl
);
4844 *view
= &view_gl
->v
;
4849 struct wined3d_view_gl_destroy_ctx
4851 struct wined3d_device
*device
;
4852 const struct wined3d_gl_view
*gl_view
;
4853 struct wined3d_bo_user
*bo_user
;
4854 struct wined3d_bo_gl
*counter_bo
;
4856 struct wined3d_view_gl_destroy_ctx
*free
;
4859 static void wined3d_view_gl_destroy_object(void *object
)
4861 struct wined3d_view_gl_destroy_ctx
*ctx
= object
;
4862 const struct wined3d_gl_info
*gl_info
;
4863 struct wined3d_context
*context
;
4864 struct wined3d_device
*device
;
4867 TRACE("ctx %p.\n", ctx
);
4869 device
= ctx
->device
;
4871 counter_id
= ctx
->counter_bo
? ctx
->counter_bo
->id
: 0;
4872 if (ctx
->gl_view
->name
|| counter_id
)
4874 context
= context_acquire(device
, NULL
, 0);
4875 gl_info
= wined3d_context_gl(context
)->gl_info
;
4876 if (ctx
->gl_view
->name
)
4878 context_gl_resource_released(device
, ctx
->gl_view
->name
, FALSE
);
4879 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &ctx
->gl_view
->name
);
4882 wined3d_context_gl_destroy_bo(wined3d_context_gl(context
), ctx
->counter_bo
);
4883 checkGLcall("delete resources");
4884 context_release(context
);
4887 list_remove(&ctx
->bo_user
->entry
);
4889 heap_free(ctx
->object
);
4890 heap_free(ctx
->free
);
4893 static void wined3d_view_gl_destroy(struct wined3d_device
*device
, const struct wined3d_gl_view
*gl_view
,
4894 struct wined3d_bo_user
*bo_user
, struct wined3d_bo_gl
*counter_bo
, void *object
)
4896 struct wined3d_view_gl_destroy_ctx
*ctx
, c
;
4898 if (!(ctx
= heap_alloc(sizeof(*ctx
))))
4900 ctx
->device
= device
;
4901 ctx
->gl_view
= gl_view
;
4902 ctx
->bo_user
= bo_user
;
4903 ctx
->counter_bo
= counter_bo
;
4904 ctx
->object
= object
;
4905 ctx
->free
= ctx
!= &c
? ctx
: NULL
;
4907 wined3d_cs_destroy_object(device
->cs
, wined3d_view_gl_destroy_object
, ctx
);
4909 wined3d_cs_finish(device
->cs
, WINED3D_CS_QUEUE_DEFAULT
);
4912 static void adapter_gl_destroy_rendertarget_view(struct wined3d_rendertarget_view
*view
)
4914 struct wined3d_rendertarget_view_gl
*view_gl
= wined3d_rendertarget_view_gl(view
);
4915 struct wined3d_resource
*resource
= view_gl
->v
.resource
;
4917 TRACE("view_gl %p.\n", view_gl
);
4919 /* Take a reference to the resource, in case releasing the resource
4920 * would cause the device to be destroyed. */
4921 wined3d_resource_incref(resource
);
4922 wined3d_rendertarget_view_cleanup(&view_gl
->v
);
4923 wined3d_view_gl_destroy(resource
->device
, &view_gl
->gl_view
, NULL
, NULL
, view_gl
);
4924 wined3d_resource_decref(resource
);
4927 static HRESULT
adapter_gl_create_shader_resource_view(const struct wined3d_view_desc
*desc
,
4928 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
4929 struct wined3d_shader_resource_view
**view
)
4931 struct wined3d_shader_resource_view_gl
*view_gl
;
4934 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
4935 wined3d_debug_view_desc(desc
, resource
), resource
, parent
, parent_ops
, view
);
4937 if (!(view_gl
= heap_alloc_zero(sizeof(*view_gl
))))
4938 return E_OUTOFMEMORY
;
4940 if (FAILED(hr
= wined3d_shader_resource_view_gl_init(view_gl
, desc
, resource
, parent
, parent_ops
)))
4942 WARN("Failed to initialise view, hr %#lx.\n", hr
);
4947 TRACE("Created shader resource view %p.\n", view_gl
);
4948 *view
= &view_gl
->v
;
4953 static void adapter_gl_destroy_shader_resource_view(struct wined3d_shader_resource_view
*view
)
4955 struct wined3d_shader_resource_view_gl
*view_gl
= wined3d_shader_resource_view_gl(view
);
4956 struct wined3d_resource
*resource
= view_gl
->v
.resource
;
4958 TRACE("view_gl %p.\n", view_gl
);
4960 /* Take a reference to the resource. There are two reasons for this:
4961 * - Releasing the resource could in turn cause the device to be
4962 * destroyed, but we still need the device for
4963 * wined3d_view_vk_destroy().
4964 * - We shouldn't free buffer resources until after we've removed the
4965 * view from its bo_user list. */
4966 wined3d_resource_incref(resource
);
4967 wined3d_shader_resource_view_cleanup(&view_gl
->v
);
4968 wined3d_view_gl_destroy(resource
->device
, &view_gl
->gl_view
, &view_gl
->bo_user
, NULL
, view_gl
);
4969 wined3d_resource_decref(resource
);
4972 static HRESULT
adapter_gl_create_unordered_access_view(const struct wined3d_view_desc
*desc
,
4973 struct wined3d_resource
*resource
, void *parent
, const struct wined3d_parent_ops
*parent_ops
,
4974 struct wined3d_unordered_access_view
**view
)
4976 struct wined3d_unordered_access_view_gl
*view_gl
;
4979 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
4980 wined3d_debug_view_desc(desc
, resource
), resource
, parent
, parent_ops
, view
);
4982 if (!(view_gl
= heap_alloc_zero(sizeof(*view_gl
))))
4983 return E_OUTOFMEMORY
;
4985 if (FAILED(hr
= wined3d_unordered_access_view_gl_init(view_gl
, desc
, resource
, parent
, parent_ops
)))
4987 WARN("Failed to initialise view, hr %#lx.\n", hr
);
4992 TRACE("Created unordered access view %p.\n", view_gl
);
4993 *view
= &view_gl
->v
;
4998 static void adapter_gl_destroy_unordered_access_view(struct wined3d_unordered_access_view
*view
)
5000 struct wined3d_unordered_access_view_gl
*view_gl
= wined3d_unordered_access_view_gl(view
);
5001 struct wined3d_resource
*resource
= view_gl
->v
.resource
;
5003 TRACE("view_gl %p.\n", view_gl
);
5005 /* Take a reference to the resource. There are two reasons for this:
5006 * - Releasing the resource could in turn cause the device to be
5007 * destroyed, but we still need the device for
5008 * wined3d_view_vk_destroy().
5009 * - We shouldn't free buffer resources until after we've removed the
5010 * view from its bo_user list. */
5011 wined3d_resource_incref(resource
);
5012 wined3d_unordered_access_view_cleanup(&view_gl
->v
);
5013 wined3d_view_gl_destroy(resource
->device
, &view_gl
->gl_view
, &view_gl
->bo_user
, &view_gl
->counter_bo
, view_gl
);
5014 wined3d_resource_decref(resource
);
5017 static HRESULT
adapter_gl_create_sampler(struct wined3d_device
*device
, const struct wined3d_sampler_desc
*desc
,
5018 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_sampler
**sampler
)
5020 struct wined3d_sampler_gl
*sampler_gl
;
5022 TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n",
5023 device
, desc
, parent
, parent_ops
, sampler
);
5025 if (!(sampler_gl
= heap_alloc_zero(sizeof(*sampler_gl
))))
5026 return E_OUTOFMEMORY
;
5028 wined3d_sampler_gl_init(sampler_gl
, device
, desc
, parent
, parent_ops
);
5030 TRACE("Created sampler %p.\n", sampler_gl
);
5031 *sampler
= &sampler_gl
->s
;
5036 static void wined3d_sampler_gl_destroy_object(void *object
)
5038 struct wined3d_sampler_gl
*sampler_gl
= object
;
5039 const struct wined3d_gl_info
*gl_info
;
5040 struct wined3d_context
*context
;
5042 TRACE("sampler_gl %p.\n", sampler_gl
);
5044 if (sampler_gl
->name
)
5046 context
= context_acquire(sampler_gl
->s
.device
, NULL
, 0);
5047 gl_info
= wined3d_context_gl(context
)->gl_info
;
5048 GL_EXTCALL(glDeleteSamplers(1, &sampler_gl
->name
));
5049 context_release(context
);
5052 heap_free(sampler_gl
);
5055 static void adapter_gl_destroy_sampler(struct wined3d_sampler
*sampler
)
5057 struct wined3d_sampler_gl
*sampler_gl
= wined3d_sampler_gl(sampler
);
5059 TRACE("sampler_gl %p.\n", sampler_gl
);
5061 wined3d_cs_destroy_object(sampler
->device
->cs
, wined3d_sampler_gl_destroy_object
, sampler_gl
);
5064 static HRESULT
adapter_gl_create_query(struct wined3d_device
*device
, enum wined3d_query_type type
,
5065 void *parent
, const struct wined3d_parent_ops
*parent_ops
, struct wined3d_query
**query
)
5067 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
5068 device
, type
, parent
, parent_ops
, query
);
5070 return wined3d_query_gl_create(device
, type
, parent
, parent_ops
, query
);
5073 static void wined3d_query_gl_destroy_object(void *object
)
5075 struct wined3d_query
*query
= object
;
5077 TRACE("query %p.\n", query
);
5079 if (query
->buffer_object
)
5081 struct wined3d_context
*context
;
5083 context
= context_acquire(query
->device
, NULL
, 0);
5084 wined3d_query_gl_destroy_buffer_object(wined3d_context_gl(context
), query
);
5085 context_release(context
);
5088 /* Queries are specific to the GL context that created them. Not
5089 * deleting the query will obviously leak it, but that's still better
5090 * than potentially deleting a different query with the same id in this
5091 * context, and (still) leaking the actual query. */
5092 query
->query_ops
->query_destroy(query
);
5095 static void adapter_gl_destroy_query(struct wined3d_query
*query
)
5097 TRACE("query %p.\n", query
);
5099 wined3d_cs_destroy_object(query
->device
->cs
, wined3d_query_gl_destroy_object
, query
);
5102 static void adapter_gl_flush_context(struct wined3d_context
*context
)
5104 struct wined3d_context_gl
*context_gl
= wined3d_context_gl(context
);
5106 TRACE("context_gl %p.\n", context_gl
);
5108 if (context_gl
->valid
)
5109 context_gl
->gl_info
->gl_ops
.gl
.p_glFlush();
5112 static void adapter_gl_clear_uav(struct wined3d_context
*context
,
5113 struct wined3d_unordered_access_view
*view
, const struct wined3d_uvec4
*clear_value
, bool fp
)
5115 TRACE("context %p, view %p, clear_value %s.\n", context
, view
, debug_uvec4(clear_value
));
5117 wined3d_unordered_access_view_gl_clear(wined3d_unordered_access_view_gl(view
),
5118 clear_value
, wined3d_context_gl(context
), fp
);
5121 static void adapter_gl_generate_mipmap(struct wined3d_context
*context
, struct wined3d_shader_resource_view
*view
)
5123 TRACE("context %p, view %p.\n", context
, view
);
5125 wined3d_shader_resource_view_gl_generate_mipmap(wined3d_shader_resource_view_gl(view
),
5126 wined3d_context_gl(context
));
5129 static const struct wined3d_adapter_ops wined3d_adapter_gl_ops
=
5131 .adapter_destroy
= adapter_gl_destroy
,
5132 .adapter_create_device
= adapter_gl_create_device
,
5133 .adapter_destroy_device
= adapter_gl_destroy_device
,
5134 .adapter_acquire_context
= adapter_gl_acquire_context
,
5135 .adapter_release_context
= adapter_gl_release_context
,
5136 .adapter_get_wined3d_caps
= adapter_gl_get_wined3d_caps
,
5137 .adapter_check_format
= adapter_gl_check_format
,
5138 .adapter_init_3d
= adapter_gl_init_3d
,
5139 .adapter_uninit_3d
= adapter_gl_uninit_3d
,
5140 .adapter_map_bo_address
= adapter_gl_map_bo_address
,
5141 .adapter_unmap_bo_address
= adapter_gl_unmap_bo_address
,
5142 .adapter_copy_bo_address
= adapter_gl_copy_bo_address
,
5143 .adapter_flush_bo_address
= adapter_gl_flush_bo_address
,
5144 .adapter_alloc_bo
= adapter_gl_alloc_bo
,
5145 .adapter_destroy_bo
= adapter_gl_destroy_bo
,
5146 .adapter_create_swapchain
= adapter_gl_create_swapchain
,
5147 .adapter_destroy_swapchain
= adapter_gl_destroy_swapchain
,
5148 .adapter_create_buffer
= adapter_gl_create_buffer
,
5149 .adapter_destroy_buffer
= adapter_gl_destroy_buffer
,
5150 .adapter_create_texture
= adapter_gl_create_texture
,
5151 .adapter_destroy_texture
= adapter_gl_destroy_texture
,
5152 .adapter_create_rendertarget_view
= adapter_gl_create_rendertarget_view
,
5153 .adapter_destroy_rendertarget_view
= adapter_gl_destroy_rendertarget_view
,
5154 .adapter_create_shader_resource_view
= adapter_gl_create_shader_resource_view
,
5155 .adapter_destroy_shader_resource_view
= adapter_gl_destroy_shader_resource_view
,
5156 .adapter_create_unordered_access_view
= adapter_gl_create_unordered_access_view
,
5157 .adapter_destroy_unordered_access_view
= adapter_gl_destroy_unordered_access_view
,
5158 .adapter_create_sampler
= adapter_gl_create_sampler
,
5159 .adapter_destroy_sampler
= adapter_gl_destroy_sampler
,
5160 .adapter_create_query
= adapter_gl_create_query
,
5161 .adapter_destroy_query
= adapter_gl_destroy_query
,
5162 .adapter_flush_context
= adapter_gl_flush_context
,
5163 .adapter_draw_primitive
= draw_primitive
,
5164 .adapter_dispatch_compute
= dispatch_compute
,
5165 .adapter_clear_uav
= adapter_gl_clear_uav
,
5166 .adapter_generate_mipmap
= adapter_gl_generate_mipmap
,
5169 static void wined3d_adapter_gl_init_d3d_info(struct wined3d_adapter_gl
*adapter_gl
, uint32_t wined3d_creation_flags
)
5171 const struct wined3d_gl_info
*gl_info
= &adapter_gl
->gl_info
;
5172 struct wined3d_d3d_info
*d3d_info
= &adapter_gl
->a
.d3d_info
;
5173 struct wined3d_vertex_caps vertex_caps
;
5174 struct fragment_caps fragment_caps
;
5175 struct shader_caps shader_caps
;
5178 adapter_gl
->a
.shader_backend
->shader_get_caps(&adapter_gl
->a
, &shader_caps
);
5179 adapter_gl
->a
.vertex_pipe
->vp_get_caps(&adapter_gl
->a
, &vertex_caps
);
5180 adapter_gl
->a
.misc_state_template
= misc_state_template_gl
;
5181 adapter_gl
->a
.fragment_pipe
->get_caps(&adapter_gl
->a
, &fragment_caps
);
5183 d3d_info
->limits
.vs_version
= shader_caps
.vs_version
;
5184 d3d_info
->limits
.hs_version
= shader_caps
.hs_version
;
5185 d3d_info
->limits
.ds_version
= shader_caps
.ds_version
;
5186 d3d_info
->limits
.gs_version
= shader_caps
.gs_version
;
5187 d3d_info
->limits
.ps_version
= shader_caps
.ps_version
;
5188 d3d_info
->limits
.cs_version
= shader_caps
.cs_version
;
5189 d3d_info
->limits
.vs_uniform_count
= shader_caps
.vs_uniform_count
;
5190 d3d_info
->limits
.ps_uniform_count
= shader_caps
.ps_uniform_count
;
5191 d3d_info
->limits
.varying_count
= shader_caps
.varying_count
;
5192 d3d_info
->limits
.ffp_textures
= fragment_caps
.MaxSimultaneousTextures
;
5193 d3d_info
->limits
.ffp_blend_stages
= fragment_caps
.MaxTextureBlendStages
;
5194 TRACE("Max texture stages: %u.\n", d3d_info
->limits
.ffp_blend_stages
);
5195 d3d_info
->limits
.ffp_vertex_blend_matrices
= vertex_caps
.max_vertex_blend_matrices
;
5196 d3d_info
->limits
.active_light_count
= vertex_caps
.max_active_lights
;
5198 d3d_info
->limits
.max_rt_count
= gl_info
->limits
.buffers
;
5199 d3d_info
->limits
.max_clip_distances
= gl_info
->limits
.user_clip_distances
;
5200 d3d_info
->limits
.texture_size
= gl_info
->limits
.texture_size
;
5201 d3d_info
->limits
.sample_count
= gl_info
->limits
.samples
;
5203 gl_info
->gl_ops
.gl
.p_glGetFloatv(gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
]
5204 ? GL_ALIASED_POINT_SIZE_RANGE
: GL_POINT_SIZE_RANGE
, f
);
5205 d3d_info
->limits
.pointsize_max
= f
[1];
5206 TRACE("Maximum point size support - max point size %.8e.\n", f
[1]);
5208 d3d_info
->wined3d_creation_flags
= wined3d_creation_flags
;
5209 d3d_info
->xyzrhw
= vertex_caps
.xyzrhw
;
5210 d3d_info
->emulated_flatshading
= vertex_caps
.emulated_flatshading
;
5211 d3d_info
->ffp_generic_attributes
= vertex_caps
.ffp_generic_attributes
;
5212 d3d_info
->ffp_alpha_test
= !!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
];
5213 d3d_info
->vs_clipping
= shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_VS_CLIPPING
;
5214 d3d_info
->shader_color_key
= !!(fragment_caps
.wined3d_caps
& WINED3D_FRAGMENT_CAP_COLOR_KEY
);
5215 d3d_info
->shader_double_precision
= !!(shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_DOUBLE_PRECISION
);
5216 d3d_info
->shader_output_interpolation
= !!(shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION
);
5217 d3d_info
->frag_coord_correction
= !!gl_info
->supported
[ARB_FRAGMENT_COORD_CONVENTIONS
];
5218 d3d_info
->viewport_array_index_any_shader
= !!gl_info
->supported
[ARB_SHADER_VIEWPORT_LAYER_ARRAY
];
5219 d3d_info
->texture_npot
= !!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
];
5220 d3d_info
->texture_npot_conditional
= gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
]
5221 || gl_info
->supported
[ARB_TEXTURE_RECTANGLE
];
5222 d3d_info
->normalized_texrect
= gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
];
5223 d3d_info
->draw_base_vertex_offset
= !!gl_info
->supported
[ARB_DRAW_ELEMENTS_BASE_VERTEX
];
5224 d3d_info
->vertex_bgra
= !!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
];
5225 d3d_info
->texture_swizzle
= !!gl_info
->supported
[ARB_TEXTURE_SWIZZLE
];
5226 d3d_info
->srgb_read_control
= !!gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
];
5227 d3d_info
->srgb_write_control
= !!gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
];
5228 d3d_info
->clip_control
= !!gl_info
->supported
[ARB_CLIP_CONTROL
];
5229 d3d_info
->full_ffp_varyings
= !!(shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_FULL_FFP_VARYINGS
);
5230 d3d_info
->scaled_resolve
= !!gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED
];
5231 d3d_info
->pbo
= !!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
];
5232 d3d_info
->subpixel_viewport
= gl_info
->limits
.viewport_subpixel_bits
>= 8;
5233 d3d_info
->fences
= wined3d_fence_supported(gl_info
);
5234 d3d_info
->feature_level
= feature_level_from_caps(gl_info
, &shader_caps
, &fragment_caps
);
5235 d3d_info
->filling_convention_offset
= gl_info
->filling_convention_offset
;
5236 d3d_info
->persistent_map
= !!gl_info
->supported
[ARB_BUFFER_STORAGE
];
5238 if (gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
])
5239 d3d_info
->multisample_draw_location
= WINED3D_LOCATION_TEXTURE_RGB
;
5241 d3d_info
->multisample_draw_location
= WINED3D_LOCATION_RB_MULTISAMPLE
;
5244 static float wined3d_adapter_find_fill_offset(struct wined3d_caps_gl_ctx
*ctx
)
5246 static const float test_array
[] =
5255 unsigned int upper
= ARRAY_SIZE(test_array
), lower
= 0, test
;
5258 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
5261 while (upper
!= lower
)
5263 test
= (upper
+ lower
) / 2;
5264 value
= test_array
[test
];
5265 TRACE("Good %u lower %u, test %u.\n", upper
, lower
, test
);
5266 if (wined3d_caps_gl_ctx_test_filling_convention(ctx
, value
))
5272 if (upper
< ARRAY_SIZE(test_array
))
5274 value
= test_array
[upper
];
5276 WARN("Using a filling convention fixup offset of -1/%f.\n", -1.0f
/ value
);
5278 TRACE("No need for a filling convention offset.\n");
5283 FIXME("Did not find a way to get the filling convention we want.\n");
5286 /* This value was used unconditionally before the dynamic test function was
5288 return -1.0f
/ 64.0f
;
5291 static BOOL
wined3d_adapter_gl_init(struct wined3d_adapter_gl
*adapter_gl
,
5292 unsigned int ordinal
, unsigned int wined3d_creation_flags
)
5294 static const unsigned int supported_gl_versions
[] =
5296 MAKEDWORD_VERSION(4, 4),
5297 MAKEDWORD_VERSION(3, 2),
5298 MAKEDWORD_VERSION(1, 0),
5300 struct wined3d_driver_info
*driver_info
= &adapter_gl
->a
.driver_info
;
5301 struct wined3d_gl_info
*gl_info
= &adapter_gl
->gl_info
;
5302 struct wined3d_caps_gl_ctx caps_gl_ctx
= {0};
5303 LUID primary_luid
, *luid
= NULL
;
5306 TRACE("adapter_gl %p, ordinal %u, wined3d_creation_flags %#x.\n",
5307 adapter_gl
, ordinal
, wined3d_creation_flags
);
5309 if (ordinal
== 0 && wined3d_get_primary_adapter_luid(&primary_luid
))
5310 luid
= &primary_luid
;
5312 if (!wined3d_adapter_init(&adapter_gl
->a
, ordinal
, luid
, &wined3d_adapter_gl_ops
))
5315 /* Dynamically load all GL core functions */
5317 HMODULE mod_gl
= GetModuleHandleA("opengl32.dll");
5318 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
5321 gl_info
->gl_ops
.wgl
.p_wglSwapBuffers
= (void *)GetProcAddress(mod_gl
, "wglSwapBuffers");
5322 gl_info
->gl_ops
.wgl
.p_wglGetPixelFormat
= (void *)GetProcAddress(mod_gl
, "wglGetPixelFormat");
5325 gl_info
->p_glEnableWINE
= gl_info
->gl_ops
.gl
.p_glEnable
;
5326 gl_info
->p_glDisableWINE
= gl_info
->gl_ops
.gl
.p_glDisable
;
5328 if (!wined3d_caps_gl_ctx_create(adapter_gl
, &caps_gl_ctx
))
5330 ERR("Failed to get a GL context for adapter %p.\n", adapter_gl
);
5334 for (i
= 0; i
< ARRAY_SIZE(supported_gl_versions
); ++i
)
5336 if (supported_gl_versions
[i
] <= wined3d_settings
.max_gl_version
)
5339 if (i
== ARRAY_SIZE(supported_gl_versions
))
5341 ERR_(winediag
)("Requested invalid GL version %u.%u.\n",
5342 wined3d_settings
.max_gl_version
>> 16, wined3d_settings
.max_gl_version
& 0xffff);
5343 i
= ARRAY_SIZE(supported_gl_versions
) - 1;
5346 for (; i
< ARRAY_SIZE(supported_gl_versions
); ++i
)
5348 gl_info
->selected_gl_version
= supported_gl_versions
[i
];
5350 if (wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx
, gl_info
))
5353 WARN("Couldn't create an OpenGL %u.%u context, trying fallback to a lower version.\n",
5354 supported_gl_versions
[i
] >> 16, supported_gl_versions
[i
] & 0xffff);
5357 if (!wined3d_adapter_init_gl_caps(adapter_gl
, &caps_gl_ctx
, wined3d_creation_flags
))
5359 ERR("Failed to initialize GL caps for adapter %p.\n", adapter_gl
);
5360 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5364 gl_info
->filling_convention_offset
= wined3d_adapter_find_fill_offset(&caps_gl_ctx
);
5366 wined3d_adapter_gl_init_d3d_info(adapter_gl
, wined3d_creation_flags
);
5368 if (!adapter_gl
->a
.d3d_info
.shader_color_key
)
5370 /* We do not want to deal with re-creating immutable texture storage
5371 * for colour-keying emulation. */
5372 WARN("Disabling ARB_texture_storage because fragment pipe doesn't support colour-keying.\n");
5373 gl_info
->supported
[ARB_TEXTURE_STORAGE
] = FALSE
;
5376 if (!wined3d_driver_info_init(driver_info
, caps_gl_ctx
.gpu_description
, adapter_gl
->a
.d3d_info
.feature_level
,
5377 caps_gl_ctx
.vram_bytes
, 0))
5379 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5382 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
5383 driver_info
->version_high
, driver_info
->version_low
);
5385 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
5386 ERR_(winediag
)("You are using the backbuffer for offscreen rendering. "
5387 "This is unsupported, and will be removed in a future version.\n");
5389 wined3d_adapter_init_fb_cfgs(adapter_gl
, caps_gl_ctx
.dc
);
5390 /* We haven't found any suitable formats. This should only happen in
5391 * case of GDI software rendering, which is pretty useless anyway. */
5392 if (!adapter_gl
->pixel_format_count
)
5394 WARN("No suitable pixel formats found.\n");
5395 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5396 heap_free(adapter_gl
->pixel_formats
);
5400 if (!wined3d_adapter_gl_init_format_info(&adapter_gl
->a
, &caps_gl_ctx
))
5402 ERR("Failed to initialize GL format info.\n");
5403 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5404 heap_free(adapter_gl
->pixel_formats
);
5408 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5410 wined3d_adapter_init_ffp_attrib_ops(adapter_gl
);
5415 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
, unsigned int wined3d_creation_flags
)
5417 struct wined3d_adapter_gl
*adapter
;
5419 if (!(adapter
= heap_alloc_zero(sizeof(*adapter
))))
5422 if (!wined3d_adapter_gl_init(adapter
, ordinal
, wined3d_creation_flags
))
5428 TRACE("Created adapter %p.\n", adapter
);