diff --git a/src/bgfx_p.h b/src/bgfx_p.h index cd8e9305b..7f7b34565 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -1956,7 +1956,9 @@ namespace bgfx BGFX_API_FUNC(DynamicVertexBufferHandle createDynamicVertexBuffer(const Memory* _mem, const VertexDecl& _decl) ) { - DynamicVertexBufferHandle handle = createDynamicVertexBuffer(_mem->size/_decl.m_stride, _decl); + uint32_t numVertices = _mem->size/_decl.m_stride; + BX_CHECK(numVertices <= UINT16_MAX, "Num vertices exceeds maximum (num %d, max %d).", numVertices, UINT16_MAX); + DynamicVertexBufferHandle handle = createDynamicVertexBuffer(uint16_t(numVertices), _decl); if (isValid(handle) ) { updateDynamicVertexBuffer(handle, _mem); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index b8f93cef8..67c4640fe 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2461,14 +2461,56 @@ namespace bgfx m_constantBuffer = ConstantBuffer::create(1024); m_numSamplers = 0; + struct VariableInfo + { + GLenum type; + GLint loc; + GLint num; + }; + VariableInfo vi; + GLenum props[] = { GL_TYPE, GL_LOCATION, GL_ARRAY_SIZE }; + + const bool piqSupported = s_extension[Extension::ARB_program_interface_query].m_supported; + BX_TRACE("Uniforms (%d):", activeUniforms); for (int32_t ii = 0; ii < activeUniforms; ++ii) { - GLint num; GLenum gltype; + GLint num; + GLint loc; - GL_CHECK(glGetActiveUniform(m_id, ii, maxLength + 1, NULL, &num, &gltype, name) ); - GLint loc = glGetUniformLocation(m_id, name); + if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES >= 31) + || piqSupported) + { + GL_CHECK(glGetProgramResourceiv(m_id + , GL_UNIFORM + , ii + , BX_COUNTOF(props) + , props + , BX_COUNTOF(props) + , NULL + , (GLint*)&vi + ) ); + + GL_CHECK(glGetProgramResourceName(m_id + , GL_UNIFORM + , ii + , maxLength + 1 + , NULL + , name + ) ); + + gltype = vi.type; + loc = vi.loc; + num = vi.num; + } + else + { + GL_CHECK(glGetActiveUniform(m_id, ii, maxLength + 1, NULL, &num, &gltype, name) ); + loc = glGetUniformLocation(m_id, name); + } + + num = bx::uint32_max(num, 1); int offset = 0; char* array = strchr(name, '['); @@ -2844,7 +2886,7 @@ namespace bgfx { uint8_t numMips = imageContainer.m_numMips; const uint32_t startLod = bx::uint32_min(_skip, numMips-1); - numMips -= startLod; + numMips -= uint8_t(startLod); const ImageBlockInfo& blockInfo = getBlockInfo(TextureFormat::Enum(imageContainer.m_format) ); const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod); const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod); diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 44d778191..d0a06dc99 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -456,6 +456,14 @@ typedef uint64_t GLuint64; # define GL_TYPE 0x92FA #endif // GL_TYPE +#ifndef GL_ARRAY_SIZE +# define GL_ARRAY_SIZE 0x92FB +#endif // GL_ARRAY_SIZE + +#ifndef GL_LOCATION +# define GL_LOCATION 0x930E +#endif // GL_LOCATION + #if BX_PLATFORM_NACL # include "glcontext_ppapi.h" #elif BX_PLATFORM_WINDOWS