298 lines
8.5 KiB
Plaintext
298 lines
8.5 KiB
Plaintext
#!amber
|
|
# Copyright (c) 2025 The Khronos Group Inc.
|
|
# Copyright (c) 2025 Valve Corporation.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
SHADER compute compute_shader SPIRV-ASM
|
|
; SPIR-V
|
|
; Version: 1.0
|
|
; Generator: Khronos Glslang Reference Front End; 11
|
|
; Bound: 61
|
|
; Schema: 0
|
|
OpCapability Shader
|
|
%1 = OpExtInstImport "GLSL.std.450"
|
|
OpMemoryModel Logical GLSL450
|
|
OpEntryPoint GLCompute %main "main" %gl_LocalInvocationIndex
|
|
OpExecutionMode %main LocalSize 64 1 1
|
|
OpSource GLSL 460
|
|
OpSourceExtension "GL_EXT_shader_explicit_arithmetic_types"
|
|
OpName %main "main"
|
|
OpName %idx "idx"
|
|
OpName %gl_LocalInvocationIndex "gl_LocalInvocationIndex"
|
|
OpName %PushConstantBlock "PushConstantBlock"
|
|
OpMemberName %PushConstantBlock 0 "count"
|
|
OpName %_ ""
|
|
OpName %s "s"
|
|
OpName %SignificandBlock "SignificandBlock"
|
|
OpMemberName %SignificandBlock 0 "significands"
|
|
OpName %__0 ""
|
|
OpName %e "e"
|
|
OpName %ExponentsBlock "ExponentsBlock"
|
|
OpMemberName %ExponentsBlock 0 "exponents"
|
|
OpName %__1 ""
|
|
OpName %r "r"
|
|
OpName %ResultsBlock "ResultsBlock"
|
|
OpMemberName %ResultsBlock 0 "results"
|
|
OpName %__2 ""
|
|
OpDecorate %gl_LocalInvocationIndex BuiltIn LocalInvocationIndex
|
|
OpDecorate %PushConstantBlock Block
|
|
OpMemberDecorate %PushConstantBlock 0 Offset 0
|
|
OpDecorate %_runtimearr_float ArrayStride 4
|
|
OpDecorate %SignificandBlock BufferBlock
|
|
OpMemberDecorate %SignificandBlock 0 NonWritable
|
|
OpMemberDecorate %SignificandBlock 0 Offset 0
|
|
OpDecorate %__0 NonWritable
|
|
OpDecorate %__0 Binding 0
|
|
OpDecorate %__0 DescriptorSet 0
|
|
OpDecorate %_runtimearr_int ArrayStride 4
|
|
OpDecorate %ExponentsBlock BufferBlock
|
|
OpMemberDecorate %ExponentsBlock 0 NonWritable
|
|
OpMemberDecorate %ExponentsBlock 0 Offset 0
|
|
OpDecorate %__1 NonWritable
|
|
OpDecorate %__1 Binding 1
|
|
OpDecorate %__1 DescriptorSet 0
|
|
OpDecorate %_runtimearr_float_0 ArrayStride 4
|
|
OpDecorate %ResultsBlock BufferBlock
|
|
OpMemberDecorate %ResultsBlock 0 Offset 0
|
|
OpDecorate %__2 Binding 2
|
|
OpDecorate %__2 DescriptorSet 0
|
|
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
|
|
%void = OpTypeVoid
|
|
%3 = OpTypeFunction %void
|
|
%uint = OpTypeInt 32 0
|
|
%_ptr_Function_uint = OpTypePointer Function %uint
|
|
%_ptr_Input_uint = OpTypePointer Input %uint
|
|
%gl_LocalInvocationIndex = OpVariable %_ptr_Input_uint Input
|
|
%PushConstantBlock = OpTypeStruct %uint
|
|
%_ptr_PushConstant_PushConstantBlock = OpTypePointer PushConstant %PushConstantBlock
|
|
%_ = OpVariable %_ptr_PushConstant_PushConstantBlock PushConstant
|
|
%int = OpTypeInt 32 1
|
|
%int_0 = OpConstant %int 0
|
|
%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint
|
|
%bool = OpTypeBool
|
|
%float = OpTypeFloat 32
|
|
%_ptr_Function_float = OpTypePointer Function %float
|
|
%_runtimearr_float = OpTypeRuntimeArray %float
|
|
%SignificandBlock = OpTypeStruct %_runtimearr_float
|
|
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
|
|
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
|
|
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
|
%_ptr_Function_int = OpTypePointer Function %int
|
|
%_runtimearr_int = OpTypeRuntimeArray %int
|
|
%ExponentsBlock = OpTypeStruct %_runtimearr_int
|
|
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
|
|
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
|
|
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
|
%_runtimearr_float_0 = OpTypeRuntimeArray %float
|
|
%ResultsBlock = OpTypeStruct %_runtimearr_float_0
|
|
%_ptr_Uniform_ResultsBlock = OpTypePointer Uniform %ResultsBlock
|
|
%__2 = OpVariable %_ptr_Uniform_ResultsBlock Uniform
|
|
%v3uint = OpTypeVector %uint 3
|
|
%uint_64 = OpConstant %uint 64
|
|
%uint_1 = OpConstant %uint 1
|
|
%gl_WorkGroupSize = OpConstantComposite %v3uint %uint_64 %uint_1 %uint_1
|
|
%main = OpFunction %void None %3
|
|
%5 = OpLabel
|
|
%idx = OpVariable %_ptr_Function_uint Function
|
|
%s = OpVariable %_ptr_Function_float Function
|
|
%e = OpVariable %_ptr_Function_int Function
|
|
%r = OpVariable %_ptr_Function_float Function
|
|
%11 = OpLoad %uint %gl_LocalInvocationIndex
|
|
OpStore %idx %11
|
|
%12 = OpLoad %uint %idx
|
|
%19 = OpAccessChain %_ptr_PushConstant_uint %_ %int_0
|
|
%20 = OpLoad %uint %19
|
|
%22 = OpULessThan %bool %12 %20
|
|
OpSelectionMerge %24 None
|
|
OpBranchConditional %22 %23 %24
|
|
%23 = OpLabel
|
|
%32 = OpLoad %uint %idx
|
|
%34 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %32
|
|
%35 = OpLoad %float %34
|
|
OpStore %s %35
|
|
%42 = OpLoad %uint %idx
|
|
%44 = OpAccessChain %_ptr_Uniform_int %__1 %int_0 %42
|
|
%45 = OpLoad %int %44
|
|
OpStore %e %45
|
|
%47 = OpLoad %float %s
|
|
%48 = OpLoad %int %e
|
|
%49 = OpExtInst %float %1 Ldexp %47 %48
|
|
OpStore %r %49
|
|
%54 = OpLoad %uint %idx
|
|
%55 = OpLoad %float %r
|
|
%56 = OpAccessChain %_ptr_Uniform_float %__2 %int_0 %54
|
|
OpStore %56 %55
|
|
OpBranch %24
|
|
%24 = OpLabel
|
|
OpReturn
|
|
OpFunctionEnd
|
|
|
|
END
|
|
|
|
BUFFER significands DATA_TYPE float DATA
|
|
-1.0
|
|
-1.0
|
|
-1.0
|
|
-1.0
|
|
-1.0
|
|
-1.0
|
|
-1.0
|
|
-1.0
|
|
0.5
|
|
0.5
|
|
0.5
|
|
0.5
|
|
0.5
|
|
0.5
|
|
0.5
|
|
0.5
|
|
1.25
|
|
1.25
|
|
1.25
|
|
1.25
|
|
1.25
|
|
1.25
|
|
1.25
|
|
1.25
|
|
2.0
|
|
2.0
|
|
2.0
|
|
2.0
|
|
2.0
|
|
2.0
|
|
2.0
|
|
2.0
|
|
END
|
|
|
|
BUFFER exponents DATA_TYPE int32 DATA
|
|
1
|
|
0
|
|
-1
|
|
-2
|
|
-14
|
|
-2147483643
|
|
-2147483644
|
|
-2147483645
|
|
1
|
|
0
|
|
-1
|
|
-2
|
|
-14
|
|
-2147483643
|
|
-2147483644
|
|
-2147483645
|
|
1
|
|
0
|
|
-1
|
|
-2
|
|
-14
|
|
-2147483643
|
|
-2147483644
|
|
-2147483645
|
|
1
|
|
0
|
|
-1
|
|
-2
|
|
-14
|
|
-2147483643
|
|
-2147483644
|
|
-2147483645
|
|
END
|
|
|
|
BUFFER results DATA_TYPE float DATA
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
0.0
|
|
END
|
|
|
|
BUFFER pc DATA_TYPE uint32 DATA
|
|
32
|
|
END
|
|
|
|
PIPELINE compute pipeline
|
|
ATTACH compute_shader
|
|
|
|
BIND BUFFER significands AS storage DESCRIPTOR_SET 0 BINDING 0
|
|
BIND BUFFER exponents AS storage DESCRIPTOR_SET 0 BINDING 1
|
|
BIND BUFFER results AS storage DESCRIPTOR_SET 0 BINDING 2
|
|
BIND BUFFER pc AS push_constant
|
|
END
|
|
|
|
RUN pipeline 1 1 1
|
|
|
|
EXPECT results IDX 0 TOLERANCE .0001 EQ -2.0
|
|
EXPECT results IDX 4 TOLERANCE .0001 EQ -1.0
|
|
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.5
|
|
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.25
|
|
EXPECT results IDX 16 TOLERANCE .0001 EQ -6.103515625e-05
|
|
EXPECT results IDX 20 TOLERANCE .0001 EQ -0.0
|
|
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.0
|
|
EXPECT results IDX 28 TOLERANCE .0001 EQ -0.0
|
|
EXPECT results IDX 32 TOLERANCE .0001 EQ 1.0
|
|
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.5
|
|
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.25
|
|
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.125
|
|
EXPECT results IDX 48 TOLERANCE .0001 EQ 3.0517578125e-05
|
|
EXPECT results IDX 52 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 64 TOLERANCE .0001 EQ 2.5
|
|
EXPECT results IDX 68 TOLERANCE .0001 EQ 1.25
|
|
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.625
|
|
EXPECT results IDX 76 TOLERANCE .0001 EQ 0.3125
|
|
EXPECT results IDX 80 TOLERANCE .0001 EQ 7.62939453125e-05
|
|
EXPECT results IDX 84 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 92 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 96 TOLERANCE .0001 EQ 4.0
|
|
EXPECT results IDX 100 TOLERANCE .0001 EQ 2.0
|
|
EXPECT results IDX 104 TOLERANCE .0001 EQ 1.0
|
|
EXPECT results IDX 108 TOLERANCE .0001 EQ 0.5
|
|
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0001220703125
|
|
EXPECT results IDX 116 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
|
|
EXPECT results IDX 124 TOLERANCE .0001 EQ 0.0
|
|
|