mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 13:56:59 +01:00
renderer: track attachment load clears by image aspect
This commit is contained in:
@@ -311,7 +311,6 @@ void RenderExecutor::ResolveRenderDepthTarget(CommandBuffer& buffer, RenderDepth
|
|||||||
}
|
}
|
||||||
r.desc = MakeDepthTargetDesc(buffer, z);
|
r.desc = MakeDepthTargetDesc(buffer, z);
|
||||||
r.depth_clear_enable = rc.depth_clear_enable;
|
r.depth_clear_enable = rc.depth_clear_enable;
|
||||||
r.depth_load_clear_enable = r.depth_clear_enable;
|
|
||||||
r.depth_clear_value = hw.GetDepthClearValue();
|
r.depth_clear_value = hw.GetDepthClearValue();
|
||||||
r.depth_test_enable = dc.z_enable;
|
r.depth_test_enable = dc.z_enable;
|
||||||
r.depth_write_enable = r.depth_test_enable && dc.z_write_enable &&
|
r.depth_write_enable = r.depth_test_enable && dc.z_write_enable &&
|
||||||
@@ -322,6 +321,9 @@ void RenderExecutor::ResolveRenderDepthTarget(CommandBuffer& buffer, RenderDepth
|
|||||||
|
|
||||||
r.stencil_clear_enable =
|
r.stencil_clear_enable =
|
||||||
has_stencil && rc.stencil_clear_enable && !z.depth_view.stencil_write_disable;
|
has_stencil && rc.stencil_clear_enable && !z.depth_view.stencil_write_disable;
|
||||||
|
r.load_clear_aspects = {};
|
||||||
|
if (r.depth_clear_enable) r.load_clear_aspects |= vk::ImageAspectFlagBits::eDepth;
|
||||||
|
if (r.stencil_clear_enable) r.load_clear_aspects |= vk::ImageAspectFlagBits::eStencil;
|
||||||
r.stencil_clear_value = hw.GetStencilClearValue();
|
r.stencil_clear_value = hw.GetStencilClearValue();
|
||||||
r.stencil_test_enable = has_stencil && dc.stencil_enable;
|
r.stencil_test_enable = has_stencil && dc.stencil_enable;
|
||||||
if (r.stencil_test_enable) {
|
if (r.stencil_test_enable) {
|
||||||
@@ -421,9 +423,9 @@ vk::ImageAspectFlags RenderDepthInfo::AttachmentWriteAspects() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto available = ImageViewOps::DepthAspectMask(format);
|
const auto available = ImageViewOps::DepthAspectMask(format);
|
||||||
vk::ImageAspectFlags writes {};
|
vk::ImageAspectFlags writes = load_clear_aspects & available;
|
||||||
if ((available & vk::ImageAspectFlagBits::eDepth) &&
|
if ((available & vk::ImageAspectFlagBits::eDepth) &&
|
||||||
(depth_load_clear_enable || depth_write_enable)) {
|
depth_write_enable) {
|
||||||
writes |= vk::ImageAspectFlagBits::eDepth;
|
writes |= vk::ImageAspectFlagBits::eDepth;
|
||||||
}
|
}
|
||||||
if (!(available & vk::ImageAspectFlagBits::eStencil)) {
|
if (!(available & vk::ImageAspectFlagBits::eStencil)) {
|
||||||
@@ -461,8 +463,7 @@ vk::ImageAspectFlags RenderDepthInfo::AttachmentWriteAspects() const {
|
|||||||
(can_pass && depth_pass && state.passOp != vk::StencilOp::eKeep) ||
|
(can_pass && depth_pass && state.passOp != vk::StencilOp::eKeep) ||
|
||||||
(can_pass && depth_fail && state.depthFailOp != vk::StencilOp::eKeep);
|
(can_pass && depth_fail && state.depthFailOp != vk::StencilOp::eKeep);
|
||||||
};
|
};
|
||||||
if (stencil_clear_enable ||
|
if (stencil_test_enable && (face_writes(stencil_front) || face_writes(stencil_back))) {
|
||||||
(stencil_test_enable && (face_writes(stencil_front) || face_writes(stencil_back)))) {
|
|
||||||
writes |= vk::ImageAspectFlagBits::eStencil;
|
writes |= vk::ImageAspectFlagBits::eStencil;
|
||||||
}
|
}
|
||||||
return writes;
|
return writes;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ struct RenderDepthInfo {
|
|||||||
// Discovery keeps guest image information but can remap the view into a larger cache image.
|
// Discovery keeps guest image information but can remap the view into a larger cache image.
|
||||||
TextureCache::ImageDesc desc;
|
TextureCache::ImageDesc desc;
|
||||||
bool depth_clear_enable = false;
|
bool depth_clear_enable = false;
|
||||||
bool depth_load_clear_enable = false;
|
vk::ImageAspectFlags load_clear_aspects;
|
||||||
float depth_clear_value = 0.0f;
|
float depth_clear_value = 0.0f;
|
||||||
bool depth_test_enable = false;
|
bool depth_test_enable = false;
|
||||||
// Effective draw writes; discovery applies test, target-write and clear controls.
|
// Effective draw writes; discovery applies test, target-write and clear controls.
|
||||||
|
|||||||
@@ -514,7 +514,11 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo
|
|||||||
const bool meta_clear =
|
const bool meta_clear =
|
||||||
metadata.kind == ImageMetadataKind::Htile &&
|
metadata.kind == ImageMetadataKind::Htile &&
|
||||||
cache.IsMetaCleared(metadata.range.address, depth.desc.view_info.base_layer);
|
cache.IsMetaCleared(metadata.range.address, depth.desc.view_info.base_layer);
|
||||||
depth.depth_load_clear_enable = depth.depth_clear_enable || meta_clear;
|
depth.load_clear_aspects = {};
|
||||||
|
if (depth.depth_clear_enable || meta_clear)
|
||||||
|
depth.load_clear_aspects |= vk::ImageAspectFlagBits::eDepth;
|
||||||
|
if (depth.stencil_clear_enable)
|
||||||
|
depth.load_clear_aspects |= vk::ImageAspectFlagBits::eStencil;
|
||||||
if (meta_clear &&
|
if (meta_clear &&
|
||||||
!cache.TouchMeta(metadata.range.address, depth.desc.view_info.base_layer, false)) {
|
!cache.TouchMeta(metadata.range.address, depth.desc.view_info.base_layer, false)) {
|
||||||
EXIT("failed to consume HTile clear state\n");
|
EXIT("failed to consume HTile clear state\n");
|
||||||
@@ -567,9 +571,11 @@ RenderState RenderExecutor::AcquireRenderTargets(CommandBuffer& buffer, RenderCo
|
|||||||
attachment.clear_value[0] = std::bit_cast<uint32_t>(depth.depth_clear_value);
|
attachment.clear_value[0] = std::bit_cast<uint32_t>(depth.depth_clear_value);
|
||||||
attachment.clear_value[1] = depth.stencil_clear_value;
|
attachment.clear_value[1] = depth.stencil_clear_value;
|
||||||
attachment.has_depth = static_cast<bool>(aspects & vk::ImageAspectFlagBits::eDepth);
|
attachment.has_depth = static_cast<bool>(aspects & vk::ImageAspectFlagBits::eDepth);
|
||||||
attachment.depth_clear = depth.depth_load_clear_enable;
|
attachment.depth_clear =
|
||||||
|
static_cast<bool>(depth.load_clear_aspects & vk::ImageAspectFlagBits::eDepth);
|
||||||
attachment.has_stencil = static_cast<bool>(aspects & vk::ImageAspectFlagBits::eStencil);
|
attachment.has_stencil = static_cast<bool>(aspects & vk::ImageAspectFlagBits::eStencil);
|
||||||
attachment.stencil_clear = depth.stencil_clear_enable;
|
attachment.stencil_clear =
|
||||||
|
static_cast<bool>(depth.load_clear_aspects & vk::ImageAspectFlagBits::eStencil);
|
||||||
}
|
}
|
||||||
if (color_count == 0 && !depth.image_id) {
|
if (color_count == 0 && !depth.image_id) {
|
||||||
const auto& limits = buffer.GetGraphics().GetPhysicalDeviceProperties().limits;
|
const auto& limits = buffer.GetGraphics().GetPhysicalDeviceProperties().limits;
|
||||||
@@ -1060,7 +1066,7 @@ bool RenderExecutor::CopyDepthToColor(CommandBuffer& buffer, const DrawCallInfo&
|
|||||||
state.ps_input_info.ps_sample_mask_export_enable);
|
state.ps_input_info.ps_sample_mask_export_enable);
|
||||||
vk::ImageAspectFlags feedback;
|
vk::ImageAspectFlags feedback;
|
||||||
const auto rendering = AcquireRenderTargets(buffer, &color, 1, depth, feedback);
|
const auto rendering = AcquireRenderTargets(buffer, &color, 1, depth, feedback);
|
||||||
if (depth.depth_load_clear_enable) {
|
if (depth.load_clear_aspects) {
|
||||||
m_context.GetCommandScheduler().BeginRendering(rendering);
|
m_context.GetCommandScheduler().BeginRendering(rendering);
|
||||||
}
|
}
|
||||||
auto& cache = m_context.GetTextureCache();
|
auto& cache = m_context.GetTextureCache();
|
||||||
|
|||||||
@@ -14672,7 +14672,7 @@ public:
|
|||||||
phased_rendering.num_color_attachments == 0 &&
|
phased_rendering.num_color_attachments == 0 &&
|
||||||
phased_rendering.depth_stencil_attachment.has_depth &&
|
phased_rendering.depth_stencil_attachment.has_depth &&
|
||||||
phased_rendering.depth_stencil_attachment.depth_clear &&
|
phased_rendering.depth_stencil_attachment.depth_clear &&
|
||||||
phased_depth.depth_load_clear_enable &&
|
static_cast<bool>(phased_depth.load_clear_aspects & vk::ImageAspectFlagBits::eDepth) &&
|
||||||
texture_cache.IsMeta(phased_depth.desc.info.metadata.range.address) &&
|
texture_cache.IsMeta(phased_depth.desc.info.metadata.range.address) &&
|
||||||
!texture_cache.IsMetaCleared(
|
!texture_cache.IsMetaCleared(
|
||||||
phased_depth.desc.info.metadata.range.address,
|
phased_depth.desc.info.metadata.range.address,
|
||||||
@@ -14853,7 +14853,7 @@ public:
|
|||||||
bounds_depth.image_id == depth_only.image_id &&
|
bounds_depth.image_id == depth_only.image_id &&
|
||||||
bounds_depth.depth_bounds_test_enable &&
|
bounds_depth.depth_bounds_test_enable &&
|
||||||
!bounds_depth.depth_write_enable &&
|
!bounds_depth.depth_write_enable &&
|
||||||
bounds_depth.depth_load_clear_enable == (pass == 0) &&
|
static_cast<bool>(bounds_depth.load_clear_aspects & vk::ImageAspectFlagBits::eDepth) == (pass == 0) &&
|
||||||
!texture_cache.IsMetaCleared(depth_only_htile_address, 0) &&
|
!texture_cache.IsMetaCleared(depth_only_htile_address, 0) &&
|
||||||
bounds_feedback == (pass == 0
|
bounds_feedback == (pass == 0
|
||||||
? vk::ImageAspectFlagBits::eDepth
|
? vk::ImageAspectFlagBits::eDepth
|
||||||
@@ -14932,7 +14932,7 @@ public:
|
|||||||
executor, scheduler.Current(), &no_color, 0, acquired_high_slice);
|
executor, scheduler.Current(), &no_color, 0, acquired_high_slice);
|
||||||
Require(name, "high HTile slice clear consumption",
|
Require(name, "high HTile slice clear consumption",
|
||||||
acquired_high_slice.image_id == high_slice.image_id &&
|
acquired_high_slice.image_id == high_slice.image_id &&
|
||||||
acquired_high_slice.depth_load_clear_enable == (pass == 0) &&
|
static_cast<bool>(acquired_high_slice.load_clear_aspects & vk::ImageAspectFlagBits::eDepth) == (pass == 0) &&
|
||||||
rendering.depth_stencil_attachment.depth_clear == (pass == 0) &&
|
rendering.depth_stencil_attachment.depth_clear == (pass == 0) &&
|
||||||
!texture_cache.IsMetaCleared(high_slice_target.htile_data_base_addr, 86) &&
|
!texture_cache.IsMetaCleared(high_slice_target.htile_data_base_addr, 86) &&
|
||||||
texture_cache.IsMetaCleared(high_slice_target.htile_data_base_addr, 85),
|
texture_cache.IsMetaCleared(high_slice_target.htile_data_base_addr, 85),
|
||||||
@@ -45703,12 +45703,12 @@ void CheckDepthAttachmentWrites() {
|
|||||||
|
|
||||||
target.depth_test_enable = false;
|
target.depth_test_enable = false;
|
||||||
target.depth_write_enable = false;
|
target.depth_write_enable = false;
|
||||||
target.depth_load_clear_enable = true;
|
target.load_clear_aspects = vk::ImageAspectFlagBits::eDepth;
|
||||||
Require("DepthAttachmentWrites", "depth clear",
|
Require("DepthAttachmentWrites", "depth clear",
|
||||||
target.AttachmentWriteAspects() == vk::ImageAspectFlagBits::eDepth,
|
target.AttachmentWriteAspects() == vk::ImageAspectFlagBits::eDepth,
|
||||||
"depth attachment clear did not claim depth");
|
"depth attachment clear did not claim depth");
|
||||||
|
|
||||||
target.depth_load_clear_enable = false;
|
target.load_clear_aspects = {};
|
||||||
target.stencil_test_enable = true;
|
target.stencil_test_enable = true;
|
||||||
target.stencil_front = {vk::StencilOp::eKeep, vk::StencilOp::eKeep,
|
target.stencil_front = {vk::StencilOp::eKeep, vk::StencilOp::eKeep,
|
||||||
vk::StencilOp::eKeep, vk::CompareOp::eAlways, 0xff, 0xff, 0};
|
vk::StencilOp::eKeep, vk::CompareOp::eAlways, 0xff, 0xff, 0};
|
||||||
@@ -45734,7 +45734,7 @@ void CheckDepthAttachmentWrites() {
|
|||||||
"masked front write or KEEP-only back face claimed stencil");
|
"masked front write or KEEP-only back face claimed stencil");
|
||||||
|
|
||||||
target.stencil_test_enable = false;
|
target.stencil_test_enable = false;
|
||||||
target.stencil_clear_enable = true;
|
target.load_clear_aspects = vk::ImageAspectFlagBits::eStencil;
|
||||||
Require("DepthAttachmentWrites", "stencil clear",
|
Require("DepthAttachmentWrites", "stencil clear",
|
||||||
target.AttachmentWriteAspects() == vk::ImageAspectFlagBits::eStencil,
|
target.AttachmentWriteAspects() == vk::ImageAspectFlagBits::eStencil,
|
||||||
"stencil attachment clear did not claim stencil");
|
"stencil attachment clear did not claim stencil");
|
||||||
@@ -45808,12 +45808,11 @@ void CheckDepthFeedbackAspects() {
|
|||||||
feedback(sampled) == vk::ImageAspectFlagBits::eDepth,
|
feedback(sampled) == vk::ImageAspectFlagBits::eDepth,
|
||||||
"overlapping mip and layer boundaries missed depth feedback");
|
"overlapping mip and layer boundaries missed depth feedback");
|
||||||
target.depth_write_enable = false;
|
target.depth_write_enable = false;
|
||||||
target.depth_load_clear_enable = true;
|
target.load_clear_aspects = vk::ImageAspectFlagBits::eDepth;
|
||||||
Require("DepthFeedbackAspects", "depth clear only",
|
Require("DepthFeedbackAspects", "depth clear only",
|
||||||
feedback(sampled) == vk::ImageAspectFlagBits::eDepth,
|
feedback(sampled) == vk::ImageAspectFlagBits::eDepth,
|
||||||
"a sampled depth attachment clear missed feedback");
|
"a sampled depth attachment clear missed feedback");
|
||||||
target.depth_load_clear_enable = false;
|
target.load_clear_aspects = vk::ImageAspectFlagBits::eStencil;
|
||||||
target.stencil_clear_enable = true;
|
|
||||||
sampled.aspect = vk::ImageAspectFlagBits::eStencil;
|
sampled.aspect = vk::ImageAspectFlagBits::eStencil;
|
||||||
Require("DepthFeedbackAspects", "stencil clear only",
|
Require("DepthFeedbackAspects", "stencil clear only",
|
||||||
feedback(sampled) == vk::ImageAspectFlagBits::eStencil,
|
feedback(sampled) == vk::ImageAspectFlagBits::eStencil,
|
||||||
@@ -45867,7 +45866,7 @@ void CheckDynamicRenderingState() {
|
|||||||
depth_attachment_layout(attachment) ==
|
depth_attachment_layout(attachment) ==
|
||||||
vk::ImageLayout::eDepthStencilReadOnlyOptimal,
|
vk::ImageLayout::eDepthStencilReadOnlyOptimal,
|
||||||
"fully read-only depth/stencil used a writable layout");
|
"fully read-only depth/stencil used a writable layout");
|
||||||
attachment.depth_load_clear_enable = true;
|
attachment.load_clear_aspects = vk::ImageAspectFlagBits::eDepth;
|
||||||
Require("DynamicRenderingState", "deferred depth clear layout",
|
Require("DynamicRenderingState", "deferred depth clear layout",
|
||||||
depth_attachment_layout(attachment) ==
|
depth_attachment_layout(attachment) ==
|
||||||
vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal,
|
vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal,
|
||||||
@@ -45878,9 +45877,9 @@ void CheckDynamicRenderingState() {
|
|||||||
depth_attachment_layout(attachment) ==
|
depth_attachment_layout(attachment) ==
|
||||||
vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal,
|
vk::ImageLayout::eDepthAttachmentStencilReadOnlyOptimal,
|
||||||
"depth-only writes did not retain read-only stencil");
|
"depth-only writes did not retain read-only stencil");
|
||||||
attachment.depth_load_clear_enable = false;
|
attachment.load_clear_aspects = {};
|
||||||
attachment.depth_write_enable = false;
|
attachment.depth_write_enable = false;
|
||||||
attachment.stencil_clear_enable = true;
|
attachment.load_clear_aspects = vk::ImageAspectFlagBits::eStencil;
|
||||||
Require("DynamicRenderingState", "depth-read stencil-write layout",
|
Require("DynamicRenderingState", "depth-read stencil-write layout",
|
||||||
depth_attachment_layout(attachment) ==
|
depth_attachment_layout(attachment) ==
|
||||||
vk::ImageLayout::eDepthReadOnlyStencilAttachmentOptimal,
|
vk::ImageLayout::eDepthReadOnlyStencilAttachmentOptimal,
|
||||||
|
|||||||
Reference in New Issue
Block a user