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

@ -36,7 +36,7 @@ struct HookBase
using EventHook = std::unique_ptr<HookBase>; using EventHook = std::unique_ptr<HookBase>;
template<StringLiteral EventName, typename... CallbackArgs> template <StringLiteral EventName, typename... CallbackArgs>
class Event class Event
{ {
public: public:
@ -46,12 +46,12 @@ private:
struct HookImpl : public HookBase struct HookImpl : public HookBase
{ {
~HookImpl() override { Event::Remove(this); } ~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; 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

@ -7,11 +7,10 @@
// 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(
const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator(); [](auto& present_info) {
// The denominator should always be > 0 but if it's not, just return 1 const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator();
const double last_speed = last_speed_denominator > 0.0 ? (1.0 / last_speed_denominator) : 1.0; // The denominator should always be > 0 but if it's not, just return 1
Core::Callback_FramePresented(last_speed); const double last_speed = last_speed_denominator > 0.0 ? (1.0 / last_speed_denominator) : 1.0;
}, "Core Frame Presented"); Core::Callback_FramePresented(last_speed);
},
"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,24 +255,26 @@ 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(
const bool was_recording = OpcodeDecoder::g_record_fifo_data; [this] {
OpcodeDecoder::g_record_fifo_data = IsRecording(); const bool was_recording = OpcodeDecoder::g_record_fifo_data;
OpcodeDecoder::g_record_fifo_data = IsRecording();
if (!OpcodeDecoder::g_record_fifo_data) if (!OpcodeDecoder::g_record_fifo_data)
return; return;
if (!was_recording) if (!was_recording)
{ {
RecordInitialVideoMemory(); RecordInitialVideoMemory();
} }
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
auto& command_processor = system.GetCommandProcessor(); auto& command_processor = system.GetCommandProcessor();
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

@ -50,19 +50,19 @@ bool Gfx::IsHeadless() const
} }
std::unique_ptr<AbstractTexture> Gfx::CreateTexture(const TextureConfig& config, std::unique_ptr<AbstractTexture> Gfx::CreateTexture(const TextureConfig& config,
std::string_view name) std::string_view name)
{ {
return DXTexture::Create(config, name); return DXTexture::Create(config, name);
} }
std::unique_ptr<AbstractStagingTexture> Gfx::CreateStagingTexture(StagingTextureType type, std::unique_ptr<AbstractStagingTexture> Gfx::CreateStagingTexture(StagingTextureType type,
const TextureConfig& config) const TextureConfig& config)
{ {
return DXStagingTexture::Create(type, config); return DXStagingTexture::Create(type, config);
} }
std::unique_ptr<AbstractFramebuffer> Gfx::CreateFramebuffer(AbstractTexture* color_attachment, std::unique_ptr<AbstractFramebuffer> Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
AbstractTexture* depth_attachment) AbstractTexture* depth_attachment)
{ {
return DXFramebuffer::Create(static_cast<DXTexture*>(color_attachment), return DXFramebuffer::Create(static_cast<DXTexture*>(color_attachment),
static_cast<DXTexture*>(depth_attachment)); static_cast<DXTexture*>(depth_attachment));
@ -78,16 +78,15 @@ 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);
} }
std::unique_ptr<AbstractPipeline> Gfx::CreatePipeline(const AbstractPipelineConfig& config, std::unique_ptr<AbstractPipeline> Gfx::CreatePipeline(const AbstractPipelineConfig& config,
const void* cache_data, const void* cache_data,
size_t cache_data_length) size_t cache_data_length)
{ {
return DXPipeline::Create(config); return DXPipeline::Create(config);
} }
@ -129,7 +128,7 @@ void Gfx::SetScissorRect(const MathUtil::Rectangle<int>& rc)
} }
void Gfx::SetViewport(float x, float y, float width, float height, float near_depth, void Gfx::SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth) float far_depth)
{ {
// TODO: Move to stateman // TODO: Move to stateman
const CD3D11_VIEWPORT vp(x, y, width, height, near_depth, far_depth); 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, 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<const DXShader*>(shader)->GetD3DComputeShader()); D3D::stateman->SetComputeShader(static_cast<const DXShader*>(shader)->GetD3DComputeShader());
D3D::stateman->SyncComputeBindings(); D3D::stateman->SyncComputeBindings();
@ -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"
@ -161,7 +161,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
auto bounding_box = std::make_unique<D3DBoundingBox>(); auto bounding_box = std::make_unique<D3DBoundingBox>();
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query), return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
std::move(bounding_box)); std::move(bounding_box));
} }
void VideoBackend::Shutdown() void VideoBackend::Shutdown()

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

