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"
28 WINE_DEFAULT_DEBUG_CHANNEL(d3d
);
29 WINE_DECLARE_DEBUG_CHANNEL(d3d_perf
);
30 WINE_DECLARE_DEBUG_CHANNEL(winediag
);
32 enum wined3d_gl_vendor
41 struct wined3d_extension_map
43 const char *extension_string
;
44 enum wined3d_gl_extension extension
;
47 static const struct wined3d_extension_map gl_extension_map
[] =
50 {"GL_APPLE_fence", APPLE_FENCE
},
51 {"GL_APPLE_float_pixels", APPLE_FLOAT_PIXELS
},
52 {"GL_APPLE_flush_buffer_range", APPLE_FLUSH_BUFFER_RANGE
},
53 {"GL_APPLE_flush_render", APPLE_FLUSH_RENDER
},
54 {"GL_APPLE_rgb_422", APPLE_RGB_422
},
55 {"GL_APPLE_ycbcr_422", APPLE_YCBCR_422
},
58 {"GL_ARB_base_instance", ARB_BASE_INSTANCE
},
59 {"GL_ARB_blend_func_extended", ARB_BLEND_FUNC_EXTENDED
},
60 {"GL_ARB_buffer_storage", ARB_BUFFER_STORAGE
},
61 {"GL_ARB_clear_buffer_object", ARB_CLEAR_BUFFER_OBJECT
},
62 {"GL_ARB_clear_texture", ARB_CLEAR_TEXTURE
},
63 {"GL_ARB_clip_control", ARB_CLIP_CONTROL
},
64 {"GL_ARB_color_buffer_float", ARB_COLOR_BUFFER_FLOAT
},
65 {"GL_ARB_compute_shader", ARB_COMPUTE_SHADER
},
66 {"GL_ARB_conservative_depth", ARB_CONSERVATIVE_DEPTH
},
67 {"GL_ARB_copy_buffer", ARB_COPY_BUFFER
},
68 {"GL_ARB_copy_image", ARB_COPY_IMAGE
},
69 {"GL_ARB_cull_distance", ARB_CULL_DISTANCE
},
70 {"GL_ARB_debug_output", ARB_DEBUG_OUTPUT
},
71 {"GL_ARB_depth_buffer_float", ARB_DEPTH_BUFFER_FLOAT
},
72 {"GL_ARB_depth_clamp", ARB_DEPTH_CLAMP
},
73 {"GL_ARB_depth_texture", ARB_DEPTH_TEXTURE
},
74 {"GL_ARB_derivative_control", ARB_DERIVATIVE_CONTROL
},
75 {"GL_ARB_draw_buffers", ARB_DRAW_BUFFERS
},
76 {"GL_ARB_draw_buffers_blend", ARB_DRAW_BUFFERS_BLEND
},
77 {"GL_ARB_draw_elements_base_vertex", ARB_DRAW_ELEMENTS_BASE_VERTEX
},
78 {"GL_ARB_draw_indirect", ARB_DRAW_INDIRECT
},
79 {"GL_ARB_draw_instanced", ARB_DRAW_INSTANCED
},
80 {"GL_ARB_ES2_compatibility", ARB_ES2_COMPATIBILITY
},
81 {"GL_ARB_ES3_compatibility", ARB_ES3_COMPATIBILITY
},
82 {"GL_ARB_explicit_attrib_location", ARB_EXPLICIT_ATTRIB_LOCATION
},
83 {"GL_ARB_fragment_coord_conventions", ARB_FRAGMENT_COORD_CONVENTIONS
},
84 {"GL_ARB_fragment_layer_viewport", ARB_FRAGMENT_LAYER_VIEWPORT
},
85 {"GL_ARB_fragment_program", ARB_FRAGMENT_PROGRAM
},
86 {"GL_ARB_fragment_shader", ARB_FRAGMENT_SHADER
},
87 {"GL_ARB_framebuffer_no_attachments", ARB_FRAMEBUFFER_NO_ATTACHMENTS
},
88 {"GL_ARB_framebuffer_object", ARB_FRAMEBUFFER_OBJECT
},
89 {"GL_ARB_framebuffer_sRGB", ARB_FRAMEBUFFER_SRGB
},
90 {"GL_ARB_geometry_shader4", ARB_GEOMETRY_SHADER4
},
91 {"GL_ARB_gpu_shader5", ARB_GPU_SHADER5
},
92 {"GL_ARB_half_float_pixel", ARB_HALF_FLOAT_PIXEL
},
93 {"GL_ARB_half_float_vertex", ARB_HALF_FLOAT_VERTEX
},
94 {"GL_ARB_instanced_arrays", ARB_INSTANCED_ARRAYS
},
95 {"GL_ARB_internalformat_query", ARB_INTERNALFORMAT_QUERY
},
96 {"GL_ARB_internalformat_query2", ARB_INTERNALFORMAT_QUERY2
},
97 {"GL_ARB_map_buffer_alignment", ARB_MAP_BUFFER_ALIGNMENT
},
98 {"GL_ARB_map_buffer_range", ARB_MAP_BUFFER_RANGE
},
99 {"GL_ARB_multisample", ARB_MULTISAMPLE
},
100 {"GL_ARB_multitexture", ARB_MULTITEXTURE
},
101 {"GL_ARB_occlusion_query", ARB_OCCLUSION_QUERY
},
102 {"GL_ARB_pipeline_statistics_query", ARB_PIPELINE_STATISTICS_QUERY
},
103 {"GL_ARB_pixel_buffer_object", ARB_PIXEL_BUFFER_OBJECT
},
104 {"GL_ARB_point_parameters", ARB_POINT_PARAMETERS
},
105 {"GL_ARB_point_sprite", ARB_POINT_SPRITE
},
106 {"GL_ARB_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP
},
107 {"GL_ARB_provoking_vertex", ARB_PROVOKING_VERTEX
},
108 {"GL_ARB_query_buffer_object", ARB_QUERY_BUFFER_OBJECT
},
109 {"GL_ARB_sample_shading", ARB_SAMPLE_SHADING
},
110 {"GL_ARB_sampler_objects", ARB_SAMPLER_OBJECTS
},
111 {"GL_ARB_seamless_cube_map", ARB_SEAMLESS_CUBE_MAP
},
112 {"GL_ARB_shader_atomic_counters", ARB_SHADER_ATOMIC_COUNTERS
},
113 {"GL_ARB_shader_bit_encoding", ARB_SHADER_BIT_ENCODING
},
114 {"GL_ARB_shader_image_load_store", ARB_SHADER_IMAGE_LOAD_STORE
},
115 {"GL_ARB_shader_image_size", ARB_SHADER_IMAGE_SIZE
},
116 {"GL_ARB_shader_storage_buffer_object", ARB_SHADER_STORAGE_BUFFER_OBJECT
},
117 {"GL_ARB_shader_texture_image_samples", ARB_SHADER_TEXTURE_IMAGE_SAMPLES
},
118 {"GL_ARB_shader_texture_lod", ARB_SHADER_TEXTURE_LOD
},
119 {"GL_ARB_shader_viewport_layer_array", ARB_SHADER_VIEWPORT_LAYER_ARRAY
},
120 {"GL_ARB_shading_language_100", ARB_SHADING_LANGUAGE_100
},
121 {"GL_ARB_shading_language_420pack", ARB_SHADING_LANGUAGE_420PACK
},
122 {"GL_ARB_shading_language_packing", ARB_SHADING_LANGUAGE_PACKING
},
123 {"GL_ARB_shadow", ARB_SHADOW
},
124 {"GL_ARB_stencil_texturing", ARB_STENCIL_TEXTURING
},
125 {"GL_ARB_sync", ARB_SYNC
},
126 {"GL_ARB_tessellation_shader", ARB_TESSELLATION_SHADER
},
127 {"GL_ARB_texture_border_clamp", ARB_TEXTURE_BORDER_CLAMP
},
128 {"GL_ARB_texture_buffer_object", ARB_TEXTURE_BUFFER_OBJECT
},
129 {"GL_ARB_texture_buffer_range", ARB_TEXTURE_BUFFER_RANGE
},
130 {"GL_ARB_texture_compression", ARB_TEXTURE_COMPRESSION
},
131 {"GL_ARB_texture_compression_bptc", ARB_TEXTURE_COMPRESSION_BPTC
},
132 {"GL_ARB_texture_compression_rgtc", ARB_TEXTURE_COMPRESSION_RGTC
},
133 {"GL_ARB_texture_cube_map", ARB_TEXTURE_CUBE_MAP
},
134 {"GL_ARB_texture_cube_map_array", ARB_TEXTURE_CUBE_MAP_ARRAY
},
135 {"GL_ARB_texture_env_combine", ARB_TEXTURE_ENV_COMBINE
},
136 {"GL_ARB_texture_env_dot3", ARB_TEXTURE_ENV_DOT3
},
137 {"GL_ARB_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC
},
138 {"GL_ARB_texture_float", ARB_TEXTURE_FLOAT
},
139 {"GL_ARB_texture_gather", ARB_TEXTURE_GATHER
},
140 {"GL_ARB_texture_mirrored_repeat", ARB_TEXTURE_MIRRORED_REPEAT
},
141 {"GL_ARB_texture_mirror_clamp_to_edge", ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
},
142 {"GL_ARB_texture_multisample", ARB_TEXTURE_MULTISAMPLE
},
143 {"GL_ARB_texture_non_power_of_two", ARB_TEXTURE_NON_POWER_OF_TWO
},
144 {"GL_ARB_texture_query_levels", ARB_TEXTURE_QUERY_LEVELS
},
145 {"GL_ARB_texture_rectangle", ARB_TEXTURE_RECTANGLE
},
146 {"GL_ARB_texture_rg", ARB_TEXTURE_RG
},
147 {"GL_ARB_texture_rgb10_a2ui", ARB_TEXTURE_RGB10_A2UI
},
148 {"GL_ARB_texture_storage", ARB_TEXTURE_STORAGE
},
149 {"GL_ARB_texture_storage_multisample", ARB_TEXTURE_STORAGE_MULTISAMPLE
},
150 {"GL_ARB_texture_swizzle", ARB_TEXTURE_SWIZZLE
},
151 {"GL_ARB_texture_view", ARB_TEXTURE_VIEW
},
152 {"GL_ARB_timer_query", ARB_TIMER_QUERY
},
153 {"GL_ARB_transform_feedback2", ARB_TRANSFORM_FEEDBACK2
},
154 {"GL_ARB_transform_feedback3", ARB_TRANSFORM_FEEDBACK3
},
155 {"GL_ARB_uniform_buffer_object", ARB_UNIFORM_BUFFER_OBJECT
},
156 {"GL_ARB_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
},
157 {"GL_ARB_vertex_buffer_object", ARB_VERTEX_BUFFER_OBJECT
},
158 {"GL_ARB_vertex_program", ARB_VERTEX_PROGRAM
},
159 {"GL_ARB_vertex_shader", ARB_VERTEX_SHADER
},
160 {"GL_ARB_vertex_type_10f_11f_11f_rev", ARB_VERTEX_TYPE_10F_11F_11F_REV
},
161 {"GL_ARB_vertex_type_2_10_10_10_rev", ARB_VERTEX_TYPE_2_10_10_10_REV
},
162 {"GL_ARB_viewport_array", ARB_VIEWPORT_ARRAY
},
163 {"GL_ARB_texture_barrier", ARB_TEXTURE_BARRIER
},
166 {"GL_ATI_fragment_shader", ATI_FRAGMENT_SHADER
},
167 {"GL_ATI_separate_stencil", ATI_SEPARATE_STENCIL
},
168 {"GL_ATI_texture_compression_3dc", ATI_TEXTURE_COMPRESSION_3DC
},
169 {"GL_ATI_texture_env_combine3", ATI_TEXTURE_ENV_COMBINE3
},
170 {"GL_ATI_texture_mirror_once", ATI_TEXTURE_MIRROR_ONCE
},
173 {"GL_EXT_blend_color", EXT_BLEND_COLOR
},
174 {"GL_EXT_blend_equation_separate", EXT_BLEND_EQUATION_SEPARATE
},
175 {"GL_EXT_blend_func_separate", EXT_BLEND_FUNC_SEPARATE
},
176 {"GL_EXT_blend_minmax", EXT_BLEND_MINMAX
},
177 {"GL_EXT_blend_subtract", EXT_BLEND_SUBTRACT
},
178 {"GL_EXT_depth_bounds_test", EXT_DEPTH_BOUNDS_TEST
},
179 {"GL_EXT_draw_buffers2", EXT_DRAW_BUFFERS2
},
180 {"GL_EXT_fog_coord", EXT_FOG_COORD
},
181 {"GL_EXT_framebuffer_blit", EXT_FRAMEBUFFER_BLIT
},
182 {"GL_EXT_framebuffer_multisample", EXT_FRAMEBUFFER_MULTISAMPLE
},
183 {"GL_EXT_framebuffer_multisample_blit_scaled",
184 EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED
},
185 {"GL_EXT_framebuffer_object", EXT_FRAMEBUFFER_OBJECT
},
186 {"GL_EXT_memory_object", EXT_MEMORY_OBJECT
},
187 {"GL_EXT_gpu_program_parameters", EXT_GPU_PROGRAM_PARAMETERS
},
188 {"GL_EXT_gpu_shader4", EXT_GPU_SHADER4
},
189 {"GL_EXT_packed_depth_stencil", EXT_PACKED_DEPTH_STENCIL
},
190 {"GL_EXT_packed_float", EXT_PACKED_FLOAT
},
191 {"GL_EXT_point_parameters", EXT_POINT_PARAMETERS
},
192 {"GL_EXT_polygon_offset_clamp", ARB_POLYGON_OFFSET_CLAMP
},
193 {"GL_EXT_provoking_vertex", EXT_PROVOKING_VERTEX
},
194 {"GL_EXT_secondary_color", EXT_SECONDARY_COLOR
},
195 {"GL_EXT_stencil_two_side", EXT_STENCIL_TWO_SIDE
},
196 {"GL_EXT_stencil_wrap", EXT_STENCIL_WRAP
},
197 {"GL_EXT_texture3D", EXT_TEXTURE3D
},
198 {"GL_EXT_texture_array", EXT_TEXTURE_ARRAY
},
199 {"GL_EXT_texture_compression_rgtc", EXT_TEXTURE_COMPRESSION_RGTC
},
200 {"GL_EXT_texture_compression_s3tc", EXT_TEXTURE_COMPRESSION_S3TC
},
201 {"GL_EXT_texture_env_combine", EXT_TEXTURE_ENV_COMBINE
},
202 {"GL_EXT_texture_env_dot3", EXT_TEXTURE_ENV_DOT3
},
203 {"GL_EXT_texture_filter_anisotropic", ARB_TEXTURE_FILTER_ANISOTROPIC
},
204 {"GL_EXT_texture_integer", EXT_TEXTURE_INTEGER
},
205 {"GL_EXT_texture_lod_bias", EXT_TEXTURE_LOD_BIAS
},
206 {"GL_EXT_texture_mirror_clamp", EXT_TEXTURE_MIRROR_CLAMP
},
207 {"GL_EXT_texture_shadow_lod", EXT_TEXTURE_SHADOW_LOD
},
208 {"GL_EXT_texture_shared_exponent", EXT_TEXTURE_SHARED_EXPONENT
},
209 {"GL_EXT_texture_snorm", EXT_TEXTURE_SNORM
},
210 {"GL_EXT_texture_sRGB", EXT_TEXTURE_SRGB
},
211 {"GL_EXT_texture_sRGB_decode", EXT_TEXTURE_SRGB_DECODE
},
212 {"GL_EXT_texture_swizzle", ARB_TEXTURE_SWIZZLE
},
213 {"GL_EXT_vertex_array_bgra", ARB_VERTEX_ARRAY_BGRA
},
216 {"GL_NV_fence", NV_FENCE
},
217 {"GL_NV_fog_distance", NV_FOG_DISTANCE
},
218 {"GL_NV_fragment_program", NV_FRAGMENT_PROGRAM
},
219 {"GL_NV_fragment_program2", NV_FRAGMENT_PROGRAM2
},
220 {"GL_NV_fragment_program_option", NV_FRAGMENT_PROGRAM_OPTION
},
221 {"GL_NV_half_float", NV_HALF_FLOAT
},
222 {"GL_NV_light_max_exponent", NV_LIGHT_MAX_EXPONENT
},
223 {"GL_NV_point_sprite", NV_POINT_SPRITE
},
224 {"GL_NV_register_combiners", NV_REGISTER_COMBINERS
},
225 {"GL_NV_register_combiners2", NV_REGISTER_COMBINERS2
},
226 {"GL_NV_texgen_reflection", NV_TEXGEN_REFLECTION
},
227 {"GL_NV_texture_env_combine4", NV_TEXTURE_ENV_COMBINE4
},
228 {"GL_NV_texture_shader", NV_TEXTURE_SHADER
},
229 {"GL_NV_texture_shader2", NV_TEXTURE_SHADER2
},
230 {"GL_NV_vertex_program", NV_VERTEX_PROGRAM
},
231 {"GL_NV_vertex_program1_1", NV_VERTEX_PROGRAM1_1
},
232 {"GL_NV_vertex_program2", NV_VERTEX_PROGRAM2
},
233 {"GL_NV_vertex_program2_option", NV_VERTEX_PROGRAM2_OPTION
},
234 {"GL_NV_vertex_program3", NV_VERTEX_PROGRAM3
},
235 {"GL_NV_texture_barrier", NV_TEXTURE_BARRIER
},
238 static const struct wined3d_extension_map wgl_extension_map
[] =
240 {"WGL_ARB_pixel_format", WGL_ARB_PIXEL_FORMAT
},
241 {"WGL_EXT_swap_control", WGL_EXT_SWAP_CONTROL
},
242 {"WGL_WINE_pixel_format_passthrough", WGL_WINE_PIXEL_FORMAT_PASSTHROUGH
},
243 {"WGL_WINE_query_renderer", WGL_WINE_QUERY_RENDERER
},
246 static void wined3d_caps_gl_ctx_destroy(const struct wined3d_caps_gl_ctx
*ctx
)
248 const struct wined3d_gl_info
*gl_info
= ctx
->gl_info
;
250 TRACE("Destroying caps GL context.\n");
252 /* Both glDeleteProgram and glDeleteBuffers silently ignore 0 IDs but
253 * this function might be called before the relevant function pointers
254 * in gl_info are initialized. */
255 if (ctx
->test_program_id
|| ctx
->test_vbo
)
257 GL_EXTCALL(glDeleteProgram(ctx
->test_program_id
));
258 GL_EXTCALL(glDeleteBuffers(1, &ctx
->test_vbo
));
261 if (!wglMakeCurrent(NULL
, NULL
))
262 ERR("Failed to disable caps GL context.\n");
264 if (!wglDeleteContext(ctx
->gl_ctx
))
266 DWORD err
= GetLastError();
267 ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx
->gl_ctx
, err
);
270 wined3d_release_dc(ctx
->wnd
, ctx
->dc
);
271 DestroyWindow(ctx
->wnd
);
273 if (ctx
->restore_gl_ctx
&& !wglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
274 ERR("Failed to restore previous GL context.\n");
277 static BOOL
wined3d_caps_gl_ctx_create_attribs(struct wined3d_caps_gl_ctx
*caps_gl_ctx
,
278 struct wined3d_gl_info
*gl_info
)
282 if (!(gl_info
->p_wglCreateContextAttribsARB
= (void *)wglGetProcAddress("wglCreateContextAttribsARB")))
285 if (!(new_ctx
= context_create_wgl_attribs(gl_info
, caps_gl_ctx
->dc
, NULL
)))
287 gl_info
->p_wglCreateContextAttribsARB
= NULL
;
291 if (!wglMakeCurrent(caps_gl_ctx
->dc
, new_ctx
))
293 ERR("Failed to make new context current, last error %#x.\n", GetLastError());
294 if (!wglDeleteContext(new_ctx
))
295 ERR("Failed to delete new context, last error %#x.\n", GetLastError());
296 gl_info
->p_wglCreateContextAttribsARB
= NULL
;
300 if (!wglDeleteContext(caps_gl_ctx
->gl_ctx
))
301 ERR("Failed to delete old context, last error %#x.\n", GetLastError());
302 caps_gl_ctx
->gl_ctx
= new_ctx
;
307 static BOOL
wined3d_caps_gl_ctx_create(struct wined3d_adapter
*adapter
, struct wined3d_caps_gl_ctx
*ctx
)
309 PIXELFORMATDESCRIPTOR pfd
;
312 TRACE("getting context...\n");
314 ctx
->restore_dc
= wglGetCurrentDC();
315 ctx
->restore_gl_ctx
= wglGetCurrentContext();
317 /* We need a fake window as a hdc retrieved using GetDC(0) can't be used for much GL purposes. */
318 ctx
->wnd
= CreateWindowA(WINED3D_OPENGL_WINDOW_CLASS_NAME
, "WineD3D fake window",
319 WS_OVERLAPPEDWINDOW
, 10, 10, 10, 10, NULL
, NULL
, NULL
, NULL
);
322 ERR("Failed to create a window.\n");
326 ctx
->dc
= GetDC(ctx
->wnd
);
329 ERR("Failed to get a DC.\n");
333 /* PixelFormat selection */
334 ZeroMemory(&pfd
, sizeof(pfd
));
335 pfd
.nSize
= sizeof(pfd
);
337 pfd
.dwFlags
= PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER
| PFD_DRAW_TO_WINDOW
; /* PFD_GENERIC_ACCELERATED */
338 pfd
.iPixelType
= PFD_TYPE_RGBA
;
340 pfd
.iLayerType
= PFD_MAIN_PLANE
;
342 if (!(iPixelFormat
= ChoosePixelFormat(ctx
->dc
, &pfd
)))
344 /* If this happens something is very wrong as ChoosePixelFormat barely fails. */
345 ERR("Failed to find a suitable pixel format.\n");
348 DescribePixelFormat(ctx
->dc
, iPixelFormat
, sizeof(pfd
), &pfd
);
349 SetPixelFormat(ctx
->dc
, iPixelFormat
, &pfd
);
351 /* Create a GL context. */
352 if (!(ctx
->gl_ctx
= wglCreateContext(ctx
->dc
)))
354 WARN("Failed to create default context for capabilities initialization.\n");
358 /* Make it the current GL context. */
359 if (!wglMakeCurrent(ctx
->dc
, ctx
->gl_ctx
))
361 ERR("Failed to make caps GL context current.\n");
365 ctx
->gl_info
= &adapter
->gl_info
;
369 if (ctx
->gl_ctx
) wglDeleteContext(ctx
->gl_ctx
);
371 if (ctx
->dc
) ReleaseDC(ctx
->wnd
, ctx
->dc
);
373 if (ctx
->wnd
) DestroyWindow(ctx
->wnd
);
375 if (ctx
->restore_gl_ctx
&& !wglMakeCurrent(ctx
->restore_dc
, ctx
->restore_gl_ctx
))
376 ERR("Failed to restore previous GL context.\n");
381 /* Context activation is done by the caller. */
382 static BOOL
test_arb_vs_offset_limit(const struct wined3d_gl_info
*gl_info
)
386 static const char testcode
[] =
388 "PARAM C[66] = { program.env[0..65] };\n"
390 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
391 "ARL A0.x, zero.x;\n"
392 "MOV result.position, C[A0.x + 65];\n"
395 while (gl_info
->gl_ops
.gl
.p_glGetError());
396 GL_EXTCALL(glGenProgramsARB(1, &prog
));
398 ERR("Failed to create an ARB offset limit test program\n");
400 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
401 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
402 strlen(testcode
), testcode
));
403 if (gl_info
->gl_ops
.gl
.p_glGetError())
405 TRACE("OpenGL implementation does not allow indirect addressing offsets > 63\n");
406 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
408 } else TRACE("OpenGL implementation allows offsets > 63\n");
410 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
411 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
412 checkGLcall("ARB vp offset limit test cleanup");
417 static BOOL
match_amd_r300_to_500(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
418 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
419 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
421 return card_vendor
== HW_VENDOR_AMD
422 && (device
== CARD_AMD_RADEON_9500
423 || device
== CARD_AMD_RADEON_X700
424 || device
== CARD_AMD_RADEON_X1600
);
427 static BOOL
match_geforce5(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
428 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
429 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
431 return card_vendor
== HW_VENDOR_NVIDIA
432 && (device
== CARD_NVIDIA_GEFORCEFX_5200
433 || device
== CARD_NVIDIA_GEFORCEFX_5600
434 || device
== CARD_NVIDIA_GEFORCEFX_5800
);
437 static BOOL
match_apple(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
438 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
439 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
441 /* MacOS has various specialities in the extensions it advertises. Some
442 * have to be loaded from the OpenGL 1.2+ core, while other extensions are
443 * advertised, but software emulated. So try to detect the Apple OpenGL
444 * implementation to apply some extension fixups afterwards.
446 * Detecting this isn't really easy. The vendor string doesn't mention
447 * Apple. Compile-time checks aren't sufficient either because a Linux
448 * binary may display on a macOS X server via remote X11. So try to detect
449 * the OpenGL implementation by looking at certain Apple extensions. Some
450 * extensions like client storage might be supported on other
451 * implementations too, but GL_APPLE_flush_render is specific to the
452 * macOS X window management, and GL_APPLE_ycbcr_422 is QuickTime
453 * specific. So the chance that other implementations support them is
454 * rather small since Win32 QuickTime uses DirectDraw, not OpenGL.
456 * This test has been moved into wined3d_guess_gl_vendor(). */
457 return gl_vendor
== GL_VENDOR_APPLE
;
460 /* Context activation is done by the caller. */
461 static void test_pbo_functionality(struct wined3d_gl_info
*gl_info
)
463 /* Some OpenGL implementations, namely Apple's Geforce 8 driver, advertises PBOs,
464 * but glTexSubImage from a PBO fails miserably, with the first line repeated over
465 * all the texture. This function detects this bug by its symptom and disables PBOs
468 * The test uploads a 4x4 texture via the PBO in the "native" format GL_BGRA,
469 * GL_UNSIGNED_INT_8_8_8_8_REV. This format triggers the bug, and it is what we use
470 * for D3DFMT_A8R8G8B8. Then the texture is read back without any PBO and the data
471 * read back is compared to the original. If they are equal PBOs are assumed to work,
472 * otherwise the PBO extension is disabled. */
474 static const unsigned int pattern
[] =
476 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
477 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
478 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
479 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
481 unsigned int check
[ARRAY_SIZE(pattern
)];
483 /* No PBO -> No point in testing them. */
484 if (!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
]) return;
486 while (gl_info
->gl_ops
.gl
.p_glGetError());
487 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &texture
);
488 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, texture
);
490 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAX_LEVEL
, 0);
491 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);
492 checkGLcall("Specifying the PBO test texture");
494 GL_EXTCALL(glGenBuffers(1, &pbo
));
495 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER
, pbo
));
496 GL_EXTCALL(glBufferData(GL_PIXEL_UNPACK_BUFFER
, sizeof(pattern
), pattern
, GL_STREAM_DRAW
));
497 checkGLcall("Specifying the PBO test pbo");
499 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
);
500 checkGLcall("Loading the PBO test texture");
502 GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER
, 0));
504 gl_info
->gl_ops
.gl
.p_glFinish(); /* just to be sure */
506 memset(check
, 0, sizeof(check
));
507 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, check
);
508 checkGLcall("Reading back the PBO test texture");
510 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &texture
);
511 GL_EXTCALL(glDeleteBuffers(1, &pbo
));
512 checkGLcall("PBO test cleanup");
514 if (memcmp(check
, pattern
, sizeof(check
)))
516 WARN_(d3d_perf
)("PBO test failed, read back data doesn't match original.\n"
517 "Disabling PBOs. This may result in slower performance.\n");
518 gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
] = FALSE
;
522 TRACE("PBO test successful.\n");
526 static BOOL
match_dx10_capable(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
527 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
528 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
530 /* Direct3D 9 cards support 40 single float varyings in hardware, most
531 * drivers report 32. ATI misreports 44 varyings. So assume that if we
532 * have more than 44 varyings we have a Direct3D 10+ card. This detection
533 * is for the gl_ClipPos varying quirk. If a Direct3D 9 card really
534 * supports more than 44 varyings and we subtract one in Direct3D 9
535 * shaders it's not going to hurt us because the Direct3D 9 limit is
538 * Direct3D 10 cards usually have 64 varyings. */
539 return gl_info
->limits
.glsl_varyings
> 44;
542 static BOOL
match_not_dx10_capable(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
543 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
544 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
546 return !match_dx10_capable(gl_info
, ctx
, gl_renderer
, gl_vendor
, card_vendor
, device
);
549 /* A GL context is provided by the caller */
550 static BOOL
match_allows_spec_alpha(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
551 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
552 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
557 if (!gl_info
->supported
[EXT_SECONDARY_COLOR
] || !gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
560 while (gl_info
->gl_ops
.gl
.p_glGetError());
561 GL_EXTCALL(glSecondaryColorPointerEXT
)(4, GL_UNSIGNED_BYTE
, 4, data
);
562 error
= gl_info
->gl_ops
.gl
.p_glGetError();
564 if (error
== GL_NO_ERROR
)
566 TRACE("GL Implementation accepts 4 component specular color pointers\n");
571 TRACE("GL implementation does not accept 4 component specular colors, error %s\n",
572 debug_glerror(error
));
577 /* A GL context is provided by the caller */
578 static BOOL
match_broken_nv_clip(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
579 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
580 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
585 static const char testcode
[] =
587 "OPTION NV_vertex_program2;\n"
588 "MOV result.clip[0], 0.0;\n"
589 "MOV result.position, 0.0;\n"
592 if (!gl_info
->supported
[NV_VERTEX_PROGRAM2_OPTION
]) return FALSE
;
594 while (gl_info
->gl_ops
.gl
.p_glGetError());
596 GL_EXTCALL(glGenProgramsARB(1, &prog
));
599 ERR("Failed to create the NVvp clip test program\n");
602 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prog
));
603 GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
604 strlen(testcode
), testcode
));
605 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &pos
);
608 WARN("GL_NV_vertex_program2_option result.clip[] test failed\n");
609 TRACE("error: %s\n", debugstr_a((const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
)));
611 while (gl_info
->gl_ops
.gl
.p_glGetError());
613 else TRACE("GL_NV_vertex_program2_option result.clip[] test passed\n");
615 GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, 0));
616 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
617 checkGLcall("GL_NV_vertex_program2_option result.clip[] test cleanup");
622 /* Context activation is done by the caller. */
623 static BOOL
match_fbo_tex_update(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
624 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
625 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
627 char data
[4 * 4 * 4];
631 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
) return FALSE
;
633 memset(data
, 0xcc, sizeof(data
));
635 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
636 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
637 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
638 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
639 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
);
640 checkGLcall("glTexImage2D");
642 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
643 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
644 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
645 checkGLcall("glFramebufferTexture2D");
647 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
648 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
649 checkGLcall("glCheckFramebufferStatus");
651 memset(data
, 0x11, sizeof(data
));
652 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
);
653 checkGLcall("glTexSubImage2D");
655 gl_info
->gl_ops
.gl
.p_glClearColor(0.996f
, 0.729f
, 0.745f
, 0.792f
);
656 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
657 checkGLcall("glClear");
659 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
660 checkGLcall("glGetTexImage");
662 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, 0, 0);
663 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
664 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
665 checkGLcall("glBindTexture");
667 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
668 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
669 checkGLcall("glDeleteTextures");
671 return *(DWORD
*)data
== 0x11111111;
674 /* Context activation is done by the caller. */
675 static BOOL
match_broken_rgba16(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
676 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
677 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
679 /* GL_RGBA16 uses GL_RGBA8 internally on Geforce 7 and older cards.
680 * This leads to graphical bugs in Half Life 2 and Unreal engine games. */
684 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
685 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
686 gl_info
->gl_ops
.gl
.p_glTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA16
, 4, 4, 0, GL_RGBA
, GL_UNSIGNED_SHORT
, NULL
);
687 checkGLcall("glTexImage2D");
689 gl_info
->gl_ops
.gl
.p_glGetTexLevelParameteriv(GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &size
);
690 checkGLcall("glGetTexLevelParameteriv");
691 TRACE("Real color depth is %d\n", size
);
693 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
694 checkGLcall("glBindTexture");
695 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
696 checkGLcall("glDeleteTextures");
701 static BOOL
match_fglrx(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
702 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
703 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
705 return gl_vendor
== GL_VENDOR_FGLRX
;
708 static BOOL
match_r200(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
709 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
710 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
712 if (card_vendor
!= HW_VENDOR_AMD
) return FALSE
;
713 if (device
== CARD_AMD_RADEON_8500
) return TRUE
;
717 static BOOL
match_broken_arb_fog(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
718 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
719 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
724 float color
[4] = {0.0f
, 1.0f
, 0.0f
, 0.0f
};
727 static const char program_code
[] =
729 "OPTION ARB_fog_linear;\n"
730 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
733 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
735 if (!gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
737 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
740 gl_info
->gl_ops
.gl
.p_glGenTextures(1, &tex
);
741 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
);
742 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
743 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
744 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
);
745 checkGLcall("glTexImage2D");
747 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
748 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, fbo
);
749 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
, 0);
750 checkGLcall("glFramebufferTexture2D");
752 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_FRAMEBUFFER
);
753 if (status
!= GL_FRAMEBUFFER_COMPLETE
) ERR("FBO status %#x\n", status
);
754 checkGLcall("glCheckFramebufferStatus");
756 gl_info
->gl_ops
.gl
.p_glClearColor(0.0f
, 0.0f
, 1.0f
, 0.0f
);
757 gl_info
->gl_ops
.gl
.p_glClear(GL_COLOR_BUFFER_BIT
);
758 checkGLcall("glClear");
759 gl_info
->gl_ops
.gl
.p_glViewport(0, 0, 4, 1);
760 checkGLcall("glViewport");
762 gl_info
->gl_ops
.gl
.p_glEnable(GL_FOG
);
763 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_START
, 0.5f
);
764 gl_info
->gl_ops
.gl
.p_glFogf(GL_FOG_END
, 0.5f
);
765 gl_info
->gl_ops
.gl
.p_glFogi(GL_FOG_MODE
, GL_LINEAR
);
766 gl_info
->gl_ops
.gl
.p_glHint(GL_FOG_HINT
, GL_NICEST
);
767 gl_info
->gl_ops
.gl
.p_glFogfv(GL_FOG_COLOR
, color
);
768 checkGLcall("fog setup");
770 GL_EXTCALL(glGenProgramsARB(1, &prog
));
771 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, prog
));
772 GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
773 strlen(program_code
), program_code
));
774 gl_info
->gl_ops
.gl
.p_glEnable(GL_FRAGMENT_PROGRAM_ARB
);
775 checkGLcall("Test fragment program setup");
777 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &err_pos
);
780 const char *error_str
;
781 error_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_PROGRAM_ERROR_STRING_ARB
);
782 FIXME("Fog test program error at position %d: %s\n\n", err_pos
, debugstr_a(error_str
));
785 gl_info
->gl_ops
.gl
.p_glBegin(GL_TRIANGLE_STRIP
);
786 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, -1.0f
, 0.0f
);
787 gl_info
->gl_ops
.gl
.p_glVertex3f( 1.0f
, -1.0f
, 1.0f
);
788 gl_info
->gl_ops
.gl
.p_glVertex3f(-1.0f
, 1.0f
, 0.0f
);
789 gl_info
->gl_ops
.gl
.p_glVertex3f( 1.0f
, 1.0f
, 1.0f
);
790 gl_info
->gl_ops
.gl
.p_glEnd();
791 checkGLcall("ARBfp fog test draw");
793 gl_info
->gl_ops
.gl
.p_glGetTexImage(GL_TEXTURE_2D
, 0, GL_BGRA
, GL_UNSIGNED_INT_8_8_8_8_REV
, data
);
794 checkGLcall("glGetTexImage");
795 data
[0] &= 0x00ffffff;
796 data
[1] &= 0x00ffffff;
797 data
[2] &= 0x00ffffff;
798 data
[3] &= 0x00ffffff;
800 gl_info
->fbo_ops
.glBindFramebuffer(GL_FRAMEBUFFER
, 0);
801 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
803 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
804 gl_info
->gl_ops
.gl
.p_glDeleteTextures(1, &tex
);
805 gl_info
->gl_ops
.gl
.p_glDisable(GL_FOG
);
806 GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB
, 0));
807 gl_info
->gl_ops
.gl
.p_glDisable(GL_FRAGMENT_PROGRAM_ARB
);
808 GL_EXTCALL(glDeleteProgramsARB(1, &prog
));
809 checkGLcall("ARBfp fog test teardown");
811 TRACE("Fog test data: %08x %08x %08x %08x\n", data
[0], data
[1], data
[2], data
[3]);
812 return data
[0] != 0x00ff0000 || data
[3] != 0x0000ff00;
815 static BOOL
match_broken_viewport_subpixel_bits(const struct wined3d_gl_info
*gl_info
,
816 struct wined3d_caps_gl_ctx
*ctx
, const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
817 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
819 if (!gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
821 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
823 return !wined3d_caps_gl_ctx_test_viewport_subpixel_bits(ctx
);
826 static BOOL
match_no_independent_bit_depths(const struct wined3d_gl_info
*gl_info
,
827 struct wined3d_caps_gl_ctx
*ctx
, const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
828 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
)
833 /* ARB_framebuffer_object allows implementation-dependent internal format
834 * restrictions. The EXT extension explicitly calls out an error in the
836 if (!gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
838 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
841 gl_info
->gl_ops
.gl
.p_glGenTextures(2, tex
);
843 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
[0]);
844 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
845 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
846 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
);
848 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, tex
[1]);
849 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
850 gl_info
->gl_ops
.gl
.p_glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
851 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
);
852 gl_info
->gl_ops
.gl
.p_glBindTexture(GL_TEXTURE_2D
, 0);
854 gl_info
->fbo_ops
.glGenFramebuffers(1, &fbo
);
855 gl_info
->fbo_ops
.glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, fbo
);
856 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
, GL_TEXTURE_2D
, tex
[0], 0);
857 gl_info
->fbo_ops
.glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER
, GL_COLOR_ATTACHMENT1
, GL_TEXTURE_2D
, tex
[1], 0);
859 status
= gl_info
->fbo_ops
.glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER
);
861 gl_info
->fbo_ops
.glBindFramebuffer(GL_DRAW_FRAMEBUFFER
, 0);
862 gl_info
->fbo_ops
.glDeleteFramebuffers(1, &fbo
);
863 gl_info
->gl_ops
.gl
.p_glDeleteTextures(2, tex
);
864 checkGLcall("testing multiple framebuffer attachments with different bit depths");
866 return status
!= GL_FRAMEBUFFER_COMPLETE
;
869 static void quirk_apple_glsl_constants(struct wined3d_gl_info
*gl_info
)
871 /* MacOS needs uniforms for relative addressing offsets. This can
872 * accumulate to quite a few uniforms. Beyond that the general uniform
873 * isn't optimal, so reserve a number of uniforms. 12 vec4's should allow
874 * 48 different offsets or other helper immediate values. */
875 TRACE("Reserving 12 GLSL constants for compiler private use.\n");
876 gl_info
->reserved_glsl_constants
= max(gl_info
->reserved_glsl_constants
, 12);
879 static void quirk_amd_dx9(struct wined3d_gl_info
*gl_info
)
881 /* MacOS advertises GL_ARB_texture_non_power_of_two on ATI r500 and
882 * earlier cards, although these cards only support
883 * GL_ARB_texture_rectangle (D3DPTEXTURECAPS_NONPOW2CONDITIONAL).
885 * If real NP2 textures are used, the driver falls back to software. We
886 * could just disable the extension and use GL_ARB_texture_rectangle
887 * instead, but texture_rectangle is inconvenient due to the
888 * non-normalised texture coordinates. Thus set an internal extension
889 * flag, GL_WINE_normalized_texrect, which signals the code that it can
890 * use non-power-of-two textures as per GL_ARB_texture_non_power_of_two,
891 * but has to stick to the texture_rectangle limits.
893 * Fglrx doesn't advertise GL_ARB_texture_non_power_of_two, but it
894 * advertises OpenGL 2.0, which has this extension promoted to core. The
895 * extension loading code sets this extension supported due to that, so
896 * this code works on fglrx as well. */
897 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
899 TRACE("GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
900 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
901 gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
] = TRUE
;
905 static void quirk_no_np2(struct wined3d_gl_info
*gl_info
)
907 /* The NVIDIA GeForce FX series reports OpenGL 2.0 capabilities with the
908 * latest drivers versions, but doesn't explicitly advertise the
909 * ARB_tex_npot extension in the OpenGL extension string. This usually
910 * means that ARB_tex_npot is supported in hardware as long as the
911 * application is staying within the limits enforced by the
912 * ARB_texture_rectangle extension. This however is not true for the
913 * FX series, which instantly falls back to a slower software path as
914 * soon as ARB_tex_npot is used. We therefore completely remove
915 * ARB_tex_npot from the list of supported extensions.
917 * Note that WINE_normalized_texrect can't be used in this case because
918 * internally it uses ARB_tex_npot, triggering the software fallback.
919 * There is not much we can do here apart from disabling the
920 * software-emulated extension and re-enable ARB_tex_rect (which was
921 * previously disabled in wined3d_adapter_init_gl_caps).
923 * This fixup removes performance problems on both the FX 5900 and
924 * FX 5700 (e.g. for framebuffer post-processing effects in the game
925 * "Max Payne 2"). The behaviour can be verified through a simple test
926 * app attached in bugreport #14724. */
927 TRACE("GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
928 gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
] = FALSE
;
929 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = TRUE
;
932 static void quirk_clip_varying(struct wined3d_gl_info
*gl_info
)
934 gl_info
->quirks
|= WINED3D_QUIRK_GLSL_CLIP_VARYING
;
937 static void quirk_allows_specular_alpha(struct wined3d_gl_info
*gl_info
)
939 gl_info
->quirks
|= WINED3D_QUIRK_ALLOWS_SPECULAR_ALPHA
;
942 static void quirk_disable_nvvp_clip(struct wined3d_gl_info
*gl_info
)
944 gl_info
->quirks
|= WINED3D_QUIRK_NV_CLIP_BROKEN
;
947 static void quirk_fbo_tex_update(struct wined3d_gl_info
*gl_info
)
949 gl_info
->quirks
|= WINED3D_QUIRK_FBO_TEX_UPDATE
;
952 static void quirk_broken_rgba16(struct wined3d_gl_info
*gl_info
)
954 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_RGBA16
;
957 static void quirk_infolog_spam(struct wined3d_gl_info
*gl_info
)
959 gl_info
->quirks
|= WINED3D_QUIRK_INFO_LOG_SPAM
;
962 static void quirk_limited_tex_filtering(struct wined3d_gl_info
*gl_info
)
964 /* NVIDIA GeForce 6xxx and 7xxx support accelerated VTF only on a few
965 * selected texture formats. They are apparently the only Direct3D 9 class
966 * GPUs supporting VTF. Also, Direct3D 9-era GPUs are somewhat limited
967 * with float texture filtering and blending. */
968 gl_info
->quirks
|= WINED3D_QUIRK_LIMITED_TEX_FILTERING
;
971 static void quirk_r200_constants(struct wined3d_gl_info
*gl_info
)
973 /* The Mesa r200 driver (and there is no other driver for this GPU Wine
974 * would run on) loads some fog parameters (start, end, exponent, but not
975 * the colour) into the program.
977 * Apparently the fog hardware is only able to handle linear fog with a
978 * range of 0.0;1.0, and it is the responsibility of the vertex pipeline
979 * to handle non-linear fog and linear fog with start and end other than
981 TRACE("Reserving 1 ARB constant for compiler private use.\n");
982 gl_info
->reserved_arb_constants
= max(gl_info
->reserved_arb_constants
, 1);
985 static void quirk_broken_arb_fog(struct wined3d_gl_info
*gl_info
)
987 gl_info
->quirks
|= WINED3D_QUIRK_BROKEN_ARB_FOG
;
990 static void quirk_broken_viewport_subpixel_bits(struct wined3d_gl_info
*gl_info
)
992 gl_info
->limits
.viewport_subpixel_bits
= 0;
993 if (gl_info
->supported
[ARB_CLIP_CONTROL
])
995 TRACE("Disabling ARB_clip_control.\n");
996 gl_info
->supported
[ARB_CLIP_CONTROL
] = FALSE
;
1000 static void quirk_no_independent_bit_depths(struct wined3d_gl_info
*gl_info
)
1002 gl_info
->quirks
|= WINED3D_QUIRK_NO_INDEPENDENT_BIT_DEPTHS
;
1005 static const struct wined3d_gpu_description
*query_gpu_description(const struct wined3d_gl_info
*gl_info
,
1008 const struct wined3d_gpu_description
*gpu_description
= NULL
, *gpu_description_override
;
1009 enum wined3d_pci_vendor vendor
= PCI_VENDOR_NONE
;
1010 enum wined3d_pci_device device
= PCI_DEVICE_NONE
;
1013 if (gl_info
->supported
[WGL_WINE_QUERY_RENDERER
])
1015 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VENDOR_ID_WINE
, &value
)))
1017 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_DEVICE_ID_WINE
, &value
)))
1019 if (GL_EXTCALL(wglQueryCurrentRendererIntegerWINE(WGL_RENDERER_VIDEO_MEMORY_WINE
, &value
)))
1020 *vram_bytes
= (UINT64
)value
* 1024 * 1024;
1022 TRACE("Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1023 vendor
, device
, wine_dbgstr_longlong(*vram_bytes
));
1025 gpu_description
= wined3d_get_gpu_description(vendor
, device
);
1028 if ((gpu_description_override
= wined3d_get_user_override_gpu_description(vendor
, device
)))
1029 gpu_description
= gpu_description_override
;
1031 return gpu_description
;
1034 /* Context activation is done by the caller. */
1035 static void fixup_extensions(struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
1036 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
)
1038 enum wined3d_pci_vendor card_vendor
= ctx
->gpu_description
->vendor
;
1039 enum wined3d_pci_device device
= ctx
->gpu_description
->device
;
1042 static const struct driver_quirk
1044 BOOL (*match
)(const struct wined3d_gl_info
*gl_info
, struct wined3d_caps_gl_ctx
*ctx
,
1045 const char *gl_renderer
, enum wined3d_gl_vendor gl_vendor
,
1046 enum wined3d_pci_vendor card_vendor
, enum wined3d_pci_device device
);
1047 void (*apply
)(struct wined3d_gl_info
*gl_info
);
1048 const char *description
;
1053 match_amd_r300_to_500
,
1055 "AMD normalised texrect quirk"
1059 quirk_apple_glsl_constants
,
1060 "Apple GLSL uniform override"
1065 "Geforce 5 NP2 disable"
1070 "Reserved varying for gl_ClipPos"
1073 /* GL_EXT_secondary_color does not allow 4 component secondary
1074 * colours, but most OpenGL implementations accept it. Apple's
1075 * is the only OpenGL implementation known to reject it.
1077 * If we can pass 4-component specular colours, do it, because
1078 * (a) we don't have to screw around with the data, and (b) the
1079 * Direct3D fixed-function vertex pipeline passes specular alpha
1080 * to the pixel shader if any is used. Otherwise the specular
1081 * alpha is used to pass the fog coordinate, which we pass to
1082 * OpenGL via GL_EXT_fog_coord. */
1083 match_allows_spec_alpha
,
1084 quirk_allows_specular_alpha
,
1085 "Allow specular alpha quirk"
1088 match_broken_nv_clip
,
1089 quirk_disable_nvvp_clip
,
1090 "Apple NV_vertex_program clip bug quirk"
1093 match_fbo_tex_update
,
1094 quirk_fbo_tex_update
,
1095 "FBO rebind for attachment updates"
1098 match_broken_rgba16
,
1099 quirk_broken_rgba16
,
1100 "True RGBA16 is not available"
1105 "Not printing GLSL infolog"
1108 match_not_dx10_capable
,
1109 quirk_limited_tex_filtering
,
1110 "Texture filtering, blending and VTF support is limited"
1114 quirk_r200_constants
,
1115 "r200 vertex shader constants"
1118 match_broken_arb_fog
,
1119 quirk_broken_arb_fog
,
1120 "ARBfp fogstart == fogend workaround"
1123 match_broken_viewport_subpixel_bits
,
1124 quirk_broken_viewport_subpixel_bits
,
1125 "NVIDIA viewport subpixel bits bug"
1128 match_no_independent_bit_depths
,
1129 quirk_no_independent_bit_depths
,
1130 "No support for MRT with independent bit depths"
1134 for (i
= 0; i
< ARRAY_SIZE(quirk_table
); ++i
)
1136 if (!quirk_table
[i
].match(gl_info
, ctx
, gl_renderer
, gl_vendor
, card_vendor
, device
)) continue;
1137 TRACE("Applying driver quirk \"%s\".\n", quirk_table
[i
].description
);
1138 quirk_table
[i
].apply(gl_info
);
1141 /* Find out if PBOs work as they are supposed to. */
1142 test_pbo_functionality(gl_info
);
1145 static DWORD
wined3d_parse_gl_version(const char *gl_version
)
1147 const char *ptr
= gl_version
;
1152 ERR("Invalid OpenGL major version %d.\n", major
);
1154 while (isdigit(*ptr
)) ++ptr
;
1156 ERR("Invalid OpenGL version string %s.\n", debugstr_a(gl_version
));
1160 TRACE("Found OpenGL version %d.%d.\n", major
, minor
);
1162 return MAKEDWORD_VERSION(major
, minor
);
1165 static enum wined3d_gl_vendor
wined3d_guess_gl_vendor(const struct wined3d_gl_info
*gl_info
,
1166 const char *gl_vendor_string
, const char *gl_renderer
, const char *gl_version
)
1168 /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
1169 * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
1170 * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
1172 * Detecting this isn't really easy. The vendor string doesn't mention Apple. Compile-time checks
1173 * aren't sufficient either because a Linux binary may display on a macos X server via remote X11.
1174 * So try to detect the GL implementation by looking at certain Apple extensions. Some extensions
1175 * like client storage might be supported on other implementations too, but GL_APPLE_flush_render
1176 * is specific to the Mac OS X window management, and GL_APPLE_ycbcr_422 is QuickTime specific. So
1177 * the chance that other implementations support them is rather small since Win32 QuickTime uses
1178 * DirectDraw, not OpenGL. */
1179 if (gl_info
->supported
[APPLE_FLUSH_RENDER
]
1180 && (gl_info
->supported
[APPLE_YCBCR_422
] || gl_info
->supported
[APPLE_RGB_422
]))
1181 return GL_VENDOR_APPLE
;
1183 if (strstr(gl_vendor_string
, "NVIDIA"))
1184 return GL_VENDOR_NVIDIA
;
1186 if (strstr(gl_vendor_string
, "ATI"))
1187 return GL_VENDOR_FGLRX
;
1189 if (strstr(gl_vendor_string
, "Mesa")
1190 || strstr(gl_vendor_string
, "X.Org")
1191 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1192 || strstr(gl_vendor_string
, "DRI R300 Project")
1193 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1194 || strstr(gl_vendor_string
, "VMware, Inc.")
1195 || strstr(gl_vendor_string
, "Red Hat")
1196 || strstr(gl_vendor_string
, "Intel")
1197 || strstr(gl_renderer
, "Mesa")
1198 || strstr(gl_renderer
, "Gallium")
1199 || strstr(gl_renderer
, "Intel")
1200 || strstr(gl_version
, "Mesa"))
1201 return GL_VENDOR_MESA
;
1203 FIXME("Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1204 debugstr_a(gl_vendor_string
));
1206 return GL_VENDOR_UNKNOWN
;
1209 static enum wined3d_pci_vendor
wined3d_guess_card_vendor(const char *gl_vendor_string
, const char *gl_renderer
)
1211 if (strstr(gl_vendor_string
, "NVIDIA")
1212 || strstr(gl_vendor_string
, "Nouveau")
1213 || strstr(gl_vendor_string
, "nouveau"))
1214 return HW_VENDOR_NVIDIA
;
1216 if (strstr(gl_vendor_string
, "ATI")
1217 || strstr(gl_vendor_string
, "Advanced Micro Devices, Inc.")
1218 || strstr(gl_vendor_string
, "X.Org R300 Project")
1219 || strstr(gl_renderer
, "AMD")
1220 || strstr(gl_renderer
, "FirePro")
1221 || strstr(gl_renderer
, "Radeon")
1222 || strstr(gl_renderer
, "R100")
1223 || strstr(gl_renderer
, "R200")
1224 || strstr(gl_renderer
, "R300")
1225 || strstr(gl_renderer
, "R600")
1226 || strstr(gl_renderer
, "R700"))
1227 return HW_VENDOR_AMD
;
1229 if (strstr(gl_vendor_string
, "Intel(R)")
1230 /* Intel switched from Intel(R) to Intel® recently, so just match Intel. */
1231 || strstr(gl_renderer
, "Intel")
1232 || strstr(gl_renderer
, "i915")
1233 || strstr(gl_vendor_string
, "Intel Inc."))
1234 return HW_VENDOR_INTEL
;
1236 if (strstr(gl_vendor_string
, "Red Hat")
1237 || strstr(gl_renderer
, "virgl"))
1238 return HW_VENDOR_REDHAT
;
1240 if (strstr(gl_renderer
, "SVGA3D"))
1241 return HW_VENDOR_VMWARE
;
1243 if (strstr(gl_vendor_string
, "Mesa")
1244 || strstr(gl_vendor_string
, "Brian Paul")
1245 || strstr(gl_vendor_string
, "Tungsten Graphics, Inc")
1246 || strstr(gl_vendor_string
, "VMware, Inc."))
1247 return HW_VENDOR_SOFTWARE
;
1249 FIXME("Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n", debugstr_a(gl_vendor_string
));
1251 return HW_VENDOR_NVIDIA
;
1254 static enum wined3d_feature_level
feature_level_from_caps(const struct wined3d_gl_info
*gl_info
,
1255 const struct shader_caps
*shader_caps
, const struct fragment_caps
*fragment_caps
)
1257 unsigned int shader_model
;
1259 shader_model
= min(shader_caps
->vs_version
, shader_caps
->ps_version
);
1260 shader_model
= min(shader_model
, max(shader_caps
->gs_version
, 3));
1261 shader_model
= min(shader_model
, max(shader_caps
->hs_version
, 4));
1262 shader_model
= min(shader_model
, max(shader_caps
->ds_version
, 4));
1264 if (gl_info
->supported
[WINED3D_GL_VERSION_3_2
]
1265 && gl_info
->supported
[ARB_POLYGON_OFFSET_CLAMP
]
1266 && gl_info
->supported
[ARB_SAMPLER_OBJECTS
])
1268 if (shader_model
>= 5
1269 && gl_info
->supported
[ARB_DRAW_INDIRECT
]
1270 && gl_info
->supported
[ARB_TEXTURE_COMPRESSION_BPTC
])
1271 return WINED3D_FEATURE_LEVEL_11_1
;
1273 if (shader_model
>= 4)
1275 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP_ARRAY
]
1276 && gl_info
->supported
[ARB_DRAW_BUFFERS_BLEND
])
1277 return WINED3D_FEATURE_LEVEL_10_1
;
1278 return WINED3D_FEATURE_LEVEL_10
;
1282 if (shader_model
>= 3 && gl_info
->limits
.texture_size
>= 4096 && gl_info
->limits
.buffers
>= 4)
1283 return WINED3D_FEATURE_LEVEL_9_3
;
1284 if (shader_model
>= 2)
1286 if (gl_info
->supported
[ARB_OCCLUSION_QUERY
]
1287 && gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
]
1288 && gl_info
->supported
[EXT_BLEND_EQUATION_SEPARATE
]
1289 && gl_info
->supported
[EXT_BLEND_FUNC_SEPARATE
])
1290 return WINED3D_FEATURE_LEVEL_9_2
;
1292 return WINED3D_FEATURE_LEVEL_9_1
;
1294 if (shader_model
>= 1)
1295 return WINED3D_FEATURE_LEVEL_8
;
1297 if (fragment_caps
->TextureOpCaps
& WINED3DTEXOPCAPS_DOTPRODUCT3
)
1298 return WINED3D_FEATURE_LEVEL_7
;
1299 if (fragment_caps
->MaxSimultaneousTextures
> 1)
1300 return WINED3D_FEATURE_LEVEL_6
;
1302 return WINED3D_FEATURE_LEVEL_5
;
1305 static const struct wined3d_renderer_table
1307 const char *renderer
;
1308 enum wined3d_pci_device id
;
1310 cards_nvidia_binary
[] =
1313 {"Tesla T4", CARD_NVIDIA_TESLA_T4
},
1314 {"RTX 2080 Ti", CARD_NVIDIA_GEFORCE_RTX2080TI
}, /* GeForce 2000 - highend */
1315 {"RTX 2080", CARD_NVIDIA_GEFORCE_RTX2080
}, /* GeForce 2000 - highend */
1316 {"RTX 2070", CARD_NVIDIA_GEFORCE_RTX2070
}, /* GeForce 2000 - highend */
1317 {"RTX 2060", CARD_NVIDIA_GEFORCE_RTX2060
}, /* GeForce 2000 - highend */
1318 {"GTX 1660 Ti", CARD_NVIDIA_GEFORCE_GTX1660TI
}, /* GeForce 1600 - highend */
1319 {"GTX 1660 SUPER", CARD_NVIDIA_GEFORCE_GTX1660SUPER
}, /* GeForce 1600 - highend */
1320 {"GTX 1650 SUPER", CARD_NVIDIA_GEFORCE_GTX1650SUPER
}, /* GeForce 1600 - midend high */
1321 {"TITAN V", CARD_NVIDIA_TITANV
}, /* GeForce 1000 - highend */
1322 {"TITAN X (Pascal)", CARD_NVIDIA_TITANX_PASCAL
}, /* GeForce 1000 - highend */
1323 {"GTX 1080 Ti", CARD_NVIDIA_GEFORCE_GTX1080TI
}, /* GeForce 1000 - highend */
1324 {"GTX 1080", CARD_NVIDIA_GEFORCE_GTX1080
}, /* GeForce 1000 - highend */
1325 {"GTX 1070", CARD_NVIDIA_GEFORCE_GTX1070
}, /* GeForce 1000 - highend */
1326 {"GTX 1060 3GB", CARD_NVIDIA_GEFORCE_GTX1060_3GB
},/* GeForce 1000 - midend high */
1327 {"GTX 1060", CARD_NVIDIA_GEFORCE_GTX1060
}, /* GeForce 1000 - midend high */
1328 {"GTX 1050 Ti", CARD_NVIDIA_GEFORCE_GTX1050TI
}, /* GeForce 1000 - midend */
1329 {"GTX 1050", CARD_NVIDIA_GEFORCE_GTX1050
}, /* GeForce 1000 - midend */
1330 {"GT 1030", CARD_NVIDIA_GEFORCE_GT1030
}, /* GeForce 1000 - lowend */
1331 {"GTX 980 Ti", CARD_NVIDIA_GEFORCE_GTX980TI
}, /* GeForce 900 - highend */
1332 {"GTX 980", CARD_NVIDIA_GEFORCE_GTX980
}, /* GeForce 900 - highend */
1333 {"GTX 970M", CARD_NVIDIA_GEFORCE_GTX970M
}, /* GeForce 900 - highend mobile*/
1334 {"GTX 970", CARD_NVIDIA_GEFORCE_GTX970
}, /* GeForce 900 - highend */
1335 {"GTX TITAN X", CARD_NVIDIA_GEFORCE_GTXTITANX
}, /* Geforce 900 - highend */
1336 {"GTX 960M", CARD_NVIDIA_GEFORCE_GTX960M
}, /* GeForce 900 - midend high mobile */
1337 {"GTX 960", CARD_NVIDIA_GEFORCE_GTX960
}, /* GeForce 900 - midend high */
1338 {"GTX 950M", CARD_NVIDIA_GEFORCE_GTX950M
}, /* GeForce 900 - midend mobile */
1339 {"GTX 950", CARD_NVIDIA_GEFORCE_GTX950
}, /* GeForce 900 - midend */
1340 {"GeForce 940M", CARD_NVIDIA_GEFORCE_940M
}, /* GeForce 900 - midend mobile */
1341 {"GTX 880M", CARD_NVIDIA_GEFORCE_GTX880M
}, /* GeForce 800 - mobile */
1342 {"GTX 870M", CARD_NVIDIA_GEFORCE_GTX870M
}, /* GeForce 800 - mobile */
1343 {"GTX 860M", CARD_NVIDIA_GEFORCE_GTX860M
}, /* GeForce 800 - mobile */
1344 {"GTX 850M", CARD_NVIDIA_GEFORCE_GTX850M
}, /* GeForce 800 - mobile */
1345 {"GeForce 845M", CARD_NVIDIA_GEFORCE_845M
}, /* GeForce 800 - mobile */
1346 {"GeForce 840M", CARD_NVIDIA_GEFORCE_840M
}, /* GeForce 800 - mobile */
1347 {"GeForce 830M", CARD_NVIDIA_GEFORCE_830M
}, /* GeForce 800 - mobile */
1348 {"GeForce 820M", CARD_NVIDIA_GEFORCE_820M
}, /* GeForce 800 - mobile */
1349 {"GTX 780 Ti", CARD_NVIDIA_GEFORCE_GTX780TI
}, /* Geforce 700 - highend */
1350 {"GTX TITAN Black", CARD_NVIDIA_GEFORCE_GTXTITANB
}, /* Geforce 700 - highend */
1351 {"GTX TITAN Z", CARD_NVIDIA_GEFORCE_GTXTITANZ
}, /* Geforce 700 - highend */
1352 {"GTX TITAN", CARD_NVIDIA_GEFORCE_GTXTITAN
}, /* Geforce 700 - highend */
1353 {"GTX 780", CARD_NVIDIA_GEFORCE_GTX780
}, /* Geforce 700 - highend */
1354 {"GTX 770M", CARD_NVIDIA_GEFORCE_GTX770M
}, /* Geforce 700 - midend high mobile */
1355 {"GTX 770", CARD_NVIDIA_GEFORCE_GTX770
}, /* Geforce 700 - highend */
1356 {"GTX 765M", CARD_NVIDIA_GEFORCE_GTX765M
}, /* Geforce 700 - midend high mobile */
1357 {"GTX 760 Ti", CARD_NVIDIA_GEFORCE_GTX760TI
}, /* Geforce 700 - midend high */
1358 {"GTX 760", CARD_NVIDIA_GEFORCE_GTX760
}, /* Geforce 700 - midend high */
1359 {"GTX 750 Ti", CARD_NVIDIA_GEFORCE_GTX750TI
}, /* Geforce 700 - midend */
1360 {"GTX 750", CARD_NVIDIA_GEFORCE_GTX750
}, /* Geforce 700 - midend */
1361 {"GT 750M", CARD_NVIDIA_GEFORCE_GT750M
}, /* Geforce 700 - midend mobile */
1362 {"GT 740M", CARD_NVIDIA_GEFORCE_GT740M
}, /* Geforce 700 - midend mobile */
1363 {"GT 730M", CARD_NVIDIA_GEFORCE_GT730M
}, /* Geforce 700 - midend mobile */
1364 {"GT 730", CARD_NVIDIA_GEFORCE_GT730
}, /* Geforce 700 - lowend */
1365 {"GTX 690", CARD_NVIDIA_GEFORCE_GTX690
}, /* Geforce 600 - highend */
1366 {"GTX 680", CARD_NVIDIA_GEFORCE_GTX680
}, /* Geforce 600 - highend */
1367 {"GTX 675MX", CARD_NVIDIA_GEFORCE_GTX675MX_1
},/* Geforce 600 - highend */
1368 {"GTX 670MX", CARD_NVIDIA_GEFORCE_GTX670MX
}, /* Geforce 600 - highend */
1369 {"GTX 670", CARD_NVIDIA_GEFORCE_GTX670
}, /* Geforce 600 - midend high */
1370 {"GTX 660 Ti", CARD_NVIDIA_GEFORCE_GTX660TI
}, /* Geforce 600 - midend high */
1371 {"GTX 660M", CARD_NVIDIA_GEFORCE_GTX660M
}, /* Geforce 600 - midend high mobile */
1372 {"GTX 660", CARD_NVIDIA_GEFORCE_GTX660
}, /* Geforce 600 - midend high */
1373 {"GTX 650 Ti", CARD_NVIDIA_GEFORCE_GTX650TI
}, /* Geforce 600 - lowend */
1374 {"GTX 650", CARD_NVIDIA_GEFORCE_GTX650
}, /* Geforce 600 - lowend */
1375 {"GT 650M", CARD_NVIDIA_GEFORCE_GT650M
}, /* Geforce 600 - midend mobile */
1376 {"GT 640M", CARD_NVIDIA_GEFORCE_GT640M
}, /* Geforce 600 - midend mobile */
1377 {"GT 630M", CARD_NVIDIA_GEFORCE_GT630M
}, /* Geforce 600 - midend mobile */
1378 {"GT 630", CARD_NVIDIA_GEFORCE_GT630
}, /* Geforce 600 - lowend */
1379 {"GT 610", CARD_NVIDIA_GEFORCE_GT610
}, /* Geforce 600 - lowend */
1380 {"GTX 580", CARD_NVIDIA_GEFORCE_GTX580
}, /* Geforce 500 - highend */
1381 {"GTX 570", CARD_NVIDIA_GEFORCE_GTX570
}, /* Geforce 500 - midend high */
1382 {"GTX 560 Ti", CARD_NVIDIA_GEFORCE_GTX560TI
}, /* Geforce 500 - midend */
1383 {"GTX 560M", CARD_NVIDIA_GEFORCE_GTX560M
}, /* Geforce 500 - midend mobile */
1384 {"GTX 560", CARD_NVIDIA_GEFORCE_GTX560
}, /* Geforce 500 - midend */
1385 {"GT 555M", CARD_NVIDIA_GEFORCE_GT555M
}, /* Geforce 500 - midend mobile */
1386 {"GTX 550 Ti", CARD_NVIDIA_GEFORCE_GTX550
}, /* Geforce 500 - midend */
1387 {"GT 540M", CARD_NVIDIA_GEFORCE_GT540M
}, /* Geforce 500 - midend mobile */
1388 {"GT 525M", CARD_NVIDIA_GEFORCE_GT525M
}, /* Geforce 500 - lowend mobile */
1389 {"GT 520", CARD_NVIDIA_GEFORCE_GT520
}, /* Geforce 500 - lowend */
1390 {"GTX 480", CARD_NVIDIA_GEFORCE_GTX480
}, /* Geforce 400 - highend */
1391 {"GTX 470", CARD_NVIDIA_GEFORCE_GTX470
}, /* Geforce 400 - midend high */
1393 {"GTX 465", CARD_NVIDIA_GEFORCE_GTX465
}, /* Geforce 400 - midend */
1394 {"GTX 460M", CARD_NVIDIA_GEFORCE_GTX460M
}, /* Geforce 400 - highend mobile */
1395 {"GTX 460", CARD_NVIDIA_GEFORCE_GTX460
}, /* Geforce 400 - midend */
1396 {"GTS 450", CARD_NVIDIA_GEFORCE_GTS450
}, /* Geforce 400 - midend low */
1397 {"GT 440", CARD_NVIDIA_GEFORCE_GT440
}, /* Geforce 400 - lowend */
1398 {"GT 430", CARD_NVIDIA_GEFORCE_GT430
}, /* Geforce 400 - lowend */
1399 {"GT 425M", CARD_NVIDIA_GEFORCE_GT425M
}, /* Geforce 400 - lowend mobile */
1400 {"GT 420", CARD_NVIDIA_GEFORCE_GT420
}, /* Geforce 400 - lowend */
1401 {"410M", CARD_NVIDIA_GEFORCE_410M
}, /* Geforce 400 - lowend mobile */
1402 {"GT 330", CARD_NVIDIA_GEFORCE_GT330
}, /* Geforce 300 - highend */
1403 {"GTS 360M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1404 {"GTS 350M", CARD_NVIDIA_GEFORCE_GTS350M
}, /* Geforce 300 - highend mobile */
1405 {"GT 330M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1406 {"GT 325M", CARD_NVIDIA_GEFORCE_GT325M
}, /* Geforce 300 - midend mobile */
1407 {"GT 320M", CARD_NVIDIA_GEFORCE_GT320M
}, /* Geforce 300 - midend mobile */
1408 {"320M", CARD_NVIDIA_GEFORCE_320M
}, /* Geforce 300 - midend mobile */
1409 {"315M", CARD_NVIDIA_GEFORCE_315M
}, /* Geforce 300 - midend mobile */
1410 {"GTX 295", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1411 {"GTX 285", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1412 {"GTX 280", CARD_NVIDIA_GEFORCE_GTX280
}, /* Geforce 200 - highend */
1413 {"GTX 275", CARD_NVIDIA_GEFORCE_GTX275
}, /* Geforce 200 - midend high */
1414 {"GTX 260", CARD_NVIDIA_GEFORCE_GTX260
}, /* Geforce 200 - midend */
1415 {"GTS 250", CARD_NVIDIA_GEFORCE_GTS250
}, /* Geforce 200 - midend */
1416 {"GT 240", CARD_NVIDIA_GEFORCE_GT240
}, /* Geforce 200 - midend */
1417 {"GT 220", CARD_NVIDIA_GEFORCE_GT220
}, /* Geforce 200 - lowend */
1418 {"GeForce 310", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1419 {"GeForce 305", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1420 {"GeForce 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1421 {"G 210", CARD_NVIDIA_GEFORCE_210
}, /* Geforce 200 - lowend */
1422 {"GTS 150", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1423 {"9800", CARD_NVIDIA_GEFORCE_9800GT
}, /* Geforce 9 - highend / Geforce 200 - midend */
1424 {"9700M GT", CARD_NVIDIA_GEFORCE_9700MGT
}, /* Geforce 9 - midend */
1425 {"GT 140", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1426 {"9600", CARD_NVIDIA_GEFORCE_9600GT
}, /* Geforce 9 - midend */
1427 {"GT 130", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1428 {"GT 120", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1429 {"9500", CARD_NVIDIA_GEFORCE_9500GT
}, /* Geforce 9 - midend low / Geforce 200 - low */
1430 {"9400M", CARD_NVIDIA_GEFORCE_9400M
}, /* Geforce 9 - lowend */
1431 {"9400", CARD_NVIDIA_GEFORCE_9400GT
}, /* Geforce 9 - lowend */
1432 {"9300", CARD_NVIDIA_GEFORCE_9300
}, /* Geforce 9 - lowend low */
1433 {"9200", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1434 {"9100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1435 {"G 100", CARD_NVIDIA_GEFORCE_9200
}, /* Geforce 9 - lowend low */
1436 {"8800 GTX", CARD_NVIDIA_GEFORCE_8800GTX
}, /* Geforce 8 - highend high */
1437 {"8800", CARD_NVIDIA_GEFORCE_8800GTS
}, /* Geforce 8 - highend */
1438 {"8600M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1439 {"8600 M", CARD_NVIDIA_GEFORCE_8600MGT
}, /* Geforce 8 - midend mobile */
1440 {"8700", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1441 {"8600", CARD_NVIDIA_GEFORCE_8600GT
}, /* Geforce 8 - midend */
1442 {"8500", CARD_NVIDIA_GEFORCE_8500GT
}, /* Geforce 8 - mid-lowend */
1443 {"8400", CARD_NVIDIA_GEFORCE_8400GS
}, /* Geforce 8 - mid-lowend */
1444 {"8300", CARD_NVIDIA_GEFORCE_8300GS
}, /* Geforce 8 - lowend */
1445 {"8200", CARD_NVIDIA_GEFORCE_8200
}, /* Geforce 8 - lowend */
1446 {"8100", CARD_NVIDIA_GEFORCE_8200
}, /* Geforce 8 - lowend */
1447 /* Direct 3D 9 SM3 */
1448 {"Quadro FX 5", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1449 {"Quadro FX 4", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1450 {"7950", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1451 {"7900", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1452 {"7800", CARD_NVIDIA_GEFORCE_7800GT
}, /* Geforce 7 - highend */
1453 {"7700", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1454 {"7600", CARD_NVIDIA_GEFORCE_7600
}, /* Geforce 7 - midend */
1455 {"7400", CARD_NVIDIA_GEFORCE_7400
}, /* Geforce 7 - lower medium */
1456 {"7300", CARD_NVIDIA_GEFORCE_7300
}, /* Geforce 7 - lowend */
1457 {"6800", CARD_NVIDIA_GEFORCE_6800
}, /* Geforce 6 - highend */
1458 {"6700", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1459 {"6610", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1460 {"6600", CARD_NVIDIA_GEFORCE_6600GT
}, /* Geforce 6 - midend */
1461 /* Direct 3D 9 SM2 */
1462 {"Quadro FX", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1463 {"5950", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1464 {"5900", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1465 {"5800", CARD_NVIDIA_GEFORCEFX_5800
}, /* GeforceFX - highend */
1466 {"5750", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1467 {"5700", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1468 {"5650", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1469 {"5600", CARD_NVIDIA_GEFORCEFX_5600
}, /* GeforceFX - midend */
1470 {"5500", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1471 {"5300", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1472 {"5250", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1473 {"5200", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1474 {"5100", CARD_NVIDIA_GEFORCEFX_5200
}, /* GeforceFX - lowend */
1476 {"Quadro4", CARD_NVIDIA_GEFORCE4_TI4200
},
1477 {"GeForce4 Ti", CARD_NVIDIA_GEFORCE4_TI4200
}, /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800 */
1479 {"GeForce4 MX", CARD_NVIDIA_GEFORCE4_MX
}, /* MX420/MX440/MX460/MX4000 */
1480 {"Quadro2 MXR", CARD_NVIDIA_GEFORCE2_MX
},
1481 {"GeForce2 MX", CARD_NVIDIA_GEFORCE2_MX
}, /* Geforce2 standard/MX100/MX200/MX400 */
1482 {"Quadro2", CARD_NVIDIA_GEFORCE2
},
1483 {"GeForce2", CARD_NVIDIA_GEFORCE2
}, /* Geforce2 GTS/Pro/Ti/Ultra */
1485 {"TNT2", CARD_NVIDIA_RIVA_TNT2
}, /* Riva TNT2 standard/M64/Pro/Ultra */
1487 /* See http://developer.amd.com/resources/hardware-drivers/ati-catalyst-pc-vendor-id-1002-li/
1489 * Beware: renderer string do not match exact card model,
1490 * e.g. HD 4800 is returned for multiple cards, even for RV790 based ones. */
1491 cards_amd_binary
[] =
1493 {"RX 480", CARD_AMD_RADEON_RX_480
},
1494 {"RX 460", CARD_AMD_RADEON_RX_460
},
1495 {"R9 Fury Series", CARD_AMD_RADEON_R9_FURY
},
1496 /* Southern Islands */
1497 {"HD 7900", CARD_AMD_RADEON_HD7900
},
1498 {"HD 7800", CARD_AMD_RADEON_HD7800
},
1499 {"HD 7700", CARD_AMD_RADEON_HD7700
},
1500 /* Northern Islands */
1501 {"HD 6970", CARD_AMD_RADEON_HD6900
},
1502 {"HD 6900", CARD_AMD_RADEON_HD6900
},
1503 {"HD 6800", CARD_AMD_RADEON_HD6800
},
1504 {"HD 6770M", CARD_AMD_RADEON_HD6600M
},
1505 {"HD 6750M", CARD_AMD_RADEON_HD6600M
},
1506 {"HD 6700", CARD_AMD_RADEON_HD6700
},
1507 {"HD 6670", CARD_AMD_RADEON_HD6600
},
1508 {"HD 6630M", CARD_AMD_RADEON_HD6600M
},
1509 {"HD 6600M", CARD_AMD_RADEON_HD6600M
},
1510 {"HD 6600", CARD_AMD_RADEON_HD6600
},
1511 {"HD 6570", CARD_AMD_RADEON_HD6600
},
1512 {"HD 6500M", CARD_AMD_RADEON_HD6600M
},
1513 {"HD 6500", CARD_AMD_RADEON_HD6600
},
1514 {"HD 6480G", CARD_AMD_RADEON_HD6480G
},
1515 {"HD 6400", CARD_AMD_RADEON_HD6400
},
1516 {"HD 6300", CARD_AMD_RADEON_HD6300
},
1517 {"HD 6200", CARD_AMD_RADEON_HD6300
},
1519 {"HD 5870", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS PRO */
1520 {"HD 5850", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS XT */
1521 {"HD 5800", CARD_AMD_RADEON_HD5800
}, /* Radeon EG CYPRESS HD58xx generic renderer string */
1522 {"HD 5770", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER XT */
1523 {"HD 5750", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER LE */
1524 {"HD 5700", CARD_AMD_RADEON_HD5700
}, /* Radeon EG JUNIPER HD57xx generic renderer string */
1525 {"HD 5670", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD XT */
1526 {"HD 5570", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD PRO mapped to HD5600 series */
1527 {"HD 5550", CARD_AMD_RADEON_HD5600
}, /* Radeon EG REDWOOD LE mapped to HD5600 series */
1528 {"HD 5450", CARD_AMD_RADEON_HD5400
}, /* Radeon EG CEDAR PRO */
1529 {"HD 5000", CARD_AMD_RADEON_HD5600
}, /* Defaulting to HD 5600 */
1531 {"HD 4890", CARD_AMD_RADEON_HD4800
}, /* Radeon RV790 */
1532 {"HD 4870", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1533 {"HD 4850", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1534 {"HD 4830", CARD_AMD_RADEON_HD4800
}, /* Radeon RV770 */
1535 {"HD 4800", CARD_AMD_RADEON_HD4800
}, /* Radeon RV7xx HD48xx generic renderer string */
1536 {"HD 4770", CARD_AMD_RADEON_HD4700
}, /* Radeon RV740 */
1537 {"HD 4700", CARD_AMD_RADEON_HD4700
}, /* Radeon RV7xx HD47xx generic renderer string */
1538 {"HD 4670", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1539 {"HD 4650", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1540 {"HD 4600", CARD_AMD_RADEON_HD4600
}, /* Radeon RV730 */
1541 {"HD 4550", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1542 {"HD 4350", CARD_AMD_RADEON_HD4350
}, /* Radeon RV710 */
1543 /* R600/R700 integrated */
1544 {"HD 4200M", CARD_AMD_RADEON_HD4200M
},
1545 {"HD 3300", CARD_AMD_RADEON_HD3200
},
1546 {"HD 3200", CARD_AMD_RADEON_HD3200
},
1547 {"HD 3100", CARD_AMD_RADEON_HD3200
},
1549 {"HD 3870", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1550 {"HD 3850", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1551 {"HD 2900", CARD_AMD_RADEON_HD2900
}, /* HD2900/HD3800 - highend */
1552 {"HD 3830", CARD_AMD_RADEON_HD2600
}, /* China-only midend */
1553 {"HD 3690", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1554 {"HD 3650", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1555 {"HD 2600", CARD_AMD_RADEON_HD2600
}, /* HD2600/HD3600 - midend */
1556 {"HD 3470", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1557 {"HD 3450", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1558 {"HD 3430", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1559 {"HD 3400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1560 {"HD 2400", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1561 {"HD 2350", CARD_AMD_RADEON_HD2350
}, /* HD2350/HD2400/HD3400 - lowend */
1563 {"X1950", CARD_AMD_RADEON_X1600
},
1564 {"X1900", CARD_AMD_RADEON_X1600
},
1565 {"X1800", CARD_AMD_RADEON_X1600
},
1566 {"X1650", CARD_AMD_RADEON_X1600
},
1567 {"X1600", CARD_AMD_RADEON_X1600
},
1568 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300/X2500/HD2300 (lowend R5xx)
1569 * Note X2300/X2500/HD2300 are R5xx GPUs with a 2xxx naming but they are still DX9-only */
1570 {"HD 2300", CARD_AMD_RADEON_X700
},
1571 {"X2500", CARD_AMD_RADEON_X700
},
1572 {"X2300", CARD_AMD_RADEON_X700
},
1573 {"X1550", CARD_AMD_RADEON_X700
},
1574 {"X1450", CARD_AMD_RADEON_X700
},
1575 {"X1400", CARD_AMD_RADEON_X700
},
1576 {"X1300", CARD_AMD_RADEON_X700
},
1577 {"X850", CARD_AMD_RADEON_X700
},
1578 {"X800", CARD_AMD_RADEON_X700
},
1579 {"X700", CARD_AMD_RADEON_X700
},
1580 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400 MHz */
1581 {"Radeon Xpress", CARD_AMD_RADEON_XPRESS_200M
},
1586 {"Iris Pro Graphics P580", CARD_INTEL_IPP580_1
},
1587 {"Skylake", CARD_INTEL_HD520_1
},
1589 {"Iris Pro P6300", CARD_INTEL_IPP6300
},
1590 {"Iris Pro 6200", CARD_INTEL_IP6200
},
1591 {"Iris 6100", CARD_INTEL_I6100
},
1592 {"Iris(TM) Graphics 6100", CARD_INTEL_I6100
}, /* MacOS */
1594 {"Iris Pro 5200", CARD_INTEL_IP5200_1
},
1595 {"Iris 5100", CARD_INTEL_I5100_1
},
1596 {"HD Graphics 5000", CARD_INTEL_HD5000_1
}, /* MacOS */
1597 {"Haswell Mobile", CARD_INTEL_HWM
},
1598 {"Iris OpenGL Engine", CARD_INTEL_HWM
}, /* MacOS */
1600 {"Ivybridge Server", CARD_INTEL_IVBS
},
1601 {"Ivybridge Mobile", CARD_INTEL_IVBM
},
1602 {"Ivybridge Desktop", CARD_INTEL_IVBD
},
1603 {"HD Graphics 4000", CARD_INTEL_IVBD
}, /* MacOS */
1605 {"Sandybridge Server", CARD_INTEL_SNBS
},
1606 {"Sandybridge Mobile", CARD_INTEL_SNBM
},
1607 {"Sandybridge Desktop", CARD_INTEL_SNBD
},
1609 {"Ironlake Mobile", CARD_INTEL_ILKM
},
1610 {"Ironlake Desktop", CARD_INTEL_ILKD
},
1612 {"B43", CARD_INTEL_B43
},
1613 {"G41", CARD_INTEL_G41
},
1614 {"G45", CARD_INTEL_G45
},
1615 {"Q45", CARD_INTEL_Q45
},
1616 {"Integrated Graphics Device", CARD_INTEL_IGD
},
1617 {"GM45", CARD_INTEL_GM45
},
1619 {"965GME", CARD_INTEL_965GME
},
1620 {"965GM", CARD_INTEL_965GM
},
1621 {"X3100", CARD_INTEL_965GM
}, /* MacOS */
1622 {"946GZ", CARD_INTEL_946GZ
},
1623 {"965G", CARD_INTEL_965G
},
1624 {"965Q", CARD_INTEL_965Q
},
1626 {"Pineview M", CARD_INTEL_PNVM
},
1627 {"Pineview G", CARD_INTEL_PNVG
},
1628 {"IGD", CARD_INTEL_PNVG
},
1629 {"Q33", CARD_INTEL_Q33
},
1630 {"G33", CARD_INTEL_G33
},
1631 {"Q35", CARD_INTEL_Q35
},
1632 {"945GME", CARD_INTEL_945GME
},
1633 {"945GM", CARD_INTEL_945GM
},
1634 {"GMA 950", CARD_INTEL_945GM
}, /* MacOS */
1635 {"945G", CARD_INTEL_945G
},
1637 {"915GM", CARD_INTEL_915GM
},
1638 {"E7221G", CARD_INTEL_E7221G
},
1639 {"915G", CARD_INTEL_915G
},
1641 {"865G", CARD_INTEL_865G
},
1642 {"845G", CARD_INTEL_845G
},
1643 {"855GM", CARD_INTEL_855GM
},
1644 {"830M", CARD_INTEL_830M
},
1646 /* 20101109 - These are never returned by current Gallium radeon
1647 * drivers: R700, RV790, R680, RV535, RV516, R410, RS485, RV360, RV351. */
1651 {"NAVI10", CARD_AMD_RADEON_RX_NAVI_10
},
1652 {"NAVI14", CARD_AMD_RADEON_RX_NAVI_14
},
1654 {"POLARIS10", CARD_AMD_RADEON_RX_480
},
1655 {"POLARIS11", CARD_AMD_RADEON_RX_460
},
1656 /* Volcanic Islands */
1657 {"FIJI", CARD_AMD_RADEON_R9_FURY
},
1658 {"TONGA", CARD_AMD_RADEON_R9_285
},
1660 {"HAWAII", CARD_AMD_RADEON_R9_290
},
1661 {"KAVERI", CARD_AMD_RADEON_R7
},
1662 {"KABINI", CARD_AMD_RADEON_R3
},
1663 {"BONAIRE", CARD_AMD_RADEON_HD8770
},
1664 /* Southern Islands */
1665 {"OLAND", CARD_AMD_RADEON_HD8670
},
1666 {"HAINAN", CARD_AMD_RADEON_HD8600M
},
1667 {"TAHITI", CARD_AMD_RADEON_HD7900
},
1668 {"PITCAIRN", CARD_AMD_RADEON_HD7800
},
1669 {"CAPE VERDE", CARD_AMD_RADEON_HD7700
},
1670 /* Northern Islands */
1671 {"ARUBA", CARD_AMD_RADEON_HD7660D
},
1672 {"CAYMAN", CARD_AMD_RADEON_HD6900
},
1673 {"BARTS", CARD_AMD_RADEON_HD6800
},
1674 {"TURKS", CARD_AMD_RADEON_HD6600
},
1675 {"SUMO2", CARD_AMD_RADEON_HD6410D
}, /* SUMO2 first, because we do a strstr(). */
1676 {"SUMO", CARD_AMD_RADEON_HD6550D
},
1677 {"CAICOS", CARD_AMD_RADEON_HD6400
},
1678 {"PALM", CARD_AMD_RADEON_HD6300
},
1680 {"HEMLOCK", CARD_AMD_RADEON_HD5900
},
1681 {"CYPRESS", CARD_AMD_RADEON_HD5800
},
1682 {"JUNIPER", CARD_AMD_RADEON_HD5700
},
1683 {"REDWOOD", CARD_AMD_RADEON_HD5600
},
1684 {"CEDAR", CARD_AMD_RADEON_HD5400
},
1686 {"R700", CARD_AMD_RADEON_HD4800
},
1687 {"RV790", CARD_AMD_RADEON_HD4800
},
1688 {"RV770", CARD_AMD_RADEON_HD4800
},
1689 {"RV740", CARD_AMD_RADEON_HD4700
},
1690 {"RV730", CARD_AMD_RADEON_HD4600
},
1691 {"RV710", CARD_AMD_RADEON_HD4350
},
1692 /* R600/R700 integrated */
1693 {"RS880", CARD_AMD_RADEON_HD4200M
},
1694 {"RS780", CARD_AMD_RADEON_HD3200
},
1696 {"R680", CARD_AMD_RADEON_HD2900
},
1697 {"R600", CARD_AMD_RADEON_HD2900
},
1698 {"RV670", CARD_AMD_RADEON_HD3850
},
1699 {"RV635", CARD_AMD_RADEON_HD2600
},
1700 {"RV630", CARD_AMD_RADEON_HD2600
},
1701 {"RV620", CARD_AMD_RADEON_HD2350
},
1702 {"RV610", CARD_AMD_RADEON_HD2350
},
1704 {"R580", CARD_AMD_RADEON_X1600
},
1705 {"R520", CARD_AMD_RADEON_X1600
},
1706 {"RV570", CARD_AMD_RADEON_X1600
},
1707 {"RV560", CARD_AMD_RADEON_X1600
},
1708 {"RV535", CARD_AMD_RADEON_X1600
},
1709 {"RV530", CARD_AMD_RADEON_X1600
},
1710 {"RV516", CARD_AMD_RADEON_X700
},
1711 {"RV515", CARD_AMD_RADEON_X700
},
1713 {"R481", CARD_AMD_RADEON_X700
},
1714 {"R480", CARD_AMD_RADEON_X700
},
1715 {"R430", CARD_AMD_RADEON_X700
},
1716 {"R423", CARD_AMD_RADEON_X700
},
1717 {"R420", CARD_AMD_RADEON_X700
},
1718 {"R410", CARD_AMD_RADEON_X700
},
1719 {"RV410", CARD_AMD_RADEON_X700
},
1720 /* Radeon Xpress - onboard, DX9b, Shader 2.0, 300-400 MHz */
1721 {"RS740", CARD_AMD_RADEON_XPRESS_200M
},
1722 {"RS690", CARD_AMD_RADEON_XPRESS_200M
},
1723 {"RS600", CARD_AMD_RADEON_XPRESS_200M
},
1724 {"RS485", CARD_AMD_RADEON_XPRESS_200M
},
1725 {"RS482", CARD_AMD_RADEON_XPRESS_200M
},
1726 {"RS480", CARD_AMD_RADEON_XPRESS_200M
},
1727 {"RS400", CARD_AMD_RADEON_XPRESS_200M
},
1728 {"RC410", CARD_AMD_RADEON_XPRESS_200M
},
1730 {"R360", CARD_AMD_RADEON_9500
},
1731 {"R350", CARD_AMD_RADEON_9500
},
1732 {"R300", CARD_AMD_RADEON_9500
},
1733 {"RV380", CARD_AMD_RADEON_9500
},
1734 {"RV370", CARD_AMD_RADEON_9500
},
1735 {"RV360", CARD_AMD_RADEON_9500
},
1736 {"RV351", CARD_AMD_RADEON_9500
},
1737 {"RV350", CARD_AMD_RADEON_9500
},
1739 cards_nvidia_mesa
[] =
1742 {"NV124", CARD_NVIDIA_GEFORCE_GTX970
},
1743 {"NV120", CARD_NVIDIA_GEFORCE_GTX980TI
},
1744 {"NV118", CARD_NVIDIA_GEFORCE_840M
},
1745 {"NV117", CARD_NVIDIA_GEFORCE_GTX750
},
1747 {"NV108", CARD_NVIDIA_GEFORCE_GT740M
},
1748 {"NV106", CARD_NVIDIA_GEFORCE_GT720
},
1749 {"NVF1", CARD_NVIDIA_GEFORCE_GTX780TI
},
1750 {"NVF0", CARD_NVIDIA_GEFORCE_GTX780
},
1751 {"NVE6", CARD_NVIDIA_GEFORCE_GTX770M
},
1752 {"NVE4", CARD_NVIDIA_GEFORCE_GTX680
}, /* 690 / 675MX / 760TI */
1754 {"NVD9", CARD_NVIDIA_GEFORCE_GT520
},
1755 {"NVD7", CARD_NVIDIA_GEFORCE_820M
},
1756 {"NVCF", CARD_NVIDIA_GEFORCE_GTX550
},
1757 {"NVCE", CARD_NVIDIA_GEFORCE_GTX560
},
1758 {"NVC8", CARD_NVIDIA_GEFORCE_GTX570
},
1759 {"NVC4", CARD_NVIDIA_GEFORCE_GTX460
},
1760 {"NVC3", CARD_NVIDIA_GEFORCE_GT440
},
1761 {"NVC1", CARD_NVIDIA_GEFORCE_GT420
},
1762 {"NVC0", CARD_NVIDIA_GEFORCE_GTX480
},
1764 {"NVAF", CARD_NVIDIA_GEFORCE_GT320M
},
1765 {"NVAC", CARD_NVIDIA_GEFORCE_8200
},
1766 {"NVAA", CARD_NVIDIA_GEFORCE_8200
}, /* 8100 */
1767 {"NVA8", CARD_NVIDIA_GEFORCE_210
},
1768 {"NVA5", CARD_NVIDIA_GEFORCE_GT220
},
1769 {"NVA3", CARD_NVIDIA_GEFORCE_GT240
},
1770 {"NVA0", CARD_NVIDIA_GEFORCE_GTX280
},
1771 {"NV98", CARD_NVIDIA_GEFORCE_9200
},
1772 {"NV96", CARD_NVIDIA_GEFORCE_9400GT
},
1773 {"NV94", CARD_NVIDIA_GEFORCE_9600GT
},
1774 {"NV92", CARD_NVIDIA_GEFORCE_9800GT
},
1775 {"NV86", CARD_NVIDIA_GEFORCE_8500GT
},
1776 {"NV84", CARD_NVIDIA_GEFORCE_8600GT
},
1777 {"NV50", CARD_NVIDIA_GEFORCE_8800GTX
},
1779 {"NV68", CARD_NVIDIA_GEFORCE_6200
}, /* 7050 */
1780 {"NV67", CARD_NVIDIA_GEFORCE_6200
}, /* 7000M */
1781 {"NV63", CARD_NVIDIA_GEFORCE_6200
}, /* 7100 */
1782 {"NV4E", CARD_NVIDIA_GEFORCE_6200
}, /* 6100 Go / 6150 Go */
1783 {"NV4C", CARD_NVIDIA_GEFORCE_6200
}, /* 6150SE */
1784 {"NV4B", CARD_NVIDIA_GEFORCE_7600
},
1785 {"NV4A", CARD_NVIDIA_GEFORCE_6200
},
1786 {"NV49", CARD_NVIDIA_GEFORCE_7800GT
}, /* 7900 */
1787 {"NV47", CARD_NVIDIA_GEFORCE_7800GT
},
1788 {"NV46", CARD_NVIDIA_GEFORCE_7400
},
1789 {"NV45", CARD_NVIDIA_GEFORCE_6800
},
1790 {"NV44", CARD_NVIDIA_GEFORCE_6200
},
1791 {"NV43", CARD_NVIDIA_GEFORCE_6600GT
},
1792 {"NV42", CARD_NVIDIA_GEFORCE_6800
},
1793 {"NV41", CARD_NVIDIA_GEFORCE_6800
},
1794 {"NV40", CARD_NVIDIA_GEFORCE_6800
},
1796 {"NV38", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5950 Ultra */
1797 {"NV36", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5700/5750 */
1798 {"NV35", CARD_NVIDIA_GEFORCEFX_5800
}, /* FX 5900 */
1799 {"NV34", CARD_NVIDIA_GEFORCEFX_5200
},
1800 {"NV31", CARD_NVIDIA_GEFORCEFX_5600
},
1801 {"NV30", CARD_NVIDIA_GEFORCEFX_5800
},
1803 {"nv28", CARD_NVIDIA_GEFORCE4_TI4200
},
1804 {"nv25", CARD_NVIDIA_GEFORCE4_TI4200
},
1805 {"nv20", CARD_NVIDIA_GEFORCE3
},
1807 {"nv1F", CARD_NVIDIA_GEFORCE4_MX
}, /* GF4 MX IGP */
1808 {"nv1A", CARD_NVIDIA_GEFORCE2
}, /* GF2 IGP */
1809 {"nv18", CARD_NVIDIA_GEFORCE4_MX
},
1810 {"nv17", CARD_NVIDIA_GEFORCE4_MX
},
1811 {"nv16", CARD_NVIDIA_GEFORCE2
},
1812 {"nv15", CARD_NVIDIA_GEFORCE2
},
1813 {"nv11", CARD_NVIDIA_GEFORCE2_MX
},
1814 {"nv10", CARD_NVIDIA_GEFORCE
},
1816 {"nv05", CARD_NVIDIA_RIVA_TNT2
},
1817 {"nv04", CARD_NVIDIA_RIVA_TNT
},
1818 {"nv03", CARD_NVIDIA_RIVA_128
},
1822 {"virgl", CARD_REDHAT_VIRGL
},
1826 {"SVGA3D", CARD_VMWARE_SVGA3D
},
1829 static const struct gl_vendor_selection
1831 enum wined3d_gl_vendor gl_vendor
;
1832 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
1833 const struct wined3d_renderer_table
*cards
; /* To be used as cards[], pointer to the first member in an array */
1834 size_t cards_size
; /* Number of entries in the array above */
1836 amd_gl_vendor_table
[] =
1838 {GL_VENDOR_APPLE
, "Apple OSX AMD/ATI binary driver", cards_amd_binary
, ARRAY_SIZE(cards_amd_binary
)},
1839 {GL_VENDOR_FGLRX
, "AMD/ATI binary driver", cards_amd_binary
, ARRAY_SIZE(cards_amd_binary
)},
1840 {GL_VENDOR_MESA
, "Mesa AMD/ATI driver", cards_amd_mesa
, ARRAY_SIZE(cards_amd_mesa
)},
1842 nvidia_gl_vendor_table
[] =
1844 {GL_VENDOR_APPLE
, "Apple OSX NVidia binary driver", cards_nvidia_binary
, ARRAY_SIZE(cards_nvidia_binary
)},
1845 {GL_VENDOR_MESA
, "Mesa Nouveau driver", cards_nvidia_mesa
, ARRAY_SIZE(cards_nvidia_mesa
)},
1846 {GL_VENDOR_NVIDIA
, "NVIDIA binary driver", cards_nvidia_binary
, ARRAY_SIZE(cards_nvidia_binary
)},
1848 redhat_gl_vendor_table
[] =
1850 {GL_VENDOR_MESA
, "Red Hat driver", cards_redhat
, ARRAY_SIZE(cards_redhat
)},
1852 vmware_gl_vendor_table
[] =
1854 {GL_VENDOR_MESA
, "VMware driver", cards_vmware
, ARRAY_SIZE(cards_vmware
)},
1856 intel_gl_vendor_table
[] =
1858 {GL_VENDOR_APPLE
, "Apple OSX Intel binary driver", cards_intel
, ARRAY_SIZE(cards_intel
)},
1859 {GL_VENDOR_MESA
, "Mesa Intel driver", cards_intel
, ARRAY_SIZE(cards_intel
)},
1862 static enum wined3d_pci_device
select_card_handler(const struct gl_vendor_selection
*table
,
1863 unsigned int table_size
, enum wined3d_gl_vendor gl_vendor
, const char *gl_renderer
)
1867 for (i
= 0; i
< table_size
; ++i
)
1869 if (table
[i
].gl_vendor
!= gl_vendor
)
1872 TRACE("Applying card selector \"%s\".\n", table
[i
].description
);
1874 for (j
= 0; j
< table
[i
].cards_size
; ++j
)
1876 if (strstr(gl_renderer
, table
[i
].cards
[j
].renderer
))
1877 return table
[i
].cards
[j
].id
;
1879 return PCI_DEVICE_NONE
;
1881 FIXME("Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
1882 gl_vendor
, debugstr_a(gl_renderer
));
1884 return PCI_DEVICE_NONE
;
1889 enum wined3d_pci_vendor card_vendor
;
1890 const char *description
; /* Description of the card selector i.e. Apple OS/X Intel */
1891 const struct gl_vendor_selection
*gl_vendor_selection
;
1892 unsigned int gl_vendor_count
;
1894 card_vendor_table
[] =
1896 {HW_VENDOR_AMD
, "AMD", amd_gl_vendor_table
, ARRAY_SIZE(amd_gl_vendor_table
)},
1897 {HW_VENDOR_NVIDIA
, "NVIDIA", nvidia_gl_vendor_table
, ARRAY_SIZE(nvidia_gl_vendor_table
)},
1898 {HW_VENDOR_REDHAT
, "Red Hat",redhat_gl_vendor_table
, ARRAY_SIZE(redhat_gl_vendor_table
)},
1899 {HW_VENDOR_VMWARE
, "VMware", vmware_gl_vendor_table
, ARRAY_SIZE(vmware_gl_vendor_table
)},
1900 {HW_VENDOR_INTEL
, "Intel", intel_gl_vendor_table
, ARRAY_SIZE(intel_gl_vendor_table
)},
1903 static enum wined3d_pci_device
wined3d_guess_card(enum wined3d_feature_level feature_level
,
1904 const char *gl_renderer
, enum wined3d_gl_vendor
*gl_vendor
,
1905 enum wined3d_pci_vendor
*card_vendor
)
1907 /* A Direct3D device object contains the PCI id (vendor + device) of the
1908 * videocard which is used for rendering. Various applications use this
1909 * information to get a rough estimation of the features of the card and
1910 * some might use it for enabling 3d effects only on certain types of
1911 * videocards. In some cases games might even use it to work around bugs
1912 * which happen on certain videocards/driver combinations. The problem is
1913 * that OpenGL only exposes a rendering string containing the name of the
1914 * videocard and not the PCI id.
1916 * Various games depend on the PCI id, so somehow we need to provide one.
1917 * A simple option is to parse the renderer string and translate this to
1918 * the right PCI id. This is a lot of work because there are more than 200
1919 * GPUs just for NVIDIA. Various cards share the same renderer string, so
1920 * the amount of code might be 'small' but there are quite a number of
1921 * exceptions which would make this a pain to maintain. Another way would
1922 * be to query the PCI id from the operating system (assuming this is the
1923 * videocard which is used for rendering which is not always the case).
1924 * This would work but it is not very portable. Second it would not work
1925 * well in, let's say, a remote X situation in which the amount of 3d
1926 * features which can be used is limited.
1928 * As said most games only use the PCI id to get an indication of the
1929 * capabilities of the card. It doesn't really matter if the given id is
1930 * the correct one if we return the id of a card with similar 3d features.
1932 * The code below checks the OpenGL capabilities of a videocard and matches
1933 * that to a certain level of Direct3D functionality. Once a card passes
1934 * the Direct3D9 check, we know that the card (in case of NVIDIA) is at
1935 * least a GeforceFX. To give a better estimate we do a basic check on the
1936 * renderer string but if that won't pass we return a default card. This
1937 * way is better than maintaining a full card database as even without a
1938 * full database we can return a card with similar features. Second the
1939 * size of the database can be made quite small because when you know what
1940 * type of 3d functionality a card has, you know to which GPU family the
1941 * GPU must belong. Because of this you only have to check a small part of
1942 * the renderer string to distinguish between different models from that
1945 * The code also selects a default amount of video memory which we will
1946 * use for an estimation of the amount of free texture memory. In case of
1947 * real D3D the amount of texture memory includes video memory and system
1948 * memory (to be specific AGP memory or in case of PCIE TurboCache /
1949 * HyperMemory). We don't know how much system memory can be addressed by
1950 * the system but we can make a reasonable estimation about the amount of
1951 * video memory. If the value is slightly wrong it doesn't matter as we
1952 * didn't include AGP-like memory which makes the amount of addressable
1953 * memory higher and second OpenGL isn't that critical it moves to system
1954 * memory behind our backs if really needed. Note that the amount of video
1955 * memory can be overruled using a registry setting. */
1957 enum wined3d_pci_device device
;
1960 for (i
= 0; i
< ARRAY_SIZE(card_vendor_table
); ++i
)
1962 if (card_vendor_table
[i
].card_vendor
!= *card_vendor
)
1965 TRACE("Applying card selector \"%s\".\n", card_vendor_table
[i
].description
);
1966 device
= select_card_handler(card_vendor_table
[i
].gl_vendor_selection
,
1967 card_vendor_table
[i
].gl_vendor_count
, *gl_vendor
, gl_renderer
);
1968 if (device
!= PCI_DEVICE_NONE
)
1971 TRACE("Unrecognized renderer %s, falling back to default.\n", debugstr_a(gl_renderer
));
1973 return wined3d_gpu_from_feature_level(card_vendor
, feature_level
);
1976 FIXME("No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
1977 *card_vendor
, debugstr_a(gl_renderer
));
1979 return wined3d_gpu_from_feature_level(card_vendor
, feature_level
);
1982 static const struct wined3d_vertex_pipe_ops
*select_vertex_implementation(const struct wined3d_gl_info
*gl_info
,
1983 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
1985 if (shader_backend_ops
== &glsl_shader_backend
&& gl_info
->supported
[ARB_VERTEX_SHADER
])
1986 return &glsl_vertex_pipe
;
1987 return &ffp_vertex_pipe
;
1990 static const struct wined3d_fragment_pipe_ops
*select_fragment_implementation(const struct wined3d_gl_info
*gl_info
,
1991 const struct wined3d_shader_backend_ops
*shader_backend_ops
)
1993 if (shader_backend_ops
== &glsl_shader_backend
&& gl_info
->supported
[ARB_FRAGMENT_SHADER
])
1994 return &glsl_fragment_pipe
;
1995 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
1996 return &arbfp_fragment_pipeline
;
1997 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
1998 return &atifs_fragment_pipeline
;
1999 if (gl_info
->supported
[NV_REGISTER_COMBINERS
] && gl_info
->supported
[NV_TEXTURE_SHADER2
])
2000 return &nvts_fragment_pipeline
;
2001 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2002 return &nvrc_fragment_pipeline
;
2003 return &ffp_fragment_pipeline
;
2006 static const struct wined3d_shader_backend_ops
*select_shader_backend(const struct wined3d_gl_info
*gl_info
)
2008 BOOL glsl
= wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_AUTO
2009 || wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_GLSL
;
2010 BOOL arb
= wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_AUTO
2011 || wined3d_settings
.shader_backend
== WINED3D_SHADER_BACKEND_ARB
;
2013 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
] && !glsl
)
2015 ERR_(winediag
)("Ignoring the shader backend registry key. "
2016 "GLSL is the only shader backend available on core profile contexts. "
2017 "You need to explicitly set GL version to use legacy contexts.\n");
2021 glsl
= glsl
&& gl_info
->glsl_version
>= MAKEDWORD_VERSION(1, 20);
2023 if (glsl
&& gl_info
->supported
[ARB_VERTEX_SHADER
] && gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2024 return &glsl_shader_backend
;
2025 if (arb
&& gl_info
->supported
[ARB_VERTEX_PROGRAM
] && gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2026 return &arb_program_shader_backend
;
2027 if (glsl
&& (gl_info
->supported
[ARB_VERTEX_SHADER
] || gl_info
->supported
[ARB_FRAGMENT_SHADER
]))
2028 return &glsl_shader_backend
;
2029 if (arb
&& (gl_info
->supported
[ARB_VERTEX_PROGRAM
] || gl_info
->supported
[ARB_FRAGMENT_PROGRAM
]))
2030 return &arb_program_shader_backend
;
2031 return &none_shader_backend
;
2034 static void parse_extension_string(struct wined3d_gl_info
*gl_info
, const char *extensions
,
2035 const struct wined3d_extension_map
*map
, UINT entry_count
)
2043 while (isspace(*extensions
))
2046 while (!isspace(*extensions
) && *extensions
)
2049 len
= extensions
- start
;
2053 TRACE("- %s.\n", debugstr_an(start
, len
));
2055 for (i
= 0; i
< entry_count
; ++i
)
2057 if (len
== strlen(map
[i
].extension_string
)
2058 && !memcmp(start
, map
[i
].extension_string
, len
))
2060 TRACE(" FOUND: %s support.\n", map
[i
].extension_string
);
2061 gl_info
->supported
[map
[i
].extension
] = TRUE
;
2068 static void enumerate_gl_extensions(struct wined3d_gl_info
*gl_info
,
2069 const struct wined3d_extension_map
*map
, unsigned int map_entries_count
)
2071 const char *gl_extension_name
;
2073 GLint extensions_count
;
2075 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_NUM_EXTENSIONS
, &extensions_count
);
2076 for (i
= 0; i
< extensions_count
; ++i
)
2078 gl_extension_name
= (const char *)GL_EXTCALL(glGetStringi(GL_EXTENSIONS
, i
));
2079 TRACE("- %s.\n", debugstr_a(gl_extension_name
));
2080 for (j
= 0; j
< map_entries_count
; ++j
)
2082 if (!strcmp(gl_extension_name
, map
[j
].extension_string
))
2084 TRACE("FOUND: %s support.\n", map
[j
].extension_string
);
2085 gl_info
->supported
[map
[j
].extension
] = TRUE
;
2092 static void load_gl_funcs(struct wined3d_gl_info
*gl_info
)
2094 #define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2095 /* GL_APPLE_fence */
2096 USE_GL_FUNC(glDeleteFencesAPPLE
)
2097 USE_GL_FUNC(glFinishFenceAPPLE
)
2098 USE_GL_FUNC(glFinishObjectAPPLE
)
2099 USE_GL_FUNC(glGenFencesAPPLE
)
2100 USE_GL_FUNC(glIsFenceAPPLE
)
2101 USE_GL_FUNC(glSetFenceAPPLE
)
2102 USE_GL_FUNC(glTestFenceAPPLE
)
2103 USE_GL_FUNC(glTestObjectAPPLE
)
2104 /* GL_APPLE_flush_buffer_range */
2105 USE_GL_FUNC(glBufferParameteriAPPLE
)
2106 USE_GL_FUNC(glFlushMappedBufferRangeAPPLE
)
2107 /* GL_ARB_base_instance */
2108 USE_GL_FUNC(glDrawArraysInstancedBaseInstance
)
2109 USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance
)
2110 /* GL_ARB_blend_func_extended */
2111 USE_GL_FUNC(glBindFragDataLocationIndexed
)
2112 USE_GL_FUNC(glGetFragDataIndex
)
2113 /* GL_ARB_buffer_storage */
2114 USE_GL_FUNC(glBufferStorage
)
2115 /* GL_ARB_clear_buffer_object */
2116 USE_GL_FUNC(glClearBufferData
)
2117 USE_GL_FUNC(glClearBufferSubData
)
2118 /* GL_ARB_clear_texture */
2119 USE_GL_FUNC(glClearTexImage
)
2120 USE_GL_FUNC(glClearTexSubImage
)
2121 /* GL_ARB_clip_control */
2122 USE_GL_FUNC(glClipControl
)
2123 /* GL_ARB_color_buffer_float */
2124 USE_GL_FUNC(glClampColorARB
)
2125 /* GL_ARB_compute_shader */
2126 USE_GL_FUNC(glDispatchCompute
)
2127 USE_GL_FUNC(glDispatchComputeIndirect
)
2128 /* GL_ARB_copy_buffer */
2129 USE_GL_FUNC(glCopyBufferSubData
)
2130 /* GL_ARB_copy_image */
2131 USE_GL_FUNC(glCopyImageSubData
)
2132 /* GL_ARB_debug_output */
2133 USE_GL_FUNC(glDebugMessageCallbackARB
)
2134 USE_GL_FUNC(glDebugMessageControlARB
)
2135 USE_GL_FUNC(glDebugMessageInsertARB
)
2136 USE_GL_FUNC(glGetDebugMessageLogARB
)
2137 /* GL_ARB_draw_buffers */
2138 USE_GL_FUNC(glDrawBuffersARB
)
2139 /* GL_ARB_draw_buffers_blend */
2140 USE_GL_FUNC(glBlendEquationiARB
)
2141 USE_GL_FUNC(glBlendEquationSeparateiARB
)
2142 USE_GL_FUNC(glBlendFunciARB
)
2143 USE_GL_FUNC(glBlendFuncSeparateiARB
)
2144 /* GL_ARB_draw_elements_base_vertex */
2145 USE_GL_FUNC(glDrawElementsBaseVertex
)
2146 USE_GL_FUNC(glDrawElementsInstancedBaseVertex
)
2147 USE_GL_FUNC(glDrawRangeElementsBaseVertex
)
2148 USE_GL_FUNC(glMultiDrawElementsBaseVertex
)
2149 /* GL_ARB_draw_indirect */
2150 USE_GL_FUNC(glDrawArraysIndirect
)
2151 USE_GL_FUNC(glDrawElementsIndirect
)
2152 /* GL_ARB_draw_instanced */
2153 USE_GL_FUNC(glDrawArraysInstancedARB
)
2154 USE_GL_FUNC(glDrawElementsInstancedARB
)
2155 /* GL_ARB_ES2_compatibility */
2156 USE_GL_FUNC(glReleaseShaderCompiler
)
2157 USE_GL_FUNC(glShaderBinary
)
2158 USE_GL_FUNC(glGetShaderPrecisionFormat
)
2159 USE_GL_FUNC(glDepthRangef
)
2160 USE_GL_FUNC(glClearDepthf
)
2161 /* GL_ARB_framebuffer_no_attachments */
2162 USE_GL_FUNC(glFramebufferParameteri
)
2163 /* GL_ARB_framebuffer_object */
2164 USE_GL_FUNC(glBindFramebuffer
)
2165 USE_GL_FUNC(glBindRenderbuffer
)
2166 USE_GL_FUNC(glBlitFramebuffer
)
2167 USE_GL_FUNC(glCheckFramebufferStatus
)
2168 USE_GL_FUNC(glDeleteFramebuffers
)
2169 USE_GL_FUNC(glDeleteRenderbuffers
)
2170 USE_GL_FUNC(glFramebufferRenderbuffer
)
2171 USE_GL_FUNC(glFramebufferTexture
)
2172 USE_GL_FUNC(glFramebufferTexture1D
)
2173 USE_GL_FUNC(glFramebufferTexture2D
)
2174 USE_GL_FUNC(glFramebufferTexture3D
)
2175 USE_GL_FUNC(glFramebufferTextureLayer
)
2176 USE_GL_FUNC(glGenFramebuffers
)
2177 USE_GL_FUNC(glGenRenderbuffers
)
2178 USE_GL_FUNC(glGenerateMipmap
)
2179 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv
)
2180 USE_GL_FUNC(glGetRenderbufferParameteriv
)
2181 USE_GL_FUNC(glIsFramebuffer
)
2182 USE_GL_FUNC(glIsRenderbuffer
)
2183 USE_GL_FUNC(glRenderbufferStorage
)
2184 USE_GL_FUNC(glRenderbufferStorageMultisample
)
2185 /* GL_ARB_geometry_shader4 */
2186 USE_GL_FUNC(glFramebufferTextureARB
)
2187 USE_GL_FUNC(glFramebufferTextureFaceARB
)
2188 USE_GL_FUNC(glFramebufferTextureLayerARB
)
2189 USE_GL_FUNC(glProgramParameteriARB
)
2190 /* GL_ARB_instanced_arrays */
2191 USE_GL_FUNC(glVertexAttribDivisorARB
)
2192 /* GL_ARB_internalformat_query */
2193 USE_GL_FUNC(glGetInternalformativ
)
2194 /* GL_ARB_internalformat_query2 */
2195 USE_GL_FUNC(glGetInternalformati64v
)
2196 /* GL_ARB_map_buffer_range */
2197 USE_GL_FUNC(glFlushMappedBufferRange
)
2198 USE_GL_FUNC(glMapBufferRange
)
2199 /* GL_ARB_multisample */
2200 USE_GL_FUNC(glSampleCoverageARB
)
2201 /* GL_ARB_multitexture */
2202 USE_GL_FUNC(glActiveTextureARB
)
2203 USE_GL_FUNC(glClientActiveTextureARB
)
2204 USE_GL_FUNC(glMultiTexCoord1fARB
)
2205 USE_GL_FUNC(glMultiTexCoord1fvARB
)
2206 USE_GL_FUNC(glMultiTexCoord2fARB
)
2207 USE_GL_FUNC(glMultiTexCoord2fvARB
)
2208 USE_GL_FUNC(glMultiTexCoord2svARB
)
2209 USE_GL_FUNC(glMultiTexCoord3fARB
)
2210 USE_GL_FUNC(glMultiTexCoord3fvARB
)
2211 USE_GL_FUNC(glMultiTexCoord4fARB
)
2212 USE_GL_FUNC(glMultiTexCoord4fvARB
)
2213 USE_GL_FUNC(glMultiTexCoord4svARB
)
2214 /* GL_ARB_occlusion_query */
2215 USE_GL_FUNC(glBeginQueryARB
)
2216 USE_GL_FUNC(glDeleteQueriesARB
)
2217 USE_GL_FUNC(glEndQueryARB
)
2218 USE_GL_FUNC(glGenQueriesARB
)
2219 USE_GL_FUNC(glGetQueryivARB
)
2220 USE_GL_FUNC(glGetQueryObjectivARB
)
2221 USE_GL_FUNC(glGetQueryObjectuivARB
)
2222 USE_GL_FUNC(glIsQueryARB
)
2223 /* GL_ARB_point_parameters */
2224 USE_GL_FUNC(glPointParameterfARB
)
2225 USE_GL_FUNC(glPointParameterfvARB
)
2226 /* GL_ARB_polgyon_offset_clamp */
2227 USE_GL_FUNC(glPolygonOffsetClamp
)
2228 /* GL_ARB_provoking_vertex */
2229 USE_GL_FUNC(glProvokingVertex
)
2230 /* GL_ARB_sample_shading */
2231 USE_GL_FUNC(glMinSampleShadingARB
)
2232 /* GL_ARB_sampler_objects */
2233 USE_GL_FUNC(glGenSamplers
)
2234 USE_GL_FUNC(glDeleteSamplers
)
2235 USE_GL_FUNC(glIsSampler
)
2236 USE_GL_FUNC(glBindSampler
)
2237 USE_GL_FUNC(glSamplerParameteri
)
2238 USE_GL_FUNC(glSamplerParameterf
)
2239 USE_GL_FUNC(glSamplerParameteriv
)
2240 USE_GL_FUNC(glSamplerParameterfv
)
2241 USE_GL_FUNC(glSamplerParameterIiv
)
2242 USE_GL_FUNC(glSamplerParameterIuiv
)
2243 USE_GL_FUNC(glGetSamplerParameteriv
)
2244 USE_GL_FUNC(glGetSamplerParameterfv
)
2245 USE_GL_FUNC(glGetSamplerParameterIiv
)
2246 USE_GL_FUNC(glGetSamplerParameterIuiv
)
2247 /* GL_ARB_shader_atomic_counters */
2248 USE_GL_FUNC(glGetActiveAtomicCounterBufferiv
)
2249 /* GL_ARB_shader_image_load_store */
2250 USE_GL_FUNC(glBindImageTexture
)
2251 USE_GL_FUNC(glMemoryBarrier
)
2252 /* GL_ARB_shader_objects */
2253 USE_GL_FUNC(glAttachObjectARB
)
2254 USE_GL_FUNC(glBindAttribLocationARB
)
2255 USE_GL_FUNC(glCompileShaderARB
)
2256 USE_GL_FUNC(glCreateProgramObjectARB
)
2257 USE_GL_FUNC(glCreateShaderObjectARB
)
2258 USE_GL_FUNC(glDeleteObjectARB
)
2259 USE_GL_FUNC(glDetachObjectARB
)
2260 USE_GL_FUNC(glGetActiveUniformARB
)
2261 USE_GL_FUNC(glGetAttachedObjectsARB
)
2262 USE_GL_FUNC(glGetAttribLocationARB
)
2263 USE_GL_FUNC(glGetHandleARB
)
2264 USE_GL_FUNC(glGetInfoLogARB
)
2265 USE_GL_FUNC(glGetObjectParameterfvARB
)
2266 USE_GL_FUNC(glGetObjectParameterivARB
)
2267 USE_GL_FUNC(glGetShaderSourceARB
)
2268 USE_GL_FUNC(glGetUniformLocationARB
)
2269 USE_GL_FUNC(glGetUniformfvARB
)
2270 USE_GL_FUNC(glGetUniformivARB
)
2271 USE_GL_FUNC(glLinkProgramARB
)
2272 USE_GL_FUNC(glShaderSourceARB
)
2273 USE_GL_FUNC(glUniform1fARB
)
2274 USE_GL_FUNC(glUniform1fvARB
)
2275 USE_GL_FUNC(glUniform1iARB
)
2276 USE_GL_FUNC(glUniform1ivARB
)
2277 USE_GL_FUNC(glUniform2fARB
)
2278 USE_GL_FUNC(glUniform2fvARB
)
2279 USE_GL_FUNC(glUniform2iARB
)
2280 USE_GL_FUNC(glUniform2ivARB
)
2281 USE_GL_FUNC(glUniform3fARB
)
2282 USE_GL_FUNC(glUniform3fvARB
)
2283 USE_GL_FUNC(glUniform3iARB
)
2284 USE_GL_FUNC(glUniform3ivARB
)
2285 USE_GL_FUNC(glUniform4fARB
)
2286 USE_GL_FUNC(glUniform4fvARB
)
2287 USE_GL_FUNC(glUniform4iARB
)
2288 USE_GL_FUNC(glUniform4ivARB
)
2289 USE_GL_FUNC(glUniformMatrix2fvARB
)
2290 USE_GL_FUNC(glUniformMatrix3fvARB
)
2291 USE_GL_FUNC(glUniformMatrix4fvARB
)
2292 USE_GL_FUNC(glUseProgramObjectARB
)
2293 USE_GL_FUNC(glValidateProgramARB
)
2294 /* GL_ARB_shader_storage_buffer_object */
2295 USE_GL_FUNC(glShaderStorageBlockBinding
)
2297 USE_GL_FUNC(glClientWaitSync
)
2298 USE_GL_FUNC(glDeleteSync
)
2299 USE_GL_FUNC(glFenceSync
)
2300 USE_GL_FUNC(glGetInteger64v
)
2301 USE_GL_FUNC(glGetSynciv
)
2302 USE_GL_FUNC(glIsSync
)
2303 USE_GL_FUNC(glWaitSync
)
2304 /* GL_ARB_tessellation_shader */
2305 USE_GL_FUNC(glPatchParameteri
)
2306 USE_GL_FUNC(glPatchParameterfv
)
2307 /* GL_ARB_texture_buffer_object */
2308 USE_GL_FUNC(glTexBufferARB
)
2309 /* GL_ARB_texture_buffer_range */
2310 USE_GL_FUNC(glTexBufferRange
)
2311 /* GL_ARB_texture_compression */
2312 USE_GL_FUNC(glCompressedTexImage2DARB
)
2313 USE_GL_FUNC(glCompressedTexImage3DARB
)
2314 USE_GL_FUNC(glCompressedTexSubImage2DARB
)
2315 USE_GL_FUNC(glCompressedTexSubImage3DARB
)
2316 USE_GL_FUNC(glGetCompressedTexImageARB
)
2317 /* GL_ARB_texture_multisample */
2318 USE_GL_FUNC(glGetMultisamplefv
);
2319 USE_GL_FUNC(glSampleMaski
);
2320 USE_GL_FUNC(glTexImage2DMultisample
);
2321 USE_GL_FUNC(glTexImage3DMultisample
);
2322 /* GL_ARB_texture_storage */
2323 USE_GL_FUNC(glTexStorage1D
)
2324 USE_GL_FUNC(glTexStorage2D
)
2325 USE_GL_FUNC(glTexStorage3D
)
2326 /* GL_ARB_texture_storage_multisample */
2327 USE_GL_FUNC(glTexStorage2DMultisample
);
2328 USE_GL_FUNC(glTexStorage3DMultisample
);
2329 /* GL_ARB_texture_view */
2330 USE_GL_FUNC(glTextureView
)
2331 /* GL_ARB_timer_query */
2332 USE_GL_FUNC(glQueryCounter
)
2333 USE_GL_FUNC(glGetQueryObjectui64v
)
2334 /* GL_ARB_transform_feedback2 */
2335 USE_GL_FUNC(glBindTransformFeedback
);
2336 USE_GL_FUNC(glDeleteTransformFeedbacks
);
2337 USE_GL_FUNC(glDrawTransformFeedback
);
2338 USE_GL_FUNC(glGenTransformFeedbacks
);
2339 USE_GL_FUNC(glIsTransformFeedback
);
2340 USE_GL_FUNC(glPauseTransformFeedback
);
2341 USE_GL_FUNC(glResumeTransformFeedback
);
2342 /* GL_ARB_transform_feedback3 */
2343 USE_GL_FUNC(glBeginQueryIndexed
);
2344 USE_GL_FUNC(glDrawTransformFeedbackStream
);
2345 USE_GL_FUNC(glEndQueryIndexed
);
2346 USE_GL_FUNC(glGetQueryIndexediv
);
2347 /* GL_ARB_uniform_buffer_object */
2348 USE_GL_FUNC(glBindBufferBase
)
2349 USE_GL_FUNC(glBindBufferRange
)
2350 USE_GL_FUNC(glGetActiveUniformBlockName
)
2351 USE_GL_FUNC(glGetActiveUniformBlockiv
)
2352 USE_GL_FUNC(glGetActiveUniformName
)
2353 USE_GL_FUNC(glGetActiveUniformsiv
)
2354 USE_GL_FUNC(glGetIntegeri_v
)
2355 USE_GL_FUNC(glGetUniformBlockIndex
)
2356 USE_GL_FUNC(glGetUniformIndices
)
2357 USE_GL_FUNC(glUniformBlockBinding
)
2358 /* GL_ARB_vertex_buffer_object */
2359 USE_GL_FUNC(glBindBufferARB
)
2360 USE_GL_FUNC(glBufferDataARB
)
2361 USE_GL_FUNC(glBufferSubDataARB
)
2362 USE_GL_FUNC(glDeleteBuffersARB
)
2363 USE_GL_FUNC(glGenBuffersARB
)
2364 USE_GL_FUNC(glGetBufferParameterivARB
)
2365 USE_GL_FUNC(glGetBufferPointervARB
)
2366 USE_GL_FUNC(glGetBufferSubDataARB
)
2367 USE_GL_FUNC(glIsBufferARB
)
2368 USE_GL_FUNC(glMapBufferARB
)
2369 USE_GL_FUNC(glUnmapBufferARB
)
2370 /* GL_ARB_vertex_program */
2371 USE_GL_FUNC(glBindProgramARB
)
2372 USE_GL_FUNC(glDeleteProgramsARB
)
2373 USE_GL_FUNC(glDisableVertexAttribArrayARB
)
2374 USE_GL_FUNC(glEnableVertexAttribArrayARB
)
2375 USE_GL_FUNC(glGenProgramsARB
)
2376 USE_GL_FUNC(glGetProgramivARB
)
2377 USE_GL_FUNC(glProgramEnvParameter4fvARB
)
2378 USE_GL_FUNC(glProgramLocalParameter4fvARB
)
2379 USE_GL_FUNC(glProgramStringARB
)
2380 USE_GL_FUNC(glVertexAttrib1dARB
)
2381 USE_GL_FUNC(glVertexAttrib1dvARB
)
2382 USE_GL_FUNC(glVertexAttrib1fARB
)
2383 USE_GL_FUNC(glVertexAttrib1fvARB
)
2384 USE_GL_FUNC(glVertexAttrib1sARB
)
2385 USE_GL_FUNC(glVertexAttrib1svARB
)
2386 USE_GL_FUNC(glVertexAttrib2dARB
)
2387 USE_GL_FUNC(glVertexAttrib2dvARB
)
2388 USE_GL_FUNC(glVertexAttrib2fARB
)
2389 USE_GL_FUNC(glVertexAttrib2fvARB
)
2390 USE_GL_FUNC(glVertexAttrib2sARB
)
2391 USE_GL_FUNC(glVertexAttrib2svARB
)
2392 USE_GL_FUNC(glVertexAttrib3dARB
)
2393 USE_GL_FUNC(glVertexAttrib3dvARB
)
2394 USE_GL_FUNC(glVertexAttrib3fARB
)
2395 USE_GL_FUNC(glVertexAttrib3fvARB
)
2396 USE_GL_FUNC(glVertexAttrib3sARB
)
2397 USE_GL_FUNC(glVertexAttrib3svARB
)
2398 USE_GL_FUNC(glVertexAttrib4NbvARB
)
2399 USE_GL_FUNC(glVertexAttrib4NivARB
)
2400 USE_GL_FUNC(glVertexAttrib4NsvARB
)
2401 USE_GL_FUNC(glVertexAttrib4NubARB
)
2402 USE_GL_FUNC(glVertexAttrib4NubvARB
)
2403 USE_GL_FUNC(glVertexAttrib4NuivARB
)
2404 USE_GL_FUNC(glVertexAttrib4NusvARB
)
2405 USE_GL_FUNC(glVertexAttrib4bvARB
)
2406 USE_GL_FUNC(glVertexAttrib4dARB
)
2407 USE_GL_FUNC(glVertexAttrib4dvARB
)
2408 USE_GL_FUNC(glVertexAttrib4fARB
)
2409 USE_GL_FUNC(glVertexAttrib4fvARB
)
2410 USE_GL_FUNC(glVertexAttrib4ivARB
)
2411 USE_GL_FUNC(glVertexAttrib4sARB
)
2412 USE_GL_FUNC(glVertexAttrib4svARB
)
2413 USE_GL_FUNC(glVertexAttrib4ubvARB
)
2414 USE_GL_FUNC(glVertexAttrib4uivARB
)
2415 USE_GL_FUNC(glVertexAttrib4usvARB
)
2416 USE_GL_FUNC(glVertexAttribPointerARB
)
2417 /* GL_ARB_viewport_array */
2418 USE_GL_FUNC(glDepthRangeArrayv
)
2419 USE_GL_FUNC(glDepthRangeIndexed
)
2420 USE_GL_FUNC(glGetDoublei_v
)
2421 USE_GL_FUNC(glGetFloati_v
)
2422 USE_GL_FUNC(glScissorArrayv
)
2423 USE_GL_FUNC(glScissorIndexed
)
2424 USE_GL_FUNC(glScissorIndexedv
)
2425 USE_GL_FUNC(glViewportArrayv
)
2426 USE_GL_FUNC(glViewportIndexedf
)
2427 USE_GL_FUNC(glViewportIndexedfv
)
2428 /* GL_ARB_texture_barrier */
2429 USE_GL_FUNC(glTextureBarrier
);
2430 /* GL_ATI_fragment_shader */
2431 USE_GL_FUNC(glAlphaFragmentOp1ATI
)
2432 USE_GL_FUNC(glAlphaFragmentOp2ATI
)
2433 USE_GL_FUNC(glAlphaFragmentOp3ATI
)
2434 USE_GL_FUNC(glBeginFragmentShaderATI
)
2435 USE_GL_FUNC(glBindFragmentShaderATI
)
2436 USE_GL_FUNC(glColorFragmentOp1ATI
)
2437 USE_GL_FUNC(glColorFragmentOp2ATI
)
2438 USE_GL_FUNC(glColorFragmentOp3ATI
)
2439 USE_GL_FUNC(glDeleteFragmentShaderATI
)
2440 USE_GL_FUNC(glEndFragmentShaderATI
)
2441 USE_GL_FUNC(glGenFragmentShadersATI
)
2442 USE_GL_FUNC(glPassTexCoordATI
)
2443 USE_GL_FUNC(glSampleMapATI
)
2444 USE_GL_FUNC(glSetFragmentShaderConstantATI
)
2445 /* GL_ATI_separate_stencil */
2446 USE_GL_FUNC(glStencilOpSeparateATI
)
2447 USE_GL_FUNC(glStencilFuncSeparateATI
)
2448 /* GL_EXT_blend_color */
2449 USE_GL_FUNC(glBlendColorEXT
)
2450 /* GL_EXT_blend_equation_separate */
2451 USE_GL_FUNC(glBlendFuncSeparateEXT
)
2452 /* GL_EXT_blend_func_separate */
2453 USE_GL_FUNC(glBlendEquationSeparateEXT
)
2454 /* GL_EXT_blend_minmax */
2455 USE_GL_FUNC(glBlendEquationEXT
)
2456 /* GL_EXT_depth_bounds_test */
2457 USE_GL_FUNC(glDepthBoundsEXT
)
2458 /* GL_EXT_draw_buffers2 */
2459 USE_GL_FUNC(glColorMaskIndexedEXT
)
2460 USE_GL_FUNC(glDisableIndexedEXT
)
2461 USE_GL_FUNC(glEnableIndexedEXT
)
2462 USE_GL_FUNC(glGetBooleanIndexedvEXT
)
2463 USE_GL_FUNC(glGetIntegerIndexedvEXT
)
2464 USE_GL_FUNC(glIsEnabledIndexedEXT
)
2465 /* GL_EXT_fog_coord */
2466 USE_GL_FUNC(glFogCoordPointerEXT
)
2467 USE_GL_FUNC(glFogCoorddEXT
)
2468 USE_GL_FUNC(glFogCoorddvEXT
)
2469 USE_GL_FUNC(glFogCoordfEXT
)
2470 USE_GL_FUNC(glFogCoordfvEXT
)
2471 /* GL_EXT_framebuffer_blit */
2472 USE_GL_FUNC(glBlitFramebufferEXT
)
2473 /* GL_EXT_framebuffer_multisample */
2474 USE_GL_FUNC(glRenderbufferStorageMultisampleEXT
)
2475 /* GL_EXT_framebuffer_object */
2476 USE_GL_FUNC(glBindFramebufferEXT
)
2477 USE_GL_FUNC(glBindRenderbufferEXT
)
2478 USE_GL_FUNC(glCheckFramebufferStatusEXT
)
2479 USE_GL_FUNC(glDeleteFramebuffersEXT
)
2480 USE_GL_FUNC(glDeleteRenderbuffersEXT
)
2481 USE_GL_FUNC(glFramebufferRenderbufferEXT
)
2482 USE_GL_FUNC(glFramebufferTexture1DEXT
)
2483 USE_GL_FUNC(glFramebufferTexture2DEXT
)
2484 USE_GL_FUNC(glFramebufferTexture3DEXT
)
2485 USE_GL_FUNC(glGenFramebuffersEXT
)
2486 USE_GL_FUNC(glGenRenderbuffersEXT
)
2487 USE_GL_FUNC(glGenerateMipmapEXT
)
2488 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT
)
2489 USE_GL_FUNC(glGetRenderbufferParameterivEXT
)
2490 USE_GL_FUNC(glIsFramebufferEXT
)
2491 USE_GL_FUNC(glIsRenderbufferEXT
)
2492 USE_GL_FUNC(glRenderbufferStorageEXT
)
2493 /* GL_EXT_gpu_program_parameters */
2494 USE_GL_FUNC(glProgramEnvParameters4fvEXT
)
2495 USE_GL_FUNC(glProgramLocalParameters4fvEXT
)
2496 /* GL_EXT_gpu_shader4 */
2497 USE_GL_FUNC(glBindFragDataLocationEXT
)
2498 USE_GL_FUNC(glGetFragDataLocationEXT
)
2499 USE_GL_FUNC(glGetUniformuivEXT
)
2500 USE_GL_FUNC(glGetVertexAttribIivEXT
)
2501 USE_GL_FUNC(glGetVertexAttribIuivEXT
)
2502 USE_GL_FUNC(glUniform1uiEXT
)
2503 USE_GL_FUNC(glUniform1uivEXT
)
2504 USE_GL_FUNC(glUniform2uiEXT
)
2505 USE_GL_FUNC(glUniform2uivEXT
)
2506 USE_GL_FUNC(glUniform3uiEXT
)
2507 USE_GL_FUNC(glUniform3uivEXT
)
2508 USE_GL_FUNC(glUniform4uiEXT
)
2509 USE_GL_FUNC(glUniform4uivEXT
)
2510 USE_GL_FUNC(glVertexAttribI1iEXT
)
2511 USE_GL_FUNC(glVertexAttribI1ivEXT
)
2512 USE_GL_FUNC(glVertexAttribI1uiEXT
)
2513 USE_GL_FUNC(glVertexAttribI1uivEXT
)
2514 USE_GL_FUNC(glVertexAttribI2iEXT
)
2515 USE_GL_FUNC(glVertexAttribI2ivEXT
)
2516 USE_GL_FUNC(glVertexAttribI2uiEXT
)
2517 USE_GL_FUNC(glVertexAttribI2uivEXT
)
2518 USE_GL_FUNC(glVertexAttribI3iEXT
)
2519 USE_GL_FUNC(glVertexAttribI3ivEXT
)
2520 USE_GL_FUNC(glVertexAttribI3uiEXT
)
2521 USE_GL_FUNC(glVertexAttribI3uivEXT
)
2522 USE_GL_FUNC(glVertexAttribI4bvEXT
)
2523 USE_GL_FUNC(glVertexAttribI4iEXT
)
2524 USE_GL_FUNC(glVertexAttribI4ivEXT
)
2525 USE_GL_FUNC(glVertexAttribI4svEXT
)
2526 USE_GL_FUNC(glVertexAttribI4ubvEXT
)
2527 USE_GL_FUNC(glVertexAttribI4uiEXT
)
2528 USE_GL_FUNC(glVertexAttribI4uivEXT
)
2529 USE_GL_FUNC(glVertexAttribI4usvEXT
)
2530 USE_GL_FUNC(glVertexAttribIPointerEXT
)
2531 /* GL_EXT_memory_object */
2532 USE_GL_FUNC(glGetUnsignedBytei_vEXT
)
2533 USE_GL_FUNC(glGetUnsignedBytevEXT
)
2534 /* GL_EXT_point_parameters */
2535 USE_GL_FUNC(glPointParameterfEXT
)
2536 USE_GL_FUNC(glPointParameterfvEXT
)
2537 /* GL_EXT_polgyon_offset_clamp */
2538 USE_GL_FUNC(glPolygonOffsetClampEXT
)
2539 /* GL_EXT_provoking_vertex */
2540 USE_GL_FUNC(glProvokingVertexEXT
)
2541 /* GL_EXT_secondary_color */
2542 USE_GL_FUNC(glSecondaryColor3fEXT
)
2543 USE_GL_FUNC(glSecondaryColor3fvEXT
)
2544 USE_GL_FUNC(glSecondaryColor3ubEXT
)
2545 USE_GL_FUNC(glSecondaryColor3ubvEXT
)
2546 USE_GL_FUNC(glSecondaryColorPointerEXT
)
2547 /* GL_EXT_stencil_two_side */
2548 USE_GL_FUNC(glActiveStencilFaceEXT
)
2549 /* GL_EXT_texture3D */
2550 USE_GL_FUNC(glTexImage3D
)
2551 USE_GL_FUNC(glTexImage3DEXT
)
2552 USE_GL_FUNC(glTexSubImage3D
)
2553 USE_GL_FUNC(glTexSubImage3DEXT
)
2555 USE_GL_FUNC(glDeleteFencesNV
)
2556 USE_GL_FUNC(glFinishFenceNV
)
2557 USE_GL_FUNC(glGenFencesNV
)
2558 USE_GL_FUNC(glGetFenceivNV
)
2559 USE_GL_FUNC(glIsFenceNV
)
2560 USE_GL_FUNC(glSetFenceNV
)
2561 USE_GL_FUNC(glTestFenceNV
)
2562 /* GL_NV_half_float */
2563 USE_GL_FUNC(glColor3hNV
)
2564 USE_GL_FUNC(glColor3hvNV
)
2565 USE_GL_FUNC(glColor4hNV
)
2566 USE_GL_FUNC(glColor4hvNV
)
2567 USE_GL_FUNC(glFogCoordhNV
)
2568 USE_GL_FUNC(glFogCoordhvNV
)
2569 USE_GL_FUNC(glMultiTexCoord1hNV
)
2570 USE_GL_FUNC(glMultiTexCoord1hvNV
)
2571 USE_GL_FUNC(glMultiTexCoord2hNV
)
2572 USE_GL_FUNC(glMultiTexCoord2hvNV
)
2573 USE_GL_FUNC(glMultiTexCoord3hNV
)
2574 USE_GL_FUNC(glMultiTexCoord3hvNV
)
2575 USE_GL_FUNC(glMultiTexCoord4hNV
)
2576 USE_GL_FUNC(glMultiTexCoord4hvNV
)
2577 USE_GL_FUNC(glNormal3hNV
)
2578 USE_GL_FUNC(glNormal3hvNV
)
2579 USE_GL_FUNC(glSecondaryColor3hNV
)
2580 USE_GL_FUNC(glSecondaryColor3hvNV
)
2581 USE_GL_FUNC(glTexCoord1hNV
)
2582 USE_GL_FUNC(glTexCoord1hvNV
)
2583 USE_GL_FUNC(glTexCoord2hNV
)
2584 USE_GL_FUNC(glTexCoord2hvNV
)
2585 USE_GL_FUNC(glTexCoord3hNV
)
2586 USE_GL_FUNC(glTexCoord3hvNV
)
2587 USE_GL_FUNC(glTexCoord4hNV
)
2588 USE_GL_FUNC(glTexCoord4hvNV
)
2589 USE_GL_FUNC(glVertex2hNV
)
2590 USE_GL_FUNC(glVertex2hvNV
)
2591 USE_GL_FUNC(glVertex3hNV
)
2592 USE_GL_FUNC(glVertex3hvNV
)
2593 USE_GL_FUNC(glVertex4hNV
)
2594 USE_GL_FUNC(glVertex4hvNV
)
2595 USE_GL_FUNC(glVertexAttrib1hNV
)
2596 USE_GL_FUNC(glVertexAttrib1hvNV
)
2597 USE_GL_FUNC(glVertexAttrib2hNV
)
2598 USE_GL_FUNC(glVertexAttrib2hvNV
)
2599 USE_GL_FUNC(glVertexAttrib3hNV
)
2600 USE_GL_FUNC(glVertexAttrib3hvNV
)
2601 USE_GL_FUNC(glVertexAttrib4hNV
)
2602 USE_GL_FUNC(glVertexAttrib4hvNV
)
2603 USE_GL_FUNC(glVertexAttribs1hvNV
)
2604 USE_GL_FUNC(glVertexAttribs2hvNV
)
2605 USE_GL_FUNC(glVertexAttribs3hvNV
)
2606 USE_GL_FUNC(glVertexAttribs4hvNV
)
2607 USE_GL_FUNC(glVertexWeighthNV
)
2608 USE_GL_FUNC(glVertexWeighthvNV
)
2609 /* GL_NV_point_sprite */
2610 USE_GL_FUNC(glPointParameteriNV
)
2611 USE_GL_FUNC(glPointParameterivNV
)
2612 /* GL_NV_register_combiners */
2613 USE_GL_FUNC(glCombinerInputNV
)
2614 USE_GL_FUNC(glCombinerOutputNV
)
2615 USE_GL_FUNC(glCombinerParameterfNV
)
2616 USE_GL_FUNC(glCombinerParameterfvNV
)
2617 USE_GL_FUNC(glCombinerParameteriNV
)
2618 USE_GL_FUNC(glCombinerParameterivNV
)
2619 USE_GL_FUNC(glFinalCombinerInputNV
)
2620 /* GL_NV_texture_barrier */
2621 USE_GL_FUNC(glTextureBarrierNV
);
2622 /* WGL extensions */
2623 USE_GL_FUNC(wglChoosePixelFormatARB
)
2624 USE_GL_FUNC(wglGetExtensionsStringARB
)
2625 USE_GL_FUNC(wglGetPixelFormatAttribfvARB
)
2626 USE_GL_FUNC(wglGetPixelFormatAttribivARB
)
2627 USE_GL_FUNC(wglQueryCurrentRendererIntegerWINE
)
2628 USE_GL_FUNC(wglQueryCurrentRendererStringWINE
)
2629 USE_GL_FUNC(wglQueryRendererIntegerWINE
)
2630 USE_GL_FUNC(wglQueryRendererStringWINE
)
2631 USE_GL_FUNC(wglSetPixelFormatWINE
)
2632 USE_GL_FUNC(wglSwapIntervalEXT
)
2634 /* Newer core functions */
2635 USE_GL_FUNC(glActiveTexture
) /* OpenGL 1.3 */
2636 USE_GL_FUNC(glAttachShader
) /* OpenGL 2.0 */
2637 USE_GL_FUNC(glBeginQuery
) /* OpenGL 1.5 */
2638 USE_GL_FUNC(glBeginTransformFeedback
) /* OpenGL 3.0 */
2639 USE_GL_FUNC(glBindAttribLocation
) /* OpenGL 2.0 */
2640 USE_GL_FUNC(glBindBuffer
) /* OpenGL 1.5 */
2641 USE_GL_FUNC(glBindFragDataLocation
) /* OpenGL 3.0 */
2642 USE_GL_FUNC(glBindVertexArray
) /* OpenGL 3.0 */
2643 USE_GL_FUNC(glBlendColor
) /* OpenGL 1.4 */
2644 USE_GL_FUNC(glBlendEquation
) /* OpenGL 1.4 */
2645 USE_GL_FUNC(glBlendEquationi
) /* OpenGL 4.0 */
2646 USE_GL_FUNC(glBlendEquationSeparate
) /* OpenGL 2.0 */
2647 USE_GL_FUNC(glBlendEquationSeparatei
) /* OpenGL 4.0 */
2648 USE_GL_FUNC(glBlendFunci
) /* OpenGL 4.0 */
2649 USE_GL_FUNC(glBlendFuncSeparate
) /* OpenGL 1.4 */
2650 USE_GL_FUNC(glBlendFuncSeparatei
) /* OpenGL 4.0 */
2651 USE_GL_FUNC(glBufferData
) /* OpenGL 1.5 */
2652 USE_GL_FUNC(glBufferSubData
) /* OpenGL 1.5 */
2653 USE_GL_FUNC(glColorMaski
) /* OpenGL 3.0 */
2654 USE_GL_FUNC(glCompileShader
) /* OpenGL 2.0 */
2655 USE_GL_FUNC(glCompressedTexImage2D
) /* OpenGL 1.3 */
2656 USE_GL_FUNC(glCompressedTexImage3D
) /* OpenGL 1.3 */
2657 USE_GL_FUNC(glCompressedTexSubImage2D
) /* OpenGL 1.3 */
2658 USE_GL_FUNC(glCompressedTexSubImage3D
) /* OpenGL 1.3 */
2659 USE_GL_FUNC(glCreateProgram
) /* OpenGL 2.0 */
2660 USE_GL_FUNC(glCreateShader
) /* OpenGL 2.0 */
2661 USE_GL_FUNC(glDebugMessageCallback
) /* OpenGL 4.3 */
2662 USE_GL_FUNC(glDebugMessageControl
) /* OpenGL 4.3 */
2663 USE_GL_FUNC(glDebugMessageInsert
) /* OpenGL 4.3 */
2664 USE_GL_FUNC(glDeleteBuffers
) /* OpenGL 1.5 */
2665 USE_GL_FUNC(glDeleteProgram
) /* OpenGL 2.0 */
2666 USE_GL_FUNC(glDeleteQueries
) /* OpenGL 1.5 */
2667 USE_GL_FUNC(glDeleteShader
) /* OpenGL 2.0 */
2668 USE_GL_FUNC(glDeleteVertexArrays
) /* OpenGL 3.0 */
2669 USE_GL_FUNC(glDetachShader
) /* OpenGL 2.0 */
2670 USE_GL_FUNC(glDisablei
) /* OpenGL 3.0 */
2671 USE_GL_FUNC(glDisableVertexAttribArray
) /* OpenGL 2.0 */
2672 USE_GL_FUNC(glDrawArraysInstanced
) /* OpenGL 3.1 */
2673 USE_GL_FUNC(glDrawBuffers
) /* OpenGL 2.0 */
2674 USE_GL_FUNC(glDrawElementsInstanced
) /* OpenGL 3.1 */
2675 USE_GL_FUNC(glEnablei
) /* OpenGL 3.0 */
2676 USE_GL_FUNC(glEnableVertexAttribArray
) /* OpenGL 2.0 */
2677 USE_GL_FUNC(glEndQuery
) /* OpenGL 1.5 */
2678 USE_GL_FUNC(glEndTransformFeedback
) /* OpenGL 3.0 */
2679 USE_GL_FUNC(glFramebufferTexture
) /* OpenGL 3.2 */
2680 USE_GL_FUNC(glGenBuffers
) /* OpenGL 1.5 */
2681 USE_GL_FUNC(glGenQueries
) /* OpenGL 1.5 */
2682 USE_GL_FUNC(glGenVertexArrays
) /* OpenGL 3.0 */
2683 USE_GL_FUNC(glGetActiveUniform
) /* OpenGL 2.0 */
2684 USE_GL_FUNC(glGetAttachedShaders
) /* OpenGL 2.0 */
2685 USE_GL_FUNC(glGetAttribLocation
) /* OpenGL 2.0 */
2686 USE_GL_FUNC(glGetBooleani_v
) /* OpenGL 3.0 */
2687 USE_GL_FUNC(glGetBufferSubData
) /* OpenGL 1.5 */
2688 USE_GL_FUNC(glGetCompressedTexImage
) /* OpenGL 1.3 */
2689 USE_GL_FUNC(glGetDebugMessageLog
) /* OpenGL 4.3 */
2690 USE_GL_FUNC(glGetIntegeri_v
) /* OpenGL 3.0 */
2691 USE_GL_FUNC(glGetProgramInfoLog
) /* OpenGL 2.0 */
2692 USE_GL_FUNC(glGetProgramiv
) /* OpenGL 2.0 */
2693 USE_GL_FUNC(glGetQueryiv
) /* OpenGL 1.5 */
2694 USE_GL_FUNC(glGetQueryObjectuiv
) /* OpenGL 1.5 */
2695 USE_GL_FUNC(glGetShaderInfoLog
) /* OpenGL 2.0 */
2696 USE_GL_FUNC(glGetShaderiv
) /* OpenGL 2.0 */
2697 USE_GL_FUNC(glGetShaderSource
) /* OpenGL 2.0 */
2698 USE_GL_FUNC(glGetStringi
) /* OpenGL 3.0 */
2699 USE_GL_FUNC(glGetTextureLevelParameteriv
) /* OpenGL 4.5 */
2700 USE_GL_FUNC(glGetTextureParameteriv
) /* OpenGL 4.5 */
2701 USE_GL_FUNC(glGetUniformfv
) /* OpenGL 2.0 */
2702 USE_GL_FUNC(glGetUniformiv
) /* OpenGL 2.0 */
2703 USE_GL_FUNC(glGetUniformLocation
) /* OpenGL 2.0 */
2704 USE_GL_FUNC(glIsEnabledi
) /* OpenGL 3.0 */
2705 USE_GL_FUNC(glLinkProgram
) /* OpenGL 2.0 */
2706 USE_GL_FUNC(glMapBuffer
) /* OpenGL 1.5 */
2707 USE_GL_FUNC(glMinSampleShading
) /* OpenGL 4.0 */
2708 USE_GL_FUNC(glPointParameteri
) /* OpenGL 1.4 */
2709 USE_GL_FUNC(glPointParameteriv
) /* OpenGL 1.4 */
2710 USE_GL_FUNC(glShaderSource
) /* OpenGL 2.0 */
2711 USE_GL_FUNC(glStencilFuncSeparate
) /* OpenGL 2.0 */
2712 USE_GL_FUNC(glStencilOpSeparate
) /* OpenGL 2.0 */
2713 USE_GL_FUNC(glTexBuffer
) /* OpenGL 3.1 */
2714 USE_GL_FUNC(glTexImage3D
) /* OpenGL 1.2 */
2715 USE_GL_FUNC(glTexSubImage3D
) /* OpenGL 1.2 */
2716 USE_GL_FUNC(glTransformFeedbackVaryings
) /* OpenGL 3.0 */
2717 USE_GL_FUNC(glUniform1f
) /* OpenGL 2.0 */
2718 USE_GL_FUNC(glUniform1fv
) /* OpenGL 2.0 */
2719 USE_GL_FUNC(glUniform1i
) /* OpenGL 2.0 */
2720 USE_GL_FUNC(glUniform1iv
) /* OpenGL 2.0 */
2721 USE_GL_FUNC(glUniform2f
) /* OpenGL 2.0 */
2722 USE_GL_FUNC(glUniform2fv
) /* OpenGL 2.0 */
2723 USE_GL_FUNC(glUniform2i
) /* OpenGL 2.0 */
2724 USE_GL_FUNC(glUniform2iv
) /* OpenGL 2.0 */
2725 USE_GL_FUNC(glUniform3f
) /* OpenGL 2.0 */
2726 USE_GL_FUNC(glUniform3fv
) /* OpenGL 2.0 */
2727 USE_GL_FUNC(glUniform3i
) /* OpenGL 2.0 */
2728 USE_GL_FUNC(glUniform3iv
) /* OpenGL 2.0 */
2729 USE_GL_FUNC(glUniform4f
) /* OpenGL 2.0 */
2730 USE_GL_FUNC(glUniform4fv
) /* OpenGL 2.0 */
2731 USE_GL_FUNC(glUniform4i
) /* OpenGL 2.0 */
2732 USE_GL_FUNC(glUniform4iv
) /* OpenGL 2.0 */
2733 USE_GL_FUNC(glUniformMatrix2fv
) /* OpenGL 2.0 */
2734 USE_GL_FUNC(glUniformMatrix3fv
) /* OpenGL 2.0 */
2735 USE_GL_FUNC(glUniformMatrix4fv
) /* OpenGL 2.0 */
2736 USE_GL_FUNC(glUnmapBuffer
) /* OpenGL 1.5 */
2737 USE_GL_FUNC(glUseProgram
) /* OpenGL 2.0 */
2738 USE_GL_FUNC(glValidateProgram
) /* OpenGL 2.0 */
2739 USE_GL_FUNC(glVertexAttrib1f
) /* OpenGL 2.0 */
2740 USE_GL_FUNC(glVertexAttrib1fv
) /* OpenGL 2.0 */
2741 USE_GL_FUNC(glVertexAttrib2f
) /* OpenGL 2.0 */
2742 USE_GL_FUNC(glVertexAttrib2fv
) /* OpenGL 2.0 */
2743 USE_GL_FUNC(glVertexAttrib3f
) /* OpenGL 2.0 */
2744 USE_GL_FUNC(glVertexAttrib3fv
) /* OpenGL 2.0 */
2745 USE_GL_FUNC(glVertexAttrib4f
) /* OpenGL 2.0 */
2746 USE_GL_FUNC(glVertexAttrib4fv
) /* OpenGL 2.0 */
2747 USE_GL_FUNC(glVertexAttrib4Nsv
) /* OpenGL 2.0 */
2748 USE_GL_FUNC(glVertexAttrib4Nub
) /* OpenGL 2.0 */
2749 USE_GL_FUNC(glVertexAttrib4Nubv
) /* OpenGL 2.0 */
2750 USE_GL_FUNC(glVertexAttrib4Nusv
) /* OpenGL 2.0 */
2751 USE_GL_FUNC(glVertexAttrib4sv
) /* OpenGL 2.0 */
2752 USE_GL_FUNC(glVertexAttrib4ubv
) /* OpenGL 2.0 */
2753 USE_GL_FUNC(glVertexAttribDivisor
) /* OpenGL 3.3 */
2754 USE_GL_FUNC(glVertexAttribIPointer
) /* OpenGL 3.0 */
2755 USE_GL_FUNC(glVertexAttribPointer
) /* OpenGL 2.0 */
2758 #ifndef USE_WIN32_OPENGL
2759 /* hack: use the functions directly from the TEB table to bypass the thunks */
2760 /* note that we still need the above wglGetProcAddress calls to initialize the table */
2761 gl_info
->gl_ops
.ext
= ((struct opengl_funcs
*)NtCurrentTeb()->glTable
)->ext
;
2764 #define MAP_GL_FUNCTION(core_func, ext_func) \
2767 if (!gl_info->gl_ops.ext.p_##core_func) \
2768 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
2770 #define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
2773 if (!gl_info->gl_ops.ext.p_##core_func) \
2774 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
2777 MAP_GL_FUNCTION(glActiveTexture
, glActiveTextureARB
);
2778 MAP_GL_FUNCTION(glAttachShader
, glAttachObjectARB
);
2779 MAP_GL_FUNCTION(glBeginQuery
, glBeginQueryARB
);
2780 MAP_GL_FUNCTION(glBindAttribLocation
, glBindAttribLocationARB
);
2781 MAP_GL_FUNCTION(glBindBuffer
, glBindBufferARB
);
2782 MAP_GL_FUNCTION(glBindFragDataLocation
, glBindFragDataLocationEXT
);
2783 MAP_GL_FUNCTION(glBlendColor
, glBlendColorEXT
);
2784 MAP_GL_FUNCTION(glBlendEquation
, glBlendEquationEXT
);
2785 MAP_GL_FUNCTION(glBlendEquationi
, glBlendEquationiARB
);
2786 MAP_GL_FUNCTION(glBlendEquationSeparate
, glBlendEquationSeparateEXT
);
2787 MAP_GL_FUNCTION(glBlendEquationSeparatei
, glBlendEquationSeparateiARB
);
2788 MAP_GL_FUNCTION(glBlendFunci
, glBlendFunciARB
);
2789 MAP_GL_FUNCTION(glBlendFuncSeparate
, glBlendFuncSeparateEXT
);
2790 MAP_GL_FUNCTION(glBlendFuncSeparatei
, glBlendFuncSeparateiARB
);
2791 MAP_GL_FUNCTION(glBufferData
, glBufferDataARB
);
2792 MAP_GL_FUNCTION(glBufferSubData
, glBufferSubDataARB
);
2793 MAP_GL_FUNCTION(glColorMaski
, glColorMaskIndexedEXT
);
2794 MAP_GL_FUNCTION(glCompileShader
, glCompileShaderARB
);
2795 MAP_GL_FUNCTION(glCompressedTexImage2D
, glCompressedTexImage2DARB
);
2796 MAP_GL_FUNCTION(glCompressedTexImage3D
, glCompressedTexImage3DARB
);
2797 MAP_GL_FUNCTION(glCompressedTexSubImage2D
, glCompressedTexSubImage2DARB
);
2798 MAP_GL_FUNCTION(glCompressedTexSubImage3D
, glCompressedTexSubImage3DARB
);
2799 MAP_GL_FUNCTION(glCreateProgram
, glCreateProgramObjectARB
);
2800 MAP_GL_FUNCTION(glCreateShader
, glCreateShaderObjectARB
);
2801 MAP_GL_FUNCTION(glDebugMessageCallback
, glDebugMessageCallbackARB
);
2802 MAP_GL_FUNCTION(glDebugMessageControl
, glDebugMessageControlARB
);
2803 MAP_GL_FUNCTION(glDebugMessageInsert
, glDebugMessageInsertARB
);
2804 MAP_GL_FUNCTION(glDeleteBuffers
, glDeleteBuffersARB
);
2805 MAP_GL_FUNCTION(glDeleteProgram
, glDeleteObjectARB
);
2806 MAP_GL_FUNCTION(glDeleteQueries
, glDeleteQueriesARB
);
2807 MAP_GL_FUNCTION(glDeleteShader
, glDeleteObjectARB
);
2808 MAP_GL_FUNCTION(glDetachShader
, glDetachObjectARB
);
2809 MAP_GL_FUNCTION(glDisablei
, glDisableIndexedEXT
);
2810 MAP_GL_FUNCTION(glDisableVertexAttribArray
, glDisableVertexAttribArrayARB
);
2811 MAP_GL_FUNCTION(glDrawArraysInstanced
, glDrawArraysInstancedARB
);
2812 MAP_GL_FUNCTION(glDrawBuffers
, glDrawBuffersARB
);
2813 MAP_GL_FUNCTION(glDrawElementsInstanced
, glDrawElementsInstancedARB
);
2814 MAP_GL_FUNCTION(glEnablei
, glEnableIndexedEXT
);
2815 MAP_GL_FUNCTION(glEnableVertexAttribArray
, glEnableVertexAttribArrayARB
);
2816 MAP_GL_FUNCTION(glEndQuery
, glEndQueryARB
);
2817 MAP_GL_FUNCTION(glFramebufferTexture
, glFramebufferTextureARB
);
2818 MAP_GL_FUNCTION(glGenBuffers
, glGenBuffersARB
);
2819 MAP_GL_FUNCTION(glGenQueries
, glGenQueriesARB
);
2820 MAP_GL_FUNCTION(glGetActiveUniform
, glGetActiveUniformARB
);
2821 MAP_GL_FUNCTION(glGetAttachedShaders
, glGetAttachedObjectsARB
);
2822 MAP_GL_FUNCTION(glGetAttribLocation
, glGetAttribLocationARB
);
2823 MAP_GL_FUNCTION(glGetBooleani_v
, glGetBooleanIndexedvEXT
);
2824 MAP_GL_FUNCTION(glGetBufferSubData
, glGetBufferSubDataARB
);
2825 MAP_GL_FUNCTION(glGetCompressedTexImage
, glGetCompressedTexImageARB
);
2826 MAP_GL_FUNCTION(glGetDebugMessageLog
, glGetDebugMessageLogARB
);
2827 MAP_GL_FUNCTION(glGetIntegeri_v
, glGetIntegerIndexedvEXT
);
2828 MAP_GL_FUNCTION(glGetProgramInfoLog
, glGetInfoLogARB
);
2829 MAP_GL_FUNCTION(glGetProgramiv
, glGetObjectParameterivARB
);
2830 MAP_GL_FUNCTION(glGetQueryiv
, glGetQueryivARB
);
2831 MAP_GL_FUNCTION(glGetQueryObjectuiv
, glGetQueryObjectuivARB
);
2832 MAP_GL_FUNCTION(glGetShaderInfoLog
, glGetInfoLogARB
);
2833 MAP_GL_FUNCTION(glGetShaderiv
, glGetObjectParameterivARB
);
2834 MAP_GL_FUNCTION(glGetShaderSource
, glGetShaderSourceARB
);
2835 MAP_GL_FUNCTION(glGetUniformfv
, glGetUniformfvARB
);
2836 MAP_GL_FUNCTION(glGetUniformiv
, glGetUniformivARB
);
2837 MAP_GL_FUNCTION(glGetUniformLocation
, glGetUniformLocationARB
);
2838 MAP_GL_FUNCTION(glIsEnabledi
, glIsEnabledIndexedEXT
);
2839 MAP_GL_FUNCTION(glLinkProgram
, glLinkProgramARB
);
2840 MAP_GL_FUNCTION(glMapBuffer
, glMapBufferARB
);
2841 MAP_GL_FUNCTION(glMinSampleShading
, glMinSampleShadingARB
);
2842 MAP_GL_FUNCTION(glPolygonOffsetClamp
, glPolygonOffsetClampEXT
);
2843 MAP_GL_FUNCTION_CAST(glShaderSource
, glShaderSourceARB
);
2844 MAP_GL_FUNCTION(glTexBuffer
, glTexBufferARB
);
2845 MAP_GL_FUNCTION_CAST(glTexImage3D
, glTexImage3DEXT
);
2846 MAP_GL_FUNCTION(glTexSubImage3D
, glTexSubImage3DEXT
);
2847 MAP_GL_FUNCTION(glUniform1f
, glUniform1fARB
);
2848 MAP_GL_FUNCTION(glUniform1fv
, glUniform1fvARB
);
2849 MAP_GL_FUNCTION(glUniform1i
, glUniform1iARB
);
2850 MAP_GL_FUNCTION(glUniform1iv
, glUniform1ivARB
);
2851 MAP_GL_FUNCTION(glUniform2f
, glUniform2fARB
);
2852 MAP_GL_FUNCTION(glUniform2fv
, glUniform2fvARB
);
2853 MAP_GL_FUNCTION(glUniform2i
, glUniform2iARB
);
2854 MAP_GL_FUNCTION(glUniform2iv
, glUniform2ivARB
);
2855 MAP_GL_FUNCTION(glUniform3f
, glUniform3fARB
);
2856 MAP_GL_FUNCTION(glUniform3fv
, glUniform3fvARB
);
2857 MAP_GL_FUNCTION(glUniform3i
, glUniform3iARB
);
2858 MAP_GL_FUNCTION(glUniform3iv
, glUniform3ivARB
);
2859 MAP_GL_FUNCTION(glUniform4f
, glUniform4fARB
);
2860 MAP_GL_FUNCTION(glUniform4fv
, glUniform4fvARB
);
2861 MAP_GL_FUNCTION(glUniform4i
, glUniform4iARB
);
2862 MAP_GL_FUNCTION(glUniform4iv
, glUniform4ivARB
);
2863 MAP_GL_FUNCTION(glUniformMatrix2fv
, glUniformMatrix2fvARB
);
2864 MAP_GL_FUNCTION(glUniformMatrix3fv
, glUniformMatrix3fvARB
);
2865 MAP_GL_FUNCTION(glUniformMatrix4fv
, glUniformMatrix4fvARB
);
2866 MAP_GL_FUNCTION(glUnmapBuffer
, glUnmapBufferARB
);
2867 MAP_GL_FUNCTION(glUseProgram
, glUseProgramObjectARB
);
2868 MAP_GL_FUNCTION(glValidateProgram
, glValidateProgramARB
);
2869 MAP_GL_FUNCTION(glVertexAttrib1f
, glVertexAttrib1fARB
);
2870 MAP_GL_FUNCTION(glVertexAttrib1fv
, glVertexAttrib1fvARB
);
2871 MAP_GL_FUNCTION(glVertexAttrib2f
, glVertexAttrib2fARB
);
2872 MAP_GL_FUNCTION(glVertexAttrib2fv
, glVertexAttrib2fvARB
);
2873 MAP_GL_FUNCTION(glVertexAttrib3f
, glVertexAttrib3fARB
);
2874 MAP_GL_FUNCTION(glVertexAttrib3fv
, glVertexAttrib3fvARB
);
2875 MAP_GL_FUNCTION(glVertexAttrib4f
, glVertexAttrib4fARB
);
2876 MAP_GL_FUNCTION(glVertexAttrib4fv
, glVertexAttrib4fvARB
);
2877 MAP_GL_FUNCTION(glVertexAttrib4Nsv
, glVertexAttrib4NsvARB
);
2878 MAP_GL_FUNCTION(glVertexAttrib4Nub
, glVertexAttrib4NubARB
);
2879 MAP_GL_FUNCTION(glVertexAttrib4Nubv
, glVertexAttrib4NubvARB
);
2880 MAP_GL_FUNCTION(glVertexAttrib4Nusv
, glVertexAttrib4NusvARB
);
2881 MAP_GL_FUNCTION(glVertexAttrib4sv
, glVertexAttrib4svARB
);
2882 MAP_GL_FUNCTION(glVertexAttrib4ubv
, glVertexAttrib4ubvARB
);
2883 MAP_GL_FUNCTION(glVertexAttribDivisor
, glVertexAttribDivisorARB
);
2884 MAP_GL_FUNCTION(glVertexAttribIPointer
, glVertexAttribIPointerEXT
);
2885 MAP_GL_FUNCTION(glVertexAttribPointer
, glVertexAttribPointerARB
);
2886 #undef MAP_GL_FUNCTION
2887 #undef MAP_GL_FUNCTION_CAST
2890 static void wined3d_adapter_init_limits(struct wined3d_gl_info
*gl_info
)
2892 unsigned int i
, sampler_count
;
2895 gl_info
->limits
.buffers
= 1;
2896 gl_info
->limits
.textures
= 0;
2897 gl_info
->limits
.texture_coords
= 0;
2898 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
2900 gl_info
->limits
.uniform_blocks
[i
] = 0;
2901 gl_info
->limits
.samplers
[i
] = 0;
2903 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] = 1;
2904 gl_info
->limits
.combined_samplers
= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
];
2905 gl_info
->limits
.graphics_samplers
= gl_info
->limits
.combined_samplers
;
2906 gl_info
->limits
.vertex_attribs
= 16;
2907 gl_info
->limits
.texture_buffer_offset_alignment
= 1;
2908 gl_info
->limits
.glsl_vs_float_constants
= 0;
2909 gl_info
->limits
.glsl_ps_float_constants
= 0;
2910 gl_info
->limits
.arb_vs_float_constants
= 0;
2911 gl_info
->limits
.arb_vs_native_constants
= 0;
2912 gl_info
->limits
.arb_vs_instructions
= 0;
2913 gl_info
->limits
.arb_vs_temps
= 0;
2914 gl_info
->limits
.arb_ps_float_constants
= 0;
2915 gl_info
->limits
.arb_ps_local_constants
= 0;
2916 gl_info
->limits
.arb_ps_instructions
= 0;
2917 gl_info
->limits
.arb_ps_temps
= 0;
2919 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_CLIP_DISTANCES
, &gl_max
);
2920 gl_info
->limits
.user_clip_distances
= min(WINED3D_MAX_CLIP_DISTANCES
, gl_max
);
2921 TRACE("Clip plane support - max planes %d.\n", gl_max
);
2923 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
2925 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_LIGHTS
, &gl_max
);
2926 gl_info
->limits
.lights
= gl_max
;
2927 TRACE("Light support - max lights %d.\n", gl_max
);
2930 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_SIZE
, &gl_max
);
2931 gl_info
->limits
.texture_size
= gl_max
;
2932 TRACE("Maximum texture size support - max texture size %d.\n", gl_max
);
2934 if (gl_info
->supported
[ARB_MAP_BUFFER_ALIGNMENT
])
2936 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MIN_MAP_BUFFER_ALIGNMENT
, &gl_max
);
2937 TRACE("Minimum buffer map alignment: %d.\n", gl_max
);
2941 WARN_(d3d_perf
)("Driver doesn't guarantee a minimum buffer map alignment.\n");
2943 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
2945 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GENERAL_COMBINERS_NV
, &gl_max
);
2946 gl_info
->limits
.general_combiners
= gl_max
;
2947 TRACE("Max general combiners: %d.\n", gl_max
);
2949 if (gl_info
->supported
[ARB_DRAW_BUFFERS
] && wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
2951 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB
, &gl_max
);
2952 gl_info
->limits
.buffers
= min(WINED3D_MAX_RENDER_TARGETS
, gl_max
);
2953 TRACE("Max draw buffers: %u.\n", gl_max
);
2955 if (gl_info
->supported
[ARB_MULTITEXTURE
])
2957 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
2959 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB
, &gl_max
);
2960 gl_info
->limits
.textures
= min(WINED3D_MAX_TEXTURES
, gl_max
);
2961 TRACE("Max textures: %d.\n", gl_info
->limits
.textures
);
2963 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
2965 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB
, &gl_max
);
2966 gl_info
->limits
.texture_coords
= min(WINED3D_MAX_TEXTURES
, gl_max
);
2970 gl_info
->limits
.texture_coords
= gl_info
->limits
.textures
;
2972 TRACE("Max texture coords: %d.\n", gl_info
->limits
.texture_coords
);
2975 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
] || gl_info
->supported
[ARB_FRAGMENT_SHADER
])
2977 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS
, &gl_max
);
2978 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] = gl_max
;
2982 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] = gl_info
->limits
.textures
;
2984 TRACE("Max fragment samplers: %d.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
]);
2986 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
2988 unsigned int vertex_sampler_count
;
2990 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB
, &gl_max
);
2991 vertex_sampler_count
= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_VERTEX
] = gl_max
;
2992 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB
, &gl_max
);
2993 gl_info
->limits
.combined_samplers
= gl_max
;
2994 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB
, &gl_max
);
2995 gl_info
->limits
.vertex_attribs
= gl_max
;
2997 /* Loading GLSL sampler uniforms is much simpler if we can assume
2998 * that the sampler setup is known at shader link time. In a
2999 * vertex shader + pixel shader combination this isn't an issue
3000 * because then the sampler setup only depends on the two shaders.
3001 * If a pixel shader is used with fixed-function vertex processing
3002 * we're fine too because fixed-function vertex processing doesn't
3003 * use any samplers. If fixed-function fragment processing is used
3004 * we have to make sure that all vertex sampler setups are valid
3005 * together with all possible fixed-function fragment processing
3006 * setups. This is true if vsamplers + WINED3D_MAX_TEXTURES <= max_samplers.
3007 * This is true on all Direct3D 9 cards that support vertex
3008 * texture fetch (GeForce 6 and GeForce 7 cards). Direct3D 9
3009 * Radeon cards do not support vertex texture fetch. Direct3D 10
3010 * cards have 128 samplers, and Direct3D 9 is limited to 8
3011 * fixed-function texture stages and 4 vertex samplers.
3012 * Direct3D 10 does not have a fixed-function pipeline anymore.
3014 * So this is just a check to check that our assumption holds
3015 * true. If not, write a warning and reduce the number of vertex
3016 * samplers or probably disable vertex texture fetch. */
3017 if (vertex_sampler_count
&& gl_info
->limits
.combined_samplers
< 12
3018 && WINED3D_MAX_TEXTURES
+ vertex_sampler_count
> gl_info
->limits
.combined_samplers
)
3020 FIXME("OpenGL implementation supports %u vertex samplers and %u total samplers.\n",
3021 vertex_sampler_count
, gl_info
->limits
.combined_samplers
);
3022 FIXME("Expected vertex samplers + WINED3D_MAX_TEXTURES(=8) > combined_samplers.\n");
3023 if (gl_info
->limits
.combined_samplers
> WINED3D_MAX_TEXTURES
)
3024 vertex_sampler_count
= gl_info
->limits
.combined_samplers
- WINED3D_MAX_TEXTURES
;
3026 vertex_sampler_count
= 0;
3027 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_VERTEX
] = vertex_sampler_count
;
3032 gl_info
->limits
.combined_samplers
= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
];
3034 TRACE("Max vertex samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_VERTEX
]);
3035 TRACE("Max combined samplers: %u.\n", gl_info
->limits
.combined_samplers
);
3036 TRACE("Max vertex attributes: %u.\n", gl_info
->limits
.vertex_attribs
);
3040 gl_info
->limits
.textures
= 1;
3041 gl_info
->limits
.texture_coords
= 1;
3044 if (gl_info
->supported
[EXT_TEXTURE3D
])
3046 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE_EXT
, &gl_max
);
3047 gl_info
->limits
.texture3d_size
= gl_max
;
3048 TRACE("Max texture3D size: %d.\n", gl_info
->limits
.texture3d_size
);
3050 if (gl_info
->supported
[ARB_TEXTURE_FILTER_ANISOTROPIC
])
3052 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY
, &gl_max
);
3053 gl_info
->limits
.anisotropy
= gl_max
;
3054 TRACE("Max anisotropy: %d.\n", gl_info
->limits
.anisotropy
);
3056 if (gl_info
->supported
[ARB_FRAGMENT_PROGRAM
])
3058 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
3059 gl_info
->limits
.arb_ps_float_constants
= gl_max
;
3060 TRACE("Max ARB_FRAGMENT_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_ps_float_constants
);
3061 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
3062 gl_info
->limits
.arb_ps_native_constants
= gl_max
;
3063 TRACE("Max ARB_FRAGMENT_PROGRAM native float constants: %d.\n",
3064 gl_info
->limits
.arb_ps_native_constants
);
3065 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
3066 gl_info
->limits
.arb_ps_temps
= gl_max
;
3067 TRACE("Max ARB_FRAGMENT_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_ps_temps
);
3068 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
3069 gl_info
->limits
.arb_ps_instructions
= gl_max
;
3070 TRACE("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_ps_instructions
);
3071 GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB
, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB
, &gl_max
));
3072 gl_info
->limits
.arb_ps_local_constants
= gl_max
;
3073 TRACE("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info
->limits
.arb_ps_instructions
);
3075 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
])
3077 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB
, &gl_max
));
3078 gl_info
->limits
.arb_vs_float_constants
= gl_max
;
3079 TRACE("Max ARB_VERTEX_PROGRAM float constants: %d.\n", gl_info
->limits
.arb_vs_float_constants
);
3080 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB
, &gl_max
));
3081 gl_info
->limits
.arb_vs_native_constants
= gl_max
;
3082 TRACE("Max ARB_VERTEX_PROGRAM native float constants: %d.\n",
3083 gl_info
->limits
.arb_vs_native_constants
);
3084 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB
, &gl_max
));
3085 gl_info
->limits
.arb_vs_temps
= gl_max
;
3086 TRACE("Max ARB_VERTEX_PROGRAM native temporaries: %d.\n", gl_info
->limits
.arb_vs_temps
);
3087 GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB
, GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB
, &gl_max
));
3088 gl_info
->limits
.arb_vs_instructions
= gl_max
;
3089 TRACE("Max ARB_VERTEX_PROGRAM native instructions: %d.\n", gl_info
->limits
.arb_vs_instructions
);
3091 if (gl_info
->supported
[ARB_VERTEX_SHADER
])
3093 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB
, &gl_max
);
3094 gl_info
->limits
.glsl_vs_float_constants
= gl_max
/ 4;
3095 TRACE("Max ARB_VERTEX_SHADER float constants: %u.\n", gl_info
->limits
.glsl_vs_float_constants
);
3097 if (gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3099 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_UNIFORM_BLOCKS
, &gl_max
);
3100 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_VERTEX
] = min(gl_max
, WINED3D_MAX_CBS
);
3101 TRACE("Max vertex uniform blocks: %u (%d).\n",
3102 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_VERTEX
], gl_max
);
3105 if (gl_info
->supported
[ARB_TESSELLATION_SHADER
])
3107 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS
, &gl_max
);
3108 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_HULL
] = min(gl_max
, WINED3D_MAX_CBS
);
3109 TRACE("Max hull uniform blocks: %u (%d).\n",
3110 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_HULL
], gl_max
);
3111 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS
, &gl_max
);
3112 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_HULL
] = gl_max
;
3113 TRACE("Max hull samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_HULL
]);
3115 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS
, &gl_max
);
3116 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_DOMAIN
] = min(gl_max
, WINED3D_MAX_CBS
);
3117 TRACE("Max domain uniform blocks: %u (%d).\n",
3118 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_DOMAIN
], gl_max
);
3119 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS
, &gl_max
);
3120 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_DOMAIN
] = gl_max
;
3121 TRACE("Max domain samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_DOMAIN
]);
3123 if (gl_info
->supported
[WINED3D_GL_VERSION_3_2
] && gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3125 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GEOMETRY_UNIFORM_BLOCKS
, &gl_max
);
3126 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_GEOMETRY
] = min(gl_max
, WINED3D_MAX_CBS
);
3127 TRACE("Max geometry uniform blocks: %u (%d).\n",
3128 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_GEOMETRY
], gl_max
);
3129 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS
, &gl_max
);
3130 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_GEOMETRY
] = gl_max
;
3131 TRACE("Max geometry samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_GEOMETRY
]);
3133 if (gl_info
->supported
[ARB_FRAGMENT_SHADER
])
3135 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB
, &gl_max
);
3136 gl_info
->limits
.glsl_ps_float_constants
= gl_max
/ 4;
3137 TRACE("Max ARB_FRAGMENT_SHADER float constants: %u.\n", gl_info
->limits
.glsl_ps_float_constants
);
3138 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3140 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VARYING_FLOATS_ARB
, &gl_max
);
3141 gl_info
->limits
.glsl_varyings
= gl_max
;
3145 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_INPUT_COMPONENTS
, &gl_max
);
3146 gl_info
->limits
.glsl_varyings
= gl_max
- 4;
3148 TRACE("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_info
->limits
.glsl_varyings
,
3149 gl_info
->limits
.glsl_varyings
/ 4);
3151 if (gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3153 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS
, &gl_max
);
3154 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_PIXEL
] = min(gl_max
, WINED3D_MAX_CBS
);
3155 TRACE("Max fragment uniform blocks: %u (%d).\n",
3156 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_PIXEL
], gl_max
);
3159 if (gl_info
->supported
[ARB_COMPUTE_SHADER
])
3161 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS
, &gl_max
);
3162 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_COMPUTE
] = min(gl_max
, WINED3D_MAX_CBS
);
3163 TRACE("Max compute uniform blocks: %u (%d).\n",
3164 gl_info
->limits
.uniform_blocks
[WINED3D_SHADER_TYPE_COMPUTE
], gl_max
);
3165 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS
, &gl_max
);
3166 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_COMPUTE
] = gl_max
;
3167 TRACE("Max compute samplers: %u.\n", gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_COMPUTE
]);
3169 if (gl_info
->supported
[ARB_UNIFORM_BUFFER_OBJECT
])
3171 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_UNIFORM_BLOCKS
, &gl_max
);
3172 TRACE("Max combined uniform blocks: %d.\n", gl_max
);
3173 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS
, &gl_max
);
3174 TRACE("Max uniform buffer bindings: %d.\n", gl_max
);
3176 if (gl_info
->supported
[ARB_TEXTURE_BUFFER_RANGE
])
3178 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT
, &gl_max
);
3179 gl_info
->limits
.texture_buffer_offset_alignment
= gl_max
;
3180 TRACE("Minimum required texture buffer offset alignment %d.\n", gl_max
);
3182 if (gl_info
->supported
[ARB_SHADER_ATOMIC_COUNTERS
])
3184 GLint max_fragment_buffers
, max_combined_buffers
, max_bindings
;
3185 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS
, &max_fragment_buffers
);
3186 TRACE("Max fragment atomic counter buffers: %d.\n", max_fragment_buffers
);
3187 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS
, &max_combined_buffers
);
3188 TRACE("Max combined atomic counter buffers: %d.\n", max_combined_buffers
);
3189 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS
, &max_bindings
);
3190 TRACE("Max atomic counter buffer bindings: %d.\n", max_bindings
);
3191 if (max_fragment_buffers
< MAX_UNORDERED_ACCESS_VIEWS
3192 || max_combined_buffers
< MAX_UNORDERED_ACCESS_VIEWS
3193 || max_bindings
< MAX_UNORDERED_ACCESS_VIEWS
)
3195 WARN("Disabling ARB_shader_atomic_counters.\n");
3196 gl_info
->supported
[ARB_SHADER_ATOMIC_COUNTERS
] = FALSE
;
3199 if (gl_info
->supported
[ARB_TRANSFORM_FEEDBACK3
])
3201 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_VERTEX_STREAMS
, &gl_max
);
3202 TRACE("Max vertex streams: %d.\n", gl_max
);
3205 if (gl_info
->supported
[NV_LIGHT_MAX_EXPONENT
])
3206 gl_info
->gl_ops
.gl
.p_glGetFloatv(GL_MAX_SHININESS_NV
, &gl_info
->limits
.shininess
);
3208 gl_info
->limits
.shininess
= 128.0f
;
3210 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] || gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
3212 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_SAMPLES
, &gl_max
);
3213 gl_info
->limits
.samples
= gl_max
;
3216 if (gl_info
->supported
[ARB_FRAMEBUFFER_NO_ATTACHMENTS
])
3218 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_WIDTH
, &gl_max
);
3219 gl_info
->limits
.framebuffer_width
= gl_max
;
3220 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_MAX_FRAMEBUFFER_HEIGHT
, &gl_max
);
3221 gl_info
->limits
.framebuffer_height
= gl_max
;
3225 gl_info
->limits
.framebuffer_width
= gl_info
->limits
.texture_size
;
3226 gl_info
->limits
.framebuffer_height
= gl_info
->limits
.texture_size
;
3229 gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
] =
3230 min(gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_PIXEL
], MAX_GL_FRAGMENT_SAMPLERS
);
3232 for (i
= 0; i
< WINED3D_SHADER_TYPE_GRAPHICS_COUNT
; ++i
)
3233 sampler_count
+= gl_info
->limits
.samplers
[i
];
3234 if (gl_info
->supported
[WINED3D_GL_VERSION_3_2
] && gl_info
->limits
.combined_samplers
< sampler_count
)
3236 /* The minimum value for GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS in OpenGL
3237 * 3.2 is 48 (16 per stage). When tessellation shaders are supported
3238 * the minimum value is increased to 80. */
3239 WARN("Graphics pipeline sampler count %u is greater than combined sampler count %u.\n",
3240 sampler_count
, gl_info
->limits
.combined_samplers
);
3241 for (i
= 0; i
< WINED3D_SHADER_TYPE_GRAPHICS_COUNT
; ++i
)
3242 gl_info
->limits
.samplers
[i
] = min(gl_info
->limits
.samplers
[i
], 16);
3245 /* A majority of OpenGL implementations allow us to statically partition
3246 * the set of texture bindings into six separate sets. */
3247 gl_info
->limits
.graphics_samplers
= gl_info
->limits
.combined_samplers
;
3249 for (i
= 0; i
< WINED3D_SHADER_TYPE_COUNT
; ++i
)
3250 sampler_count
+= gl_info
->limits
.samplers
[i
];
3251 if (gl_info
->limits
.combined_samplers
>= sampler_count
)
3252 gl_info
->limits
.graphics_samplers
-= gl_info
->limits
.samplers
[WINED3D_SHADER_TYPE_COMPUTE
];
3255 /* Context activation is done by the caller. */
3256 static BOOL
wined3d_adapter_init_gl_caps(struct wined3d_adapter
*adapter
,
3257 struct wined3d_caps_gl_ctx
*caps_gl_ctx
, unsigned int wined3d_creation_flags
)
3261 enum wined3d_gl_extension extension
;
3262 DWORD min_gl_version
;
3266 {EXT_TEXTURE3D
, MAKEDWORD_VERSION(1, 2)},
3267 {ARB_MULTISAMPLE
, MAKEDWORD_VERSION(1, 3)},
3268 {ARB_MULTITEXTURE
, MAKEDWORD_VERSION(1, 3)},
3269 {ARB_TEXTURE_BORDER_CLAMP
, MAKEDWORD_VERSION(1, 3)},
3270 {ARB_TEXTURE_COMPRESSION
, MAKEDWORD_VERSION(1, 3)},
3271 {ARB_TEXTURE_CUBE_MAP
, MAKEDWORD_VERSION(1, 3)},
3272 {ARB_DEPTH_TEXTURE
, MAKEDWORD_VERSION(1, 4)},
3273 {ARB_POINT_PARAMETERS
, MAKEDWORD_VERSION(1, 4)},
3274 {ARB_SHADOW
, MAKEDWORD_VERSION(1, 4)},
3275 {ARB_TEXTURE_MIRRORED_REPEAT
, MAKEDWORD_VERSION(1, 4)},
3276 {EXT_BLEND_COLOR
, MAKEDWORD_VERSION(1, 4)},
3277 {EXT_BLEND_FUNC_SEPARATE
, MAKEDWORD_VERSION(1, 4)},
3278 {EXT_BLEND_MINMAX
, MAKEDWORD_VERSION(1, 4)},
3279 {EXT_BLEND_SUBTRACT
, MAKEDWORD_VERSION(1, 4)},
3280 {EXT_STENCIL_WRAP
, MAKEDWORD_VERSION(1, 4)},
3281 {NV_POINT_SPRITE
, MAKEDWORD_VERSION(1, 4)},
3282 {ARB_OCCLUSION_QUERY
, MAKEDWORD_VERSION(1, 5)},
3283 {ARB_VERTEX_BUFFER_OBJECT
, MAKEDWORD_VERSION(1, 5)},
3284 {ARB_DRAW_BUFFERS
, MAKEDWORD_VERSION(2, 0)},
3285 {ARB_FRAGMENT_SHADER
, MAKEDWORD_VERSION(2, 0)},
3286 {ARB_SHADING_LANGUAGE_100
, MAKEDWORD_VERSION(2, 0)},
3287 {ARB_TEXTURE_NON_POWER_OF_TWO
, MAKEDWORD_VERSION(2, 0)},
3288 {ARB_VERTEX_SHADER
, MAKEDWORD_VERSION(2, 0)},
3289 {EXT_BLEND_EQUATION_SEPARATE
, MAKEDWORD_VERSION(2, 0)},
3290 {ARB_PIXEL_BUFFER_OBJECT
, MAKEDWORD_VERSION(2, 1)},
3291 {EXT_TEXTURE_SRGB
, MAKEDWORD_VERSION(2, 1)},
3292 {ARB_COLOR_BUFFER_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3293 {ARB_DEPTH_BUFFER_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3294 {ARB_FRAMEBUFFER_OBJECT
, MAKEDWORD_VERSION(3, 0)},
3295 {ARB_FRAMEBUFFER_SRGB
, MAKEDWORD_VERSION(3, 0)},
3296 {ARB_HALF_FLOAT_PIXEL
, MAKEDWORD_VERSION(3, 0)},
3297 {ARB_HALF_FLOAT_VERTEX
, MAKEDWORD_VERSION(3, 0)},
3298 {ARB_MAP_BUFFER_RANGE
, MAKEDWORD_VERSION(3, 0)},
3299 {ARB_TEXTURE_COMPRESSION_RGTC
, MAKEDWORD_VERSION(3, 0)},
3300 {ARB_TEXTURE_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3301 {ARB_TEXTURE_RG
, MAKEDWORD_VERSION(3, 0)},
3302 {EXT_DRAW_BUFFERS2
, MAKEDWORD_VERSION(3, 0)},
3303 {EXT_PACKED_FLOAT
, MAKEDWORD_VERSION(3, 0)},
3304 {EXT_TEXTURE_ARRAY
, MAKEDWORD_VERSION(3, 0)},
3305 {EXT_TEXTURE_INTEGER
, MAKEDWORD_VERSION(3, 0)},
3306 {EXT_TEXTURE_SHARED_EXPONENT
, MAKEDWORD_VERSION(3, 0)},
3307 /* We don't want to enable EXT_GPU_SHADER4: even though similar
3308 * functionality is available in core GL 3.0 / GLSL 1.30, it's different
3309 * enough that reusing the same flag for the new features hurts more
3311 /* EXT_framebuffer_object, EXT_framebuffer_blit,
3312 * EXT_framebuffer_multisample and EXT_packed_depth_stencil
3313 * are integrated into ARB_framebuffer_object. */
3315 {ARB_COPY_BUFFER
, MAKEDWORD_VERSION(3, 1)},
3316 {ARB_DRAW_INSTANCED
, MAKEDWORD_VERSION(3, 1)},
3317 {ARB_TEXTURE_BUFFER_OBJECT
, MAKEDWORD_VERSION(3, 1)},
3318 {ARB_UNIFORM_BUFFER_OBJECT
, MAKEDWORD_VERSION(3, 1)},
3319 {EXT_TEXTURE_SNORM
, MAKEDWORD_VERSION(3, 1)},
3320 /* We don't need or want GL_ARB_texture_rectangle (core in 3.1). */
3322 {ARB_DEPTH_CLAMP
, MAKEDWORD_VERSION(3, 2)},
3323 {ARB_DRAW_ELEMENTS_BASE_VERTEX
, MAKEDWORD_VERSION(3, 2)},
3324 /* ARB_geometry_shader4 exposes a somewhat different API compared to 3.2
3325 * core geometry shaders so it's not really correct to expose the
3326 * extension for core-only support. */
3327 {ARB_FRAGMENT_COORD_CONVENTIONS
, MAKEDWORD_VERSION(3, 2)},
3328 {ARB_PROVOKING_VERTEX
, MAKEDWORD_VERSION(3, 2)},
3329 {ARB_SEAMLESS_CUBE_MAP
, MAKEDWORD_VERSION(3, 2)},
3330 {ARB_SYNC
, MAKEDWORD_VERSION(3, 2)},
3331 {ARB_TEXTURE_MULTISAMPLE
, MAKEDWORD_VERSION(3, 2)},
3332 {ARB_VERTEX_ARRAY_BGRA
, MAKEDWORD_VERSION(3, 2)},
3334 {ARB_BLEND_FUNC_EXTENDED
, MAKEDWORD_VERSION(3, 3)},
3335 {ARB_EXPLICIT_ATTRIB_LOCATION
, MAKEDWORD_VERSION(3, 3)},
3336 {ARB_INSTANCED_ARRAYS
, MAKEDWORD_VERSION(3, 3)},
3337 {ARB_SAMPLER_OBJECTS
, MAKEDWORD_VERSION(3, 3)},
3338 {ARB_SHADER_BIT_ENCODING
, MAKEDWORD_VERSION(3, 3)},
3339 {ARB_TEXTURE_RGB10_A2UI
, MAKEDWORD_VERSION(3, 3)},
3340 {ARB_TEXTURE_SWIZZLE
, MAKEDWORD_VERSION(3, 3)},
3341 {ARB_TIMER_QUERY
, MAKEDWORD_VERSION(3, 3)},
3342 {ARB_VERTEX_TYPE_2_10_10_10_REV
, MAKEDWORD_VERSION(3, 3)},
3344 {ARB_DRAW_BUFFERS_BLEND
, MAKEDWORD_VERSION(4, 0)},
3345 {ARB_DRAW_INDIRECT
, MAKEDWORD_VERSION(4, 0)},
3346 {ARB_GPU_SHADER5
, MAKEDWORD_VERSION(4, 0)},
3347 {ARB_SAMPLE_SHADING
, MAKEDWORD_VERSION(4, 0)},
3348 {ARB_TESSELLATION_SHADER
, MAKEDWORD_VERSION(4, 0)},
3349 {ARB_TEXTURE_CUBE_MAP_ARRAY
, MAKEDWORD_VERSION(4, 0)},
3350 {ARB_TEXTURE_GATHER
, MAKEDWORD_VERSION(4, 0)},
3351 {ARB_TRANSFORM_FEEDBACK2
, MAKEDWORD_VERSION(4, 0)},
3352 {ARB_TRANSFORM_FEEDBACK3
, MAKEDWORD_VERSION(4, 0)},
3354 {ARB_ES2_COMPATIBILITY
, MAKEDWORD_VERSION(4, 1)},
3355 {ARB_VIEWPORT_ARRAY
, MAKEDWORD_VERSION(4, 1)},
3357 {ARB_BASE_INSTANCE
, MAKEDWORD_VERSION(4, 2)},
3358 {ARB_CONSERVATIVE_DEPTH
, MAKEDWORD_VERSION(4, 2)},
3359 {ARB_INTERNALFORMAT_QUERY
, MAKEDWORD_VERSION(4, 2)},
3360 {ARB_MAP_BUFFER_ALIGNMENT
, MAKEDWORD_VERSION(4, 2)},
3361 {ARB_SHADER_ATOMIC_COUNTERS
, MAKEDWORD_VERSION(4, 2)},
3362 {ARB_SHADER_IMAGE_LOAD_STORE
, MAKEDWORD_VERSION(4, 2)},
3363 {ARB_SHADING_LANGUAGE_420PACK
, MAKEDWORD_VERSION(4, 2)},
3364 {ARB_SHADING_LANGUAGE_PACKING
, MAKEDWORD_VERSION(4, 2)},
3365 {ARB_TEXTURE_COMPRESSION_BPTC
, MAKEDWORD_VERSION(4, 2)},
3366 {ARB_TEXTURE_STORAGE
, MAKEDWORD_VERSION(4, 2)},
3368 {ARB_CLEAR_BUFFER_OBJECT
, MAKEDWORD_VERSION(4, 3)},
3369 {ARB_COMPUTE_SHADER
, MAKEDWORD_VERSION(4, 3)},
3370 {ARB_COPY_IMAGE
, MAKEDWORD_VERSION(4, 3)},
3371 {ARB_DEBUG_OUTPUT
, MAKEDWORD_VERSION(4, 3)},
3372 {ARB_ES3_COMPATIBILITY
, MAKEDWORD_VERSION(4, 3)},
3373 {ARB_FRAGMENT_LAYER_VIEWPORT
, MAKEDWORD_VERSION(4, 3)},
3374 {ARB_FRAMEBUFFER_NO_ATTACHMENTS
, MAKEDWORD_VERSION(4, 3)},
3375 {ARB_INTERNALFORMAT_QUERY2
, MAKEDWORD_VERSION(4, 3)},
3376 {ARB_SHADER_IMAGE_SIZE
, MAKEDWORD_VERSION(4, 3)},
3377 {ARB_SHADER_STORAGE_BUFFER_OBJECT
, MAKEDWORD_VERSION(4, 3)},
3378 {ARB_STENCIL_TEXTURING
, MAKEDWORD_VERSION(4, 3)},
3379 {ARB_TEXTURE_BUFFER_RANGE
, MAKEDWORD_VERSION(4, 3)},
3380 {ARB_TEXTURE_QUERY_LEVELS
, MAKEDWORD_VERSION(4, 3)},
3381 {ARB_TEXTURE_STORAGE_MULTISAMPLE
, MAKEDWORD_VERSION(4, 3)},
3382 {ARB_TEXTURE_VIEW
, MAKEDWORD_VERSION(4, 3)},
3384 {ARB_BUFFER_STORAGE
, MAKEDWORD_VERSION(4, 4)},
3385 {ARB_CLEAR_TEXTURE
, MAKEDWORD_VERSION(4, 4)},
3386 {ARB_QUERY_BUFFER_OBJECT
, MAKEDWORD_VERSION(4, 4)},
3387 {ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
, MAKEDWORD_VERSION(4, 4)},
3388 {ARB_VERTEX_TYPE_10F_11F_11F_REV
, MAKEDWORD_VERSION(4, 4)},
3390 {ARB_CLIP_CONTROL
, MAKEDWORD_VERSION(4, 5)},
3391 {ARB_CULL_DISTANCE
, MAKEDWORD_VERSION(4, 5)},
3392 {ARB_DERIVATIVE_CONTROL
, MAKEDWORD_VERSION(4, 5)},
3393 {ARB_SHADER_TEXTURE_IMAGE_SAMPLES
, MAKEDWORD_VERSION(4, 5)},
3394 {ARB_TEXTURE_BARRIER
, MAKEDWORD_VERSION(4, 5)},
3396 {ARB_PIPELINE_STATISTICS_QUERY
, MAKEDWORD_VERSION(4, 6)},
3397 {ARB_POLYGON_OFFSET_CLAMP
, MAKEDWORD_VERSION(4, 6)},
3398 {ARB_TEXTURE_FILTER_ANISOTROPIC
, MAKEDWORD_VERSION(4, 6)},
3400 const char *gl_vendor_str
, *gl_renderer_str
, *gl_version_str
;
3401 struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
3402 DWORD gl_version
, gl_ext_emul_mask
;
3403 const char *WGL_Extensions
= NULL
;
3404 enum wined3d_gl_vendor gl_vendor
;
3405 GLint context_profile
= 0;
3409 TRACE("adapter %p.\n", adapter
);
3411 gl_renderer_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_RENDERER
);
3412 TRACE("GL_RENDERER: %s.\n", debugstr_a(gl_renderer_str
));
3413 if (!gl_renderer_str
)
3415 ERR("Received a NULL GL_RENDERER.\n");
3419 gl_vendor_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VENDOR
);
3420 TRACE("GL_VENDOR: %s.\n", debugstr_a(gl_vendor_str
));
3423 ERR("Received a NULL GL_VENDOR.\n");
3427 /* Parse the GL_VERSION field into major and minor information */
3428 gl_version_str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_VERSION
);
3429 TRACE("GL_VERSION: %s.\n", debugstr_a(gl_version_str
));
3430 if (!gl_version_str
)
3432 ERR("Received a NULL GL_VERSION.\n");
3435 gl_version
= wined3d_parse_gl_version(gl_version_str
);
3437 load_gl_funcs(gl_info
);
3439 memset(gl_info
->supported
, 0, sizeof(gl_info
->supported
));
3440 gl_info
->supported
[WINED3D_GL_EXT_NONE
] = TRUE
;
3442 if (gl_version
>= MAKEDWORD_VERSION(3, 2))
3444 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_CONTEXT_PROFILE_MASK
, &context_profile
);
3445 checkGLcall("Querying context profile");
3447 if (context_profile
& GL_CONTEXT_CORE_PROFILE_BIT
)
3448 TRACE("Got a core profile context.\n");
3450 gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
] = TRUE
;
3452 TRACE("GL extensions reported:\n");
3453 if (gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3455 const char *gl_extensions
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_EXTENSIONS
);
3459 ERR("Received a NULL GL_EXTENSIONS.\n");
3462 parse_extension_string(gl_info
, gl_extensions
, gl_extension_map
, ARRAY_SIZE(gl_extension_map
));
3466 enumerate_gl_extensions(gl_info
, gl_extension_map
, ARRAY_SIZE(gl_extension_map
));
3469 hdc
= wglGetCurrentDC();
3470 /* Not all GL drivers might offer WGL extensions e.g. VirtualBox. */
3471 if (GL_EXTCALL(wglGetExtensionsStringARB
))
3472 WGL_Extensions
= (const char *)GL_EXTCALL(wglGetExtensionsStringARB(hdc
));
3473 if (!WGL_Extensions
)
3474 WARN("WGL extensions not supported.\n");
3476 parse_extension_string(gl_info
, WGL_Extensions
, wgl_extension_map
, ARRAY_SIZE(wgl_extension_map
));
3478 for (i
= 0; i
< ARRAY_SIZE(core_extensions
); ++i
)
3480 if (!gl_info
->supported
[core_extensions
[i
].extension
]
3481 && gl_version
>= core_extensions
[i
].min_gl_version
)
3483 for (j
= 0; j
< ARRAY_SIZE(gl_extension_map
); ++j
)
3484 if (gl_extension_map
[j
].extension
== core_extensions
[i
].extension
)
3487 if (j
< ARRAY_SIZE(gl_extension_map
))
3489 TRACE("GL CORE: %s support.\n", gl_extension_map
[j
].extension_string
);
3490 gl_info
->supported
[core_extensions
[i
].extension
] = TRUE
;
3494 FIXME("GL extension %u not in the GL extensions map.\n", core_extensions
[i
].extension
);
3499 if (gl_info
->supported
[EXT_BLEND_MINMAX
] || gl_info
->supported
[EXT_BLEND_SUBTRACT
])
3500 gl_info
->supported
[WINED3D_GL_BLEND_EQUATION
] = TRUE
;
3502 if (gl_version
>= MAKEDWORD_VERSION(2, 0))
3504 gl_info
->supported
[WINED3D_GL_VERSION_2_0
] = TRUE
;
3505 /* We want to use the core APIs for two-sided stencil in GL 2.0. */
3506 gl_info
->supported
[EXT_STENCIL_TWO_SIDE
] = FALSE
;
3508 if (gl_version
>= MAKEDWORD_VERSION(3, 2))
3509 gl_info
->supported
[WINED3D_GL_VERSION_3_2
] = TRUE
;
3511 /* All the points are actually point sprites in core contexts, the APIs from
3512 * ARB_point_sprite are not supported anymore. */
3513 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3514 gl_info
->supported
[ARB_POINT_SPRITE
] = FALSE
;
3516 if (gl_info
->supported
[APPLE_FENCE
])
3518 /* GL_NV_fence and GL_APPLE_fence provide the same functionality basically.
3519 * The apple extension interacts with some other apple exts. Disable the NV
3520 * extension if the apple one is support to prevent confusion in other parts
3522 gl_info
->supported
[NV_FENCE
] = FALSE
;
3524 if (gl_info
->supported
[APPLE_FLOAT_PIXELS
])
3526 /* GL_APPLE_float_pixels == GL_ARB_texture_float + GL_ARB_half_float_pixel
3528 * The enums are the same:
3529 * GL_RGBA16F_ARB = GL_RGBA_FLOAT16_APPLE = 0x881a
3530 * GL_RGB16F_ARB = GL_RGB_FLOAT16_APPLE = 0x881b
3531 * GL_RGBA32F_ARB = GL_RGBA_FLOAT32_APPLE = 0x8814
3532 * GL_RGB32F_ARB = GL_RGB_FLOAT32_APPLE = 0x8815
3533 * GL_HALF_FLOAT_ARB = GL_HALF_APPLE = 0x140b
3535 if (!gl_info
->supported
[ARB_TEXTURE_FLOAT
])
3537 TRACE(" IMPLIED: GL_ARB_texture_float support (by GL_APPLE_float_pixels).\n");
3538 gl_info
->supported
[ARB_TEXTURE_FLOAT
] = TRUE
;
3540 if (!gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
])
3542 TRACE(" IMPLIED: GL_ARB_half_float_pixel support (by GL_APPLE_float_pixels).\n");
3543 gl_info
->supported
[ARB_HALF_FLOAT_PIXEL
] = TRUE
;
3546 if (gl_info
->supported
[ARB_MAP_BUFFER_RANGE
])
3548 /* GL_ARB_map_buffer_range and GL_APPLE_flush_buffer_range provide the same
3549 * functionality. Prefer the ARB extension */
3550 gl_info
->supported
[APPLE_FLUSH_BUFFER_RANGE
] = FALSE
;
3552 if (gl_info
->supported
[ARB_TEXTURE_CUBE_MAP
])
3554 TRACE(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
3555 gl_info
->supported
[NV_TEXGEN_REFLECTION
] = TRUE
;
3557 if (!gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
])
3559 TRACE(" IMPLIED: EXT_texture_compression_rgtc support (by ARB_texture_compression_rgtc).\n");
3560 gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
3562 if (!gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && gl_info
->supported
[EXT_TEXTURE_COMPRESSION_RGTC
])
3564 TRACE(" IMPLIED: ARB_texture_compression_rgtc support (by EXT_texture_compression_rgtc).\n");
3565 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = TRUE
;
3567 if (gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] && !gl_info
->supported
[ARB_TEXTURE_RG
])
3569 TRACE("ARB_texture_rg not supported, disabling ARB_texture_compression_rgtc.\n");
3570 gl_info
->supported
[ARB_TEXTURE_COMPRESSION_RGTC
] = FALSE
;
3572 if (gl_info
->supported
[NV_TEXTURE_SHADER2
])
3574 if (gl_info
->supported
[NV_REGISTER_COMBINERS
])
3576 /* Also disable ATI_FRAGMENT_SHADER if register combiners and texture_shader2
3577 * are supported. The nv extensions provide the same functionality as the
3578 * ATI one, and a bit more(signed pixelformats). */
3579 gl_info
->supported
[ATI_FRAGMENT_SHADER
] = FALSE
;
3582 if (gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
])
3584 /* If we have full NP2 texture support, disable
3585 * GL_ARB_texture_rectangle because we will never use it.
3586 * This saves a few redundant glDisable calls. */
3587 gl_info
->supported
[ARB_TEXTURE_RECTANGLE
] = FALSE
;
3589 if (gl_info
->supported
[ATI_FRAGMENT_SHADER
])
3591 /* Disable NV_register_combiners and fragment shader if this is supported.
3592 * generally the NV extensions are preferred over the ATI ones, and this
3593 * extension is disabled if register_combiners and texture_shader2 are both
3594 * supported. So we reach this place only if we have incomplete NV dxlevel 8
3595 * fragment processing support. */
3596 gl_info
->supported
[NV_REGISTER_COMBINERS
] = FALSE
;
3597 gl_info
->supported
[NV_REGISTER_COMBINERS2
] = FALSE
;
3598 gl_info
->supported
[NV_TEXTURE_SHADER
] = FALSE
;
3599 gl_info
->supported
[NV_TEXTURE_SHADER2
] = FALSE
;
3601 if (gl_info
->supported
[NV_HALF_FLOAT
])
3603 /* GL_ARB_half_float_vertex is a subset of GL_NV_half_float. */
3604 gl_info
->supported
[ARB_HALF_FLOAT_VERTEX
] = TRUE
;
3606 if (gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
] && !gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
])
3608 /* Current wined3d sRGB infrastructure requires EXT_texture_sRGB_decode
3609 * for GL_ARB_framebuffer_sRGB support (without EXT_texture_sRGB_decode
3610 * we never render to sRGB surfaces). */
3611 TRACE("EXT_texture_sRGB_decode is not supported, disabling ARB_framebuffer_sRGB.\n");
3612 gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
] = FALSE
;
3614 if (gl_info
->supported
[ARB_OCCLUSION_QUERY
])
3618 GL_EXTCALL(glGetQueryiv(GL_SAMPLES_PASSED
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3619 TRACE("Occlusion query counter has %d bits.\n", counter_bits
);
3621 gl_info
->supported
[ARB_OCCLUSION_QUERY
] = FALSE
;
3623 if (gl_info
->supported
[ARB_TIMER_QUERY
])
3627 GL_EXTCALL(glGetQueryiv(GL_TIMESTAMP
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3628 TRACE("Timestamp query counter has %d bits.\n", counter_bits
);
3630 gl_info
->supported
[ARB_TIMER_QUERY
] = FALSE
;
3632 if (gl_version
>= MAKEDWORD_VERSION(3, 0))
3636 gl_info
->supported
[WINED3D_GL_PRIMITIVE_QUERY
] = TRUE
;
3638 GL_EXTCALL(glGetQueryiv(GL_PRIMITIVES_GENERATED
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3639 TRACE("Primitives query counter has %d bits.\n", counter_bits
);
3641 gl_info
->supported
[WINED3D_GL_PRIMITIVE_QUERY
] = FALSE
;
3643 GL_EXTCALL(glGetQueryiv(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
, GL_QUERY_COUNTER_BITS
, &counter_bits
));
3644 TRACE("Transform feedback primitives query counter has %d bits.\n", counter_bits
);
3646 gl_info
->supported
[WINED3D_GL_PRIMITIVE_QUERY
] = FALSE
;
3648 if (gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
3650 GLint subpixel_bits
;
3652 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_VIEWPORT_SUBPIXEL_BITS
, &subpixel_bits
);
3653 TRACE("Viewport supports %d subpixel bits.\n", subpixel_bits
);
3654 if (subpixel_bits
< 8 && gl_info
->supported
[ARB_CLIP_CONTROL
])
3656 TRACE("Disabling ARB_clip_control because viewport subpixel bits < 8.\n");
3657 gl_info
->supported
[ARB_CLIP_CONTROL
] = FALSE
;
3659 gl_info
->limits
.viewport_subpixel_bits
= subpixel_bits
;
3661 if (gl_info
->supported
[ARB_CLIP_CONTROL
] && !gl_info
->supported
[ARB_VIEWPORT_ARRAY
])
3663 /* When using ARB_clip_control we need the float viewport parameters
3664 * introduced by ARB_viewport_array to take care of the shifted pixel
3666 TRACE("Disabling ARB_clip_control because ARB_viewport_array is not supported.\n");
3667 gl_info
->supported
[ARB_CLIP_CONTROL
] = FALSE
;
3669 if (gl_info
->supported
[ARB_STENCIL_TEXTURING
] && !gl_info
->supported
[ARB_TEXTURE_SWIZZLE
])
3671 /* The stencil value needs to be placed in the green channel. */
3672 TRACE("Disabling ARB_stencil_texturing because ARB_texture_swizzle is not supported.\n");
3673 gl_info
->supported
[ARB_STENCIL_TEXTURING
] = FALSE
;
3675 if (!gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] && gl_info
->supported
[EXT_TEXTURE_MIRROR_CLAMP
])
3677 TRACE(" IMPLIED: ATI_texture_mirror_once support (by EXT_texture_mirror_clamp).\n");
3678 gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
] = TRUE
;
3680 if (!gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] && gl_info
->supported
[ATI_TEXTURE_MIRROR_ONCE
])
3682 TRACE(" IMPLIED: ARB_texture_mirror_clamp_to_edge support (by ATI_texture_mirror_once).\n");
3683 gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] = TRUE
;
3685 if (gl_info
->supported
[ARB_TEXTURE_STORAGE
] && gl_info
->supported
[APPLE_YCBCR_422
])
3687 /* AFAIK APPLE_ycbcr_422 is only available in legacy contexts so we shouldn't ever hit this. */
3688 ERR("Disabling APPLE_ycbcr_422 because of ARB_texture_storage.\n");
3689 gl_info
->supported
[APPLE_YCBCR_422
] = FALSE
;
3691 if (gl_info
->supported
[ARB_DRAW_INDIRECT
] && !gl_info
->supported
[ARB_BASE_INSTANCE
])
3693 /* If ARB_base_instance is not supported the baseInstance field
3694 * in indirect draw parameters must be 0 or behavior is undefined.
3696 WARN("Disabling ARB_draw_indirect because ARB_base_instance is not supported.\n");
3697 gl_info
->supported
[ARB_DRAW_INDIRECT
] = FALSE
;
3699 if (gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] && !wined3d_settings
.multisample_textures
)
3700 gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] = FALSE
;
3701 if (gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] && !gl_info
->supported
[ARB_TEXTURE_STORAGE_MULTISAMPLE
])
3703 WARN("Disabling ARB_texture_multisample because immutable storage is not supported.\n");
3704 gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
] = FALSE
;
3706 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
] && !gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
])
3708 TRACE(" IMPLIED: GL_EXT_packed_depth_stencil (by GL_ARB_framebuffer_object).\n");
3709 gl_info
->supported
[EXT_PACKED_DEPTH_STENCIL
] = TRUE
;
3712 wined3d_adapter_init_limits(gl_info
);
3714 if (gl_info
->supported
[ARB_VERTEX_PROGRAM
] && test_arb_vs_offset_limit(gl_info
))
3715 gl_info
->quirks
|= WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT
;
3717 if (gl_info
->supported
[ARB_SHADING_LANGUAGE_100
])
3719 const char *str
= (const char *)gl_info
->gl_ops
.gl
.p_glGetString(GL_SHADING_LANGUAGE_VERSION_ARB
);
3720 unsigned int major
, minor
;
3722 TRACE("GLSL version string: %s.\n", debugstr_a(str
));
3724 /* The format of the GLSL version string is "major.minor[.release] [vendor info]". */
3725 sscanf(str
, "%u.%u", &major
, &minor
);
3726 gl_info
->glsl_version
= MAKEDWORD_VERSION(major
, minor
);
3727 if (gl_info
->glsl_version
> MAKEDWORD_VERSION(1, 30) && gl_version
< MAKEDWORD_VERSION(3, 0))
3729 WARN("OpenGL version %u.%u too low, limiting GLSL version to 1.30.\n",
3730 gl_version
>> 16, gl_version
& 0xffff);
3731 gl_info
->glsl_version
= MAKEDWORD_VERSION(1, 30);
3733 if (gl_info
->glsl_version
>= MAKEDWORD_VERSION(1, 30))
3734 gl_info
->supported
[WINED3D_GLSL_130
] = TRUE
;
3737 checkGLcall("extension detection");
3739 adapter
->shader_backend
= select_shader_backend(gl_info
);
3740 adapter
->vertex_pipe
= select_vertex_implementation(gl_info
, adapter
->shader_backend
);
3741 adapter
->fragment_pipe
= select_fragment_implementation(gl_info
, adapter
->shader_backend
);
3743 if (gl_info
->supported
[ARB_FRAMEBUFFER_OBJECT
])
3745 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbuffer
;
3746 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbuffer
;
3747 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffers
;
3748 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffers
;
3749 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorage
;
3750 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisample
;
3751 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameteriv
;
3752 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebuffer
;
3753 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebuffer
;
3754 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffers
;
3755 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffers
;
3756 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatus
;
3757 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1D
;
3758 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2D
;
3759 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3D
;
3760 gl_info
->fbo_ops
.glFramebufferTextureLayer
= gl_info
->gl_ops
.ext
.p_glFramebufferTextureLayer
;
3761 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbuffer
;
3762 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
3763 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameteriv
;
3764 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebuffer
;
3765 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmap
;
3766 gl_info
->fbo_ops
.glFramebufferTexture
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture
;
3770 if (gl_info
->supported
[EXT_FRAMEBUFFER_OBJECT
])
3772 gl_info
->fbo_ops
.glIsRenderbuffer
= gl_info
->gl_ops
.ext
.p_glIsRenderbufferEXT
;
3773 gl_info
->fbo_ops
.glBindRenderbuffer
= gl_info
->gl_ops
.ext
.p_glBindRenderbufferEXT
;
3774 gl_info
->fbo_ops
.glDeleteRenderbuffers
= gl_info
->gl_ops
.ext
.p_glDeleteRenderbuffersEXT
;
3775 gl_info
->fbo_ops
.glGenRenderbuffers
= gl_info
->gl_ops
.ext
.p_glGenRenderbuffersEXT
;
3776 gl_info
->fbo_ops
.glRenderbufferStorage
= gl_info
->gl_ops
.ext
.p_glRenderbufferStorageEXT
;
3777 gl_info
->fbo_ops
.glGetRenderbufferParameteriv
= gl_info
->gl_ops
.ext
.p_glGetRenderbufferParameterivEXT
;
3778 gl_info
->fbo_ops
.glIsFramebuffer
= gl_info
->gl_ops
.ext
.p_glIsFramebufferEXT
;
3779 gl_info
->fbo_ops
.glBindFramebuffer
= gl_info
->gl_ops
.ext
.p_glBindFramebufferEXT
;
3780 gl_info
->fbo_ops
.glDeleteFramebuffers
= gl_info
->gl_ops
.ext
.p_glDeleteFramebuffersEXT
;
3781 gl_info
->fbo_ops
.glGenFramebuffers
= gl_info
->gl_ops
.ext
.p_glGenFramebuffersEXT
;
3782 gl_info
->fbo_ops
.glCheckFramebufferStatus
= gl_info
->gl_ops
.ext
.p_glCheckFramebufferStatusEXT
;
3783 gl_info
->fbo_ops
.glFramebufferTexture1D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture1DEXT
;
3784 gl_info
->fbo_ops
.glFramebufferTexture2D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture2DEXT
;
3785 gl_info
->fbo_ops
.glFramebufferTexture3D
= gl_info
->gl_ops
.ext
.p_glFramebufferTexture3DEXT
;
3786 gl_info
->fbo_ops
.glFramebufferRenderbuffer
= gl_info
->gl_ops
.ext
.p_glFramebufferRenderbufferEXT
;
3787 gl_info
->fbo_ops
.glGetFramebufferAttachmentParameteriv
3788 = gl_info
->gl_ops
.ext
.p_glGetFramebufferAttachmentParameterivEXT
;
3789 gl_info
->fbo_ops
.glGenerateMipmap
= gl_info
->gl_ops
.ext
.p_glGenerateMipmapEXT
;
3791 else if (wined3d_settings
.offscreen_rendering_mode
== ORM_FBO
)
3793 WARN_(d3d_perf
)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
3794 wined3d_settings
.offscreen_rendering_mode
= ORM_BACKBUFFER
;
3797 if (gl_info
->supported
[ARB_GEOMETRY_SHADER4
])
3799 gl_info
->fbo_ops
.glFramebufferTexture
= gl_info
->gl_ops
.ext
.p_glFramebufferTextureARB
;
3800 gl_info
->fbo_ops
.glFramebufferTextureLayer
= gl_info
->gl_ops
.ext
.p_glFramebufferTextureLayerARB
;
3802 if (gl_info
->supported
[EXT_FRAMEBUFFER_BLIT
])
3804 gl_info
->fbo_ops
.glBlitFramebuffer
= gl_info
->gl_ops
.ext
.p_glBlitFramebufferEXT
;
3806 if (gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE
])
3808 gl_info
->fbo_ops
.glRenderbufferStorageMultisample
3809 = gl_info
->gl_ops
.ext
.p_glRenderbufferStorageMultisampleEXT
;
3813 gl_info
->wrap_lookup
[WINED3D_TADDRESS_WRAP
- WINED3D_TADDRESS_WRAP
] = GL_REPEAT
;
3814 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR
- WINED3D_TADDRESS_WRAP
] =
3815 gl_info
->supported
[ARB_TEXTURE_MIRRORED_REPEAT
] ? GL_MIRRORED_REPEAT_ARB
: GL_REPEAT
;
3816 gl_info
->wrap_lookup
[WINED3D_TADDRESS_CLAMP
- WINED3D_TADDRESS_WRAP
] = GL_CLAMP_TO_EDGE
;
3817 gl_info
->wrap_lookup
[WINED3D_TADDRESS_BORDER
- WINED3D_TADDRESS_WRAP
] =
3818 gl_info
->supported
[ARB_TEXTURE_BORDER_CLAMP
] ? GL_CLAMP_TO_BORDER_ARB
: GL_REPEAT
;
3819 gl_info
->wrap_lookup
[WINED3D_TADDRESS_MIRROR_ONCE
- WINED3D_TADDRESS_WRAP
] =
3820 gl_info
->supported
[ARB_TEXTURE_MIRROR_CLAMP_TO_EDGE
] ? GL_MIRROR_CLAMP_TO_EDGE
: GL_REPEAT
;
3822 if (!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
])
3826 GL_EXTCALL(glGenVertexArrays(1, &vao
));
3827 GL_EXTCALL(glBindVertexArray(vao
));
3828 checkGLcall("creating VAO");
3831 gl_vendor
= wined3d_guess_gl_vendor(gl_info
, gl_vendor_str
, gl_renderer_str
, gl_version_str
);
3832 TRACE("Guessed GL vendor %#x.\n", gl_vendor
);
3834 if (!(caps_gl_ctx
->gpu_description
= query_gpu_description(gl_info
, &caps_gl_ctx
->vram_bytes
)))
3836 enum wined3d_feature_level feature_level
;
3837 struct fragment_caps fragment_caps
;
3838 enum wined3d_pci_vendor vendor
;
3839 enum wined3d_pci_device device
;
3840 struct shader_caps shader_caps
;
3842 adapter
->shader_backend
->shader_get_caps(adapter
, &shader_caps
);
3843 adapter
->fragment_pipe
->get_caps(adapter
, &fragment_caps
);
3844 feature_level
= feature_level_from_caps(gl_info
, &shader_caps
, &fragment_caps
);
3846 vendor
= wined3d_guess_card_vendor(gl_vendor_str
, gl_renderer_str
);
3847 TRACE("Guessed vendor PCI ID 0x%04x.\n", vendor
);
3849 device
= wined3d_guess_card(feature_level
, gl_renderer_str
, &gl_vendor
, &vendor
);
3850 TRACE("Guessed device PCI ID 0x%04x.\n", device
);
3852 if (!(caps_gl_ctx
->gpu_description
= wined3d_get_gpu_description(vendor
, device
)))
3854 ERR("Card %04x:%04x not found in driver DB.\n", vendor
, device
);
3858 fixup_extensions(gl_info
, caps_gl_ctx
, gl_renderer_str
, gl_vendor
);
3860 adapter
->vram_bytes_used
= 0;
3861 TRACE("Emulating 0x%s bytes of video ram.\n", wine_dbgstr_longlong(caps_gl_ctx
->vram_bytes
));
3863 if (gl_info
->supported
[EXT_MEMORY_OBJECT
])
3865 GLint device_count
= 0;
3867 gl_info
->gl_ops
.gl
.p_glGetIntegerv(GL_NUM_DEVICE_UUIDS_EXT
, &device_count
);
3868 if (device_count
> 0)
3870 if (device_count
> 1)
3871 FIXME("A set of %d devices is not supported.\n", device_count
);
3873 GL_EXTCALL(glGetUnsignedBytevEXT(GL_DRIVER_UUID_EXT
, (GLubyte
*)&adapter
->driver_uuid
));
3874 GL_EXTCALL(glGetUnsignedBytei_vEXT(GL_DEVICE_UUID_EXT
, 0, (GLubyte
*)&adapter
->device_uuid
));
3876 TRACE("Driver UUID: %s, device UUID %s.\n",
3877 debugstr_guid(&adapter
->driver_uuid
), debugstr_guid(&adapter
->device_uuid
));
3881 WARN("Unexpected device count %d.\n", device_count
);
3885 gl_ext_emul_mask
= adapter
->vertex_pipe
->vp_get_emul_mask(gl_info
)
3886 | adapter
->fragment_pipe
->get_emul_mask(gl_info
);
3887 if (gl_ext_emul_mask
& GL_EXT_EMUL_ARB_MULTITEXTURE
)
3888 install_gl_compat_wrapper(gl_info
, ARB_MULTITEXTURE
);
3889 if (gl_ext_emul_mask
& GL_EXT_EMUL_EXT_FOG_COORD
)
3890 install_gl_compat_wrapper(gl_info
, EXT_FOG_COORD
);
3895 static void WINE_GLAPI
invalid_func(const void *data
)
3897 ERR("Invalid vertex attribute function called.\n");
3901 static void WINE_GLAPI
invalid_texcoord_func(GLenum unit
, const void *data
)
3903 ERR("Invalid texcoord function called.\n");
3907 static void WINE_GLAPI
invalid_generic_attrib_func(GLuint idx
, const void *data
)
3909 ERR("Invalid attribute function called.\n");
3913 /* Helper functions for providing vertex data to OpenGL. The arrays are
3914 * initialised based on the extension detection and are used in
3915 * draw_primitive_immediate_mode(). */
3916 static void WINE_GLAPI
position_d3dcolor(const void *data
)
3918 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3919 DWORD pos
= *((const DWORD
*)data
);
3921 FIXME("Add a test for fixed function position from d3dcolor type.\n");
3922 gl_info
->gl_ops
.gl
.p_glVertex4s(D3DCOLOR_B_R(pos
),
3928 static void WINE_GLAPI
position_float4(const void *data
)
3930 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3931 const GLfloat
*pos
= data
;
3933 if (pos
[3] != 0.0f
&& pos
[3] != 1.0f
)
3935 float w
= 1.0f
/ pos
[3];
3937 gl_info
->gl_ops
.gl
.p_glVertex4f(pos
[0] * w
, pos
[1] * w
, pos
[2] * w
, w
);
3941 gl_info
->gl_ops
.gl
.p_glVertex3fv(pos
);
3945 static void WINE_GLAPI
diffuse_d3dcolor(const void *data
)
3947 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3948 DWORD diffuseColor
= *((const DWORD
*)data
);
3950 gl_info
->gl_ops
.gl
.p_glColor4ub(D3DCOLOR_B_R(diffuseColor
),
3951 D3DCOLOR_B_G(diffuseColor
),
3952 D3DCOLOR_B_B(diffuseColor
),
3953 D3DCOLOR_B_A(diffuseColor
));
3956 static void WINE_GLAPI
specular_d3dcolor(const void *data
)
3958 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3959 DWORD specularColor
= *((const DWORD
*)data
);
3962 D3DCOLOR_B_R(specularColor
),
3963 D3DCOLOR_B_G(specularColor
),
3964 D3DCOLOR_B_B(specularColor
)
3967 gl_info
->gl_ops
.ext
.p_glSecondaryColor3ubvEXT(d
);
3970 static void WINE_GLAPI
warn_no_specular_func(const void *data
)
3972 WARN("GL_EXT_secondary_color not supported.\n");
3975 static void WINE_GLAPI
generic_d3dcolor(GLuint idx
, const void *data
)
3977 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3978 DWORD color
= *((const DWORD
*)data
);
3980 gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nub(idx
,
3981 D3DCOLOR_B_R(color
), D3DCOLOR_B_G(color
),
3982 D3DCOLOR_B_B(color
), D3DCOLOR_B_A(color
));
3985 static void WINE_GLAPI
generic_short2n(GLuint idx
, const void *data
)
3987 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3988 const GLshort s
[] = {((const GLshort
*)data
)[0], ((const GLshort
*)data
)[1], 0, 1};
3990 gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nsv(idx
, s
);
3993 static void WINE_GLAPI
generic_ushort2n(GLuint idx
, const void *data
)
3995 const GLushort s
[] = {((const GLushort
*)data
)[0], ((const GLushort
*)data
)[1], 0, 1};
3996 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
3998 gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nusv(idx
, s
);
4001 static void WINE_GLAPI
generic_float16_2(GLuint idx
, const void *data
)
4003 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
4004 float x
= float_16_to_32(((const unsigned short *)data
) + 0);
4005 float y
= float_16_to_32(((const unsigned short *)data
) + 1);
4007 gl_info
->gl_ops
.ext
.p_glVertexAttrib2f(idx
, x
, y
);
4010 static void WINE_GLAPI
generic_float16_4(GLuint idx
, const void *data
)
4012 const struct wined3d_gl_info
*gl_info
= wined3d_context_gl_get_current()->gl_info
;
4013 float x
= float_16_to_32(((const unsigned short *)data
) + 0);
4014 float y
= float_16_to_32(((const unsigned short *)data
) + 1);
4015 float z
= float_16_to_32(((const unsigned short *)data
) + 2);
4016 float w
= float_16_to_32(((const unsigned short *)data
) + 3);
4018 gl_info
->gl_ops
.ext
.p_glVertexAttrib4f(idx
, x
, y
, z
, w
);
4021 static void wined3d_adapter_init_ffp_attrib_ops(struct wined3d_adapter
*adapter
)
4023 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_info
;
4024 struct wined3d_d3d_info
*d3d_info
= &adapter
->d3d_info
;
4025 struct wined3d_ffp_attrib_ops
*ops
= &d3d_info
->ffp_attrib_ops
;
4028 for (i
= 0; i
< WINED3D_FFP_EMIT_COUNT
; ++i
)
4030 ops
->position
[i
] = invalid_func
;
4031 ops
->diffuse
[i
] = invalid_func
;
4032 ops
->specular
[i
] = invalid_func
;
4033 ops
->normal
[i
] = invalid_func
;
4034 ops
->texcoord
[i
] = invalid_texcoord_func
;
4035 ops
->generic
[i
] = invalid_generic_attrib_func
;
4038 ops
->position
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex3fv
;
4039 if (!d3d_info
->xyzrhw
)
4040 ops
->position
[WINED3D_FFP_EMIT_FLOAT4
] = position_float4
;
4042 ops
->position
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex4fv
;
4043 ops
->position
[WINED3D_FFP_EMIT_D3DCOLOR
] = position_d3dcolor
;
4044 ops
->position
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glVertex2sv
;
4046 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor3fv
;
4047 ops
->diffuse
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4fv
;
4048 ops
->diffuse
[WINED3D_FFP_EMIT_D3DCOLOR
] = diffuse_d3dcolor
;
4049 ops
->diffuse
[WINED3D_FFP_EMIT_UBYTE4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4ubv
;
4050 ops
->diffuse
[WINED3D_FFP_EMIT_SHORT4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4sv
;
4051 ops
->diffuse
[WINED3D_FFP_EMIT_USHORT4N
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glColor4usv
;
4053 /* No 4 component entry points here. */
4054 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4055 ops
->specular
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)GL_EXTCALL(glSecondaryColor3fvEXT
);
4057 ops
->specular
[WINED3D_FFP_EMIT_FLOAT3
] = warn_no_specular_func
;
4058 if (gl_info
->supported
[EXT_SECONDARY_COLOR
])
4059 ops
->specular
[WINED3D_FFP_EMIT_D3DCOLOR
] = specular_d3dcolor
;
4061 ops
->specular
[WINED3D_FFP_EMIT_D3DCOLOR
] = warn_no_specular_func
;
4063 /* Only 3 component entry points here. Test how others behave. Float4
4064 * normals are used by one of our tests, trying to pass it to the pixel
4065 * shader, which fails on Windows. */
4066 ops
->normal
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
4067 /* Just ignore the 4th value. */
4068 ops
->normal
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_attrib_func
)gl_info
->gl_ops
.gl
.p_glNormal3fv
;
4070 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT1
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord1fvARB
;
4071 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT2
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2fvARB
;
4072 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord3fvARB
;
4073 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4fvARB
;
4074 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT2
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2svARB
;
4075 ops
->texcoord
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4svARB
;
4076 if (gl_info
->supported
[NV_HALF_FLOAT
])
4078 /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT. */
4079 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_2
] =
4080 (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord2hvNV
;
4081 ops
->texcoord
[WINED3D_FFP_EMIT_FLOAT16_4
] =
4082 (wined3d_ffp_texcoord_func
)gl_info
->gl_ops
.ext
.p_glMultiTexCoord4hvNV
;
4085 ops
->generic
[WINED3D_FFP_EMIT_FLOAT1
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib1fv
;
4086 ops
->generic
[WINED3D_FFP_EMIT_FLOAT2
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib2fv
;
4087 ops
->generic
[WINED3D_FFP_EMIT_FLOAT3
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib3fv
;
4088 ops
->generic
[WINED3D_FFP_EMIT_FLOAT4
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4fv
;
4089 if (gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
])
4090 ops
->generic
[WINED3D_FFP_EMIT_D3DCOLOR
] = generic_d3dcolor
;
4092 ops
->generic
[WINED3D_FFP_EMIT_D3DCOLOR
] =
4093 (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nubv
;
4094 ops
->generic
[WINED3D_FFP_EMIT_UBYTE4
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4ubv
;
4095 ops
->generic
[WINED3D_FFP_EMIT_SHORT2
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib2sv
;
4096 ops
->generic
[WINED3D_FFP_EMIT_SHORT4
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4sv
;
4097 ops
->generic
[WINED3D_FFP_EMIT_UBYTE4N
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nubv
;
4098 ops
->generic
[WINED3D_FFP_EMIT_SHORT2N
] = generic_short2n
;
4099 ops
->generic
[WINED3D_FFP_EMIT_SHORT4N
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nsv
;
4100 ops
->generic
[WINED3D_FFP_EMIT_USHORT2N
] = generic_ushort2n
;
4101 ops
->generic
[WINED3D_FFP_EMIT_USHORT4N
] = (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4Nusv
;
4102 if (gl_info
->supported
[NV_HALF_FLOAT
] && gl_info
->supported
[NV_VERTEX_PROGRAM
])
4104 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_2
] =
4105 (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib2hvNV
;
4106 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_4
] =
4107 (wined3d_generic_attrib_func
)gl_info
->gl_ops
.ext
.p_glVertexAttrib4hvNV
;
4111 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_2
] = generic_float16_2
;
4112 ops
->generic
[WINED3D_FFP_EMIT_FLOAT16_4
] = generic_float16_4
;
4116 static void wined3d_adapter_init_fb_cfgs(struct wined3d_adapter_gl
*adapter_gl
, HDC dc
)
4118 const struct wined3d_gl_info
*gl_info
= &adapter_gl
->a
.gl_info
;
4121 if (gl_info
->supported
[WGL_ARB_PIXEL_FORMAT
])
4123 UINT attrib_count
= 0;
4129 attribute
= WGL_NUMBER_PIXEL_FORMATS_ARB
;
4130 GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, 0, 0, 1, &attribute
, &cfg_count
));
4132 adapter_gl
->pixel_formats
= heap_calloc(cfg_count
, sizeof(*adapter_gl
->pixel_formats
));
4133 attribs
[attrib_count
++] = WGL_RED_BITS_ARB
;
4134 attribs
[attrib_count
++] = WGL_GREEN_BITS_ARB
;
4135 attribs
[attrib_count
++] = WGL_BLUE_BITS_ARB
;
4136 attribs
[attrib_count
++] = WGL_ALPHA_BITS_ARB
;
4137 attribs
[attrib_count
++] = WGL_COLOR_BITS_ARB
;
4138 attribs
[attrib_count
++] = WGL_DEPTH_BITS_ARB
;
4139 attribs
[attrib_count
++] = WGL_STENCIL_BITS_ARB
;
4140 attribs
[attrib_count
++] = WGL_DRAW_TO_WINDOW_ARB
;
4141 attribs
[attrib_count
++] = WGL_PIXEL_TYPE_ARB
;
4142 attribs
[attrib_count
++] = WGL_DOUBLE_BUFFER_ARB
;
4143 attribs
[attrib_count
++] = WGL_AUX_BUFFERS_ARB
;
4144 attribs
[attrib_count
++] = WGL_SWAP_METHOD_ARB
;
4146 for (i
= 0, adapter_gl
->pixel_format_count
= 0; i
< cfg_count
; ++i
)
4148 struct wined3d_pixel_format
*cfg
= &adapter_gl
->pixel_formats
[adapter_gl
->pixel_format_count
];
4149 int format_id
= i
+ 1;
4151 if (!GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, format_id
, 0, attrib_count
, attribs
, values
)))
4154 cfg
->iPixelFormat
= format_id
;
4155 cfg
->redSize
= values
[0];
4156 cfg
->greenSize
= values
[1];
4157 cfg
->blueSize
= values
[2];
4158 cfg
->alphaSize
= values
[3];
4159 cfg
->colorSize
= values
[4];
4160 cfg
->depthSize
= values
[5];
4161 cfg
->stencilSize
= values
[6];
4162 cfg
->windowDrawable
= values
[7];
4163 cfg
->iPixelType
= values
[8];
4164 cfg
->doubleBuffer
= values
[9];
4165 cfg
->auxBuffers
= values
[10];
4166 cfg
->swap_method
= values
[11];
4168 cfg
->numSamples
= 0;
4169 /* Check multisample support. */
4170 if (gl_info
->supported
[ARB_MULTISAMPLE
])
4172 int attribs
[2] = {WGL_SAMPLE_BUFFERS_ARB
, WGL_SAMPLES_ARB
};
4175 if (GL_EXTCALL(wglGetPixelFormatAttribivARB(dc
, format_id
, 0, 2, attribs
, values
)))
4177 /* values[0] = WGL_SAMPLE_BUFFERS_ARB which tells whether
4178 * multisampling is supported. values[1] = number of
4179 * multisample buffers. */
4181 cfg
->numSamples
= values
[1];
4185 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4186 "depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
4187 cfg
->iPixelFormat
, cfg
->iPixelType
, cfg
->doubleBuffer
,
4188 cfg
->redSize
, cfg
->greenSize
, cfg
->blueSize
, cfg
->alphaSize
,
4189 cfg
->depthSize
, cfg
->stencilSize
, cfg
->numSamples
, cfg
->windowDrawable
);
4191 ++adapter_gl
->pixel_format_count
;
4198 cfg_count
= DescribePixelFormat(dc
, 0, 0, 0);
4199 adapter_gl
->pixel_formats
= heap_calloc(cfg_count
, sizeof(*adapter_gl
->pixel_formats
));
4201 for (i
= 0, adapter_gl
->pixel_format_count
= 0; i
< cfg_count
; ++i
)
4203 struct wined3d_pixel_format
*cfg
= &adapter_gl
->pixel_formats
[adapter_gl
->pixel_format_count
];
4204 PIXELFORMATDESCRIPTOR pfd
;
4205 int format_id
= i
+ 1;
4207 if (!DescribePixelFormat(dc
, format_id
, sizeof(pfd
), &pfd
))
4210 /* We only want HW acceleration using an OpenGL ICD driver.
4211 * PFD_GENERIC_FORMAT = slow OpenGL 1.1 GDI software rendering.
4212 * PFD_GENERIC_ACCELERATED = partial hw acceleration using a MCD
4213 * driver (e.g. 3dfx minigl). */
4214 if (pfd
.dwFlags
& (PFD_GENERIC_FORMAT
| PFD_GENERIC_ACCELERATED
))
4216 TRACE("Skipping format %d because it isn't ICD accelerated.\n", format_id
);
4220 cfg
->iPixelFormat
= format_id
;
4221 cfg
->redSize
= pfd
.cRedBits
;
4222 cfg
->greenSize
= pfd
.cGreenBits
;
4223 cfg
->blueSize
= pfd
.cBlueBits
;
4224 cfg
->alphaSize
= pfd
.cAlphaBits
;
4225 cfg
->colorSize
= pfd
.cColorBits
;
4226 cfg
->depthSize
= pfd
.cDepthBits
;
4227 cfg
->stencilSize
= pfd
.cStencilBits
;
4228 cfg
->windowDrawable
= (pfd
.dwFlags
& PFD_DRAW_TO_WINDOW
) ? 1 : 0;
4229 cfg
->iPixelType
= (pfd
.iPixelType
== PFD_TYPE_RGBA
) ? WGL_TYPE_RGBA_ARB
: WGL_TYPE_COLORINDEX_ARB
;
4230 cfg
->doubleBuffer
= (pfd
.dwFlags
& PFD_DOUBLEBUFFER
) ? 1 : 0;
4231 cfg
->auxBuffers
= pfd
.cAuxBuffers
;
4232 cfg
->swap_method
= WGL_SWAP_UNDEFINED_ARB
;
4233 cfg
->numSamples
= 0;
4235 TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
4236 "depth=%d, stencil=%d, windowDrawable=%d\n",
4237 cfg
->iPixelFormat
, cfg
->iPixelType
, cfg
->doubleBuffer
,
4238 cfg
->redSize
, cfg
->greenSize
, cfg
->blueSize
, cfg
->alphaSize
,
4239 cfg
->depthSize
, cfg
->stencilSize
, cfg
->windowDrawable
);
4241 ++adapter_gl
->pixel_format_count
;
4246 static void adapter_gl_destroy(struct wined3d_adapter
*adapter
)
4248 struct wined3d_adapter_gl
*adapter_gl
= wined3d_adapter_gl(adapter
);
4250 heap_free(adapter_gl
->pixel_formats
);
4251 wined3d_adapter_cleanup(adapter
);
4252 heap_free(adapter_gl
);
4255 static HRESULT
adapter_gl_create_device(struct wined3d
*wined3d
, const struct wined3d_adapter
*adapter
,
4256 enum wined3d_device_type device_type
, HWND focus_window
, unsigned int flags
, BYTE surface_alignment
,
4257 const enum wined3d_feature_level
*levels
, unsigned int level_count
,
4258 struct wined3d_device_parent
*device_parent
, struct wined3d_device
**device
)
4260 struct wined3d_device_gl
*device_gl
;
4263 if (!(device_gl
= heap_alloc_zero(sizeof(*device_gl
))))
4264 return E_OUTOFMEMORY
;
4266 device_gl
->current_fence_id
= 1;
4268 if (FAILED(hr
= wined3d_device_init(&device_gl
->d
, wined3d
, adapter
->ordinal
, device_type
, focus_window
,
4269 flags
, surface_alignment
, levels
, level_count
, adapter
->gl_info
.supported
, device_parent
)))
4271 WARN("Failed to initialize device, hr %#x.\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_d3d_info
*d3d_info
= &adapter
->d3d_info
;
4307 const struct wined3d_gl_info
*gl_info
= &adapter
->gl_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
->flags
[WINED3D_GL_RES_TYPE_TEX_2D
] & WINED3DFMT_FLAG_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
->flags
[WINED3D_GL_RES_TYPE_TEX_2D
] & WINED3DFMT_FLAG_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 (!wined3d_swapchain_gl(device
->swapchains
[0])->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
)
4606 wined3d_context_gl_copy_bo_address(wined3d_context_gl(context
), dst
, src
, range_count
, ranges
);
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
= &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 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 %#x.\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 %#x.\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 %#x.\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 %#x.\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 %#x.\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 %#x.\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
->a
.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
;
5202 gl_info
->gl_ops
.gl
.p_glGetFloatv(gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
]
5203 ? GL_ALIASED_POINT_SIZE_RANGE
: GL_POINT_SIZE_RANGE
, f
);
5204 d3d_info
->limits
.pointsize_max
= f
[1];
5205 TRACE("Maximum point size support - max point size %.8e.\n", f
[1]);
5207 d3d_info
->wined3d_creation_flags
= wined3d_creation_flags
;
5208 d3d_info
->xyzrhw
= vertex_caps
.xyzrhw
;
5209 d3d_info
->emulated_flatshading
= vertex_caps
.emulated_flatshading
;
5210 d3d_info
->ffp_generic_attributes
= vertex_caps
.ffp_generic_attributes
;
5211 d3d_info
->ffp_alpha_test
= !!gl_info
->supported
[WINED3D_GL_LEGACY_CONTEXT
];
5212 d3d_info
->vs_clipping
= shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_VS_CLIPPING
;
5213 d3d_info
->shader_color_key
= !!(fragment_caps
.wined3d_caps
& WINED3D_FRAGMENT_CAP_COLOR_KEY
);
5214 d3d_info
->shader_double_precision
= !!(shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_DOUBLE_PRECISION
);
5215 d3d_info
->shader_output_interpolation
= !!(shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_OUTPUT_INTERPOLATION
);
5216 d3d_info
->frag_coord_correction
= !!gl_info
->supported
[ARB_FRAGMENT_COORD_CONVENTIONS
];
5217 d3d_info
->viewport_array_index_any_shader
= !!gl_info
->supported
[ARB_SHADER_VIEWPORT_LAYER_ARRAY
];
5218 d3d_info
->texture_npot
= !!gl_info
->supported
[ARB_TEXTURE_NON_POWER_OF_TWO
];
5219 d3d_info
->texture_npot_conditional
= gl_info
->supported
[WINED3D_GL_NORMALIZED_TEXRECT
]
5220 || gl_info
->supported
[ARB_TEXTURE_RECTANGLE
];
5221 d3d_info
->draw_base_vertex_offset
= !!gl_info
->supported
[ARB_DRAW_ELEMENTS_BASE_VERTEX
];
5222 d3d_info
->vertex_bgra
= !!gl_info
->supported
[ARB_VERTEX_ARRAY_BGRA
];
5223 d3d_info
->texture_swizzle
= !!gl_info
->supported
[ARB_TEXTURE_SWIZZLE
];
5224 d3d_info
->srgb_read_control
= !!gl_info
->supported
[EXT_TEXTURE_SRGB_DECODE
];
5225 d3d_info
->srgb_write_control
= !!gl_info
->supported
[ARB_FRAMEBUFFER_SRGB
];
5226 d3d_info
->clip_control
= !!gl_info
->supported
[ARB_CLIP_CONTROL
];
5227 d3d_info
->full_ffp_varyings
= !!(shader_caps
.wined3d_caps
& WINED3D_SHADER_CAP_FULL_FFP_VARYINGS
);
5228 d3d_info
->scaled_resolve
= !!gl_info
->supported
[EXT_FRAMEBUFFER_MULTISAMPLE_BLIT_SCALED
];
5229 d3d_info
->pbo
= !!gl_info
->supported
[ARB_PIXEL_BUFFER_OBJECT
];
5230 d3d_info
->subpixel_viewport
= gl_info
->limits
.viewport_subpixel_bits
>= 8;
5231 d3d_info
->feature_level
= feature_level_from_caps(gl_info
, &shader_caps
, &fragment_caps
);
5232 d3d_info
->filling_convention_offset
= gl_info
->filling_convention_offset
;
5234 if (gl_info
->supported
[ARB_TEXTURE_MULTISAMPLE
])
5235 d3d_info
->multisample_draw_location
= WINED3D_LOCATION_TEXTURE_RGB
;
5237 d3d_info
->multisample_draw_location
= WINED3D_LOCATION_RB_MULTISAMPLE
;
5240 static float wined3d_adapter_find_fill_offset(struct wined3d_caps_gl_ctx
*ctx
)
5242 static const float test_array
[] =
5251 unsigned int upper
= ARRAY_SIZE(test_array
), lower
= 0, test
;
5254 if (wined3d_settings
.offscreen_rendering_mode
!= ORM_FBO
)
5257 while (upper
!= lower
)
5259 test
= (upper
+ lower
) / 2;
5260 value
= test_array
[test
];
5261 TRACE("Good %u lower %u, test %u.\n", upper
, lower
, test
);
5262 if (wined3d_caps_gl_ctx_test_filling_convention(ctx
, value
))
5268 if (upper
< ARRAY_SIZE(test_array
))
5270 value
= test_array
[upper
];
5272 WARN("Using a filling convention fixup offset of -1/%f.\n", -1.0f
/ value
);
5274 TRACE("No need for a filling convention offset.\n");
5279 FIXME("Did not find a way to get the filling convention we want.\n");
5282 /* This value was used unconditionally before the dynamic test function was
5284 return -1.0f
/ 64.0f
;
5287 static BOOL
wined3d_adapter_gl_init(struct wined3d_adapter_gl
*adapter_gl
,
5288 unsigned int ordinal
, unsigned int wined3d_creation_flags
)
5290 static const DWORD supported_gl_versions
[] =
5292 MAKEDWORD_VERSION(4, 4),
5293 MAKEDWORD_VERSION(3, 2),
5294 MAKEDWORD_VERSION(1, 0),
5296 struct wined3d_driver_info
*driver_info
= &adapter_gl
->a
.driver_info
;
5297 struct wined3d_gl_info
*gl_info
= &adapter_gl
->a
.gl_info
;
5298 struct wined3d_caps_gl_ctx caps_gl_ctx
= {0};
5299 LUID primary_luid
, *luid
= NULL
;
5302 TRACE("adapter_gl %p, ordinal %u, wined3d_creation_flags %#x.\n",
5303 adapter_gl
, ordinal
, wined3d_creation_flags
);
5305 if (ordinal
== 0 && wined3d_get_primary_adapter_luid(&primary_luid
))
5306 luid
= &primary_luid
;
5308 if (!wined3d_adapter_init(&adapter_gl
->a
, ordinal
, luid
, &wined3d_adapter_gl_ops
))
5311 /* Dynamically load all GL core functions */
5312 #ifdef USE_WIN32_OPENGL
5314 HMODULE mod_gl
= GetModuleHandleA("opengl32.dll");
5315 #define USE_GL_FUNC(f) gl_info->gl_ops.gl.p_##f = (void *)GetProcAddress(mod_gl, #f);
5318 gl_info
->gl_ops
.wgl
.p_wglSwapBuffers
= (void *)GetProcAddress(mod_gl
, "wglSwapBuffers");
5319 gl_info
->gl_ops
.wgl
.p_wglGetPixelFormat
= (void *)GetProcAddress(mod_gl
, "wglGetPixelFormat");
5322 /* To bypass the opengl32 thunks retrieve functions from the WGL driver instead of opengl32 */
5324 HDC hdc
= GetDC( 0 );
5325 const struct opengl_funcs
*wgl_driver
= __wine_get_wgl_driver( hdc
, WINE_WGL_DRIVER_VERSION
);
5326 ReleaseDC( 0, hdc
);
5327 if (!wgl_driver
|| wgl_driver
== (void *)-1) return FALSE
;
5328 gl_info
->gl_ops
.wgl
= wgl_driver
->wgl
;
5329 gl_info
->gl_ops
.gl
= wgl_driver
->gl
;
5333 gl_info
->p_glEnableWINE
= gl_info
->gl_ops
.gl
.p_glEnable
;
5334 gl_info
->p_glDisableWINE
= gl_info
->gl_ops
.gl
.p_glDisable
;
5336 if (!wined3d_caps_gl_ctx_create(&adapter_gl
->a
, &caps_gl_ctx
))
5338 ERR("Failed to get a GL context for adapter %p.\n", adapter_gl
);
5342 for (i
= 0; i
< ARRAY_SIZE(supported_gl_versions
); ++i
)
5344 if (supported_gl_versions
[i
] <= wined3d_settings
.max_gl_version
)
5347 if (i
== ARRAY_SIZE(supported_gl_versions
))
5349 ERR_(winediag
)("Requested invalid GL version %u.%u.\n",
5350 wined3d_settings
.max_gl_version
>> 16, wined3d_settings
.max_gl_version
& 0xffff);
5351 i
= ARRAY_SIZE(supported_gl_versions
) - 1;
5354 for (; i
< ARRAY_SIZE(supported_gl_versions
); ++i
)
5356 gl_info
->selected_gl_version
= supported_gl_versions
[i
];
5358 if (wined3d_caps_gl_ctx_create_attribs(&caps_gl_ctx
, gl_info
))
5361 WARN("Couldn't create an OpenGL %u.%u context, trying fallback to a lower version.\n",
5362 supported_gl_versions
[i
] >> 16, supported_gl_versions
[i
] & 0xffff);
5365 if (!wined3d_adapter_init_gl_caps(&adapter_gl
->a
, &caps_gl_ctx
, wined3d_creation_flags
))
5367 ERR("Failed to initialize GL caps for adapter %p.\n", adapter_gl
);
5368 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5372 gl_info
->filling_convention_offset
= wined3d_adapter_find_fill_offset(&caps_gl_ctx
);
5374 wined3d_adapter_gl_init_d3d_info(adapter_gl
, wined3d_creation_flags
);
5376 if (!adapter_gl
->a
.d3d_info
.shader_color_key
)
5378 /* We do not want to deal with re-creating immutable texture storage
5379 * for colour-keying emulation. */
5380 WARN("Disabling ARB_texture_storage because fragment pipe doesn't support colour-keying.\n");
5381 gl_info
->supported
[ARB_TEXTURE_STORAGE
] = FALSE
;
5384 if (!wined3d_driver_info_init(driver_info
, caps_gl_ctx
.gpu_description
, adapter_gl
->a
.d3d_info
.feature_level
,
5385 caps_gl_ctx
.vram_bytes
, 0))
5387 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5390 TRACE("Reporting (fake) driver version 0x%08x-0x%08x.\n",
5391 driver_info
->version_high
, driver_info
->version_low
);
5393 if (wined3d_settings
.offscreen_rendering_mode
== ORM_BACKBUFFER
)
5394 ERR_(winediag
)("You are using the backbuffer for offscreen rendering. "
5395 "This is unsupported, and will be removed in a future version.\n");
5397 wined3d_adapter_init_fb_cfgs(adapter_gl
, caps_gl_ctx
.dc
);
5398 /* We haven't found any suitable formats. This should only happen in
5399 * case of GDI software rendering, which is pretty useless anyway. */
5400 if (!adapter_gl
->pixel_format_count
)
5402 WARN("No suitable pixel formats found.\n");
5403 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5404 heap_free(adapter_gl
->pixel_formats
);
5408 if (!wined3d_adapter_gl_init_format_info(&adapter_gl
->a
, &caps_gl_ctx
))
5410 ERR("Failed to initialize GL format info.\n");
5411 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5412 heap_free(adapter_gl
->pixel_formats
);
5416 wined3d_caps_gl_ctx_destroy(&caps_gl_ctx
);
5418 wined3d_adapter_init_ffp_attrib_ops(&adapter_gl
->a
);
5423 struct wined3d_adapter
*wined3d_adapter_gl_create(unsigned int ordinal
, unsigned int wined3d_creation_flags
)
5425 struct wined3d_adapter_gl
*adapter
;
5427 if (!(adapter
= heap_alloc_zero(sizeof(*adapter
))))
5430 if (!wined3d_adapter_gl_init(adapter
, ordinal
, wined3d_creation_flags
))
5436 TRACE("Created adapter %p.\n", adapter
);