mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Lint fixes
This commit is contained in:
@@ -36,7 +36,7 @@ struct HookBase
|
||||
|
||||
using EventHook = std::unique_ptr<HookBase>;
|
||||
|
||||
template<StringLiteral EventName, typename... CallbackArgs>
|
||||
template <StringLiteral EventName, typename... CallbackArgs>
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
@@ -46,12 +46,12 @@ private:
|
||||
struct HookImpl : public HookBase
|
||||
{
|
||||
~HookImpl() override { Event::Remove(this); }
|
||||
HookImpl(CallbackType callback, std::string name) : m_fn(callback), m_name(name){ }
|
||||
HookImpl(CallbackType callback, std::string name) : m_fn(callback), m_name(name) {}
|
||||
CallbackType m_fn;
|
||||
std::string m_name;
|
||||
};
|
||||
public:
|
||||
|
||||
public:
|
||||
// Returns a handle that will unregister the listener when destroyed.
|
||||
static EventHook Register(CallbackType callback, std::string name)
|
||||
{
|
||||
|
||||
@@ -7,11 +7,10 @@
|
||||
|
||||
// A useful template for passing string literals as arguments to templates
|
||||
// from: https://ctrpeach.io/posts/cpp20-string-literal-template-parameters/
|
||||
template<size_t N>
|
||||
struct StringLiteral {
|
||||
consteval StringLiteral(const char (&str)[N]) {
|
||||
std::copy_n(str, N, value);
|
||||
}
|
||||
template <size_t N>
|
||||
struct StringLiteral
|
||||
{
|
||||
consteval StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); }
|
||||
|
||||
char value[N];
|
||||
};
|
||||
|
||||
@@ -132,12 +132,14 @@ static thread_local bool tls_is_gpu_thread = false;
|
||||
|
||||
static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi);
|
||||
|
||||
static EventHook s_frame_presented = AfterPresentEvent::Register([](auto& present_info) {
|
||||
const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator();
|
||||
// The denominator should always be > 0 but if it's not, just return 1
|
||||
const double last_speed = last_speed_denominator > 0.0 ? (1.0 / last_speed_denominator) : 1.0;
|
||||
Core::Callback_FramePresented(last_speed);
|
||||
}, "Core Frame Presented");
|
||||
static EventHook s_frame_presented = AfterPresentEvent::Register(
|
||||
[](auto& present_info) {
|
||||
const double last_speed_denominator = g_perf_metrics.GetLastSpeedDenominator();
|
||||
// The denominator should always be > 0 but if it's not, just return 1
|
||||
const double last_speed = last_speed_denominator > 0.0 ? (1.0 / last_speed_denominator) : 1.0;
|
||||
Core::Callback_FramePresented(last_speed);
|
||||
},
|
||||
"Core Frame Presented");
|
||||
|
||||
bool GetIsThrottlerTempDisabled()
|
||||
{
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#include "VideoCommon/CommandProcessor.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
#include "VideoCommon/TextureDecoder.h"
|
||||
#include "VideoCommon/XFStructs.h"
|
||||
#include "VideoCommon/XFMemory.h"
|
||||
#include "VideoCommon/VideoEvents.h"
|
||||
#include "VideoCommon/XFMemory.h"
|
||||
#include "VideoCommon/XFStructs.h"
|
||||
|
||||
class FifoRecorder::FifoRecordAnalyzer : public OpcodeDecoder::Callback
|
||||
{
|
||||
@@ -255,24 +255,26 @@ void FifoRecorder::StartRecording(s32 numFrames, CallbackFunc finishedCb)
|
||||
m_RequestedRecordingEnd = false;
|
||||
m_FinishedCb = finishedCb;
|
||||
|
||||
m_end_of_frame_event = AfterFrameEvent::Register([this] {
|
||||
const bool was_recording = OpcodeDecoder::g_record_fifo_data;
|
||||
OpcodeDecoder::g_record_fifo_data = IsRecording();
|
||||
m_end_of_frame_event = AfterFrameEvent::Register(
|
||||
[this] {
|
||||
const bool was_recording = OpcodeDecoder::g_record_fifo_data;
|
||||
OpcodeDecoder::g_record_fifo_data = IsRecording();
|
||||
|
||||
if (!OpcodeDecoder::g_record_fifo_data)
|
||||
return;
|
||||
if (!OpcodeDecoder::g_record_fifo_data)
|
||||
return;
|
||||
|
||||
if (!was_recording)
|
||||
{
|
||||
RecordInitialVideoMemory();
|
||||
}
|
||||
if (!was_recording)
|
||||
{
|
||||
RecordInitialVideoMemory();
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& command_processor = system.GetCommandProcessor();
|
||||
const auto& fifo = command_processor.GetFifo();
|
||||
EndFrame(fifo.CPBase.load(std::memory_order_relaxed),
|
||||
fifo.CPEnd.load(std::memory_order_relaxed));
|
||||
}, "FifoRecorder::EndFrame");
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& command_processor = system.GetCommandProcessor();
|
||||
const auto& fifo = command_processor.GetFifo();
|
||||
EndFrame(fifo.CPBase.load(std::memory_order_relaxed),
|
||||
fifo.CPEnd.load(std::memory_order_relaxed));
|
||||
},
|
||||
"FifoRecorder::EndFrame");
|
||||
}
|
||||
|
||||
void FifoRecorder::RecordInitialVideoMemory()
|
||||
|
||||
@@ -50,19 +50,19 @@ bool Gfx::IsHeadless() const
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractTexture> Gfx::CreateTexture(const TextureConfig& config,
|
||||
std::string_view name)
|
||||
std::string_view name)
|
||||
{
|
||||
return DXTexture::Create(config, name);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractStagingTexture> Gfx::CreateStagingTexture(StagingTextureType type,
|
||||
const TextureConfig& config)
|
||||
const TextureConfig& config)
|
||||
{
|
||||
return DXStagingTexture::Create(type, config);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractFramebuffer> Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
|
||||
AbstractTexture* depth_attachment)
|
||||
AbstractTexture* depth_attachment)
|
||||
{
|
||||
return DXFramebuffer::Create(static_cast<DXTexture*>(color_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);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage,
|
||||
const void* data, size_t length,
|
||||
std::string_view name)
|
||||
std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage, const void* data,
|
||||
size_t length, std::string_view name)
|
||||
{
|
||||
return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractPipeline> Gfx::CreatePipeline(const AbstractPipelineConfig& config,
|
||||
const void* cache_data,
|
||||
size_t cache_data_length)
|
||||
const void* cache_data,
|
||||
size_t cache_data_length)
|
||||
{
|
||||
return DXPipeline::Create(config);
|
||||
}
|
||||
@@ -129,7 +128,7 @@ void Gfx::SetScissorRect(const MathUtil::Rectangle<int>& rc)
|
||||
}
|
||||
|
||||
void Gfx::SetViewport(float x, float y, float width, float height, float near_depth,
|
||||
float far_depth)
|
||||
float far_depth)
|
||||
{
|
||||
// TODO: Move to stateman
|
||||
const CD3D11_VIEWPORT vp(x, y, width, height, near_depth, far_depth);
|
||||
@@ -149,7 +148,7 @@ void Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex)
|
||||
}
|
||||
|
||||
void Gfx::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y,
|
||||
u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z)
|
||||
u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z)
|
||||
{
|
||||
D3D::stateman->SetComputeShader(static_cast<const DXShader*>(shader)->GetD3DComputeShader());
|
||||
D3D::stateman->SyncComputeBindings();
|
||||
@@ -222,8 +221,8 @@ void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
SetFramebuffer(framebuffer);
|
||||
}
|
||||
|
||||
void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
|
||||
const ClearColor& color_value, float depth_value)
|
||||
void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value,
|
||||
float depth_value)
|
||||
{
|
||||
SetFramebuffer(framebuffer);
|
||||
D3D::stateman->Apply();
|
||||
@@ -286,12 +285,9 @@ bool Gfx::IsFullscreen() const
|
||||
|
||||
SurfaceInfo Gfx::GetSurfaceInfo() const
|
||||
{
|
||||
return {
|
||||
m_swap_chain ? static_cast<u32>(m_swap_chain->GetWidth()) : 0,
|
||||
m_swap_chain ? static_cast<u32>(m_swap_chain->GetHeight()) : 0,
|
||||
m_backbuffer_scale,
|
||||
m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined
|
||||
};
|
||||
return {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 ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined};
|
||||
}
|
||||
|
||||
} // namespace DX11
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DBoundingBox.h"
|
||||
#include "VideoBackends/D3D/D3DPerfQuery.h"
|
||||
#include "VideoBackends/D3D/D3DGfx.h"
|
||||
#include "VideoBackends/D3D/D3DPerfQuery.h"
|
||||
#include "VideoBackends/D3D/D3DSwapChain.h"
|
||||
#include "VideoBackends/D3D/D3DVertexManager.h"
|
||||
#include "VideoBackends/D3DCommon/D3DCommon.h"
|
||||
@@ -161,7 +161,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
auto bounding_box = std::make_unique<D3DBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
|
||||
@@ -114,8 +114,8 @@ void PerfQuery::FlushOne()
|
||||
// NOTE: Reported pixel metrics should be referenced to native resolution
|
||||
// TODO: Dropping the lower 2 bits from this count should be closer to actual
|
||||
// hardware behavior when drawing triangles.
|
||||
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
|
||||
g_framebuffer_manager->GetEFBHeight();
|
||||
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() *
|
||||
EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight();
|
||||
m_results[entry.query_group].fetch_add(static_cast<u32>(native_res_result),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
@@ -143,8 +143,8 @@ void PerfQuery::WeakFlush()
|
||||
if (hr == S_OK)
|
||||
{
|
||||
// NOTE: Reported pixel metrics should be referenced to native resolution
|
||||
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() * EFB_HEIGHT /
|
||||
g_framebuffer_manager->GetEFBHeight();
|
||||
const u64 native_res_result = result * EFB_WIDTH / g_framebuffer_manager->GetEFBWidth() *
|
||||
EFB_HEIGHT / g_framebuffer_manager->GetEFBHeight();
|
||||
m_results[entry.query_group].store(static_cast<u32>(native_res_result),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
|
||||
@@ -49,19 +49,19 @@ bool Gfx::IsHeadless() const
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractTexture> Gfx::CreateTexture(const TextureConfig& config,
|
||||
std::string_view name)
|
||||
std::string_view name)
|
||||
{
|
||||
return DXTexture::Create(config, name);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractStagingTexture> Gfx::CreateStagingTexture(StagingTextureType type,
|
||||
const TextureConfig& config)
|
||||
const TextureConfig& config)
|
||||
{
|
||||
return DXStagingTexture::Create(type, config);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractFramebuffer> Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
|
||||
AbstractTexture* depth_attachment)
|
||||
AbstractTexture* depth_attachment)
|
||||
{
|
||||
return DXFramebuffer::Create(static_cast<DXTexture*>(color_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);
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage,
|
||||
const void* data, size_t length,
|
||||
std::string_view name)
|
||||
std::unique_ptr<AbstractShader> Gfx::CreateShaderFromBinary(ShaderStage stage, const void* data,
|
||||
size_t length, std::string_view name)
|
||||
{
|
||||
return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name);
|
||||
}
|
||||
@@ -87,8 +86,8 @@ Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractPipeline> Gfx::CreatePipeline(const AbstractPipelineConfig& config,
|
||||
const void* cache_data,
|
||||
size_t cache_data_length)
|
||||
const void* cache_data,
|
||||
size_t cache_data_length)
|
||||
{
|
||||
return DXPipeline::Create(config, cache_data, cache_data_length);
|
||||
}
|
||||
@@ -103,8 +102,8 @@ void Gfx::WaitForGPUIdle()
|
||||
ExecuteCommandList(true);
|
||||
}
|
||||
|
||||
void Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z)
|
||||
void Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable,
|
||||
bool alpha_enable, bool z_enable, u32 color, u32 z)
|
||||
{
|
||||
// Use a fast path without the shader if both color/alpha are enabled.
|
||||
const bool fast_color_clear = color_enable && alpha_enable;
|
||||
@@ -229,8 +228,8 @@ void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
}
|
||||
}
|
||||
|
||||
void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
|
||||
const ClearColor& color_value, float depth_value)
|
||||
void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value,
|
||||
float depth_value)
|
||||
{
|
||||
DXFramebuffer* dxfb = static_cast<DXFramebuffer*>(framebuffer);
|
||||
BindFramebuffer(dxfb);
|
||||
@@ -318,7 +317,7 @@ void Gfx::UnbindTexture(const AbstractTexture* texture)
|
||||
}
|
||||
|
||||
void Gfx::SetViewport(float x, float y, float width, float height, float near_depth,
|
||||
float far_depth)
|
||||
float far_depth)
|
||||
{
|
||||
if (m_state.viewport.TopLeftX == x && m_state.viewport.TopLeftY == y &&
|
||||
m_state.viewport.Width == width && m_state.viewport.Height == height &&
|
||||
@@ -357,7 +356,7 @@ void Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex)
|
||||
}
|
||||
|
||||
void Gfx::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y,
|
||||
u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z)
|
||||
u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z)
|
||||
{
|
||||
SetRootSignatures();
|
||||
SetDescriptorHeaps();
|
||||
@@ -427,12 +426,9 @@ void Gfx::PresentBackbuffer()
|
||||
|
||||
SurfaceInfo Gfx::GetSurfaceInfo() const
|
||||
{
|
||||
return {
|
||||
m_swap_chain ? static_cast<u32>(m_swap_chain->GetWidth()) : 0,
|
||||
m_swap_chain ? static_cast<u32>(m_swap_chain->GetHeight()) : 0,
|
||||
m_backbuffer_scale,
|
||||
m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined
|
||||
};
|
||||
return {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 ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined};
|
||||
}
|
||||
|
||||
void Gfx::OnConfigChanged(u32 bits)
|
||||
@@ -494,7 +490,7 @@ void Gfx::SetPixelShaderUAV(D3D12_CPU_DESCRIPTOR_HANDLE handle)
|
||||
}
|
||||
|
||||
void Gfx::SetVertexBuffer(D3D12_GPU_VIRTUAL_ADDRESS address, D3D12_CPU_DESCRIPTOR_HANDLE srv,
|
||||
u32 stride, u32 size)
|
||||
u32 stride, u32 size)
|
||||
{
|
||||
if (m_state.vertex_buffer.BufferLocation != address ||
|
||||
m_state.vertex_buffer.StrideInBytes != stride || m_state.vertex_buffer.SizeInBytes != size)
|
||||
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
void Flush() override;
|
||||
void WaitForGPUIdle() override;
|
||||
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override;
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable, bool alpha_enable,
|
||||
bool z_enable, u32 color, u32 z) override;
|
||||
|
||||
void SetPipeline(const AbstractPipeline* pipeline) override;
|
||||
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#include "VideoBackends/D3D12/Common.h"
|
||||
#include "VideoBackends/D3D12/D3D12Gfx.h"
|
||||
#include "VideoBackends/D3D12/DX12Context.h"
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/RenderBase.h"
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
|
||||
@@ -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));
|
||||
|
||||
Gfx::GetInstance()->SetVertexBuffer(m_vertex_stream_buffer.GetGPUPointer(),
|
||||
m_vertex_srv.cpu_handle, vertex_stride,
|
||||
m_vertex_stream_buffer.GetSize());
|
||||
m_vertex_srv.cpu_handle, vertex_stride,
|
||||
m_vertex_stream_buffer.GetSize());
|
||||
Gfx::GetInstance()->SetIndexBuffer(m_index_stream_buffer.GetGPUPointer(),
|
||||
m_index_stream_buffer.GetSize(), DXGI_FORMAT_R16_UINT);
|
||||
m_index_stream_buffer.GetSize(), DXGI_FORMAT_R16_UINT);
|
||||
}
|
||||
|
||||
void VertexManager::UploadUniforms()
|
||||
@@ -235,11 +235,11 @@ void VertexManager::UploadAllConstants()
|
||||
|
||||
// Update bindings
|
||||
Gfx::GetInstance()->SetConstantBuffer(0, m_uniform_stream_buffer.GetCurrentGPUPointer() +
|
||||
pixel_constants_offset);
|
||||
pixel_constants_offset);
|
||||
Gfx::GetInstance()->SetConstantBuffer(1, m_uniform_stream_buffer.GetCurrentGPUPointer() +
|
||||
vertex_constants_offset);
|
||||
vertex_constants_offset);
|
||||
Gfx::GetInstance()->SetConstantBuffer(2, m_uniform_stream_buffer.GetCurrentGPUPointer() +
|
||||
geometry_constants_offset);
|
||||
geometry_constants_offset);
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& pixel_shader_manager = system.GetPixelShaderManager();
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
#include "VideoBackends/D3D12/Common.h"
|
||||
#include "VideoBackends/D3D12/D3D12BoundingBox.h"
|
||||
#include "VideoBackends/D3D12/D3D12PerfQuery.h"
|
||||
#include "VideoBackends/D3D12/D3D12Gfx.h"
|
||||
#include "VideoBackends/D3D12/D3D12PerfQuery.h"
|
||||
#include "VideoBackends/D3D12/D3D12SwapChain.h"
|
||||
#include "VideoBackends/D3D12/D3D12VertexManager.h"
|
||||
#include "VideoBackends/D3D12/DX12Context.h"
|
||||
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
void WaitForGPUIdle() override;
|
||||
void OnConfigChanged(u32 bits) override;
|
||||
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override;
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable, bool alpha_enable,
|
||||
bool z_enable, u32 color, u32 z) override;
|
||||
|
||||
void SetPipeline(const AbstractPipeline* pipeline) override;
|
||||
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
Metal::Gfx::Gfx(MRCOwned<CAMetalLayer*> layer)
|
||||
: m_layer(std::move(layer))
|
||||
Metal::Gfx::Gfx(MRCOwned<CAMetalLayer*> layer) : m_layer(std::move(layer))
|
||||
{
|
||||
UpdateActiveConfig();
|
||||
[m_layer setDisplaySyncEnabled:g_ActiveConfig.bVSyncActive];
|
||||
@@ -38,7 +37,7 @@ bool Metal::Gfx::IsHeadless() const
|
||||
// MARK: Texture Creation
|
||||
|
||||
std::unique_ptr<AbstractTexture> Metal::Gfx::CreateTexture(const TextureConfig& config,
|
||||
std::string_view name)
|
||||
std::string_view name)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
@@ -94,8 +93,7 @@ Metal::Gfx::CreateStagingTexture(StagingTextureType type, const TextureConfig& c
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractFramebuffer>
|
||||
Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
|
||||
AbstractTexture* depth_attachment)
|
||||
Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment)
|
||||
{
|
||||
AbstractTexture* const either_attachment = color_attachment ? color_attachment : depth_attachment;
|
||||
return std::make_unique<Framebuffer>(
|
||||
@@ -107,8 +105,8 @@ Metal::Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
|
||||
// MARK: Pipeline Creation
|
||||
|
||||
std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromSource(ShaderStage stage,
|
||||
std::string_view source,
|
||||
std::string_view name)
|
||||
std::string_view source,
|
||||
std::string_view name)
|
||||
{
|
||||
std::optional<std::string> msl = Util::TranslateShaderToMSL(stage, source);
|
||||
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,
|
||||
const void* data,
|
||||
size_t length,
|
||||
std::string_view name)
|
||||
const void* data, size_t length,
|
||||
std::string_view name)
|
||||
{
|
||||
return CreateShaderFromMSL(stage, std::string(static_cast<const char*>(data), length), {}, name);
|
||||
}
|
||||
@@ -154,10 +151,9 @@ static NSString* GenericShaderName(ShaderStage stage)
|
||||
|
||||
// clang-format on
|
||||
|
||||
std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromMSL(ShaderStage stage,
|
||||
std::string msl,
|
||||
std::string_view glsl,
|
||||
std::string_view name)
|
||||
std::unique_ptr<AbstractShader> Metal::Gfx::CreateShaderFromMSL(ShaderStage stage, std::string msl,
|
||||
std::string_view glsl,
|
||||
std::string_view name)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
@@ -247,9 +243,9 @@ Metal::Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractPipeline>
|
||||
Metal::Gfx::CreatePipeline(const AbstractPipelineConfig& config, const void* cache_data,
|
||||
size_t cache_data_length)
|
||||
std::unique_ptr<AbstractPipeline> Metal::Gfx::CreatePipeline(const AbstractPipelineConfig& config,
|
||||
const void* cache_data,
|
||||
size_t cache_data_length)
|
||||
{
|
||||
return g_object_cache->CreatePipeline(config);
|
||||
}
|
||||
@@ -285,8 +281,8 @@ void Metal::Gfx::OnConfigChanged(u32 bits)
|
||||
}
|
||||
}
|
||||
|
||||
void Metal::Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z)
|
||||
void Metal::Gfx::ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable,
|
||||
bool alpha_enable, bool z_enable, u32 color, u32 z)
|
||||
{
|
||||
u32 framebuffer_width = m_current_framebuffer->GetWidth();
|
||||
u32 framebuffer_height = m_current_framebuffer->GetHeight();
|
||||
@@ -362,7 +358,7 @@ void Metal::Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
|
||||
}
|
||||
|
||||
void Metal::Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
|
||||
const ClearColor& color_value, float depth_value)
|
||||
const ClearColor& color_value, float depth_value)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
@@ -400,7 +396,7 @@ void Metal::Gfx::UnbindTexture(const AbstractTexture* texture)
|
||||
}
|
||||
|
||||
void Metal::Gfx::SetViewport(float x, float y, float width, float height, float near_depth,
|
||||
float far_depth)
|
||||
float far_depth)
|
||||
{
|
||||
g_state_tracker->SetViewport(x, y, width, height, near_depth, far_depth);
|
||||
}
|
||||
@@ -422,8 +418,8 @@ void Metal::Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex)
|
||||
}
|
||||
|
||||
void Metal::Gfx::DispatchComputeShader(const AbstractShader* shader, //
|
||||
u32 groupsize_x, u32 groupsize_y, u32 groupsize_z,
|
||||
u32 groups_x, u32 groups_y, u32 groups_z)
|
||||
u32 groupsize_x, u32 groupsize_y, u32 groupsize_z,
|
||||
u32 groups_x, u32 groups_y, u32 groups_z)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
@@ -491,7 +487,8 @@ void Metal::Gfx::SetupSurface()
|
||||
|
||||
[m_layer setDrawableSize:{static_cast<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_backbuffer = std::make_unique<Framebuffer>(m_bb_texture.get(), nullptr, //
|
||||
info.width, info.height, 1, 1);
|
||||
@@ -502,16 +499,12 @@ void Metal::Gfx::SetupSurface()
|
||||
|
||||
SurfaceInfo Metal::Gfx::GetSurfaceInfo() const
|
||||
{
|
||||
if (!m_layer) // Headless
|
||||
if (!m_layer) // Headless
|
||||
return {};
|
||||
|
||||
CGSize size = [m_layer bounds].size;
|
||||
const float scale = [m_layer contentsScale];
|
||||
|
||||
return {
|
||||
static_cast<u32>(size.width * scale),
|
||||
static_cast<u32>(size.height * scale),
|
||||
scale,
|
||||
Util::ToAbstract([m_layer pixelFormat])
|
||||
};
|
||||
return {static_cast<u32>(size.width * scale), static_cast<u32>(size.height * scale), scale,
|
||||
Util::ToAbstract([m_layer pixelFormat])};
|
||||
}
|
||||
|
||||
@@ -77,8 +77,9 @@ void Metal::PerfQuery::ReturnResults(const u64* data, const PerfQueryGroup* grou
|
||||
{
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
u64 native_res_result = data[i] * (EFB_WIDTH * EFB_HEIGHT) /
|
||||
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight());
|
||||
u64 native_res_result =
|
||||
data[i] * (EFB_WIDTH * EFB_HEIGHT) /
|
||||
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight());
|
||||
|
||||
native_res_result /= g_ActiveConfig.iMultisamples;
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
void SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) override;
|
||||
void SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value = {},
|
||||
float depth_value = 0.0f) override;
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool colorEnable, bool alphaEnable,
|
||||
bool zEnable, u32 color, u32 z) override;
|
||||
void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
|
||||
void SetTexture(u32 index, const AbstractTexture* texture) override;
|
||||
void SetSamplerState(u32 index, const SamplerState& state) override;
|
||||
|
||||
@@ -264,8 +264,9 @@ void PerfQueryGLESNV::FlushOne()
|
||||
// NOTE: Reported pixel metrics should be referenced to native resolution
|
||||
// TODO: Dropping the lower 2 bits from this count should be closer to actual
|
||||
// hardware behavior when drawing triangles.
|
||||
const u64 native_res_result = static_cast<u64>(result) * EFB_WIDTH * EFB_HEIGHT /
|
||||
(g_framebuffer_manager->GetEFBWidth() * g_framebuffer_manager->GetEFBHeight());
|
||||
const u64 native_res_result =
|
||||
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),
|
||||
std::memory_order_relaxed);
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public:
|
||||
|
||||
void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
|
||||
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool colorEnable, bool alphaEnable,
|
||||
bool zEnable, u32 color, u32 z) override;
|
||||
|
||||
private:
|
||||
std::unique_ptr<SWOGLWindow> m_window;
|
||||
|
||||
@@ -53,8 +53,8 @@ public:
|
||||
void WaitForGPUIdle() override;
|
||||
void OnConfigChanged(u32 bits) override;
|
||||
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc,
|
||||
bool color_enable, bool alpha_enable, bool z_enable, u32 color, u32 z) override;
|
||||
void ClearRegion(const MathUtil::Rectangle<int>& target_rc, bool color_enable, bool alpha_enable,
|
||||
bool z_enable, u32 color, u32 z) override;
|
||||
|
||||
void SetPipeline(const AbstractPipeline* pipeline) override;
|
||||
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
||||
|
||||
@@ -240,7 +240,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
auto bounding_box = std::make_unique<VKBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user