Merge pull request #11522 from phire/KillRendererWithFire

Kill Renderer (with phire)
This commit is contained in:
Scott Mansell
2023-02-09 19:59:16 +13:00
committed by GitHub
144 changed files with 5584 additions and 4840 deletions
+6 -6
View File
@@ -59,7 +59,7 @@
#include "UICommon/UICommon.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoBackendBase.h"
#include "jni/AndroidCommon/AndroidCommon.h"
@@ -456,8 +456,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChang
if (s_surf == nullptr)
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "Error: Surface is null.");
if (g_renderer)
g_renderer->ChangeSurface(s_surf);
if (g_presenter)
g_presenter->ChangeSurface(s_surf);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv*,
@@ -483,8 +483,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestr
std::lock_guard surface_guard(s_surface_lock);
if (g_renderer)
g_renderer->ChangeSurface(nullptr);
if (g_presenter)
g_presenter->ChangeSurface(nullptr);
if (s_surf)
{
@@ -503,7 +503,7 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_HasSurfa
JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetGameAspectRatio(JNIEnv*,
jclass)
{
return g_renderer->CalculateDrawAspectRatio();
return g_presenter->CalculateDrawAspectRatio();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimotes(JNIEnv*, jclass)
+2
View File
@@ -62,6 +62,7 @@ add_library(common
GekkoDisassembler.h
Hash.cpp
Hash.h
HookableEvent.h
HttpRequest.cpp
HttpRequest.h
Image.cpp
@@ -115,6 +116,7 @@ add_library(common
SocketContext.cpp
SocketContext.h
SPSCQueue.h
StringLiteral.h
StringUtil.cpp
StringUtil.h
SymbolDB.cpp
+102
View File
@@ -0,0 +1,102 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "Common/Logging/Log.h"
#include "Common/StringLiteral.h"
#include <functional>
#include <memory>
#include <mutex>
#include <string>
#include <string_view>
#include <vector>
namespace Common
{
struct HookBase
{
virtual ~HookBase() = default;
protected:
HookBase() = default;
// This shouldn't be copied. And since we always wrap it in unique_ptr, no need to move it either
HookBase(const HookBase&) = delete;
HookBase(HookBase&&) = delete;
HookBase& operator=(const HookBase&) = delete;
HookBase& operator=(HookBase&&) = delete;
};
// EventHook is a handle a registered listener holds.
// When the handle is destroyed, the HookableEvent will automatically remove the listener.
using EventHook = std::unique_ptr<HookBase>;
// A hookable event system.
//
// Define Events in a header as:
//
// using MyLoveyEvent = HookableEvent<"My lovely event", std::string, u32>;
//
// Register listeners anywhere you need them as:
// EventHook myHook = MyLoveyEvent::Register([](std::string foo, u32 bar) {
// fmt::print("I've been triggered with {} and {}", foo, bar)
// }, "NameOfHook");
//
// The hook will be automatically unregistered when the EventHook object goes out of scope.
// Trigger events by calling Trigger as:
//
// MyLoveyEvent::Trigger("Hello world", 42);
//
template <StringLiteral EventName, typename... CallbackArgs>
class HookableEvent
{
public:
using CallbackType = std::function<void(CallbackArgs...)>;
private:
struct HookImpl final : public HookBase
{
~HookImpl() override { HookableEvent::Remove(this); }
HookImpl(CallbackType callback, std::string name)
: m_fn(std::move(callback)), m_name(std::move(name))
{
}
CallbackType m_fn;
std::string m_name;
};
public:
// Returns a handle that will unregister the listener when destroyed.
static EventHook Register(CallbackType callback, std::string name)
{
std::lock_guard lock(m_mutex);
DEBUG_LOG_FMT(COMMON, "Registering {} handler at {} event hook", name, EventName.value);
auto handle = std::make_unique<HookImpl>(callback, std::move(name));
m_listeners.push_back(handle.get());
return handle;
}
static void Trigger(const CallbackArgs&... args)
{
std::lock_guard lock(m_mutex);
for (const auto& handle : m_listeners)
handle->m_fn(args...);
}
private:
static void Remove(HookImpl* handle)
{
std::lock_guard lock(m_mutex);
std::erase(m_listeners, handle);
}
inline static std::vector<HookImpl*> m_listeners = {};
inline static std::mutex m_mutex;
};
} // namespace Common
+20
View File
@@ -0,0 +1,20 @@
// Copyright 2023 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <algorithm>
namespace Common
{
// A useful template for passing string literals as arguments to templates
// from: https://ctrpeach.io/posts/cpp20-string-literal-template-parameters/
template <size_t N>
struct StringLiteral
{
consteval StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); }
char value[N];
};
} // namespace Common
+14 -8
View File
@@ -84,11 +84,13 @@
#include "VideoCommon/AsyncRequests.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/FrameDumper.h"
#include "VideoCommon/HiresTextures.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/PerformanceMetrics.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoEvents.h"
#ifdef ANDROID
#include "jni/AndroidCommon/IDCache.h"
@@ -130,6 +132,15 @@ static thread_local bool tls_is_gpu_thread = false;
static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi);
static Common::EventHook s_frame_presented = AfterPresentEvent::Register(
[](auto& present_info) {
const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator();
// The denominator should always be > 0 but if it's not, just return 1
const double last_speed = last_speed_denominator > 0.0 ? (1.0 / last_speed_denominator) : 1.0;
Core::Callback_FramePresented(last_speed);
},
"Core Frame Presented");
bool GetIsThrottlerTempDisabled()
{
return s_is_throttler_temp_disabled;
@@ -538,11 +549,6 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
}
Common::ScopeGuard video_guard{[] { g_video_backend->Shutdown(); }};
// Render a single frame without anything on it to clear the screen.
// This avoids the game list being displayed while the core is finishing initializing.
g_renderer->BeginUIFrame();
g_renderer->EndUIFrame();
if (cpu_info.HTT)
Config::SetBaseOrCurrent(Config::MAIN_DSP_THREAD, cpu_info.num_cores > 4);
else
@@ -731,13 +737,13 @@ static std::string GenerateScreenshotName()
void SaveScreenShot()
{
Core::RunAsCPUThread([] { g_renderer->SaveScreenshot(GenerateScreenshotName()); });
Core::RunAsCPUThread([] { g_frame_dumper->SaveScreenshot(GenerateScreenshotName()); });
}
void SaveScreenShot(std::string_view name)
{
Core::RunAsCPUThread([&name] {
g_renderer->SaveScreenshot(fmt::format("{}{}.png", GenerateScreenshotFolderPath(), name));
g_frame_dumper->SaveScreenshot(fmt::format("{}{}.png", GenerateScreenshotFolderPath(), name));
});
}
+46 -2
View File
@@ -14,7 +14,12 @@
#include "Core/HW/Memmap.h"
#include "Core/System.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/TextureDecoder.h"
#include "VideoCommon/VideoEvents.h"
#include "VideoCommon/XFMemory.h"
#include "VideoCommon/XFStructs.h"
class FifoRecorder::FifoRecordAnalyzer : public OpcodeDecoder::Callback
@@ -249,6 +254,42 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
m_RequestedRecordingEnd = false;
m_FinishedCb = finishedCb;
m_end_of_frame_event = AfterFrameEvent::Register(
[this] {
const bool was_recording = OpcodeDecoder::g_record_fifo_data;
OpcodeDecoder::g_record_fifo_data = IsRecording();
if (!OpcodeDecoder::g_record_fifo_data)
return;
if (!was_recording)
{
RecordInitialVideoMemory();
}
auto& system = Core::System::GetInstance();
auto& command_processor = system.GetCommandProcessor();
const auto& fifo = command_processor.GetFifo();
EndFrame(fifo.CPBase.load(std::memory_order_relaxed),
fifo.CPEnd.load(std::memory_order_relaxed));
},
"FifoRecorder::EndFrame");
}
void FifoRecorder::RecordInitialVideoMemory()
{
const u32* bpmem_ptr = reinterpret_cast<const u32*>(&bpmem);
u32 cpmem[256] = {};
// The FIFO recording format splits XF memory into xfmem and xfregs; follow
// that split here.
const u32* xfmem_ptr = reinterpret_cast<const u32*>(&xfmem);
const u32* xfregs_ptr = reinterpret_cast<const u32*>(&xfmem) + FifoDataFile::XF_MEM_SIZE;
u32 xfregs_size = sizeof(XFMemory) / 4 - FifoDataFile::XF_MEM_SIZE;
g_main_cp_state.FillCPMemoryArray(cpmem);
SetVideoMemory(bpmem_ptr, cpmem, xfmem_ptr, xfregs_ptr, xfregs_size, texMem);
}
void FifoRecorder::StopRecording()
@@ -391,11 +432,14 @@ void FifoRecorder::EndFrame(u32 fifoStart, u32 fifoEnd)
m_SkipFutureData = true;
// Signal video backend that it should not call this function when the next frame ends
m_IsRecording = false;
// Remove our frame end callback
m_end_of_frame_event.reset();
}
}
void FifoRecorder::SetVideoMemory(const u32* bpMem, const u32* cpMem, const u32* xfMem,
const u32* xfRegs, u32 xfRegsSize, const u8* texMem)
const u32* xfRegs, u32 xfRegsSize, const u8* texMem_ptr)
{
std::lock_guard lk(m_mutex);
@@ -408,7 +452,7 @@ void FifoRecorder::SetVideoMemory(const u32* bpMem, const u32* cpMem, const u32*
u32 xfRegsCopySize = std::min((u32)FifoDataFile::XF_REGS_SIZE, xfRegsSize);
memcpy(m_File->GetXFRegs(), xfRegs, xfRegsCopySize * 4);
memcpy(m_File->GetTexMem(), texMem, FifoDataFile::TEX_MEM_SIZE);
memcpy(m_File->GetTexMem(), texMem_ptr, FifoDataFile::TEX_MEM_SIZE);
}
m_record_analyzer = std::make_unique<FifoRecordAnalyzer>(this, cpMem);
@@ -9,6 +9,7 @@
#include <vector>
#include "Common/Assert.h"
#include "Common/HookableEvent.h"
#include "Core/FifoPlayer/FifoDataFile.h"
class FifoRecorder
@@ -50,6 +51,8 @@ public:
private:
class FifoRecordAnalyzer;
void RecordInitialVideoMemory();
// Accessed from both GUI and video threads
std::recursive_mutex m_mutex;
@@ -72,4 +75,6 @@ private:
std::vector<u8> m_FifoData;
std::vector<u8> m_Ram;
std::vector<u8> m_ExRam;
Common::EventHook m_end_of_frame_event;
};
+2 -2
View File
@@ -42,7 +42,7 @@
#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "VideoCommon/FrameDump.h"
#include "VideoCommon/FrameDumpFFMpeg.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoBackendBase.h"
@@ -96,7 +96,7 @@ static size_t s_state_writes_in_queue;
static std::condition_variable s_state_write_queue_is_empty;
// Don't forget to increase this after doing changes on the savestate system
constexpr u32 STATE_VERSION = 157; // Last changed in PR 11183
constexpr u32 STATE_VERSION = 158; // Last changed in PR 11522
// Maps savestate versions to Dolphin versions.
// Versions after 42 don't need to be added to this list,
+30 -12
View File
@@ -109,6 +109,7 @@
<ClInclude Include="Common\GL\GLUtil.h" />
<ClInclude Include="Common\GL\GLX11Window.h" />
<ClInclude Include="Common\Hash.h" />
<ClInclude Include="Common\HookableEvent.h" />
<ClInclude Include="Common\HRWrap.h" />
<ClInclude Include="Common\HttpRequest.h" />
<ClInclude Include="Common\Image.h" />
@@ -145,6 +146,7 @@
<ClInclude Include="Common\SFMLHelper.h" />
<ClInclude Include="Common\SocketContext.h" />
<ClInclude Include="Common\SPSCQueue.h" />
<ClInclude Include="Common\StringLiteral.h" />
<ClInclude Include="Common\StringUtil.h" />
<ClInclude Include="Common\Swap.h" />
<ClInclude Include="Common\SymbolDB.h" />
@@ -534,7 +536,7 @@
<ClInclude Include="VideoBackends\D3D\D3DBase.h" />
<ClInclude Include="VideoBackends\D3D\D3DBoundingBox.h" />
<ClInclude Include="VideoBackends\D3D\D3DPerfQuery.h" />
<ClInclude Include="VideoBackends\D3D\D3DRender.h" />
<ClInclude Include="VideoBackends\D3D\D3DGfx.h" />
<ClInclude Include="VideoBackends\D3D\D3DState.h" />
<ClInclude Include="VideoBackends\D3D\D3DSwapChain.h" />
<ClInclude Include="VideoBackends\D3D\D3DVertexManager.h" />
@@ -545,7 +547,7 @@
<ClInclude Include="VideoBackends\D3D12\Common.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12BoundingBox.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12PerfQuery.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12Renderer.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12Gfx.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12StreamBuffer.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12SwapChain.h" />
<ClInclude Include="VideoBackends\D3D12\D3D12VertexManager.h" />
@@ -561,7 +563,7 @@
<ClInclude Include="VideoBackends\D3DCommon\Shader.h" />
<ClInclude Include="VideoBackends\D3DCommon\SwapChain.h" />
<ClInclude Include="VideoBackends\Null\NullBoundingBox.h" />
<ClInclude Include="VideoBackends\Null\NullRender.h" />
<ClInclude Include="VideoBackends\Null\NullGfx.h" />
<ClInclude Include="VideoBackends\Null\NullTexture.h" />
<ClInclude Include="VideoBackends\Null\NullVertexManager.h" />
<ClInclude Include="VideoBackends\Null\PerfQuery.h" />
@@ -569,9 +571,10 @@
<ClInclude Include="VideoBackends\Null\VideoBackend.h" />
<ClInclude Include="VideoBackends\OGL\GPUTimer.h" />
<ClInclude Include="VideoBackends\OGL\OGLBoundingBox.h" />
<ClInclude Include="VideoBackends\OGL\OGLConfig.h" />
<ClInclude Include="VideoBackends\OGL\OGLGfx.h" />
<ClInclude Include="VideoBackends\OGL\OGLPerfQuery.h" />
<ClInclude Include="VideoBackends\OGL\OGLPipeline.h" />
<ClInclude Include="VideoBackends\OGL\OGLRender.h" />
<ClInclude Include="VideoBackends\OGL\OGLShader.h" />
<ClInclude Include="VideoBackends\OGL\OGLStreamBuffer.h" />
<ClInclude Include="VideoBackends\OGL\OGLTexture.h" />
@@ -587,6 +590,7 @@
<ClInclude Include="VideoBackends\Software\Rasterizer.h" />
<ClInclude Include="VideoBackends\Software\SetupUnit.h" />
<ClInclude Include="VideoBackends\Software\SWBoundingBox.h" />
<ClInclude Include="VideoBackends\Software\SWGfx.h" />
<ClInclude Include="VideoBackends\Software\SWOGLWindow.h" />
<ClInclude Include="VideoBackends\Software\SWRenderer.h" />
<ClInclude Include="VideoBackends\Software\SWTexture.h" />
@@ -608,7 +612,7 @@
<ClInclude Include="VideoBackends\Vulkan\VKBoundingBox.h" />
<ClInclude Include="VideoBackends\Vulkan\VKPerfQuery.h" />
<ClInclude Include="VideoBackends\Vulkan\VKPipeline.h" />
<ClInclude Include="VideoBackends\Vulkan\VKRenderer.h" />
<ClInclude Include="VideoBackends\Vulkan\VKGfx.h" />
<ClInclude Include="VideoBackends\Vulkan\VKShader.h" />
<ClInclude Include="VideoBackends\Vulkan\VKStreamBuffer.h" />
<ClInclude Include="VideoBackends\Vulkan\VKSwapChain.h" />
@@ -618,6 +622,7 @@
<ClInclude Include="VideoBackends\Vulkan\VulkanContext.h" />
<ClInclude Include="VideoBackends\Vulkan\VulkanLoader.h" />
<ClInclude Include="VideoCommon\AbstractFramebuffer.h" />
<ClInclude Include="VideoCommon\AbstractGfx.h" />
<ClInclude Include="VideoCommon\AbstractPipeline.h" />
<ClInclude Include="VideoCommon\AbstractShader.h" />
<ClInclude Include="VideoCommon\AbstractStagingTexture.h" />
@@ -638,7 +643,8 @@
<ClInclude Include="VideoCommon\Fifo.h" />
<ClInclude Include="VideoCommon\FramebufferManager.h" />
<ClInclude Include="VideoCommon\FramebufferShaderGen.h" />
<ClInclude Include="VideoCommon\FrameDump.h" />
<ClInclude Include="VideoCommon\FrameDumpFFMpeg.h" />
<ClInclude Include="VideoCommon\FrameDumper.h" />
<ClInclude Include="VideoCommon\FreeLookCamera.h" />
<ClInclude Include="VideoCommon\GeometryShaderGen.h" />
<ClInclude Include="VideoCommon\GeometryShaderManager.h" />
@@ -668,6 +674,8 @@
<ClInclude Include="VideoCommon\NetPlayChatUI.h" />
<ClInclude Include="VideoCommon\NetPlayGolfUI.h" />
<ClInclude Include="VideoCommon\OnScreenDisplay.h" />
<ClInclude Include="VideoCommon\OnScreenUI.h" />
<ClInclude Include="VideoCommon\OnScreenUIKeyMap.h" />
<ClInclude Include="VideoCommon\OpcodeDecoding.h" />
<ClInclude Include="VideoCommon\PerfQueryBase.h" />
<ClInclude Include="VideoCommon\PerformanceMetrics.h" />
@@ -676,6 +684,7 @@
<ClInclude Include="VideoCommon\PixelShaderGen.h" />
<ClInclude Include="VideoCommon\PixelShaderManager.h" />
<ClInclude Include="VideoCommon\PostProcessing.h" />
<ClInclude Include="VideoCommon\Present.h" />
<ClInclude Include="VideoCommon\RenderBase.h" />
<ClInclude Include="VideoCommon\RenderState.h" />
<ClInclude Include="VideoCommon\ShaderCache.h" />
@@ -707,7 +716,9 @@
<ClInclude Include="VideoCommon\VideoBackendBase.h" />
<ClInclude Include="VideoCommon\VideoCommon.h" />
<ClInclude Include="VideoCommon\VideoConfig.h" />
<ClInclude Include="VideoCommon\VideoEvents.h" />
<ClInclude Include="VideoCommon\VideoState.h" />
<ClInclude Include="VideoCommon\Widescreen.h" />
<ClInclude Include="VideoCommon\XFMemory.h" />
<ClInclude Include="VideoCommon\XFStructs.h" />
</ItemGroup>
@@ -1142,7 +1153,7 @@
<ClCompile Include="VideoBackends\D3D\D3DMain.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DNativeVertexFormat.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DPerfQuery.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DRender.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DGfx.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DState.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DSwapChain.cpp" />
<ClCompile Include="VideoBackends\D3D\D3DVertexManager.cpp" />
@@ -1151,7 +1162,7 @@
<ClCompile Include="VideoBackends\D3D\DXTexture.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12BoundingBox.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12PerfQuery.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12Renderer.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12Gfx.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12StreamBuffer.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12SwapChain.cpp" />
<ClCompile Include="VideoBackends\D3D12\D3D12VertexManager.cpp" />
@@ -1167,15 +1178,16 @@
<ClCompile Include="VideoBackends\D3DCommon\Shader.cpp" />
<ClCompile Include="VideoBackends\D3DCommon\SwapChain.cpp" />
<ClCompile Include="VideoBackends\Null\NullBackend.cpp" />
<ClCompile Include="VideoBackends\Null\NullRender.cpp" />
<ClCompile Include="VideoBackends\Null\NullGfx.cpp" />
<ClCompile Include="VideoBackends\Null\NullTexture.cpp" />
<ClCompile Include="VideoBackends\Null\NullVertexManager.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLBoundingBox.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLConfig.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLGfx.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLMain.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLNativeVertexFormat.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLPerfQuery.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLPipeline.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLRender.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLShader.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLStreamBuffer.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLTexture.cpp" />
@@ -1189,6 +1201,7 @@
<ClCompile Include="VideoBackends\Software\SetupUnit.cpp" />
<ClCompile Include="VideoBackends\Software\SWmain.cpp" />
<ClCompile Include="VideoBackends\Software\SWBoundingBox.cpp" />
<ClCompile Include="VideoBackends\Software\SWGfx.cpp" />
<ClCompile Include="VideoBackends\Software\SWOGLWindow.cpp" />
<ClCompile Include="VideoBackends\Software\SWRenderer.cpp" />
<ClCompile Include="VideoBackends\Software\SWTexture.cpp" />
@@ -1206,7 +1219,7 @@
<ClCompile Include="VideoBackends\Vulkan\VKMain.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKPerfQuery.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKPipeline.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKRenderer.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKGfx.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKShader.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKStreamBuffer.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VKSwapChain.cpp" />
@@ -1216,6 +1229,7 @@
<ClCompile Include="VideoBackends\Vulkan\VulkanContext.cpp" />
<ClCompile Include="VideoBackends\Vulkan\VulkanLoader.cpp" />
<ClCompile Include="VideoCommon\AbstractFramebuffer.cpp" />
<ClCompile Include="VideoCommon\AbstractGfx.cpp" />
<ClCompile Include="VideoCommon\AbstractStagingTexture.cpp" />
<ClCompile Include="VideoCommon\AbstractTexture.cpp" />
<ClCompile Include="VideoCommon\AsyncRequests.cpp" />
@@ -1231,7 +1245,8 @@
<ClCompile Include="VideoCommon\Fifo.cpp" />
<ClCompile Include="VideoCommon\FramebufferManager.cpp" />
<ClCompile Include="VideoCommon\FramebufferShaderGen.cpp" />
<ClCompile Include="VideoCommon\FrameDump.cpp" />
<ClCompile Include="VideoCommon\FrameDumpFFMpeg.cpp" />
<ClCompile Include="VideoCommon\FrameDumper.cpp" />
<ClCompile Include="VideoCommon\FreeLookCamera.cpp" />
<ClCompile Include="VideoCommon\GeometryShaderGen.cpp" />
<ClCompile Include="VideoCommon\GeometryShaderManager.cpp" />
@@ -1254,6 +1269,7 @@
<ClCompile Include="VideoCommon\NetPlayChatUI.cpp" />
<ClCompile Include="VideoCommon\NetPlayGolfUI.cpp" />
<ClCompile Include="VideoCommon\OnScreenDisplay.cpp" />
<ClCompile Include="VideoCommon\OnScreenUI.cpp" />
<ClCompile Include="VideoCommon\OpcodeDecoding.cpp" />
<ClCompile Include="VideoCommon\PerfQueryBase.cpp" />
<ClCompile Include="VideoCommon\PerformanceMetrics.cpp" />
@@ -1262,6 +1278,7 @@
<ClCompile Include="VideoCommon\PixelShaderGen.cpp" />
<ClCompile Include="VideoCommon\PixelShaderManager.cpp" />
<ClCompile Include="VideoCommon\PostProcessing.cpp" />
<ClCompile Include="VideoCommon\Present.cpp" />
<ClCompile Include="VideoCommon\RenderBase.cpp" />
<ClCompile Include="VideoCommon\RenderState.cpp" />
<ClCompile Include="VideoCommon\ShaderCache.cpp" />
@@ -1291,6 +1308,7 @@
<ClCompile Include="VideoCommon\VideoBackendBase.cpp" />
<ClCompile Include="VideoCommon\VideoConfig.cpp" />
<ClCompile Include="VideoCommon\VideoState.cpp" />
<ClCompile Include="VideoCommon\Widescreen.cpp" />
<ClCompile Include="VideoCommon\XFMemory.cpp" />
<ClCompile Include="VideoCommon\XFStructs.cpp" />
</ItemGroup>
-1
View File
@@ -33,7 +33,6 @@
#include "InputCommon/GCAdapter.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoBackendBase.h"
static std::unique_ptr<Platform> s_platform;
+1 -1
View File
@@ -12,6 +12,7 @@
#include <climits>
#include <cstdio>
#include <thread>
#include <fcntl.h>
#include <linux/fb.h>
@@ -21,7 +22,6 @@
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include "VideoCommon/RenderBase.h"
namespace
{
+3 -3
View File
@@ -13,7 +13,7 @@
#include <climits>
#include <cstdio>
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "resource.h"
namespace
@@ -181,8 +181,8 @@ LRESULT PlatformWin32::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
case WM_SIZE:
{
if (g_renderer)
g_renderer->ResizeSurface();
if (g_presenter)
g_presenter->ResizeSurface();
}
break;
+4 -3
View File
@@ -19,13 +19,14 @@ static constexpr auto X_None = None;
#include <climits>
#include <cstdio>
#include <cstring>
#include <thread>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include "UICommon/X11Utils.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
@@ -263,8 +264,8 @@ void PlatformX11::ProcessEvents()
break;
case ConfigureNotify:
{
if (g_renderer)
g_renderer->ResizeSurface();
if (g_presenter)
g_presenter->ResizeSurface();
}
break;
}
@@ -21,7 +21,7 @@
#include "DolphinQt/Config/Graphics/EnhancementsWidget.h"
#include "VideoCommon/PostProcessing.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoConfig.h"
using ConfigurationOption = VideoCommon::PostProcessingConfiguration::ConfigurationOption;
@@ -31,9 +31,9 @@ PostProcessingConfigWindow::PostProcessingConfigWindow(EnhancementsWidget* paren
const std::string& shader)
: QDialog(parent), m_shader(shader)
{
if (g_renderer && g_renderer->GetPostProcessor())
if (g_presenter && g_presenter->GetPostProcessor())
{
m_post_processor = g_renderer->GetPostProcessor()->GetConfig();
m_post_processor = g_presenter->GetPostProcessor()->GetConfig();
}
else
{
@@ -52,7 +52,7 @@ PostProcessingConfigWindow::PostProcessingConfigWindow(EnhancementsWidget* paren
PostProcessingConfigWindow::~PostProcessingConfigWindow()
{
m_post_processor->SaveOptionsConfiguration();
if (!(g_renderer && g_renderer->GetPostProcessor()))
if (!(g_presenter && g_presenter->GetPostProcessor()))
{
delete m_post_processor;
}
+10 -10
View File
@@ -36,8 +36,9 @@
#include "UICommon/DiscordPresence.h"
#include "VideoCommon/AbstractGfx.h"
#include "VideoCommon/Fifo.cpp"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoConfig.h"
static thread_local bool tls_is_host_thread = false;
@@ -76,9 +77,9 @@ void Host::SetRenderHandle(void* handle)
return;
m_render_handle = handle;
if (g_renderer)
if (g_presenter)
{
g_renderer->ChangeSurface(handle);
g_presenter->ChangeSurface(handle);
g_controller_interface.ChangeWindow(handle);
}
}
@@ -149,11 +150,11 @@ bool Host::GetRenderFullFocus()
void Host::SetRenderFocus(bool focus)
{
m_render_focus = focus;
if (g_renderer && m_render_fullscreen && g_ActiveConfig.ExclusiveFullscreenEnabled())
if (g_gfx && m_render_fullscreen && g_ActiveConfig.ExclusiveFullscreenEnabled())
{
RunWithGPUThreadInactive([focus] {
if (!Config::Get(Config::MAIN_RENDER_TO_MAIN))
g_renderer->SetFullscreen(focus);
g_gfx->SetFullscreen(focus);
});
}
}
@@ -181,17 +182,16 @@ void Host::SetRenderFullscreen(bool fullscreen)
{
m_render_fullscreen = fullscreen;
if (g_renderer && g_renderer->IsFullscreen() != fullscreen &&
g_ActiveConfig.ExclusiveFullscreenEnabled())
if (g_gfx && g_gfx->IsFullscreen() != fullscreen && g_ActiveConfig.ExclusiveFullscreenEnabled())
{
RunWithGPUThreadInactive([fullscreen] { g_renderer->SetFullscreen(fullscreen); });
RunWithGPUThreadInactive([fullscreen] { g_gfx->SetFullscreen(fullscreen); });
}
}
void Host::ResizeSurface(int new_width, int new_height)
{
if (g_renderer)
g_renderer->ResizeSurface();
if (g_presenter)
g_presenter->ResizeSurface();
}
std::vector<std::string> Host_GetPreferredLocales()
@@ -43,7 +43,6 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoConfig.h"
+2 -2
View File
@@ -1383,7 +1383,7 @@ void MainWindow::SetStateSlot(int slot)
void MainWindow::IncrementSelectedStateSlot()
{
int state_slot = m_state_slot + 1;
u32 state_slot = m_state_slot + 1;
if (state_slot > State::NUM_STATES)
state_slot = 1;
m_menu_bar->SetStateSlot(state_slot);
@@ -1391,7 +1391,7 @@ void MainWindow::IncrementSelectedStateSlot()
void MainWindow::DecrementSelectedStateSlot()
{
int state_slot = m_state_slot - 1;
u32 state_slot = m_state_slot - 1;
if (state_slot < 1)
state_slot = State::NUM_STATES;
m_menu_bar->SetStateSlot(state_slot);
+1 -1
View File
@@ -217,7 +217,7 @@ private:
bool m_exit_requested = false;
bool m_fullscreen_requested = false;
bool m_is_screensaver_inhibited = false;
int m_state_slot = 1;
u32 m_state_slot = 1;
std::unique_ptr<BootParameters> m_pending_boot;
ControllersWindow* m_controllers_window = nullptr;
@@ -61,7 +61,6 @@
#include "VideoCommon/NetPlayChatUI.h"
#include "VideoCommon/NetPlayGolfUI.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoConfig.h"
namespace
+28 -47
View File
@@ -19,8 +19,6 @@
#include <QTimer>
#include <QWindow>
#include <imgui.h>
#include "Core/Config/MainSettings.h"
#include "Core/Core.h"
#include "Core/State.h"
@@ -32,7 +30,8 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/OnScreenUI.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/VideoConfig.h"
#ifdef _WIN32
@@ -62,7 +61,7 @@ RenderWidget::RenderWidget(QWidget* parent) : QWidget(parent)
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
if (state == Core::State::Running)
SetImGuiKeyMap();
SetPresenterKeyMap();
});
// We have to use Qt::DirectConnection here because we don't want those signals to get queued
@@ -338,7 +337,7 @@ void RenderWidget::SetWaitingForMessageBox(bool waiting_for_message_box)
bool RenderWidget::event(QEvent* event)
{
PassEventToImGui(event);
PassEventToPresenter(event);
switch (event->type())
{
@@ -470,7 +469,7 @@ bool RenderWidget::event(QEvent* event)
return QWidget::event(event);
}
void RenderWidget::PassEventToImGui(const QEvent* event)
void RenderWidget::PassEventToPresenter(const QEvent* event)
{
if (!Core::IsRunningAndStarted())
return;
@@ -487,38 +486,40 @@ void RenderWidget::PassEventToImGui(const QEvent* event)
const QKeyEvent* key_event = static_cast<const QKeyEvent*>(event);
const bool is_down = event->type() == QEvent::KeyPress;
const u32 key = static_cast<u32>(key_event->key() & 0x1FF);
auto lock = g_renderer->GetImGuiLock();
if (key < std::size(ImGui::GetIO().KeysDown))
ImGui::GetIO().KeysDown[key] = is_down;
const char* chars = nullptr;
if (is_down)
{
auto utf8 = key_event->text().toUtf8();
ImGui::GetIO().AddInputCharactersUTF8(utf8.constData());
if (utf8.size())
chars = utf8.constData();
}
// Pass the key onto Presenter (for the imgui UI)
g_presenter->SetKey(key, is_down, chars);
}
break;
case QEvent::MouseMove:
{
auto lock = g_renderer->GetImGuiLock();
// Qt multiplies all coordinates by the scaling factor in highdpi mode, giving us "scaled" mouse
// coordinates (as if the screen was standard dpi). We need to update the mouse position in
// native coordinates, as the UI (and game) is rendered at native resolution.
const float scale = devicePixelRatio();
ImGui::GetIO().MousePos.x = static_cast<const QMouseEvent*>(event)->pos().x() * scale;
ImGui::GetIO().MousePos.y = static_cast<const QMouseEvent*>(event)->pos().y() * scale;
float x = static_cast<const QMouseEvent*>(event)->pos().x() * scale;
float y = static_cast<const QMouseEvent*>(event)->pos().y() * scale;
g_presenter->SetMousePos(x, y);
}
break;
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
{
auto lock = g_renderer->GetImGuiLock();
const u32 button_mask = static_cast<u32>(static_cast<const QMouseEvent*>(event)->buttons());
for (size_t i = 0; i < std::size(ImGui::GetIO().MouseDown); i++)
ImGui::GetIO().MouseDown[i] = (button_mask & (1u << i)) != 0;
g_presenter->SetMousePress(button_mask);
}
break;
@@ -527,36 +528,16 @@ void RenderWidget::PassEventToImGui(const QEvent* event)
}
}
void RenderWidget::SetImGuiKeyMap()
void RenderWidget::SetPresenterKeyMap()
{
static constexpr std::array<std::array<int, 2>, 21> key_map{{
{ImGuiKey_Tab, Qt::Key_Tab},
{ImGuiKey_LeftArrow, Qt::Key_Left},
{ImGuiKey_RightArrow, Qt::Key_Right},
{ImGuiKey_UpArrow, Qt::Key_Up},
{ImGuiKey_DownArrow, Qt::Key_Down},
{ImGuiKey_PageUp, Qt::Key_PageUp},
{ImGuiKey_PageDown, Qt::Key_PageDown},
{ImGuiKey_Home, Qt::Key_Home},
{ImGuiKey_End, Qt::Key_End},
{ImGuiKey_Insert, Qt::Key_Insert},
{ImGuiKey_Delete, Qt::Key_Delete},
{ImGuiKey_Backspace, Qt::Key_Backspace},
{ImGuiKey_Space, Qt::Key_Space},
{ImGuiKey_Enter, Qt::Key_Return},
{ImGuiKey_Escape, Qt::Key_Escape},
{ImGuiKey_A, Qt::Key_A},
{ImGuiKey_C, Qt::Key_C},
{ImGuiKey_V, Qt::Key_V},
{ImGuiKey_X, Qt::Key_X},
{ImGuiKey_Y, Qt::Key_Y},
{ImGuiKey_Z, Qt::Key_Z},
}};
auto lock = g_renderer->GetImGuiLock();
static constexpr DolphinKeyMap key_map = {
Qt::Key_Tab, Qt::Key_Left, Qt::Key_Right, Qt::Key_Up, Qt::Key_Down,
Qt::Key_PageUp, Qt::Key_PageDown, Qt::Key_Home, Qt::Key_End, Qt::Key_Insert,
Qt::Key_Delete, Qt::Key_Backspace, Qt::Key_Space, Qt::Key_Return, Qt::Key_Escape,
Qt::Key_Enter, // Keypad enter
Qt::Key_A, Qt::Key_C, Qt::Key_V, Qt::Key_X, Qt::Key_Y,
Qt::Key_Z,
};
if (!ImGui::GetCurrentContext())
return;
for (auto [imgui_key, qt_key] : key_map)
ImGui::GetIO().KeyMap[imgui_key] = (qt_key & 0x1FF);
g_presenter->SetKeyMap(key_map);
}

Some files were not shown because too many files have changed in this diff Show More