MCPcopy Create free account
hub / github.com/crownengine/crown / isTextureFormatValidPerSpec

Function isTextureFormatValidPerSpec

3rdparty/bgfx/src/renderer_gl.cpp:1686–1832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1684
1685#if BX_PLATFORM_EMSCRIPTEN
1686 static bool isTextureFormatValidPerSpec(
1687 TextureFormat::Enum _format
1688 , bool _srgb
1689 , bool _mipAutogen
1690 )
1691 {
1692 // Avoid creating test textures for WebGL, that causes error noise in the browser
1693 // console; instead examine the supported texture formats from the spec.
1694 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
1695
1696 EmscriptenWebGLContextAttributes attrs;
1697 EMSCRIPTEN_CHECK(emscripten_webgl_get_context_attributes(ctx, &attrs) );
1698
1699 const int glesVersion = attrs.majorVersion + 1;
1700
1701 switch(_format)
1702 {
1703 case TextureFormat::A8:
1704 case TextureFormat::R8: // Luminance
1705 case TextureFormat::B5G6R5:
1706 case TextureFormat::R5G6B5:
1707 case TextureFormat::BGRA4:
1708 case TextureFormat::RGBA4:
1709 case TextureFormat::BGR5A1:
1710 case TextureFormat::RGB5A1:
1711 // GLES2 formats without sRGB.
1712 return !_srgb;
1713
1714 case TextureFormat::D16:
1715 // GLES2 formats without sRGB, depth textures do not support mipmaps.
1716 return !_srgb
1717 && !_mipAutogen
1718 ;
1719
1720 case TextureFormat::R16F:
1721 case TextureFormat::R32F:
1722 case TextureFormat::RG8:
1723 case TextureFormat::RG16F:
1724 case TextureFormat::RG32F:
1725 case TextureFormat::RGB10A2:
1726 case TextureFormat::RG11B10F:
1727 // GLES3 formats without sRGB
1728 return !_srgb
1729 && glesVersion >= 3
1730 ;
1731
1732 case TextureFormat::R8I:
1733 case TextureFormat::R8U:
1734 case TextureFormat::R16I:
1735 case TextureFormat::R16U:
1736 case TextureFormat::R32I:
1737 case TextureFormat::R32U:
1738 case TextureFormat::RG8I:
1739 case TextureFormat::RG8U:
1740 case TextureFormat::RG16I:
1741 case TextureFormat::RG16U:
1742 case TextureFormat::RG32I:
1743 case TextureFormat::RG32U:

Callers 1

isTextureFormatValidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected