|
|
|
@ -39,6 +39,12 @@ TextureCache<P>::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface&
|
|
|
|
|
sampler_descriptor.mipmap_filter.Assign(Tegra::Texture::TextureMipmapFilter::Linear);
|
|
|
|
|
sampler_descriptor.cubemap_anisotropy.Assign(1);
|
|
|
|
|
|
|
|
|
|
// These values were chosen based on typical peak swizzle data sizes seen in some titles
|
|
|
|
|
static constexpr size_t SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 8_MiB;
|
|
|
|
|
static constexpr size_t UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY = 1_MiB;
|
|
|
|
|
swizzle_data_buffer.resize_destructive(SWIZZLE_DATA_BUFFER_INITIAL_CAPACITY);
|
|
|
|
|
unswizzle_data_buffer.resize_destructive(UNSWIZZLE_DATA_BUFFER_INITIAL_CAPACITY);
|
|
|
|
|
|
|
|
|
|
// Make sure the first index is reserved for the null resources
|
|
|
|
|
// This way the null resource becomes a compile time constant
|
|
|
|
|
void(slot_images.insert(NullImageParams{}));
|
|
|
|
@ -90,7 +96,8 @@ void TextureCache<P>::RunGarbageCollector() {
|
|
|
|
|
const auto copies = FullDownloadCopies(image.info);
|
|
|
|
|
image.DownloadMemory(map, copies);
|
|
|
|
|
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)) {
|
|
|
|
|
UntrackImage(image, image_id);
|
|
|
|
@ -461,7 +468,8 @@ void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) {
|
|
|
|
|
const auto copies = FullDownloadCopies(image.info);
|
|
|
|
|
image.DownloadMemory(map, copies);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -672,7 +680,8 @@ void TextureCache<P>::PopAsyncFlushes() {
|
|
|
|
|
for (const ImageId image_id : download_ids) {
|
|
|
|
|
const ImageBase& image = slot_images[image_id];
|
|
|
|
|
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_span = download_span.subspan(image.unswizzled_size_bytes);
|
|
|
|
|
}
|
|
|
|
@ -734,13 +743,21 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging)
|
|
|
|
|
gpu_memory->ReadBlockUnsafe(gpu_addr, mapped_span.data(), mapped_span.size_bytes());
|
|
|
|
|
const auto uploads = FullUploadSwizzles(image.info);
|
|
|
|
|
runtime.AccelerateImageUpload(image, staging, uploads);
|
|
|
|
|
} else if (True(image.flags & ImageFlagBits::Converted)) {
|
|
|
|
|
std::vector<u8> unswizzled_data(image.unswizzled_size_bytes);
|
|
|
|
|
auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, unswizzled_data);
|
|
|
|
|
ConvertImage(unswizzled_data, image.info, mapped_span, copies);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const size_t guest_size_bytes = image.guest_size_bytes;
|
|
|
|
|
swizzle_data_buffer.resize_destructive(guest_size_bytes);
|
|
|
|
|
gpu_memory->ReadBlockUnsafe(gpu_addr, swizzle_data_buffer.data(), guest_size_bytes);
|
|
|
|
|
|
|
|
|
|
if (True(image.flags & ImageFlagBits::Converted)) {
|
|
|
|
|
unswizzle_data_buffer.resize_destructive(image.unswizzled_size_bytes);
|
|
|
|
|
auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, swizzle_data_buffer,
|
|
|
|
|
unswizzle_data_buffer);
|
|
|
|
|
ConvertImage(unswizzle_data_buffer, image.info, mapped_span, copies);
|
|
|
|
|
image.UploadMemory(staging, copies);
|
|
|
|
|
} else {
|
|
|
|
|
const auto copies = UnswizzleImage(*gpu_memory, gpu_addr, image.info, mapped_span);
|
|
|
|
|
const auto copies =
|
|
|
|
|
UnswizzleImage(*gpu_memory, gpu_addr, image.info, swizzle_data_buffer, mapped_span);
|
|
|
|
|
image.UploadMemory(staging, copies);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -910,7 +927,7 @@ void TextureCache<P>::InvalidateScale(Image& image) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class P>
|
|
|
|
|
u64 TextureCache<P>::GetScaledImageSizeBytes(ImageBase& image) {
|
|
|
|
|
u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) {
|
|
|
|
|
const u64 scale_up = static_cast<u64>(Settings::values.resolution_info.up_scale *
|
|
|
|
|
Settings::values.resolution_info.up_scale);
|
|
|
|
|
const u64 down_shift = static_cast<u64>(Settings::values.resolution_info.down_shift +
|
|
|
|
|