mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-03-31 00:18:30 -04:00
video_core: MCI boot fixes and DMA multisized components support
Add workarounds for Marvel Cosmic Invasion boot issues: - Skip first 2 compute dispatches (xbzk@eden-emu.dev) - Clamp staging buffers to 2GB to prevent Vulkan failures (xbzk@eden-emu.dev) - Validate staging buffer sizes before uploads (xbzk@eden-emu.dev) Also improve DMA engine to support multisized components (1-4 bytes) instead of hardcoded 4-byte components. Co-authored-by: xbzk <xbzk@eden-emu.dev> Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
@@ -37,6 +38,7 @@
|
||||
#include "video_core/texture_cache/texture_cache_base.h"
|
||||
#include "video_core/vulkan_common/vulkan_device.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
#include "citron/util/title_ids.h"
|
||||
|
||||
namespace Vulkan {
|
||||
|
||||
@@ -487,6 +489,15 @@ void RasterizerVulkan::Clear(u32 layer_count) {
|
||||
}
|
||||
|
||||
void RasterizerVulkan::DispatchCompute() {
|
||||
// Skip first 2 dispatches for Marvel Cosmic Invasion to fix boot issues
|
||||
if (program_id == UICommon::TitleID::MarvelCosmicInvasion) {
|
||||
static u32 dispatch_count = 0;
|
||||
if (dispatch_count < 2) {
|
||||
dispatch_count++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FlushWork();
|
||||
gpu_memory->FlushCaching();
|
||||
|
||||
@@ -1604,6 +1615,7 @@ void RasterizerVulkan::InitializeChannel(Tegra::Control::ChannelState& channel)
|
||||
|
||||
void RasterizerVulkan::BindChannel(Tegra::Control::ChannelState& channel) {
|
||||
const s32 channel_id = channel.bind_id;
|
||||
staging_pool.SetProgramId(channel.program_id);
|
||||
BindToChannel(channel_id);
|
||||
{
|
||||
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
@@ -16,6 +17,7 @@
|
||||
#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h"
|
||||
#include "video_core/vulkan_common/vulkan_device.h"
|
||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||
#include "citron/util/title_ids.h"
|
||||
|
||||
namespace Vulkan {
|
||||
namespace {
|
||||
@@ -235,7 +237,15 @@ std::optional<StagingBufferRef> StagingBufferPool::TryGetReservedBuffer(size_t s
|
||||
|
||||
StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage usage,
|
||||
bool deferred) {
|
||||
const u32 log2 = Common::Log2Ceil64(size);
|
||||
u32 log2 = Common::Log2Ceil64(size);
|
||||
|
||||
// Only apply this workaround for Marvel Cosmic Invasion
|
||||
if (program_id == UICommon::TitleID::MarvelCosmicInvasion) {
|
||||
static constexpr u32 MAX_STAGING_BUFFER_LOG2 = 31U;
|
||||
// Calculate log2 of requested size, but clamp to maximum to prevent overflow
|
||||
// This ensures we still round up to the next power of 2, but cap at 2GB
|
||||
log2 = std::min(log2, MAX_STAGING_BUFFER_LOG2);
|
||||
}
|
||||
VkBufferCreateInfo buffer_ci = {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
@@ -44,6 +45,10 @@ public:
|
||||
|
||||
u64 GetMemoryUsage() const;
|
||||
|
||||
void SetProgramId(u64 program_id_) {
|
||||
program_id = program_id_;
|
||||
}
|
||||
|
||||
private:
|
||||
struct StreamBufferCommit {
|
||||
size_t upper_bound;
|
||||
@@ -121,6 +126,7 @@ private:
|
||||
size_t current_delete_level = 0;
|
||||
u64 buffer_index = 0;
|
||||
u64 unique_ids{};
|
||||
u64 program_id{};
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
||||
Reference in New Issue
Block a user