Account for ConstTexCoord.

This commit is contained in:
Skyth 2024-11-26 23:02:16 +03:00
parent f1eb4992ab
commit e92d839e4b
5 changed files with 95 additions and 4 deletions

View file

@ -27,7 +27,7 @@ namespace Hedgehog::Mirage
public: public:
hh::map<Base::CStringSymbol, boost::shared_ptr<CVertexShaderPermutationData>> m_VertexShaderPermutations; hh::map<Base::CStringSymbol, boost::shared_ptr<CVertexShaderPermutationData>> m_VertexShaderPermutations;
hh::map<be<uint32_t>, boost::shared_ptr<CPixelShaderData>> m_PixelShaders; hh::map<be<uint32_t>, boost::shared_ptr<CPixelShaderData>> m_PixelShaders;
uint32_t m_SubPermutations; be<uint32_t> m_SubPermutations;
}; };
SWA_ASSERT_OFFSETOF(CPixelShaderPermutationData, m_VertexShaderPermutations, 0x0); SWA_ASSERT_OFFSETOF(CPixelShaderPermutationData, m_VertexShaderPermutations, 0x0);

View file

@ -0,0 +1,24 @@
#pragma once
#include <boost/smart_ptr/shared_ptr.h>
#include <Hedgehog/Base/Container/hhVector.h>
#include <Hedgehog/Database/System/hhDatabaseData.h>
namespace Hedgehog::Mirage
{
class CTextureData;
class CTexsetData : public Database::CDatabaseData
{
public:
hh::vector<boost::shared_ptr<CTextureData>> m_TextureList;
hh::vector<Base::CSharedString> m_TextureNameList;
bool m_ConstTexCoord;
};
SWA_ASSERT_OFFSETOF(CTexsetData, m_TextureList, 0xC);
SWA_ASSERT_OFFSETOF(CTexsetData, m_TextureNameList, 0x1C);
SWA_ASSERT_OFFSETOF(CTexsetData, m_ConstTexCoord, 0x2C);
SWA_ASSERT_SIZEOF(CTexsetData, 0x30);
}

View file

@ -0,0 +1,17 @@
#pragma once
#include <Hedgehog/Database/System/hhDatabaseData.h>
namespace Hedgehog::Mirage
{
class CTextureData : public Database::CDatabaseData
{
public:
SWA_INSERT_PADDING(0x8);
uint8_t m_TexcoordIndex;
SWA_INSERT_PADDING(0x1B);
};
SWA_ASSERT_OFFSETOF(CTextureData, m_TexcoordIndex, 0x14);
SWA_ASSERT_SIZEOF(CTextureData, 0x30);
}

View file

@ -37,6 +37,8 @@
#include "Hedgehog/MirageCore/RenderData/hhPixelShaderData.h" #include "Hedgehog/MirageCore/RenderData/hhPixelShaderData.h"
#include "Hedgehog/MirageCore/RenderData/hhShaderListData.h" #include "Hedgehog/MirageCore/RenderData/hhShaderListData.h"
#include "Hedgehog/MirageCore/RenderData/hhTerrainModelData.h" #include "Hedgehog/MirageCore/RenderData/hhTerrainModelData.h"
#include "Hedgehog/MirageCore/RenderData/hhTexsetData.h"
#include "Hedgehog/MirageCore/RenderData/hhTextureData.h"
#include "Hedgehog/MirageCore/RenderData/hhVertexShaderCodeData.h" #include "Hedgehog/MirageCore/RenderData/hhVertexShaderCodeData.h"
#include "Hedgehog/MirageCore/RenderData/hhVertexShaderData.h" #include "Hedgehog/MirageCore/RenderData/hhVertexShaderData.h"
#include "Hedgehog/MirageCore/Renderable/hhRenderable.h" #include "Hedgehog/MirageCore/Renderable/hhRenderable.h"

View file

