Lint fixes

This commit is contained in:
Scott Mansell 2023-01-31 17:29:16 +13:00
parent 11de923dcb
commit 31cfe8250d
39 changed files with 219 additions and 235 deletions

View File

@ -50,8 +50,8 @@ private:
CallbackType m_fn; CallbackType m_fn;
std::string m_name; std::string m_name;
}; };
public:
public:
// Returns a handle that will unregister the listener when destroyed. // Returns a handle that will unregister the listener when destroyed.
static EventHook Register(CallbackType callback, std::string name) static EventHook Register(CallbackType callback, std::string name)
{ {

View File

@ -8,10 +8,9 @@
// A useful template for passing string literals as arguments to templates // A useful template for passing string literals as arguments to templates
// from: https://ctrpeach.io/posts/cpp20-string-literal-template-parameters/ // from: https://ctrpeach.io/posts/cpp20-string-literal-template-parameters/
template <size_t N> template <size_t N>
struct StringLiteral { struct StringLiteral
consteval StringLiteral(const char (&str)[N]) { {
std::copy_n(str, N, value); consteval StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); }
}
char value[N]; char value[N];
}; };

View File

@ -132,12 +132,14 @@ static thread_local bool tls_is_gpu_thread = false;
static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi); static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi);
static EventHook s_frame_presented = AfterPresentEvent::Register([](auto& present_info) { static EventHook s_frame_presented = AfterPresentEvent::Register(
[](auto& present_info) {
const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator(); const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator();
// The denominator should always be > 0 but if it's not, just return 1 // 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; const double last_speed = last_speed_denominator > 0.0 ? (1.0 / last_speed_denominator) : 1.0;
Core::Callback_FramePresented(last_speed); Core::Callback_FramePresented(last_speed);
}, "Core Frame Presented"); },
"Core Frame Presented");
bool GetIsThrottlerTempDisabled() bool GetIsThrottlerTempDisabled()
{ {

View File

@ -18,9 +18,9 @@
#include "VideoCommon/CommandProcessor.h" #include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/TextureDecoder.h" #include "VideoCommon/TextureDecoder.h"
#include "VideoCommon/XFStructs.h"
#include "VideoCommon/XFMemory.h"
#include "VideoCommon/VideoEvents.h" #include "VideoCommon/VideoEvents.h"
#include "VideoCommon/XFMemory.h"
#include "VideoCommon/XFStructs.h"
class FifoRecorder::FifoRecordAnalyzer : public OpcodeDecoder::Callback class FifoRecorder::FifoRecordAnalyzer : public OpcodeDecoder::Callback
{ {
@ -255,7 +255,8 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
m_RequestedRecordingEnd = false; m_RequestedRecordingEnd = false;
m_FinishedCb = finishedCb; m_FinishedCb = finishedCb;
m_end_of_frame_event = AfterFrameEvent::Register([this] { m_end_of_frame_event = AfterFrameEvent::Register(
[this] {
const bool was_recording = OpcodeDecoder::g_record_fifo_data; const bool was_recording = OpcodeDecoder::g_record_fifo_data;
OpcodeDecoder::g_record_fifo_data = IsRecording(); OpcodeDecoder::g_record_fifo_data = IsRecording();
@ -272,7 +273,8 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
const auto& fifo = command_processor.GetFifo(); const auto& fifo = command_processor.GetFifo();
EndFrame(fifo.CPBase.load(std::memory_order_relaxed), EndFrame(fifo.CPBase.load(std::memory_order_relaxed),
fifo.CPEnd.load(std::memory_order_relaxed)); fifo.CPEnd.load(std::memory_order_relaxed));
}, "FifoRecorder::EndFrame"); },
"FifoRecorder::EndFrame");
} }
void FifoRecorder::RecordInitialVideoMemory() void FifoRecorder::RecordInitialVideoMemory()

View File

@ -78,9 +78,8 @@ Gfx::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::str
return DXShader::CreateFromBytecode(stage, std::move(*bytecode), name); return DXShader::CreateFromBytecode(stage, std::move(*bytecode), name);
} }
std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage, std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage, const void* data,
const void* data, size_t length, size_t length, std::string_view name)
std::string_view name)
{ {
return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name); return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name);
} }
@ -222,8 +221,8 @@ void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
SetFramebuffer(framebuffer); SetFramebuffer(framebuffer);
} }
void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value,
const ClearColor& color_value, float depth_value) float depth_value)
{ {
SetFramebuffer(framebuffer); SetFramebuffer(framebuffer);
D3D::stateman->Apply(); D3D::stateman->Apply();
@ -286,12 +285,9 @@ bool Gfx::IsFullscreen() const
SurfaceInfo Gfx::GetSurfaceInfo() const SurfaceInfo Gfx::GetSurfaceInfo() const
{ {
return { return {m_swap_chain ? static_cast<u32>(m_swap_chain->GetWidth()) : 0,
m_swap_chain ? static_cast<u32>(m_swap_chain->GetWidth()) : 0, m_swap_chain ? static_cast<u32>(m_swap_chain->GetHeight()) : 0, m_backbuffer_scale,
m_swap_chain ? static_cast<u32>(m_swap_chain->GetHeight()) : 0, m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined};
m_backbuffer_scale,
m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined
};
} }
} // namespace DX11 } // namespace DX11

View File

@ -13,8 +13,8 @@
#include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DBoundingBox.h" #include "VideoBackends/D3D/D3DBoundingBox.h"
#include "VideoBackends/D3D/D3DPerfQuery.h"
#include "VideoBackends/D3D/D3DGfx.h" #include "VideoBackends/D3D/D3DGfx.h"
#include "VideoBackends/D3D/D3DPerfQuery.h"
#include "VideoBackends/D3D/D3DSwapChain.h" #include "VideoBackends/D3D/D3DSwapChain.h"
#include "VideoBackends/D3D/D3DVertexManager.h" #include "VideoBackends/D3D/D3DVertexManager.h"
#include "VideoBackends/D3DCommon/D3DCommon.h" #include "VideoBackends/D3DCommon/D3DCommon.h"

View File

@ -114,8 +114,8 @@ void PerfQuery::FlushOne()
// NOTE: Reported pixel metrics should be referenced to native resolution // NOTE: Reported pixel metrics should be referenced to native resolution
// TODO: Dropping the lower 2 bits from this count should be closer to actual // TODO: Dropping the lower 2 bits from this count should be closer to actual
// hardware behavior when drawing triangles. // hardware behavior when drawing triangles.
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT / const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() *
g_framebuffer_manager->GetEFBHeight(); EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight();
m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result), m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result),
std::memory_order_relaxed); std::memory_order_relaxed);
@ -143,8 +143,8 @@ void PerfQuery::WeakFlush()
if (hr == S_OK) if (hr == S_OK)
{ {
// NOTE: Reported pixel metrics should be referenced to native resolution // NOTE: Reported pixel metrics should be referenced to native resolution
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT / const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() *
g_framebuffer_manager->GetEFBHeight(); EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight();
m_results[entry.query_group].store(static_cast<u32>(native_res_result), m_results[entry.query_group].store(static_cast<u32>(native_res_result),
std::memory_order_relaxed); std::memory_order_relaxed);

View File

@ -73,9 +73,8 @@ Gfx::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::str
return DXShader::CreateFromSource(stage, source, name); return DXShader::CreateFromSource(stage, source, name);
} }
std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage, std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage, const void* data,
const void* data, size_t length, size_t length, std::string_view name)
std::string_view name)
{ {
return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name); return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name);
} }
@ -103,8 +102,8 @@ void Gfx::WaitForGPUIdle()
ExecuteCommandList(true); ExecuteCommandList(true);
} }
void Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, void Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable,
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) bool alpha_enable, bool z_enable, u32 color, u32 z)
{ {
// Use a fast path without the shader if both color/alpha are enabled. // Use a fast path without the shader if both color/alpha are enabled.
const bool fast_color_clear = color_enable && alpha_enable; const bool fast_color_clear = color_enable && alpha_enable;
@ -229,8 +228,8 @@ void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
} }
} }
void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value,
const ClearColor& color_value, float depth_value) float depth_value)
{ {
DXFramebuffer* dxfb = static_cast<DXFramebuffer*>(framebuffer); DXFramebuffer* dxfb = static_cast<DXFramebuffer*>(framebuffer);
BindFramebuffer(dxfb); BindFramebuffer(dxfb);
@ -427,12 +426,9 @@ void Gfx::PresentBackbuffer()
SurfaceInfo Gfx::GetSurfaceInfo() const SurfaceInfo Gfx::GetSurfaceInfo() const
{ {
return { return {m_swap_chain ? static_cast<u32>(m_swap_chain->GetWidth()) : 0,
m_swap_chain ? static_cast<u32>(m_swap_chain->GetWidth()) : 0, m_swap_chain ? static_cast<u32>(m_swap_chain->GetHeight()) : 0, m_backbuffer_scale,
m_swap_chain ? static_cast<u32>(m_swap_chain->GetHeight()) : 0, m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined};
m_backbuffer_scale,
m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined
};
} }
void Gfx::OnConfigChanged(u32 bits) void Gfx::OnConfigChanged(u32 bits)

View File

@ -47,8 +47,8 @@ public:
void Flush() override; void Flush() override;
void WaitForGPUIdle() override; void WaitForGPUIdle() override;
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable, bool alpha_enable,
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override; bool z_enable, u32 color, u32 z) override;
void SetPipeline(const AbstractPipeline* pipeline) override; void SetPipeline(const AbstractPipeline* pipeline) override;
void SetFramebuffer(AbstractFramebuffer* framebuffer) override; void SetFramebuffer(AbstractFramebuffer* framebuffer) override;

View File

@ -11,8 +11,8 @@
#include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/Common.h"
#include "VideoBackends/D3D12/D3D12Gfx.h" #include "VideoBackends/D3D12/D3D12Gfx.h"
#include "VideoBackends/D3D12/DX12Context.h" #include "VideoBackends/D3D12/DX12Context.h"
#include "VideoCommon/VideoCommon.h"
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoCommon.h"
namespace DX12 namespace DX12
{ {

View File

@ -12,8 +12,8 @@
#include "VideoBackends/D3D12/Common.h" #include "VideoBackends/D3D12/Common.h"
#include "VideoBackends/D3D12/D3D12BoundingBox.h" #include "VideoBackends/D3D12/D3D12BoundingBox.h"
#include "VideoBackends/D3D12/D3D12PerfQuery.h"
#include "VideoBackends/D3D12/D3D12Gfx.h" #include "VideoBackends/D3D12/D3D12Gfx.h"
#include "VideoBackends/D3D12/D3D12PerfQuery.h"
#include "VideoBackends/D3D12/D3D12SwapChain.h" #include "VideoBackends/D3D12/D3D12SwapChain.h"
#include "VideoBackends/D3D12/D3D12VertexManager.h" #include "VideoBackends/D3D12/D3D12VertexManager.h"
#include "VideoBackends/D3D12/DX12Context.h" #include "VideoBackends/D3D12/DX12Context.h"

View File

@ -47,8 +47,8 @@ public:
void WaitForGPUIdle() override; void WaitForGPUIdle() override;
void OnConfigChanged(u32 bits) override; void OnConfigChanged(u32 bits) override;
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable, bool alpha_enable,
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override; bool z_enable, u32 color, u32 z) override;
void SetPipeline(const AbstractPipeline* pipeline) override; void SetPipeline(const AbstractPipeline* pipeline) override;
void SetFramebuffer(AbstractFramebuffer* framebuffer) override; void SetFramebuffer(AbstractFramebuffer* framebuffer) override;

View File

@ -18,8 +18,7 @@
#include <fstream> #include <fstream>
Metal::Gfx::Gfx(MRCOwned<CAMetalLayer*> layer) Metal::Gfx::Gfx(MRCOwned<CAMetalLayer*> layer) : m_layer(std::move(layer))
: m_layer(std::move(layer))
{ {
UpdateActiveConfig(); UpdateActiveConfig();
[m_layer setDisplaySyncEnabled:g_ActiveConfig.bVSyncActive]; [m_layer setDisplaySyncEnabled:g_ActiveConfig.bVSyncActive];
@ -94,8 +93,7 @@ Metal::Gfx::CreateStagingTexture(StagingTextureType type, const TextureConfig& c
} }
std::unique_ptr<AbstractFramebuffer> std::unique_ptr<AbstractFramebuffer>
Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment, Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment)
AbstractTexture* depth_attachment)
{ {
AbstractTexture* const either_attachment = color_attachment ? color_attachment : depth_attachment; AbstractTexture* const either_attachment = color_attachment ? color_attachment : depth_attachment;
return std::make_unique<Framebuffer>( return std::make_unique<Framebuffer>(
@ -121,8 +119,7 @@ std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromSource(ShaderStage s
} }
std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromBinary(ShaderStage stage, std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromBinary(ShaderStage stage,
const void* data, const void* data, size_t length,
size_t length,
std::string_view name) std::string_view name)
{ {
return CreateShaderFromMSL(stage, std::string(static_cast<const char*>(data), length), {}, name); return CreateShaderFromMSL(stage, std::string(static_cast<const char*>(data), length), {}, name);
@ -154,8 +151,7 @@ static NSString* GenericShaderName(ShaderStage stage)
// clang-format on // clang-format on
std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromMSL(ShaderStage stage, std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromMSL(ShaderStage stage, std::string msl,
std::string msl,
std::string_view glsl, std::string_view glsl,
std::string_view name) std::string_view name)
{ {
@ -247,8 +243,8 @@ Metal::Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
} }
} }
std::unique_ptr<AbstractPipeline> std::unique_ptr<AbstractPipeline> Metal::Gfx::CreatePipeline(const AbstractPipelineConfig& config,
Metal::Gfx::CreatePipeline(const AbstractPipelineConfig& config, const void* cache_data, const void* cache_data,
size_t cache_data_length) size_t cache_data_length)
{ {
return g_object_cache->CreatePipeline(config); return g_object_cache->CreatePipeline(config);
@ -285,8 +281,8 @@ void Metal::Gfx::OnConfigChanged(u32 bits)
} }
} }
void Metal::Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, void Metal::Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable,
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) bool alpha_enable, bool z_enable, u32 color, u32 z)
{ {
u32 framebuffer_width = m_current_framebuffer->GetWidth(); u32 framebuffer_width = m_current_framebuffer->GetWidth();
u32 framebuffer_height = m_current_framebuffer->GetHeight(); u32 framebuffer_height = m_current_framebuffer->GetHeight();
@ -491,7 +487,8 @@ void Metal::Gfx::SetupSurface()
[m_layer setDrawableSize:{static_cast<double>(info.width), static_cast<double>(info.height)}]; [m_layer setDrawableSize:{static_cast<double>(info.width), static_cast<double>(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<Texture>(nullptr, cfg); m_bb_texture = std::make_unique<Texture>(nullptr, cfg);
m_backbuffer = std::make_unique<Framebuffer>(m_bb_texture.get(), nullptr, // m_backbuffer = std::make_unique<Framebuffer>(m_bb_texture.get(), nullptr, //
info.width, info.height, 1, 1); info.width, info.height, 1, 1);
@ -508,10 +505,6 @@ SurfaceInfo Metal::Gfx::GetSurfaceInfo() const
CGSize size = [m_layer bounds].size; CGSize size = [m_layer bounds].size;
const float scale = [m_layer contentsScale]; const float scale = [m_layer contentsScale];
return { return {static_cast<u32>(size.width * scale), static_cast<u32>(size.height * scale), scale,
static_cast<u32>(size.width * scale), Util::ToAbstract([m_layer pixelFormat])};
static_cast<u32>(size.height * scale),
scale,
Util::ToAbstract([m_layer pixelFormat])
};
} }

View File

@ -77,7 +77,8 @@ void Metal::PerfQuery::ReturnResults(const u64* data, const PerfQueryGroup* grou
{ {
for (size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i)
{ {
u64 native_res_result = data[i] * (EFB_WIDTH * EFB_HEIGHT) / u64 native_res_result =
data[i] * (EFB_WIDTH * EFB_HEIGHT) /
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); (g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight());
native_res_result /= g_ActiveConfig.iMultisamples; native_res_result /= g_ActiveConfig.iMultisamples;

View File

@ -42,8 +42,8 @@ public:
void SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) override; void SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) override;
void SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value = {}, void SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value = {},
float depth_value = 0.0f) override; float depth_value = 0.0f) override;
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool colorEnable, bool alphaEnable,
bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override; bool zEnable, u32 color, u32 z) override;
void SetScissorRect(const MathUtil::Rectangle<int>& rc) override; void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
void SetTexture(u32 index, const AbstractTexture* texture) override; void SetTexture(u32 index, const AbstractTexture* texture) override;
void SetSamplerState(u32 index, const SamplerState& state) override; void SetSamplerState(u32 index, const SamplerState& state) override;

View File

@ -264,7 +264,8 @@ void PerfQueryGLESNV::FlushOne()
// NOTE: Reported pixel metrics should be referenced to native resolution // NOTE: Reported pixel metrics should be referenced to native resolution
// TODO: Dropping the lower 2 bits from this count should be closer to actual // TODO: Dropping the lower 2 bits from this count should be closer to actual
// hardware behavior when drawing triangles. // hardware behavior when drawing triangles.
const u64 native_res_result = static_cast<u64>(result) * EFB_WIDTH * EFB_HEIGHT / const u64 native_res_result =
static_cast<u64>(result) * EFB_WIDTH * EFB_HEIGHT /
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); (g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight());
m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result), m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result),
std::memory_order_relaxed); std::memory_order_relaxed);

