mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 16:22:47 +01:00
texture_cache: Use pre-allocated buffer for texture downloads
This commit is contained in:
parent
c448b3af2f
commit
1209d428f1
3 changed files with 14 additions and 9 deletions
|
@ -96,7 +96,8 @@ void TextureCache<P>::RunGarbageCollector() {
|
||||||
const auto copies = FullDownloadCopies(image.info);
|
const auto copies = FullDownloadCopies(image.info);
|
||||||
image.DownloadMemory(map, copies);
|
image.DownloadMemory(map, copies);
|
||||||
runtime.Finish();
|
runtime.Finish();
|
||||||
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span);
|
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span,
|
||||||
|
swizzle_data_buffer);
|
||||||
}
|
}
|
||||||
if (True(image.flags & ImageFlagBits::Tracked)) {
|
if (True(image.flags & ImageFlagBits::Tracked)) {
|
||||||
UntrackImage(image, image_id);
|
UntrackImage(image, image_id);
|
||||||
|
@ -467,7 +468,8 @@ void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) {
|
||||||
const auto copies = FullDownloadCopies(image.info);
|
const auto copies = FullDownloadCopies(image.info);
|
||||||
image.DownloadMemory(map, copies);
|
image.DownloadMemory(map, copies);
|
||||||
runtime.Finish();
|
runtime.Finish();
|
||||||
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span);
|
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, map.mapped_span,
|
||||||
|
swizzle_data_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +680,8 @@ void TextureCache<P>::PopAsyncFlushes() {
|
||||||
for (const ImageId image_id : download_ids) {
|
for (const ImageId image_id : download_ids) {
|
||||||
const ImageBase& image = slot_images[image_id];
|
const ImageBase& image = slot_images[image_id];
|
||||||
const auto copies = FullDownloadCopies(image.info);
|
const auto copies = FullDownloadCopies(image.info);
|
||||||
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span);
|
SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span,
|
||||||
|
swizzle_data_buffer);
|
||||||
download_map.offset += image.unswizzled_size_bytes;
|
download_map.offset += image.unswizzled_size_bytes;
|
||||||
download_span = download_span.subspan(image.unswizzled_size_bytes);
|
download_span = download_span.subspan(image.unswizzled_size_bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,7 +505,7 @@ void SwizzlePitchLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr
|
||||||
|
|
||||||
void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr,
|
void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr,
|
||||||
const ImageInfo& info, const BufferImageCopy& copy,
|
const ImageInfo& info, const BufferImageCopy& copy,
|
||||||
std::span<const u8> input) {
|
std::span<const u8> input, std::vector<u8>& tmp_buffer) {
|
||||||
const Extent3D size = info.size;
|
const Extent3D size = info.size;
|
||||||
const LevelInfo level_info = MakeLevelInfo(info);
|
const LevelInfo level_info = MakeLevelInfo(info);
|
||||||
const Extent2D tile_size = DefaultBlockSize(info.format);
|
const Extent2D tile_size = DefaultBlockSize(info.format);
|
||||||
|
@ -534,8 +534,8 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr
|
||||||
tile_size.height, info.tile_width_spacing);
|
tile_size.height, info.tile_width_spacing);
|
||||||
const size_t subresource_size = sizes[level];
|
const size_t subresource_size = sizes[level];
|
||||||
|
|
||||||
const auto dst_data = std::make_unique<u8[]>(subresource_size);
|
tmp_buffer.resize(subresource_size);
|
||||||
const std::span<u8> dst(dst_data.get(), subresource_size);
|
const std::span<u8> dst(tmp_buffer);
|
||||||
|
|
||||||
for (s32 layer = 0; layer < info.resources.layers; ++layer) {
|
for (s32 layer = 0; layer < info.resources.layers; ++layer) {
|
||||||
const std::span<const u8> src = input.subspan(host_offset);
|
const std::span<const u8> src = input.subspan(host_offset);
|
||||||
|
@ -977,13 +977,14 @@ std::vector<SwizzleParameters> FullUploadSwizzles(const ImageInfo& info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info,
|
void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info,
|
||||||
std::span<const BufferImageCopy> copies, std::span<const u8> memory) {
|
std::span<const BufferImageCopy> copies, std::span<const u8> memory,
|
||||||
|
std::vector<u8>& tmp_buffer) {
|
||||||
const bool is_pitch_linear = info.type == ImageType::Linear;
|
const bool is_pitch_linear = info.type == ImageType::Linear;
|
||||||
for (const BufferImageCopy& copy : copies) {
|
for (const BufferImageCopy& copy : copies) {
|
||||||
if (is_pitch_linear) {
|
if (is_pitch_linear) {
|
||||||
SwizzlePitchLinearImage(gpu_memory, gpu_addr, info, copy, memory);
|
SwizzlePitchLinearImage(gpu_memory, gpu_addr, info, copy, memory);
|
||||||
} else {
|
} else {
|
||||||
SwizzleBlockLinearImage(gpu_memory, gpu_addr, info, copy, memory);
|
SwizzleBlockLinearImage(gpu_memory, gpu_addr, info, copy, memory, tmp_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,8 @@ void ConvertImage(std::span<const u8> input, const ImageInfo& info, std::span<u8
|
||||||
[[nodiscard]] std::vector<SwizzleParameters> FullUploadSwizzles(const ImageInfo& info);
|
[[nodiscard]] std::vector<SwizzleParameters> FullUploadSwizzles(const ImageInfo& info);
|
||||||
|
|
||||||
void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info,
|
void SwizzleImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr, const ImageInfo& info,
|
||||||
std::span<const BufferImageCopy> copies, std::span<const u8> memory);
|
std::span<const BufferImageCopy> copies, std::span<const u8> memory,
|
||||||
|
std::vector<u8>& tmp_buffer);
|
||||||
|
|
||||||
[[nodiscard]] bool IsBlockLinearSizeCompatible(const ImageInfo& new_info,
|
[[nodiscard]] bool IsBlockLinearSizeCompatible(const ImageInfo& new_info,
|
||||||
const ImageInfo& overlap_info, u32 new_level,
|
const ImageInfo& overlap_info, u32 new_level,
|
||||||
|
|
Loading…
Reference in a new issue