From 31cfe8250d5a27bd586136d0b71b09736861ad7d Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Tue, 31 Jan 2023 17:29:16 +1300 Subject: [PATCH] Lint fixes --- Source/Core/Common/EventHook.h | 6 +- Source/Core/Common/StringLiteral.h | 9 +-- Source/Core/Core/Core.cpp | 14 ++-- Source/Core/Core/FifoPlayer/FifoRecorder.cpp | 36 ++++----- Source/Core/VideoBackends/D3D/D3DGfx.cpp | 32 ++++---- Source/Core/VideoBackends/D3D/D3DMain.cpp | 4 +- .../Core/VideoBackends/D3D/D3DPerfQuery.cpp | 8 +- Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp | 38 +++++----- Source/Core/VideoBackends/D3D12/D3D12Gfx.h | 4 +- .../VideoBackends/D3D12/D3D12PerfQuery.cpp | 2 +- .../D3D12/D3D12VertexManager.cpp | 12 +-- .../Core/VideoBackends/D3D12/VideoBackend.cpp | 2 +- Source/Core/VideoBackends/Metal/MTLGfx.h | 4 +- Source/Core/VideoBackends/Metal/MTLGfx.mm | 55 ++++++-------- .../Core/VideoBackends/Metal/MTLPerfQuery.mm | 5 +- Source/Core/VideoBackends/OGL/OGLGfx.h | 4 +- .../Core/VideoBackends/OGL/OGLPerfQuery.cpp | 5 +- Source/Core/VideoBackends/Software/SWGfx.h | 4 +- Source/Core/VideoBackends/Vulkan/VKGfx.h | 4 +- Source/Core/VideoBackends/Vulkan/VKMain.cpp | 2 +- Source/Core/VideoCommon/AsyncRequests.cpp | 2 +- Source/Core/VideoCommon/BPStructs.cpp | 3 +- .../Core/VideoCommon/FramebufferManager.cpp | 13 ++-- Source/Core/VideoCommon/FramebufferManager.h | 3 +- .../Runtime/GraphicsModManager.h | 2 +- Source/Core/VideoCommon/OnScreenUI.h | 1 - .../Core/VideoCommon/PixelShaderManager.cpp | 7 +- Source/Core/VideoCommon/Present.cpp | 15 ++-- Source/Core/VideoCommon/RenderBase.cpp | 15 ++-- Source/Core/VideoCommon/RenderBase.h | 1 - Source/Core/VideoCommon/ShaderCache.cpp | 3 +- Source/Core/VideoCommon/Statistics.cpp | 21 +++--- Source/Core/VideoCommon/TextureCacheBase.cpp | 14 ++-- Source/Core/VideoCommon/VertexManagerBase.cpp | 5 +- .../Core/VideoCommon/VertexShaderManager.cpp | 7 +- Source/Core/VideoCommon/VideoConfig.cpp | 11 +-- Source/Core/VideoCommon/VideoConfig.h | 1 - Source/Core/VideoCommon/VideoEvents.h | 75 +++++++++---------- Source/Core/VideoCommon/VideoState.cpp | 5 +- 39 files changed, 219 insertions(+), 235 deletions(-) diff --git a/Source/Core/Common/EventHook.h b/Source/Core/Common/EventHook.h index 265013827a..903ff3ae36 100644 --- a/Source/Core/Common/EventHook.h +++ b/Source/Core/Common/EventHook.h @@ -36,7 +36,7 @@ struct HookBase using EventHook = std::unique_ptr; -template +template class Event { public: @@ -46,12 +46,12 @@ private: struct HookImpl : public HookBase { ~HookImpl() override { Event::Remove(this); } - HookImpl(CallbackType callback, std::string name) : m_fn(callback), m_name(name){ } + HookImpl(CallbackType callback, std::string name) : m_fn(callback), m_name(name) {} CallbackType m_fn; std::string m_name; }; -public: +public: // Returns a handle that will unregister the listener when destroyed. static EventHook Register(CallbackType callback, std::string name) { diff --git a/Source/Core/Common/StringLiteral.h b/Source/Core/Common/StringLiteral.h index 6227d48ed6..33ecee31e5 100644 --- a/Source/Core/Common/StringLiteral.h +++ b/Source/Core/Common/StringLiteral.h @@ -7,11 +7,10 @@ // A useful template for passing string literals as arguments to templates // from: https://ctrpeach.io/posts/cpp20-string-literal-template-parameters/ -template -struct StringLiteral { - consteval StringLiteral(const char (&str)[N]) { - std::copy_n(str, N, value); - } +template +struct StringLiteral +{ + consteval StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); } char value[N]; }; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 495ffc6ba4..f49261483d 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -132,12 +132,14 @@ static thread_local bool tls_is_gpu_thread = false; static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi); -static 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"); +static 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() { diff --git a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp index 0ec2232843..15063c3f02 100644 --- a/Source/Core/Core/FifoPlayer/FifoRecorder.cpp +++ b/Source/Core/Core/FifoPlayer/FifoRecorder.cpp @@ -18,9 +18,9 @@ #include "VideoCommon/CommandProcessor.h" #include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/TextureDecoder.h" -#include "VideoCommon/XFStructs.h" -#include "VideoCommon/XFMemory.h" #include "VideoCommon/VideoEvents.h" +#include "VideoCommon/XFMemory.h" +#include "VideoCommon/XFStructs.h" class FifoRecorder::FifoRecordAnalyzer : public OpcodeDecoder::Callback { @@ -255,24 +255,26 @@ 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(); + 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 (!OpcodeDecoder::g_record_fifo_data) + return; - if (!was_recording) - { - RecordInitialVideoMemory(); - } + 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"); + 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() diff --git a/Source/Core/VideoBackends/D3D/D3DGfx.cpp b/Source/Core/VideoBackends/D3D/D3DGfx.cpp index 32dc21fb6a..35be881e01 100644 --- a/Source/Core/VideoBackends/D3D/D3DGfx.cpp +++ b/Source/Core/VideoBackends/D3D/D3DGfx.cpp @@ -50,19 +50,19 @@ bool Gfx::IsHeadless() const } std::unique_ptr Gfx::CreateTexture(const TextureConfig& config, - std::string_view name) + std::string_view name) { return DXTexture::Create(config, name); } std::unique_ptr Gfx::CreateStagingTexture(StagingTextureType type, - const TextureConfig& config) + const TextureConfig& config) { return DXStagingTexture::Create(type, config); } std::unique_ptr Gfx::CreateFramebuffer(AbstractTexture* color_attachment, - AbstractTexture* depth_attachment) + AbstractTexture* depth_attachment) { return DXFramebuffer::Create(static_cast(color_attachment), static_cast(depth_attachment)); @@ -78,16 +78,15 @@ Gfx::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::str return DXShader::CreateFromBytecode(stage, std::move(*bytecode), name); } -std::unique_ptr Gfx::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length, - std::string_view name) +std::unique_ptr Gfx::CreateShaderFromBinary(ShaderStage stage, const void* data, + size_t length, std::string_view name) { return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name); } std::unique_ptr Gfx::CreatePipeline(const AbstractPipelineConfig& config, - const void* cache_data, - size_t cache_data_length) + const void* cache_data, + size_t cache_data_length) { return DXPipeline::Create(config); } @@ -129,7 +128,7 @@ void Gfx::SetScissorRect(const MathUtil::Rectangle& rc) } void Gfx::SetViewport(float x, float y, float width, float height, float near_depth, - float far_depth) + float far_depth) { // TODO: Move to stateman const CD3D11_VIEWPORT vp(x, y, width, height, near_depth, far_depth); @@ -149,7 +148,7 @@ void Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex) } void Gfx::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y, - u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z) + u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z) { D3D::stateman->SetComputeShader(static_cast(shader)->GetD3DComputeShader()); D3D::stateman->SyncComputeBindings(); @@ -222,8 +221,8 @@ void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) SetFramebuffer(framebuffer); } -void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, - const ClearColor& color_value, float depth_value) +void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value, + float depth_value) { SetFramebuffer(framebuffer); D3D::stateman->Apply(); @@ -286,12 +285,9 @@ bool Gfx::IsFullscreen() const SurfaceInfo Gfx::GetSurfaceInfo() const { - return { - m_swap_chain ? static_cast(m_swap_chain->GetWidth()) : 0, - m_swap_chain ? static_cast(m_swap_chain->GetHeight()) : 0, - m_backbuffer_scale, - m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined - }; + return {m_swap_chain ? static_cast(m_swap_chain->GetWidth()) : 0, + m_swap_chain ? static_cast(m_swap_chain->GetHeight()) : 0, m_backbuffer_scale, + m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined}; } } // namespace DX11 diff --git a/Source/Core/VideoBackends/D3D/D3DMain.cpp b/Source/Core/VideoBackends/D3D/D3DMain.cpp index ae2e0cd959..8256674ad5 100644 --- a/Source/Core/VideoBackends/D3D/D3DMain.cpp +++ b/Source/Core/VideoBackends/D3D/D3DMain.cpp @@ -13,8 +13,8 @@ #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DBoundingBox.h" -#include "VideoBackends/D3D/D3DPerfQuery.h" #include "VideoBackends/D3D/D3DGfx.h" +#include "VideoBackends/D3D/D3DPerfQuery.h" #include "VideoBackends/D3D/D3DSwapChain.h" #include "VideoBackends/D3D/D3DVertexManager.h" #include "VideoBackends/D3DCommon/D3DCommon.h" @@ -161,7 +161,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi) auto bounding_box = std::make_unique(); return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query), - std::move(bounding_box)); + std::move(bounding_box)); } void VideoBackend::Shutdown() diff --git a/Source/Core/VideoBackends/D3D/D3DPerfQuery.cpp b/Source/Core/VideoBackends/D3D/D3DPerfQuery.cpp index d72b88c0fb..bef3834dc5 100644 --- a/Source/Core/VideoBackends/D3D/D3DPerfQuery.cpp +++ b/Source/Core/VideoBackends/D3D/D3DPerfQuery.cpp @@ -114,8 +114,8 @@ void PerfQuery::FlushOne() // NOTE: Reported pixel metrics should be referenced to native resolution // TODO: Dropping the lower 2 bits from this count should be closer to actual // hardware behavior when drawing triangles. - const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT / - g_framebuffer_manager->GetEFBHeight(); + const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * + EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight(); m_results[entry.query_group].fetch_add(static_cast(native_res_result), std::memory_order_relaxed); @@ -143,8 +143,8 @@ void PerfQuery::WeakFlush() if (hr == S_OK) { // NOTE: Reported pixel metrics should be referenced to native resolution - const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT / - g_framebuffer_manager->GetEFBHeight(); + const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * + EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight(); m_results[entry.query_group].store(static_cast(native_res_result), std::memory_order_relaxed); diff --git a/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp b/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp index e1c82353b2..b3ade2e5d3 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12Gfx.cpp @@ -49,19 +49,19 @@ bool Gfx::IsHeadless() const } std::unique_ptr Gfx::CreateTexture(const TextureConfig& config, - std::string_view name) + std::string_view name) { return DXTexture::Create(config, name); } std::unique_ptr Gfx::CreateStagingTexture(StagingTextureType type, - const TextureConfig& config) + const TextureConfig& config) { return DXStagingTexture::Create(type, config); } std::unique_ptr Gfx::CreateFramebuffer(AbstractTexture* color_attachment, - AbstractTexture* depth_attachment) + AbstractTexture* depth_attachment) { return DXFramebuffer::Create(static_cast(color_attachment), static_cast(depth_attachment)); @@ -73,9 +73,8 @@ Gfx::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::str return DXShader::CreateFromSource(stage, source, name); } -std::unique_ptr Gfx::CreateShaderFromBinary(ShaderStage stage, - const void* data, size_t length, - std::string_view name) +std::unique_ptr Gfx::CreateShaderFromBinary(ShaderStage stage, const void* data, + size_t length, std::string_view name) { return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name); } @@ -87,8 +86,8 @@ Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) } std::unique_ptr Gfx::CreatePipeline(const AbstractPipelineConfig& config, - const void* cache_data, - size_t cache_data_length) + const void* cache_data, + size_t cache_data_length) { return DXPipeline::Create(config, cache_data, cache_data_length); } @@ -103,8 +102,8 @@ void Gfx::WaitForGPUIdle() ExecuteCommandList(true); } -void Gfx::ClearRegion(const MathUtil::Rectangle& target_rc, - bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) +void Gfx::ClearRegion(const MathUtil::Rectangle& target_rc, bool color_enable, + bool alpha_enable, bool z_enable, u32 color, u32 z) { // Use a fast path without the shader if both color/alpha are enabled. const bool fast_color_clear = color_enable && alpha_enable; @@ -229,8 +228,8 @@ void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) } } -void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, - const ClearColor& color_value, float depth_value) +void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value, + float depth_value) { DXFramebuffer* dxfb = static_cast(framebuffer); BindFramebuffer(dxfb); @@ -318,7 +317,7 @@ void Gfx::UnbindTexture(const AbstractTexture* texture) } void Gfx::SetViewport(float x, float y, float width, float height, float near_depth, - float far_depth) + float far_depth) { if (m_state.viewport.TopLeftX == x && m_state.viewport.TopLeftY == y && m_state.viewport.Width == width && m_state.viewport.Height == height && @@ -357,7 +356,7 @@ void Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex) } void Gfx::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y, - u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z) + u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z) { SetRootSignatures(); SetDescriptorHeaps(); @@ -427,12 +426,9 @@ void Gfx::PresentBackbuffer() SurfaceInfo Gfx::GetSurfaceInfo() const { - return { - m_swap_chain ? static_cast(m_swap_chain->GetWidth()) : 0, - m_swap_chain ? static_cast(m_swap_chain->GetHeight()) : 0, - m_backbuffer_scale, - m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined - }; + return {m_swap_chain ? static_cast(m_swap_chain->GetWidth()) : 0, + m_swap_chain ? static_cast(m_swap_chain->GetHeight()) : 0, m_backbuffer_scale, + m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined}; } void Gfx::OnConfigChanged(u32 bits) @@ -494,7 +490,7 @@ void Gfx::SetPixelShaderUAV(D3D12_CPU_DESCRIPTOR_HANDLE handle) } void Gfx::SetVertexBuffer(D3D12_GPU_VIRTUAL_ADDRESS address, D3D12_CPU_DESCRIPTOR_HANDLE srv, - u32 stride, u32 size) + u32 stride, u32 size) { if (m_state.vertex_buffer.BufferLocation != address || m_state.vertex_buffer.StrideInBytes != stride || m_state.vertex_buffer.SizeInBytes != size) diff --git a/Source/Core/VideoBackends/D3D12/D3D12Gfx.h b/Source/Core/VideoBackends/D3D12/D3D12Gfx.h index e7eb015b2f..95774dd71d 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12Gfx.h +++ b/Source/Core/VideoBackends/D3D12/D3D12Gfx.h @@ -47,8 +47,8 @@ public: void Flush() override; void WaitForGPUIdle() override; - void ClearRegion(const MathUtil::Rectangle& target_rc, - bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override; + void ClearRegion(const MathUtil::Rectangle& target_rc, bool color_enable, bool alpha_enable, + bool z_enable, u32 color, u32 z) override; void SetPipeline(const AbstractPipeline* pipeline) override; void SetFramebuffer(AbstractFramebuffer* framebuffer) override; diff --git a/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.cpp b/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.cpp index 17cb1da2d3..d7ada1516a 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12PerfQuery.cpp @@ -11,8 +11,8 @@ #include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/D3D12Gfx.h" #include "VideoBackends/D3D12/DX12Context.h" -#include "VideoCommon/VideoCommon.h" #include "VideoCommon/RenderBase.h" +#include "VideoCommon/VideoCommon.h" namespace DX12 { diff --git a/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp b/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp index 55f13630a9..03e88e3867 100644 --- a/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp +++ b/Source/Core/VideoBackends/D3D12/D3D12VertexManager.cpp @@ -130,10 +130,10 @@ void VertexManager::CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_in ADDSTAT(g_stats.this_frame.bytes_index_streamed, static_cast(index_data_size)); Gfx::GetInstance()->SetVertexBuffer(m_vertex_stream_buffer.GetGPUPointer(), - m_vertex_srv.cpu_handle, vertex_stride, - m_vertex_stream_buffer.GetSize()); + m_vertex_srv.cpu_handle, vertex_stride, + m_vertex_stream_buffer.GetSize()); Gfx::GetInstance()->SetIndexBuffer(m_index_stream_buffer.GetGPUPointer(), - m_index_stream_buffer.GetSize(), DXGI_FORMAT_R16_UINT); + m_index_stream_buffer.GetSize(), DXGI_FORMAT_R16_UINT); } void VertexManager::UploadUniforms() @@ -235,11 +235,11 @@ void VertexManager::UploadAllConstants() // Update bindings Gfx::GetInstance()->SetConstantBuffer(0, m_uniform_stream_buffer.GetCurrentGPUPointer() + - pixel_constants_offset); + pixel_constants_offset); Gfx::GetInstance()->SetConstantBuffer(1, m_uniform_stream_buffer.GetCurrentGPUPointer() + - vertex_constants_offset); + vertex_constants_offset); Gfx::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer() + - geometry_constants_offset); + geometry_constants_offset); auto& system = Core::System::GetInstance(); auto& pixel_shader_manager = system.GetPixelShaderManager(); diff --git a/Source/Core/VideoBackends/D3D12/VideoBackend.cpp b/Source/Core/VideoBackends/D3D12/VideoBackend.cpp index dbf51bd7f8..afc5bb96e8 100644 --- a/Source/Core/VideoBackends/D3D12/VideoBackend.cpp +++ b/Source/Core/VideoBackends/D3D12/VideoBackend.cpp @@ -12,8 +12,8 @@ #include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/D3D12BoundingBox.h" -#include "VideoBackends/D3D12/D3D12PerfQuery.h" #include "VideoBackends/D3D12/D3D12Gfx.h" +#include "VideoBackends/D3D12/D3D12PerfQuery.h" #include "VideoBackends/D3D12/D3D12SwapChain.h" #include "VideoBackends/D3D12/D3D12VertexManager.h" #include "VideoBackends/D3D12/DX12Context.h" diff --git a/Source/Core/VideoBackends/Metal/MTLGfx.h b/Source/Core/VideoBackends/Metal/MTLGfx.h index b4c3a3d0e8..a7d5e170b6 100644 --- a/Source/Core/VideoBackends/Metal/MTLGfx.h +++ b/Source/Core/VideoBackends/Metal/MTLGfx.h @@ -47,8 +47,8 @@ public: void WaitForGPUIdle() override; void OnConfigChanged(u32 bits) override; - void ClearRegion(const MathUtil::Rectangle& target_rc, - bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override; + void ClearRegion(const MathUtil::Rectangle& target_rc, bool color_enable, bool alpha_enable, + bool z_enable, u32 color, u32 z) override; void SetPipeline(const AbstractPipeline* pipeline) override; void SetFramebuffer(AbstractFramebuffer* framebuffer) override; diff --git a/Source/Core/VideoBackends/Metal/MTLGfx.mm b/Source/Core/VideoBackends/Metal/MTLGfx.mm index ba7d64e333..d6621396ec 100644 --- a/Source/Core/VideoBackends/Metal/MTLGfx.mm +++ b/Source/Core/VideoBackends/Metal/MTLGfx.mm @@ -18,8 +18,7 @@ #include -Metal::Gfx::Gfx(MRCOwned layer) - : m_layer(std::move(layer)) +Metal::Gfx::Gfx(MRCOwned layer) : m_layer(std::move(layer)) { UpdateActiveConfig(); [m_layer setDisplaySyncEnabled:g_ActiveConfig.bVSyncActive]; @@ -38,7 +37,7 @@ bool Metal::Gfx::IsHeadless() const // MARK: Texture Creation std::unique_ptr Metal::Gfx::CreateTexture(const TextureConfig& config, - std::string_view name) + std::string_view name) { @autoreleasepool { @@ -94,8 +93,7 @@ Metal::Gfx::CreateStagingTexture(StagingTextureType type, const TextureConfig& c } std::unique_ptr -Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment, - AbstractTexture* depth_attachment) +Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) { AbstractTexture* const either_attachment = color_attachment ? color_attachment : depth_attachment; return std::make_unique( @@ -107,8 +105,8 @@ Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment, // MARK: Pipeline Creation std::unique_ptr Metal::Gfx::CreateShaderFromSource(ShaderStage stage, - std::string_view source, - std::string_view name) + std::string_view source, + std::string_view name) { std::optional msl = Util::TranslateShaderToMSL(stage, source); if (!msl.has_value()) @@ -121,9 +119,8 @@ std::unique_ptr Metal::Gfx::CreateShaderFromSource(ShaderStage s } std::unique_ptr Metal::Gfx::CreateShaderFromBinary(ShaderStage stage, - const void* data, - size_t length, - std::string_view name) + const void* data, size_t length, + std::string_view name) { return CreateShaderFromMSL(stage, std::string(static_cast(data), length), {}, name); } @@ -154,10 +151,9 @@ static NSString* GenericShaderName(ShaderStage stage) // clang-format on -std::unique_ptr Metal::Gfx::CreateShaderFromMSL(ShaderStage stage, - std::string msl, - std::string_view glsl, - std::string_view name) +std::unique_ptr Metal::Gfx::CreateShaderFromMSL(ShaderStage stage, std::string msl, + std::string_view glsl, + std::string_view name) { @autoreleasepool { @@ -247,9 +243,9 @@ Metal::Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) } } -std::unique_ptr -Metal::Gfx::CreatePipeline(const AbstractPipelineConfig& config, const void* cache_data, - size_t cache_data_length) +std::unique_ptr Metal::Gfx::CreatePipeline(const AbstractPipelineConfig& config, + const void* cache_data, + size_t cache_data_length) { return g_object_cache->CreatePipeline(config); } @@ -285,8 +281,8 @@ void Metal::Gfx::OnConfigChanged(u32 bits) } } -void Metal::Gfx::ClearRegion(const MathUtil::Rectangle& target_rc, - bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) +void Metal::Gfx::ClearRegion(const MathUtil::Rectangle& target_rc, bool color_enable, + bool alpha_enable, bool z_enable, u32 color, u32 z) { u32 framebuffer_width = m_current_framebuffer->GetWidth(); u32 framebuffer_height = m_current_framebuffer->GetHeight(); @@ -362,7 +358,7 @@ void Metal::Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) } void Metal::Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, - const ClearColor& color_value, float depth_value) + const ClearColor& color_value, float depth_value) { @autoreleasepool { @@ -400,7 +396,7 @@ void Metal::Gfx::UnbindTexture(const AbstractTexture* texture) } void Metal::Gfx::SetViewport(float x, float y, float width, float height, float near_depth, - float far_depth) + float far_depth) { g_state_tracker->SetViewport(x, y, width, height, near_depth, far_depth); } @@ -422,8 +418,8 @@ void Metal::Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex) } void Metal::Gfx::DispatchComputeShader(const AbstractShader* shader, // - u32 groupsize_x, u32 groupsize_y, u32 groupsize_z, - u32 groups_x, u32 groups_y, u32 groups_z) + u32 groupsize_x, u32 groupsize_y, u32 groupsize_z, + u32 groups_x, u32 groups_y, u32 groups_z) { @autoreleasepool { @@ -491,7 +487,8 @@ void Metal::Gfx::SetupSurface() [m_layer setDrawableSize:{static_cast(info.width), static_cast(info.height)}]; - TextureConfig cfg(info.width, info.height, 1, 1, 1, info.format, AbstractTextureFlag_RenderTarget); + TextureConfig cfg(info.width, info.height, 1, 1, 1, info.format, + AbstractTextureFlag_RenderTarget); m_bb_texture = std::make_unique(nullptr, cfg); m_backbuffer = std::make_unique(m_bb_texture.get(), nullptr, // info.width, info.height, 1, 1); @@ -502,16 +499,12 @@ void Metal::Gfx::SetupSurface() SurfaceInfo Metal::Gfx::GetSurfaceInfo() const { - if (!m_layer) // Headless + if (!m_layer) // Headless return {}; CGSize size = [m_layer bounds].size; const float scale = [m_layer contentsScale]; - return { - static_cast(size.width * scale), - static_cast(size.height * scale), - scale, - Util::ToAbstract([m_layer pixelFormat]) - }; + return {static_cast(size.width * scale), static_cast(size.height * scale), scale, + Util::ToAbstract([m_layer pixelFormat])}; } diff --git a/Source/Core/VideoBackends/Metal/MTLPerfQuery.mm b/Source/Core/VideoBackends/Metal/MTLPerfQuery.mm index 4bf37ccd22..76bddc1dce 100644 --- a/Source/Core/VideoBackends/Metal/MTLPerfQuery.mm +++ b/Source/Core/VideoBackends/Metal/MTLPerfQuery.mm @@ -77,8 +77,9 @@ void Metal::PerfQuery::ReturnResults(const u64* data, const PerfQueryGroup* grou { for (size_t i = 0; i < count; ++i) { - u64 native_res_result = data[i] * (EFB_WIDTH * EFB_HEIGHT) / - (g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); + u64 native_res_result = + data[i] * (EFB_WIDTH * EFB_HEIGHT) / + (g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); native_res_result /= g_ActiveConfig.iMultisamples; diff --git a/Source/Core/VideoBackends/OGL/OGLGfx.h b/Source/Core/VideoBackends/OGL/OGLGfx.h index 671d78ee4a..410b7d562e 100644 --- a/Source/Core/VideoBackends/OGL/OGLGfx.h +++ b/Source/Core/VideoBackends/OGL/OGLGfx.h @@ -42,8 +42,8 @@ public: void SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) override; void SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value = {}, float depth_value = 0.0f) override; - void ClearRegion(const MathUtil::Rectangle& target_rc, - bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override; + void ClearRegion(const MathUtil::Rectangle& target_rc, bool colorEnable, bool alphaEnable, + bool zEnable, u32 color, u32 z) override; void SetScissorRect(const MathUtil::Rectangle& rc) override; void SetTexture(u32 index, const AbstractTexture* texture) override; void SetSamplerState(u32 index, const SamplerState& state) override; diff --git a/Source/Core/VideoBackends/OGL/OGLPerfQuery.cpp b/Source/Core/VideoBackends/OGL/OGLPerfQuery.cpp index a5bd155afb..6303464251 100644 --- a/Source/Core/VideoBackends/OGL/OGLPerfQuery.cpp +++ b/Source/Core/VideoBackends/OGL/OGLPerfQuery.cpp @@ -264,8 +264,9 @@ void PerfQueryGLESNV::FlushOne() // NOTE: Reported pixel metrics should be referenced to native resolution // TODO: Dropping the lower 2 bits from this count should be closer to actual // hardware behavior when drawing triangles. - const u64 native_res_result = static_cast(result) * EFB_WIDTH * EFB_HEIGHT / - (g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); + const u64 native_res_result = + static_cast(result) * EFB_WIDTH * EFB_HEIGHT / + (g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); m_results[entry.query_group].fetch_add(static_cast(native_res_result), std::memory_order_relaxed); diff --git a/Source/Core/VideoBackends/Software/SWGfx.h b/Source/Core/VideoBackends/Software/SWGfx.h index 6e5b328b5c..74ead3a323 100644 --- a/Source/Core/VideoBackends/Software/SWGfx.h +++ b/Source/Core/VideoBackends/Software/SWGfx.h @@ -46,8 +46,8 @@ public: void SetScissorRect(const MathUtil::Rectangle& rc) override; - void ClearRegion(const MathUtil::Rectangle& target_rc, - bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override; + void ClearRegion(const MathUtil::Rectangle& target_rc, bool colorEnable, bool alphaEnable, + bool zEnable, u32 color, u32 z) override; private: std::unique_ptr m_window; diff --git a/Source/Core/VideoBackends/Vulkan/VKGfx.h b/Source/Core/VideoBackends/Vulkan/VKGfx.h index 8275038479..8217533f06 100644 --- a/Source/Core/VideoBackends/Vulkan/VKGfx.h +++ b/Source/Core/VideoBackends/Vulkan/VKGfx.h @@ -53,8 +53,8 @@ public: void WaitForGPUIdle() override; void OnConfigChanged(u32 bits) override; - void ClearRegion(const MathUtil::Rectangle& target_rc, - bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override; + void ClearRegion(const MathUtil::Rectangle& target_rc, bool color_enable, bool alpha_enable, + bool z_enable, u32 color, u32 z) override; void SetPipeline(const AbstractPipeline* pipeline) override; void SetFramebuffer(AbstractFramebuffer* framebuffer) override; diff --git a/Source/Core/VideoBackends/Vulkan/VKMain.cpp b/Source/Core/VideoBackends/Vulkan/VKMain.cpp index 7521915897..053b592c14 100644 --- a/Source/Core/VideoBackends/Vulkan/VKMain.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKMain.cpp @@ -240,7 +240,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi) auto bounding_box = std::make_unique(); return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query), - std::move(bounding_box)); + std::move(bounding_box)); } void VideoBackend::Shutdown() diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index 8c254d4e71..ad854a3dce 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -15,8 +15,8 @@ #include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoCommon.h" -#include "VideoCommon/VideoState.h" #include "VideoCommon/VideoEvents.h" +#include "VideoCommon/VideoState.h" AsyncRequests AsyncRequests::s_singleton; diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp index 6d50377950..f5383042a0 100644 --- a/Source/Core/VideoCommon/BPStructs.cpp +++ b/Source/Core/VideoCommon/BPStructs.cpp @@ -31,9 +31,9 @@ #include "VideoCommon/GeometryShaderManager.h" #include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/PerfQueryBase.h" -#include "VideoCommon/Present.h" #include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelShaderManager.h" +#include "VideoCommon/Present.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/TMEM.h" @@ -346,7 +346,6 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, // It works 99% of the time. AfterFrameEvent::Trigger(); - if (g_ActiveConfig.bImmediateXFB) { // below div two to convert from bytes to pixels - it expects width, not stride diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index 38cab15f00..a987624f1a 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -149,16 +149,14 @@ static u32 CalculateEFBLayers() TextureConfig FramebufferManager::GetEFBColorTextureConfig(u32 width, u32 height) { - return TextureConfig(width, height, 1, - CalculateEFBLayers(), g_ActiveConfig.iMultisamples, GetEFBColorFormat(), - AbstractTextureFlag_RenderTarget); + return TextureConfig(width, height, 1, CalculateEFBLayers(), g_ActiveConfig.iMultisamples, + GetEFBColorFormat(), AbstractTextureFlag_RenderTarget); } TextureConfig FramebufferManager::GetEFBDepthTextureConfig(u32 width, u32 height) { - return TextureConfig(width, height, 1, - CalculateEFBLayers(), g_ActiveConfig.iMultisamples, GetEFBDepthFormat(), - AbstractTextureFlag_RenderTarget); + return TextureConfig(width, height, 1, CalculateEFBLayers(), g_ActiveConfig.iMultisamples, + GetEFBDepthFormat(), AbstractTextureFlag_RenderTarget); } FramebufferState FramebufferManager::GetEFBFramebufferState() const @@ -905,8 +903,7 @@ bool FramebufferManager::CompileClearPipelines() config.depth_state.testenable = depth_enable != 0; config.depth_state.updateenable = depth_enable != 0; - m_clear_pipelines[color_enable][alpha_enable][depth_enable] = - g_gfx->CreatePipeline(config); + m_clear_pipelines[color_enable][alpha_enable][depth_enable] = g_gfx->CreatePipeline(config); if (!m_clear_pipelines[color_enable][alpha_enable][depth_enable]) return false; } diff --git a/Source/Core/VideoCommon/FramebufferManager.h b/Source/Core/VideoCommon/FramebufferManager.h index 0eb5d4aa93..cc41c0ffba 100644 --- a/Source/Core/VideoCommon/FramebufferManager.h +++ b/Source/Core/VideoCommon/FramebufferManager.h @@ -226,8 +226,7 @@ protected: // EFB clear pipelines // Indexed by [color_write_enabled][alpha_write_enabled][depth_write_enabled] - std::array, 2>, 2>, 2> - m_clear_pipelines; + std::array, 2>, 2>, 2> m_clear_pipelines; // EFB poke drawing setup std::unique_ptr m_poke_vertex_format; diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h index aeb55f17d1..9115d8f45d 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h @@ -13,8 +13,8 @@ #include "VideoCommon/GraphicsModSystem/Runtime/FBInfo.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h" #include "VideoCommon/TextureInfo.h" -#include "VideoCommon/XFMemory.h" #include "VideoCommon/VideoEvents.h" +#include "VideoCommon/XFMemory.h" class GraphicsModGroupConfig; class GraphicsModManager diff --git a/Source/Core/VideoCommon/OnScreenUI.h b/Source/Core/VideoCommon/OnScreenUI.h index e90d1c2132..43dc6144d1 100644 --- a/Source/Core/VideoCommon/OnScreenUI.h +++ b/Source/Core/VideoCommon/OnScreenUI.h @@ -16,7 +16,6 @@ class AbstractPipeline; namespace VideoCommon { - // OnScreenUI handles all the ImGui rendering. class OnScreenUI { diff --git a/Source/Core/VideoCommon/PixelShaderManager.cpp b/Source/Core/VideoCommon/PixelShaderManager.cpp index c929db6995..94b37be4e8 100644 --- a/Source/Core/VideoCommon/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/PixelShaderManager.cpp @@ -74,7 +74,8 @@ void PixelShaderManager::Dirty() // Any constants that can changed based on settings should be re-calculated m_fog_range_adjusted_changed = true; - SetEfbScaleChanged(g_framebuffer_manager->EFBToScaledXf(1), g_framebuffer_manager->EFBToScaledYf(1)); + SetEfbScaleChanged(g_framebuffer_manager->EFBToScaledXf(1), + g_framebuffer_manager->EFBToScaledYf(1)); SetFogParamChanged(); dirty = true; @@ -102,8 +103,8 @@ void PixelShaderManager::SetConstants() // so to simplify I use the hi coefficient as K in the shader taking 256 as the scale // TODO: Shouldn't this be EFBToScaledXf? constants.fogf[2] = ScreenSpaceCenter; - constants.fogf[3] = - static_cast(g_framebuffer_manager->EFBToScaledX(static_cast(2.0f * xfmem.viewport.wd))); + constants.fogf[3] = static_cast( + g_framebuffer_manager->EFBToScaledX(static_cast(2.0f * xfmem.viewport.wd))); for (size_t i = 0, vec_index = 0; i < std::size(bpmem.fogRange.K); i++) { diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp index b7a60c7dc6..d5fa440417 100644 --- a/Source/Core/VideoCommon/Present.cpp +++ b/Source/Core/VideoCommon/Present.cpp @@ -9,6 +9,7 @@ #include "InputCommon/ControllerInterface/ControllerInterface.h" +#include "Present.h" #include "VideoCommon/AbstractGfx.h" #include "VideoCommon/FrameDumper.h" #include "VideoCommon/OnScreenUI.h" @@ -18,7 +19,6 @@ #include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoEvents.h" -#include "Present.h" std::unique_ptr g_presenter; @@ -67,7 +67,8 @@ bool Presenter::FetchXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_heigh { ReleaseXFBContentLock(); - m_xfb_entry = g_texture_cache->GetXFBTexture(xfb_addr, fb_width, fb_height, fb_stride, &m_xfb_rect); + m_xfb_entry = + g_texture_cache->GetXFBTexture(xfb_addr, fb_width, fb_height, fb_stride, &m_xfb_rect); bool is_duplicate = m_xfb_entry->id == m_last_xfb_id; m_xfb_entry->AcquireContentLock(); @@ -95,7 +96,7 @@ void Presenter::ViSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, } else { - present_info.frame_count = m_frame_count - 1; // Previous frame + present_info.frame_count = m_frame_count - 1; // Previous frame present_info.reason = PresentInfo::PresentReason::VideoInterfaceDuplicate; } present_info.present_count = m_present_count; @@ -308,7 +309,7 @@ void Presenter::ResizeSurface() void* Presenter::GetNewSurfaceHandle() { - void *handle = m_new_surface_handle; + void* handle = m_new_surface_handle; m_new_surface_handle = nullptr; return handle; } @@ -605,11 +606,9 @@ void Presenter::DoState(PointerWrap& p) AfterFrameEvent::Trigger(); // re-display the most recent XFB - ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, - m_last_xfb_height, m_last_xfb_ticks); + ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, m_last_xfb_height, + m_last_xfb_ticks); } - } - } // namespace VideoCommon diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index c30495f9d1..d324dacac6 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -31,31 +31,32 @@ #include "Core/System.h" #include "VideoCommon/AbstractGfx.h" +#include "VideoCommon/BPFunctions.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/BoundingBox.h" -#include "VideoCommon/BPFunctions.h" #include "VideoCommon/FrameDumper.h" - #include "VideoCommon/FramebufferManager.h" +#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/PixelEngine.h" #include "VideoCommon/Present.h" #include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VideoBackendBase.h" -#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoCommon.h" +#include "VideoCommon/VideoConfig.h" #include "VideoCommon/XFMemory.h" std::unique_ptr g_renderer; -Renderer::Renderer() - : m_prev_efb_format{PixelFormat::INVALID_FMT} +Renderer::Renderer() : m_prev_efb_format{PixelFormat::INVALID_FMT} { UpdateWidescreen(); - m_config_changed_handle = ConfigChangedEvent::Register([this](u32 bits) { OnConfigChanged(bits); }, "Renderer"); + m_config_changed_handle = + ConfigChangedEvent::Register([this](u32 bits) { OnConfigChanged(bits); }, "Renderer"); // VertexManager doesn't maintain statistics in Wii mode. if (!SConfig::GetInstance().bWii) - m_update_widescreen_handle = AfterFrameEvent::Register([this] { UpdateWidescreenHeuristic(); }, "WideScreen Heuristic"); + m_update_widescreen_handle = + AfterFrameEvent::Register([this] { UpdateWidescreenHeuristic(); }, "WideScreen Heuristic"); } Renderer::~Renderer() = default; diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index 52415c0f36..afdfffccb9 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -1,7 +1,6 @@ // Copyright 2010 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later - #pragma once #include diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index cc6e9fb86a..26af6b65d1 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -46,7 +46,8 @@ bool ShaderCache::Initialize() return false; m_async_shader_compiler = g_gfx->CreateAsyncShaderCompiler(); - m_frame_end_handler = AfterFrameEvent::Register([this] { RetrieveAsyncShaders(); }, "RetreiveAsyncShaders"); + m_frame_end_handler = + AfterFrameEvent::Register([this] { RetrieveAsyncShaders(); }, "RetreiveAsyncShaders"); return true; } diff --git a/Source/Core/VideoCommon/Statistics.cpp b/Source/Core/VideoCommon/Statistics.cpp index a1ab6122ab..ecca851968 100644 --- a/Source/Core/VideoCommon/Statistics.cpp +++ b/Source/Core/VideoCommon/Statistics.cpp @@ -18,17 +18,18 @@ Statistics g_stats; -static EventHook s_before_frame_event = BeforeFrameEvent::Register([] { - g_stats.ResetFrame(); -}, "Statistics::ResetFrame"); +static EventHook s_before_frame_event = + BeforeFrameEvent::Register([] { g_stats.ResetFrame(); }, "Statistics::ResetFrame"); -static EventHook s_after_frame_event = AfterFrameEvent::Register([] { - DolphinAnalytics::PerformanceSample perf_sample; - perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance(); - perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims; - perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls; - DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample)); -}, "Statistics::PerformanceSample"); +static EventHook s_after_frame_event = AfterFrameEvent::Register( + [] { + DolphinAnalytics::PerformanceSample perf_sample; + perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance(); + perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims; + perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls; + DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample)); + }, + "Statistics::PerformanceSample"); static bool clear_scissors; diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 02601baaf4..ce14075552 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -773,7 +773,7 @@ void TextureCacheBase::OnFrameEnd() { if (m_force_reload_textures.TestAndClear()) { - ForceReload(); + ForceReload(); } else { @@ -920,9 +920,9 @@ RcTcacheEntry TextureCacheBase::DoPartialTextureUpdates(RcTcacheEntry& entry_to_ entry_to_update->native_height != entry_to_update->GetHeight() || entry->native_width != entry->GetWidth() || entry->native_height != entry->GetHeight()) { - ScaleTextureCacheEntryTo(entry_to_update, - g_framebuffer_manager->EFBToScaledX(entry_to_update->native_width), - g_framebuffer_manager->EFBToScaledY(entry_to_update->native_height)); + ScaleTextureCacheEntryTo( + entry_to_update, g_framebuffer_manager->EFBToScaledX(entry_to_update->native_width), + g_framebuffer_manager->EFBToScaledY(entry_to_update->native_height)); ScaleTextureCacheEntryTo(entry, g_framebuffer_manager->EFBToScaledX(entry->native_width), g_framebuffer_manager->EFBToScaledY(entry->native_height)); @@ -1957,7 +1957,8 @@ void TextureCacheBase::StitchXFBCopy(RcTcacheEntry& stitched_entry) // copies to be stitched together. if (create_upscaled_copy) { - ScaleTextureCacheEntryTo(stitched_entry, g_framebuffer_manager->EFBToScaledX(stitched_entry->native_width), + ScaleTextureCacheEntryTo(stitched_entry, + g_framebuffer_manager->EFBToScaledX(stitched_entry->native_width), g_framebuffer_manager->EFBToScaledY(stitched_entry->native_height)); } @@ -2269,7 +2270,8 @@ void TextureCacheBase::CopyRenderTargetToTexture( // TODO: This only produces perfect downsampling for 2x IR, other resolutions will need more // complex down filtering to average all pixels and produce the correct result. const bool linear_filter = - !is_depth_copy && (scaleByHalf || g_framebuffer_manager->GetEFBScale() != 1 || y_scale > 1.0f); + !is_depth_copy && + (scaleByHalf || g_framebuffer_manager->GetEFBScale() != 1 || y_scale > 1.0f); RcTcacheEntry entry; if (copy_to_vram) diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index a1058c77c7..9686809c88 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -104,7 +104,7 @@ VertexManagerBase::~VertexManagerBase() = default; bool VertexManagerBase::Initialize() { - m_frame_end_event = AfterFrameEvent::Register([this] { OnEndFrame();}, "VertexManagerBase"); + m_frame_end_event = AfterFrameEvent::Register([this] { OnEndFrame(); }, "VertexManagerBase"); m_index_generator.Init(); m_cpu_cull.Init(); return true; @@ -562,8 +562,7 @@ void VertexManagerBase::Flush() { bool skip = false; GraphicsModActionData::DrawStarted draw_started{&skip}; - for (const auto action : - g_graphics_mod_manager->GetDrawStartedActions(texture_name)) + for (const auto action : g_graphics_mod_manager->GetDrawStartedActions(texture_name)) { action->OnDrawStarted(&draw_started); } diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp index f2a203cfe1..4177f3b834 100644 --- a/Source/Core/VideoCommon/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/VertexShaderManager.cpp @@ -388,16 +388,15 @@ void VertexShaderManager::SetConstants(const std::vector& textures) std::vector projection_actions; if (g_ActiveConfig.bGraphicMods) { - for (const auto action : - g_graphics_mod_manager->GetProjectionActions(xfmem.projection.type)) + for (const auto action : g_graphics_mod_manager->GetProjectionActions(xfmem.projection.type)) { projection_actions.push_back(action); } for (const auto& texture : textures) { - for (const auto action : g_graphics_mod_manager->GetProjectionTextureActions( - xfmem.projection.type, texture)) + for (const auto action : + g_graphics_mod_manager->GetProjectionTextureActions(xfmem.projection.type, texture)) { projection_actions.push_back(action); } diff --git a/Source/Core/VideoCommon/VideoConfig.cpp b/Source/Core/VideoCommon/VideoConfig.cpp index 21f006af4a..0c209a9686 100644 --- a/Source/Core/VideoCommon/VideoConfig.cpp +++ b/Source/Core/VideoCommon/VideoConfig.cpp @@ -24,8 +24,8 @@ #include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h" #include "VideoCommon/OnScreenDisplay.h" -#include "VideoCommon/Present.h" #include "VideoCommon/PixelShaderManager.h" +#include "VideoCommon/Present.h" #include "VideoCommon/ShaderGenCommon.h" #include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/VertexManagerBase.h" @@ -355,7 +355,8 @@ void CheckForConfigChanges() // TODO: Move everything else to the ConfigChanged event } -static EventHook s_check_config_event = AfterFrameEvent::Register([] { - CheckForConfigChanges(); - -}, "CheckForConfigChanges"); +static EventHook s_check_config_event = AfterFrameEvent::Register( + [] { + CheckForConfigChanges(); + }, + "CheckForConfigChanges"); diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h index c86ec647bc..1e5e2f683e 100644 --- a/Source/Core/VideoCommon/VideoConfig.h +++ b/Source/Core/VideoCommon/VideoConfig.h @@ -59,7 +59,6 @@ enum class TriState : int Auto }; - // Bitmask containing information about which configuration has changed for the backend. enum ConfigChangeBits : u32 { diff --git a/Source/Core/VideoCommon/VideoEvents.h b/Source/Core/VideoCommon/VideoEvents.h index bb95296ebd..a2e0760075 100644 --- a/Source/Core/VideoCommon/VideoEvents.h +++ b/Source/Core/VideoCommon/VideoEvents.h @@ -6,7 +6,6 @@ #include "Common/CommonTypes.h" #include "Common/EventHook.h" - // Called when certain video config setting are changed using ConfigChangedEvent = Event<"ConfigChanged", u32>; @@ -21,60 +20,60 @@ using AfterFrameEvent = Event<"AfterFrame">; struct PresentInfo { - enum class PresentReason - { - Immediate, // FIFO is Presenting the XFB immediately, straight after the XFB copy - VideoInterface, // VideoInterface has triggered a present with a new frame - VideoInterfaceDuplicate, // VideoInterface has triggered a present with a duplicate frame - }; + enum class PresentReason + { + Immediate, // FIFO is Presenting the XFB immediately, straight after the XFB copy + VideoInterface, // VideoInterface has triggered a present with a new frame + VideoInterfaceDuplicate, // VideoInterface has triggered a present with a duplicate frame + }; - // The number of (unique) frames since the emulated console booted - u64 frame_count; + // The number of (unique) frames since the emulated console booted + u64 frame_count; + // The number of presents since the video backend was initialized. + // never goes backwards. + u64 present_count; - // The number of presents since the video backend was initialized. - // never goes backwards. - u64 present_count; + // The frame is identical to the previous frame + PresentReason reason; - // The frame is identical to the previous frame - PresentReason reason; + // The exact emulated time of the when real hardware would have presented this frame + // FIXME: Immediate should predict the timestamp of this present + u64 emulated_timestamp; - // The exact emulated time of the when real hardware would have presented this frame - // FIXME: Immediate should predict the timestamp of this present - u64 emulated_timestamp; + // TODO: + // u64 intended_present_time; - // TODO: - // u64 intended_present_time; + // AfterPresent only: The actual time the frame was presented + u64 actual_present_time = 0; - // AfterPresent only: The actual time the frame was presented - u64 actual_present_time = 0; + enum class PresentTimeAccuracy + { + // The Driver/OS has given us an exact timestamp of when the first line of the frame started + // scanning out to the monitor + PresentOnScreenExact, - enum class PresentTimeAccuracy - { - // The Driver/OS has given us an exact timestamp of when the first line of the frame started - // scanning out to the monitor - PresentOnScreenExact, + // An approximate timestamp of scanout. + PresentOnScreen, - // An approximate timestamp of scanout. - PresentOnScreen, + // Dolphin doesn't have visibility of the present time. But the present operation has + // been queued with the GPU driver and will happen in the near future. + PresentInProgress, - // Dolphin doesn't have visibility of the present time. But the present operation has - // been queued with the GPU driver and will happen in the near future. - PresentInProgress, + // Not implemented + Unimplemented, + }; - // Not implemented - Unimplemented, - }; - - // Accuracy of actual_present_time - PresentTimeAccuracy present_time_accuracy = PresentTimeAccuracy::Unimplemented; + // Accuracy of actual_present_time + PresentTimeAccuracy present_time_accuracy = PresentTimeAccuracy::Unimplemented; }; // An event called just as a frame is queued for presentation. // The exact timing of this event depends on the "Immediately Present XFB" option. // // If enabled, this event will trigger immediately after AfterFrame -// If disabled, this event won't trigger until the emulated interface starts drawing out a new frame. +// If disabled, this event won't trigger until the emulated interface starts drawing out a new +// frame. // // frame_count: The number of frames using BeforePresentEvent = Event<"BeforePresent", PresentInfo&>; diff --git a/Source/Core/VideoCommon/VideoState.cpp b/Source/Core/VideoCommon/VideoState.cpp index 6981e14adb..5aae09e354 100644 --- a/Source/Core/VideoCommon/VideoState.cpp +++ b/Source/Core/VideoCommon/VideoState.cpp @@ -7,14 +7,14 @@ #include "Common/ChunkFile.h" #include "Core/System.h" -#include "VideoCommon/BoundingBox.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/BPStructs.h" +#include "VideoCommon/BoundingBox.h" #include "VideoCommon/CPMemory.h" #include "VideoCommon/CommandProcessor.h" #include "VideoCommon/Fifo.h" -#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/FrameDumper.h" +#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/GeometryShaderManager.h" #include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelShaderManager.h" @@ -105,7 +105,6 @@ void VideoCommon_DoState(PointerWrap& p) g_bounding_box->DoState(p); p.DoMarker("Bounding Box"); - // Refresh state. if (p.IsReadMode()) {