Giter Club home page Giter Club logo

Comments (7)

lexaknyazev avatar lexaknyazev commented on June 13, 2024

I've run into a few more issues while filling this table.


VK_FORMAT_B8G8R8_UNORM

Three unsigned normalized 8-bit components in B, G, R order. There's nothing like that in Metal or DX. But OpenGL can handle it in some cases.

glType: GL_UNSIGNED_BYTE

OpenGL ES

There's a vendor-specific extension called GL_NV_bgr.
glFormat: GL_BGR_NV (0x80E0)
glInternalFormat (for glTexImage): GL_BGR_NV (0x80E0)

Interaction with glTexStorage is not documented.

OpenGL

Part of core, assuming client conversion to RGB.
glFormat: GL_BGR (0x80E0)
glInternalFormat: GL_RGB8 (0x8051) or unsized GL_RGB (0x1907)

What should GL metadata be?

VK_FORMAT_B8G8R8_SNORM

Same as previous but signed. Nothing in Metal, DX, or OpenGL ES.

Should work in OpenGL (with client conversion to RGB) with
glType: GL_BYTE
glFormat: GL_BGR (0x80E0)
glInternalFormat: GL_RGB8_SNORM (0x8F96)

VK_FORMAT_B8G8R8_UINT

Three unsigned integer 8-bit components in B, G, R order. No support in Metal, DX, or OpenGL ES.

OpenGL with conversion:
glType: GL_UNSIGNED_BYTE
glFormat: GL_BGR_INTEGER (0x8D9A)
glInternalFormat: GL_RGB8UI (0x8D7D)

VK_FORMAT_B8G8R8_SINT

Same as previous but signed. No support in Metal, DX, or OpenGL ES.

OpenGL with conversion:
glType: GL_BYTE
glFormat: GL_BGR_INTEGER (0x8D9A)
glInternalFormat: GL_RGB8I (0x8D8F)

VK_FORMAT_B8G8R8_SRGB

Three unsigned normalized 8-bit components in B, G, R order using sRGB space. No support in Metal, DX, or OpenGL ES.

OpenGL with conversion:
glType: GL_UNSIGNED_BYTE
glFormat: GL_BGR (0x80E0)
glInternalFormat: GL_SRGB8 (0x8C41)


VK_FORMAT_B8G8R8A8_UNORM

Four unsigned normalized 8-bit components in B, G, R, A order. Native Metal and DX support.
OpenGL is tricky.

glType: GL_UNSIGNED_BYTE

OpenGL ES

There are two extensions with slightly different semantics.

  • APPLE_texture_format_BGRA8888:
    glFormat: GL_BGRA_EXT (0x80E1)
    glInternalFormat (for glTexImage): GL_RGBA (0x1908)
    glInternalFormat (for glTexStorage): GL_BGRA8_EXT (0x93A1)

  • EXT_texture_format_BGRA8888:
    glFormat: GL_BGRA_EXT (0x80E1)
    glInternalFormat (for glTexImage): GL_BGRA_EXT (0x80E1)
    glInternalFormat (for glTexStorage, mentioned in EXT_texture_storage): GL_BGRA8_EXT (0x93A1)

OpenGL

Conversion to RGBA.
glFormat: GL_BGRA (0x80E1)
glInternalFormat: GL_RGBA8 (0x8058) or unsized GL_RGBA (0x1908)

What should GL metadata be?

VK_FORMAT_B8G8R8A8_SNORM

Same as previous but signed. Nothing in Metal, DX, or OpenGL ES.

OpenGL with conversion:
glType: GL_BYTE
glFormat: GL_BGRA (0x80E1)
glInternalFormat: GL_RGBA8_SNORM (0x8F97)

VK_FORMAT_B8G8R8A8_UINT

Four unsigned integer 8-bit components in B, G, R, A order. No support in Metal, DX, or OpenGL ES.

OpenGL with conversion:
glType: GL_UNSIGNED_BYTE
glFormat: GL_BGRA_INTEGER (0x8D9B)
glInternalFormat: GL_RGBA8UI (0x8D7C)

VK_FORMAT_B8G8R8A8_SINT

Same as previous but signed. No support in Metal, DX, or OpenGL ES.

OpenGL with conversion:
glType: GL_BYTE
glFormat: GL_BGRA_INTEGER (0x8D9B)
glInternalFormat: GL_RGBA8I (0x8D8E)

