mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Test] (MG_Util, MG_State): TEMP stage-timing probes for the async-compile campaign - remove before merge
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToGL/ProgramEnumConverter.h>
|
||||
#include <MG_Util/Converters/SPIRVCrossToGL/SpvcTypeConverter.h>
|
||||
#include <MG_Util/Debug/TempStageProbe.h> // TEMP-STAGE-PROBE
|
||||
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
|
||||
#include <MG_Util/ShaderTranspiler/ShaderSourceProcessor.h>
|
||||
#include <MG_Util/ShaderTranspiler/Types.h>
|
||||
@@ -293,6 +294,15 @@ namespace MobileGL::MG_State::GLState {
|
||||
const GlslangThreadAllocatorGuard glslangGuard;
|
||||
using namespace MG_Util::ShaderTranspiler;
|
||||
|
||||
// TEMP-STAGE-PROBE: "linktask-total" (whole link body, superset of glslang-link /
|
||||
// spirv-gen / spirv-opt / reflection / spvc-routing / the ConsumeShaders re-parse)
|
||||
// plus the every-25-links running-total dump of every stage.
|
||||
// Declared FIRST so it is destroyed LAST: the dump then already includes this link's
|
||||
// own contribution to every stage, including "linktask-total".
|
||||
const MG_Util::Debug::TempStageProbeLinkTick tempStageProbeLinkTick;
|
||||
const MG_Util::Debug::TempStageProbeScope tempStageProbeLinkTask(
|
||||
MG_Util::Debug::kTempStageProbeLinkTaskTotal);
|
||||
|
||||
MOBILEGL_ASSERT(in.env != nullptr, "ProgramLinkTask: the CompileEnv snapshot is missing");
|
||||
const CompileEnv& env = *in.env;
|
||||
|
||||
@@ -332,7 +342,12 @@ namespace MobileGL::MG_State::GLState {
|
||||
.explicitOpaqueUniformBindings = &artifacts.explicitOpaqueUniformBindings};
|
||||
|
||||
MGLOG_D("ProgramObject %u: Calling ShaderCompiler::LinkProgram", in.externalIndex);
|
||||
auto result = ShaderCompiler::LinkProgram(attrib);
|
||||
// TEMP-STAGE-PROBE: "glslang-link" - TProgram::link + mapIO.
|
||||
auto result = [&] {
|
||||
const MG_Util::Debug::TempStageProbeScope tempStageProbeGlslangLink(
|
||||
MG_Util::Debug::kTempStageProbeGlslangLink);
|
||||
return ShaderCompiler::LinkProgram(attrib);
|
||||
}();
|
||||
if (result) {
|
||||
artifacts.linkStatus = true;
|
||||
artifacts.program = result.value();
|
||||
@@ -375,14 +390,25 @@ namespace MobileGL::MG_State::GLState {
|
||||
GenerateSpirv();
|
||||
|
||||
MGLOG_D("ProgramObject %u: Starting reflection", in.externalIndex);
|
||||
if (!DoReflection(env)) {
|
||||
// TEMP-STAGE-PROBE: "reflection" - buildReflection + the GL location assignment.
|
||||
const bool tempStageProbeReflectionOk = [&] {
|
||||
const MG_Util::Debug::TempStageProbeScope tempStageProbeReflection(
|
||||
MG_Util::Debug::kTempStageProbeReflection);
|
||||
return static_cast<bool>(DoReflection(env));
|
||||
}();
|
||||
if (!tempStageProbeReflectionOk) {
|
||||
DeferLog(std::format("ProgramObject {}: Link failed during reflection: {}", in.externalIndex,
|
||||
artifacts.infoLog));
|
||||
return;
|
||||
}
|
||||
|
||||
MGLOG_D("ProgramObject %u: Building global-UBO routing tables", in.externalIndex);
|
||||
BuildGlobalUboRouting();
|
||||
{
|
||||
// TEMP-STAGE-PROBE: "spvc-routing" - the SPIRV-Cross session per SPIR-V module.
|
||||
const MG_Util::Debug::TempStageProbeScope tempStageProbeSpvcRouting(
|
||||
MG_Util::Debug::kTempStageProbeSpvcRouting);
|
||||
BuildGlobalUboRouting();
|
||||
}
|
||||
MGLOG_D("ProgramObject %u: Reflection done (linkStatus=%d)", in.externalIndex, (int)artifacts.linkStatus);
|
||||
if (!ValidateFragmentOutputLocations()) {
|
||||
return;
|
||||
@@ -867,7 +893,12 @@ namespace MobileGL::MG_State::GLState {
|
||||
.program = *artifacts.program,
|
||||
};
|
||||
MGLOG_D("ProgramObject %u: GenerateSpirv - requesting SPIR-V binary from program", in.externalIndex);
|
||||
auto binaryResult = ShaderCompiler::GetSpirvBinaryFromProgram(binaryAttrib);
|
||||
// TEMP-STAGE-PROBE: "spirv-gen" - GlslangToSpv for every stage of this program.
|
||||
auto binaryResult = [&] {
|
||||
const MG_Util::Debug::TempStageProbeScope tempStageProbeSpirvGen(
|
||||
MG_Util::Debug::kTempStageProbeSpirvGen);
|
||||
return ShaderCompiler::GetSpirvBinaryFromProgram(binaryAttrib);
|
||||
}();
|
||||
if (!binaryResult) {
|
||||
DeferLog(std::format("ProgramObject {}: GenerateSpirv - GetSpirvBinaryFromProgram failed",
|
||||
in.externalIndex));
|
||||
@@ -878,9 +909,14 @@ namespace MobileGL::MG_State::GLState {
|
||||
artifacts.generatedSpirv.size());
|
||||
|
||||
// Linked SPIR-V generated, sanitize and optimize it
|
||||
for (auto& spv : artifacts.generatedSpirv) {
|
||||
auto success = ShaderCompiler::SanitizeAndOptimizeBinary(spv, spv);
|
||||
MOBILEGL_ASSERT(success, "SanitizeBinary failed");
|
||||
{
|
||||
// TEMP-STAGE-PROBE: "spirv-opt" - the spirv-tools optimizer run over every module.
|
||||
const MG_Util::Debug::TempStageProbeScope tempStageProbeSpirvOpt(
|
||||
MG_Util::Debug::kTempStageProbeSpirvOpt);
|
||||
for (auto& spv : artifacts.generatedSpirv) {
|
||||
auto success = ShaderCompiler::SanitizeAndOptimizeBinary(spv, spv);
|
||||
MOBILEGL_ASSERT(success, "SanitizeBinary failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user