Skip to content

Commit

Permalink
Fix invalid memory access
Browse files Browse the repository at this point in the history
  • Loading branch information
CodingJellyfish committed Dec 19, 2024
1 parent 724a28c commit f72d62c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/graphics/sp/sp_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ unsigned g_skinning_offset = 0;
// ----------------------------------------------------------------------------
std::vector<SPMeshNode*> g_skinning_mesh;
// ----------------------------------------------------------------------------
int g_skinning_tbo_limit = 0;
bool g_skinning_use_tbo = false;
// ----------------------------------------------------------------------------
int sp_cur_shadow_cascade = 0;
// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -319,12 +319,13 @@ void initSkinning()
else
{
#ifndef USE_GLES2
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &g_skinning_tbo_limit);
if (stk_config->m_max_skinning_bones << 6 > (unsigned)g_skinning_tbo_limit)
int skinning_tbo_limit;
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &skinning_tbo_limit);
if (stk_config->m_max_skinning_bones << 6 > (unsigned)skinning_tbo_limit)
{
Log::warn("SharedGPUObjects", "Too many bones for skinning, max: %d",
g_skinning_tbo_limit >> 6);
stk_config->m_max_skinning_bones = g_skinning_tbo_limit >> 6;
skinning_tbo_limit >> 6);
stk_config->m_max_skinning_bones = skinning_tbo_limit >> 6;
}
Log::info("SharedGPUObjects", "Hardware Skinning enabled, method: TBO, "
"max bones: %u", stk_config->m_max_skinning_bones);
Expand Down Expand Up @@ -444,7 +445,14 @@ void init()

if (CVS->isARBTextureBufferObjectUsable())
{
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE_ARB, &g_skinning_tbo_limit);
int skinning_tbo_limit;
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE_ARB, &skinning_tbo_limit);

g_skinning_use_tbo = skinning_tbo_limit >= stk_config->m_max_skinning_bones << 6;
}
else
{
g_skinning_use_tbo = false;
}

initSkinning();
Expand Down Expand Up @@ -655,8 +663,7 @@ SPShader* getNormalVisualizer()
// ----------------------------------------------------------------------------
bool skinningUseTBO()
{
return CVS->isARBTextureBufferObjectUsable()
&& g_skinning_tbo_limit >= 64 * stk_config->m_max_skinning_bones;
return g_skinning_use_tbo;
}


Expand Down

0 comments on commit f72d62c

Please sign in to comment.