diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp index b7d2fd2e..46cb3de9 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp @@ -18,7 +18,7 @@ namespace skyline::gpu::interconnect::maxwell3d { manager.Bind(handle, colorTarget); } - ColorRenderTargetState::ColorRenderTargetState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine) : engine{manager, dirtyHandle, engine} {} + ColorRenderTargetState::ColorRenderTargetState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine, size_t index) : engine{manager, dirtyHandle, engine}, index{index} {} static texture::Format ConvertColorRenderTargetFormat(engine::ColorTarget::Format format) { #define FORMAT_CASE_BASE(engineFormat, skFormat, warn) \ @@ -107,8 +107,10 @@ namespace skyline::gpu::interconnect::maxwell3d { #undef FORMAT_CASE_BASE } - void ColorRenderTargetState::Flush(InterconnectContext &ctx) { + void ColorRenderTargetState::Flush(InterconnectContext &ctx, Key &key) { auto &target{engine->colorTarget}; + key.SetCtFormat(index, target.format); + if (target.format == engine::ColorTarget::Format::Disabled) { view = {}; return; @@ -173,7 +175,9 @@ namespace skyline::gpu::interconnect::maxwell3d { #undef FORMAT_CASE } - void DepthRenderTargetState::Flush(InterconnectContext &ctx) { + void DepthRenderTargetState::Flush(InterconnectContext &ctx, Key &key) { + key.SetZtFormat(engine->ztFormat); + if (!engine->ztSelect.targetCount) { view = {}; return; @@ -824,19 +828,21 @@ namespace skyline::gpu::interconnect::maxwell3d { PipelineState::PipelineState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine) : engine{manager, dirtyHandle, engine}, - colorRenderTargets{util::MergeInto, engine::ColorTargetCount>(manager, engine.colorRenderTargetsRegisters)}, + colorRenderTargets{util::MergeInto, engine::ColorTargetCount>(manager, engine.colorRenderTargetsRegisters, util::IncrementingT{})}, depthRenderTarget{manager, engine.depthRenderTargetRegisters}, rasterization{manager, engine.rasterizationRegisters}, depthStencil{manager, engine.depthStencilRegisters}, colorBlend{manager, engine.colorBlendRegisters} {} void PipelineState::Flush(InterconnectContext &ctx, StateUpdateBuilder &builder) { + Key key; + boost::container::static_vector colorAttachments; for (auto &colorRenderTarget : colorRenderTargets) - if (auto view{colorRenderTarget.UpdateGet(ctx).view}; view) + if (auto view{colorRenderTarget.UpdateGet(ctx, key).view}; view) colorAttachments.push_back(view.get()); - TextureView *depthAttachment{depthRenderTarget.UpdateGet(ctx).view.get()}; + TextureView *depthAttachment{depthRenderTarget.UpdateGet(ctx, key).view.get()}; auto vertexInputState{directState.vertexInput.Build(ctx, engine->vertexInputRegisters)}; const auto &inputAssemblyState{directState.inputAssembly.Build()}; @@ -867,10 +873,10 @@ namespace skyline::gpu::interconnect::maxwell3d { } std::shared_ptr PipelineState::GetColorRenderTargetForClear(InterconnectContext &ctx, size_t index) { - return colorRenderTargets[index].UpdateGet(ctx).view; + return colorRenderTargets[index].UpdateGet(ctx, key).view; } std::shared_ptr PipelineState::GetDepthRenderTargetForClear(InterconnectContext &ctx) { - return depthRenderTarget.UpdateGet(ctx).view; + return depthRenderTarget.UpdateGet(ctx, key).view; } } \ No newline at end of file diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h index b0eecb2a..9587c128 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h @@ -8,6 +8,26 @@ #include "common.h" namespace skyline::gpu::interconnect::maxwell3d { + class Key { + private: + struct { + u8 ztFormat : 5; // ZtFormat - 0xA as u8 + }; + + std::array ctFormats; //!< ColorTarget::Format as u8 + + public: + std::array vertexAttributes; + + void SetCtFormat(size_t index, engine::ColorTarget::Format format) { + ctFormats[index] = static_cast(format); + } + + void SetZtFormat(engine::ZtFormat format) { + ztFormat = static_cast(format) - static_cast(engine::ZtFormat::ZF32); + } + }; + class ColorRenderTargetState : dirty::ManualDirty { public: struct EngineRegisters { @@ -18,13 +38,14 @@ namespace skyline::gpu::interconnect::maxwell3d { private: dirty::BoundSubresource engine; + size_t index; public: - ColorRenderTargetState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine); + ColorRenderTargetState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine, size_t index); std::shared_ptr view; - void Flush(InterconnectContext &ctx); + void Flush(InterconnectContext &ctx, Key &key); }; class DepthRenderTargetState : dirty::ManualDirty { @@ -49,7 +70,7 @@ namespace skyline::gpu::interconnect::maxwell3d { std::shared_ptr view; - void Flush(InterconnectContext &ctx); + void Flush(InterconnectContext &ctx, Key &key); }; struct VertexInputState { @@ -242,6 +263,8 @@ namespace skyline::gpu::interconnect::maxwell3d { }; private: + Key key{}; + dirty::BoundSubresource engine; std::array, engine::ColorTargetCount> colorRenderTargets;