diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 173d0020e..f45ba42b1 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -394,9 +394,9 @@ namespace bgfx Count }; - uint8_t m_type; - uint16_t m_loc; + uint32_t m_loc; uint16_t m_count; + uint8_t m_type; }; const char* getPredefinedUniformName(PredefinedUniform::Enum _enum); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index cb533f049..87a169f71 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1116,7 +1116,8 @@ namespace bgfx { data = info->m_data; UniformType::Enum type = convertGlType(gltype); - m_constantBuffer->writeUniformRef(type, loc, data, num); + m_constantBuffer->writeUniformRef(type, 0, data, num); + m_constantBuffer->write(loc); BX_TRACE("store %s %p", name, data); } } @@ -1141,8 +1142,8 @@ namespace bgfx uint32_t used = 0; for (uint32_t ii = 0; ii < Attrib::Count; ++ii) { - GLuint loc = glGetAttribLocation(m_id, s_attribName[ii]); - if (GLuint(-1) != loc ) + GLint loc = glGetAttribLocation(m_id, s_attribName[ii]); + if (-1 != loc) { BX_TRACE("attr %s: %d", s_attribName[ii], loc); m_attributes[ii] = loc; @@ -1170,14 +1171,14 @@ namespace bgfx for (uint32_t ii = 0; Attrib::Count != m_used[ii]; ++ii) { Attrib::Enum attr = Attrib::Enum(m_used[ii]); - GLuint loc = m_attributes[attr]; + GLint loc = m_attributes[attr]; uint8_t num; AttribType::Enum type; bool normalized; _vertexDecl.decode(attr, num, type, normalized); - if (0xffff != loc + if (-1 != loc && 0xff != _vertexDecl.m_attributes[attr]) { GL_CHECK(glEnableVertexAttribArray(loc) ); @@ -1223,7 +1224,7 @@ namespace bgfx uint32_t baseVertex = _baseVertex; for (uint32_t ii = 0; 0xffff != m_instanceData[ii]; ++ii) { - GLuint loc = m_instanceData[ii]; + GLint loc = m_instanceData[ii]; GL_CHECK(glEnableVertexAttribArray(loc) ); GL_CHECK(glVertexAttribPointer(loc, 4, GL_FLOAT, GL_FALSE, _stride, (void*)(uintptr_t)baseVertex) ); GL_CHECK(s_vertexAttribDivisor(loc, 1) ); @@ -1855,10 +1856,10 @@ namespace bgfx } UniformType::Enum type; - uint16_t loc; + uint16_t ignore; uint16_t num; uint16_t copy; - decodeOpcode(opcode, type, loc, num, copy); + decodeOpcode(opcode, type, ignore, num, copy); const char* data; if (copy) @@ -1870,6 +1871,8 @@ namespace bgfx memcpy(&data, read(sizeof(void*) ), sizeof(void*) ); } + uint32_t loc = read(); + #define CASE_IMPLEMENT_UNIFORM(_uniform, _glsuffix, _dxsuffix, _type) \ case UniformType::_uniform: \ { \ diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 6adcb865a..fca4fcf98 100644 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -432,11 +432,10 @@ namespace bgfx GLuint m_id; uint8_t m_used[Attrib::Count+1]; // dense - uint16_t m_attributes[Attrib::Count]; // sparse - uint16_t m_instanceData[BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT]; - uint32_t m_enabled; + GLint m_attributes[Attrib::Count]; // sparse + GLint m_instanceData[BGFX_CONFIG_MAX_INSTANCE_DATA_COUNT]; - GLuint m_sampler[BGFX_CONFIG_MAX_TEXTURES]; + GLint m_sampler[BGFX_CONFIG_MAX_TEXTURES]; uint8_t m_numSamplers; ConstantBuffer* m_constantBuffer;