From bffaec9c5e6b68187a86288cf3db6e88e4bea2ce Mon Sep 17 00:00:00 2001 From: OatmealDome Date: Fri, 24 Jan 2025 18:31:42 -0500 Subject: VertexLoaderBase: Allow the vertex loader type to be set via config --- Source/Core/VideoCommon/VertexLoaderBase.cpp | 39 +++++++++++++++++----------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'Source/Core/VideoCommon/VertexLoaderBase.cpp') diff --git a/Source/Core/VideoCommon/VertexLoaderBase.cpp b/Source/Core/VideoCommon/VertexLoaderBase.cpp index a3597b53e5..36b6a2a67f 100644 --- a/Source/Core/VideoCommon/VertexLoaderBase.cpp +++ b/Source/Core/VideoCommon/VertexLoaderBase.cpp @@ -25,6 +25,7 @@ #include "VideoCommon/VertexLoader_Normal.h" #include "VideoCommon/VertexLoader_Position.h" #include "VideoCommon/VertexLoader_TextCoord.h" +#include "VideoCommon/VideoConfig.h" #ifdef _M_X86_64 #include "VideoCommon/VertexLoaderX64.h" @@ -238,29 +239,37 @@ u32 VertexLoaderBase::GetVertexComponents(const TVtxDesc& vtx_desc, const VAT& v std::unique_ptr VertexLoaderBase::CreateVertexLoader(const TVtxDesc& vtx_desc, const VAT& vtx_attr) { - std::unique_ptr loader = nullptr; + const VertexLoaderType loader_type = g_ActiveConfig.vertex_loader_type; - // #define COMPARE_VERTEXLOADERS + if (loader_type == VertexLoaderType::Software) + { + return std::make_unique(vtx_desc, vtx_attr); + } + + std::unique_ptr native_loader = nullptr; #if defined(_M_X86_64) - loader = std::make_unique(vtx_desc, vtx_attr); + native_loader = std::make_unique(vtx_desc, vtx_attr); #elif defined(_M_ARM_64) - loader = std::make_unique(vtx_desc, vtx_attr); + native_loader = std::make_unique(vtx_desc, vtx_attr); #endif // Use the software loader as a fallback // (not currently applicable, as both VertexLoaderX64 and VertexLoaderARM64 // are always usable, but if a loader that only works on some CPUs is created // then this fallback would be used) - if (!loader) - loader = std::make_unique(vtx_desc, vtx_attr); - -#if defined(COMPARE_VERTEXLOADERS) - return std::make_unique( - std::make_unique(vtx_desc, vtx_attr), // the software one - std::move(loader), // the new one to compare - vtx_desc, vtx_attr); -#else - return loader; -#endif + if (!native_loader) + { + return std::make_unique(vtx_desc, vtx_attr); + } + + if (loader_type == VertexLoaderType::Compare) + { + return std::make_unique( + std::make_unique(vtx_desc, vtx_attr), // the software one + std::move(native_loader), // the new one to compare + vtx_desc, vtx_attr); + } + + return native_loader; } -- cgit v1.2.3