Minimal stopgaps for MCI to boot

- Clamp staging buffer size to 2GB to prevent Vulkan allocation failures
- Add size validation in MappedUploadMemory to avoid buffer overruns
This commit is contained in:
xbzk
2025-12-09 18:40:33 -03:00
committed by crueter
parent cfae726289
commit a701ea274f
2 changed files with 4 additions and 1 deletions

View File

@@ -1510,6 +1510,9 @@ void BufferCache<P>::MappedUploadMemory([[maybe_unused]] Buffer& buffer,
if constexpr (USE_MEMORY_MAPS) {
auto upload_staging = runtime.UploadStagingBuffer(total_size_bytes);
const std::span<u8> staging_pointer = upload_staging.mapped_span;
if (staging_pointer.size() < total_size_bytes) {
return;
}
for (BufferCopy& copy : copies) {
u8* const src_pointer = staging_pointer.data() + copy.src_offset;
const DAddr device_addr = buffer.CpuAddr() + copy.dst_offset;

View File

@@ -181,7 +181,7 @@ std::optional<StagingBufferRef> StagingBufferPool::TryGetReservedBuffer(size_t s
StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage usage,
bool deferred) {
const u32 log2 = Common::Log2Ceil64(size);
const u32 log2 = (std::min)(Common::Log2Ceil64(size), 31U);
VkBufferCreateInfo buffer_ci = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.pNext = nullptr,