Remove explicit support for systems that don't support rgba8 canvases.

This is just a very small number of really old OpenGL ES 2 drivers.
This commit is contained in:
Sasha Szpakowski
2023-10-13 21:53:45 -03:00
parent 3865868358
commit 983ea6c0e6
9 changed files with 23 additions and 75 deletions
+16
View File
@@ -2389,6 +2389,22 @@ const Graphics::Capabilities &Graphics::getCapabilities() const
return capabilities; return capabilities;
} }
PixelFormat Graphics::getSizedFormat(PixelFormat format) const
{
switch (format)
{
case PIXELFORMAT_NORMAL:
if (isGammaCorrect())
return PIXELFORMAT_RGBA8_UNORM_sRGB;
else
return PIXELFORMAT_RGBA8_UNORM;
case PIXELFORMAT_HDR:
return PIXELFORMAT_RGBA16_FLOAT;
default:
return format;
}
}
Graphics::Stats Graphics::getStats() const Graphics::Stats Graphics::getStats() const
{ {
Stats stats; Stats stats;
+1 -1
View File
@@ -819,7 +819,7 @@ public:
/** /**
* Converts PIXELFORMAT_NORMAL and PIXELFORMAT_HDR into a real format. * Converts PIXELFORMAT_NORMAL and PIXELFORMAT_HDR into a real format.
**/ **/
virtual PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const = 0; PixelFormat getSizedFormat(PixelFormat format) const;
/** /**
* Gets whether the specified pixel format usage is supported. * Gets whether the specified pixel format usage is supported.
+1 -1
View File
@@ -235,7 +235,7 @@ Texture::Texture(Graphics *gfx, const Settings &settings, const Slices *slices)
else else
readable = !renderTarget || !isPixelFormatDepthStencil(format); readable = !renderTarget || !isPixelFormatDepthStencil(format);
format = gfx->getSizedFormat(format, renderTarget, readable); format = gfx->getSizedFormat(format);
sRGB = isPixelFormatSRGB(format) || (isCompressed() && isGammaCorrect() && !settings.linear); sRGB = isPixelFormatSRGB(format) || (isCompressed() && isGammaCorrect() && !settings.linear);
if (mipmapsMode == MIPMAPS_AUTO && isCompressed()) if (mipmapsMode == MIPMAPS_AUTO && isCompressed())
-1
View File
@@ -110,7 +110,6 @@ public:
void setWireframe(bool enable) override; void setWireframe(bool enable) override;
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override;
bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override; bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override;
Renderer getRenderer() const override; Renderer getRenderer() const override;
bool usesGLSLES() const override; bool usesGLSLES() const override;
+2 -21
View File
@@ -1864,28 +1864,9 @@ void Graphics::setWireframe(bool enable)
} }
} }
PixelFormat Graphics::getSizedFormat(PixelFormat format, bool /*rendertarget*/, bool /*readable*/) const
{
switch (format)
{
case PIXELFORMAT_NORMAL:
if (isGammaCorrect())
return PIXELFORMAT_RGBA8_UNORM_sRGB;
else
return PIXELFORMAT_RGBA8_UNORM;
case PIXELFORMAT_HDR:
return PIXELFORMAT_RGBA16_FLOAT;
default:
return format;
}
}
bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB) bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB)
{ {
bool rendertarget = (usage & PIXELFORMATUSAGEFLAGS_RENDERTARGET) != 0; format = getSizedFormat(format);
bool readable = (usage & PIXELFORMATUSAGEFLAGS_SAMPLE) != 0;
format = getSizedFormat(format, rendertarget, readable);
if (sRGB) if (sRGB)
format = getSRGBPixelFormat(format); format = getSRGBPixelFormat(format);
@@ -1902,7 +1883,7 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
uint32 flags = PIXELFORMATUSAGEFLAGS_NONE; uint32 flags = PIXELFORMATUSAGEFLAGS_NONE;
if (isPixelFormatCompressed(format) && rendertarget) if (isPixelFormatCompressed(format) && (usage & rt) != 0)
return false; return false;
// https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf // https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
+2 -29
View File
@@ -1734,31 +1734,6 @@ void Graphics::initCapabilities()
} }
} }
PixelFormat Graphics::getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const
{
uint32 requiredflags = 0;
if (rendertarget)
requiredflags |= PIXELFORMATUSAGEFLAGS_RENDERTARGET;
if (readable)
requiredflags |= PIXELFORMATUSAGEFLAGS_SAMPLE;
switch (format)
{
case PIXELFORMAT_NORMAL:
if (isGammaCorrect())
return PIXELFORMAT_RGBA8_UNORM_sRGB;
else if ((OpenGL::getPixelFormatUsageFlags(PIXELFORMAT_RGBA8_UNORM) & requiredflags) != requiredflags)
// 32-bit render targets don't have guaranteed support on GLES2.
return PIXELFORMAT_RGBA4_UNORM;
else
return PIXELFORMAT_RGBA8_UNORM;
case PIXELFORMAT_HDR:
return PIXELFORMAT_RGBA16_FLOAT;
default:
return format;
}
}
uint32 Graphics::computePixelFormatUsage(PixelFormat format, bool readable) uint32 Graphics::computePixelFormatUsage(PixelFormat format, bool readable)
{ {
uint32 usage = OpenGL::getPixelFormatUsageFlags(format); uint32 usage = OpenGL::getPixelFormatUsageFlags(format);
@@ -1844,11 +1819,9 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRG
if (sRGB) if (sRGB)
format = getSRGBPixelFormat(format); format = getSRGBPixelFormat(format);
bool rendertarget = (usage & PIXELFORMATUSAGEFLAGS_RENDERTARGET) != 0; format = getSizedFormat(format);
bool readable = (usage & PIXELFORMATUSAGEFLAGS_SAMPLE) != 0; bool readable = (usage & PIXELFORMATUSAGEFLAGS_SAMPLE) != 0;
format = getSizedFormat(format, rendertarget, readable);
return (usage & pixelFormatUsage[format][readable ? 1 : 0]) == usage; return (usage & pixelFormatUsage[format][readable ? 1 : 0]) == usage;
} }
-1
View File
@@ -106,7 +106,6 @@ public:
void setWireframe(bool enable) override; void setWireframe(bool enable) override;
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override;
bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override; bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB = false) override;
Renderer getRenderer() const override; Renderer getRenderer() const override;
bool usesGLSLES() const override; bool usesGLSLES() const override;
+1 -20
View File
@@ -1057,28 +1057,9 @@ void Graphics::setWireframe(bool enable)
states.back().wireframe = enable; states.back().wireframe = enable;
} }
PixelFormat Graphics::getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const
{
switch (format)
{
case PIXELFORMAT_NORMAL:
if (isGammaCorrect())
return PIXELFORMAT_RGBA8_UNORM_sRGB;
else
return PIXELFORMAT_RGBA8_UNORM;
case PIXELFORMAT_HDR:
return PIXELFORMAT_RGBA16_FLOAT;
default:
return format;
}
}
bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB) bool Graphics::isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB)
{ {
bool rendertarget = (usage & PIXELFORMATUSAGEFLAGS_RENDERTARGET) != 0; format = getSizedFormat(format);
bool readable = (usage & PIXELFORMATUSAGEFLAGS_SAMPLE) != 0;
format = getSizedFormat(format, rendertarget, readable);
auto vulkanFormat = Vulkan::getTextureFormat(format, sRGB); auto vulkanFormat = Vulkan::getTextureFormat(format, sRGB);
-1
View File
@@ -297,7 +297,6 @@ public:
void setBlendState(const BlendState &blend) override; void setBlendState(const BlendState &blend) override;
void setPointSize(float size) override; void setPointSize(float size) override;
void setWireframe(bool enable) override; void setWireframe(bool enable) override;
PixelFormat getSizedFormat(PixelFormat format, bool rendertarget, bool readable) const override;
bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB) override; bool isPixelFormatSupported(PixelFormat format, uint32 usage, bool sRGB) override;
Renderer getRenderer() const override; Renderer getRenderer() const override;
bool usesGLSLES() const override; bool usesGLSLES() const override;