@ -49,19 +49,19 @@ bool Gfx::IsHeadless() const
} }
std::unique_ptr<AbstractTexture> Gfx::CreateTexture(const TextureConfig& config, std::unique_ptr<AbstractTexture> Gfx::CreateTexture(const TextureConfig& config,
std::string_view name) std::string_view name)
{ {
return DXTexture::Create(config, name); return DXTexture::Create(config, name);
} }
std::unique_ptr<AbstractStagingTexture> Gfx::CreateStagingTexture(StagingTextureType type, std::unique_ptr<AbstractStagingTexture> Gfx::CreateStagingTexture(StagingTextureType type,
const TextureConfig& config) const TextureConfig& config)
{ {
return DXStagingTexture::Create(type, config); return DXStagingTexture::Create(type, config);
} }
std::unique_ptr<AbstractFramebuffer> Gfx::CreateFramebuffer(AbstractTexture* color_attachment, std::unique_ptr<AbstractFramebuffer> Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
AbstractTexture* depth_attachment) AbstractTexture* depth_attachment)
{ {
return DXFramebuffer::Create(static_cast<DXTexture*>(color_attachment), return DXFramebuffer::Create(static_cast<DXTexture*>(color_attachment),
static_cast<DXTexture*>(depth_attachment)); static_cast<DXTexture*>(depth_attachment));
@ -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);
} }
@ -87,8 +86,8 @@ Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
} }
std::unique_ptr<AbstractPipeline> Gfx::CreatePipeline(const AbstractPipelineConfig& config, std::unique_ptr<AbstractPipeline> Gfx::CreatePipeline(const AbstractPipelineConfig& config,
const void* cache_data, const void* cache_data,
size_t cache_data_length) size_t cache_data_length)
{ {
return DXPipeline::Create(config, cache_data, cache_data_length); return DXPipeline::Create(config, cache_data, cache_data_length);
} }
@ -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);
@ -318,7 +317,7 @@ void Gfx::UnbindTexture(const AbstractTexture* texture)
} }
void Gfx::SetViewport(float x, float y, float width, float height, float near_depth, 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 && if (m_state.viewport.TopLeftX == x && m_state.viewport.TopLeftY == y &&
m_state.viewport.Width == width && m_state.viewport.Height == height && 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, 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(); SetRootSignatures();
SetDescriptorHeaps(); SetDescriptorHeaps();
@ -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)
@ -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, 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 || if (m_state.vertex_buffer.BufferLocation != address ||
m_state.vertex_buffer.StrideInBytes != stride || m_state.vertex_buffer.SizeInBytes != size) m_state.vertex_buffer.StrideInBytes != stride || m_state.vertex_buffer.SizeInBytes != size)

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

