Browse Source

More texture format support cleanup

Alex Szpakowski 4 years ago
parent
commit
4244e01a35

+ 8 - 17
src/modules/graphics/opengl/OpenGL.cpp

@@ -1986,6 +1986,8 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
 			flags |= commonsample;
 			flags |= commonsample;
 		if (GLAD_EXT_color_buffer_half_float && (GLAD_ES_VERSION_3_0 || GLAD_EXT_texture_rg))
 		if (GLAD_EXT_color_buffer_half_float && (GLAD_ES_VERSION_3_0 || GLAD_EXT_texture_rg))
 			flags |= commonrender;
 			flags |= commonrender;
+		if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear))
+			flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
 		break;
 		break;
 	case PIXELFORMAT_RGBA16_FLOAT:
 	case PIXELFORMAT_RGBA16_FLOAT:
 		if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float && GLAD_ARB_half_float_pixel))
 		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;
 			flags |= commonsample;
 		if (GLAD_EXT_color_buffer_half_float)
 		if (GLAD_EXT_color_buffer_half_float)
 			flags |= commonrender;
 			flags |= commonrender;
+		if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear))
+			flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
 		break;
 		break;
 	case PIXELFORMAT_R32_FLOAT:
 	case PIXELFORMAT_R32_FLOAT:
 	case PIXELFORMAT_RG32_FLOAT:
 	case PIXELFORMAT_RG32_FLOAT:
@@ -2001,12 +2005,16 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
 			flags |= commonsample | commonrender;
 			flags |= commonsample | commonrender;
 		if (GLAD_ES_VERSION_3_0 || (GLAD_OES_texture_float && GLAD_EXT_texture_rg))
 		if (GLAD_ES_VERSION_3_0 || (GLAD_OES_texture_float && GLAD_EXT_texture_rg))
 			flags |= commonsample;
 			flags |= commonsample;
+		if (!(GLAD_VERSION_1_1 || GLAD_ES_VERSION_3_0 || GLAD_OES_texture_half_float_linear))
+			flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
 		break;
 		break;
 	case PIXELFORMAT_RGBA32_FLOAT:
 	case PIXELFORMAT_RGBA32_FLOAT:
 		if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float))
 		if (GLAD_VERSION_3_0 || (GLAD_VERSION_1_0 && GLAD_ARB_texture_float))
 			flags |= commonsample | commonrender;
 			flags |= commonsample | commonrender;
 		if (GLAD_ES_VERSION_3_0 || GLAD_OES_texture_float)
 		if (GLAD_ES_VERSION_3_0 || GLAD_OES_texture_float)
 			flags |= commonsample;
 			flags |= commonsample;
+		if (!(GLAD_VERSION_1_1 || GLAD_OES_texture_float_linear))
+			flags &= ~PIXELFORMATUSAGEFLAGS_LINEAR;
 		break;
 		break;
 
 
 	case PIXELFORMAT_LA8_UNORM:
 	case PIXELFORMAT_LA8_UNORM:
@@ -2139,23 +2147,6 @@ uint32 OpenGL::getPixelFormatUsageFlags(PixelFormat pixelformat)
 	return flags;
 	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)
 const char *OpenGL::errorString(GLenum errorcode)
 {
 {
 	switch (errorcode)
 	switch (errorcode)

+ 0 - 1
src/modules/graphics/opengl/OpenGL.h

@@ -444,7 +444,6 @@ public:
 	static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB);
 	static TextureFormat convertPixelFormat(PixelFormat pixelformat, bool renderbuffer, bool &isSRGB);
 	static bool isTexStorageSupported();
 	static bool isTexStorageSupported();
 	static uint32 getPixelFormatUsageFlags(PixelFormat pixelformat);
 	static uint32 getPixelFormatUsageFlags(PixelFormat pixelformat);
-	static bool hasTextureFilteringSupport(PixelFormat pixelformat);
 
 
 	static const char *errorString(GLenum errorcode);
 	static const char *errorString(GLenum errorcode);
 	static const char *framebufferStatusString(GLenum status);
 	static const char *framebufferStatusString(GLenum status);

+ 3 - 1
src/modules/graphics/opengl/Texture.cpp

@@ -539,7 +539,9 @@ void Texture::setSamplerState(const SamplerState &s)
 	// Base class does common validation and assigns samplerState.
 	// Base class does common validation and assigns samplerState.
 	love::graphics::Texture::setSamplerState(s);
 	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;
 		samplerState.magFilter = samplerState.minFilter = SamplerState::FILTER_NEAREST;