From 87bbb2d827064a4fd59ffc77cc2dcbc31f02ce4f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 31 Jan 2010 23:45:51 +0000 Subject: WM Draw Methods now has a new option Automatic (default). This will set the draw method to triple buffer or overlap depending on the configuration. Ideally I could get all cases working well with triple buffer but it's hard in practice. At the moment there are two cases that use overlap instead: * opensource ATI drives on linux * windows software renderer Also added a utility function to check GPU device/os/driver. --- source/blender/gpu/GPU_extensions.h | 31 +++++++++++++- source/blender/gpu/intern/gpu_extensions.c | 66 ++++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 5 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index c2af4e8fcb1..998c13d2a64 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -37,8 +37,6 @@ extern "C" { #endif -/* GPU extensions support */ - struct Image; struct ImageUser; @@ -54,6 +52,8 @@ typedef struct GPUOffScreen GPUOffScreen; struct GPUShader; typedef struct GPUShader GPUShader; +/* GPU extensions support */ + void GPU_extensions_disable(void); void GPU_extensions_init(void); /* call this before running any of the functions below */ void GPU_extensions_exit(void); @@ -61,6 +61,33 @@ int GPU_glsl_support(void); int GPU_non_power_of_two_support(void); int GPU_print_error(char *str); +/* GPU Types */ + +typedef enum GPUDeviceType { + GPU_DEVICE_NVIDIA = (1<<0), + GPU_DEVICE_ATI = (1<<1), + GPU_DEVICE_INTEL = (1<<2), + GPU_DEVICE_SOFTWARE = (1<<3), + GPU_DEVICE_UNKNOWN = (1<<4), + GPU_DEVICE_ANY = (0xff) +} GPUDeviceType; + +typedef enum GPUOSType { + GPU_OS_WIN = (1<<16), + GPU_OS_MAC = (1<<17), + GPU_OS_UNIX = (1<<18), + GPU_OS_ANY = (0xff00) +} GPUOSType; + +typedef enum GPUDriverType { + GPU_DRIVER_OFFICIAL = (1<<24), + GPU_DRIVER_OPENSOURCE = (1<<25), + GPU_DRIVER_SOFTWARE = (1<<26), + GPU_DRIVER_UNKNOWN = (0xff0000) +} GPUDriverType; + +int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver); + /* GPU Texture - always returns unsigned char RGBA textures - if texture with non square dimensions is created, depending on the diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index a5a8c626cbd..e93dd37db82 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -71,8 +71,20 @@ static struct GPUGlobal { GLuint currentfb; int glslsupport; int extdisabled; + GPUDeviceType device; + GPUOSType os; + GPUDriverType driver; } GG = {1, 0, 0, 0}; +/* GPU Types */ + +int GPU_type_matches(GPUDeviceType device, GPUOSType os, GPUDriverType driver) +{ + return (GG.device & device) && (GG.os & os) && (GG.driver & driver); +} + +/* GPU Extensions */ + void GPU_extensions_disable() { GG.extdisabled = 1; @@ -80,6 +92,8 @@ void GPU_extensions_disable() void GPU_extensions_init() { + const char *vendor, *renderer; + glewInit(); /* glewIsSupported("GL_VERSION_2_0") */ @@ -91,6 +105,54 @@ void GPU_extensions_init() if (!GLEW_ARB_multitexture) GG.glslsupport = 0; if (!GLEW_ARB_vertex_shader) GG.glslsupport = 0; if (!GLEW_ARB_fragment_shader) GG.glslsupport = 0; + + vendor = (const char*)glGetString(GL_VENDOR); + renderer = (const char*)glGetString(GL_RENDERER); + + if(strstr(vendor, "ATI")) { + GG.device = GPU_DEVICE_ATI; + GG.driver = GPU_DRIVER_OFFICIAL; + } + else if(strstr(vendor, "NVIDIA")) { + GG.device = GPU_DEVICE_NVIDIA; + GG.driver = GPU_DRIVER_OFFICIAL; + } + else if(strstr(vendor, "Intel") || strstr(renderer, "Mesa DRI Intel")) { + GG.device = GPU_DEVICE_INTEL; + GG.driver = GPU_DRIVER_OFFICIAL; + } + else if(strstr(renderer, "Mesa DRI R")) { + GG.device = GPU_DEVICE_ATI; + GG.driver = GPU_DRIVER_OPENSOURCE; + } + else if(strstr(renderer, "Nouveau")) { + GG.device = GPU_DEVICE_NVIDIA; + GG.driver = GPU_DRIVER_OPENSOURCE; + } + else if(strcmp(vendor, "Mesa") == 0) { + GG.device = GPU_DEVICE_SOFTWARE; + GG.driver = GPU_DRIVER_SOFTWARE; + } + else if(strstr(vendor, "Microsoft")) { + GG.device = GPU_DEVICE_SOFTWARE; + GG.driver = GPU_DRIVER_SOFTWARE; + } + else if(strcmp(renderer, "Apple Software Renderer") == 0) { + GG.device = GPU_DEVICE_SOFTWARE; + GG.driver = GPU_DRIVER_SOFTWARE; + } + else { + GG.device = GPU_DEVICE_UNKNOWN; + GG.driver = GPU_DRIVER_UNKNOWN; + } + + GG.os = GPU_OS_UNIX; +#ifdef _WIN32 + GG.os = GPU_OS_WIN; +#endif +#ifdef __APPLE__ + GG.os = GPU_OS_MAC; +#endif } int GPU_glsl_support() @@ -102,10 +164,8 @@ int GPU_non_power_of_two_support() { /* Exception for buggy ATI/Apple driver in Mac OS X 10.5/10.6, * they claim to support this but can cause system freeze */ -#ifdef __APPLE__ - if(strcmp((char*)glGetString(GL_VENDOR), "ATI Technologies Inc.") == 0) + if(GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) return 0; -#endif return GLEW_ARB_texture_non_power_of_two; } -- cgit v1.2.3