mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Fix] (Review): decline a point-size program the device cannot run, bound the compile-failure source dump, and correct the pass-through rationale
This commit is contained in:
@@ -785,6 +785,36 @@ namespace MobileGL {
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool ShaderCompiler::ModuleDeclaresTessellationOrGeometryPointSize(const Vector<Uint32>& spirv) {
|
||||
if (spirv.empty()) {
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<spvtools::opt::IRContext> context = spvtools::BuildModule(
|
||||
SPV_ENV_VULKAN_1_1,
|
||||
MakeSpirvMessageConsumer("ModuleDeclaresTessellationOrGeometryPointSize"), spirv.data(),
|
||||
spirv.size());
|
||||
if (!context) {
|
||||
// Unparseable is not a verdict about point size. Say no, so the caller keeps
|
||||
// building the program: the module is already broken for other reasons and
|
||||
// the diagnostics that own that failure are better placed than this one.
|
||||
return false;
|
||||
}
|
||||
// The CAPABILITY, not the BuiltIn decoration, because the capability is exactly
|
||||
// what the feature gates: a module may declare gl_PerVertex with a PointSize
|
||||
// member and never access it, and glslang then emits no capability
|
||||
// (GlslangToSpv defers it to actual use) - such a module is legal without the
|
||||
// feature and must not be declined.
|
||||
for (const spvtools::opt::Instruction& capability : context->capabilities()) {
|
||||
if (capability.NumInOperands() < 1) continue;
|
||||
const auto declared = static_cast<spv::Capability>(capability.GetSingleWordInOperand(0));
|
||||
if (declared == spv::Capability::TessellationPointSize ||
|
||||
declared == spv::Capability::GeometryPointSize) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool ShaderCompiler::ModuleDeclaresFloat64(const Vector<Uint32>& spirv) {
|
||||
if (spirv.empty()) {
|
||||
// Same reasoning as ModuleDeclaresBufferTextureSampler: a stage that produced
|
||||
|
||||
@@ -538,6 +538,15 @@ namespace MobileGL {
|
||||
// Asked of the FINAL bytes, so it answers for whatever the backend transform
|
||||
// chain actually produced rather than for what it was asked to produce.
|
||||
static Bool ModuleDeclaresTransformFeedback(const Vector<Uint32>& spirv);
|
||||
// Does this module declare TessellationPointSize or GeometryPointSize - i.e. does
|
||||
// it need VkPhysicalDeviceFeatures::shaderTessellationAndGeometryPointSize before
|
||||
// a pipeline built from it is legal usage (VUID-RuntimeSpirv-PointSize-06439)?
|
||||
// glslang emits either capability from any access to the PointSize built-in in a
|
||||
// tessellation or geometry stage, which desktop GL treats as an ordinary
|
||||
// per-vertex output, so a program that is perfectly legal in GL can need a Vulkan
|
||||
// feature the device does not have. Callers only ask when the feature is OFF, so
|
||||
// the module parse costs nothing on a device that has it.
|
||||
static Bool ModuleDeclaresTessellationOrGeometryPointSize(const Vector<Uint32>& spirv);
|
||||
|
||||
// True when the module still declares a 64-bit float type. After
|
||||
// SanitizeAndOptimizeBinary that can only mean DemoteFloat64Pass declined the
|
||||
|
||||
Reference in New Issue
Block a user