preserve DB_DEPTH_SIZE_XY and add tiled readback

This commit is contained in:
nmzik
2026-07-17 21:56:09 +02:00
parent 42d42e3258
commit f136c46519
7 changed files with 88 additions and 5 deletions
@@ -126,7 +126,10 @@ void ResolveRenderDepthTarget(uint64_t submit_id, CommandBuffer* buffer, const H
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 == 0 && z.stencil_read_base_addr == 0 &&
z.stencil_write_base_addr == 0 && z.htile_data_base_addr == 0 &&
!z.z_info.tile_surface_enable && !z.size.valid && !z.width_height_valid &&
// DB_DEPTH_SIZE_XY is independent state and may remain programmed after the attachment
// formats and addresses are unbound. A zero encoding is the valid 1x1 value, so its
// presence alone must not manufacture a depth attachment.
!z.z_info.tile_surface_enable && !z.width_height_valid &&
!z.pitch_height_valid && z.size.x_max == 0 && z.size.y_max == 0 &&
z.pitch_div8_minus1 == 0 && z.height_div8_minus1 == 0 && z.slice_div64_minus1 == 0 &&
z.width == 0 && z.height == 0;
@@ -215,7 +218,7 @@ void ResolveRenderDepthTarget(uint64_t submit_id, CommandBuffer* buffer, const H
} else if (z.htile_data_base_addr != 0) {
DepthFatal("HTile address without an enabled tile surface");
}
const bool size_xy_valid = z.size.valid && (z.size.x_max != 0 || z.size.y_max != 0);
const bool size_xy_valid = z.size.valid;
const bool wh_valid = z.width_height_valid && z.width != 0 && z.height != 0;
if (!size_xy_valid && !wh_valid) {
DepthFatal("missing depth extent");
+33
View File
@@ -2,6 +2,7 @@
#include "common/assert.h"
#include "graphics/guest_gpu/gpu_defs.h"
#include "graphics/guest_gpu/gpu_format.h"
#include "graphics/guest_gpu/tile.h"
#include "graphics/host_gpu/graphicContext.h"
#include "graphics/host_gpu/objects/textureCommon.h"
@@ -170,6 +171,38 @@ void Tiler::TileImage(void* dst, const void* src, const RenderTargetInfo& info)
}
}
void Tiler::TileImage(void* dst, const void* src, const ImageInfo& info) const {
const bool image_2d = info.type == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) &&
info.depth == 1;
const auto bytes_per_element = Prospero::RenderTargetBytesPerElement(info.format);
if (!image_2d || info.levels == 0 || info.levels > 16 ||
info.tile != Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) ||
bytes_per_element == 0) {
EXIT("Tiler: unsupported storage-texture tile, addr=0x%016" PRIx64
"+0x%016" PRIx64 " extent=%ux%ux%u levels=%u tile=%u format=%u\n",
info.address, info.size, info.width, info.height, info.depth, info.levels, info.tile,
info.format);
}
auto layout = TextureCalcUploadLayout(info.format, info.width, info.height, info.levels,
info.depth, info.pitch, info.tile, info.size, true, false,
false, "StorageTextureReadback");
auto regions = TextureBuildUploadRegions(
layout, Prospero::SurfaceFormat(info.format), info.width, info.height, info.depth,
info.levels, false, false, TextureUploadDestination::MipLevels,
TextureUploadSliceLayout::MipChainPerSlice);
std::memset(dst, 0, info.size);
for (uint32_t level = 0; level < info.levels; level++) {
const auto& level_size = layout.level_sizes[level];
const auto guest_offset = level_size.src_size != 0 ? level_size.src_offset
: level_size.offset;
auto* guest = static_cast<uint8_t*>(dst) + guest_offset;
const auto* linear = static_cast<const uint8_t*>(src) + regions[level].offset;
TileConvertLinearToTiledRenderTarget(
guest, linear, regions[level].width, regions[level].height, regions[level].pitch,
bytes_per_element, level_size.size, level_size.src_size, level_size.x, level_size.y);
}
}
void Tiler::TileImage(void* dst, const void* src, const DepthTargetInfo& info) const {
if (info.stencil_address != 0 || info.stencil_size != 0 ||
info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kDepth) ||
+1
View File
@@ -25,6 +25,7 @@ public:
const DepthTargetInfo& info, const BufferImageCopySource& source,
bool refresh, uint32_t base_layer = 0) const;
void TileImage(void* dst, const void* src, const RenderTargetInfo& info) const;
void TileImage(void* dst, const void* src, const ImageInfo& info) const;
void TileImage(void* dst, const void* src, const DepthTargetInfo& info) const;
};