Fixes runtime switch of the GPU skinning.

Fixes #7572, #7630.
This commit is contained in:
Vladislav Belov
2025-04-25 20:13:59 +02:00
parent 0180faa1f2
commit 2264807ad0
3 changed files with 10 additions and 8 deletions
+5 -7
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -236,12 +236,10 @@ void CModel::ValidatePosition()
// For CPU skinning, we precompute as much as possible so that the only
// per-vertex work is a single matrix*vec multiplication.
// For GPU skinning, we try to minimise CPU work by doing most computation
// in the vertex shader instead.
// Using g_RenderingOptions to detect CPU vs GPU is a bit hacky,
// and this doesn't allow the setting to change at runtime, but there isn't
// an obvious cleaner way to determine what data needs to be computed.
bool worldSpaceBoneMatrices = !g_RenderingOptions.GetGPUSkinning();
bool computeBlendMatrices = !g_RenderingOptions.GetGPUSkinning();
// in the compute shader instead.
const bool isGPUSkinningEnabled{g_RenderingOptions.GetGPUSkinning()};
const bool worldSpaceBoneMatrices{!isGPUSkinningEnabled};
const bool computeBlendMatrices{!isGPUSkinningEnabled};
if (m_BoneMatrices && worldSpaceBoneMatrices)
{
+2 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2024 Wildfire Games.
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -219,6 +219,7 @@ void ShaderModelRenderer::Submit(int cullGroup, CModel* model)
const void* key = m->vertexRenderer.get();
if (!rdata || rdata->GetKey() != key)
{
model->InvalidatePosition();
rdata = m->vertexRenderer->CreateModelData(key, model);
model->SetRenderData(rdata);
model->SetDirty(~0u);
+3
View File
@@ -248,6 +248,9 @@ void CRenderingOptions::ReadConfigAndSetupHooks()
m_GPUSkinning = true;
else
LOGMESSAGE("GPU skinning isn't supported on the current hardware.");
if (CRenderer::IsInitialised())
g_Renderer.MakeShadersDirty();
});
m_ConfigHooks->Setup("renderactors", m_RenderActors);