Only apply an AMD-specific hack when generating mipmaps on AMD GPUs

This commit is contained in:
Alex Szpakowski
2013-11-17 05:44:09 -04:00
parent 0214bab0fe
commit c0b28f9d07
3 changed files with 62 additions and 6 deletions
+9 -5
View File
@@ -204,12 +204,16 @@ void Image::createMipmaps()
if (hasNpot() && (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object))
{
// AMD/ATI drivers have several bugs when generating mipmaps,
// re-uploading the entire base image seems to be required.
uploadTexture();
if (gl.getVendor() == OpenGL::VENDOR_ATI_AMD)
{
// AMD/ATI drivers have several bugs when generating mipmaps,
// re-uploading the entire base image seems to be required.
uploadTexture();
// More bugs: http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation
glEnable(GL_TEXTURE_2D);
}
// More bugs: http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation
glEnable(GL_TEXTURE_2D);
glGenerateMipmap(GL_TEXTURE_2D);
}
else
+33 -1
View File
@@ -25,9 +25,12 @@
#include "Shader.h"
#include "common/Exception.h"
// STL
// C++
#include <algorithm>
// C
#include <cstring>
namespace love
{
namespace graphics
@@ -39,6 +42,7 @@ OpenGL::OpenGL()
: contextInitialized(false)
, maxAnisotropy(1.0f)
, maxTextureSize(0)
, vendor(VENDOR_UNKNOWN)
, state()
{
}
@@ -118,6 +122,29 @@ void OpenGL::deInitContext()
contextInitialized = false;
}
void OpenGL::initVendor()
{
const char *vstr = (const char *) glGetString(GL_VENDOR);
if (!vstr)
return;
// http://feedback.wildfiregames.com/report/opengl/feature/GL_VENDOR
if (strstr(vstr, "ATI Technologies"))
vendor = VENDOR_ATI_AMD;
else if (strstr(vstr, "NVIDIA"))
vendor = VENDOR_NVIDIA;
else if (strstr(vstr, "Intel"))
vendor = VENDOR_INTEL;
else if (strstr(vstr, "Mesa"))
vendor = VENDOR_MESA_SOFT;
else if (strstr(vstr, "Apple Computer"))
vendor = VENDOR_APPLE;
else if (strstr(vstr, "Microsoft"))
vendor = VENDOR_MICROSOFT;
else
vendor = VENDOR_UNKNOWN;
}
void OpenGL::initOpenGLFunctions()
{
// The functionality of the core and ARB VBOs are identical, so we can
@@ -461,6 +488,11 @@ int OpenGL::getMaxTextureSize() const
return maxTextureSize;
}
OpenGL::Vendor OpenGL::getVendor() const
{
return vendor;
}
// OpenGL class instance singleton.
OpenGL gl;
+20
View File
@@ -51,6 +51,18 @@ class OpenGL
{
public:
// OpenGL GPU vendors.
enum Vendor
{
VENDOR_ATI_AMD,
VENDOR_NVIDIA,
VENDOR_INTEL,
VENDOR_MESA_SOFT, // Software renderer.
VENDOR_APPLE, // Software renderer.
VENDOR_MICROSOFT, // Software renderer.
VENDOR_UNKNOWN
};
// A rectangle representing an OpenGL viewport or a scissor box.
struct Viewport
{
@@ -176,8 +188,14 @@ public:
**/
int getMaxTextureSize() const;
/**
* Get the GPU vendor of this OpenGL context.
**/
Vendor getVendor() const;
private:
void initVendor();
void initOpenGLFunctions();
void initMaxValues();
void createDefaultTexture();
@@ -187,6 +205,8 @@ private:
float maxAnisotropy;
int maxTextureSize;
Vendor vendor;
// Tracked OpenGL state.
struct
{