From 90466b8830b1f08d26e12bda08fc178e143ffaed Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Fri, 21 Oct 2022 21:57:12 +0100 Subject: [PATCH] Implement depth clamp rasterisation state Used in SMO for shadows. --- .../gpu/interconnect/maxwell_3d/packed_pipeline_state.cpp | 4 ++++ .../gpu/interconnect/maxwell_3d/packed_pipeline_state.h | 3 +++ .../skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp | 2 +- .../skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp | 1 + 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.cpp index c28f6c39..ca5e4a69 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.cpp @@ -340,6 +340,10 @@ namespace skyline::gpu::interconnect::maxwell3d { // Vulkan enum values match 1-1 with hades return static_cast(alphaFunc); } + + void PackedPipelineState::SetDepthClampEnable(engine::ViewportClipControl::GeometryClip clip) { + depthClampEnable = (clip != engine::ViewportClipControl::GeometryClip::Passthru) && (clip != engine::ViewportClipControl::GeometryClip::FrustrumXYZClip) && (clip != engine::ViewportClipControl::GeometryClip::FrustrumZClip); + } } #pragma clang diagnostic pop \ No newline at end of file diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.h index 5987331a..4920810f 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/packed_pipeline_state.h @@ -57,6 +57,7 @@ namespace skyline::gpu::interconnect::maxwell3d { bool transformFeedbackEnable : 1; u8 alphaFunc : 3; //!< Use {Set,Get}AlphaFunc bool alphaTestEnable : 1; + bool depthClampEnable : 1; // Use SetDepthClampEnable }; u32 patchSize; @@ -141,6 +142,8 @@ namespace skyline::gpu::interconnect::maxwell3d { Shader::CompareFunction GetAlphaFunc() const; + void SetDepthClampEnable(engine::ViewportClipControl::GeometryClip clip); + bool operator==(const PackedPipelineState &other) const { // Only hash transform feedback state if it's enabled if (other.transformFeedbackEnable && transformFeedbackEnable) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp index f51711f5..53bc6061 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp @@ -493,6 +493,7 @@ namespace skyline::gpu::interconnect::maxwell3d { rasterizationCreateInfo.cullMode = vk::CullModeFlags{packedState.cullMode}; rasterizationCreateInfo.frontFace = packedState.frontFaceClockwise ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise; rasterizationCreateInfo.depthBiasEnable = packedState.depthBiasEnable; + rasterizationCreateInfo.depthClampEnable = packedState.depthClampEnable; rasterizationState.get().provokingVertexMode = ConvertProvokingVertex(packedState.provokingVertex); constexpr vk::PipelineMultisampleStateCreateInfo multisampleState{ @@ -651,7 +652,6 @@ namespace skyline::gpu::interconnect::maxwell3d { view.GetBuffer()->BlockSequencedCpuBackingWrites(); - return view; } 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 32cbe5b6..0f63e10a 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 @@ -446,6 +446,7 @@ namespace skyline::gpu::interconnect::maxwell3d { packedState.provokingVertex = engine->provokingVertex.value; packedState.pointSize = engine->pointSize; packedState.openGlNdc = engine->zClipRange == engine::ZClipRange::NegativeWToPositiveW; + packedState.SetDepthClampEnable(engine->viewportClipControl.geometryClip); } /* Depth Stencil State */