graphics: support depth targets with read-only backing

This commit is contained in:
nmzik
2026-08-20 07:56:30 +02:00
parent fbdc1e8714
commit 6f9ed6ffe5
3 changed files with 28 additions and 3 deletions
+3 -2
View File
@@ -561,9 +561,10 @@ static void ZCheck(const HW::DepthRenderTarget& z, const HW::DepthControl& dc,
z.depth_view.stencil_write_disable ? "true" : "false");
}
}
EXIT_NOT_IMPLEMENTED(z.z_read_base_addr != z.z_write_base_addr);
EXIT_NOT_IMPLEMENTED(!z.depth_view.depth_write_disable &&
z.z_read_base_addr != z.z_write_base_addr);
EXIT_NOT_IMPLEMENTED(z.stencil_read_base_addr != z.stencil_write_base_addr);
EXIT_NOT_IMPLEMENTED(z.z_write_base_addr == 0);
EXIT_NOT_IMPLEMENTED(!z.depth_view.depth_write_disable && z.z_write_base_addr == 0);
if (z.stencil_info.format != Prospero::StencilFormat::kInvalid &&
z.stencil_write_base_addr == 0) {
LOGF("\t warning: stencil format is set without a stencil base address, continuing "
@@ -177,7 +177,8 @@ void RenderExecutor::ResolveRenderDepthTarget(uint64_t submit_id, RenderCommandB
z.htile_surface.htile_uses_preload_win != 0 || z.htile_surface.preload != 0 ||
z.htile_surface.prefetch_width != 0 || z.htile_surface.prefetch_height != 0 ||
z.htile_surface.dst_outside_zero_to_one != 0 || z.z_read_base_addr == 0 ||
z.z_write_base_addr != z.z_read_base_addr || (z.z_read_base_addr & 0xffffu) != 0 ||
(!z.depth_view.depth_write_disable && z.z_write_base_addr != z.z_read_base_addr) ||
(z.z_read_base_addr & 0xffffu) != 0 ||
dc.zfunc > static_cast<uint8_t>(vk::CompareOp::eAlways)) {
DepthFatal("unsupported depth register state");
}
+23
View File
@@ -7491,7 +7491,30 @@ public:
!texture_cache.GetImage(phased_depth.image_id).usage.depth_target,
"valid PS5 texture-compatibility policy changed logical depth image "
"identity or discovery side effects");
auto read_only_depth_target = phased_depth_target;
read_only_depth_target.z_write_base_addr = 0;
read_only_depth_target.depth_view.depth_write_disable = true;
registers.SetDepthRenderTarget(read_only_depth_target);
auto read_only_depth_control = phased_depth_control;
read_only_depth_control.z_write_enable = false;
registers.SetDepthControl(read_only_depth_control);
RenderDepthInfo read_only_depth{};
RenderExecutorTestAccess::ResolveRenderDepthTarget(
executor, 1, scheduler.Current(), read_only_depth);
Require(
name, "read-only depth target without write address",
read_only_depth.image_id == phased_depth.image_id &&
read_only_depth.depth_buffer_vaddr == phased_depth_address &&
!read_only_depth.depth_write_enable &&
!read_only_depth.AttachmentWriteAspects() &&
depth_attachment_layout(read_only_depth) ==
vk::ImageLayout::eDepthStencilReadOnlyOptimal,
"a PS5 read-only depth target required a depth write address or "
"selected a writable host layout");
registers.SetDepthRenderTarget(phased_depth_target);
registers.SetDepthControl(phased_depth_control);
RenderColorInfo no_color{};
auto phased_rendering = RenderExecutorTestAccess::AcquireRenderTargets(
executor, scheduler.Current(), &no_color, 0, phased_depth);