View File

@ -46,8 +46,8 @@ public:
void SetScissorRect(const MathUtil::Rectangle<int>& rc) override; void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool colorEnable, bool alphaEnable,
bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override; bool zEnable, u32 color, u32 z) override;
private: private:
std::unique_ptr<SWOGLWindow> m_window; std::unique_ptr<SWOGLWindow> m_window;

View File

@ -53,8 +53,8 @@ public:
void WaitForGPUIdle() override; void WaitForGPUIdle() override;
void OnConfigChanged(u32 bits) override; void OnConfigChanged(u32 bits) override;
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable, bool alpha_enable,
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override; bool z_enable, u32 color, u32 z) override;
void SetPipeline(const AbstractPipeline* pipeline) override; void SetPipeline(const AbstractPipeline* pipeline) override;
void SetFramebuffer(AbstractFramebuffer* framebuffer) override; void SetFramebuffer(AbstractFramebuffer* framebuffer) override;

View File

@ -15,8 +15,8 @@
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoState.h"
#include "VideoCommon/VideoEvents.h" #include "VideoCommon/VideoEvents.h"
#include "VideoCommon/VideoState.h"
AsyncRequests AsyncRequests::s_singleton; AsyncRequests AsyncRequests::s_singleton;

View File

@ -31,9 +31,9 @@
#include "VideoCommon/GeometryShaderManager.h" #include "VideoCommon/GeometryShaderManager.h"
#include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/PerfQueryBase.h" #include "VideoCommon/PerfQueryBase.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/Statistics.h" #include "VideoCommon/Statistics.h"
#include "VideoCommon/TMEM.h" #include "VideoCommon/TMEM.h"
@ -346,7 +346,6 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager,
// It works 99% of the time. // It works 99% of the time.
AfterFrameEvent::Trigger(); AfterFrameEvent::Trigger();
if (g_ActiveConfig.bImmediateXFB) if (g_ActiveConfig.bImmediateXFB)
{ {
// below div two to convert from bytes to pixels - it expects width, not stride // below div two to convert from bytes to pixels - it expects width, not stride

View File

@ -149,16 +149,14 @@ static u32 CalculateEFBLayers()
TextureConfig FramebufferManager::GetEFBColorTextureConfig(u32 width, u32 height) TextureConfig FramebufferManager::GetEFBColorTextureConfig(u32 width, u32 height)
{ {
return TextureConfig(width, height, 1, return TextureConfig(width, height, 1, CalculateEFBLayers(), g_ActiveConfig.iMultisamples,
CalculateEFBLayers(), g_ActiveConfig.iMultisamples, GetEFBColorFormat(), GetEFBColorFormat(), AbstractTextureFlag_RenderTarget);
AbstractTextureFlag_RenderTarget);
} }
TextureConfig FramebufferManager::GetEFBDepthTextureConfig(u32 width, u32 height) TextureConfig FramebufferManager::GetEFBDepthTextureConfig(u32 width, u32 height)
{ {
return TextureConfig(width, height, 1, return TextureConfig(width, height, 1, CalculateEFBLayers(), g_ActiveConfig.iMultisamples,
CalculateEFBLayers(), g_ActiveConfig.iMultisamples, GetEFBDepthFormat(), GetEFBDepthFormat(), AbstractTextureFlag_RenderTarget);
AbstractTextureFlag_RenderTarget);
} }
FramebufferState FramebufferManager::GetEFBFramebufferState() const FramebufferState FramebufferManager::GetEFBFramebufferState() const
@ -905,8 +903,7 @@ bool FramebufferManager::CompileClearPipelines()
config.depth_state.testenable = depth_enable != 0; config.depth_state.testenable = depth_enable != 0;
config.depth_state.updateenable = depth_enable != 0; config.depth_state.updateenable = depth_enable != 0;
m_clear_pipelines[color_enable][alpha_enable][depth_enable] = m_clear_pipelines[color_enable][alpha_enable][depth_enable] = g_gfx->CreatePipeline(config);
g_gfx->CreatePipeline(config);
if (!m_clear_pipelines[color_enable][alpha_enable][depth_enable]) if (!m_clear_pipelines[color_enable][alpha_enable][depth_enable])
return false; return false;
} }

View File

@ -226,8 +226,7 @@ protected:
// EFB clear pipelines // EFB clear pipelines
// Indexed by [color_write_enabled][alpha_write_enabled][depth_write_enabled] // Indexed by [color_write_enabled][alpha_write_enabled][depth_write_enabled]
std::array<std::array<std::array<std::unique_ptr<AbstractPipeline>, 2>, 2>, 2> std::array<std::array<std::array<std::unique_ptr<AbstractPipeline>, 2>, 2>, 2> m_clear_pipelines;
m_clear_pipelines;
// EFB poke drawing setup // EFB poke drawing setup
std::unique_ptr<NativeVertexFormat> m_poke_vertex_format; std::unique_ptr<NativeVertexFormat> m_poke_vertex_format;

View File

@ -13,8 +13,8 @@
#include "VideoCommon/GraphicsModSystem/Runtime/FBInfo.h" #include "VideoCommon/GraphicsModSystem/Runtime/FBInfo.h"
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModAction.h"
#include "VideoCommon/TextureInfo.h" #include "VideoCommon/TextureInfo.h"
#include "VideoCommon/XFMemory.h"
#include "VideoCommon/VideoEvents.h" #include "VideoCommon/VideoEvents.h"
#include "VideoCommon/XFMemory.h"
class GraphicsModGroupConfig; class GraphicsModGroupConfig;
class GraphicsModManager class GraphicsModManager

