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

Function isFramebufferFormatValidPerSpec

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

Source from the content-addressed store, hash-verified

1941
1942#if BX_PLATFORM_EMSCRIPTEN
1943 static bool isFramebufferFormatValidPerSpec(
1944 TextureFormat::Enum _format
1945 , bool _srgb
1946 , bool _writeOnly
1947 )
1948 {
1949 // Avoid creating test textures for WebGL, that causes error noise in the browser console; instead examine the supported texture formats from the spec.
1950 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context();
1951
1952 EmscriptenWebGLContextAttributes attrs;
1953 EMSCRIPTEN_CHECK(emscripten_webgl_get_context_attributes(ctx, &attrs) );
1954
1955 const int glesVersion = attrs.majorVersion + 1;
1956
1957 switch(_format)
1958 {
1959 // GLES2 textures
1960 case TextureFormat::B5G6R5:
1961 case TextureFormat::R5G6B5:
1962 case TextureFormat::BGRA4:
1963 case TextureFormat::RGBA4:
1964 case TextureFormat::BGR5A1:
1965 case TextureFormat::RGB5A1:
1966 case TextureFormat::D16:
1967 return !_srgb;
1968
1969 // GLES2 renderbuffers not a texture in GLES3
1970 case TextureFormat::D0S8:
1971 return !_srgb
1972 && _writeOnly
1973 ;
1974
1975 // GLES2 textures that are not renderbuffers
1976 case TextureFormat::RGB8:
1977 case TextureFormat::RGBA8:
1978 return !_srgb
1979 && (!_writeOnly || glesVersion >= 3)
1980 ;
1981
1982 // GLES3 EXT_color_buffer_float renderbuffer formats
1983 case TextureFormat::R16F:
1984 case TextureFormat::RG16F:
1985 case TextureFormat::R32F:
1986 case TextureFormat::RG32F:
1987 case TextureFormat::RG11B10F:
1988 if (_writeOnly)
1989 {
1990 return emscripten_webgl_enable_extension(ctx, "EXT_color_buffer_float");
1991 }
1992
1993 return !_srgb && glesVersion >= 3;
1994
1995 // GLES2 float extension:
1996 case TextureFormat::RGBA16F:
1997 if (_writeOnly && emscripten_webgl_enable_extension(ctx, "EXT_color_buffer_half_float") )
1998 {
1999 return true;
2000 }

Callers 1

isFramebufferFormatValidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected