preserve DB_DEPTH_SIZE_XY and add tiled readback

This commit is contained in:
nmzik committed 2026-07-17 23:04:51 +02:00
1 parent 42d42e3258
commit f136c46519
7 files changed
+88 -5

No files matched your search

+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) ||