diff options
| author | 2020-08-26 22:19:52 -0400 | |
|---|---|---|
| committer | 2020-08-26 22:19:52 -0400 | |
| commit | 1e2a92918b0dea7867c5fcb8adba1a139afe6c22 (patch) | |
| tree | 7f429fbb90991febf623f77a6a36433c75b414dd /src | |
| parent | Merge pull request #4593 from lioncash/const2 (diff) | |
| parent | vk_state_tracker: Fix primitive topology (diff) | |
| download | yuzu-1e2a92918b0dea7867c5fcb8adba1a139afe6c22.tar.gz yuzu-1e2a92918b0dea7867c5fcb8adba1a139afe6c22.tar.xz yuzu-1e2a92918b0dea7867c5fcb8adba1a139afe6c22.zip | |
Merge pull request #4555 from ReinUsesLisp/fix-primitive-topology
vk_state_tracker: Fix primitive topology
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_state_tracker.h | 16 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 936f76195..ff1b52eab 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -1443,10 +1443,10 @@ void RasterizerVulkan::UpdateFrontFace(Tegra::Engines::Maxwell3D::Regs& regs) { | |||
| 1443 | } | 1443 | } |
| 1444 | 1444 | ||
| 1445 | void RasterizerVulkan::UpdatePrimitiveTopology(Tegra::Engines::Maxwell3D::Regs& regs) { | 1445 | void RasterizerVulkan::UpdatePrimitiveTopology(Tegra::Engines::Maxwell3D::Regs& regs) { |
| 1446 | if (!state_tracker.TouchPrimitiveTopology()) { | 1446 | const Maxwell::PrimitiveTopology primitive_topology = regs.draw.topology.Value(); |
| 1447 | if (!state_tracker.ChangePrimitiveTopology(primitive_topology)) { | ||
| 1447 | return; | 1448 | return; |
| 1448 | } | 1449 | } |
| 1449 | const Maxwell::PrimitiveTopology primitive_topology = regs.draw.topology.Value(); | ||
| 1450 | scheduler.Record([this, primitive_topology](vk::CommandBuffer cmdbuf) { | 1450 | scheduler.Record([this, primitive_topology](vk::CommandBuffer cmdbuf) { |
| 1451 | cmdbuf.SetPrimitiveTopologyEXT(MaxwellToVK::PrimitiveTopology(device, primitive_topology)); | 1451 | cmdbuf.SetPrimitiveTopologyEXT(MaxwellToVK::PrimitiveTopology(device, primitive_topology)); |
| 1452 | }); | 1452 | }); |
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.cpp b/src/video_core/renderer_vulkan/vk_state_tracker.cpp index 9151d9fb1..4bd1009f9 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.cpp +++ b/src/video_core/renderer_vulkan/vk_state_tracker.cpp | |||
| @@ -42,7 +42,6 @@ Flags MakeInvalidationFlags() { | |||
| 42 | flags[DepthWriteEnable] = true; | 42 | flags[DepthWriteEnable] = true; |
| 43 | flags[DepthCompareOp] = true; | 43 | flags[DepthCompareOp] = true; |
| 44 | flags[FrontFace] = true; | 44 | flags[FrontFace] = true; |
| 45 | flags[PrimitiveTopology] = true; | ||
| 46 | flags[StencilOp] = true; | 45 | flags[StencilOp] = true; |
| 47 | flags[StencilTestEnable] = true; | 46 | flags[StencilTestEnable] = true; |
| 48 | return flags; | 47 | return flags; |
| @@ -112,10 +111,6 @@ void SetupDirtyFrontFace(Tables& tables) { | |||
| 112 | table[OFF(screen_y_control)] = FrontFace; | 111 | table[OFF(screen_y_control)] = FrontFace; |
| 113 | } | 112 | } |
| 114 | 113 | ||
| 115 | void SetupDirtyPrimitiveTopology(Tables& tables) { | ||
| 116 | tables[0][OFF(draw.topology)] = PrimitiveTopology; | ||
| 117 | } | ||
| 118 | |||
| 119 | void SetupDirtyStencilOp(Tables& tables) { | 114 | void SetupDirtyStencilOp(Tables& tables) { |
| 120 | auto& table = tables[0]; | 115 | auto& table = tables[0]; |
| 121 | table[OFF(stencil_front_op_fail)] = StencilOp; | 116 | table[OFF(stencil_front_op_fail)] = StencilOp; |
| @@ -156,13 +151,13 @@ void StateTracker::Initialize() { | |||
| 156 | SetupDirtyDepthWriteEnable(tables); | 151 | SetupDirtyDepthWriteEnable(tables); |
| 157 | SetupDirtyDepthCompareOp(tables); | 152 | SetupDirtyDepthCompareOp(tables); |
| 158 | SetupDirtyFrontFace(tables); | 153 | SetupDirtyFrontFace(tables); |
| 159 | SetupDirtyPrimitiveTopology(tables); | ||
| 160 | SetupDirtyStencilOp(tables); | 154 | SetupDirtyStencilOp(tables); |
| 161 | SetupDirtyStencilTestEnable(tables); | 155 | SetupDirtyStencilTestEnable(tables); |
| 162 | } | 156 | } |
| 163 | 157 | ||
| 164 | void StateTracker::InvalidateCommandBufferState() { | 158 | void StateTracker::InvalidateCommandBufferState() { |
| 165 | system.GPU().Maxwell3D().dirty.flags |= invalidation_flags; | 159 | system.GPU().Maxwell3D().dirty.flags |= invalidation_flags; |
| 160 | current_topology = INVALID_TOPOLOGY; | ||
| 166 | } | 161 | } |
| 167 | 162 | ||
| 168 | } // namespace Vulkan | 163 | } // namespace Vulkan |
diff --git a/src/video_core/renderer_vulkan/vk_state_tracker.h b/src/video_core/renderer_vulkan/vk_state_tracker.h index 54ca0d6c6..13a6ce786 100644 --- a/src/video_core/renderer_vulkan/vk_state_tracker.h +++ b/src/video_core/renderer_vulkan/vk_state_tracker.h | |||
| @@ -32,7 +32,6 @@ enum : u8 { | |||
| 32 | DepthWriteEnable, | 32 | DepthWriteEnable, |
| 33 | DepthCompareOp, | 33 | DepthCompareOp, |
| 34 | FrontFace, | 34 | FrontFace, |
| 35 | PrimitiveTopology, | ||
| 36 | StencilOp, | 35 | StencilOp, |
| 37 | StencilTestEnable, | 36 | StencilTestEnable, |
| 38 | 37 | ||
| @@ -43,6 +42,8 @@ static_assert(Last <= std::numeric_limits<u8>::max()); | |||
| 43 | } // namespace Dirty | 42 | } // namespace Dirty |
| 44 | 43 | ||
| 45 | class StateTracker { | 44 | class StateTracker { |
| 45 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | ||
| 46 | |||
| 46 | public: | 47 | public: |
| 47 | explicit StateTracker(Core::System& system); | 48 | explicit StateTracker(Core::System& system); |
| 48 | 49 | ||
| @@ -102,10 +103,6 @@ public: | |||
| 102 | return Exchange(Dirty::FrontFace, false); | 103 | return Exchange(Dirty::FrontFace, false); |
| 103 | } | 104 | } |
| 104 | 105 | ||
| 105 | bool TouchPrimitiveTopology() { | ||
| 106 | return Exchange(Dirty::PrimitiveTopology, false); | ||
| 107 | } | ||
| 108 | |||
| 109 | bool TouchStencilOp() { | 106 | bool TouchStencilOp() { |
| 110 | return Exchange(Dirty::StencilOp, false); | 107 | return Exchange(Dirty::StencilOp, false); |
| 111 | } | 108 | } |
| @@ -114,7 +111,15 @@ public: | |||
| 114 | return Exchange(Dirty::StencilTestEnable, false); | 111 | return Exchange(Dirty::StencilTestEnable, false); |
| 115 | } | 112 | } |
| 116 | 113 | ||
| 114 | bool ChangePrimitiveTopology(Maxwell::PrimitiveTopology new_topology) { | ||
| 115 | const bool has_changed = current_topology != new_topology; | ||
| 116 | current_topology = new_topology; | ||
| 117 | return has_changed; | ||
| 118 | } | ||
| 119 | |||
| 117 | private: | 120 | private: |
| 121 | static constexpr auto INVALID_TOPOLOGY = static_cast<Maxwell::PrimitiveTopology>(~0u); | ||
| 122 | |||
| 118 | bool Exchange(std::size_t id, bool new_value) const noexcept { | 123 | bool Exchange(std::size_t id, bool new_value) const noexcept { |
| 119 | auto& flags = system.GPU().Maxwell3D().dirty.flags; | 124 | auto& flags = system.GPU().Maxwell3D().dirty.flags; |
| 120 | const bool is_dirty = flags[id]; | 125 | const bool is_dirty = flags[id]; |
| @@ -124,6 +129,7 @@ private: | |||
| 124 | 129 | ||
| 125 | Core::System& system; | 130 | Core::System& system; |
| 126 | Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags; | 131 | Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags; |
| 132 | Maxwell::PrimitiveTopology current_topology = INVALID_TOPOLOGY; | ||
| 127 | }; | 133 | }; |
| 128 | 134 | ||
| 129 | } // namespace Vulkan | 135 | } // namespace Vulkan |