Cleanup.
This commit is contained in:
parent
d26aac6d2c
commit
e495c613a5
@ -1175,67 +1175,76 @@ namespace bgfx { namespace gl
|
|||||||
return 0 == err ? result : 0;
|
return 0 == err ? result : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t currentlyEnabledVertexAttribArrays = 0;
|
static uint64_t s_currentlyEnabledVertexAttribArrays = 0;
|
||||||
static uint64_t vertexAttribArraysPendingDisable = 0;
|
static uint64_t s_vertexAttribArraysPendingDisable = 0;
|
||||||
static uint64_t vertexAttribArraysPendingEnable = 0;
|
static uint64_t s_vertexAttribArraysPendingEnable = 0;
|
||||||
|
|
||||||
void lazyEnableVertexAttribArray(GLuint index)
|
void lazyEnableVertexAttribArray(GLuint index)
|
||||||
{
|
{
|
||||||
#if BX_PLATFORM_EMSCRIPTEN
|
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||||
// On WebGL platform calling out to WebGL API is detrimental to performance, so optimize
|
{
|
||||||
// out redundant API calls to glEnable/DisableVertexAttribArray.
|
// On WebGL platform calling out to WebGL API is detrimental to performance, so optimize
|
||||||
if (index >= 64)
|
// out redundant API calls to glEnable/DisableVertexAttribArray.
|
||||||
|
if (index >= 64)
|
||||||
|
{
|
||||||
|
glEnableVertexAttribArray(index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t mask = UINT64_C(1) << index;
|
||||||
|
s_vertexAttribArraysPendingEnable |= mask & (~s_currentlyEnabledVertexAttribArrays);
|
||||||
|
s_vertexAttribArraysPendingDisable &= ~mask;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
glEnableVertexAttribArray(index);
|
glEnableVertexAttribArray(index);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
uint64_t mask = 1ULL << index;
|
|
||||||
vertexAttribArraysPendingEnable |= mask & (~currentlyEnabledVertexAttribArrays);
|
|
||||||
vertexAttribArraysPendingDisable &= ~mask;
|
|
||||||
#else
|
|
||||||
glEnableVertexAttribArray(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lazyDisableVertexAttribArray(GLuint index)
|
void lazyDisableVertexAttribArray(GLuint index)
|
||||||
{
|
{
|
||||||
#if BX_PLATFORM_EMSCRIPTEN
|
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||||
// On WebGL platform calling out to WebGL API is detrimental to performance, so optimize
|
{
|
||||||
// out redundant API calls to glEnable/DisableVertexAttribArray.
|
// On WebGL platform calling out to WebGL API is detrimental to performance, so optimize
|
||||||
if (index >= 64)
|
// out redundant API calls to glEnable/DisableVertexAttribArray.
|
||||||
|
if (index >= 64)
|
||||||
|
{
|
||||||
|
glDisableVertexAttribArray(index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t mask = UINT64_C(1) << index;
|
||||||
|
s_vertexAttribArraysPendingDisable |= mask & s_currentlyEnabledVertexAttribArrays;
|
||||||
|
s_vertexAttribArraysPendingEnable &= ~mask;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
glDisableVertexAttribArray(index);
|
glDisableVertexAttribArray(index);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
uint64_t mask = 1ULL << index;
|
|
||||||
vertexAttribArraysPendingDisable |= mask & currentlyEnabledVertexAttribArrays;
|
|
||||||
vertexAttribArraysPendingEnable &= ~mask;
|
|
||||||
#else
|
|
||||||
glDisableVertexAttribArray(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyLazyEnabledVertexAttributes()
|
void applyLazyEnabledVertexAttributes()
|
||||||
{
|
{
|
||||||
#if BX_PLATFORM_EMSCRIPTEN
|
if (BX_ENABLED(BX_PLATFORM_EMSCRIPTEN) )
|
||||||
while(vertexAttribArraysPendingDisable)
|
|
||||||
{
|
{
|
||||||
int index = __builtin_ctzll(vertexAttribArraysPendingDisable);
|
while (s_vertexAttribArraysPendingDisable)
|
||||||
uint64_t mask = ~(1ULL << index);
|
{
|
||||||
vertexAttribArraysPendingDisable &= mask;
|
uint32_t index = bx::uint32_cnttz(s_vertexAttribArraysPendingDisable);
|
||||||
currentlyEnabledVertexAttribArrays &= mask;
|
uint64_t mask = ~(UINT64_C(1) << index);
|
||||||
glDisableVertexAttribArray(index);
|
s_vertexAttribArraysPendingDisable &= mask;
|
||||||
}
|
s_currentlyEnabledVertexAttribArrays &= mask;
|
||||||
|
glDisableVertexAttribArray(index);
|
||||||
|
}
|
||||||
|
|
||||||
while(vertexAttribArraysPendingEnable)
|
while (s_vertexAttribArraysPendingEnable)
|
||||||
{
|
{
|
||||||
int index = __builtin_ctzll(vertexAttribArraysPendingEnable);
|
uint32_t index = bx::uint32_cnttz(s_vertexAttribArraysPendingEnable);
|
||||||
uint64_t mask = 1ULL << index;
|
uint64_t mask = UINT64_C(1) << index;
|
||||||
vertexAttribArraysPendingEnable &= ~mask;
|
s_vertexAttribArraysPendingEnable &= ~mask;
|
||||||
currentlyEnabledVertexAttribArrays |= mask;
|
s_currentlyEnabledVertexAttribArrays |= mask;
|
||||||
glEnableVertexAttribArray(index);
|
glEnableVertexAttribArray(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setTextureFormat(TextureFormat::Enum _format, GLenum _internalFmt, GLenum _fmt, GLenum _type = GL_ZERO)
|
void setTextureFormat(TextureFormat::Enum _format, GLenum _internalFmt, GLenum _fmt, GLenum _type = GL_ZERO)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user