More texture format support cleanup

This commit is contained in:
Alex Szpakowski
2021-01-17 14:48:35 -04:00
parent ef5a0250e9
commit 4244e01a35
3 changed files with 11 additions and 19 deletions
+8 -17
View File
@@ -1986,6 +1986,8 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
flags |= commonsample;
if (GLAD_EXT_color_buffer_half_float && (GLAD_ES_VERSION_3_0 || GLAD_EXT_texture_rg))
flags |= commonrender;
if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear))
flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
break;
case PIXELFORMAT_RGBA16_FLOAT:
if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float && GLAD_ARB_half_float_pixel))
@@ -1994,6 +1996,8 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
flags |= commonsample;
if (GLAD_EXT_color_buffer_half_float)
flags |= commonrender;
if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear))
flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
break;
case PIXELFORMAT_R32_FLOAT:
case PIXELFORMAT_RG32_FLOAT:
@@ -2001,12 +2005,16 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
flags |= commonsample | commonrender;
if (GLAD_ES_VERSION_3_0 || (GLAD_OES_texture_float && GLAD_EXT_texture_rg))
flags |= commonsample;
if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear))
flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
break;
case PIXELFORMAT_RGBA32_FLOAT:
if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float))
flags |= commonsample | commonrender;
if (GLAD_ES_VERSION_3_0 || GLAD_OES_texture_float)
flags |= commonsample;
if (!(GLAD_VERSION_1_1 || GLAD_OES_texture_float_linear))
flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
break;
case PIXELFORMAT_LA8_UNORM:
@@ -2139,23 +2147,6 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
return flags;
}
bool OpenGL::hasTextureFilteringSupport(PixelFormat pixelformat)
{
switch (pixelformat)
{
case PIXELFORMAT_R16_FLOAT:
case PIXELFORMAT_RG16_FLOAT:
case PIXELFORMAT_RGBA16_FLOAT:
return GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear;
case PIXELFORMAT_R32_FLOAT:
case PIXELFORMAT_RG32_FLOAT:
case PIXELFORMAT_RGBA32_FLOAT:
return GLAD_VERSION_1_1 || GLAD_OES_texture_float_linear;
default:
return true;
}
}
const char *OpenGL::errorString(GLenum errorcode)
{
switch (errorcode)
-1
View File
@@ -444,7 +444,6 @@ public:
static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB);
static bool isTexStorageSupported();
static uint32 getPixelFormatUsageFlags(PixelFormat pixelformat);
static bool hasTextureFilteringSupport(PixelFormat pixelformat);
static const char *errorString(GLenum errorcode);
static const char *framebufferStatusString(GLenum status);
+3 -1
View File
@@ -539,7 +539,9 @@ void Texture::setSamplerState(const SamplerState &s)
// Base class does common validation and assigns samplerState.
love::graphics::Texture::setSamplerState(s);
if (!OpenGL::hasTextureFilteringSupport(getPixelFormat()))
auto supportedflags = OpenGL::getPixelFormatUsageFlags(getPixelFormat());
if ((supportedflags & PIXELFORMATUSAGEFLAGS_LINEAR) == 0)
{
samplerState.magFilter = samplerState.minFilter = SamplerState::FILTER_NEAREST;