View File

@ -16,7 +16,6 @@ class AbstractPipeline;
namespace VideoCommon namespace VideoCommon
{ {
// OnScreenUI handles all the ImGui rendering. // OnScreenUI handles all the ImGui rendering.
class OnScreenUI class OnScreenUI
{ {

View File

@ -74,7 +74,8 @@ void PixelShaderManager::Dirty()
// Any constants that can changed based on settings should be re-calculated // Any constants that can changed based on settings should be re-calculated
m_fog_range_adjusted_changed = true; 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(); SetFogParamChanged();
dirty = true; 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 // so to simplify I use the hi coefficient as K in the shader taking 256 as the scale
// TODO: Shouldn't this be EFBToScaledXf? // TODO: Shouldn't this be EFBToScaledXf?
constants.fogf[2] = ScreenSpaceCenter; constants.fogf[2] = ScreenSpaceCenter;
constants.fogf[3] = constants.fogf[3] = static_cast<float>(
static_cast<float>(g_framebuffer_manager->EFBToScaledX(static_cast<int>(2.0f * xfmem.viewport.wd))); g_framebuffer_manager->EFBToScaledX(static_cast<int>(2.0f * xfmem.viewport.wd)));
for (size_t i = 0, vec_index = 0; i < std::size(bpmem.fogRange.K); i++) for (size_t i = 0, vec_index = 0; i < std::size(bpmem.fogRange.K); i++)
{ {

View File

@ -9,6 +9,7 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "Present.h"
#include "VideoCommon/AbstractGfx.h" #include "VideoCommon/AbstractGfx.h"
#include "VideoCommon/FrameDumper.h" #include "VideoCommon/FrameDumper.h"
#include "VideoCommon/OnScreenUI.h" #include "VideoCommon/OnScreenUI.h"
@ -18,7 +19,6 @@
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoEvents.h" #include "VideoCommon/VideoEvents.h"
#include "Present.h"
std::unique_ptr<VideoCommon::Presenter> g_presenter; std::unique_ptr<VideoCommon::Presenter> g_presenter;
@ -67,7 +67,8 @@ bool Presenter::FetchXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_heigh
{ {
ReleaseXFBContentLock(); 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; bool is_duplicate = m_xfb_entry->id == m_last_xfb_id;
m_xfb_entry->AcquireContentLock(); m_xfb_entry->AcquireContentLock();
@ -605,11 +606,9 @@ void Presenter::DoState(PointerWrap& p)
AfterFrameEvent::Trigger(); AfterFrameEvent::Trigger();
// re-display the most recent XFB // re-display the most recent XFB
ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, ImmediateSwap(m_last_xfb_addr, m_last_xfb_width, m_last_xfb_stride, m_last_xfb_height,
m_last_xfb_height, m_last_xfb_ticks); m_last_xfb_ticks);
} }
} }
} // namespace VideoCommon } // namespace VideoCommon

View File

@ -31,31 +31,32 @@
#include "Core/System.h" #include "Core/System.h"
#include "VideoCommon/AbstractGfx.h" #include "VideoCommon/AbstractGfx.h"
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/BoundingBox.h" #include "VideoCommon/BoundingBox.h"
#include "VideoCommon/BPFunctions.h"
#include "VideoCommon/FrameDumper.h" #include "VideoCommon/FrameDumper.h"
#include "VideoCommon/FramebufferManager.h" #include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelEngine.h"
#include "VideoCommon/Present.h" #include "VideoCommon/Present.h"
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoCommon.h"
#include "VideoCommon/VideoConfig.h"
#include "VideoCommon/XFMemory.h" #include "VideoCommon/XFMemory.h"
std::unique_ptr<Renderer> g_renderer; std::unique_ptr<Renderer> g_renderer;
Renderer::Renderer() Renderer::Renderer() : m_prev_efb_format{PixelFormat::INVALID_FMT}
: m_prev_efb_format{PixelFormat::INVALID_FMT}
{ {
UpdateWidescreen(); 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. // VertexManager doesn't maintain statistics in Wii mode.
if (!SConfig::GetInstance().bWii) 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; Renderer::~Renderer() = default;

View File

@ -1,7 +1,6 @@
// Copyright 2010 Dolphin Emulator Project // Copyright 2010 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#pragma once #pragma once
#include <memory> #include <memory>

View File

@ -46,7 +46,8 @@ bool ShaderCache::Initialize()
return false; return false;
m_async_shader_compiler = g_gfx->CreateAsyncShaderCompiler(); 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; return true;
} }

View File

@ -18,17 +18,18 @@
Statistics g_stats; Statistics g_stats;
static EventHook s_before_frame_event = BeforeFrameEvent::Register([] { static EventHook s_before_frame_event =
g_stats.ResetFrame(); BeforeFrameEvent::Register([] { g_stats.ResetFrame(); }, "Statistics::ResetFrame");
}, "Statistics::ResetFrame");
static EventHook s_after_frame_event = AfterFrameEvent::Register([] { static EventHook s_after_frame_event = AfterFrameEvent::Register(
[] {
DolphinAnalytics::PerformanceSample perf_sample; DolphinAnalytics::PerformanceSample perf_sample;
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance(); 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_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; perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls;
DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample)); DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample));
}, "Statistics::PerformanceSample"); },
"Statistics::PerformanceSample");
static bool clear_scissors; static bool clear_scissors;

