texture_cache: Basic handling of partially resident images (#3066)

* texture_cache: Avoid gpu tracking assert on sparse image

At the moment just take the easy way of creating the entire image normally and uploading unmapped subresources are zero

* tile_manager: Downgrade assert to error

* fix macos
This commit is contained in:
TheTurtle
2025-06-09 11:26:10 +03:00
committed by GitHub
parent 12f4a8f073
commit d7051f15f4
5 changed files with 69 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
#include "common/debug.h"
#include "common/scope_exit.h"
#include "common/types.h"
#include "core/memory.h"
#include "video_core/amdgpu/liverpool.h"
#include "video_core/buffer_cache/buffer_cache.h"
#include "video_core/host_shaders/fault_buffer_process_comp.h"
@@ -28,7 +29,7 @@ BufferCache::BufferCache(const Vulkan::Instance& instance_, Vulkan::Scheduler& s
Vulkan::Rasterizer& rasterizer_, AmdGpu::Liverpool* liverpool_,
TextureCache& texture_cache_, PageManager& tracker_)
: instance{instance_}, scheduler{scheduler_}, rasterizer{rasterizer_}, liverpool{liverpool_},
texture_cache{texture_cache_}, tracker{tracker_},
memory{Core::Memory::Instance()}, texture_cache{texture_cache_}, tracker{tracker_},
staging_buffer{instance, scheduler, MemoryUsage::Upload, StagingBufferSize},
stream_buffer{instance, scheduler, MemoryUsage::Stream, UboStreamBufferSize},
download_buffer(instance, scheduler, MemoryUsage::Download, DownloadBufferSize),
@@ -365,7 +366,9 @@ std::pair<Buffer*, u32> BufferCache::ObtainViewBuffer(VAddr gpu_addr, u32 size,
return ObtainBuffer(gpu_addr, size, false, false);
}
// In all other cases, just do a CPU copy to the staging buffer.
const u32 offset = staging_buffer.Copy(gpu_addr, size, 16);
const auto [data, offset] = staging_buffer.Map(size, 16);
memory->CopySparseMemory(gpu_addr, data, size);
staging_buffer.Commit();
return {&staging_buffer, offset};
}

View File

@@ -17,6 +17,10 @@ namespace AmdGpu {
struct Liverpool;
}
namespace Core {
class MemoryManager;
}
namespace Shader {
namespace Gcn {
struct FetchShaderData;
@@ -183,6 +187,7 @@ private:
Vulkan::Scheduler& scheduler;
Vulkan::Rasterizer& rasterizer;
AmdGpu::Liverpool* liverpool;
Core::MemoryManager* memory;
TextureCache& texture_cache;
PageManager& tracker;
StreamBuffer staging_buffer;