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

Function isTextureFormatValid

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

Source from the content-addressed store, hash-verified

1833#endif // BX_PLATFORM_EMSCRIPTEN
1834
1835 static bool isTextureFormatValid(
1836 TextureFormat::Enum _format
1837 , bool _srgb = false
1838 , bool _mipAutogen = false
1839 , bool _array = false
1840 , GLsizei _dim = 16
1841 )
1842 {
1843#if BX_PLATFORM_EMSCRIPTEN
1844 // On web platform read the validity of textures based on the available GL context and extensions
1845 // to avoid developer unfriendly console error noise that would come from probing.
1846 BX_UNUSED(_array, _dim);
1847 return isTextureFormatValidPerSpec(_format, _srgb, _mipAutogen);
1848#else
1849 // On other platforms probe the supported textures.
1850 const TextureFormatInfo& tfi = s_textureFormat[_format];
1851 GLenum internalFmt = _srgb
1852 ? tfi.m_internalFmtSrgb
1853 : tfi.m_internalFmt
1854 ;
1855 if (GL_ZERO == internalFmt)
1856 {
1857 return false;
1858 }
1859
1860 const GLenum target = _array
1861 ? GL_TEXTURE_2D_ARRAY
1862 : GL_TEXTURE_2D
1863 ;
1864
1865 GLuint id;
1866 GL_CHECK(glGenTextures(1, &id) );
1867 GL_CHECK(glBindTexture(target, id) );
1868
1869 GLenum err = 0;
1870 if (_array)
1871 {
1872 glTexStorage3D(target
1873 , 1 + GLsizei(bx::ceilLog2( (int32_t)_dim) )
1874 , internalFmt
1875 , _dim
1876 , _dim
1877 , _dim
1878 );
1879 err = getGlError();
1880 }
1881
1882 if (0 == err)
1883 {
1884 err = initTestTexture(_format, _srgb, _mipAutogen, _array, _dim);
1885 BX_WARN(0 == err, "TextureFormat::%s %s%s%sis not supported (%x: %s)."
1886 , getName(_format)
1887 , _srgb ? "+sRGB " : ""
1888 , _mipAutogen ? "+mipAutoGen " : ""
1889 , _array ? "+array " : ""
1890 , err
1891 , glEnumName(err)
1892 );

Callers 1

initMethod · 0.85

Calls 5

getGlErrorFunction · 0.85
initTestTextureFunction · 0.85
glEnumNameFunction · 0.85
getNameFunction · 0.70

Tested by

no test coverage detected