yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

HACK: Avoid swizzling and reuploading ASTC image every frame

This commit is contained in:
Ameer J 2023-08-06 14:49:34 -04:00
parent 913803bf65
commit b18c1fb1bb
5 changed files with 39 additions and 4 deletions

View File

@ -554,7 +554,14 @@ void TextureCacheRuntime::Finish() {
} }
StagingBufferMap TextureCacheRuntime::UploadStagingBuffer(size_t size) { StagingBufferMap TextureCacheRuntime::UploadStagingBuffer(size_t size) {
return staging_buffer_pool.RequestUploadBuffer(size); static StagingBufferMap result;
static size_t last_size = 0;
if (size == last_size) {
return result;
}
last_size = size;
result = staging_buffer_pool.RequestUploadBuffer(size);
return result;
} }
StagingBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) { StagingBufferMap TextureCacheRuntime::DownloadStagingBuffer(size_t size) {

View File

@ -214,6 +214,7 @@ StagingBufferPool::StagingBuffersCache& StagingBufferPool::GetCache(MemoryUsage
} }
void StagingBufferPool::ReleaseCache(MemoryUsage usage) { void StagingBufferPool::ReleaseCache(MemoryUsage usage) {
return;
ReleaseLevel(GetCache(usage), current_delete_level); ReleaseLevel(GetCache(usage), current_delete_level);
} }

View File

@ -846,7 +846,15 @@ void TextureCacheRuntime::Finish() {
} }
StagingBufferRef TextureCacheRuntime::UploadStagingBuffer(size_t size) { StagingBufferRef TextureCacheRuntime::UploadStagingBuffer(size_t size) {
return staging_buffer_pool.Request(size, MemoryUsage::Upload); static StagingBufferRef result;
static size_t last_size = 0;
if (size == last_size) {
return result;
}
LOG_ERROR(Debug, "Called");
last_size = size;
result = staging_buffer_pool.Request(size, MemoryUsage::Upload);
return result;
} }
StagingBufferRef TextureCacheRuntime::DownloadStagingBuffer(size_t size, bool deferred) { StagingBufferRef TextureCacheRuntime::DownloadStagingBuffer(size_t size, bool deferred) {

View File

@ -1021,8 +1021,18 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging)
const GPUVAddr gpu_addr = image.gpu_addr; const GPUVAddr gpu_addr = image.gpu_addr;
if (True(image.flags & ImageFlagBits::AcceleratedUpload)) { if (True(image.flags & ImageFlagBits::AcceleratedUpload)) {
gpu_memory->ReadBlock(gpu_addr, mapped_span.data(), mapped_span.size_bytes(), static u64 last_size = 0;
VideoCommon::CacheType::NoTextureCache); bool has_run = false;
if (last_size == image.unswizzled_size_bytes) {
has_run = true;
}
last_size = image.unswizzled_size_bytes;
if (!has_run) {
LOG_ERROR(Debug, "Called");
gpu_memory->ReadBlock(gpu_addr, mapped_span.data(), mapped_span.size_bytes(),
VideoCommon::CacheType::NoTextureCache);
}
const auto uploads = FullUploadSwizzles(image.info); const auto uploads = FullUploadSwizzles(image.info);
runtime.AccelerateImageUpload(image, staging, uploads); runtime.AccelerateImageUpload(image, staging, uploads);
return; return;

View File

@ -88,6 +88,7 @@ void SwizzleImpl(std::span<u8> output, std::span<const u8> input, u32 width, u32
} }
} }
template <bool TO_LINEAR, u32 BYTES_PER_PIXEL> template <bool TO_LINEAR, u32 BYTES_PER_PIXEL>
void SwizzleSubrectImpl(std::span<u8> output, std::span<const u8> input, u32 width, u32 height, void SwizzleSubrectImpl(std::span<u8> output, std::span<const u8> input, u32 width, u32 height,
u32 depth, u32 origin_x, u32 origin_y, u32 extent_x, u32 num_lines, u32 depth, u32 origin_x, u32 origin_y, u32 extent_x, u32 num_lines,
@ -95,6 +96,14 @@ void SwizzleSubrectImpl(std::span<u8> output, std::span<const u8> input, u32 wid
// The origin of the transformation can be configured here, leave it as zero as the current API // The origin of the transformation can be configured here, leave it as zero as the current API
// doesn't expose it. // doesn't expose it.
static constexpr u32 origin_z = 0; static constexpr u32 origin_z = 0;
static u32 last_width = 0;
static u32 last_height = 0;
if (last_width == width && last_height == height) {
return;
}
LOG_ERROR(Debug, "Called");
last_width = width;
last_height = height;
// We can configure here a custom pitch // We can configure here a custom pitch
// As it's not exposed 'width * BYTES_PER_PIXEL' will be the expected pitch. // As it's not exposed 'width * BYTES_PER_PIXEL' will be the expected pitch.