From 7c118f2ee31c842a6164af77430df72e3ccc52d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 13 Oct 2026 14:41:42 +0200 Subject: [PATCH] Headless: Add --hardware-transform and --disable-gpu-features --disable-gpu-features=clip-distance,cull-distance,depth-clamp acts as if the GPU lacked those, to test the fallbacks for old Mali on any machine. It replaces the simulateOldMali constant. --hardware-transform=false runs every draw through software transform. Co-Authored-By: Claude Opus 5.5 --- Core/CmdLine.cpp | 6 ++++++ Core/CmdLine.h | 3 +++ Core/CoreParameter.h | 2 ++ GPU/GPUCommonHW.cpp | 9 +++------ headless/Headless.cpp | 16 ++++++++++++++++ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Core/CmdLine.cpp b/Core/CmdLine.cpp index 4d2bb53d1b..ca29199c87 100644 --- a/Core/CmdLine.cpp +++ b/Core/CmdLine.cpp @@ -206,6 +206,8 @@ static const CommandLineParam g_autoParams[] = { {POFF(screenshotFilenameSave), CmdParamType::String, "screenshot-save", '\0', "Save rendered screenshot to specified path (PNG if the path ends in .png, BMP otherwise)", CmdLineMode::Headless}, {POFF(replayEnd), CmdParamType::Int, "replay-end", '\0', "When replaying a GE frame dump, only draw primitives up to this one (1-based)", CmdLineMode::Headless}, {POFF(dumpCompat), CmdParamType::Bool, "dump-compat", '\0', "Apply the game's compat.ini settings when replaying a GE frame dump (off by default)", CmdLineMode::Headless}, + {POFF(hardwareTransform), CmdParamType::Bool, "hardware-transform", '\0', "Transform vertices on the GPU (default true); false transforms them on the CPU", CmdLineMode::Headless}, + {POFF(disableGPUFeatures), CmdParamType::String, "disable-gpu-features", '\0', "Act as if the GPU lacked these, to test the fallbacks: comma-separated clip-distance, cull-distance, depth-clamp", CmdLineMode::Headless}, {POFF(depthFilenameSave), CmdParamType::String, "depth-save", '\0', "Save the depth buffer to FILE along with the screenshot (u32 width, u32 height, u16 depths; float depths if FILE ends in .f32)", CmdLineMode::Headless}, {POFF(screenshotRenderTarget), CmdParamType::Bool, "screenshot-render-target", '\0', "Take screenshots of the current render target instead of the displayed framebuffer", CmdLineMode::Headless}, {POFF(screenshotFilenameDiff), CmdParamType::String, "screenshot-diff", '\0', "Save a visual comparison image to FILE when comparing screenshots", CmdLineMode::Headless}, @@ -541,6 +543,10 @@ void CommandLineOptions::ApplyToConfig() const { if (cpuCore.has_value()) { g_Config.iCpuCore = (int)cpuCore.value(); } + if (hardwareTransform.has_value()) { + g_Config.bHardwareTransform = hardwareTransform.value(); + g_Config.DoNotSaveSetting(&g_Config.bHardwareTransform); + } if (softwareRendering.has_value()) { g_Config.bSoftwareRendering = softwareRendering.value(); g_Config.DoNotSaveSetting(&g_Config.bSoftwareRendering); diff --git a/Core/CmdLine.h b/Core/CmdLine.h index efbd0da460..3bc1dea616 100644 --- a/Core/CmdLine.h +++ b/Core/CmdLine.h @@ -188,6 +188,9 @@ struct CommandLineOptions { std::optional replayEnd; // Headless: apply the game's compatibility settings when replaying a GE frame dump. std::optional dumpCompat; + std::optional hardwareTransform; + // Headless: comma-separated clip-distance, cull-distance, depth-clamp. + std::optional disableGPUFeatures; std::optional screenshotRenderTarget; std::optional screenshotFilenameDiff; // Headless: preserve the alpha channel when saving PNG screenshots. diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index 8e93d7eae5..9db8701b8c 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -77,6 +77,8 @@ struct CoreParameter { bool headLess = false; // Try to avoid messageboxes etc // Headless leaves out compat settings when replaying frame dumps, unless this is set. bool dumpCompat = false; + // Headless: GPU_USE_ feature bits to turn off, to test the fallbacks for GPUs without them. + u32 disabledGPUFeatures = 0; // Internal PSP rendering resolution and scale factor. int renderScaleFactor = 1; diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index b27f9faae0..d49361a331 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -613,12 +613,9 @@ u32 GPUCommonHW::CheckGPUFeatures() const { features |= GPU_USE_VS_RANGE_CULLING; } - // Set this to true to easily test our fallback shaders for depth clamp and min/max clipping. - // DO NOT check that in! This should be false normally. - constexpr bool simulateOldMali = false; - if (simulateOldMali) { - features &= ~(GPU_USE_CLIP_DISTANCE | GPU_USE_CULL_DISTANCE | GPU_USE_DEPTH_CLAMP); - } + // Headless --disable-gpu-features, to test the fallbacks for GPUs without them (old Mali has none of + // clip distance, cull distance and depth clamp). + features &= ~PSP_CoreParameter().disabledGPUFeatures; return features; } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 7093e286fb..7e563cbfc4 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -1118,6 +1118,22 @@ int main(int argc, const char* argv[]) { coreParameter.startBreak = false; coreParameter.headLess = true; coreParameter.dumpCompat = cmdLineOptions.dumpCompat.value_or(false); + if (cmdLineOptions.disableGPUFeatures.has_value()) { + std::vector names; + SplitString(cmdLineOptions.disableGPUFeatures.value(), ',', names); + for (const std::string &name : names) { + if (name == "clip-distance") { + coreParameter.disabledGPUFeatures |= GPU_USE_CLIP_DISTANCE; + } else if (name == "cull-distance") { + coreParameter.disabledGPUFeatures |= GPU_USE_CULL_DISTANCE; + } else if (name == "depth-clamp") { + coreParameter.disabledGPUFeatures |= GPU_USE_DEPTH_CLAMP; + } else { + fprintf(stderr, "Unknown feature for --disable-gpu-features: %s (expected clip-distance, cull-distance or depth-clamp)\n", name.c_str()); + return 1; + } + } + } coreParameter.loadGameConfigs = false; coreParameter.renderScaleFactor = cmdLineOptions.resolutionScale.value_or(1); coreParameter.renderWidth = 480 * coreParameter.renderScaleFactor;