early-access version 3276

This commit is contained in:
pineappleEA 2023-01-04 00:44:27 +01:00
parent 0f64bad6bd
commit 906fe8d33a
5 changed files with 119 additions and 38 deletions

View File

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 3275. This is the source code for early-access 3276.
## Legal Notice ## Legal Notice

View File

@ -895,45 +895,83 @@ void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs)
update_compare_masks = true; update_compare_masks = true;
} }
if (update_references) { if (update_references) {
scheduler.Record([front_ref = regs.stencil_front_ref, back_ref = regs.stencil_back_ref, [&]() {
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) { if (regs.stencil_two_side_enable) {
const bool set_back = two_sided && front_ref != back_ref; if (!state_tracker.CheckStencilReferenceFront(regs.stencil_front_ref) &&
// Front face !state_tracker.CheckStencilReferenceBack(regs.stencil_back_ref)) {
cmdbuf.SetStencilReference( return;
set_back ? VK_STENCIL_FACE_FRONT_BIT : VK_STENCIL_FACE_FRONT_AND_BACK, front_ref); }
if (set_back) { } else {
cmdbuf.SetStencilReference(VK_STENCIL_FACE_BACK_BIT, back_ref); if (!state_tracker.CheckStencilReferenceFront(regs.stencil_front_ref)) {
return;
}
} }
}); scheduler.Record([front_ref = regs.stencil_front_ref, back_ref = regs.stencil_back_ref,
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) {
const bool set_back = two_sided && front_ref != back_ref;
// Front face
cmdbuf.SetStencilReference(set_back ? VK_STENCIL_FACE_FRONT_BIT
: VK_STENCIL_FACE_FRONT_AND_BACK,
front_ref);
if (set_back) {
cmdbuf.SetStencilReference(VK_STENCIL_FACE_BACK_BIT, back_ref);
}
});
}();
} }
if (update_write_mask) { if (update_write_mask) {
scheduler.Record([front_write_mask = regs.stencil_front_mask, [&]() {
back_write_mask = regs.stencil_back_mask, if (regs.stencil_two_side_enable) {
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) { if (!state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask) &&
const bool set_back = two_sided && front_write_mask != back_write_mask; !state_tracker.CheckStencilWriteMaskBack(regs.stencil_back_mask)) {
// Front face return;
cmdbuf.SetStencilWriteMask(set_back ? VK_STENCIL_FACE_FRONT_BIT }
: VK_STENCIL_FACE_FRONT_AND_BACK, } else {
front_write_mask); if (!state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask)) {
if (set_back) { return;
cmdbuf.SetStencilWriteMask(VK_STENCIL_FACE_BACK_BIT, back_write_mask); }
} }
}); scheduler.Record([front_write_mask = regs.stencil_front_mask,
back_write_mask = regs.stencil_back_mask,
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) {
const bool set_back = two_sided && front_write_mask != back_write_mask;
// Front face
cmdbuf.SetStencilWriteMask(set_back ? VK_STENCIL_FACE_FRONT_BIT
: VK_STENCIL_FACE_FRONT_AND_BACK,
front_write_mask);
if (set_back) {
cmdbuf.SetStencilWriteMask(VK_STENCIL_FACE_BACK_BIT, back_write_mask);
}
});
}();
} }
if (update_compare_masks) { if (update_compare_masks) {
scheduler.Record([front_test_mask = regs.stencil_front_func_mask, [&]() {
back_test_mask = regs.stencil_back_func_mask, if (regs.stencil_two_side_enable) {
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) { if (!state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask) &&
const bool set_back = two_sided && front_test_mask != back_test_mask; !state_tracker.CheckStencilCompareMaskBack(regs.stencil_back_func_mask)) {
// Front face return;
cmdbuf.SetStencilCompareMask(set_back ? VK_STENCIL_FACE_FRONT_BIT }
: VK_STENCIL_FACE_FRONT_AND_BACK, } else {
front_test_mask); if (!state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask)) {
if (set_back) { return;
cmdbuf.SetStencilCompareMask(VK_STENCIL_FACE_BACK_BIT, back_test_mask); }
} }
}); scheduler.Record([front_test_mask = regs.stencil_front_func_mask,
back_test_mask = regs.stencil_back_func_mask,
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) {
const bool set_back = two_sided && front_test_mask != back_test_mask;
// Front face
cmdbuf.SetStencilCompareMask(set_back ? VK_STENCIL_FACE_FRONT_BIT
: VK_STENCIL_FACE_FRONT_AND_BACK,
front_test_mask);
if (set_back) {
cmdbuf.SetStencilCompareMask(VK_STENCIL_FACE_BACK_BIT, back_test_mask);
}
});
}();
} }
state_tracker.ClearStencilReset();
} }
void RasterizerVulkan::UpdateLineWidth(Tegra::Engines::Maxwell3D::Regs& regs) { void RasterizerVulkan::UpdateLineWidth(Tegra::Engines::Maxwell3D::Regs& regs) {

View File

@ -244,9 +244,11 @@ void StateTracker::ChangeChannel(Tegra::Control::ChannelState& channel_state) {
void StateTracker::InvalidateState() { void StateTracker::InvalidateState() {
flags->set(); flags->set();
current_topology = INVALID_TOPOLOGY;
stencil_reset = true;
} }
StateTracker::StateTracker() StateTracker::StateTracker()
: flags{&default_flags}, default_flags{}, invalidation_flags{MakeInvalidationFlags()} {} : flags{&default_flags}, default_flags{}, invalidation_flags{MakeInvalidationFlags()} {}
} // namespace Vulkan } // namespace Vulkan

View File

@ -77,6 +77,7 @@ public:
void InvalidateCommandBufferState() { void InvalidateCommandBufferState() {
(*flags) |= invalidation_flags; (*flags) |= invalidation_flags;
current_topology = INVALID_TOPOLOGY; current_topology = INVALID_TOPOLOGY;
stencil_reset = true;
} }
void InvalidateViewports() { void InvalidateViewports() {
@ -128,12 +129,45 @@ public:
return Exchange(Dirty::StencilCompare, false); return Exchange(Dirty::StencilCompare, false);
} }
bool TouchStencilSide(bool two_sided_stencil_new) { template <typename T>
bool result = two_sided_stencil != two_sided_stencil_new; bool ExchangeCheck(T& old_value, T new_value) {
two_sided_stencil = two_sided_stencil_new; bool result = old_value != new_value;
old_value = new_value;
return result; return result;
} }
bool TouchStencilSide(bool two_sided_stencil_new) {
return ExchangeCheck(two_sided_stencil, two_sided_stencil_new) || stencil_reset;
}
bool CheckStencilReferenceFront(u32 new_value) {
return ExchangeCheck(front.ref, new_value) || stencil_reset;
}
bool CheckStencilReferenceBack(u32 new_value) {
return ExchangeCheck(back.ref, new_value) || stencil_reset;
}
bool CheckStencilWriteMaskFront(u32 new_value) {
return ExchangeCheck(front.write_mask, new_value) || stencil_reset;
}
bool CheckStencilWriteMaskBack(u32 new_value) {
return ExchangeCheck(back.write_mask, new_value) || stencil_reset;
}
bool CheckStencilCompareMaskFront(u32 new_value) {
return ExchangeCheck(front.compare_mask, new_value) || stencil_reset;
}
bool CheckStencilCompareMaskBack(u32 new_value) {
return ExchangeCheck(back.compare_mask, new_value) || stencil_reset;
}
void ClearStencilReset() {
stencil_reset = false;
}
bool TouchLineWidth() const { bool TouchLineWidth() const {
return Exchange(Dirty::LineWidth, false); return Exchange(Dirty::LineWidth, false);
} }
@ -235,11 +269,20 @@ private:
return is_dirty; return is_dirty;
} }
struct StencilProperties {
u32 ref = 0;
u32 write_mask = 0;
u32 compare_mask = 0;
};
Tegra::Engines::Maxwell3D::DirtyState::Flags* flags; Tegra::Engines::Maxwell3D::DirtyState::Flags* flags;
Tegra::Engines::Maxwell3D::DirtyState::Flags default_flags; Tegra::Engines::Maxwell3D::DirtyState::Flags default_flags;
Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags; Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags;
Maxwell::PrimitiveTopology current_topology = INVALID_TOPOLOGY; Maxwell::PrimitiveTopology current_topology = INVALID_TOPOLOGY;
bool two_sided_stencil = false; bool two_sided_stencil = false;
StencilProperties front{};
StencilProperties back{};
bool stencil_reset = false;
}; };
} // namespace Vulkan } // namespace Vulkan

View File

@ -1531,8 +1531,6 @@ void TextureCache<P>::BubbleUpImages(VAddr cpu_addr, size_t size) {
if (slot_images[bottom_map.image_id].modification_tick < if (slot_images[bottom_map.image_id].modification_tick <
slot_images[top_map.image_id].modification_tick) { slot_images[top_map.image_id].modification_tick) {
std::swap(map_vector[i - 1], map_vector[i]); std::swap(map_vector[i - 1], map_vector[i]);
} else {
return;
} }
} }
}); });