diff --git a/MobileGL/MG_State/GLState/ProgramState/ProgramLinkTask.cpp b/MobileGL/MG_State/GLState/ProgramState/ProgramLinkTask.cpp index bffc2083..32547df1 100644 --- a/MobileGL/MG_State/GLState/ProgramState/ProgramLinkTask.cpp +++ b/MobileGL/MG_State/GLState/ProgramState/ProgramLinkTask.cpp @@ -909,6 +909,19 @@ namespace MobileGL::MG_State::GLState { artifacts.generatedSpirv.size()); // Linked SPIR-V generated, sanitize and optimize it + { + // TEMP-STAGE-PROBE: "spirv-null" - the same Optimizer::Run with ZERO passes, + // on the pre-optimize binary: pure BuildModule + serialize + IRContext + // teardown. Its device/desktop share ratio against "spirv-opt" is the + // allocator-pathology discriminator. Costs one extra plumbing round per + // module; diagnostic build only. + const MG_Util::Debug::TempStageProbeScope tempStageProbeSpirvNull( + MG_Util::Debug::kTempStageProbeSpirvNull); + for (auto& spv : artifacts.generatedSpirv) { + Vector nullOut; + (void)ShaderCompiler::TempProbeNullOptimizeBinary(spv, nullOut); + } + } { // TEMP-STAGE-PROBE: "spirv-opt" - the spirv-tools optimizer run over every module. const MG_Util::Debug::TempStageProbeScope tempStageProbeSpirvOpt( diff --git a/MobileGL/MG_Util/Debug/TempStageProbe.h b/MobileGL/MG_Util/Debug/TempStageProbe.h index 9537e5cf..e69cac4e 100644 --- a/MobileGL/MG_Util/Debug/TempStageProbe.h +++ b/MobileGL/MG_Util/Debug/TempStageProbe.h @@ -31,6 +31,7 @@ namespace MobileGL::MG_Util::Debug { kTempStageProbeParseReparse, kTempStageProbeGlslangLink, kTempStageProbeSpirvGen, + kTempStageProbeSpirvNull, kTempStageProbeSpirvOpt, kTempStageProbeReflection, kTempStageProbeSpvcRouting, @@ -45,6 +46,7 @@ namespace MobileGL::MG_Util::Debug { "parse-reparse[subset-of-parse]", "glslang-link", "spirv-gen", + "spirv-null[plumbing-only]", "spirv-opt", "reflection", "spvc-routing", diff --git a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp index 27baf7ff..f9898098 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp +++ b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.cpp @@ -385,6 +385,19 @@ namespace MobileGL { return optimizer.Run(inputBinary.data(), inputBinary.size(), &outputBinary, options); } + // TEMP-STAGE-PROBE tempStageProbeNullOptimize: SanitizeAndOptimizeBinary minus + // every pass - measures the pure IR plumbing (BuildModule + serialize + + // IRContext teardown) so a device run can separate allocator-bound plumbing + // from transformation work. Remove with the probes. + bool ShaderCompiler::TempProbeNullOptimizeBinary(const Vector& inputBinary, + Vector& outputBinary) { + using namespace spvtools; + OptimizerOptions options; + options.set_run_validator(false); + Optimizer optimizer(SPV_ENV_VULKAN_1_1); + return optimizer.Run(inputBinary.data(), inputBinary.size(), &outputBinary, options); + } + bool ShaderCompiler::LowerDrawParametersForEssl(const Vector& inputBinary, Vector& outputBinary) { using namespace spvtools; diff --git a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h index bd1a5964..450b4863 100644 --- a/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h +++ b/MobileGL/MG_Util/ShaderTranspiler/ShaderCompiler.h @@ -22,6 +22,10 @@ namespace MobileGL { static Result>> GetSpirvBinaryFromProgram(const ProgramBinaryAttrib& attrib); static bool SanitizeAndOptimizeBinary(const Vector& inputBinary, Vector& outputBinary); + // TEMP-STAGE-PROBE: SanitizeAndOptimizeBinary with zero passes - pure IR + // plumbing, for the allocator-pathology discriminator. Remove with the probes. + static bool TempProbeNullOptimizeBinary(const Vector& inputBinary, + Vector& outputBinary); // Demotes DrawIndex/BaseInstance/BaseVertex builtins to plain Private globals // (mg_DrawID/mg_BaseInstance/mg_BaseVertex) so SPIRV-Cross can emit ESSL. // Only for backends without native draw-parameter support (DirectGLES).