Graphics: Switch glyph atlases to R8 instead of A8
A8 can't be supported efficiently on API lacking texture swizzle support (DX, WebGL, WebGPU), so we swizzle in the shader instead
This commit is contained in:
@@ -26,6 +26,8 @@ namespace Nz
|
||||
GLenum swizzleG;
|
||||
GLenum swizzleB;
|
||||
GLenum swizzleA;
|
||||
|
||||
inline bool HasSwizzle() const;
|
||||
};
|
||||
|
||||
inline std::optional<GLTextureFormat> DescribeTextureFormat(PixelFormat pixelFormat);
|
||||
|
||||
@@ -10,14 +10,19 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline bool GLTextureFormat::HasSwizzle() const
|
||||
{
|
||||
return swizzleR != GL_RED || swizzleG != GL_GREEN || swizzleB != GL_BLUE || swizzleA != GL_ALPHA;
|
||||
}
|
||||
|
||||
inline std::optional<GLTextureFormat> DescribeTextureFormat(PixelFormat pixelFormat)
|
||||
{
|
||||
// TODO: Fill this switch
|
||||
switch (pixelFormat)
|
||||
{
|
||||
case PixelFormat::A8: return GLTextureFormat{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, GL_ONE, GL_ONE, GL_ONE, GL_RED };
|
||||
case PixelFormat::BGR8: return GLTextureFormat{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ONE };
|
||||
case PixelFormat::BGR8_SRGB: return GLTextureFormat{ GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ONE };
|
||||
case PixelFormat::BGR8: return GLTextureFormat{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||
case PixelFormat::BGR8_SRGB: return GLTextureFormat{ GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||
case PixelFormat::BGRA8: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||
case PixelFormat::BGRA8_SRGB: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_BLUE, GL_GREEN, GL_RED, GL_ALPHA };
|
||||
case PixelFormat::Depth16: return GLTextureFormat{ GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_RED, GL_ZERO, GL_ZERO, GL_ZERO };
|
||||
@@ -27,8 +32,10 @@ namespace Nz
|
||||
case PixelFormat::Depth32FStencil8: return GLTextureFormat{ GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_RED, GL_GREEN, GL_ZERO, GL_ZERO };
|
||||
case PixelFormat::L8: return GLTextureFormat{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, GL_RED, GL_RED, GL_RED, GL_ONE };
|
||||
case PixelFormat::LA8: return GLTextureFormat{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, GL_RED, GL_RED, GL_RED, GL_GREEN };
|
||||
case PixelFormat::RGB8: return GLTextureFormat{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ONE };
|
||||
case PixelFormat::RGB8_SRGB: return GLTextureFormat{ GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ONE };
|
||||
case PixelFormat::R8: return GLTextureFormat{ GL_R8, GL_RED, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
case PixelFormat::RG8: return GLTextureFormat{ GL_RG8, GL_RG, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
case PixelFormat::RGB8: return GLTextureFormat{ GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
case PixelFormat::RGB8_SRGB: return GLTextureFormat{ GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
case PixelFormat::RGBA8: return GLTextureFormat{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
case PixelFormat::RGBA8_SRGB: return GLTextureFormat{ GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
case PixelFormat::RGBA16F: return GLTextureFormat{ GL_RGBA16F, GL_RGBA, GL_FLOAT, GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA };
|
||||
|
||||
Reference in New Issue
Block a user