| 15 | namespace |
| 16 | { |
| 17 | bgfx::TextureFormat::Enum XrTextureFormatToBgfxFormat(xr::TextureFormat format) |
| 18 | { |
| 19 | switch (format) |
| 20 | { |
| 21 | // Color Formats |
| 22 | // NOTE: Use linear formats even though XR requests sRGB to match what happens on the web. |
| 23 | // WebGL shaders expect sRGB output while native shaders expect linear output. |
| 24 | case xr::TextureFormat::BGRA8_SRGB: |
| 25 | return bgfx::TextureFormat::BGRA8; |
| 26 | case xr::TextureFormat::RGBA8_SRGB: |
| 27 | return bgfx::TextureFormat::RGBA8; |
| 28 | |
| 29 | // Depth Formats |
| 30 | case xr::TextureFormat::D24S8: |
| 31 | return bgfx::TextureFormat::D24S8; |
| 32 | |
| 33 | default: |
| 34 | throw std::exception{/* Unsupported texture format */}; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // clang-format off |
| 39 | constexpr std::array<float, 16> IDENTITY_MATRIX{ |