Skip to content

Commit

Permalink
[WebGL] Fixed texture initialization for WebGL.
Browse files Browse the repository at this point in the history
- Add integer identifier to all stencil and depth-stencil format flags.
- Only initialize GL textures with GL_FLOAT type for strictly float formats,
  i.e. GL_RGBA is UNorm but *not* considered a floating-point type.
- Initialize GL texture parameters *after* texture storage has been allocated.
  • Loading branch information
LukasBanana committed Aug 31, 2024
1 parent 99d2b2b commit 1b25809
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 84 deletions.
62 changes: 31 additions & 31 deletions include/LLGL/Format.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,39 +227,39 @@ enum class Format
BC5SNorm, //!< Compressed color format: S3TC BC5 compressed red and green channels with normalized signed integer components in 128-bit per 4x4 block.

/* --- Advanced scalable texture compression (ASTC) formats --- */
ASTC4x4, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 4x4 block (8.00 bit rate). \note Only supported with: OpenGLES.
ASTC4x4_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 4x4 block (8.00 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC5x4, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x4 block (6.40 bit rate). \note Only supported with: OpenGLES.
ASTC5x4_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x4 block (6.40 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC5x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x5 block (5.12 bit rate). \note Only supported with: OpenGLES.
ASTC5x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x5 block (5.12 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC6x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x5 block (4.27 bit rate). \note Only supported with: OpenGLES.
ASTC6x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x5 block (4.27 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC6x6, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x6 block (3.56 bit rate). \note Only supported with: OpenGLES.
ASTC6x6_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x6 block (3.56 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC8x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x5 block (3.20 bit rate). \note Only supported with: OpenGLES.
ASTC8x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x5 block (3.20 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC8x6, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x6 block (2.67 bit rate). \note Only supported with: OpenGLES.
ASTC8x6_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x6 block (2.67 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC8x8, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x8 block (2.00 bit rate). \note Only supported with: OpenGLES.
ASTC8x8_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x8 block (2.00 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC10x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x5 block (2.56 bit rate). \note Only supported with: OpenGLES.
ASTC10x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x5 block (2.56 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC10x6, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x6 block (2.13 bit rate). \note Only supported with: OpenGLES.
ASTC10x6_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x6 block (2.13 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC10x8, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x8 block (1.60 bit rate). \note Only supported with: OpenGLES.
ASTC10x8_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x8 block (1.60 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC10x10, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x10 block (1.28 bit rate). \note Only supported with: OpenGLES.
ASTC10x10_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x10 block (1.28 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC12x10, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x10 block (1.07 bit rate). \note Only supported with: OpenGLES.
ASTC12x10_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x10 block (1.07 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC12x12, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x12 block (0.89 bit rate). \note Only supported with: OpenGLES.
ASTC12x12_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x12 block (0.89 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGLES.
ASTC4x4, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 4x4 block (8.00 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC4x4_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 4x4 block (8.00 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC5x4, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x4 block (6.40 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC5x4_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x4 block (6.40 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC5x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x5 block (5.12 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC5x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 5x5 block (5.12 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC6x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x5 block (4.27 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC6x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x5 block (4.27 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC6x6, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x6 block (3.56 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC6x6_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 6x6 block (3.56 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC8x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x5 block (3.20 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC8x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x5 block (3.20 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC8x6, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x6 block (2.67 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC8x6_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x6 block (2.67 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC8x8, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x8 block (2.00 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC8x8_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 8x8 block (2.00 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x5, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x5 block (2.56 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x5_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x5 block (2.56 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x6, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x6 block (2.13 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x6_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x6 block (2.13 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x8, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x8 block (1.60 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x8_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x8 block (1.60 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x10, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x10 block (1.28 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC10x10_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 10x10 block (1.28 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC12x10, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x10 block (1.07 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC12x10_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x10 block (1.07 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
ASTC12x12, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x12 block (0.89 bit rate). \note Only supported with: OpenGL, Vulkan, Metal.
ASTC12x12_sRGB, //!< Compressed color format: ASTC compressed RGBA format in 128-bit per 12x12 block (0.89 bit rate) in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.

/* --- Ericsson texture compression (ETC) formats --- */
ETC1UNorm, //!< Compressed color format: ETC1 compressed RGB with normalized unsigned integer components in 64-bit per 4x4 block. \note Only supported with: OpenGLES.
ETC2UNorm, //!< Compressed color format: ETC2 compressed RGB with normalized unsigned integer components in 64-bit per 4x4 block. \note Only supported with: OpenGLES.
ETC2UNorm_sRGB, //!< Compressed color format: ETC2 compressed RGB with normalized unsigned integer components in 64-bit per 4x4 block in non-linear sRGB color space. \note Only supported with: OpenGLES.
ETC1UNorm, //!< Compressed color format: ETC1 compressed RGB with normalized unsigned integer components in 64-bit per 4x4 block. \note Only supported with: OpenGL, Vulkan, Metal.
ETC2UNorm, //!< Compressed color format: ETC2 compressed RGB with normalized unsigned integer components in 64-bit per 4x4 block. \note Only supported with: OpenGL, Vulkan, Metal.
ETC2UNorm_sRGB, //!< Compressed color format: ETC2 compressed RGB with normalized unsigned integer components in 64-bit per 4x4 block in non-linear sRGB color space. \note Only supported with: OpenGL, Vulkan, Metal.
};

/**
Expand Down
3 changes: 2 additions & 1 deletion sources/Renderer/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace Internal

// Shortcuts for the format flags
static constexpr long Depth = FormatFlags::HasDepth;
static constexpr long Stencil = FormatFlags::HasStencil;
static constexpr long sRGB = FormatFlags::IsColorSpace_sRGB;
static constexpr long Compr = FormatFlags::IsCompressed;
static constexpr long Norm = FormatFlags::IsNormalized;
Expand All @@ -45,6 +44,8 @@ static constexpr long UNorm = Unsigned | Norm;
static constexpr long SFloat = 0;
static constexpr long UFloat = Unsigned;

static constexpr long Stencil = FormatFlags::HasStencil | UInt;

// Declaration of all hardware format descriptors
static const FormatAttributes g_formatAttribs[] =
{
Expand Down
Loading

0 comments on commit 1b25809

Please sign in to comment.