@ -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<int>(index_data_size)); ADDSTAT(g_stats.this_frame.bytes_index_streamed, static_cast<int>(index_data_size));
Gfx::GetInstance()->SetVertexBuffer(m_vertex_stream_buffer.GetGPUPointer(), Gfx::GetInstance()->SetVertexBuffer(m_vertex_stream_buffer.GetGPUPointer(),
m_vertex_srv.cpu_handle, vertex_stride, m_vertex_srv.cpu_handle, vertex_stride,
m_vertex_stream_buffer.GetSize()); m_vertex_stream_buffer.GetSize());
Gfx::GetInstance()->SetIndexBuffer(m_index_stream_buffer.GetGPUPointer(), 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() void VertexManager::UploadUniforms()
@ -235,11 +235,11 @@ void VertexManager::UploadAllConstants()
// Update bindings // Update bindings
Gfx::GetInstance()->SetConstantBuffer(0, m_uniform_stream_buffer.GetCurrentGPUPointer() + Gfx::GetInstance()->SetConstantBuffer(0, m_uniform_stream_buffer.GetCurrentGPUPointer() +
pixel_constants_offset); pixel_constants_offset);
Gfx::GetInstance()->SetConstantBuffer(1, m_uniform_stream_buffer.GetCurrentGPUPointer() + Gfx::GetInstance()->SetConstantBuffer(1, m_uniform_stream_buffer.GetCurrentGPUPointer() +
vertex_constants_offset); vertex_constants_offset);
Gfx::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer() + Gfx::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer() +
geometry_constants_offset); geometry_constants_offset);
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
auto& pixel_shader_manager = system.GetPixelShaderManager(); auto& pixel_shader_manager = system.GetPixelShaderManager();

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];
@ -38,7 +37,7 @@ bool Metal::Gfx::IsHeadless() const
// MARK: Texture Creation // MARK: Texture Creation
std::unique_ptr<AbstractTexture> Metal::Gfx::CreateTexture(const TextureConfig& config, std::unique_ptr<AbstractTexture> Metal::Gfx::CreateTexture(const TextureConfig& config,
std::string_view name) std::string_view name)
{ {
@autoreleasepool @autoreleasepool
{ {
@ -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>(
@ -107,8 +105,8 @@ Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
// MARK: Pipeline Creation // MARK: Pipeline Creation
std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromSource(ShaderStage stage, std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromSource(ShaderStage stage,
std::string_view source, std::string_view source,
std::string_view name) std::string_view name)
{ {
std::optional<std::string> msl = Util::TranslateShaderToMSL(stage, source); std::optional<std::string> msl = Util::TranslateShaderToMSL(stage, source);
if (!msl.has_value()) if (!msl.has_value())
@ -121,9 +119,8 @@ 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,10 +151,9 @@ 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)
{ {
@autoreleasepool @autoreleasepool
{ {
@ -247,9 +243,9 @@ 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();
@ -362,7 +358,7 @@ void Metal::Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
} }
void Metal::Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, void Metal::Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
const ClearColor& color_value, float depth_value) const ClearColor& color_value, float depth_value)
{ {
@autoreleasepool @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, 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); 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, // void Metal::Gfx::DispatchComputeShader(const AbstractShader* shader, //
u32 groupsize_x, u32 groupsize_y, u32 groupsize_z, u32 groupsize_x, u32 groupsize_y, u32 groupsize_z,
u32 groups_x, u32 groups_y, u32 groups_z) u32 groups_x, u32 groups_y, u32 groups_z)
{ {
@autoreleasepool @autoreleasepool
{ {
@ -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);
@ -502,16 +499,12 @@ void Metal::Gfx::SetupSurface()
SurfaceInfo Metal::Gfx::GetSurfaceInfo() const SurfaceInfo Metal::Gfx::GetSurfaceInfo() const
{ {
if (!m_layer) // Headless if (!m_layer) // Headless
return {}; return {};
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,8 +77,9 @@ 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 =
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); data[i] * (EFB_WIDTH * EFB_HEIGHT) /
(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,8 +264,9 @@ 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 =
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight()); static_cast<u64>(result) * EFB_WIDTH * EFB_HEIGHT /
(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

@ -240,7 +240,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
auto bounding_box = std::make_unique<VKBoundingBox>(); auto bounding_box = std::make_unique<VKBoundingBox>();
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query), return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
std::move(bounding_box)); std::move(bounding_box));
} }
void VideoBackend::Shutdown() void VideoBackend::Shutdown()

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();
@ -95,7 +96,7 @@ void Presenter::ViSwap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
} }
else 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.reason = PresentInfo::PresentReason::VideoInterfaceDuplicate;
} }
present_info.present_count = m_present_count; present_info.present_count = m_present_count;
@ -308,7 +309,7 @@ void Presenter::ResizeSurface()
void* Presenter::GetNewSurfaceHandle() void* Presenter::GetNewSurfaceHandle()
{ {
void *handle = m_new_surface_handle; void* handle = m_new_surface_handle;
m_new_surface_handle = nullptr; m_new_surface_handle = nullptr;
return handle; return handle;
} }
@ -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; [] {
perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance(); DolphinAnalytics::PerformanceSample perf_sample;
perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims; perf_sample.speed_ratio = SystemTimers::GetEstimatedEmulationPerformance();
perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls; perf_sample.num_prims = g_stats.this_frame.num_prims + g_stats.this_frame.num_dl_prims;
DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample)); perf_sample.num_draw_calls = g_stats.this_frame.num_draw_calls;
}, "Statistics::PerformanceSample"); DolphinAnalytics::Instance().ReportPerformanceInfo(std::move(perf_sample));
},
"Statistics::PerformanceSample");
static bool clear_scissors; static bool clear_scissors;

