From dc3c5ab7ff651efd5a7d3f08554c157f8273b5d8 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Wed, 27 Nov 2024 00:15:48 +0300 Subject: [PATCH] Sky shader compilation & more debugging helpers. --- UnleashedRecomp/gpu/video.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index 2fcfdccd..c32e233e 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -4283,7 +4283,7 @@ static moodycamel::BlockingConcurrentQueue g_asyncPipelines; static Mutex g_asyncPipelineMutex; -static void CreateGraphicsPipelineInPipelineThread(const PipelineState& pipelineState) +static void CreateGraphicsPipelineInPipelineThread(const PipelineState& pipelineState, const char* name) { XXH64_hash_t hash = XXH3_64bits(&pipelineState, sizeof(pipelineState)); @@ -4296,7 +4296,7 @@ static void CreateGraphicsPipelineInPipelineThread(const PipelineState& pipeline if (shouldCompile) { auto pipeline = CreateGraphicsPipeline(pipelineState); - pipeline->setName(std::format("Async Pipeline {:X}", hash)); + pipeline->setName(std::format("Async Pipeline {} {:X}", name, hash)); // Will get dropped in render thread if a different thread already managed to compile this. RenderCommand cmd; @@ -4327,6 +4327,7 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay auto& material = mesh->m_spMaterial; auto& shaderList = material->m_spShaderListData; + bool isSky = strstr(shaderList->m_TypeAndName.c_str(), "Sky") != nullptr; bool constTexCoord = true; if (material->m_spTexsetData.get() != nullptr) @@ -4343,7 +4344,7 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay } // Shadow pipeline. - if (layer == MeshLayer::Opaque || layer == MeshLayer::PunchThrough) + if (!isSky && (layer == MeshLayer::Opaque || layer == MeshLayer::PunchThrough)) { PipelineState pipelineState{}; @@ -4371,7 +4372,7 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay pipelineState.specConstants |= SPEC_CONSTANT_ALPHA_TEST; SanitizePipelineState(pipelineState); - CreateGraphicsPipelineInPipelineThread(pipelineState); + CreateGraphicsPipelineInPipelineThread(pipelineState, layer == MeshLayer::PunchThrough ? "MakeShadowMapTransparent" : "MakeShadowMap"); } guest_stack_var defaultSymbol(reinterpret_cast(g_memory.Translate(0x8202DDBC))); @@ -4383,8 +4384,8 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay if (constTexCoord) pixelShaderSubPermutationsToCompile |= 0x1; if (args.noGI) pixelShaderSubPermutationsToCompile |= 0x2; - if ((defaultFindResult->second.m_SubPermutations.get() & (1 << pixelShaderSubPermutationsToCompile)) == 0) - pixelShaderSubPermutationsToCompile &= ~0x1; + if ((defaultFindResult->second.m_SubPermutations.get() & (1 << pixelShaderSubPermutationsToCompile)) == 0) pixelShaderSubPermutationsToCompile &= ~0x1; + if ((defaultFindResult->second.m_SubPermutations.get() & (1 << pixelShaderSubPermutationsToCompile)) == 0) pixelShaderSubPermutationsToCompile &= ~0x2; guest_stack_var noneSymbol(reinterpret_cast(g_memory.Translate(0x8200D938))); auto noneFindResult = defaultFindResult->second.m_VertexShaderPermutations.find(*noneSymbol); @@ -4411,7 +4412,7 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay pipelineState.vertexShader = reinterpret_cast(vertexShader->m_spCode->m_pD3DVertexShader.get()); pipelineState.pixelShader = reinterpret_cast(pixelShader->m_spCode->m_pD3DPixelShader.get()); pipelineState.vertexDeclaration = reinterpret_cast(mesh->m_VertexDeclarationPtr.m_pD3DVertexDeclaration.get()); - pipelineState.zWriteEnable = layer != MeshLayer::Transparent; + pipelineState.zWriteEnable = !isSky && layer != MeshLayer::Transparent; pipelineState.srcBlend = RenderBlend::SRC_ALPHA; pipelineState.destBlend = material->m_Additive ? RenderBlend::ONE : RenderBlend::INV_SRC_ALPHA; pipelineState.cullMode = material->m_DoubleSided ? RenderCullMode::NONE : RenderCullMode::BACK; @@ -4444,10 +4445,11 @@ static void CompileMeshPipeline(Hedgehog::Mirage::CMeshData* mesh, MeshLayer lay } } - pipelineState.specConstants |= SPEC_CONSTANT_REVERSE_Z; + if (!isSky) + pipelineState.specConstants |= SPEC_CONSTANT_REVERSE_Z; SanitizePipelineState(pipelineState); - CreateGraphicsPipelineInPipelineThread(pipelineState); + CreateGraphicsPipelineInPipelineThread(pipelineState, shaderList->m_TypeAndName.c_str() + 3); } } }