VertexLoaderBase: Allow the vertex loader type to be set via config

This commit is contained in:
OatmealDome 2025-01-24 18:31:42 -05:00
parent d0b7c96fdb
commit bffaec9c5e
5 changed files with 43 additions and 14 deletions

View File

@ -126,6 +126,9 @@ const Info<bool> GFX_MODS_ENABLE{{System::GFX, "Settings", "EnableMods"}, false}
const Info<std::string> GFX_DRIVER_LIB_NAME{{System::GFX, "Settings", "DriverLibName"}, ""}; const Info<std::string> GFX_DRIVER_LIB_NAME{{System::GFX, "Settings", "DriverLibName"}, ""};
const Info<VertexLoaderType> GFX_VERTEX_LOADER_TYPE{{System::GFX, "Settings", "VertexLoaderType"},
VertexLoaderType::Native};
// Graphics.Enhancements // Graphics.Enhancements
const Info<TextureFilteringMode> GFX_ENHANCE_FORCE_TEXTURE_FILTERING{ const Info<TextureFilteringMode> GFX_ENHANCE_FORCE_TEXTURE_FILTERING{

View File

@ -16,6 +16,7 @@ enum class OutputResamplingMode : int;
enum class ColorCorrectionRegion : int; enum class ColorCorrectionRegion : int;
enum class TriState : int; enum class TriState : int;
enum class FrameDumpResolutionType : int; enum class FrameDumpResolutionType : int;
enum class VertexLoaderType : int;
namespace Config namespace Config
{ {
@ -184,4 +185,8 @@ extern const Info<bool> GFX_PERF_QUERIES_ENABLE;
extern const Info<std::string> GFX_DRIVER_LIB_NAME; extern const Info<std::string> GFX_DRIVER_LIB_NAME;
// Vertex loader
extern const Info<VertexLoaderType> GFX_VERTEX_LOADER_TYPE;
} // namespace Config } // namespace Config

View File

@ -25,6 +25,7 @@
#include "VideoCommon/VertexLoader_Normal.h" #include "VideoCommon/VertexLoader_Normal.h"
#include "VideoCommon/VertexLoader_Position.h" #include "VideoCommon/VertexLoader_Position.h"
#include "VideoCommon/VertexLoader_TextCoord.h" #include "VideoCommon/VertexLoader_TextCoord.h"
#include "VideoCommon/VideoConfig.h"
#ifdef _M_X86_64 #ifdef _M_X86_64
#include "VideoCommon/VertexLoaderX64.h" #include "VideoCommon/VertexLoaderX64.h"
@ -238,29 +239,37 @@ u32 VertexLoaderBase::GetVertexComponents(const TVtxDesc& vtx_desc, const VAT& v
std::unique_ptr<VertexLoaderBase> VertexLoaderBase::CreateVertexLoader(const TVtxDesc& vtx_desc, std::unique_ptr<VertexLoaderBase> VertexLoaderBase::CreateVertexLoader(const TVtxDesc& vtx_desc,
const VAT& vtx_attr) const VAT& vtx_attr)
{ {
std::unique_ptr<VertexLoaderBase> loader = nullptr; const VertexLoaderType loader_type = g_ActiveConfig.vertex_loader_type;
// #define COMPARE_VERTEXLOADERS if (loader_type == VertexLoaderType::Software)
{
return std::make_unique<VertexLoader>(vtx_desc, vtx_attr);
}
std::unique_ptr<VertexLoaderBase> native_loader = nullptr;
#if defined(_M_X86_64) #if defined(_M_X86_64)
loader = std::make_unique<VertexLoaderX64>(vtx_desc, vtx_attr); native_loader = std::make_unique<VertexLoaderX64>(vtx_desc, vtx_attr);
#elif defined(_M_ARM_64) #elif defined(_M_ARM_64)
loader = std::make_unique<VertexLoaderARM64>(vtx_desc, vtx_attr); native_loader = std::make_unique<VertexLoaderARM64>(vtx_desc, vtx_attr);
#endif #endif
// Use the software loader as a fallback // Use the software loader as a fallback
// (not currently applicable, as both VertexLoaderX64 and VertexLoaderARM64 // (not currently applicable, as both VertexLoaderX64 and VertexLoaderARM64
// are always usable, but if a loader that only works on some CPUs is created // are always usable, but if a loader that only works on some CPUs is created
// then this fallback would be used) // then this fallback would be used)
if (!loader) if (!native_loader)
loader = std::make_unique<VertexLoader>(vtx_desc, vtx_attr); {
return std::make_unique<VertexLoader>(vtx_desc, vtx_attr);
}
#if defined(COMPARE_VERTEXLOADERS) if (loader_type == VertexLoaderType::Compare)
return std::make_unique<VertexLoaderTester>( {
std::make_unique<VertexLoader>(vtx_desc, vtx_attr), // the software one return std::make_unique<VertexLoaderTester>(
std::move(loader), // the new one to compare std::make_unique<VertexLoader>(vtx_desc, vtx_attr), // the software one
vtx_desc, vtx_attr); std::move(native_loader), // the new one to compare
#else vtx_desc, vtx_attr);
return loader; }
#endif
return native_loader;
} }

View File

@ -206,6 +206,8 @@ void VideoConfig::Refresh()
bGraphicMods = Config::Get(Config::GFX_MODS_ENABLE); bGraphicMods = Config::Get(Config::GFX_MODS_ENABLE);
customDriverLibraryName = Config::Get(Config::GFX_DRIVER_LIB_NAME); customDriverLibraryName = Config::Get(Config::GFX_DRIVER_LIB_NAME);
vertex_loader_type = Config::Get(Config::GFX_VERTEX_LOADER_TYPE);
} }
void VideoConfig::VerifyValidity() void VideoConfig::VerifyValidity()

View File

@ -90,6 +90,13 @@ enum class FrameDumpResolutionType : int
XFBRawResolution, XFBRawResolution,
}; };
enum class VertexLoaderType : int
{
Native,
Software,
Compare
};
// 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
{ {
@ -279,6 +286,9 @@ struct VideoConfig final
// Loading custom drivers on Android // Loading custom drivers on Android
std::string customDriverLibraryName; std::string customDriverLibraryName;
// Vertex loader
VertexLoaderType vertex_loader_type;
// Static config per API // Static config per API
// TODO: Move this out of VideoConfig // TODO: Move this out of VideoConfig
struct struct