mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-14 07:08:32 +09:00
[Fix, Test] (DirectVulkan, ShaderTranspiler, TraceReplay): derive NumSubgroups behind opt-in quirk
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "ProgramFactory.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "MG_Backend/DirectVulkan/DirectVulkanResourceState.h"
|
||||
#include "MG_Util/ShaderTranspiler/ShaderCompiler.h"
|
||||
#include "MG_Util/ShaderTranspiler/SpvcSession.h"
|
||||
@@ -3163,6 +3164,23 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
}
|
||||
|
||||
// NumSubgroups is defined by the local workgroup dimensions and SubgroupSize. Derive
|
||||
// it in SPIR-V instead of trusting a driver builtin that can disagree with the
|
||||
// SubgroupId topology produced by the same compute dispatch (Adreno reports 1 while
|
||||
// emitting IDs 0..7 for a 512-invocation, 64-wide workgroup).
|
||||
if (MG_Config::Features.NumSubgroupsQuirk && shaders[i] &&
|
||||
shaders[i]->GetShaderStage() == ShaderStage::Compute) {
|
||||
Vector<Uint> derivedNumSubgroupsSpirv;
|
||||
if (MG_Util::ShaderTranspiler::ShaderCompiler::DeriveNumSubgroupsForVulkan(
|
||||
moduleSpirvs[i], derivedNumSubgroupsSpirv, enableSpirvValidation)) {
|
||||
moduleSpirvs[i] = std::move(derivedNumSubgroupsSpirv);
|
||||
} else {
|
||||
MGLOG_E("ProgramFactory: failed to derive gl_NumSubgroups for program %u; "
|
||||
"compute shaders may observe a driver-inconsistent subgroup count",
|
||||
program.GetExternalIndex());
|
||||
}
|
||||
}
|
||||
|
||||
// Vulkan's SPIR-V environment has no rectangle image dimension, so a
|
||||
// GL_TEXTURE_RECTANGLE lookup has to become the 2D one the texture is really
|
||||
// stored as - which addresses [0,1] where the application addressed texels.
|
||||
|
||||
Reference in New Issue
Block a user