30#include "wine/winternl.h"
36#define DEFAULT_REFRESH_RATE 0
94static const GUID IID_D3DDEVICE_D3DUID = { 0xaeb2cdd4, 0x6e41, 0x43ea, { 0x94,0x1c,0x83,0x61,0xcc,0x76,0x07,0x81 } };
309 TRACE(
"Destroying caps GL context.\n");
314 if (
ctx->test_program_id ||
ctx->test_vbo)
321 ERR(
"Failed to disable caps GL context.\n");
326 ERR(
"wglDeleteContext(%p) failed, last error %#x.\n",
ctx->gl_ctx,
err);
333 ERR(
"Failed to restore previous GL context.\n");
341 if (!(gl_info->p_wglCreateContextAttribsARB = (
void *)
wglGetProcAddress(
"wglCreateContextAttribsARB")))
346 gl_info->p_wglCreateContextAttribsARB =
NULL;
352 ERR(
"Failed to make new context current, last error %#x.\n",
GetLastError());
354 ERR(
"Failed to delete new context, last error %#x.\n",
GetLastError());
355 gl_info->p_wglCreateContextAttribsARB =
NULL;
360 ERR(
"Failed to delete old context, last error %#x.\n",
GetLastError());
361 caps_gl_ctx->
gl_ctx = new_ctx;
371 TRACE(
"getting context...\n");
381 ERR(
"Failed to create a window.\n");
388 ERR(
"Failed to get a DC.\n");
404 ERR(
"Failed to find a suitable pixel format.\n");
413 WARN(
"Failed to create default context for capabilities initialization.\n");
420 ERR(
"Failed to make caps GL context current.\n");
435 ERR(
"Failed to restore previous GL context.\n");
443 adapter->vram_bytes_used += amount;
444 TRACE(
"Adjusted used adapter memory by 0x%s to 0x%s.\n",
447 return adapter->vram_bytes_used;
460 TRACE(
"%p increasing refcount to %u.\n",
wined3d, refcount);
469 TRACE(
"%p decreasing refcount to %u.\n",
wined3d, refcount);
490 static const char testcode[] =
492 "PARAM C[66] = { program.env[0..65] };\n"
494 "PARAM zero = {0.0, 0.0, 0.0, 0.0};\n"
495 "ARL A0.x, zero.x;\n"
496 "MOV result.position, C[A0.x + 65];\n"
499 while (gl_info->
gl_ops.gl.p_glGetError());
502 ERR(
"Failed to create an ARB offset limit test program\n");
506 strlen(testcode), testcode));
507 if (gl_info->
gl_ops.gl.p_glGetError())
509 TRACE(
"OpenGL implementation does not allow indirect addressing offsets > 63\n");
512 }
else TRACE(
"OpenGL implementation allows offsets > 63\n");
583 static const unsigned int pattern[] =
585 0x00000000, 0x000000ff, 0x0000ff00, 0x40ff0000,
586 0x80ffffff, 0x40ffff00, 0x00ff00ff, 0x0000ffff,
587 0x00ffff00, 0x00ff00ff, 0x0000ffff, 0x000000ff,
588 0x80ff00ff, 0x0000ffff, 0x00ff00ff, 0x40ff00ff
595 while (gl_info->
gl_ops.gl.p_glGetError());
613 gl_info->
gl_ops.gl.p_glFinish();
625 WARN_(d3d_perf)(
"PBO test failed, read back data doesn't match original.\n"
626 "Disabling PBOs. This may result in slower performance.\n");
631 TRACE(
"PBO test successful.\n");
663 return gl_info->
limits.glsl_varyings > 44;
684 while (gl_info->
gl_ops.gl.p_glGetError());
690 TRACE(
"GL Implementation accepts 4 component specular color pointers\n");
695 TRACE(
"GL implementation does not accept 4 component specular colors, error %s\n",
709 static const char testcode[] =
711 "OPTION NV_vertex_program2;\n"
712 "MOV result.clip[0], 0.0;\n"
713 "MOV result.position, 0.0;\n"
718 while (gl_info->
gl_ops.gl.p_glGetError());
723 ERR(
"Failed to create the NVvp clip test program\n");
728 strlen(testcode), testcode));
732 WARN(
"GL_NV_vertex_program2_option result.clip[] test failed\n");
735 while (gl_info->
gl_ops.gl.p_glGetError());
737 else TRACE(
"GL_NV_vertex_program2_option result.clip[] test passed\n");
741 checkGLcall(
"GL_NV_vertex_program2_option result.clip[] test cleanup");
751 char data[4 * 4 * 4];
759 gl_info->
gl_ops.gl.p_glGenTextures(1, &tex);
766 gl_info->
fbo_ops.glGenFramebuffers(1, &fbo);
779 gl_info->
gl_ops.gl.p_glClearColor(0.996f, 0.729f, 0.745f, 0.792f);
791 gl_info->
fbo_ops.glDeleteFramebuffers(1, &fbo);
792 gl_info->
gl_ops.gl.p_glDeleteTextures(1, &tex);
808 gl_info->
gl_ops.gl.p_glGenTextures(1, &tex);
819 gl_info->
gl_ops.gl.p_glDeleteTextures(1, &tex);
848 float color[4] = {0.0f, 1.0f, 0.0f, 0.0f};
851 static const char program_code[] =
853 "OPTION ARB_fog_linear;\n"
854 "MOV result.color, {1.0, 0.0, 0.0, 0.0};\n"
862 gl_info->
gl_ops.gl.p_glGenTextures(1, &tex);
869 gl_info->
fbo_ops.glGenFramebuffers(1, &fbo);
878 gl_info->
gl_ops.gl.p_glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
881 gl_info->
gl_ops.gl.p_glViewport(0, 0, 4, 1);
895 strlen(program_code), program_code));
902 const char *error_str;
904 FIXME(
"Fog test program error at position %d: %s\n\n", err_pos,
debugstr_a(error_str));
908 gl_info->
gl_ops.gl.p_glVertex3f(-1.0f, -1.0f, 0.0f);
909 gl_info->
gl_ops.gl.p_glVertex3f( 1.0f, -1.0f, 1.0f);
910 gl_info->
gl_ops.gl.p_glVertex3f(-1.0f, 1.0f, 0.0f);
911 gl_info->
gl_ops.gl.p_glVertex3f( 1.0f, 1.0f, 1.0f);
912 gl_info->
gl_ops.gl.p_glEnd();
917 data[0] &= 0x00ffffff;
918 data[1] &= 0x00ffffff;
919 data[2] &= 0x00ffffff;
920 data[3] &= 0x00ffffff;
925 gl_info->
fbo_ops.glDeleteFramebuffers(1, &fbo);
926 gl_info->
gl_ops.gl.p_glDeleteTextures(1, &tex);
934 return data[0] != 0x00ff0000 ||
data[3] != 0x0000ff00;
953 TRACE(
"Reserving 12 GLSL constants for compiler private use.\n");
972 TRACE(
"GL_ARB_texture_non_power_of_two advertised on R500 or earlier card, removing.\n");
994 TRACE(
"GL_ARB_texture_non_power_of_two advertised through OpenGL 2.0 on NV FX card, removing.\n");
1014 TRACE(
"Enabling vertex texture coord fixes in vertex shaders.\n");
1067 TRACE(
"Reserving 1 ARB constant for compiler private use.\n");
1080 TRACE(
"Disabling ARB_clip_control.\n");
1099 "AMD normalized texrect quirk"
1104 "Apple GLSL uniform override"
1109 "Geforce 5 NP2 disable"
1114 "Init texcoord .w for Apple Intel GPU driver"
1119 "Init texcoord .w for Apple ATI >= r600 GPU driver"
1124 "Reserved varying for gl_ClipPos"
1139 "Allow specular alpha quirk"
1144 "Apple NV_vertex_program clip bug quirk"
1149 "FBO rebind for attachment updates"
1154 "True RGBA16 is not available"
1159 "Not printing GLSL infolog"
1164 "Texture filtering, blending and VTF support is limited"
1169 "r200 vertex shader constants"
1174 "ARBfp fogstart == fogend workaround"
1179 "Nvidia viewport subpixel bits bug"
1544 TRACE(
"Found driver \"%s\", version %u, subversion %u, build %u.\n",
1571 static unsigned int once;
1583 TRACE(
"Card reports vendor PCI ID 0x%04x, device PCI ID 0x%04x, 0x%s bytes of video memory.\n",
1591 *vram_bytes = (
UINT64)vram_kb * 1024;
1592 TRACE(
"Got 0x%s as video memory from NVX_GPU_MEMORY_INFO extension.\n",
1599 TRACE(
"Overriding vendor PCI ID with 0x%04x.\n",
vendor);
1605 TRACE(
"Overriding device PCI ID with 0x%04x.\n",
device);
1611 TRACE(
"Overriding amount of video memory with 0x%s bytes.\n",
1618 ERR_(winediag)(
"Invalid GPU override %04x:%04x specified, ignoring.\n",
vendor,
device);
1627 WORD driver_os_version;
1632 memset(&os_version, 0,
sizeof(os_version));
1636 ERR(
"Failed to get OS version, reporting 2000/XP.\n");
1637 driver_os_version = 6;
1649 driver_os_version = 4;
1654 driver_os_version = 6;
1661 driver_os_version = 7;
1666 driver_os_version = 8;
1673 FIXME(
"Unhandled OS version %u.%u, reporting Win 8.\n",
1676 driver_os_version = 9;
1682 driver_os_version = 10;
1687 FIXME(
"Unhandled OS version %u.%u, reporting 2000/XP.\n",
1689 driver_os_version = 6;
1707 if (driver_model < DRIVER_MODEL_NT6X && driver_info->vram_bytes >
LONG_MAX)
1709 TRACE(
"Limiting amount of video memory to %#lx bytes for OS version older than Vista.\n",
LONG_MAX);
1736 ERR(
"No driver version info found for device %04x:%04x, driver model %#x.\n",
1738 driver_info->
name =
"Display";
1743 TRACE(
"Reporting (fake) driver version 0x%08x-0x%08x.\n",
1767 const char *
ptr = gl_version;
1772 ERR(
"Invalid OpenGL major version %d.\n",
major);
1776 ERR(
"Invalid OpenGL version string %s.\n",
debugstr_a(gl_version));
1786 const char *gl_vendor_string,
const char *gl_renderer,
const char *gl_version)
1802 if (
strstr(gl_vendor_string,
"NVIDIA"))
1805 if (
strstr(gl_vendor_string,
"ATI"))
1808 if (
strstr(gl_vendor_string,
"Mesa")
1809 ||
strstr(gl_vendor_string,
"Brian Paul")
1810 ||
strstr(gl_vendor_string,
"X.Org")
1811 ||
strstr(gl_vendor_string,
"Advanced Micro Devices, Inc.")
1812 ||
strstr(gl_vendor_string,
"DRI R300 Project")
1813 ||
strstr(gl_vendor_string,
"Tungsten Graphics, Inc")
1814 ||
strstr(gl_vendor_string,
"VMware, Inc.")
1815 ||
strstr(gl_vendor_string,
"Intel")
1816 ||
strstr(gl_renderer,
"Mesa")
1817 ||
strstr(gl_renderer,
"Gallium")
1818 ||
strstr(gl_renderer,
"Intel")
1819 ||
strstr(gl_version,
"Mesa"))
1822 FIXME(
"Received unrecognized GL_VENDOR %s. Returning GL_VENDOR_UNKNOWN.\n",
1830 if (
strstr(gl_vendor_string,
"NVIDIA")
1831 ||
strstr(gl_vendor_string,
"Nouveau")
1832 ||
strstr(gl_vendor_string,
"nouveau"))
1835 if (
strstr(gl_vendor_string,
"ATI")
1836 ||
strstr(gl_vendor_string,
"Advanced Micro Devices, Inc.")
1837 ||
strstr(gl_vendor_string,
"X.Org R300 Project")
1838 ||
strstr(gl_renderer,
"AMD")
1839 ||
strstr(gl_renderer,
"FirePro")
1840 ||
strstr(gl_renderer,
"Radeon")
1841 ||
strstr(gl_renderer,
"R100")
1842 ||
strstr(gl_renderer,
"R200")
1843 ||
strstr(gl_renderer,
"R300")
1844 ||
strstr(gl_renderer,
"R600")
1845 ||
strstr(gl_renderer,
"R700"))
1848 if (
strstr(gl_vendor_string,
"Intel(R)")
1850 ||
strstr(gl_renderer,
"Intel")
1851 ||
strstr(gl_renderer,
"i915")
1852 ||
strstr(gl_vendor_string,
"Intel Inc."))
1855 if (
strstr(gl_renderer,
"SVGA3D"))
1858 if (
strstr(gl_vendor_string,
"Mesa")
1859 ||
strstr(gl_vendor_string,
"Brian Paul")
1860 ||
strstr(gl_vendor_string,
"Tungsten Graphics, Inc")
1861 ||
strstr(gl_vendor_string,
"VMware, Inc."))
1864 FIXME(
"Received unrecognized GL_VENDOR %s. Returning HW_VENDOR_NVIDIA.\n",
debugstr_a(gl_vendor_string));
2476 if (
table[
i].gl_vendor != gl_vendor)
2481 for (
j = 0;
j <
table[
i].cards_size; ++
j)
2488 FIXME(
"Couldn't find a suitable card selector for GL vendor %04x (using GL_RENDERER %s)\n",
2587 TRACE(
"Unrecognized renderer %s, falling back to default.\n",
debugstr_a(gl_renderer));
2591 FIXME(
"No card selector available for card vendor %04x (using GL_RENDERER %s).\n",
2650 while (!
isspace(*extensions) && *extensions)
2659 for (
i = 0;
i < entry_count; ++
i)
2664 TRACE(
" FOUND: %s support.\n",
map[
i].extension_string);
2675 const char *gl_extension_name;
2677 GLint extensions_count;
2680 for (
i = 0;
i < extensions_count; ++
i)
2684 for (
j = 0;
j < map_entries_count; ++
j)
2686 if (!
strcmp(gl_extension_name,
map[
j].extension_string))
2688 TRACE(
"FOUND: %s support.\n",
map[
j].extension_string);
2698#define USE_GL_FUNC(pfn) gl_info->gl_ops.ext.p_##pfn = (void *)wglGetProcAddress(#pfn);
2713 USE_GL_FUNC(glDrawElementsInstancedBaseVertexBaseInstance)
2776 USE_GL_FUNC(glGetFramebufferAttachmentParameteriv)
3090 USE_GL_FUNC(glGetFramebufferAttachmentParameterivEXT)
3350#ifndef USE_WIN32_OPENGL
3356#define MAP_GL_FUNCTION(core_func, ext_func) \
3359 if (!gl_info->gl_ops.ext.p_##core_func) \
3360 gl_info->gl_ops.ext.p_##core_func = gl_info->gl_ops.ext.p_##ext_func; \
3362#define MAP_GL_FUNCTION_CAST(core_func, ext_func) \
3365 if (!gl_info->gl_ops.ext.p_##core_func) \
3366 gl_info->gl_ops.ext.p_##core_func = (void *)gl_info->gl_ops.ext.p_##ext_func; \
3398 MAP_GL_FUNCTION(glDisableVertexAttribArray, glDisableVertexAttribArrayARB);
3403 MAP_GL_FUNCTION(glEnableVertexAttribArray, glEnableVertexAttribArrayARB);