mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-23 17:57:03 +02:00
[vk] The next step of the human kind before it's doom
This commit is contained in:
parent
c36769b776
commit
0d1f76665f
1 changed files with 57 additions and 65 deletions
|
|
@ -1278,52 +1278,57 @@ void RasterizerVulkan::UpdateDepthBias(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// void RasterizerVulkan::UpdateLineWidth(Tegra::Engines::Maxwell3D::Regs& regs) {
|
void RasterizerVulkan::UpdateBlendConstants(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
// if (!state_tracker.TouchLineWidth()) {
|
if (!state_tracker.TouchBlendConstants()) {
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// const std::array blend_color = {regs.blend_color.r, regs.blend_color.g, regs.blend_color.b,
|
const std::array<float, 4> blend_color{
|
||||||
// regs.blend_color.a};
|
regs.blend_color.r,
|
||||||
// scheduler.Record(
|
regs.blend_color.g,
|
||||||
// [blend_color](vk::CommandBuffer cmdbuf) { cmdbuf.SetBlendConstants(blend_color.data()); });
|
regs.blend_color.b,
|
||||||
// }
|
regs.blend_color.a,
|
||||||
|
};
|
||||||
|
scheduler.Record([blend_color](vk::CommandBuffer cmdbuf) {
|
||||||
|
cmdbuf.SetBlendConstants(blend_color.data());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::UpdateDepthBounds(Tegra::Engines::Maxwell3D::Regs& regs) {
|
void RasterizerVulkan::UpdateDepthBounds(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
if (!state_tracker.TouchDepthBounds()) {
|
if (!state_tracker.TouchDepthBounds()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scheduler.Record([min = regs.depth_bounds[0], max = regs.depth_bounds[1]](
|
if (!device.IsDepthBoundsSupported()) {
|
||||||
vk::CommandBuffer cmdbuf) { cmdbuf.SetDepthBounds(min, max); });
|
return;
|
||||||
|
}
|
||||||
|
const float min_depth = regs.depth_bounds[0];
|
||||||
|
const float max_depth = regs.depth_bounds[1];
|
||||||
|
scheduler.Record([min_depth, max_depth](vk::CommandBuffer cmdbuf) {
|
||||||
|
cmdbuf.SetDepthBounds(min_depth, max_depth);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs) {
|
void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs) {
|
||||||
if (!state_tracker.TouchStencilProperties()) {
|
const bool properties_dirty = state_tracker.TouchStencilProperties();
|
||||||
|
const bool two_sided = regs.stencil_two_side_enable != 0;
|
||||||
|
const bool update_side = state_tracker.TouchStencilSide(two_sided) || properties_dirty;
|
||||||
|
const bool update_reference = state_tracker.TouchStencilReference() || properties_dirty || update_side;
|
||||||
|
const bool update_write_masks = state_tracker.TouchStencilWriteMask() || properties_dirty || update_side;
|
||||||
|
const bool update_compare_masks = state_tracker.TouchStencilCompare() || properties_dirty || update_side;
|
||||||
|
|
||||||
|
if (!update_reference && !update_write_masks && !update_compare_masks) {
|
||||||
|
state_tracker.ClearStencilReset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool update_references = state_tracker.TouchStencilReference();
|
|
||||||
bool update_write_mask = state_tracker.TouchStencilWriteMask();
|
if (update_reference) {
|
||||||
bool update_compare_masks = state_tracker.TouchStencilCompare();
|
const bool front_dirty = state_tracker.CheckStencilReferenceFront(regs.stencil_front_ref);
|
||||||
if (state_tracker.TouchStencilSide(regs.stencil_two_side_enable != 0)) {
|
const bool back_dirty = two_sided ?
|
||||||
update_references = true;
|
state_tracker.CheckStencilReferenceBack(regs.stencil_back_ref) : false;
|
||||||
update_write_mask = true;
|
if (update_side || front_dirty || back_dirty) {
|
||||||
update_compare_masks = true;
|
scheduler.Record([front_ref = regs.stencil_front_ref,
|
||||||
}
|
back_ref = regs.stencil_back_ref,
|
||||||
if (update_references) {
|
two_sided](vk::CommandBuffer cmdbuf) {
|
||||||
[&]() {
|
|
||||||
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;
|
const bool set_back = two_sided && front_ref != back_ref;
|
||||||
// Front face
|
|
||||||
cmdbuf.SetStencilReference(set_back ? VK_STENCIL_FACE_FRONT_BIT
|
cmdbuf.SetStencilReference(set_back ? VK_STENCIL_FACE_FRONT_BIT
|
||||||
: VK_STENCIL_FACE_FRONT_AND_BACK,
|
: VK_STENCIL_FACE_FRONT_AND_BACK,
|
||||||
front_ref);
|
front_ref);
|
||||||
|
|
@ -1331,25 +1336,18 @@ void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
cmdbuf.SetStencilReference(VK_STENCIL_FACE_BACK_BIT, back_ref);
|
cmdbuf.SetStencilReference(VK_STENCIL_FACE_BACK_BIT, back_ref);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}();
|
}
|
||||||
}
|
}
|
||||||
if (update_write_mask) {
|
|
||||||
[&]() {
|
if (update_write_masks) {
|
||||||
if (regs.stencil_two_side_enable) {
|
const bool front_dirty = state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask);
|
||||||
if (!state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask) &&
|
const bool back_dirty = two_sided ?
|
||||||
!state_tracker.CheckStencilWriteMaskBack(regs.stencil_back_mask)) {
|
state_tracker.CheckStencilWriteMaskBack(regs.stencil_back_mask) : false;
|
||||||
return;
|
if (update_side || front_dirty || back_dirty) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!state_tracker.CheckStencilWriteMaskFront(regs.stencil_front_mask)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scheduler.Record([front_write_mask = regs.stencil_front_mask,
|
scheduler.Record([front_write_mask = regs.stencil_front_mask,
|
||||||
back_write_mask = regs.stencil_back_mask,
|
back_write_mask = regs.stencil_back_mask,
|
||||||
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) {
|
two_sided](vk::CommandBuffer cmdbuf) {
|
||||||
const bool set_back = two_sided && front_write_mask != back_write_mask;
|
const bool set_back = two_sided && front_write_mask != back_write_mask;
|
||||||
// Front face
|
|
||||||
cmdbuf.SetStencilWriteMask(set_back ? VK_STENCIL_FACE_FRONT_BIT
|
cmdbuf.SetStencilWriteMask(set_back ? VK_STENCIL_FACE_FRONT_BIT
|
||||||
: VK_STENCIL_FACE_FRONT_AND_BACK,
|
: VK_STENCIL_FACE_FRONT_AND_BACK,
|
||||||
front_write_mask);
|
front_write_mask);
|
||||||
|
|
@ -1357,25 +1355,18 @@ void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
cmdbuf.SetStencilWriteMask(VK_STENCIL_FACE_BACK_BIT, back_write_mask);
|
cmdbuf.SetStencilWriteMask(VK_STENCIL_FACE_BACK_BIT, back_write_mask);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_compare_masks) {
|
if (update_compare_masks) {
|
||||||
[&]() {
|
const bool front_dirty = state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask);
|
||||||
if (regs.stencil_two_side_enable) {
|
const bool back_dirty = two_sided ?
|
||||||
if (!state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask) &&
|
state_tracker.CheckStencilCompareMaskBack(regs.stencil_back_func_mask) : false;
|
||||||
!state_tracker.CheckStencilCompareMaskBack(regs.stencil_back_func_mask)) {
|
if (update_side || front_dirty || back_dirty) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!state_tracker.CheckStencilCompareMaskFront(regs.stencil_front_func_mask)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scheduler.Record([front_test_mask = regs.stencil_front_func_mask,
|
scheduler.Record([front_test_mask = regs.stencil_front_func_mask,
|
||||||
back_test_mask = regs.stencil_back_func_mask,
|
back_test_mask = regs.stencil_back_func_mask,
|
||||||
two_sided = regs.stencil_two_side_enable](vk::CommandBuffer cmdbuf) {
|
two_sided](vk::CommandBuffer cmdbuf) {
|
||||||
const bool set_back = two_sided && front_test_mask != back_test_mask;
|
const bool set_back = two_sided && front_test_mask != back_test_mask;
|
||||||
// Front face
|
|
||||||
cmdbuf.SetStencilCompareMask(set_back ? VK_STENCIL_FACE_FRONT_BIT
|
cmdbuf.SetStencilCompareMask(set_back ? VK_STENCIL_FACE_FRONT_BIT
|
||||||
: VK_STENCIL_FACE_FRONT_AND_BACK,
|
: VK_STENCIL_FACE_FRONT_AND_BACK,
|
||||||
front_test_mask);
|
front_test_mask);
|
||||||
|
|
@ -1383,8 +1374,9 @@ void RasterizerVulkan::UpdateStencilFaces(Tegra::Engines::Maxwell3D::Regs& regs)
|
||||||
cmdbuf.SetStencilCompareMask(VK_STENCIL_FACE_BACK_BIT, back_test_mask);
|
cmdbuf.SetStencilCompareMask(VK_STENCIL_FACE_BACK_BIT, back_test_mask);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state_tracker.ClearStencilReset();
|
state_tracker.ClearStencilReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue