Skip to content

validation of 16bit storage extension: Doesn't catch comparisons of fp16 values #2729

@dneto0

Description

@dneto0

Example SPIR-V 1.0 input, which is a modified version of the shader in dEQP-VK.spirv_assembly.instruction.compute.opphi.vartype_float16

               OpCapability Shader
               OpCapability StorageBuffer16BitAccess
               OpExtension "SPV_KHR_16bit_storage"
               OpMemoryModel Logical GLSL450
               OpEntryPoint GLCompute %main "main" %gl_GlobalInvocationID
               OpExecutionMode %main LocalSize 1 1 1
               OpSource GLSL 430
               OpName %main "main"
               OpName %gl_GlobalInvocationID "gl_GlobalInvocationID"
               OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
               OpDecorate %_struct_3 BufferBlock
               OpDecorate %4 DescriptorSet 0
               OpDecorate %4 Binding 0
               OpDecorate %5 DescriptorSet 0
               OpDecorate %5 Binding 1
               OpDecorate %_runtimearr_half ArrayStride 2
               OpMemberDecorate %_struct_3 0 Offset 0
       %half = OpTypeFloat 16
%_ptr_Uniform_half = OpTypePointer Uniform %half
%_runtimearr_half = OpTypeRuntimeArray %half
       %bool = OpTypeBool
       %void = OpTypeVoid
         %11 = OpTypeFunction %void
       %uint = OpTypeInt 32 0
        %int = OpTypeInt 32 1
      %float = OpTypeFloat 32
     %v3uint = OpTypeVector %uint 3
    %v3float = OpTypeVector %float 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%_ptr_Uniform_int = OpTypePointer Uniform %int
%_ptr_Uniform_float = OpTypePointer Uniform %float
%_runtimearr_int = OpTypeRuntimeArray %int
%_runtimearr_float = OpTypeRuntimeArray %float
  %_struct_3 = OpTypeStruct %_runtimearr_half
%_ptr_Uniform__struct_3 = OpTypePointer Uniform %_struct_3
          %4 = OpVariable %_ptr_Uniform__struct_3 Uniform
          %5 = OpVariable %_ptr_Uniform__struct_3 Uniform
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
      %int_0 = OpConstant %int 0
%float_0 = OpConstant %float 0x0p+0
%float_1 = OpConstant %float 0x1p+0
%float_n1 = OpConstant %float -0x1p+0

       %main = OpFunction %void None %11
         %27 = OpLabel
%half_0x0p_0 = OpFConvert %half %float_0
%half_0x1p_0 = OpFConvert %half %float_1
%half_n0x1p_0 = OpFConvert %half %float_n1
         %28 = OpLoad %v3uint %gl_GlobalInvocationID
         %29 = OpCompositeExtract %uint %28 0
         %30 = OpAccessChain %_ptr_Uniform_half %4 %int_0 %29
         %31 = OpLoad %half %30
         %32 = OpFOrdGreaterThan %bool %31 %half_0x0p_0
               OpSelectionMerge %33 None
               OpBranchConditional %32 %34 %35
         %34 = OpLabel
               OpBranch %33
         %35 = OpLabel
               OpBranch %33
         %33 = OpLabel
         %36 = OpPhi %half %half_0x1p_0 %34 %half_n0x1p_0 %35
         %37 = OpAccessChain %_ptr_Uniform_half %5 %int_0 %29
               OpStore %37 %36
               OpReturn
               OpFunctionEnd

The OpFOrdGreaterThan is not on the whitelist of permitted instructions that may operate on fp16 values when only the storage extension is enabled.
But this passes validation with top-of-tree SPIRV-Tools.

cc: @jeffbolznv

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions