summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2022-04-13 16:20:34 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2022-10-06 21:00:53 +0200
commit770e19f51a0767c8fc2b204d9d50fa504a3c4e44 (patch)
tree938617d76e967a0d50b70011e3e92d0b41686124
parentVideoCore: Add option to dump the macros. (diff)
downloadyuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.tar
yuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.tar.gz
yuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.tar.bz2
yuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.tar.lz
yuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.tar.xz
yuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.tar.zst
yuzu-770e19f51a0767c8fc2b204d9d50fa504a3c4e44.zip
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h10
-rw-r--r--src/video_core/memory_manager.cpp2
-rw-r--r--src/video_core/memory_manager.h4
3 files changed, 12 insertions, 4 deletions
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 6eb672475..2e616cee4 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -1316,12 +1316,16 @@ void BufferCache<P>::UpdateVertexBuffer(u32 index) {
const GPUVAddr gpu_addr_begin = array.StartAddress();
const GPUVAddr gpu_addr_end = limit.LimitAddress() + 1;
const std::optional<VAddr> cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr_begin);
- const u32 address_size = static_cast<u32>(gpu_addr_end - gpu_addr_begin);
- const u32 size = address_size; // TODO: Analyze stride and number of vertices
- if (array.enable == 0 || size == 0 || !cpu_addr) {
+ u32 address_size = static_cast<u32>(
+ std::min(gpu_addr_end - gpu_addr_begin, static_cast<u64>(std::numeric_limits<u32>::max())));
+ if (array.enable == 0 || address_size == 0 || !cpu_addr) {
vertex_buffers[index] = NULL_BINDING;
return;
}
+ if (!gpu_memory->IsWithinGPUAddressRange(gpu_addr_end)) {
+ address_size = gpu_memory->MaxContinousRange(gpu_addr_begin, address_size);
+ }
+ const u32 size = address_size; // TODO: Analyze stride and number of vertices
vertex_buffers[index] = Binding{
.cpu_addr = *cpu_addr,
.size = size,
diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp
index 4a692448e..3cb2d9224 100644
--- a/src/video_core/memory_manager.cpp
+++ b/src/video_core/memory_manager.cpp
@@ -193,7 +193,7 @@ void MemoryManager::Unmap(GPUVAddr gpu_addr, std::size_t size) {
}
std::optional<VAddr> MemoryManager::GpuToCpuAddress(GPUVAddr gpu_addr) const {
- if (gpu_addr >= address_space_size) [[unlikely]] {
+ if (!IsWithinGPUAddressRange(gpu_addr)) [[unlikely]] {
return std::nullopt;
}
if (GetEntry<true>(gpu_addr) != EntryType::Mapped) [[unlikely]] {
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 9c08edc20..ae4fd98df 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -110,6 +110,10 @@ public:
size_t MaxContinousRange(GPUVAddr gpu_addr, size_t size) const;
+ bool IsWithinGPUAddressRange(GPUVAddr gpu_addr) const {
+ return gpu_addr < address_space_size;
+ }
+
private:
template <bool is_big_pages, typename FuncMapped, typename FuncReserved, typename FuncUnmapped>
inline void MemoryOperation(GPUVAddr gpu_src_addr, std::size_t size, FuncMapped&& func_mapped,