MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / isFramebufferFormatValid

Function isFramebufferFormatValid

Source/3rdParty/bgfx/src/renderer_gl.cpp:2059–2153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2057#endif
2058
2059 static bool isFramebufferFormatValid(
2060 TextureFormat::Enum _format
2061 , bool _srgb = false
2062 , bool _writeOnly = false
2063 , GLsizei _dim = 16
2064 )
2065 {
2066#if BX_PLATFORM_EMSCRIPTEN
2067 // On web platform read the validity of framebuffers based on the available GL context and extensions
2068 // to avoid developer unfriendly console error noise that would come from probing.
2069 BX_UNUSED(_dim);
2070 return isFramebufferFormatValidPerSpec(_format, _srgb, _writeOnly);
2071#else
2072 // On other platforms probe the supported textures.
2073 const TextureFormatInfo& tfi = s_textureFormat[_format];
2074 GLenum internalFmt = _srgb
2075 ? tfi.m_internalFmtSrgb
2076 : tfi.m_internalFmt
2077 ;
2078 if (GL_ZERO == internalFmt)
2079 {
2080 return false;
2081 }
2082
2083 if (_writeOnly)
2084 {
2085 GLuint rbo;
2086 glGenRenderbuffers(1, &rbo);
2087 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
2088
2089 glRenderbufferStorage(GL_RENDERBUFFER
2090 , s_rboFormat[_format]
2091 , _dim
2092 , _dim
2093 );
2094 glBindRenderbuffer(GL_RENDERBUFFER, 0);
2095 glDeleteRenderbuffers(1, &rbo);
2096
2097 GLenum err = getGlError();
2098 return 0 == err;
2099 }
2100
2101 GLuint fbo;
2102 GL_CHECK(glGenFramebuffers(1, &fbo) );
2103 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, fbo) );
2104
2105 GLuint id;
2106 GL_CHECK(glGenTextures(1, &id) );
2107 GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) );
2108
2109 GLenum err = initTestTexture(_format, _srgb, false, false, _dim);
2110
2111 GLenum attachment;
2112 if (bimg::isDepth(bimg::TextureFormat::Enum(_format) ) )
2113 {
2114 const bimg::ImageBlockInfo& info = bimg::getBlockInfo(bimg::TextureFormat::Enum(_format) );
2115 if (0 == info.depthBits)
2116 {

Callers 1

initMethod · 0.85

Calls 5

getGlErrorFunction · 0.85
initTestTextureFunction · 0.85
isDepthFunction · 0.85
EnumEnum · 0.70

Tested by

no test coverage detected