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 1f4e4b35..7f404b30 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 @@ -331,6 +331,15 @@ namespace skyline::gpu::interconnect::maxwell3d { return convertedVaryings; } + + void PackedPipelineState::SetAlphaFunc(engine::CompareFunc func) { + alphaFunc = ConvertCompareFunc(func); + } + + Shader::CompareFunction PackedPipelineState::GetAlphaFunc() const { + // Vulkan enum values match 1-1 with hades + return static_cast(alphaFunc); + } } #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 22fa79e5..5987331a 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 @@ -55,9 +55,12 @@ namespace skyline::gpu::interconnect::maxwell3d { bool apiMandatedEarlyZ : 1; bool openGlNdc : 1; bool transformFeedbackEnable : 1; + u8 alphaFunc : 3; //!< Use {Set,Get}AlphaFunc + bool alphaTestEnable : 1; }; u32 patchSize; + float alphaRef; float pointSize; std::array vertexAttributes; std::array colorRenderTargetFormats; //!< Use {Set, Get}ColorRenderTargetFormat @@ -134,6 +137,10 @@ namespace skyline::gpu::interconnect::maxwell3d { std::vector GetTransformFeedbackVaryings() const; + void SetAlphaFunc(engine::CompareFunc func); + + Shader::CompareFunction GetAlphaFunc() const; + 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 1d1857b5..244954dd 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 @@ -129,9 +129,11 @@ namespace skyline::gpu::interconnect::maxwell3d { info.convert_depth_mode = packedState.openGlNdc; break; case Shader::Stage::Fragment: - // info.alpha_test_func = MaxwellToCompareFunction( - // key.state.UnpackComparisonOp(key.state.alpha_test_func.Value())); - // info.alpha_test_reference = Common::BitCast(key.state.alpha_test_ref); + if (packedState.alphaTestEnable) { + info.alpha_test_func = packedState.GetAlphaFunc(); + info.alpha_test_reference = packedState.alphaRef; + } + break; default: break; 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 9e44bd3c..b3ef0875 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 @@ -411,7 +411,7 @@ namespace skyline::gpu::interconnect::maxwell3d { /* Depth Stencil State */ void DepthStencilState::EngineRegisters::DirtyBind(DirtyManager &manager, dirty::Handle handle) const { - manager.Bind(handle, depthTestEnable, depthWriteEnable, depthFunc, depthBoundsTestEnable, stencilTestEnable, twoSidedStencilTestEnable, stencilOps, stencilBack); + manager.Bind(handle, depthTestEnable, depthWriteEnable, depthFunc, depthBoundsTestEnable, stencilTestEnable, twoSidedStencilTestEnable, stencilOps, stencilBack, alphaTestEnable, alphaFunc, alphaRef); } DepthStencilState::DepthStencilState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine) : engine{manager, dirtyHandle, engine} {} @@ -419,12 +419,20 @@ namespace skyline::gpu::interconnect::maxwell3d { void DepthStencilState::Flush(PackedPipelineState &packedState) { packedState.depthTestEnable = engine->depthTestEnable; packedState.depthWriteEnable = engine->depthWriteEnable; - packedState.SetDepthFunc(engine->depthFunc); + packedState.SetDepthFunc(engine->depthTestEnable ? engine->depthFunc : engine::CompareFunc::OglAlways); packedState.depthBoundsTestEnable = engine->depthBoundsTestEnable; - packedState.stencilTestEnable = engine->stencilTestEnable; - auto stencilBack{engine->twoSidedStencilTestEnable ? engine->stencilBack : engine->stencilOps}; - packedState.SetStencilOps(engine->stencilOps, engine->stencilOps); + packedState.stencilTestEnable = engine->stencilTestEnable; + if (packedState.stencilTestEnable) { + auto stencilBack{engine->twoSidedStencilTestEnable ? engine->stencilBack : engine->stencilOps}; + packedState.SetStencilOps(engine->stencilOps, stencilBack); + } else { + packedState.SetStencilOps({ .func = engine::CompareFunc::OglAlways }, { .func = engine::CompareFunc::OglAlways }); + } + + packedState.alphaTestEnable = engine->alphaTestEnable; + packedState.SetAlphaFunc(engine->alphaTestEnable ? engine->alphaFunc : engine::CompareFunc::OglAlways); + packedState.alphaRef = engine->alphaTestEnable ? engine->alphaRef : 0; }; /* Color Blend State */ 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 e07624a0..82b0314c 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 @@ -214,6 +214,9 @@ namespace skyline::gpu::interconnect::maxwell3d { const u32 &twoSidedStencilTestEnable; const engine::StencilOps &stencilOps; const engine::StencilOps &stencilBack; + const u32 &alphaTestEnable; + const engine::CompareFunc &alphaFunc; + const float &alphaRef; void DirtyBind(DirtyManager &manager, dirty::Handle handle) const; };