KhronosGroup / SPIRV-Tools

Apache License 2.0
1.04k stars 545 forks source link

spirv-val: Variable pointer might not have a required storage class #3650

Open Vasniktel opened 4 years ago

Vasniktel commented 4 years ago

The spec says

Variable pointer: A pointer of logical pointer type that results from one of the following instructions: ... OpPhi ...

It also says that

A variable pointer must point to one of the following storage classes: StorageBuffer Workgroup (if the VariablePointers capability is declared)

However, the following code

               OpCapability VariablePointers
          %1 = OpExtInstImport "GLSL.std.450"
               OpMemoryModel Logical GLSL450
               OpEntryPoint Fragment %4 "main"
               OpExecutionMode %4 OriginUpperLeft
               OpSource ESSL 310
          %2 = OpTypeVoid
          %3 = OpTypeFunction %2
          %6 = OpTypeFloat 32
         %11 = OpConstant %6 23
          %7 = OpTypePointer Function %6
          %4 = OpFunction %2 None %3

          %5 = OpLabel
          %8 = OpVariable %7 Function
               OpBranch %9

          %9 = OpLabel
         %10 = OpPhi %7 %8 %5
               OpStore %10 %11
               OpReturn

               OpFunctionEnd

passes the validation even though the result of the OpPhi (%10) has Function storage class.

Vasniktel commented 4 years ago

@alan-baker @s-perron ping

alan-baker commented 4 years ago

Yes, variable pointer validation has some gaps. There was some work to improve it, but it went dead. Hopefully it will be revived.