diff options
| author | 2020-01-06 21:11:23 -0300 | |
|---|---|---|
| committer | 2020-01-06 22:02:26 -0300 | |
| commit | 3142f1b597436d0bd1de12c1769da897976c6b32 (patch) | |
| tree | 00cf8638f7c5a86726d9f823e67a9cbe09b391bc /src | |
| parent | vk_rasterizer: Add placeholder (diff) | |
| download | yuzu-3142f1b597436d0bd1de12c1769da897976c6b32.tar.gz yuzu-3142f1b597436d0bd1de12c1769da897976c6b32.tar.xz yuzu-3142f1b597436d0bd1de12c1769da897976c6b32.zip | |
fixed_pipeline_state: Add depth clamp
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/fixed_pipeline_state.h | 10 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp index 5a490f6ef..4e3ff231e 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.cpp | |||
| @@ -109,6 +109,9 @@ constexpr FixedPipelineState::Rasterizer GetRasterizerState(const Maxwell& regs) | |||
| 109 | const auto topology = static_cast<std::size_t>(regs.draw.topology.Value()); | 109 | const auto topology = static_cast<std::size_t>(regs.draw.topology.Value()); |
| 110 | const bool depth_bias_enabled = enabled_lut[PolygonOffsetEnableLUT[topology]]; | 110 | const bool depth_bias_enabled = enabled_lut[PolygonOffsetEnableLUT[topology]]; |
| 111 | 111 | ||
| 112 | const auto& clip = regs.view_volume_clip_control; | ||
| 113 | const bool depth_clamp_enabled = clip.depth_clamp_near == 1 || clip.depth_clamp_far == 1; | ||
| 114 | |||
| 112 | Maxwell::Cull::FrontFace front_face = regs.cull.front_face; | 115 | Maxwell::Cull::FrontFace front_face = regs.cull.front_face; |
| 113 | if (regs.screen_y_control.triangle_rast_flip != 0 && | 116 | if (regs.screen_y_control.triangle_rast_flip != 0 && |
| 114 | regs.viewport_transform[0].scale_y > 0.0f) { | 117 | regs.viewport_transform[0].scale_y > 0.0f) { |
| @@ -119,8 +122,9 @@ constexpr FixedPipelineState::Rasterizer GetRasterizerState(const Maxwell& regs) | |||
| 119 | } | 122 | } |
| 120 | 123 | ||
| 121 | const bool gl_ndc = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne; | 124 | const bool gl_ndc = regs.depth_mode == Maxwell::DepthMode::MinusOneToOne; |
| 122 | return FixedPipelineState::Rasterizer(regs.cull.enabled, depth_bias_enabled, gl_ndc, | 125 | return FixedPipelineState::Rasterizer(regs.cull.enabled, depth_bias_enabled, |
| 123 | regs.cull.cull_face, front_face); | 126 | depth_clamp_enabled, gl_ndc, regs.cull.cull_face, |
| 127 | front_face); | ||
| 124 | } | 128 | } |
| 125 | 129 | ||
| 126 | } // Anonymous namespace | 130 | } // Anonymous namespace |
| @@ -222,15 +226,17 @@ bool FixedPipelineState::Tessellation::operator==(const Tessellation& rhs) const | |||
| 222 | std::size_t FixedPipelineState::Rasterizer::Hash() const noexcept { | 226 | std::size_t FixedPipelineState::Rasterizer::Hash() const noexcept { |
| 223 | return static_cast<std::size_t>(cull_enable) ^ | 227 | return static_cast<std::size_t>(cull_enable) ^ |
| 224 | (static_cast<std::size_t>(depth_bias_enable) << 1) ^ | 228 | (static_cast<std::size_t>(depth_bias_enable) << 1) ^ |
| 225 | (static_cast<std::size_t>(ndc_minus_one_to_one) << 2) ^ | 229 | (static_cast<std::size_t>(depth_clamp_enable) << 2) ^ |
| 230 | (static_cast<std::size_t>(ndc_minus_one_to_one) << 3) ^ | ||
| 226 | (static_cast<std::size_t>(cull_face) << 24) ^ | 231 | (static_cast<std::size_t>(cull_face) << 24) ^ |
| 227 | (static_cast<std::size_t>(front_face) << 48); | 232 | (static_cast<std::size_t>(front_face) << 48); |
| 228 | } | 233 | } |
| 229 | 234 | ||
| 230 | bool FixedPipelineState::Rasterizer::operator==(const Rasterizer& rhs) const noexcept { | 235 | bool FixedPipelineState::Rasterizer::operator==(const Rasterizer& rhs) const noexcept { |
| 231 | return std::tie(cull_enable, depth_bias_enable, ndc_minus_one_to_one, cull_face, front_face) == | 236 | return std::tie(cull_enable, depth_bias_enable, depth_clamp_enable, ndc_minus_one_to_one, |
| 232 | std::tie(rhs.cull_enable, rhs.depth_bias_enable, rhs.ndc_minus_one_to_one, rhs.cull_face, | 237 | cull_face, front_face) == |
| 233 | rhs.front_face); | 238 | std::tie(rhs.cull_enable, rhs.depth_bias_enable, rhs.depth_clamp_enable, |
| 239 | rhs.ndc_minus_one_to_one, rhs.cull_face, rhs.front_face); | ||
| 234 | } | 240 | } |
| 235 | 241 | ||
| 236 | std::size_t FixedPipelineState::DepthStencil::Hash() const noexcept { | 242 | std::size_t FixedPipelineState::DepthStencil::Hash() const noexcept { |
diff --git a/src/video_core/renderer_vulkan/fixed_pipeline_state.h b/src/video_core/renderer_vulkan/fixed_pipeline_state.h index 04152c0d4..87056ef37 100644 --- a/src/video_core/renderer_vulkan/fixed_pipeline_state.h +++ b/src/video_core/renderer_vulkan/fixed_pipeline_state.h | |||
| @@ -170,15 +170,17 @@ struct FixedPipelineState { | |||
| 170 | }; | 170 | }; |
| 171 | 171 | ||
| 172 | struct Rasterizer { | 172 | struct Rasterizer { |
| 173 | constexpr Rasterizer(bool cull_enable, bool depth_bias_enable, bool ndc_minus_one_to_one, | 173 | constexpr Rasterizer(bool cull_enable, bool depth_bias_enable, bool depth_clamp_enable, |
| 174 | Maxwell::Cull::CullFace cull_face, Maxwell::Cull::FrontFace front_face) | 174 | bool ndc_minus_one_to_one, Maxwell::Cull::CullFace cull_face, |
| 175 | Maxwell::Cull::FrontFace front_face) | ||
| 175 | : cull_enable{cull_enable}, depth_bias_enable{depth_bias_enable}, | 176 | : cull_enable{cull_enable}, depth_bias_enable{depth_bias_enable}, |
| 176 | ndc_minus_one_to_one{ndc_minus_one_to_one}, cull_face{cull_face}, front_face{ | 177 | depth_clamp_enable{depth_clamp_enable}, ndc_minus_one_to_one{ndc_minus_one_to_one}, |
| 177 | front_face} {} | 178 | cull_face{cull_face}, front_face{front_face} {} |
| 178 | Rasterizer() = default; | 179 | Rasterizer() = default; |
| 179 | 180 | ||
| 180 | bool cull_enable; | 181 | bool cull_enable; |
| 181 | bool depth_bias_enable; | 182 | bool depth_bias_enable; |
| 183 | bool depth_clamp_enable; | ||
| 182 | bool ndc_minus_one_to_one; | 184 | bool ndc_minus_one_to_one; |
| 183 | Maxwell::Cull::CullFace cull_face; | 185 | Maxwell::Cull::CullFace cull_face; |
| 184 | Maxwell::Cull::FrontFace front_face; | 186 | Maxwell::Cull::FrontFace front_face; |