From 1f844e2c186abb2037e7f78b79fd051b95d82c0b Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Tue, 6 Sep 2022 19:23:13 +0100 Subject: [PATCH] Transition rasterization state to pipeline cache key --- .../maxwell_3d/pipeline_state.cpp | 31 ++++++++++++------- .../interconnect/maxwell_3d/pipeline_state.h | 14 ++++++++- 2 files changed, 32 insertions(+), 13 deletions(-) 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 d6fadaaf..06cf93a4 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 @@ -477,20 +477,27 @@ namespace skyline::gpu::interconnect::maxwell3d { } } - void RasterizationState::Flush() { - auto &rasterizationCreateInfo{rasterizationState.get()}; - rasterizationCreateInfo.rasterizerDiscardEnable = !engine->rasterEnable; - rasterizationCreateInfo.polygonMode = ConvertPolygonMode(engine->frontPolygonMode); + void RasterizationState::Flush(Key &key) { + key.rasterizerDiscardEnable = !engine->rasterEnable; + key.SetPolygonMode(engine->frontPolygonMode); if (engine->backPolygonMode != engine->frontPolygonMode) Logger::Warn("Non-matching polygon modes!"); - rasterizationCreateInfo.cullMode = engine->oglCullEnable ? ConvertCullMode(engine->oglCullFace) : vk::CullModeFlagBits::eNone; + if (engine->oglCullEnable) { + key.cullModeFront = engine->oglCullFace == engine::CullFace::Front || engine->oglCullFace == engine::CullFace::FrontAndBack; + key.cullModeBack = engine->oglCullFace == engine::CullFace::Back || engine->oglCullFace == engine::CullFace::FrontAndBack; + } else { + key.cullModeFront = key.cullModeBack = false; + } + // UpdateRuntimeInformation(runtimeInfo.y_negate, enabled, maxwell3d::PipelineStage::Vertex, maxwell3d::PipelineStage::Fragment); + key.flipYEnable = engine->windowOrigin.flipY; + bool origFrontFaceClockwise{engine->oglFrontFace == engine::FrontFace::CW}; - rasterizationCreateInfo.frontFace = (engine->windowOrigin.flipY != origFrontFaceClockwise) ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise; - rasterizationCreateInfo.depthBiasEnable = ConvertDepthBiasEnable(engine->polyOffset, engine->frontPolygonMode); - rasterizationState.get().provokingVertexMode = ConvertProvokingVertex(engine->provokingVertex.value); + key.frontFaceClockwise = (key.flipYEnable != origFrontFaceClockwise); + key.depthBiasEnable = ConvertDepthBiasEnable(engine->polyOffset, engine->frontPolygonMode); + key.provokingVertex = engine->provokingVertex.value; } /* Depth Stencil State */ @@ -789,12 +796,12 @@ namespace skyline::gpu::interconnect::maxwell3d { vertexInput.Update(key); directState.inputAssembly.Update(key); - tessellation.Update(key); - const auto &rasterizationState{rasterization.UpdateGet().rasterizationState}; - vk::PipelineMultisampleStateCreateInfo multisampleState{ + rasterization.Update(key); + /* vk::PipelineMultisampleStateCreateInfo multisampleState{ .rasterizationSamples = vk::SampleCountFlagBits::e1 - }; + }; */ + const auto &depthStencilState{depthStencil.UpdateGet().depthStencilState}; const auto &colorBlendState{colorBlend.UpdateGet(ctx, colorAttachments.size()).colorBlendState}; 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 63c93f07..117f41ee 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 @@ -17,6 +17,14 @@ namespace skyline::gpu::interconnect::maxwell3d { engine::TessellationParameters::DomainType domainType : 2; //!< Use SetTessellationParameters engine::TessellationParameters::Spacing spacing : 2; //!< Use SetTessellationParameters engine::TessellationParameters::OutputPrimitives outputPrimitives : 2; //!< Use SetTessellationParameters + bool rasterizerDiscardEnable : 1; + u8 polygonMode : 2; //!< Use {Set, Get}PolygonMode + bool cullModeFront : 1; + bool cullModeBack : 1; + bool flipYEnable : 1; + bool frontFaceClockwise : 1; //!< With Y flip transformation already applied + bool depthBiasEnable : 1; + engine::ProvokingVertex::Value provokingVertex : 1; }; struct VertexBinding { @@ -53,6 +61,10 @@ namespace skyline::gpu::interconnect::maxwell3d { spacing = parameters.spacing; outputPrimitives = parameters.outputPrimitives; } + + void SetPolygonMode(engine::PolygonMode mode) { + polygonMode = static_cast(static_cast(mode) - 0x1B00); + } }; class ColorRenderTargetState : dirty::ManualDirty { @@ -194,7 +206,7 @@ namespace skyline::gpu::interconnect::maxwell3d { RasterizationState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine); - void Flush(); + void Flush(Key &key); }; class DepthStencilState : dirty::ManualDirty {