Remove hardcoded max 1024 bones for skinning
This commit is contained in:
parent
1b70144c80
commit
e61eb3415a
@ -461,4 +461,10 @@
|
||||
<fonts-list normal-ttf="Cantarell-Regular.otf FreeSans.ttf wqy-microhei.ttf NotoNaskhArabicUI-Bold.ttf"
|
||||
digit-ttf="SigmarOne.otf" />
|
||||
|
||||
<!-- Maximum bones from all animated meshes in each frame to be uploaded for
|
||||
hardware skinning, For gles 3.0 the specification guarantees at least 2048, for
|
||||
TBO in desktop at least 65536 (max buffer size) / 64, SSBO at least 2^24 / 64,
|
||||
so 1024 will work everywhere. -->
|
||||
<skinning max-bones="1024"/>
|
||||
|
||||
</config>
|
||||
|
@ -181,6 +181,7 @@ void STKConfig::init_defaults()
|
||||
m_disable_steer_while_unskid = false;
|
||||
m_camera_follow_skid = false;
|
||||
m_cutscene_fov = 0.61f;
|
||||
m_max_skinning_bones = 1024;
|
||||
|
||||
m_score_increase.clear();
|
||||
m_leader_intervals.clear();
|
||||
@ -364,6 +365,11 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
fonts_list->get("digit-ttf", &m_digit_ttf );
|
||||
}
|
||||
|
||||
if (const XMLNode *skinning = root->getNode("skinning"))
|
||||
{
|
||||
skinning->get("max-bones", &m_max_skinning_bones);
|
||||
}
|
||||
|
||||
// Get the default KartProperties
|
||||
// ------------------------------
|
||||
const XMLNode *node = root -> getNode("general-kart-defaults");
|
||||
|
@ -152,6 +152,8 @@ public:
|
||||
|
||||
float m_cutscene_fov;
|
||||
|
||||
unsigned m_max_skinning_bones;
|
||||
|
||||
/** Lists of TTF files used in STK. */
|
||||
std::vector<std::string> m_normal_ttf;
|
||||
std::vector<std::string> m_digit_ttf;
|
||||
|
@ -246,11 +246,6 @@ void CentralVideoSettings::init()
|
||||
hasSRGBFramebuffer = false;
|
||||
}
|
||||
}
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_HARDWARE_SKINNING))
|
||||
{
|
||||
Log::info("GLDriver", "Hardware Skinning enabled, method: %s",
|
||||
isARBShaderStorageBufferObjectUsable() ? "SSBO" : "TBO");
|
||||
}
|
||||
#else
|
||||
if (m_glsl == true)
|
||||
{
|
||||
@ -291,10 +286,6 @@ void CentralVideoSettings::init()
|
||||
{
|
||||
m_need_vertex_id_workaround = true;
|
||||
}
|
||||
if (!GraphicsRestrictions::isDisabled(GraphicsRestrictions::GR_HARDWARE_SKINNING))
|
||||
{
|
||||
Log::info("GLDriver", "Hardware Skinning enabled, method: 1024 * 16 RGBA float texture");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Only unset the high def textures if they are set as default. If the
|
||||
|
@ -18,6 +18,7 @@
|
||||
#ifndef SERVER_ONLY
|
||||
#include "graphics/draw_calls.hpp"
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/command_buffer.hpp"
|
||||
#include "graphics/cpu_particle_manager.hpp"
|
||||
@ -260,12 +261,12 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node,
|
||||
{
|
||||
skinning_offset = getSkinningOffset();
|
||||
if (skinning_offset + am->getTotalJoints() >
|
||||
SharedGPUObjects::getMaxMat4Size())
|
||||
stk_config->m_max_skinning_bones)
|
||||
{
|
||||
Log::error("DrawCalls", "Don't have enough space to render skinned"
|
||||
" mesh %s! Max joints can hold: %d",
|
||||
am->getMeshDebugName().c_str(),
|
||||
SharedGPUObjects::getMaxMat4Size());
|
||||
stk_config->m_max_skinning_bones);
|
||||
return;
|
||||
}
|
||||
m_mesh_for_skinning.insert(am);
|
||||
|
@ -18,8 +18,8 @@
|
||||
#ifndef SERVER_ONLY
|
||||
|
||||
#include "graphics/shader_files_manager.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
@ -188,7 +188,7 @@ GLuint ShaderFilesManager::loadShader(const std::string &file, unsigned type)
|
||||
else
|
||||
code << "precision mediump float;\n";
|
||||
#endif
|
||||
code << "#define MAX_BONES " << SharedGPUObjects::getMaxMat4Size() << "\n";
|
||||
code << "#define MAX_BONES " << stk_config->m_max_skinning_bones << "\n";
|
||||
|
||||
code << getHeader();
|
||||
|
||||
|
@ -18,12 +18,10 @@
|
||||
#ifndef SERVER_ONLY
|
||||
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
#include "matrix4.h"
|
||||
#include <algorithm>
|
||||
|
||||
GLuint SharedGPUObjects::m_sky_tri_vbo;
|
||||
GLuint SharedGPUObjects::m_frustrum_vbo;
|
||||
GLuint SharedGPUObjects::m_frustrum_indices;
|
||||
@ -35,7 +33,6 @@ GLuint SharedGPUObjects::m_quad_buffer;
|
||||
GLuint SharedGPUObjects::m_quad_vbo;
|
||||
GLuint SharedGPUObjects::m_skinning_tex;
|
||||
GLuint SharedGPUObjects::m_skinning_buf;
|
||||
int SharedGPUObjects::m_max_mat4_size = 1024;
|
||||
bool SharedGPUObjects::m_has_been_initialised = false;
|
||||
|
||||
/** Initialises m_full_screen_quad_vbo.
|
||||
@ -161,23 +158,50 @@ void SharedGPUObjects::initLightingDataUBO()
|
||||
// ----------------------------------------------------------------------------
|
||||
void SharedGPUObjects::initSkinning()
|
||||
{
|
||||
m_max_mat4_size = 1024;
|
||||
glGenTextures(1, &m_skinning_tex);
|
||||
int max_size = 0;
|
||||
#ifdef USE_GLES2
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
|
||||
|
||||
if (stk_config->m_max_skinning_bones > (unsigned)max_size)
|
||||
{
|
||||
Log::warn("SharedGPUObjects", "Too many bones for skinning, max: %d",
|
||||
max_size);
|
||||
stk_config->m_max_skinning_bones = max_size;
|
||||
}
|
||||
Log::info("SharedGPUObjects", "Hardware Skinning enabled, method: %u"
|
||||
" (max bones) * 16 RGBA float texture",
|
||||
stk_config->m_max_skinning_bones);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_skinning_tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16, 1024, 0, GL_RGBA, GL_FLOAT,
|
||||
NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 16,
|
||||
stk_config->m_max_skinning_bones, 0, GL_RGBA, GL_FLOAT, NULL);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
#else
|
||||
|
||||
glGenBuffers(1, &m_skinning_buf);
|
||||
const bool ssbo = CVS->isARBShaderStorageBufferObjectUsable();
|
||||
glGetIntegerv(ssbo ? GL_MAX_SHADER_STORAGE_BLOCK_SIZE :
|
||||
GL_MAX_TEXTURE_BUFFER_SIZE, &max_size);
|
||||
|
||||
if (stk_config->m_max_skinning_bones * 64 > (unsigned)max_size)
|
||||
{
|
||||
Log::warn("SharedGPUObjects", "Too many bones for skinning, max: %d",
|
||||
max_size >> 6);
|
||||
stk_config->m_max_skinning_bones = max_size >> 6;
|
||||
}
|
||||
Log::info("SharedGPUObjects", "Hardware Skinning enabled, method: %s, "
|
||||
"max bones: %u", CVS->isARBShaderStorageBufferObjectUsable() ?
|
||||
"SSBO" : "TBO", stk_config->m_max_skinning_bones);
|
||||
|
||||
const GLenum buffer = ssbo ? GL_SHADER_STORAGE_BUFFER : GL_TEXTURE_BUFFER;
|
||||
glBindBuffer(buffer, m_skinning_buf);
|
||||
glBufferData(buffer, 65536, NULL, GL_DYNAMIC_DRAW);
|
||||
glBufferData(buffer, stk_config->m_max_skinning_bones * 64, NULL,
|
||||
GL_DYNAMIC_DRAW);
|
||||
if (!ssbo)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_BUFFER, m_skinning_tex);
|
||||
|
@ -37,7 +37,6 @@ private:
|
||||
static GLuint m_quad_vbo;
|
||||
static GLuint m_skinning_tex;
|
||||
static GLuint m_skinning_buf;
|
||||
static int m_max_mat4_size;
|
||||
|
||||
static void initQuadVBO();
|
||||
static void initQuadBuffer();
|
||||
@ -109,18 +108,14 @@ public:
|
||||
{
|
||||
assert(m_has_been_initialised);
|
||||
return m_skinning_tex;
|
||||
} // getSkinningTex
|
||||
} // getSkinningTexture
|
||||
// ------------------------------------------------------------------------
|
||||
static GLuint getSkinningBuffer()
|
||||
{
|
||||
assert(m_has_been_initialised);
|
||||
return m_skinning_buf;
|
||||
} // getSkinningBuffer
|
||||
// ------------------------------------------------------------------------
|
||||
static int getMaxMat4Size()
|
||||
{
|
||||
return m_max_mat4_size;
|
||||
} // getMaxMat4Size
|
||||
|
||||
}; // class SharedGPUObjects
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "states_screens/dialogs/custom_video_settings.hpp"
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "guiengine/widgets/check_box_widget.hpp"
|
||||
#include "guiengine/widgets/spinner_widget.hpp"
|
||||
@ -24,7 +25,6 @@
|
||||
#include "utils/translation.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
@ -40,7 +40,7 @@ CustomVideoSettingsDialog::CustomVideoSettingsDialog(const float w, const float
|
||||
ModalDialog(w, h), m_all_kart_animated(true)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
m_all_kart_animated = SharedGPUObjects::getMaxMat4Size() > 512 ||
|
||||
m_all_kart_animated = stk_config->m_max_skinning_bones > 512 ||
|
||||
!CVS->supportsHardwareSkinning();
|
||||
#endif
|
||||
loadFromFile("custom_video_settings.stkgui");
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/central_settings.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/shared_gpu_objects.hpp"
|
||||
#include "graphics/stk_tex_manager.hpp"
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/button_widget.hpp"
|
||||
@ -88,7 +88,7 @@ void OptionsScreenVideo::initPresets()
|
||||
true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */, true /* weather */,
|
||||
2 /* animatedScenery */,
|
||||
#ifndef SERVER_ONLY
|
||||
(SharedGPUObjects::getMaxMat4Size() > 512 || !CVS->supportsHardwareSkinning() ? 2 : 1),
|
||||
(stk_config->m_max_skinning_bones > 512 || !CVS->supportsHardwareSkinning() ? 2 : 1),
|
||||
#else
|
||||
2 /* animatedCharacters */,
|
||||
#endif
|
||||
@ -102,7 +102,7 @@ void OptionsScreenVideo::initPresets()
|
||||
true /* lightshaft */, true /* glow */, true /* mlaa */, true /* ssao */, true /* weather */,
|
||||
2 /* animatedScenery */,
|
||||
#ifndef SERVER_ONLY
|
||||
(SharedGPUObjects::getMaxMat4Size() > 512 || !CVS->supportsHardwareSkinning() ? 2 : 1),
|
||||
(stk_config->m_max_skinning_bones > 512 || !CVS->supportsHardwareSkinning() ? 2 : 1),
|
||||
#else
|
||||
2 /* animatedCharacters */,
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user