Add some more graphics feature and limit queries (resolves issue #1234).

love.graphics.getSupported():
 - Added “fullnpot” field, is true everywhere except on some older mobile devices. If false, mipmapping and wrap modes other than “clamp” can’t be used on non-power-of-two sized textures.
 - Added “pixelshaderhighp” field, is true everywhere except some older mobile devices. If false, “highp” precision can’t be used in pixel shaders and love will default to “mediump” instead.

love.graphics.getSystemLimits():
- Added “anisotropy” field, gets the maximum amount of anisotropy you can specify in Texture:setFilter. love will clamp anisotropy arguments greater than this value.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-11-25 19:35:07 -04:00
parent 5d2b0a98e5
commit f85ee6b504
5 changed files with 41 additions and 0 deletions
+3
View File
@@ -258,6 +258,8 @@ StringMap<Graphics::Feature, Graphics::FEATURE_MAX_ENUM>::Entry Graphics::featur
{ "multicanvasformats", FEATURE_MULTI_CANVAS_FORMATS },
{ "clampzero", FEATURE_CLAMP_ZERO },
{ "lighten", FEATURE_LIGHTEN },
{ "fullnpot", FEATURE_FULL_NPOT },
{ "pixelshaderhighp", FEATURE_PIXEL_SHADER_HIGHP },
};
StringMap<Graphics::Feature, Graphics::FEATURE_MAX_ENUM> Graphics::features(Graphics::featureEntries, sizeof(Graphics::featureEntries));
@@ -268,6 +270,7 @@ StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM>::Entry Graphics::syst
{ "texturesize", LIMIT_TEXTURE_SIZE },
{ "multicanvas", LIMIT_MULTI_CANVAS },
{ "canvasmsaa", LIMIT_CANVAS_MSAA },
{ "anisotropy", LIMIT_ANISOTROPY },
};
StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM> Graphics::systemLimits(Graphics::systemLimitEntries, sizeof(Graphics::systemLimitEntries));
+3
View File
@@ -151,6 +151,8 @@ public:
FEATURE_MULTI_CANVAS_FORMATS,
FEATURE_CLAMP_ZERO,
FEATURE_LIGHTEN,
FEATURE_FULL_NPOT,
FEATURE_PIXEL_SHADER_HIGHP,
FEATURE_MAX_ENUM
};
@@ -167,6 +169,7 @@ public:
LIMIT_TEXTURE_SIZE,
LIMIT_MULTI_CANVAS,
LIMIT_CANVAS_MSAA,
LIMIT_ANISOTROPY,
LIMIT_MAX_ENUM
};
+6
View File
@@ -2009,6 +2009,8 @@ double Graphics::getSystemLimit(SystemLimit limittype) const
return (double) gl.getMaxRenderTargets();
case Graphics::LIMIT_CANVAS_MSAA:
return (double) gl.getMaxRenderbufferSamples();
case Graphics::LIMIT_ANISOTROPY:
return (double) gl.getMaxAnisotropy();
default:
return 0.0;
}
@@ -2024,6 +2026,10 @@ bool Graphics::isSupported(Feature feature) const
return gl.isClampZeroTextureWrapSupported();
case FEATURE_LIGHTEN:
return GLAD_VERSION_1_4 || GLAD_ES_VERSION_3_0 || GLAD_EXT_blend_minmax;
case FEATURE_FULL_NPOT:
return GLAD_VERSION_2_0 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_npot;
case FEATURE_PIXEL_SHADER_HIGHP:
return gl.isPixelShaderHighpSupported();
default:
return false;
}
+21
View File
@@ -65,6 +65,7 @@ static void *LOVEGetProcAddress(const char *name)
OpenGL::OpenGL()
: stats()
, contextInitialized(false)
, pixelShaderHighpSupported(false)
, maxAnisotropy(1.0f)
, maxTextureSize(0)
, maxRenderTargets(1)
@@ -268,6 +269,16 @@ void OpenGL::initOpenGLFunctions()
void OpenGL::initMaxValues()
{
if (GLAD_ES_VERSION_2_0 && !GLAD_ES_VERSION_3_0)
{
GLint range = 0;
GLint precision = 0;
glGetShaderPrecisionFormat(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, &range, &precision);
pixelShaderHighpSupported = range > 0;
}
else
pixelShaderHighpSupported = true;
// We'll need this value to clamp anisotropy.
if (GLAD_EXT_texture_filter_anisotropic)
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
@@ -715,6 +726,11 @@ bool OpenGL::isClampZeroTextureWrapSupported() const
return GLAD_VERSION_1_3 || GLAD_EXT_texture_border_clamp || GLAD_NV_texture_border_clamp;
}
bool OpenGL::isPixelShaderHighpSupported() const
{
return pixelShaderHighpSupported;
}
int OpenGL::getMaxTextureSize() const
{
return maxTextureSize;
@@ -740,6 +756,11 @@ float OpenGL::getMaxPointSize() const
return maxPointSize;
}
float OpenGL::getMaxAnisotropy() const
{
return maxAnisotropy;
}
void OpenGL::updateTextureMemorySize(size_t oldsize, size_t newsize)
{
int64 memsize = (int64) stats.textureMemory + ((int64) newsize - (int64) oldsize);
+8
View File
@@ -383,6 +383,7 @@ public:
void setTextureWrap(const graphics::Texture::Wrap &w);
bool isClampZeroTextureWrapSupported() const;
bool isPixelShaderHighpSupported() const;
/**
* Returns the maximum supported width or height of a texture.
@@ -409,6 +410,12 @@ public:
**/
float getMaxPointSize() const;
/**
* Returns the maximum anisotropic filtering value that can be used for
* Texture filtering.
**/
float getMaxAnisotropy() const;
void updateTextureMemorySize(size_t oldsize, size_t newsize);
@@ -438,6 +445,7 @@ private:
bool contextInitialized;
bool pixelShaderHighpSupported;
float maxAnisotropy;
int maxTextureSize;
int maxRenderTargets;