VK_FORMAT_B8G8R8A8_SRGB

Four unsigned normalized 8-bit components in B, G, R, A order using sRGB space. Native Metal and DX support. No support in OpenGL ES.

OpenGL with conversion:
glType: GL_UNSIGNED_BYTE
glFormat: GL_BGRA (0x80E1)
glInternalFormat: GL_SRGB8_ALPHA8 (0x8C43)

from ktx-specification.

lexaknyazev avatar lexaknyazev commented on June 13, 2024

Two more exotic formats.

VK_FORMAT_R8_SRGB

Red-only, unsigned, 8-bit, normalized, sRGB. Native Metal support.
glType: GL_UNSIGNED_BYTE
glFormat: GL_RED

OpenGL ES

Extension EXT_texture_sRGB_R8:
glInternalFormat: GL_SR8_EXT (0x8FBD)

OpenGL

Same extension (if available) or probably in-driver expansion to RGBA with GL_SRGB8_ALPHA8 will do the trick.

VK_FORMAT_RG8_SRGB

Red-green, unsigned, 8-bit, normalized, sRGB. Native Metal support.
glType: GL_UNSIGNED_BYTE
glFormat: GL_RG

OpenGL ES

Extension EXT_texture_sRGB_RG8:
glInternalFormat: GL_SRG8_EXT (0x8FBE)

OpenGL

Same extension (if available, although its spec doesn't mention desktop OpenGL) or probably in-driver expansion to RGBA with GL_SRGB8_ALPHA8 will do the trick.

from ktx-specification.

MarkCallow avatar MarkCallow commented on June 13, 2024

For VK_FORMAT_B8G8R8_UNORM I'd use GL_BGR in the mapping table. No need for metadata.

For the other BGR formats the mapping you've shown is fine. It's okay that there is no mapping to OpenGL ES. There is no intent to limit KTX2 to formats supported by OpenGL ES.

For VK_FORMAT_B8G8R8A8_UNORM use the OpenGL mapping with the sized internal format. Obviously use the OpenGL mappings also for the other BGRA formats.

For the R{,G8}_SRGB formats use the extension glInternalFormats you've shown. You can add a tip describing the alternative if the extension is not available.

from ktx-specification.

lexaknyazev avatar lexaknyazev commented on June 13, 2024

For VK_FORMAT_B8G8R8_UNORM I'd use GL_BGR in the mapping table. No need for metadata.
For the other BGR formats the mapping you've shown is fine. It's okay that there is no mapping to OpenGL ES. There is no intent to limit KTX2 to formats supported by OpenGL ES.

For better consistency with other BGR and BGRA formats, wouldn't it be better to use "converted" glInternalFormat (GL_RGB8) for B8G8R8 as well? GL_NV_bgr extension seems to be available exclusively on NVIDIA Tegra chips.

For VK_FORMAT_B8G8R8A8_UNORM use the OpenGL mapping with the sized internal format. Obviously use the OpenGL mappings also for the other BGRA formats.

OK, this looks consistent.

For the R{,G8}_SRGB formats use the extension glInternalFormats you've shown. You can add a tip describing the alternative if the extension is not available.

OK.

from ktx-specification.

MarkCallow avatar MarkCallow commented on June 13, 2024

For better consistency with other BGR and BGRA formats, wouldn't it be better to use "converted" glInternalFormat (GL_RGB8) for B8G8R8 as well?

Yes. You're right. Use GL_RGB8 for the internal format.

GL_NV_bgr extension seems to be available exclusively on NVIDIA Tegra chips.

This extension was obviously created for OpenGL ES 1.1 or 2.0, as it doesn't have a sized internal format, so I wouldn't bother too much about it. Loaders to those APIs with this extension will have to use the glFormat as the glInternalformat. The GL_BGR token in OpenGL has the same value as GL_BGR_NV.

from ktx-specification.

lexaknyazev avatar lexaknyazev commented on June 13, 2024

The table updated with BGR(A) mappings.

All formats except multi-plane are in place, so I think we can proceed with moving this data to the spec.

from ktx-specification.

MarkCallow avatar MarkCallow commented on June 13, 2024

Great. Then please close this issue and move the data to the spec.

from ktx-specification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.