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 31992ee1..137380f6 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 @@ -320,8 +320,11 @@ namespace skyline::gpu::interconnect::maxwell3d { manager.Bind(handle, primitiveRestartEnable); } - const vk::PipelineInputAssemblyStateCreateInfo &InputAssemblyState::Build() { - return inputAssemblyState; + InputAssemblyState::InputAssemblyState(const EngineRegisters &engine) : engine{engine} {} + + void InputAssemblyState::Update(Key &key) { + key.topology = currentEngineTopology; + key.primitiveRestartEnabled = engine.primitiveRestartEnable & 1; } static std::pair ConvertPrimitiveTopology(engine::DrawTopology topology) { @@ -359,9 +362,6 @@ namespace skyline::gpu::interconnect::maxwell3d { void InputAssemblyState::SetPrimitiveTopology(engine::DrawTopology topology) { currentEngineTopology = topology; - Shader::InputTopology geometryTopology{}; - std::tie(inputAssemblyState.topology, geometryTopology) = ConvertPrimitiveTopology(topology); - /* if (shaderTopology == ShaderCompiler::InputTopology::Points) UpdateRuntimeInformation(runtimeInfo.fixed_state_point_size, std::make_optional(pointSpriteSize), maxwell3d::PipelineStage::Vertex, maxwell3d::PipelineStage::Geometry); @@ -380,9 +380,6 @@ namespace skyline::gpu::interconnect::maxwell3d { return currentEngineTopology == engine::DrawTopology::Quads; } - void InputAssemblyState::SetPrimitiveRestart(bool enabled) { - inputAssemblyState.primitiveRestartEnable = enabled; - } /* Tessellation State */ void TessellationState::EngineRegisters::DirtyBind(DirtyManager &manager, dirty::Handle handle) const { @@ -779,7 +776,8 @@ namespace skyline::gpu::interconnect::maxwell3d { vertexInput{manager, engine.vertexInputRegisters}, rasterization{manager, engine.rasterizationRegisters}, depthStencil{manager, engine.depthStencilRegisters}, - colorBlend{manager, engine.colorBlendRegisters} {} + colorBlend{manager, engine.colorBlendRegisters}, + directState{engine.inputAssemblyRegisters} {} void PipelineState::Flush(InterconnectContext &ctx, StateUpdateBuilder &builder) { boost::container::static_vector colorAttachments; @@ -790,7 +788,8 @@ namespace skyline::gpu::interconnect::maxwell3d { TextureView *depthAttachment{depthRenderTarget.UpdateGet(ctx, key).view.get()}; vertexInput.Update(key); - const auto &inputAssemblyState{directState.inputAssembly.Build()}; + directState.inputAssembly.Update(key); + const auto &tessellationState{directState.tessellation.Build()}; const auto &rasterizationState{rasterization.UpdateGet().rasterizationState}; vk::PipelineMultisampleStateCreateInfo multisampleState{ 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 df7bc85c..6dbc2ba1 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 @@ -6,12 +6,14 @@ #include #include #include "common.h" +#include "soc/gm20b/engines/maxwell/types.h" namespace skyline::gpu::interconnect::maxwell3d { - class Key { - private: + struct Key { struct { - u8 ztFormat : 5; // ZtFormat - 0xA as u8 + u8 ztFormat : 5; //!< Use {Set, Get}ZtFormat. ZtFormat - 0xA as u8 + engine::DrawTopology topology : 4; + bool primitiveRestartEnabled : 1; }; struct VertexBinding { @@ -23,10 +25,8 @@ namespace skyline::gpu::interconnect::maxwell3d { }; static_assert(sizeof(VertexBinding) == 0x8); - std::array ctFormats; //!< ColorTarget::Format as u8 - std::array vertexBindings; - - public: + std::array ctFormats; //!< Use {Set, Get}CtFormat. ColorTarget::Format as u8 + std::array vertexBindings; //!< Use {Set, Get}VertexBinding std::array vertexAttributes; void SetCtFormat(size_t index, engine::ColorTarget::Format format) { @@ -109,11 +109,7 @@ namespace skyline::gpu::interconnect::maxwell3d { void Flush(Key &key); }; - struct InputAssemblyState { - private: - vk::PipelineInputAssemblyStateCreateInfo inputAssemblyState{}; - engine::DrawTopology currentEngineTopology{}; - + class InputAssemblyState { public: struct EngineRegisters { const u32 &primitiveRestartEnable; @@ -121,19 +117,21 @@ namespace skyline::gpu::interconnect::maxwell3d { void DirtyBind(DirtyManager &manager, dirty::Handle handle) const; }; + private: + EngineRegisters engine; + vk::PipelineInputAssemblyStateCreateInfo inputAssemblyState{}; + engine::DrawTopology currentEngineTopology{}; - const vk::PipelineInputAssemblyStateCreateInfo &Build(); + public: + InputAssemblyState(const EngineRegisters &engine); + + void Update(Key &key); - /** - * @note Calling this *REQUIRES* manually marking the pipeline as dirty - */ void SetPrimitiveTopology(engine::DrawTopology topology); engine::DrawTopology GetPrimitiveTopology() const; bool NeedsQuadConversion() const; - - void SetPrimitiveRestart(bool enable); }; struct TessellationState {