diff --git a/src/core/hle/service/vi/shared_buffer_manager.cpp b/src/core/hle/service/vi/shared_buffer_manager.cpp index 90b0de5cc4..01b20e1642 100644 --- a/src/core/hle/service/vi/shared_buffer_manager.cpp +++ b/src/core/hle/service/vi/shared_buffer_manager.cpp @@ -4,9 +4,15 @@ // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include +#include "common/assert.h" +#include "common/logging.h" +#include "common/scratch_buffer.h" #include "core/core.h" +#include "core/hle/kernel/k_page_group.h" #include "core/hle/kernel/k_process.h" #include "core/hle/kernel/k_system_resource.h" #include "core/hle/service/nvdrv/devices/nvmap.h" @@ -47,7 +53,7 @@ Result AllocateSharedBufferMemory(std::unique_ptr* out_page_ u32* end = system.DeviceMemory().GetPointer(block.GetAddress() + block.GetSize()); for (; start < end; start++) { - *start = 0xFF0000FF; + *start = 0x00000000; } } @@ -202,6 +208,10 @@ constexpr SharedMemoryPoolLayout SharedBufferPoolLayout = [] { constexpr u32 GetCaptureSlot(CaptureKind kind) { return static_cast(kind); } +static_assert(static_cast(CaptureKind::CallerApplet) + 1 == SharedBufferNumCaptureSlots, + "Capture slot count does not match CaptureKind"); + +constexpr u32 ColorOpaqueBlackRgba32 = 0xFF000000; template void ForEachPoolChunk(Core::System& system, Kernel::KPageGroup& page_group, u64 offset, u64 size, @@ -273,9 +283,17 @@ Result SharedBufferManager::CreateSession(Kernel::KProcess* owner_process, u64* // Record buffer id. m_buffer_id = m_next_buffer_id++; - // Record display id. - m_display_id = display_id; - } + // Record display id. + m_display_id = display_id; + + for (u32 slot = 0; slot < SharedBufferNumCaptureSlots; slot++) { + ForEachPoolChunk(m_system, *m_buffer_page_group, u64{slot} * SharedBufferSlotSize, + SharedBufferSlotSize, [](u8* dst, u64, u64 length) { + std::fill_n(reinterpret_cast(dst), length / sizeof(u32), + ColorOpaqueBlackRgba32); + }); + } + } // Map into process. Common::ProcessAddress map_address{};