Comments (7)
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 (forglTexImage
):GL_RGBA
(0x1908)
glInternalFormat (forglTexStorage
):GL_BGRA8_EXT
(0x93A1) -
EXT_texture_format_BGRA8888
:
glFormat:GL_BGRA_EXT
(0x80E1)
glInternalFormat (forglTexImage
):GL_BGRA_EXT
(0x80E1)
glInternalFormat (forglTexStorage
, mentioned inEXT_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.
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.
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.
For
VK_FORMAT_B8G8R8_UNORM
I'd useGL_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.
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.
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.
Great. Then please close this issue and move the data to the spec.
from ktx-specification.
Related Issues (20)
- The example file in the spec is invalid with regards to `dfdByteLength` equalling `dfdTotalSize`.
- Confirm prohibited formats HOT 3
- Confirm KTXwriter and KTXwriterScParams encoding HOT 1
- Consider rephrasing format mapping metadata usage HOT 1
- Clarify compressed formats for 1D textures HOT 1
- Confirm mipPadding size HOT 8
- Relax DFD transfer function restrictions HOT 2
- KDF_DF_* vs KHR_DF_* HOT 1
- Please rename default branch from 'master' to 'main' per Khronos policy HOT 1
- Reserve vendor ID for super-compression scheme HOT 3
- Investigate GDeflate supercompression HOT 3
- Definition of 'num_blocks_x' lacks max(1, ...) ? HOT 1
- Disallow two-plane 444 formats
- typeSize spec for formats with suffix _nPACKxx is wrong
- Allow A8B8G8R8 formats HOT 2
- Confirm R16G16_S10_5 support HOT 17
- Generated format switches not including many Vulkan formats in 2glFormat and 2glType HOT 4
- Some supported formats are not included in the mapping appendix HOT 1
- upgrade SDL2 to 2.30 HOT 1
- Support XMP metadata HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ktx-specification.