mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-29 23:06:23 -05:00
vk_state_tracker: Fix primitive topology
State track the current primitive topology with a regular comparison instead of using dirty flags. This fixes a bug in dirty flags for this particular state and it also avoids unnecessary state changes as this property is stored in a frequently changed bit field.
This commit is contained in:
parent
3ea3de4ecd
commit
aed6011d7c
3 changed files with 14 additions and 13 deletions
|
@ -1443,10 +1443,10 @@ void RasterizerVulkan::UpdateFrontFace(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::UpdatePrimitiveTopology(Tegra::Engines::Maxwell3D::Regs& regs) {
|
void RasterizerVulkan::UpdatePrimitiveTopology(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
if (!state_tracker.TouchPrimitiveTopology()) {
|
const Maxwell::PrimitiveTopology primitive_topology = regs.draw.topology.Value();
|
||||||
|
if (!state_tracker.ChangePrimitiveTopology(primitive_topology)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const Maxwell::PrimitiveTopology primitive_topology = regs.draw.topology.Value();
|
|
||||||
scheduler.Record([this, primitive_topology](vk::CommandBuffer cmdbuf) {
|
scheduler.Record([this, primitive_topology](vk::CommandBuffer cmdbuf) {
|
||||||
cmdbuf.SetPrimitiveTopologyEXT(MaxwellToVK::PrimitiveTopology(device, primitive_topology));
|
cmdbuf.SetPrimitiveTopologyEXT(MaxwellToVK::PrimitiveTopology(device, primitive_topology));
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,7 +42,6 @@ Flags MakeInvalidationFlags() {
|
||||||
flags[DepthWriteEnable] = true;
|
flags[DepthWriteEnable] = true;
|
||||||
flags[DepthCompareOp] = true;
|
flags[DepthCompareOp] = true;
|
||||||
flags[FrontFace] = true;
|
flags[FrontFace] = true;
|
||||||
flags[PrimitiveTopology] = true;
|
|
||||||
flags[StencilOp] = true;
|
flags[StencilOp] = true;
|
||||||
flags[StencilTestEnable] = true;
|
flags[StencilTestEnable] = true;
|
||||||
return flags;
|
return flags;
|
||||||
|
@ -112,10 +111,6 @@ void SetupDirtyFrontFace(Tables& tables) {
|
||||||
table[OFF(screen_y_control)] = FrontFace;
|
table[OFF(screen_y_control)] = FrontFace;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetupDirtyPrimitiveTopology(Tables& tables) {
|
|
||||||
tables[0][OFF(draw.topology)] = PrimitiveTopology;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetupDirtyStencilOp(Tables& tables) {
|
void SetupDirtyStencilOp(Tables& tables) {
|
||||||
auto& table = tables[0];
|
auto& table = tables[0];
|
||||||
table[OFF(stencil_front_op_fail)] = StencilOp;
|
table[OFF(stencil_front_op_fail)] = StencilOp;
|
||||||
|
@ -156,13 +151,13 @@ void StateTracker::Initialize() {
|
||||||
SetupDirtyDepthWriteEnable(tables);
|
SetupDirtyDepthWriteEnable(tables);
|
||||||
SetupDirtyDepthCompareOp(tables);
|
SetupDirtyDepthCompareOp(tables);
|
||||||
SetupDirtyFrontFace(tables);
|
SetupDirtyFrontFace(tables);
|
||||||
SetupDirtyPrimitiveTopology(tables);
|
|
||||||
SetupDirtyStencilOp(tables);
|
SetupDirtyStencilOp(tables);
|
||||||
SetupDirtyStencilTestEnable(tables);
|
SetupDirtyStencilTestEnable(tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StateTracker::InvalidateCommandBufferState() {
|
void StateTracker::InvalidateCommandBufferState() {
|
||||||
system.GPU().Maxwell3D().dirty.flags |= invalidation_flags;
|
system.GPU().Maxwell3D().dirty.flags |= invalidation_flags;
|
||||||
|
current_topology = INVALID_TOPOLOGY;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -32,7 +32,6 @@ enum : u8 {
|
||||||
DepthWriteEnable,
|
DepthWriteEnable,
|
||||||
DepthCompareOp,
|
DepthCompareOp,
|
||||||
FrontFace,
|
FrontFace,
|
||||||
PrimitiveTopology,
|
|
||||||
StencilOp,
|
StencilOp,
|
||||||
StencilTestEnable,
|
StencilTestEnable,
|
||||||
|
|
||||||
|
@ -43,6 +42,8 @@ static_assert(Last <= std::numeric_limits<u8>::max());
|
||||||
} // namespace Dirty
|
} // namespace Dirty
|
||||||
|
|
||||||
class StateTracker {
|
class StateTracker {
|
||||||
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StateTracker(Core::System& system);
|
explicit StateTracker(Core::System& system);
|
||||||
|
|
||||||
|
@ -102,10 +103,6 @@ public:
|
||||||
return Exchange(Dirty::FrontFace, false);
|
return Exchange(Dirty::FrontFace, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TouchPrimitiveTopology() {
|
|
||||||
return Exchange(Dirty::PrimitiveTopology, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TouchStencilOp() {
|
bool TouchStencilOp() {
|
||||||
return Exchange(Dirty::StencilOp, false);
|
return Exchange(Dirty::StencilOp, false);
|
||||||
}
|
}
|
||||||
|
@ -114,7 +111,15 @@ public:
|
||||||
return Exchange(Dirty::StencilTestEnable, false);
|
return Exchange(Dirty::StencilTestEnable, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChangePrimitiveTopology(Maxwell::PrimitiveTopology new_topology) {
|
||||||
|
const bool has_changed = current_topology != new_topology;
|
||||||
|
current_topology = new_topology;
|
||||||
|
return has_changed;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static constexpr auto INVALID_TOPOLOGY = static_cast<Maxwell::PrimitiveTopology>(~0u);
|
||||||
|
|
||||||
bool Exchange(std::size_t id, bool new_value) const noexcept {
|
bool Exchange(std::size_t id, bool new_value) const noexcept {
|
||||||
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
auto& flags = system.GPU().Maxwell3D().dirty.flags;
|
||||||
const bool is_dirty = flags[id];
|
const bool is_dirty = flags[id];
|
||||||
|
@ -124,6 +129,7 @@ private:
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags;
|
Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags;
|
||||||
|
Maxwell::PrimitiveTopology current_topology = INVALID_TOPOLOGY;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
Loading…
Reference in a new issue