mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-20 22:03:12 +01:00
GL: Detect write only framebuffers.
This commit is contained in:
@@ -3153,7 +3153,8 @@ error:
|
||||
srgbCaps = BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB;
|
||||
}
|
||||
|
||||
if (0 != (_flags & BGFX_TEXTURE_RT_MASK) )
|
||||
if (formatSupported
|
||||
&& 0 != (_flags & BGFX_TEXTURE_RT_MASK) )
|
||||
{
|
||||
formatSupported = 0 != (g_caps.formats[_format] & (0
|
||||
| BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
|
||||
|
||||
@@ -1546,7 +1546,12 @@ namespace bgfx { namespace gl
|
||||
return 0 == err;
|
||||
}
|
||||
|
||||
static bool isFramebufferFormatValid(TextureFormat::Enum _format, bool _srgb = false, GLsizei _dim = 16)
|
||||
static bool isFramebufferFormatValid(
|
||||
TextureFormat::Enum _format
|
||||
, bool _srgb = false
|
||||
, bool _writeOnly = false
|
||||
, GLsizei _dim = 16
|
||||
)
|
||||
{
|
||||
const TextureFormatInfo& tfi = s_textureFormat[_format];
|
||||
GLenum internalFmt = _srgb
|
||||
@@ -1559,6 +1564,24 @@ namespace bgfx { namespace gl
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_writeOnly)
|
||||
{
|
||||
GLuint rbo;
|
||||
glGenRenderbuffers(1, &rbo);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
|
||||
|
||||
glRenderbufferStorage(GL_RENDERBUFFER
|
||||
, s_rboFormat[_format]
|
||||
, _dim
|
||||
, _dim
|
||||
);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
glDeleteRenderbuffers(1, &rbo);
|
||||
|
||||
GLenum err = glGetError();
|
||||
return 0 == err;
|
||||
}
|
||||
|
||||
GLuint fbo;
|
||||
GL_CHECK(glGenFramebuffers(1, &fbo) );
|
||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, fbo) );
|
||||
@@ -2166,6 +2189,11 @@ namespace bgfx { namespace gl
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
supported |= isFramebufferFormatValid(TextureFormat::Enum(ii), false, true)
|
||||
? BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER
|
||||
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||
;
|
||||
|
||||
if (NULL != glGetInternalformativ)
|
||||
{
|
||||
GLint maxSamples;
|
||||
|
||||
Reference in New Issue
Block a user