mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
Merge 48aae964b4 into ed2fe134aa
This commit is contained in:
commit
535a493edc
@ -690,14 +690,15 @@ void StateFlags::UpdateChecksum()
|
||||
checksum = std::accumulate(flag_data.cbegin(), flag_data.cend(), 0U);
|
||||
}
|
||||
|
||||
void UpdateStateFlags(std::function<void(StateFlags*)> update_function)
|
||||
void UpdateStateFlags(IOS::HLE::EmulationKernel* const ios,
|
||||
std::function<void(StateFlags*)> update_function)
|
||||
{
|
||||
CreateSystemMenuTitleDirs();
|
||||
CreateSystemMenuTitleDirs(ios->GetESCore());
|
||||
const std::string file_path = Common::GetTitleDataPath(Titles::SYSTEM_MENU) + "/" WII_STATE;
|
||||
const auto fs = Core::System::GetInstance().GetIOS()->GetFS();
|
||||
const auto file_system = ios->GetFS();
|
||||
constexpr IOS::HLE::FS::Mode rw_mode = IOS::HLE::FS::Mode::ReadWrite;
|
||||
const auto file = fs->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, file_path,
|
||||
{rw_mode, rw_mode, rw_mode});
|
||||
const auto file = file_system->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, file_path,
|
||||
{rw_mode, rw_mode, rw_mode});
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
@ -712,10 +713,9 @@ void UpdateStateFlags(std::function<void(StateFlags*)> update_function)
|
||||
file->Write(&state, 1);
|
||||
}
|
||||
|
||||
void CreateSystemMenuTitleDirs()
|
||||
void CreateSystemMenuTitleDirs(const IOS::HLE::ESCore& es_core)
|
||||
{
|
||||
const auto& es = Core::System::GetInstance().GetIOS()->GetESCore();
|
||||
es.CreateTitleDirectories(Titles::SYSTEM_MENU, IOS::SYSMENU_GID);
|
||||
es_core.CreateTitleDirectories(Titles::SYSTEM_MENU, IOS::SYSMENU_GID);
|
||||
}
|
||||
|
||||
void AddRiivolutionPatches(BootParameters* boot_params,
|
||||
|
||||
@ -32,6 +32,12 @@ namespace File
|
||||
class IOFile;
|
||||
}
|
||||
|
||||
namespace IOS::HLE
|
||||
{
|
||||
class EmulationKernel;
|
||||
class ESCore;
|
||||
} // namespace IOS::HLE
|
||||
|
||||
namespace IOS::HLE::FS
|
||||
{
|
||||
class FileSystem;
|
||||
@ -222,13 +228,14 @@ struct StateFlags
|
||||
|
||||
// Reads the state file from the NAND, then calls the passed update function to update the struct,
|
||||
// and finally writes the updated state file to the NAND.
|
||||
void UpdateStateFlags(std::function<void(StateFlags*)> update_function);
|
||||
void UpdateStateFlags(IOS::HLE::EmulationKernel* ios,
|
||||
std::function<void(StateFlags*)> update_function);
|
||||
|
||||
/// Create title directories for the system menu (if needed).
|
||||
///
|
||||
/// Normally, this is automatically done by ES when the System Menu is installed,
|
||||
/// but we cannot rely on this because we don't require any system titles to be installed.
|
||||
void CreateSystemMenuTitleDirs();
|
||||
void CreateSystemMenuTitleDirs(const IOS::HLE::ESCore& es_core);
|
||||
|
||||
void AddRiivolutionPatches(BootParameters* boot_params,
|
||||
std::vector<DiscIO::Riivolution::Patch> riivolution_patches);
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -372,13 +373,15 @@ bool CBoot::SetupWiiMemory(Core::System& system, IOS::HLE::IOSC::ConsoleType con
|
||||
auto entryPos = region_settings.find(SConfig::GetInstance().m_region);
|
||||
RegionSetting region_setting = entryPos->second;
|
||||
|
||||
IOS::HLE::EmulationKernel* const ios = system.GetIOS();
|
||||
|
||||
std::string serno;
|
||||
std::string model = "RVL-001(" + region_setting.area + ")";
|
||||
CreateSystemMenuTitleDirs();
|
||||
CreateSystemMenuTitleDirs(ios->GetESCore());
|
||||
const std::string settings_file_path(Common::GetTitleDataPath(Titles::SYSTEM_MENU) +
|
||||
"/" WII_SETTING);
|
||||
|
||||
const auto fs = system.GetIOS()->GetFS();
|
||||
const auto fs = ios->GetFS();
|
||||
{
|
||||
Common::SettingsBuffer data;
|
||||
const auto file = fs->OpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, settings_file_path,
|
||||
@ -515,14 +518,14 @@ bool CBoot::SetupWiiMemory(Core::System& system, IOS::HLE::IOSC::ConsoleType con
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WriteEmptyPlayRecord()
|
||||
static void WriteEmptyPlayRecord(IOS::HLE::EmulationKernel* const ios)
|
||||
{
|
||||
CreateSystemMenuTitleDirs();
|
||||
CreateSystemMenuTitleDirs(ios->GetESCore());
|
||||
const std::string file_path = Common::GetTitleDataPath(Titles::SYSTEM_MENU) + "/play_rec.dat";
|
||||
const auto fs = Core::System::GetInstance().GetIOS()->GetFS();
|
||||
const auto file_system = ios->GetFS();
|
||||
constexpr IOS::HLE::FS::Mode rw_mode = IOS::HLE::FS::Mode::ReadWrite;
|
||||
const auto playrec_file = fs->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID, file_path,
|
||||
{rw_mode, rw_mode, rw_mode});
|
||||
const auto playrec_file = file_system->CreateAndOpenFile(IOS::SYSMENU_UID, IOS::SYSMENU_GID,
|
||||
file_path, {rw_mode, rw_mode, rw_mode});
|
||||
if (!playrec_file)
|
||||
return;
|
||||
std::vector<u8> empty_record(0x80);
|
||||
@ -547,8 +550,10 @@ bool CBoot::EmulatedBS2_Wii(Core::System& system, const Core::CPUThreadGuard& gu
|
||||
if (!tmd.IsValid())
|
||||
return false;
|
||||
|
||||
WriteEmptyPlayRecord();
|
||||
UpdateStateFlags([](StateFlags* state) {
|
||||
IOS::HLE::EmulationKernel* const pre_boot_ios = system.GetIOS();
|
||||
|
||||
WriteEmptyPlayRecord(pre_boot_ios);
|
||||
UpdateStateFlags(pre_boot_ios, [](StateFlags* const state) {
|
||||
state->flags = 0xc1;
|
||||
state->type = 0xff;
|
||||
state->discstate = 0x01;
|
||||
@ -573,14 +578,16 @@ bool CBoot::EmulatedBS2_Wii(Core::System& system, const Core::CPUThreadGuard& gu
|
||||
memory.Write_U32(static_cast<u32>(data_partition.offset >> 2), 0x3198);
|
||||
|
||||
const s32 ios_override = Config::Get(Config::MAIN_OVERRIDE_BOOT_IOS);
|
||||
const u64 ios = ios_override >= 0 ? Titles::IOS(static_cast<u32>(ios_override)) : tmd.GetIOSId();
|
||||
const u64 ios_id =
|
||||
ios_override >= 0 ? Titles::IOS(static_cast<u32>(ios_override)) : tmd.GetIOSId();
|
||||
|
||||
const auto console_type = volume.GetTicket(data_partition).GetConsoleType();
|
||||
if (!SetupWiiMemory(system, console_type) || !system.GetIOS()->BootIOS(ios))
|
||||
if (!SetupWiiMemory(system, console_type) || !pre_boot_ios->BootIOS(ios_id))
|
||||
return false;
|
||||
|
||||
auto di =
|
||||
std::static_pointer_cast<IOS::HLE::DIDevice>(system.GetIOS()->GetDeviceByName("/dev/di"));
|
||||
IOS::HLE::EmulationKernel* const post_boot_ios = system.GetIOS();
|
||||
|
||||
auto di = std::static_pointer_cast<IOS::HLE::DIDevice>(post_boot_ios->GetDeviceByName("/dev/di"));
|
||||
|
||||
di->InitializeIfFirstTime();
|
||||
di->ChangePartition(data_partition);
|
||||
@ -613,7 +620,7 @@ bool CBoot::EmulatedBS2_Wii(Core::System& system, const Core::CPUThreadGuard& gu
|
||||
|
||||
// Warning: This call will set incorrect running game metadata if our volume parameter
|
||||
// doesn't point to the same disc as the one that's inserted in the emulated disc drive!
|
||||
system.GetIOS()->GetESDevice()->DIVerify(tmd, volume.GetTicket(partition));
|
||||
post_boot_ios->GetESDevice()->DIVerify(tmd, volume.GetTicket(partition));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -18,11 +18,12 @@
|
||||
|
||||
bool CBoot::BootNANDTitle(Core::System& system, const u64 title_id)
|
||||
{
|
||||
UpdateStateFlags([](StateFlags* state) {
|
||||
IOS::HLE::EmulationKernel* const ios = system.GetIOS();
|
||||
UpdateStateFlags(ios, [](StateFlags* const state) {
|
||||
state->type = 0x04; // TYPE_NANDBOOT
|
||||
});
|
||||
|
||||
auto es = system.GetIOS()->GetESDevice();
|
||||
auto es = ios->GetESDevice();
|
||||
const IOS::ES::TicketReader ticket = es->GetCore().FindSignedTicket(title_id);
|
||||
auto console_type = IOS::HLE::IOSC::ConsoleType::Retail;
|
||||
if (ticket.IsValid())
|
||||
|
||||
@ -460,14 +460,14 @@ static void FifoPlayerThread(Core::System& system, const std::optional<std::stri
|
||||
AsyncRequests::GetInstance()->SetPassthrough(!system.IsDualCoreMode());
|
||||
|
||||
// Must happen on the proper thread for some video backends, e.g. OpenGL.
|
||||
return g_video_backend->Initialize(wsi);
|
||||
return g_video_backend->Initialize(system, wsi);
|
||||
};
|
||||
|
||||
const auto deinit_video = [] {
|
||||
auto deinit_video = [&] {
|
||||
// Clear on screen messages that haven't expired
|
||||
OSD::ClearMessages();
|
||||
|
||||
g_video_backend->Shutdown();
|
||||
g_video_backend->Shutdown(system);
|
||||
};
|
||||
|
||||
if (system.IsDualCoreMode())
|
||||
@ -475,7 +475,11 @@ static void FifoPlayerThread(Core::System& system, const std::optional<std::stri
|
||||
std::promise<bool> init_from_thread;
|
||||
|
||||
// Spawn the GPU thread.
|
||||
std::thread gpu_thread{[&] {
|
||||
// Capture deinit_video by value to prevent a reference to it from being used by gpu_thread
|
||||
// after GetInitializedVideoGuard returns. init_video doesn't need to be captured by value
|
||||
// because it's only used before init_from_thread is set, while GetInitializedVideoGuard waits
|
||||
// on init_from_thread below and can only return after that.
|
||||
std::thread gpu_thread{[&, deinit_video] {
|
||||
Common::SetCurrentThreadName("Video thread");
|
||||
|
||||
const bool is_init = init_video();
|
||||
@ -506,7 +510,7 @@ static void FifoPlayerThread(Core::System& system, const std::optional<std::stri
|
||||
else // SingleCore mode
|
||||
{
|
||||
if (init_video())
|
||||
return std::make_unique<GuardType>(deinit_video);
|
||||
return std::make_unique<GuardType>(std::move(deinit_video));
|
||||
}
|
||||
|
||||
return ReturnType{};
|
||||
|
||||
@ -69,8 +69,7 @@ void ExpansionInterfaceManager::AddMemoryCard(Slot slot)
|
||||
void ExpansionInterfaceManager::AddSP1Device()
|
||||
{
|
||||
EXIDeviceType sp1_device = EXIDeviceType::Baseboard;
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.IsTriforce())
|
||||
if (m_system.IsTriforce())
|
||||
{
|
||||
sp1_device = Config::Get(Config::MAIN_SERIAL_PORT_1);
|
||||
}
|
||||
|
||||
@ -864,7 +864,7 @@ void VideoInterfaceManager::OutputField(FieldType field, u64 ticks)
|
||||
// can change the register values during scanout. To correctly emulate the scanout process, we
|
||||
// would need to collate all changes to the VI registers during scanout.
|
||||
if (xfbAddr)
|
||||
g_video_backend->Video_OutputXFB(xfbAddr, fbWidth, fbStride, fbHeight, ticks);
|
||||
g_video_backend->Video_OutputXFB(m_system, xfbAddr, fbWidth, fbStride, fbHeight, ticks);
|
||||
}
|
||||
|
||||
void VideoInterfaceManager::BeginField(FieldType field, u64 ticks)
|
||||
|
||||
@ -175,7 +175,7 @@ static void DoState(Core::System& system, PointerWrap& p)
|
||||
|
||||
// Begin with video backend, so that it gets a chance to clear its caches and writeback modified
|
||||
// things to RAM
|
||||
g_video_backend->DoState(p);
|
||||
g_video_backend->DoState(system, p);
|
||||
p.DoMarker("video_backend");
|
||||
|
||||
// CoreTiming needs to be restored before restoring Hardware because
|
||||
|
||||
@ -26,6 +26,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
std::string VideoBackend::GetConfigName() const
|
||||
@ -139,7 +144,7 @@ void VideoBackend::FillBackendInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (!D3D::Create(g_Config.iAdapter, g_Config.bEnableValidationLayer))
|
||||
return false;
|
||||
@ -151,23 +156,23 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (wsi.render_surface && !(swap_chain = SwapChain::Create(wsi)))
|
||||
{
|
||||
PanicAlertFmtT("Failed to create D3D swap chain");
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
D3D::Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
auto gfx = std::make_unique<DX11::Gfx>(std::move(swap_chain), wsi.render_surface_scale);
|
||||
auto vertex_manager = std::make_unique<VertexManager>();
|
||||
auto vertex_manager = std::make_unique<VertexManager>(system);
|
||||
auto perf_query = std::make_unique<PerfQuery>();
|
||||
auto bounding_box = std::make_unique<D3DBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
D3D::Destroy();
|
||||
}
|
||||
} // namespace DX11
|
||||
|
||||
@ -67,7 +67,9 @@ CreateTexelBufferView(ID3D11Buffer* buffer, TexelBufferFormat format, DXGI_FORMA
|
||||
return srv;
|
||||
}
|
||||
|
||||
VertexManager::VertexManager() = default;
|
||||
VertexManager::VertexManager(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
VertexManager::~VertexManager() = default;
|
||||
|
||||
@ -262,9 +264,7 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
|
||||
|
||||
void VertexManager::UploadUniforms()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
if (vertex_shader_manager.dirty)
|
||||
{
|
||||
UpdateConstantBuffer(m_vertex_constant_buffer.Get(), &vertex_shader_manager.constants,
|
||||
@ -272,7 +272,7 @@ void VertexManager::UploadUniforms()
|
||||
vertex_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
auto& geometry_shader_manager = m_system.GetGeometryShaderManager();
|
||||
if (geometry_shader_manager.dirty)
|
||||
{
|
||||
UpdateConstantBuffer(m_geometry_constant_buffer.Get(), &geometry_shader_manager.constants,
|
||||
@ -280,7 +280,7 @@ void VertexManager::UploadUniforms()
|
||||
geometry_shader_manager.dirty = false;
|
||||
}
|
||||
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
if (pixel_shader_manager.dirty)
|
||||
{
|
||||
UpdateConstantBuffer(m_pixel_constant_buffer.Get(), &pixel_shader_manager.constants,
|
||||
|
||||
@ -14,6 +14,11 @@
|
||||
|
||||
enum class ShaderAttrib : u32;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
class D3DVertexFormat : public NativeVertexFormat
|
||||
@ -35,7 +40,7 @@ private:
|
||||
class VertexManager : public VertexManagerBase
|
||||
{
|
||||
public:
|
||||
VertexManager();
|
||||
VertexManager(Core::System& system);
|
||||
~VertexManager() override;
|
||||
|
||||
bool Initialize() override;
|
||||
@ -74,6 +79,8 @@ private:
|
||||
ComPtr<ID3D11Buffer> m_texel_buffer = nullptr;
|
||||
std::array<ComPtr<ID3D11ShaderResourceView>, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views;
|
||||
u32 m_texel_buffer_offset = 0;
|
||||
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
||||
} // namespace DX11
|
||||
|
||||
@ -4,15 +4,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -24,7 +24,9 @@
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
VertexManager::VertexManager() = default;
|
||||
VertexManager::VertexManager(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
VertexManager::~VertexManager() = default;
|
||||
|
||||
@ -146,8 +148,7 @@ void VertexManager::UploadUniforms()
|
||||
|
||||
void VertexManager::UpdateVertexShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
|
||||
if (!vertex_shader_manager.dirty || !ReserveConstantStorage())
|
||||
return;
|
||||
@ -162,8 +163,7 @@ void VertexManager::UpdateVertexShaderConstants()
|
||||
|
||||
void VertexManager::UpdateGeometryShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
auto& geometry_shader_manager = m_system.GetGeometryShaderManager();
|
||||
|
||||
if (!geometry_shader_manager.dirty || !ReserveConstantStorage())
|
||||
return;
|
||||
@ -178,8 +178,7 @@ void VertexManager::UpdateGeometryShaderConstants()
|
||||
|
||||
void VertexManager::UpdatePixelShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
|
||||
if (!ReserveConstantStorage())
|
||||
return;
|
||||
@ -197,8 +196,7 @@ void VertexManager::UpdatePixelShaderConstants()
|
||||
|
||||
void VertexManager::UpdateCustomShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
|
||||
if (!ReserveConstantStorage())
|
||||
return;
|
||||
@ -217,8 +215,7 @@ void VertexManager::UpdateCustomShaderConstants()
|
||||
|
||||
bool VertexManager::ReserveConstantStorage()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
|
||||
static constexpr u32 reserve_size =
|
||||
static_cast<u32>(std::max({sizeof(PixelShaderConstants), sizeof(VertexShaderConstants),
|
||||
@ -242,8 +239,7 @@ bool VertexManager::ReserveConstantStorage()
|
||||
|
||||
void VertexManager::UploadAllConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
|
||||
// We are free to re-use parts of the buffer now since we're uploading all constants.
|
||||
const u32 pixel_constants_offset = 0;
|
||||
@ -278,8 +274,8 @@ void VertexManager::UploadAllConstants()
|
||||
Gfx::GetInstance()->SetConstantBuffer(3, m_uniform_stream_buffer.GetCurrentGPUPointer() +
|
||||
geometry_constants_offset);
|
||||
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = m_system.GetGeometryShaderManager();
|
||||
|
||||
// Copy the actual data in
|
||||
std::memcpy(m_uniform_stream_buffer.GetCurrentHostPointer() + pixel_constants_offset,
|
||||
|
||||
@ -9,12 +9,17 @@
|
||||
#include "VideoBackends/D3D12/DescriptorHeapManager.h"
|
||||
#include "VideoCommon/VertexManagerBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
class VertexManager final : public VertexManagerBase
|
||||
{
|
||||
public:
|
||||
VertexManager();
|
||||
VertexManager(Core::System& system);
|
||||
~VertexManager() override;
|
||||
|
||||
bool Initialize() override;
|
||||
@ -49,6 +54,7 @@ protected:
|
||||
StreamBuffer m_texel_stream_buffer;
|
||||
std::array<DescriptorHandle, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views = {};
|
||||
DescriptorHandle m_vertex_srv = {};
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
||||
} // namespace DX12
|
||||
|
||||
@ -24,6 +24,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
std::string VideoBackend::GetConfigName() const
|
||||
@ -104,7 +109,7 @@ void VideoBackend::FillBackendInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (!DXContext::Create(g_Config.iAdapter, g_Config.bEnableValidationLayer))
|
||||
{
|
||||
@ -119,7 +124,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
{
|
||||
PanicAlertFmtT("Failed to create D3D12 global resources");
|
||||
DXContext::Destroy();
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -128,27 +133,27 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
{
|
||||
PanicAlertFmtT("Failed to create D3D swap chain");
|
||||
DXContext::Destroy();
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create main wrapper instances.
|
||||
auto gfx = std::make_unique<DX12::Gfx>(std::move(swap_chain), wsi.render_surface_scale);
|
||||
auto vertex_manager = std::make_unique<DX12::VertexManager>();
|
||||
auto vertex_manager = std::make_unique<DX12::VertexManager>(system);
|
||||
auto perf_query = std::make_unique<DX12::PerfQuery>();
|
||||
auto bounding_box = std::make_unique<DX12::D3D12BoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
// Keep the debug runtime happy...
|
||||
if (g_gfx)
|
||||
Gfx::GetInstance()->ExecuteCommandList(true);
|
||||
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
DXContext::Destroy();
|
||||
}
|
||||
} // namespace DX12
|
||||
|
||||
@ -7,13 +7,18 @@
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
class VideoBackend final : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -29,6 +29,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
std::string Metal::VideoBackend::GetConfigName() const
|
||||
{
|
||||
return CONFIG_NAME;
|
||||
@ -63,7 +68,7 @@ static bool WindowSystemTypeSupportsMetal(WindowSystemType type)
|
||||
}
|
||||
}
|
||||
|
||||
bool Metal::VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool Metal::VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
@ -125,15 +130,16 @@ bool Metal::VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
ObjectCache::Initialize(std::move(adapter));
|
||||
g_state_tracker = std::make_unique<StateTracker>();
|
||||
|
||||
return InitializeShared(
|
||||
std::make_unique<Metal::Gfx>(std::move(layer)), std::make_unique<Metal::VertexManager>(),
|
||||
std::make_unique<Metal::PerfQuery>(), std::make_unique<Metal::BoundingBox>());
|
||||
return InitializeShared(system, std::make_unique<Metal::Gfx>(std::move(layer)),
|
||||
std::make_unique<Metal::VertexManager>(system),
|
||||
std::make_unique<Metal::PerfQuery>(),
|
||||
std::make_unique<Metal::BoundingBox>());
|
||||
}
|
||||
}
|
||||
|
||||
void Metal::VideoBackend::Shutdown()
|
||||
void Metal::VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
|
||||
g_state_tracker.reset();
|
||||
ObjectCache::Shutdown();
|
||||
|
||||
@ -6,12 +6,17 @@
|
||||
#include "VideoBackends/Metal/MTLUtil.h"
|
||||
#include "VideoCommon/VertexManagerBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
};
|
||||
|
||||
namespace Metal
|
||||
{
|
||||
class VertexManager final : public VertexManagerBase
|
||||
{
|
||||
public:
|
||||
VertexManager();
|
||||
VertexManager(Core::System& system);
|
||||
~VertexManager() override;
|
||||
|
||||
void UploadUtilityUniforms(const void* uniforms, u32 uniforms_size) override;
|
||||
@ -30,5 +35,6 @@ protected:
|
||||
private:
|
||||
u32 m_vertex_offset;
|
||||
u32 m_base_vertex;
|
||||
Core::System& m_system;
|
||||
};
|
||||
} // namespace Metal
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include "VideoCommon/Statistics.h"
|
||||
#include "VideoCommon/VertexShaderManager.h"
|
||||
|
||||
Metal::VertexManager::VertexManager()
|
||||
Metal::VertexManager::VertexManager(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
@ -91,10 +91,9 @@ void Metal::VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32
|
||||
|
||||
void Metal::VertexManager::UploadUniforms()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = m_system.GetGeometryShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
g_state_tracker->InvalidateUniforms(vertex_shader_manager.dirty, geometry_shader_manager.dirty,
|
||||
pixel_shader_manager.dirty);
|
||||
vertex_shader_manager.dirty = false;
|
||||
|
||||
@ -4,15 +4,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Metal
|
||||
{
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -19,6 +19,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Null
|
||||
{
|
||||
void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
@ -65,16 +70,16 @@ void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
g_backend_info.AAModes = {1};
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
return InitializeShared(std::make_unique<NullGfx>(), std::make_unique<VertexManager>(),
|
||||
return InitializeShared(system, std::make_unique<NullGfx>(), std::make_unique<VertexManager>(),
|
||||
std::make_unique<PerfQuery>(), std::make_unique<NullBoundingBox>(),
|
||||
std::make_unique<NullEFBInterface>(), std::make_unique<TextureCache>());
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
}
|
||||
|
||||
std::string VideoBackend::GetDisplayName() const
|
||||
|
||||
@ -3,15 +3,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Null
|
||||
{
|
||||
class VideoBackend final : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override { return CONFIG_NAME; }
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -59,6 +59,11 @@ Make AA apply instantly during gameplay if possible
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
std::string VideoBackend::GetConfigName() const
|
||||
@ -193,7 +198,7 @@ bool VideoBackend::FillBackendInfo(GLContext* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
std::unique_ptr<GLContext> main_gl_context =
|
||||
GLContext::Create(wsi, g_Config.stereo_mode == StereoMode::QuadBuffer, true, false,
|
||||
@ -208,17 +213,17 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
ProgramShaderCache::Init();
|
||||
g_sampler_cache = std::make_unique<SamplerCache>();
|
||||
|
||||
auto vertex_manager = std::make_unique<VertexManager>();
|
||||
auto vertex_manager = std::make_unique<VertexManager>(system);
|
||||
auto perf_query = GetPerfQuery(gfx->IsGLES());
|
||||
auto bounding_box = std::make_unique<OGLBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
|
||||
ProgramShaderCache::Shutdown();
|
||||
g_sampler_cache.reset();
|
||||
|
||||
@ -22,6 +22,11 @@
|
||||
#include "VideoCommon/VertexLoaderManager.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
static void CheckBufferBinding()
|
||||
@ -34,7 +39,9 @@ static void CheckBufferBinding()
|
||||
}
|
||||
}
|
||||
|
||||
VertexManager::VertexManager() = default;
|
||||
VertexManager::VertexManager(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
VertexManager::~VertexManager()
|
||||
{
|
||||
@ -190,6 +197,6 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in
|
||||
|
||||
void VertexManager::UploadUniforms()
|
||||
{
|
||||
ProgramShaderCache::UploadConstants();
|
||||
ProgramShaderCache::UploadConstants(m_system);
|
||||
}
|
||||
} // namespace OGL
|
||||
|
||||
@ -11,6 +11,11 @@
|
||||
#include "VideoCommon/NativeVertexFormat.h"
|
||||
#include "VideoCommon/VertexManagerBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
class StreamBuffer;
|
||||
@ -28,7 +33,7 @@ public:
|
||||
class VertexManager final : public VertexManagerBase
|
||||
{
|
||||
public:
|
||||
VertexManager();
|
||||
VertexManager(Core::System& system);
|
||||
~VertexManager() override;
|
||||
|
||||
bool Initialize() override;
|
||||
@ -54,5 +59,6 @@ private:
|
||||
std::unique_ptr<StreamBuffer> m_index_buffer;
|
||||
std::unique_ptr<StreamBuffer> m_texel_buffer;
|
||||
std::array<GLuint, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views{};
|
||||
Core::System& m_system;
|
||||
};
|
||||
} // namespace OGL
|
||||
|
||||
@ -221,9 +221,8 @@ u32 ProgramShaderCache::GetUniformBufferAlignment()
|
||||
return s_ubo_align;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::UploadConstants()
|
||||
void ProgramShaderCache::UploadConstants(Core::System& system)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
|
||||
@ -12,6 +12,11 @@
|
||||
#include "Common/GL/GLUtil.h"
|
||||
#include "VideoCommon/AsyncShaderCompiler.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
class OGLShader;
|
||||
@ -81,7 +86,7 @@ public:
|
||||
std::string_view gcode);
|
||||
static StreamBuffer* GetUniformBuffer();
|
||||
static u32 GetUniformBufferAlignment();
|
||||
static void UploadConstants();
|
||||
static void UploadConstants(Core::System& system);
|
||||
static void UploadConstants(const void* data, u32 data_size);
|
||||
|
||||
static void Init();
|
||||
|
||||
@ -4,8 +4,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
class GLContext;
|
||||
|
||||
namespace OGL
|
||||
@ -13,8 +19,8 @@ namespace OGL
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -30,7 +30,9 @@
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
#include "VideoCommon/XFMemory.h"
|
||||
|
||||
SWVertexLoader::SWVertexLoader() = default;
|
||||
SWVertexLoader::SWVertexLoader(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
SWVertexLoader::~SWVertexLoader() = default;
|
||||
|
||||
@ -208,24 +210,21 @@ void SWVertexLoader::ParseVertex(const PortableVertexDeclaration& vdec, int inde
|
||||
}
|
||||
if (!vdec.normals[0].enable)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
m_vertex.normal[0].x = vertex_shader_manager.constants.cached_normal[0];
|
||||
m_vertex.normal[0].y = vertex_shader_manager.constants.cached_normal[1];
|
||||
m_vertex.normal[0].z = vertex_shader_manager.constants.cached_normal[2];
|
||||
}
|
||||
if (!vdec.normals[1].enable)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
m_vertex.normal[1].x = vertex_shader_manager.constants.cached_tangent[0];
|
||||
m_vertex.normal[1].y = vertex_shader_manager.constants.cached_tangent[1];
|
||||
m_vertex.normal[1].z = vertex_shader_manager.constants.cached_tangent[2];
|
||||
}
|
||||
if (!vdec.normals[2].enable)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
m_vertex.normal[2].x = vertex_shader_manager.constants.cached_binormal[0];
|
||||
m_vertex.normal[2].y = vertex_shader_manager.constants.cached_binormal[1];
|
||||
m_vertex.normal[2].z = vertex_shader_manager.constants.cached_binormal[2];
|
||||
|
||||
@ -13,10 +13,15 @@
|
||||
|
||||
#include "VideoCommon/VertexManagerBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class system;
|
||||
}
|
||||
|
||||
class SWVertexLoader final : public VertexManagerBase
|
||||
{
|
||||
public:
|
||||
SWVertexLoader();
|
||||
SWVertexLoader(Core::System& system);
|
||||
~SWVertexLoader() override;
|
||||
|
||||
DataReader PrepareForAdditionalData(OpcodeDecoder::Primitive primitive, u32 count, u32 stride,
|
||||
@ -30,4 +35,5 @@ protected:
|
||||
|
||||
InputVertexData m_vertex{};
|
||||
SetupUnit m_setup_unit;
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
||||
@ -23,6 +23,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace SW
|
||||
{
|
||||
class PerfQuery : public PerfQueryBase
|
||||
@ -90,7 +95,7 @@ void VideoSoftware::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
g_backend_info.AAModes = {1};
|
||||
}
|
||||
|
||||
bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoSoftware::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
std::unique_ptr<SWOGLWindow> window = SWOGLWindow::Create(wsi);
|
||||
if (!window)
|
||||
@ -99,14 +104,14 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
|
||||
Clipper::Init();
|
||||
Rasterizer::Init();
|
||||
|
||||
return InitializeShared(std::make_unique<SWGfx>(std::move(window)),
|
||||
std::make_unique<SWVertexLoader>(), std::make_unique<PerfQuery>(),
|
||||
return InitializeShared(system, std::make_unique<SWGfx>(std::move(window)),
|
||||
std::make_unique<SWVertexLoader>(system), std::make_unique<PerfQuery>(),
|
||||
std::make_unique<SWBoundingBox>(), std::make_unique<SWEFBInterface>(),
|
||||
std::make_unique<TextureCache>());
|
||||
}
|
||||
|
||||
void VideoSoftware::Shutdown()
|
||||
void VideoSoftware::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
}
|
||||
} // namespace SW
|
||||
|
||||
@ -4,14 +4,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace SW
|
||||
{
|
||||
class VideoSoftware : public VideoBackendBase
|
||||
{
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -23,6 +23,11 @@
|
||||
#include <objc/message.h>
|
||||
#endif
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Vulkan
|
||||
{
|
||||
void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
@ -88,7 +93,7 @@ static bool ShouldEnableDebugUtils(bool enable_validation_layers)
|
||||
return enable_validation_layers || IsHostGPULoggingEnabled();
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (!LoadVulkanLibrary())
|
||||
{
|
||||
@ -192,7 +197,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (!g_object_cache->Initialize())
|
||||
{
|
||||
PanicAlertFmt("Failed to initialize Vulkan object cache.");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -204,7 +209,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (!swap_chain)
|
||||
{
|
||||
PanicAlertFmt("Failed to create Vulkan swap chain.");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -216,27 +221,27 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (!g_command_buffer_mgr->Initialize(swapchain_image_count))
|
||||
{
|
||||
PanicAlertFmt("Failed to create Vulkan command buffers");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StateTracker::CreateInstance())
|
||||
{
|
||||
PanicAlertFmt("Failed to create state tracker");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto gfx = std::make_unique<VKGfx>(std::move(swap_chain), wsi.render_surface_scale);
|
||||
auto vertex_manager = std::make_unique<VertexManager>();
|
||||
auto vertex_manager = std::make_unique<VertexManager>(system);
|
||||
auto perf_query = std::make_unique<PerfQuery>();
|
||||
auto bounding_box = std::make_unique<VKBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
if (g_vulkan_context)
|
||||
vkDeviceWaitIdle(g_vulkan_context->GetDevice());
|
||||
@ -244,7 +249,7 @@ void VideoBackend::Shutdown()
|
||||
if (g_object_cache)
|
||||
g_object_cache->Shutdown();
|
||||
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
|
||||
g_object_cache.reset();
|
||||
StateTracker::DestroyInstance();
|
||||
|
||||
@ -53,7 +53,9 @@ static VkBufferView CreateTexelBufferView(VkBuffer buffer, VkFormat vk_format)
|
||||
return view;
|
||||
}
|
||||
|
||||
VertexManager::VertexManager() = default;
|
||||
VertexManager::VertexManager(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
VertexManager::~VertexManager()
|
||||
{
|
||||
@ -204,8 +206,7 @@ void VertexManager::UploadUniforms()
|
||||
|
||||
void VertexManager::UpdateVertexShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
|
||||
if (!vertex_shader_manager.dirty || !ReserveConstantStorage())
|
||||
return;
|
||||
@ -222,8 +223,7 @@ void VertexManager::UpdateVertexShaderConstants()
|
||||
|
||||
void VertexManager::UpdateGeometryShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
auto& geometry_shader_manager = m_system.GetGeometryShaderManager();
|
||||
|
||||
if (!geometry_shader_manager.dirty || !ReserveConstantStorage())
|
||||
return;
|
||||
@ -240,8 +240,7 @@ void VertexManager::UpdateGeometryShaderConstants()
|
||||
|
||||
void VertexManager::UpdatePixelShaderConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
|
||||
if (!ReserveConstantStorage())
|
||||
return;
|
||||
@ -275,8 +274,7 @@ void VertexManager::UpdatePixelShaderConstants()
|
||||
|
||||
bool VertexManager::ReserveConstantStorage()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
const u32 custom_constants_size = static_cast<u32>(pixel_shader_manager.custom_constants.size());
|
||||
|
||||
if (m_uniform_stream_buffer->ReserveMemory(m_uniform_buffer_reserve_size + custom_constants_size,
|
||||
@ -297,8 +295,7 @@ bool VertexManager::ReserveConstantStorage()
|
||||
|
||||
void VertexManager::UploadAllConstants()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
auto& pixel_shader_manager = m_system.GetPixelShaderManager();
|
||||
|
||||
const u32 custom_constants_size = static_cast<u32>(pixel_shader_manager.custom_constants.size());
|
||||
|
||||
@ -321,8 +318,8 @@ void VertexManager::UploadAllConstants()
|
||||
return;
|
||||
}
|
||||
|
||||
auto& vertex_shader_manager = system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = system.GetGeometryShaderManager();
|
||||
auto& vertex_shader_manager = m_system.GetVertexShaderManager();
|
||||
auto& geometry_shader_manager = m_system.GetGeometryShaderManager();
|
||||
|
||||
// Update bindings
|
||||
StateTracker::GetInstance()->SetGXUniformBuffer(
|
||||
|
||||
@ -10,6 +10,11 @@
|
||||
#include "VideoBackends/Vulkan/VulkanLoader.h"
|
||||
#include "VideoCommon/VertexManagerBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Vulkan
|
||||
{
|
||||
class StreamBuffer;
|
||||
@ -17,7 +22,7 @@ class StreamBuffer;
|
||||
class VertexManager : public VertexManagerBase
|
||||
{
|
||||
public:
|
||||
VertexManager();
|
||||
VertexManager(Core::System& system);
|
||||
~VertexManager() override;
|
||||
|
||||
bool Initialize() override;
|
||||
@ -53,5 +58,6 @@ protected:
|
||||
std::unique_ptr<StreamBuffer> m_texel_stream_buffer;
|
||||
std::array<VkBufferView, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views = {};
|
||||
u32 m_uniform_buffer_reserve_size = 0;
|
||||
Core::System& m_system;
|
||||
};
|
||||
} // namespace Vulkan
|
||||
|
||||
@ -3,16 +3,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Vulkan
|
||||
{
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override { return CONFIG_NAME; }
|
||||
std::string GetDisplayName() const override { return _trans("Vulkan"); }
|
||||
|
||||
@ -111,12 +111,13 @@ void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||
};
|
||||
for (auto& pq_reg : pq_regs)
|
||||
{
|
||||
mmio->Register(base | pq_reg.addr, MMIO::ComplexRead<u16>([pq_reg](Core::System&, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(pq_reg.pqtype) & 0xFFFF;
|
||||
mmio->Register(base | pq_reg.addr, MMIO::ComplexRead<u16>([pq_reg](Core::System& system, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(system, pq_reg.pqtype) & 0xFFFF;
|
||||
}),
|
||||
MMIO::InvalidWrite<u16>());
|
||||
mmio->Register(base | (pq_reg.addr + 2), MMIO::ComplexRead<u16>([pq_reg](Core::System&, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(pq_reg.pqtype) >> 16;
|
||||
mmio->Register(base | (pq_reg.addr + 2),
|
||||
MMIO::ComplexRead<u16>([pq_reg](Core::System& system, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(system, pq_reg.pqtype) >> 16;
|
||||
}),
|
||||
MMIO::InvalidWrite<u16>());
|
||||
}
|
||||
@ -152,7 +153,7 @@ void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||
mmio->Register(base | (PE_BBOX_LEFT + 2 * i),
|
||||
MMIO::ComplexRead<u16>([i](Core::System& system, u32) {
|
||||
g_bounding_box->Disable(system.GetPixelShaderManager());
|
||||
return g_video_backend->Video_GetBoundingBox(i);
|
||||
return g_video_backend->Video_GetBoundingBox(system, i);
|
||||
}),
|
||||
MMIO::InvalidWrite<u16>());
|
||||
}
|
||||
|
||||
@ -92,8 +92,8 @@ std::string VideoBackendBase::BadShaderFilename(const char* shader_stage, int co
|
||||
}
|
||||
|
||||
// Run from the CPU thread (from VideoInterface.cpp)
|
||||
void VideoBackendBase::Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
|
||||
u64 ticks)
|
||||
void VideoBackendBase::Video_OutputXFB(Core::System& system, u32 xfb_addr, u32 fb_width,
|
||||
u32 fb_stride, u32 fb_height, u64 ticks)
|
||||
{
|
||||
if (!m_initialized || !g_presenter)
|
||||
return;
|
||||
@ -126,14 +126,13 @@ void VideoBackendBase::Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride
|
||||
});
|
||||
}
|
||||
|
||||
u32 VideoBackendBase::Video_GetQueryResult(PerfQueryType type)
|
||||
u32 VideoBackendBase::Video_GetQueryResult(Core::System& system, PerfQueryType type)
|
||||
{
|
||||
if (!g_perf_query->ShouldEmulate())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().SyncGPU(Fifo::SyncGPUReason::PerfQuery);
|
||||
|
||||
if (!g_perf_query->IsFlushed())
|
||||
@ -144,7 +143,7 @@ u32 VideoBackendBase::Video_GetQueryResult(PerfQueryType type)
|
||||
return g_perf_query->GetQueryResult(type);
|
||||
}
|
||||
|
||||
u16 VideoBackendBase::Video_GetBoundingBox(int index)
|
||||
u16 VideoBackendBase::Video_GetBoundingBox(Core::System& system, int index)
|
||||
{
|
||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::ReadsBoundingBox);
|
||||
|
||||
@ -172,7 +171,6 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index)
|
||||
warn_once = false;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().SyncGPU(Fifo::SyncGPUReason::BBox);
|
||||
|
||||
return AsyncRequests::GetInstance()->PushBlockingEvent(
|
||||
@ -270,23 +268,22 @@ void VideoBackendBase::PopulateBackendInfo(const WindowSystemInfo& wsi)
|
||||
g_Config.VerifyValidity();
|
||||
}
|
||||
|
||||
void VideoBackendBase::DoState(PointerWrap& p)
|
||||
void VideoBackendBase::DoState(Core::System& system, PointerWrap& p)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (!system.IsDualCoreMode())
|
||||
{
|
||||
VideoCommon_DoState(p);
|
||||
VideoCommon_DoState(system, p);
|
||||
return;
|
||||
}
|
||||
|
||||
AsyncRequests::GetInstance()->PushBlockingEvent([&] { VideoCommon_DoState(p); });
|
||||
AsyncRequests::GetInstance()->PushBlockingEvent([&] { VideoCommon_DoState(system, p); });
|
||||
|
||||
// Let the GPU thread sleep after loading the state, so we're not spinning if paused after loading
|
||||
// a state. The next GP burst will wake it up again.
|
||||
system.GetFifo().GpuMaySleep();
|
||||
}
|
||||
|
||||
bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool VideoBackendBase::InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box)
|
||||
@ -294,12 +291,12 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
// All hardware backends use the default EFBInterface and TextureCacheBase.
|
||||
// Only Null and Software backends override them
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box), std::make_unique<HardwareEFBInterface>(),
|
||||
std::make_unique<TextureCacheBase>());
|
||||
}
|
||||
|
||||
bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool VideoBackendBase::InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box,
|
||||
@ -337,11 +334,10 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
!g_graphics_mod_manager->Initialize())
|
||||
{
|
||||
PanicAlertFmtT("Failed to initialize renderer classes");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& command_processor = system.GetCommandProcessor();
|
||||
command_processor.Init();
|
||||
system.GetFifo().Init();
|
||||
@ -369,9 +365,8 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
return true;
|
||||
}
|
||||
|
||||
void VideoBackendBase::ShutdownShared()
|
||||
void VideoBackendBase::ShutdownShared(Core::System& system)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetCustomResourceManager().Shutdown();
|
||||
|
||||
g_frame_dumper.reset();
|
||||
|
||||
@ -12,6 +12,11 @@
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
#include "VideoCommon/PerfQueryBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace MMIO
|
||||
{
|
||||
class Mapping;
|
||||
@ -34,8 +39,8 @@ class VideoBackendBase
|
||||
{
|
||||
public:
|
||||
virtual ~VideoBackendBase() {}
|
||||
virtual bool Initialize(const WindowSystemInfo& wsi) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual bool Initialize(Core::System& system, const WindowSystemInfo& wsi) = 0;
|
||||
virtual void Shutdown(Core::System& system) = 0;
|
||||
|
||||
virtual std::string GetConfigName() const = 0;
|
||||
virtual std::string GetDisplayName() const { return GetConfigName(); }
|
||||
@ -48,10 +53,11 @@ public:
|
||||
|
||||
static std::string BadShaderFilename(const char* shader_stage, int counter);
|
||||
|
||||
void Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks);
|
||||
void Video_OutputXFB(Core::System& system, u32 xfb_addr, u32 fb_width, u32 fb_stride,
|
||||
u32 fb_height, u64 ticks);
|
||||
|
||||
u32 Video_GetQueryResult(PerfQueryType type);
|
||||
u16 Video_GetBoundingBox(int index);
|
||||
u32 Video_GetQueryResult(Core::System& system, PerfQueryType type);
|
||||
u16 Video_GetBoundingBox(Core::System& system, int index);
|
||||
|
||||
static std::string GetDefaultBackendConfigName();
|
||||
static std::string GetDefaultBackendDisplayName();
|
||||
@ -62,23 +68,23 @@ public:
|
||||
static void PopulateBackendInfo(const WindowSystemInfo& wsi);
|
||||
|
||||
// Wrapper function which pushes the event to the GPU thread.
|
||||
void DoState(PointerWrap& p);
|
||||
void DoState(Core::System& system, PointerWrap& p);
|
||||
|
||||
protected:
|
||||
// For hardware backends
|
||||
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box);
|
||||
|
||||
// For software and null backends. Allows overriding the default EFBInterface and TextureCache
|
||||
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box,
|
||||
std::unique_ptr<EFBInterfaceBase> efb_interface,
|
||||
std::unique_ptr<TextureCacheBase> texture_cache);
|
||||
void ShutdownShared();
|
||||
void ShutdownShared(Core::System& system);
|
||||
|
||||
bool m_initialized = false;
|
||||
};
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include "VideoCommon/XFMemory.h"
|
||||
#include "VideoCommon/XFStateManager.h"
|
||||
|
||||
void VideoCommon_DoState(PointerWrap& p)
|
||||
void VideoCommon_DoState(Core::System& system, PointerWrap& p)
|
||||
{
|
||||
bool software = false;
|
||||
p.Do(software);
|
||||
@ -65,7 +65,6 @@ void VideoCommon_DoState(PointerWrap& p)
|
||||
p.DoMarker("TMEM");
|
||||
|
||||
// FIFO
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().DoState(p);
|
||||
p.DoMarker("Fifo");
|
||||
|
||||
|
||||
@ -3,6 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
void VideoCommon_DoState(PointerWrap& p);
|
||||
void VideoCommon_DoState(Core::System& system, PointerWrap& p);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user