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
=============
This is the source code for early-access 3275.
This is the source code for early-access 3276.
## Legal Notice

View file

@ -895,45 +895,83 @@ void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs)
update_compare_masks = true;
}
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) {
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 (regs.stencil_two_side_enable) {
if (!state_tracker.CheckStencilReferenceFront(regs.stencil_front_ref) &&
!state_tracker.CheckStencilReferenceBack(regs.stencil_back_ref)) {
return;
}
} else {
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) {
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 (regs.stencil_two_side_enable) {
if (!state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask) &&
!state_tracker.CheckStencilWriteMaskBack(regs.stencil_back_mask)) {
return;
}
} else {
if (!state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask)) {
return;
}
}
});
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) {
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);
[&]() {
if (regs.stencil_two_side_enable) {
if (!state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask) &&
!state_tracker.CheckStencilCompareMaskBack(regs.stencil_back_func_mask)) {
return;
}
} else {
if (!state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask)) {
return;
}
}
});
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) {

View file

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

View file

@ -77,6 +77,7 @@ public:
void InvalidateCommandBufferState() {
(*flags) |= invalidation_flags;
current_topology = INVALID_TOPOLOGY;
stencil_reset = true;
}
void InvalidateViewports() {
@ -128,12 +129,45 @@ public:
return Exchange(Dirty::StencilCompare, false);
}
bool TouchStencilSide(bool two_sided_stencil_new) {
bool result = two_sided_stencil != two_sided_stencil_new;
two_sided_stencil = two_sided_stencil_new;
template <typename T>
bool ExchangeCheck(T& old_value, T new_value) {
bool result = old_value != new_value;
old_value = new_value;
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 {
return Exchange(Dirty::LineWidth, false);
}
@ -235,11 +269,20 @@ private:
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 default_flags;
Tegra::Engines::Maxwell3D::DirtyState::Flags invalidation_flags;
Maxwell::PrimitiveTopology current_topology = INVALID_TOPOLOGY;
bool two_sided_stencil = false;
StencilProperties front{};
StencilProperties back{};
bool stencil_reset = false;
};
} // 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 <
slot_images[top_map.image_id].modification_tick) {
std::swap(map_vector[i - 1], map_vector[i]);
} else {
return;
}
}
});