View File

@ -773,7 +773,7 @@ void TextureCacheBase::OnFrameEnd()
{ {
if (m_force_reload_textures.TestAndClear()) if (m_force_reload_textures.TestAndClear())
{ {
ForceReload(); ForceReload();
} }
else else
{ {
@ -920,9 +920,9 @@ 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

@ -104,7 +104,7 @@ VertexManagerBase::~VertexManagerBase() = default;
bool VertexManagerBase::Initialize() 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_index_generator.Init();
m_cpu_cull.Init(); m_cpu_cull.Init();
return true; return true;
@ -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>;
@ -21,60 +20,60 @@ using AfterFrameEvent = Event<"AfterFrame">;
struct PresentInfo struct PresentInfo
{ {
enum class PresentReason enum class PresentReason
{ {
Immediate, // FIFO is Presenting the XFB immediately, straight after the XFB copy Immediate, // FIFO is Presenting the XFB immediately, straight after the XFB copy
VideoInterface, // VideoInterface has triggered a present with a new frame VideoInterface, // VideoInterface has triggered a present with a new frame
VideoInterfaceDuplicate, // VideoInterface has triggered a present with a duplicate frame VideoInterfaceDuplicate, // VideoInterface has triggered a present with a duplicate frame
}; };
// 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.
// never goes backwards.
u64 present_count;
// The number of presents since the video backend was initialized. // The frame is identical to the previous frame
// never goes backwards. PresentReason reason;
u64 present_count;
// The frame is identical to the previous frame // The exact emulated time of the when real hardware would have presented this frame
PresentReason reason; // 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 // TODO:
// FIXME: Immediate should predict the timestamp of this present // u64 intended_present_time;
u64 emulated_timestamp;
// TODO: // AfterPresent only: The actual time the frame was presented
// u64 intended_present_time; u64 actual_present_time = 0;
// AfterPresent only: The actual time the frame was presented enum class PresentTimeAccuracy
u64 actual_present_time = 0; {
// 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 // An approximate timestamp of scanout.
{ PresentOnScreen,
// 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. // Dolphin doesn't have visibility of the present time. But the present operation has
PresentOnScreen, // 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 // Not implemented
// been queued with the GPU driver and will happen in the near future. Unimplemented,
PresentInProgress, };
// Not implemented // Accuracy of actual_present_time
Unimplemented, 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. // An event called just as a frame is queued for presentation.
// 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())
{ {