From e9b198279fe8f50231d5f23df52920229eb0553e Mon Sep 17 00:00:00 2001 From: yuzubot Date: Wed, 14 Feb 2024 00:56:53 +0000 Subject: [PATCH] Merge yuzu-emu#12749 --- src/video_core/buffer_cache/buffer_cache.h | 5 ++++- src/video_core/renderer_vulkan/vk_query_cache.cpp | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 3818e00f4..d5f5b8a57 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -1488,7 +1488,10 @@ void BufferCache

::ImmediateUploadMemory([[maybe_unused]] Buffer& buffer, std::span upload_span; const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset; if (IsRangeGranular(device_addr, copy.size)) { - upload_span = std::span(device_memory.GetPointer(device_addr), copy.size); + auto* const ptr = device_memory.GetPointer(device_addr); + if (ptr != nullptr) { + upload_span = std::span(ptr, copy.size); + } } else { if (immediate_buffer.empty()) { immediate_buffer = ImmediateBuffer(largest_copy); diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 7cbc9c73c..a28296bda 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -1064,8 +1064,6 @@ public: } }); } - auto* ptr = device_memory.GetPointer(new_query->dependant_address); - ASSERT(ptr != nullptr); new_query->dependant_manage = must_manage_dependance; pending_flush_queries.push_back(index); @@ -1104,9 +1102,11 @@ public: tfb_streamer.Free(query->dependant_index); } else { u8* pointer = device_memory.GetPointer(query->dependant_address); - u32 result; - std::memcpy(&result, pointer, sizeof(u32)); - num_vertices = static_cast(result) / query->stride; + if (pointer != nullptr) { + u32 result; + std::memcpy(&result, pointer, sizeof(u32)); + num_vertices = static_cast(result) / query->stride; + } } query->value = [&]() -> u64 { switch (query->topology) { @@ -1360,7 +1360,9 @@ bool QueryCacheRuntime::HostConditionalRenderingCompareValues(VideoCommon::Looku const auto check_value = [&](DAddr address) { u8* ptr = impl->device_memory.GetPointer(address); u64 value{}; - std::memcpy(&value, ptr, sizeof(value)); + if (ptr != nullptr) { + std::memcpy(&value, ptr, sizeof(value)); + } return value == 0; }; std::array objects{&object_1, &object_2};