summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src/renderer_gl.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src/renderer_gl.cpp')
-rw-r--r--3rdparty/bgfx/src/renderer_gl.cpp53
1 files changed, 37 insertions, 16 deletions
diff --git a/3rdparty/bgfx/src/renderer_gl.cpp b/3rdparty/bgfx/src/renderer_gl.cpp
index 0feccaf9680..7fc65a3dbd8 100644
--- a/3rdparty/bgfx/src/renderer_gl.cpp
+++ b/3rdparty/bgfx/src/renderer_gl.cpp
@@ -246,6 +246,10 @@ namespace bgfx { namespace gl
{ GL_RG32I, GL_ZERO, GL_RG, GL_INT, false }, // RG32I
{ GL_RG32UI, GL_ZERO, GL_RG, GL_UNSIGNED_INT, false }, // RG32U
{ GL_RG32F, GL_ZERO, GL_RG, GL_FLOAT, false }, // RG32F
+ { GL_RGB8, GL_SRGB8, GL_RGB, GL_UNSIGNED_BYTE, false }, // RGB8
+ { GL_RGB8I, GL_ZERO, GL_RGB, GL_BYTE, false }, // RGB8I
+ { GL_RGB8UI, GL_ZERO, GL_RGB, GL_UNSIGNED_BYTE, false }, // RGB8U
+ { GL_RGB8_SNORM, GL_ZERO, GL_RGB, GL_BYTE, false }, // RGB8S
{ GL_RGB9_E5, GL_ZERO, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, false }, // RGB9E5F
{ GL_RGBA8, GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE, false }, // BGRA8
{ GL_RGBA8, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false }, // RGBA8
@@ -260,7 +264,7 @@ namespace bgfx { namespace gl
{ GL_RGBA32I, GL_ZERO, GL_RGBA, GL_INT, false }, // RGBA32I
{ GL_RGBA32UI, GL_ZERO, GL_RGBA, GL_UNSIGNED_INT, false }, // RGBA32U
{ GL_RGBA32F, GL_ZERO, GL_RGBA, GL_FLOAT, false }, // RGBA32F
- { GL_RGB565, GL_ZERO, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false }, // R5G6B5
+ { GL_RGB565, GL_ZERO, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, false }, // R5G6B5
{ GL_RGBA4, GL_ZERO, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, false }, // RGBA4
{ GL_RGB5_A1, GL_ZERO, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false }, // RGB5A1
{ GL_RGB10_A2, GL_ZERO, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false }, // RGB10A2
@@ -325,6 +329,10 @@ namespace bgfx { namespace gl
GL_RG32I, // RG32I
GL_RG32UI, // RG32U
GL_RG32F, // RG32F
+ GL_RGB8, // RGB8
+ GL_RGB8I, // RGB8I
+ GL_RGB8UI, // RGB8UI
+ GL_RGB8_SNORM, // RGB8S
GL_RGB9_E5, // RGB9E5F
GL_RGBA8, // BGRA8
GL_RGBA8, // RGBA8
@@ -402,6 +410,10 @@ namespace bgfx { namespace gl
GL_RG32I, // RG32I
GL_RG32UI, // RG32U
GL_RG32F, // RG32F
+ GL_RGB8, // RGB8
+ GL_RGB8I, // RGB8I
+ GL_RGB8UI, // RGB8UI
+ GL_RGB8_SNORM, // RGB8S
GL_RGB9_E5, // RGB9E5F
GL_RGBA8, // BGRA8
GL_RGBA8, // RGBA8
@@ -1551,6 +1563,8 @@ namespace bgfx { namespace gl
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL)
|| BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 30) )
{
+ setTextureFormat(TextureFormat::R8I, GL_R8I, GL_RED_INTEGER, GL_BYTE);
+ setTextureFormat(TextureFormat::R8U, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE);
setTextureFormat(TextureFormat::R16I, GL_R16I, GL_RED_INTEGER, GL_SHORT);
setTextureFormat(TextureFormat::R16U, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT);
// setTextureFormat(TextureFormat::RG16, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT);
@@ -3692,9 +3706,19 @@ namespace bgfx { namespace gl
case GL_IMAGE_CUBE:
case GL_INT_IMAGE_CUBE:
case GL_UNSIGNED_INT_IMAGE_CUBE:
- BX_TRACE("Sampler #%d at location %d.", m_numSamplers, loc);
- m_sampler[m_numSamplers] = loc;
- m_numSamplers++;
+ if (m_numSamplers < BX_COUNTOF(m_sampler) )
+ {
+ BX_TRACE("Sampler #%d at location %d.", m_numSamplers, loc);
+ m_sampler[m_numSamplers] = loc;
+ m_numSamplers++;
+ }
+ else
+ {
+ BX_TRACE("Too many samplers (max: %d)! Sampler at location %d."
+ , BX_COUNTOF(m_sampler)
+ , loc
+ );
+ }
break;
default:
@@ -3949,7 +3973,7 @@ namespace bgfx { namespace gl
}
}
- bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, TextureFormat::Enum _format, uint8_t _numMips, uint32_t _flags)
+ bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint32_t _flags)
{
m_target = _target;
m_numMips = _numMips;
@@ -3957,9 +3981,7 @@ namespace bgfx { namespace gl
m_width = _width;
m_height = _height;
m_depth = _depth;
- m_currentSamplerHash = UINT32_MAX;
- m_requestedFormat =
- m_textureFormat = uint8_t(_format);
+ m_currentSamplerHash = UINT32_MAX;
const bool writeOnly = 0 != (m_flags&BGFX_TEXTURE_RT_WRITE_ONLY);
const bool computeWrite = 0 != (m_flags&BGFX_TEXTURE_COMPUTE_WRITE );
@@ -3970,7 +3992,7 @@ namespace bgfx { namespace gl
BX_CHECK(0 != m_id, "Failed to generate texture id.");
GL_CHECK(glBindTexture(_target, m_id) );
- const TextureFormatInfo& tfi = s_textureFormat[_format];
+ const TextureFormatInfo& tfi = s_textureFormat[m_textureFormat];
m_fmt = tfi.m_fmt;
m_type = tfi.m_type;
@@ -3979,11 +4001,9 @@ namespace bgfx { namespace gl
&& !s_textureFormat[m_requestedFormat].m_supported
&& !s_renderGL->m_textureSwizzleSupport
;
- const bool compressed = isCompressed(TextureFormat::Enum(m_requestedFormat) );
- const bool convert = false
- || (compressed && m_textureFormat != m_requestedFormat)
+ const bool convert = false
+ || m_textureFormat != m_requestedFormat
|| swizzle
- || !s_textureFormat[m_requestedFormat].m_supported
;
if (convert)
@@ -4095,6 +4115,9 @@ namespace bgfx { namespace gl
textureDepth = imageContainer.m_depth;
}
+ m_requestedFormat = uint8_t(imageContainer.m_format);
+ m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
+
GLenum target = GL_TEXTURE_2D;
if (imageContainer.m_cubeMap)
{
@@ -4109,7 +4132,6 @@ namespace bgfx { namespace gl
, textureWidth
, textureHeight
, textureDepth
- , imageContainer.m_format
, numMips
, _flags
) )
@@ -4590,7 +4612,7 @@ namespace bgfx { namespace gl
for (uint32_t ii = 0; ii < count; ++ii)
{
- uint8_t nameSize;
+ uint8_t nameSize = 0;
bx::read(&reader, nameSize);
char name[256];
@@ -6638,4 +6660,3 @@ namespace bgfx { namespace gl
} /* namespace gl */ } // namespace bgfx
#endif // (BGFX_CONFIG_RENDERER_OPENGLES || BGFX_CONFIG_RENDERER_OPENGL)
-