View File

@ -920,8 +920,8 @@ RcTcacheEntry TextureCacheBase::DoPartialTextureUpdates(RcTcacheEntry& entry_to_
entry_to_update->native_height != entry_to_update->GetHeight() || entry_to_update->native_height != entry_to_update->GetHeight() ||
entry->native_width != entry->GetWidth() || entry->native_height != entry->GetHeight()) entry->native_width != entry->GetWidth() || entry->native_height != entry->GetHeight())
{ {
ScaleTextureCacheEntryTo(entry_to_update, ScaleTextureCacheEntryTo(
g_framebuffer_manager->EFBToScaledX(entry_to_update->native_width), entry_to_update, g_framebuffer_manager->EFBToScaledX(entry_to_update->native_width),
g_framebuffer_manager->EFBToScaledY(entry_to_update->native_height)); g_framebuffer_manager->EFBToScaledY(entry_to_update->native_height));
ScaleTextureCacheEntryTo(entry, g_framebuffer_manager->EFBToScaledX(entry->native_width), ScaleTextureCacheEntryTo(entry, g_framebuffer_manager->EFBToScaledX(entry->native_width),
g_framebuffer_manager->EFBToScaledY(entry->native_height)); g_framebuffer_manager->EFBToScaledY(entry->native_height));
@ -1957,7 +1957,8 @@ void TextureCacheBase::StitchXFBCopy(RcTcacheEntry& stitched_entry)
// copies to be stitched together. // copies to be stitched together.
if (create_upscaled_copy) 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)); 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 // 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. // complex down filtering to average all pixels and produce the correct result.
const bool linear_filter = 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; RcTcacheEntry entry;
if (copy_to_vram) if (copy_to_vram)