@ -4340,6 +4340,20 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay
auto& material = mesh->m_spMaterial; auto& material = mesh->m_spMaterial;
auto& shaderList = material->m_spShaderListData; auto& shaderList = material->m_spShaderListData;
bool constTexCoord = true;
if (material->m_spTexsetData.get() != nullptr)
{
for (size_t i = 1; i < material->m_spTexsetData->m_TextureList.size(); i++)
{
if (material->m_spTexsetData->m_TextureList[i]->m_TexcoordIndex !=
material->m_spTexsetData->m_TextureList[0]->m_TexcoordIndex)
{
constTexCoord = false;
break;
}
}
}
// Shadow pipeline. // Shadow pipeline.
if (layer == MeshLayer::Opaque || layer == MeshLayer::PunchThrough) if (layer == MeshLayer::Opaque || layer == MeshLayer::PunchThrough)
{ {
@ -4380,19 +4394,32 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay
if (defaultFindResult == shaderList->m_PixelShaderPermutations.end()) if (defaultFindResult == shaderList->m_PixelShaderPermutations.end())
return; return;
uint32_t pixelShaderSubPermutationsToCompile = 0;
if (constTexCoord) pixelShaderSubPermutationsToCompile |= 0x1;
if (args.noGI) pixelShaderSubPermutationsToCompile |= 0x2;
if ((defaultFindResult->second.m_SubPermutations.get() & (1 << pixelShaderSubPermutationsToCompile)) == 0)
pixelShaderSubPermutationsToCompile &= ~0x1;
guest_stack_var<Hedgehog::Base::CStringSymbol> noneSymbol(reinterpret_cast<const char*>(g_memory.Translate(0x8200D938))); guest_stack_var<Hedgehog::Base::CStringSymbol> noneSymbol(reinterpret_cast<const char*>(g_memory.Translate(0x8200D938)));
auto noneFindResult = defaultFindResult->second.m_VertexShaderPermutations.find(*noneSymbol); auto noneFindResult = defaultFindResult->second.m_VertexShaderPermutations.find(*noneSymbol);
if (noneFindResult == defaultFindResult->second.m_VertexShaderPermutations.end()) if (noneFindResult == defaultFindResult->second.m_VertexShaderPermutations.end())
return; return;
uint32_t vertexShaderSubPermutationsToCompile = 0;
if (constTexCoord) vertexShaderSubPermutationsToCompile |= 0x1;
if ((noneFindResult->second->m_SubPermutations.get() & (1 << vertexShaderSubPermutationsToCompile)) == 0)
vertexShaderSubPermutationsToCompile &= ~0x1;
for (auto& [pixelShaderSubPermutations, pixelShader] : defaultFindResult->second.m_PixelShaders) for (auto& [pixelShaderSubPermutations, pixelShader] : defaultFindResult->second.m_PixelShaders)
{ {
if (pixelShader.get() == nullptr || (pixelShaderSubPermutations & 0x2) != (args.noGI ? 0x2 : 0x0)) if (pixelShader.get() == nullptr || (pixelShaderSubPermutations & 0x3) != pixelShaderSubPermutationsToCompile)
continue; continue;
for (auto& [vertexShaderSubPermutations, vertexShader] : noneFindResult->second->m_VertexShaders) for (auto& [vertexShaderSubPermutations, vertexShader] : noneFindResult->second->m_VertexShaders)
{ {
if (vertexShader.get() == nullptr) if (vertexShader.get() == nullptr || (vertexShaderSubPermutations & 0x1) != vertexShaderSubPermutationsToCompile)
continue; continue;
PipelineState pipelineState{}; PipelineState pipelineState{};
@ -4583,7 +4610,28 @@ void GetModelDataMidAsmHook(PPCRegister& r1, PPCRegister& r31)
static bool CheckMadeAll(Hedgehog::Mirage::CMeshData* meshData) static bool CheckMadeAll(Hedgehog::Mirage::CMeshData* meshData)
{ {
return meshData->IsMadeOne() && (meshData->m_spMaterial.get() == nullptr || meshData->m_spMaterial->IsMadeOne()); if (!meshData->IsMadeOne())
return false;
if (meshData->m_spMaterial.get() != nullptr)
{
if (!meshData->m_spMaterial->IsMadeOne())
return false;
if (meshData->m_spMaterial->m_spTexsetData.get() != nullptr)
{
if (!meshData->m_spMaterial->m_spTexsetData->IsMadeOne())
return false;
for (auto& texture : meshData->m_spMaterial->m_spTexsetData->m_TextureList)
{
if (!texture->IsMadeOne())
return false;
}
}
}
return true;
} }
template<typename T> template<typename T>