KhronosGroup/Vulkan-LoaderAndValidationLayers

SPIR-V : Add Validation for Interface of Entry Point

metora opened this issue · 3 comments

Hi

I write a Mesa-IR to SPIR-V Translator, and it's fine on NVIDIA and Adreno driver.
But It's crash on MALI driver, so I found the problem is I lost add gl_Position..

OpEntryPoint Vertex %6 "main" %13
I lost the %13.

It's crash on MALI Offline Shader Compiler also.

Thanks

; SPIR-V
; Version: 1.0
; Generator: X-LEGEND Mesa-IR/SPIR-V Translator; 0
; Bound: 17
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %6 "main" %13
OpSource ESSL 310
OpName %6 "main"
OpName %10 "gl_PerVertex"
OpMemberName %10 0 "gl_Position"
OpDecorate %10 Block
OpMemberDecorate %10 0 BuiltIn Position
%2 = OpTypeFloat 32
%3 = OpTypeVector %2 4
%4 = OpTypeVoid
%5 = OpTypeFunction %4
%8 = OpConstant %2 1
%9 = OpConstantComposite %3 %8 %8 %8 %8
%12 = OpTypePointer Output %3
%14 = OpTypeInt 32 1
%10 = OpTypeStruct %3
%11 = OpTypePointer Output %10
%13 = OpVariable %11 Output
%15 = OpConstant %14 0
%6 = OpFunction %4 None %5
%7 = OpLabel
%16 = OpAccessChain %12 %13 %15
OpStore %16 %9
OpReturn
OpFunctionEnd

We should probably enforce this in SPIRV-Tools rather than here.

That is, SPIRV-Tools should enforce, for every entrypoint:

  • Every id listed in the entrypoint is for an OpVariable in the Input or Output storage class.
  • The static call graph rooted at that entrypoint does not reference any /other/ OpVariables in the Input or Output storage class which are not listed in the entrypoint. (your case)

I'm going to move this to the new repo: KhronosGroup/Vulkan-ValidationLayers