View File

@ -562,8 +562,7 @@ void VertexManagerBase::Flush()
{ {
bool skip = false; bool skip = false;
GraphicsModActionData::DrawStarted draw_started{&skip}; GraphicsModActionData::DrawStarted draw_started{&skip};
for (const auto action : for (const auto action : g_graphics_mod_manager->GetDrawStartedActions(texture_name))
g_graphics_mod_manager->GetDrawStartedActions(texture_name))
{ {
action->OnDrawStarted(&draw_started); action->OnDrawStarted(&draw_started);
} }

View File

@ -388,16 +388,15 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures)
std::vector<GraphicsModAction*> projection_actions; std::vector<GraphicsModAction*> projection_actions;
if (g_ActiveConfig.bGraphicMods) if (g_ActiveConfig.bGraphicMods)
{ {
for (const auto action : for (const auto action : g_graphics_mod_manager->GetProjectionActions(xfmem.projection.type))
g_graphics_mod_manager->GetProjectionActions(xfmem.projection.type))
{ {
projection_actions.push_back(action); projection_actions.push_back(action);
} }
for (const auto& texture : textures) for (const auto& texture : textures)
{ {
for (const auto action : g_graphics_mod_manager->GetProjectionTextureActions( for (const auto action :
xfmem.projection.type, texture)) g_graphics_mod_manager->GetProjectionTextureActions(xfmem.projection.type, texture))
{ {
projection_actions.push_back(action); projection_actions.push_back(action);
} }

View File

@ -24,8 +24,8 @@
#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h" #include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h" #include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/Present.h"
#include "VideoCommon/ShaderGenCommon.h" #include "VideoCommon/ShaderGenCommon.h"
#include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/TextureCacheBase.h"
#include "VideoCommon/VertexManagerBase.h" #include "VideoCommon/VertexManagerBase.h"
@ -355,7 +355,8 @@ void CheckForConfigChanges()
// TODO: Move everything else to the ConfigChanged event // TODO: Move everything else to the ConfigChanged event
} }
static EventHook s_check_config_event = AfterFrameEvent::Register([] { static EventHook s_check_config_event = AfterFrameEvent::Register(
[] {
CheckForConfigChanges(); CheckForConfigChanges();
},
}, "CheckForConfigChanges"); "CheckForConfigChanges");

View File

@ -59,7 +59,6 @@ enum class TriState : int
Auto Auto
}; };
// Bitmask containing information about which configuration has changed for the backend. // Bitmask containing information about which configuration has changed for the backend.
enum ConfigChangeBits : u32 enum ConfigChangeBits : u32
{ {

View File

@ -6,7 +6,6 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/EventHook.h" #include "Common/EventHook.h"
// Called when certain video config setting are changed // Called when certain video config setting are changed
using ConfigChangedEvent = Event<"ConfigChanged", u32>; using ConfigChangedEvent = Event<"ConfigChanged", u32>;
@ -31,7 +30,6 @@ struct PresentInfo
// The number of (unique) frames since the emulated console booted // The number of (unique) frames since the emulated console booted
u64 frame_count; u64 frame_count;
// The number of presents since the video backend was initialized. // The number of presents since the video backend was initialized.
// never goes backwards. // never goes backwards.
u64 present_count; u64 present_count;
@ -74,7 +72,8 @@ struct PresentInfo
// The exact timing of this event depends on the "Immediately Present XFB" option. // The exact timing of this event depends on the "Immediately Present XFB" option.
// //
// If enabled, this event will trigger immediately after AfterFrame // 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 // frame_count: The number of frames
using BeforePresentEvent = Event<"BeforePresent", PresentInfo&>; using BeforePresentEvent = Event<"BeforePresent", PresentInfo&>;

View File

@ -7,14 +7,14 @@
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Core/System.h" #include "Core/System.h"
#include "VideoCommon/BoundingBox.h"
#include "VideoCommon/BPMemory.h" #include "VideoCommon/BPMemory.h"
#include "VideoCommon/BPStructs.h" #include "VideoCommon/BPStructs.h"
#include "VideoCommon/BoundingBox.h"
#include "VideoCommon/CPMemory.h" #include "VideoCommon/CPMemory.h"
#include "VideoCommon/CommandProcessor.h" #include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/Fifo.h" #include "VideoCommon/Fifo.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/FrameDumper.h" #include "VideoCommon/FrameDumper.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/GeometryShaderManager.h" #include "VideoCommon/GeometryShaderManager.h"
#include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/PixelShaderManager.h"
@ -105,7 +105,6 @@ void VideoCommon_DoState(PointerWrap& p)
g_bounding_box->DoState(p); g_bounding_box->DoState(p);
p.DoMarker("Bounding Box"); p.DoMarker("Bounding Box");
// Refresh state. // Refresh state.
if (p.IsReadMode()) if (p.IsReadMode())
{ {