This commit is contained in:
2026-05-06 23:44:13 +02:00
parent a5f787d80f
commit fd7038b853
1574 changed files with 365439 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
How the Amber files were generated:
1. Wrote template.glsl.
This base shader is a compute shader with 64 invocations that receives 3
buffers.
a. One to receive the significands (some kind of floating point) for the
ldexp operation.
b. Another one that contains the exponents (some kind of integer) for the
ldexp operation.
c. Another one to store the results in the same kind of floating point type
as the significands.
The numbers (the buffer contents) will be the same for scalars, vec2 and vec4,
but when interpreted as scalars, vec2 and vec4 the number of actual operations
varies. As the shader always has 64 invocations, we pass the actual operation
count in a push constant and check the invocation index against it.
We run the ldexp operation and store the result in the results buffer.
2. Run gen_shaders.py.
This generates glsl versions of all shaders for all desired type combinations
of significands and exponents. These are the ldexp*.glsl files.
3. Compile all generated shaders to SPIR-V with gen_spv.sh.
This generates the ldexp*.spv files. Unfortunately, glslangValidator will fail
to compile variants in which the exponent is a 64-bit integer. Keep reading for
the fix to this issue below.
4. Disassemble the generated SPIR-V files with gen_spvasm.sh.
This generates the ldexp*.spvasm files.
5. Manually add the missing variants glslang was not able to compile
Based on the 16-bit exponent variants, we can generate 64-bit ones but we need
to:
a. Replace the Int16 with the Int64 capability.
b. Remove unneeded 16-bit storage capabilities if we do not use Float16.
c. Adjust the stride in the input exponents array.
6. Manually change the generated SPIR-V assembly
glslang likes to cast the exponent to a 32-bit integer sometimes, so we need to
remove and change a couple of instructions to make sure the ldexp operations
have the right exponent type. This applies to almost every generated file.
7. Wrote template.amber
This will be used to generate .amber files based on each of the final .spvasm
files.
8. Run gen_amber.py
This will generate the final .amber files with the right significands,
exponents, buffer contents, shaders, result checks, etc.
@@ -0,0 +1,9 @@
ldexp_f16vec2_i64vec2.glsl.spv.spvasm
ldexp_f16vec4_i64vec4.glsl.spv.spvasm
ldexp_f32vec2_i64vec2.glsl.spv.spvasm
ldexp_f32vec4_i64vec4.glsl.spv.spvasm
ldexp_f64vec2_i64vec2.glsl.spv.spvasm
ldexp_f64vec4_i64vec4.glsl.spv.spvasm
ldexp_float16_t_int64_t.glsl.spv.spvasm
ldexp_float32_t_int64_t.glsl.spv.spvasm
ldexp_float64_t_int64_t.glsl.spv.spvasm
+168
View File
@@ -0,0 +1,168 @@
#!/usr/bin/env python
#
# 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.
#
import sys
import re
import math
# These are fixed.
significands = [
-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,
]
initial_results = [
.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,
]
fixed_exponents = [1, 0, -1, -2]
optional_exponents = [-14, -126, -1022]
target_exponent_count = 8
exponent_replicas = len(set(significands)) # To pair each exponent with reach significand.
def get_component_count_from_type_name(type_name):
if 'vec' in type_name:
return int(type_name[-1])
return 1
def get_bits_from_type_name(type_name):
match_obj = re.search(r'^[a-z]*?([0-9]+).*', type_name)
if match_obj is not None:
return int(match_obj.group(1))
return 0
def min_exponent(bit_count):
return {16: -14, 32: -126, 64: -1022}[bit_count]
def bits_min(bit_count):
return -(2**(bit_count - 1))
def get_amber_float_type(bit_count):
return {16: 'float16', 32: 'float', 64: 'double'}[bit_count]
def get_amber_int_type(bit_count):
return 'int' + str(bit_count)
def read_full_file(file_name):
with open(file_name, 'r') as stream:
contents = stream.read()
return contents
def get_features(asm):
caps = re.findall(r'OpCapability \w+', asm)
caps = [x.split()[1] for x in caps]
caps = [x for x in caps if x != 'Shader']
cap_to_feature = {
'Float16': ['Float16Int8Features.shaderFloat16'],
'Float64': ['shaderFloat64'],
'Int16': ['shaderInt16'],
'Int64': ['shaderInt64'],
'Int8': ['Float16Int8Features.shaderInt8'],
'StorageBuffer16BitAccess': ['Storage16BitFeatures.storageBuffer16BitAccess', 'Storage16BitFeatures.uniformAndStorageBuffer16BitAccess'],
'UniformAndStorageBuffer8BitAccess': ['Storage8BitFeatures.uniformAndStorageBuffer8BitAccess'],
}
features = []
for c in caps:
cap_features = cap_to_feature[c]
for f in cap_features:
features.append('DEVICE_FEATURE %s' % (f,))
return '\n'.join(features)
amber_template = read_full_file('template.amber')
for arg_idx in range(1, len(sys.argv), 1):
spirv_asm = read_full_file(sys.argv[arg_idx])
device_features = get_features(spirv_asm)
file_name = sys.argv[arg_idx]
simplified_name = file_name.replace('_t', '')
match_obj = re.match(r'^ldexp_(.*?)_(.*?).glsl.spv.spvasm', simplified_name)
if match_obj is None:
print('%s does not match the expected file name' % (file_name, ), file=sys.stderr)
continue
significand_type = match_obj.group(1)
exponent_type = match_obj.group(2)
component_count = get_component_count_from_type_name(significand_type)
inv_count = int(len(significands) / component_count)
significand_bits = get_bits_from_type_name(significand_type)
exponent_bits = get_bits_from_type_name(exponent_type)
if significand_bits == 0 or exponent_bits == 0:
print('Unknown bits in significand or exponent: (%s, %s)' % (significand_bits, exponent_bits), file=sys.stderr)
continue
smallest_int_exponent = bits_min(exponent_bits) # For the integer exponent operand in the ldexp call.
smallest_float_exponent = min_exponent(significand_bits) # According to the exponent bits in the float type.
# Try exponents in the limits.
used_exponents = [x for x in fixed_exponents]
for opt_exp in optional_exponents:
if opt_exp > smallest_int_exponent and opt_exp > smallest_float_exponent:
used_exponents.append(opt_exp)
# Try really small exponents, only taking into account the integer exponent operand.
# Results when using these exponents may be flushed to zero according to the spec.
# At the same time, the upper part of these numbers is all zeros except in the most significant bit.
# If they get truncated by mistake, it results in a positive exponent.
while len(used_exponents) < target_exponent_count:
missing = target_exponent_count - len(used_exponents)
used_exponents.append(smallest_int_exponent + missing + 2) # +2 to make them non-obvious.
# Repeat exponents multipe times to combine them with each significand.
replica = [x for x in used_exponents]
for replica_idx in range(0, exponent_replicas - 1):
used_exponents.extend(replica)
amber_float_type = get_amber_float_type(significand_bits)
amber_int_type = get_amber_int_type(exponent_bits)
expects = []
for (idx, significand) in enumerate(significands):
exponent = used_exponents[idx]
result = math.ldexp(significand, exponent)
offset = int((significand_bits * idx) / 8) # in bytes
expect = 'EXPECT results IDX %s TOLERANCE .0001 EQ %s\n' % (offset, result)
expects.append(expect)
expects_str = ''.join(expects)
amber_contents = amber_template.format(device_features=device_features,
spirv_asm=spirv_asm,
significands='\n'.join(str(x) for x in significands),
exponents='\n'.join(str(x) for x in used_exponents),
initial_results='\n'.join(str(x) for x in initial_results),
count=inv_count,
amber_float_type=amber_float_type,
amber_int_type=amber_int_type,
expects=expects_str)
output_file_name = 'ldexp_%s_%s.amber' % (significand_type, exponent_type)
with open(output_file_name, 'w') as stream:
stream.write(amber_contents)
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python
#
# 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.
#
import sys
TEMPLATE_NAME = 'template.glsl'
with open(TEMPLATE_NAME, 'r') as stream:
template = stream.read()
COMPONENT_COUNTS = [1, 2, 4]
FLOAT16 = ['float16_t', 'f16vec2', 'f16vec3', 'f16vec4']
FLOAT32 = ['float32_t', 'f32vec2', 'f32vec3', 'f32vec4']
FLOAT64 = ['float64_t', 'f64vec2', 'f64vec3', 'f64vec4']
INT8 = ['int8_t', 'i8vec2', 'i8vec3', 'i8vec4']
INT16 = ['int16_t', 'i16vec2', 'i16vec3', 'i16vec4']
INT32 = ['int32_t', 'i32vec2', 'i32vec3', 'i32vec4']
INT64 = ['int64_t', 'i64vec2', 'i64vec3', 'i64vec4']
for component_count in COMPONENT_COUNTS:
type_index = component_count - 1
for significand_type in (FLOAT16[type_index], FLOAT32[type_index], FLOAT64[type_index]):
for exponent_type in (INT8[type_index], INT16[type_index], INT32[type_index], INT64[type_index]):
shader_code = template.format(significand_type=significand_type, exponent_type=exponent_type)
file_name = 'ldexp_{significand_type}_{exponent_type}.glsl'.format(significand_type=significand_type, exponent_type=exponent_type)
with open(file_name, 'w') as stream:
stream.write(shader_code)
sys.exit()
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
for f in ldexp_f*.glsl; do
glslangValidator -V -o ${f}.spv --target-env vulkan1.0 -S comp ${f}
done
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
for f in ldexp*.spv; do
spirv-dis -o ${f}.spvasm $f
done
+9
View File
@@ -0,0 +1,9 @@
ldexp_f16vec2_i64vec2.glsl
ldexp_f16vec4_i64vec4.glsl
ldexp_f32vec2_i64vec2.glsl
ldexp_f32vec4_i64vec4.glsl
ldexp_f64vec2_i64vec2.glsl
ldexp_f64vec4_i64vec4.glsl
ldexp_float16_t_int64_t.glsl
ldexp_float32_t_int64_t.glsl
ldexp_float64_t_int64_t.glsl
@@ -0,0 +1,307 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2half 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_v2short 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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%short = OpTypeInt 16 1
%v2short = OpTypeVector %short 2
%_ptr_Function_v2short = OpTypePointer Function %v2short
%_runtimearr_v2short = OpTypeRuntimeArray %v2short
%ExponentsBlock = OpTypeStruct %_runtimearr_v2short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2short = OpTypePointer Uniform %v2short
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2short Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2short %__1 %int_0 %45
%48 = OpLoad %v2short %47
OpStore %e %48
%50 = OpLoad %v2half %s
%51 = OpLoad %v2short %e
%52 = OpExtInst %v2half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v2half %r
%59 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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 int16 DATA
1
0
-1
-2
-32762
-32763
-32764
-32765
1
0
-1
-2
-32762
-32763
-32764
-32765
1
0
-1
-2
-32762
-32763
-32764
-32765
1
0
-1
-2
-32762
-32763
-32764
-32765
END
BUFFER results DATA_TYPE float16 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
16
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 10 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 14 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 26 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 28 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 30 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 42 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 46 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 58 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 62 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec2 s = significands[idx];
const i16vec2 e = exponents[idx];
const f16vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2half 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_v2short 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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%short = OpTypeInt 16 1
%v2short = OpTypeVector %short 2
%_ptr_Function_v2short = OpTypePointer Function %v2short
%_runtimearr_v2short = OpTypeRuntimeArray %v2short
%ExponentsBlock = OpTypeStruct %_runtimearr_v2short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2short = OpTypePointer Uniform %v2short
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2short Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2short %__1 %int_0 %45
%48 = OpLoad %v2short %47
OpStore %e %48
%50 = OpLoad %v2half %s
%51 = OpLoad %v2short %e
%52 = OpExtInst %v2half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v2half %r
%59 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,304 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2half 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_v2int ArrayStride 8
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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_runtimearr_v2int = OpTypeRuntimeArray %v2int
%ExponentsBlock = OpTypeStruct %_runtimearr_v2int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2int Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v2int %__1 %int_0 %44
%47 = OpLoad %v2int %46
OpStore %e %47
%49 = OpLoad %v2half %s
%50 = OpLoad %v2int %e
%51 = OpExtInst %v2half %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v2half %r
%58 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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
-2147483642
-2147483643
-2147483644
-2147483645
1
0
-1
-2
-2147483642
-2147483643
-2147483644
-2147483645
1
0
-1
-2
-2147483642
-2147483643
-2147483644
-2147483645
1
0
-1
-2
-2147483642
-2147483643
-2147483644
-2147483645
END
BUFFER results DATA_TYPE float16 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
16
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 10 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 14 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 26 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 28 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 30 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 42 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 46 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 58 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 62 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i32vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec2 s = significands[idx];
const i32vec2 e = exponents[idx];
const f16vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,127 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2half 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_v2int ArrayStride 8
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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_runtimearr_v2int = OpTypeRuntimeArray %v2int
%ExponentsBlock = OpTypeStruct %_runtimearr_v2int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2int Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v2int %__1 %int_0 %44
%47 = OpLoad %v2int %46
OpStore %e %47
%49 = OpLoad %v2half %s
%50 = OpLoad %v2int %e
%51 = OpExtInst %v2half %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v2half %r
%58 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,307 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE shaderInt64
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int64
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2half 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_v2long ArrayStride 16
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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%long = OpTypeInt 64 1
%v2long = OpTypeVector %long 2
%_ptr_Function_v2long = OpTypePointer Function %v2long
%_runtimearr_v2long = OpTypeRuntimeArray %v2long
%ExponentsBlock = OpTypeStruct %_runtimearr_v2long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2long = OpTypePointer Uniform %v2long
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2long Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2long %__1 %int_0 %45
%48 = OpLoad %v2long %47
OpStore %e %48
%50 = OpLoad %v2half %s
%51 = OpLoad %v2long %e
%52 = OpExtInst %v2half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v2half %r
%59 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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 int64 DATA
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
END
BUFFER results DATA_TYPE float16 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
16
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 10 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 14 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 26 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 28 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 30 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 42 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 46 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 58 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 62 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec2 s = significands[idx];
const i16vec2 e = exponents[idx];
const f16vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int64
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2half 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_v2long ArrayStride 16
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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%long = OpTypeInt 64 1
%v2long = OpTypeVector %long 2
%_ptr_Function_v2long = OpTypePointer Function %v2long
%_runtimearr_v2long = OpTypeRuntimeArray %v2long
%ExponentsBlock = OpTypeStruct %_runtimearr_v2long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2long = OpTypePointer Uniform %v2long
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2long Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2long %__1 %int_0 %45
%48 = OpLoad %v2long %47
OpStore %e %48
%50 = OpLoad %v2half %s
%51 = OpLoad %v2long %e
%52 = OpExtInst %v2half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v2half %r
%59 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,311 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE Float16Int8Features.shaderInt8
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
DEVICE_FEATURE Storage8BitFeatures.uniformAndStorageBuffer8BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int8
OpCapability StorageBuffer16BitAccess
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_16bit_storage"
OpExtension "SPV_KHR_8bit_storage"
%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_v2half 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_v2char ArrayStride 2
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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%char = OpTypeInt 8 1
%v2char = OpTypeVector %char 2
%_ptr_Function_v2char = OpTypePointer Function %v2char
%_runtimearr_v2char = OpTypeRuntimeArray %v2char
%ExponentsBlock = OpTypeStruct %_runtimearr_v2char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2char = OpTypePointer Uniform %v2char
%v2int = OpTypeVector %int 2
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2char Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2char %__1 %int_0 %45
%48 = OpLoad %v2char %47
OpStore %e %48
%50 = OpLoad %v2half %s
%51 = OpLoad %v2char %e
%54 = OpExtInst %v2half %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2half %r
%61 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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 int8 DATA
1
0
-1
-2
-122
-123
-124
-125
1
0
-1
-2
-122
-123
-124
-125
1
0
-1
-2
-122
-123
-124
-125
1
0
-1
-2
-122
-123
-124
-125
END
BUFFER results DATA_TYPE float16 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
16
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -1.88079096131566e-37
EXPECT results IDX 10 TOLERANCE .0001 EQ -9.4039548065783e-38
EXPECT results IDX 12 TOLERANCE .0001 EQ -4.70197740328915e-38
EXPECT results IDX 14 TOLERANCE .0001 EQ -2.350988701644575e-38
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 26 TOLERANCE .0001 EQ 4.70197740328915e-38
EXPECT results IDX 28 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 30 TOLERANCE .0001 EQ 1.1754943508222875e-38
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 2.350988701644575e-37
EXPECT results IDX 42 TOLERANCE .0001 EQ 1.1754943508222875e-37
EXPECT results IDX 44 TOLERANCE .0001 EQ 5.877471754111438e-38
EXPECT results IDX 46 TOLERANCE .0001 EQ 2.938735877055719e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 3.76158192263132e-37
EXPECT results IDX 58 TOLERANCE .0001 EQ 1.88079096131566e-37
EXPECT results IDX 60 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 62 TOLERANCE .0001 EQ 4.70197740328915e-38
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i8vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec2 s = significands[idx];
const i8vec2 e = exponents[idx];
const f16vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,132 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int8
OpCapability StorageBuffer16BitAccess
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_16bit_storage"
OpExtension "SPV_KHR_8bit_storage"
%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_v2half 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_v2char ArrayStride 2
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_v2half_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
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%_ptr_Function_v2half = OpTypePointer Function %v2half
%_runtimearr_v2half = OpTypeRuntimeArray %v2half
%SignificandBlock = OpTypeStruct %_runtimearr_v2half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2half = OpTypePointer Uniform %v2half
%char = OpTypeInt 8 1
%v2char = OpTypeVector %char 2
%_ptr_Function_v2char = OpTypePointer Function %v2char
%_runtimearr_v2char = OpTypeRuntimeArray %v2char
%ExponentsBlock = OpTypeStruct %_runtimearr_v2char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2char = OpTypePointer Uniform %v2char
%v2int = OpTypeVector %int 2
%_runtimearr_v2half_0 = OpTypeRuntimeArray %v2half
%ResultsBlock = OpTypeStruct %_runtimearr_v2half_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_v2half Function
%e = OpVariable %_ptr_Function_v2char Function
%r = OpVariable %_ptr_Function_v2half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2half %__0 %int_0 %33
%36 = OpLoad %v2half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2char %__1 %int_0 %45
%48 = OpLoad %v2char %47
OpStore %e %48
%50 = OpLoad %v2half %s
%51 = OpLoad %v2char %e
%54 = OpExtInst %v2half %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2half %r
%61 = OpAccessChain %_ptr_Uniform_v2half %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,307 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4half ArrayStride 8
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_v4short ArrayStride 8
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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%short = OpTypeInt 16 1
%v4short = OpTypeVector %short 4
%_ptr_Function_v4short = OpTypePointer Function %v4short
%_runtimearr_v4short = OpTypeRuntimeArray %v4short
%ExponentsBlock = OpTypeStruct %_runtimearr_v4short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4short = OpTypePointer Uniform %v4short
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4short Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4short %__1 %int_0 %45
%48 = OpLoad %v4short %47
OpStore %e %48
%50 = OpLoad %v4half %s
%51 = OpLoad %v4short %e
%52 = OpExtInst %v4half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v4half %r
%59 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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 int16 DATA
1
0
-1
-2
-32762
-32763
-32764
-32765
1
0
-1
-2
-32762
-32763
-32764
-32765
1
0
-1
-2
-32762
-32763
-32764
-32765
1
0
-1
-2
-32762
-32763
-32764
-32765
END
BUFFER results DATA_TYPE float16 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
8
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 10 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 14 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 26 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 28 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 30 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 42 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 46 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 58 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 62 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec4 s = significands[idx];
const i16vec4 e = exponents[idx];
const f16vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4half ArrayStride 8
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_v4short ArrayStride 8
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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%short = OpTypeInt 16 1
%v4short = OpTypeVector %short 4
%_ptr_Function_v4short = OpTypePointer Function %v4short
%_runtimearr_v4short = OpTypeRuntimeArray %v4short
%ExponentsBlock = OpTypeStruct %_runtimearr_v4short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4short = OpTypePointer Uniform %v4short
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4short Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4short %__1 %int_0 %45
%48 = OpLoad %v4short %47
OpStore %e %48
%50 = OpLoad %v4half %s
%51 = OpLoad %v4short %e
%52 = OpExtInst %v4half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v4half %r
%59 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,304 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4half ArrayStride 8
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_v4int ArrayStride 16
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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%_runtimearr_v4int = OpTypeRuntimeArray %v4int
%ExponentsBlock = OpTypeStruct %_runtimearr_v4int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4int = OpTypePointer Uniform %v4int
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4int Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v4int %__1 %int_0 %44
%47 = OpLoad %v4int %46
OpStore %e %47
%49 = OpLoad %v4half %s
%50 = OpLoad %v4int %e
%51 = OpExtInst %v4half %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v4half %r
%58 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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
-2147483642
-2147483643
-2147483644
-2147483645
1
0
-1
-2
-2147483642
-2147483643
-2147483644
-2147483645
1
0
-1
-2
-2147483642
-2147483643
-2147483644
-2147483645
1
0
-1
-2
-2147483642
-2147483643
-2147483644
-2147483645
END
BUFFER results DATA_TYPE float16 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
8
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 10 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 14 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 26 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 28 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 30 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 42 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 46 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 58 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 62 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i32vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec4 s = significands[idx];
const i32vec4 e = exponents[idx];
const f16vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,127 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4half ArrayStride 8
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_v4int ArrayStride 16
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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%_runtimearr_v4int = OpTypeRuntimeArray %v4int
%ExponentsBlock = OpTypeStruct %_runtimearr_v4int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4int = OpTypePointer Uniform %v4int
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4int Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v4int %__1 %int_0 %44
%47 = OpLoad %v4int %46
OpStore %e %47
%49 = OpLoad %v4half %s
%50 = OpLoad %v4int %e
%51 = OpExtInst %v4half %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v4half %r
%58 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,307 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE shaderInt64
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int64
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4half ArrayStride 8
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_v4long ArrayStride 32
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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%long = OpTypeInt 64 1
%v4long = OpTypeVector %long 4
%_ptr_Function_v4long = OpTypePointer Function %v4long
%_runtimearr_v4long = OpTypeRuntimeArray %v4long
%ExponentsBlock = OpTypeStruct %_runtimearr_v4long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4long = OpTypePointer Uniform %v4long
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4long Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4long %__1 %int_0 %45
%48 = OpLoad %v4long %47
OpStore %e %48
%50 = OpLoad %v4half %s
%51 = OpLoad %v4long %e
%52 = OpExtInst %v4half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v4half %r
%59 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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 int64 DATA
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-9223372036854775802
-9223372036854775803
-9223372036854775804
-9223372036854775805
END
BUFFER results DATA_TYPE float16 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
8
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 10 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 12 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 14 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 26 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 28 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 30 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 42 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 44 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 46 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 58 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 60 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 62 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec4 s = significands[idx];
const i16vec4 e = exponents[idx];
const f16vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 64
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int64
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4half ArrayStride 8
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_v4long ArrayStride 32
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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%long = OpTypeInt 64 1
%v4long = OpTypeVector %long 4
%_ptr_Function_v4long = OpTypePointer Function %v4long
%_runtimearr_v4long = OpTypeRuntimeArray %v4long
%ExponentsBlock = OpTypeStruct %_runtimearr_v4long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4long = OpTypePointer Uniform %v4long
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4long Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4long %__1 %int_0 %45
%48 = OpLoad %v4long %47
OpStore %e %48
%50 = OpLoad %v4half %s
%51 = OpLoad %v4long %e
%52 = OpExtInst %v4half %1 Ldexp %50 %51
OpStore %r %52
%57 = OpLoad %uint %idx
%58 = OpLoad %v4half %r
%59 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %57
OpStore %59 %58
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,311 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderFloat16
DEVICE_FEATURE Float16Int8Features.shaderInt8
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
DEVICE_FEATURE Storage8BitFeatures.uniformAndStorageBuffer8BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int8
OpCapability StorageBuffer16BitAccess
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_16bit_storage"
OpExtension "SPV_KHR_8bit_storage"
%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_v4half ArrayStride 8
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_v4char 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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%char = OpTypeInt 8 1
%v4char = OpTypeVector %char 4
%_ptr_Function_v4char = OpTypePointer Function %v4char
%_runtimearr_v4char = OpTypeRuntimeArray %v4char
%ExponentsBlock = OpTypeStruct %_runtimearr_v4char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4char = OpTypePointer Uniform %v4char
%v4int = OpTypeVector %int 4
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4char Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4char %__1 %int_0 %45
%48 = OpLoad %v4char %47
OpStore %e %48
%50 = OpLoad %v4half %s
%51 = OpLoad %v4char %e
%54 = OpExtInst %v4half %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4half %r
%61 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE float16 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 int8 DATA
1
0
-1
-2
-122
-123
-124
-125
1
0
-1
-2
-122
-123
-124
-125
1
0
-1
-2
-122
-123
-124
-125
1
0
-1
-2
-122
-123
-124
-125
END
BUFFER results DATA_TYPE float16 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
8
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 2 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 4 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 6 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 8 TOLERANCE .0001 EQ -1.88079096131566e-37
EXPECT results IDX 10 TOLERANCE .0001 EQ -9.4039548065783e-38
EXPECT results IDX 12 TOLERANCE .0001 EQ -4.70197740328915e-38
EXPECT results IDX 14 TOLERANCE .0001 EQ -2.350988701644575e-38
EXPECT results IDX 16 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 18 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 20 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 22 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 24 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 26 TOLERANCE .0001 EQ 4.70197740328915e-38
EXPECT results IDX 28 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 30 TOLERANCE .0001 EQ 1.1754943508222875e-38
EXPECT results IDX 32 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 34 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 36 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 38 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 40 TOLERANCE .0001 EQ 2.350988701644575e-37
EXPECT results IDX 42 TOLERANCE .0001 EQ 1.1754943508222875e-37
EXPECT results IDX 44 TOLERANCE .0001 EQ 5.877471754111438e-38
EXPECT results IDX 46 TOLERANCE .0001 EQ 2.938735877055719e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 50 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 52 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 54 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 56 TOLERANCE .0001 EQ 3.76158192263132e-37
EXPECT results IDX 58 TOLERANCE .0001 EQ 1.88079096131566e-37
EXPECT results IDX 60 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 62 TOLERANCE .0001 EQ 4.70197740328915e-38
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f16vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i8vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f16vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f16vec4 s = significands[idx];
const i8vec4 e = exponents[idx];
const f16vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,132 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability Int8
OpCapability StorageBuffer16BitAccess
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_16bit_storage"
OpExtension "SPV_KHR_8bit_storage"
%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_v4half ArrayStride 8
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_v4char 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_v4half_0 ArrayStride 8
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
%half = OpTypeFloat 16
%v4half = OpTypeVector %half 4
%_ptr_Function_v4half = OpTypePointer Function %v4half
%_runtimearr_v4half = OpTypeRuntimeArray %v4half
%SignificandBlock = OpTypeStruct %_runtimearr_v4half
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4half = OpTypePointer Uniform %v4half
%char = OpTypeInt 8 1
%v4char = OpTypeVector %char 4
%_ptr_Function_v4char = OpTypePointer Function %v4char
%_runtimearr_v4char = OpTypeRuntimeArray %v4char
%ExponentsBlock = OpTypeStruct %_runtimearr_v4char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4char = OpTypePointer Uniform %v4char
%v4int = OpTypeVector %int 4
%_runtimearr_v4half_0 = OpTypeRuntimeArray %v4half
%ResultsBlock = OpTypeStruct %_runtimearr_v4half_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_v4half Function
%e = OpVariable %_ptr_Function_v4char Function
%r = OpVariable %_ptr_Function_v4half 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4half %__0 %int_0 %33
%36 = OpLoad %v4half %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4char %__1 %int_0 %45
%48 = OpLoad %v4char %47
OpStore %e %48
%50 = OpLoad %v4half %s
%51 = OpLoad %v4char %e
%54 = OpExtInst %v4half %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4half %r
%61 = OpAccessChain %_ptr_Uniform_v4half %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,306 @@
#!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.
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2float ArrayStride 8
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_v2short 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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%short = OpTypeInt 16 1
%v2short = OpTypeVector %short 2
%_ptr_Function_v2short = OpTypePointer Function %v2short
%_runtimearr_v2short = OpTypeRuntimeArray %v2short
%ExponentsBlock = OpTypeStruct %_runtimearr_v2short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2short = OpTypePointer Uniform %v2short
%v2int = OpTypeVector %int 2
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2short Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2short %__1 %int_0 %45
%48 = OpLoad %v2short %47
OpStore %e %48
%50 = OpLoad %v2float %s
%51 = OpLoad %v2short %e
%54 = OpExtInst %v2float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2float %r
%61 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %59
OpStore %61 %60
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 int16 DATA
1
0
-1
-2
-14
-32763
-32764
-32765
1
0
-1
-2
-14
-32763
-32764
-32765
1
0
-1
-2
-14
-32763
-32764
-32765
1
0
-1
-2
-14
-32763
-32764
-32765
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
16
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
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec2 s = significands[idx];
const i16vec2 e = exponents[idx];
const f32vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2float ArrayStride 8
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_v2short 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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%short = OpTypeInt 16 1
%v2short = OpTypeVector %short 2
%_ptr_Function_v2short = OpTypePointer Function %v2short
%_runtimearr_v2short = OpTypeRuntimeArray %v2short
%ExponentsBlock = OpTypeStruct %_runtimearr_v2short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2short = OpTypePointer Uniform %v2short
%v2int = OpTypeVector %int 2
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2short Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2short %__1 %int_0 %45
%48 = OpLoad %v2short %47
OpStore %e %48
%50 = OpLoad %v2float %s
%51 = OpLoad %v2short %e
%54 = OpExtInst %v2float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2float %r
%61 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,299 @@
#!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: 63
; 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_v2float ArrayStride 8
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_v2int ArrayStride 8
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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_runtimearr_v2int = OpTypeRuntimeArray %v2int
%ExponentsBlock = OpTypeStruct %_runtimearr_v2int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2int Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v2int %__1 %int_0 %44
%47 = OpLoad %v2int %46
OpStore %e %47
%49 = OpLoad %v2float %s
%50 = OpLoad %v2int %e
%51 = OpExtInst %v2float %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v2float %r
%58 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %56
OpStore %58 %57
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
16
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
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i32vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec2 s = significands[idx];
const i32vec2 e = exponents[idx];
const f32vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,124 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; 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_v2float ArrayStride 8
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_v2int ArrayStride 8
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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_runtimearr_v2int = OpTypeRuntimeArray %v2int
%ExponentsBlock = OpTypeStruct %_runtimearr_v2int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2int Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v2int %__1 %int_0 %44
%47 = OpLoad %v2int %46
OpStore %e %47
%49 = OpLoad %v2float %s
%50 = OpLoad %v2int %e
%51 = OpExtInst %v2float %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v2float %r
%58 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,302 @@
#!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.
DEVICE_FEATURE shaderInt64
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int64
%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_v2float ArrayStride 8
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_v2long ArrayStride 16
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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%long = OpTypeInt 64 1
%v2long = OpTypeVector %long 2
%_ptr_Function_v2long = OpTypePointer Function %v2long
%_runtimearr_v2long = OpTypeRuntimeArray %v2long
%ExponentsBlock = OpTypeStruct %_runtimearr_v2long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2long = OpTypePointer Uniform %v2long
%v2int = OpTypeVector %int 2
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2long Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2long %__1 %int_0 %45
%48 = OpLoad %v2long %47
OpStore %e %48
%50 = OpLoad %v2float %s
%51 = OpLoad %v2long %e
%54 = OpExtInst %v2float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2float %r
%61 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %59
OpStore %61 %60
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 int64 DATA
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
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
16
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
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec2 s = significands[idx];
const i16vec2 e = exponents[idx];
const f32vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,127 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int64
%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_v2float ArrayStride 8
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_v2long ArrayStride 16
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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%long = OpTypeInt 64 1
%v2long = OpTypeVector %long 2
%_ptr_Function_v2long = OpTypePointer Function %v2long
%_runtimearr_v2long = OpTypeRuntimeArray %v2long
%ExponentsBlock = OpTypeStruct %_runtimearr_v2long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2long = OpTypePointer Uniform %v2long
%v2int = OpTypeVector %int 2
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2long Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2long %__1 %int_0 %45
%48 = OpLoad %v2long %47
OpStore %e %48
%50 = OpLoad %v2float %s
%51 = OpLoad %v2long %e
%54 = OpExtInst %v2float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2float %r
%61 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,305 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderInt8
DEVICE_FEATURE Storage8BitFeatures.uniformAndStorageBuffer8BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v2float ArrayStride 8
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_v2char ArrayStride 2
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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%char = OpTypeInt 8 1
%v2char = OpTypeVector %char 2
%_ptr_Function_v2char = OpTypePointer Function %v2char
%_runtimearr_v2char = OpTypeRuntimeArray %v2char
%ExponentsBlock = OpTypeStruct %_runtimearr_v2char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2char = OpTypePointer Uniform %v2char
%v2int = OpTypeVector %int 2
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2char Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2char %__1 %int_0 %45
%48 = OpLoad %v2char %47
OpStore %e %48
%50 = OpLoad %v2float %s
%51 = OpLoad %v2char %e
%54 = OpExtInst %v2float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2float %r
%61 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %59
OpStore %61 %60
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 int8 DATA
1
0
-1
-2
-14
-123
-124
-125
1
0
-1
-2
-14
-123
-124
-125
1
0
-1
-2
-14
-123
-124
-125
1
0
-1
-2
-14
-123
-124
-125
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
16
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 -9.4039548065783e-38
EXPECT results IDX 24 TOLERANCE .0001 EQ -4.70197740328915e-38
EXPECT results IDX 28 TOLERANCE .0001 EQ -2.350988701644575e-38
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 4.70197740328915e-38
EXPECT results IDX 56 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 60 TOLERANCE .0001 EQ 1.1754943508222875e-38
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 1.1754943508222875e-37
EXPECT results IDX 88 TOLERANCE .0001 EQ 5.877471754111438e-38
EXPECT results IDX 92 TOLERANCE .0001 EQ 2.938735877055719e-38
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 1.88079096131566e-37
EXPECT results IDX 120 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 124 TOLERANCE .0001 EQ 4.70197740328915e-38
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i8vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec2 s = significands[idx];
const i8vec2 e = exponents[idx];
const f32vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v2float ArrayStride 8
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_v2char ArrayStride 2
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_v2float_0 ArrayStride 8
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
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_runtimearr_v2float = OpTypeRuntimeArray %v2float
%SignificandBlock = OpTypeStruct %_runtimearr_v2float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2float = OpTypePointer Uniform %v2float
%char = OpTypeInt 8 1
%v2char = OpTypeVector %char 2
%_ptr_Function_v2char = OpTypePointer Function %v2char
%_runtimearr_v2char = OpTypeRuntimeArray %v2char
%ExponentsBlock = OpTypeStruct %_runtimearr_v2char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2char = OpTypePointer Uniform %v2char
%v2int = OpTypeVector %int 2
%_runtimearr_v2float_0 = OpTypeRuntimeArray %v2float
%ResultsBlock = OpTypeStruct %_runtimearr_v2float_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_v2float Function
%e = OpVariable %_ptr_Function_v2char Function
%r = OpVariable %_ptr_Function_v2float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2float %__0 %int_0 %33
%36 = OpLoad %v2float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2char %__1 %int_0 %45
%48 = OpLoad %v2char %47
OpStore %e %48
%50 = OpLoad %v2float %s
%51 = OpLoad %v2char %e
%54 = OpExtInst %v2float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2float %r
%61 = OpAccessChain %_ptr_Uniform_v2float %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,306 @@
#!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.
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4float ArrayStride 16
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_v4short ArrayStride 8
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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%short = OpTypeInt 16 1
%v4short = OpTypeVector %short 4
%_ptr_Function_v4short = OpTypePointer Function %v4short
%_runtimearr_v4short = OpTypeRuntimeArray %v4short
%ExponentsBlock = OpTypeStruct %_runtimearr_v4short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4short = OpTypePointer Uniform %v4short
%v4int = OpTypeVector %int 4
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4short Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4short %__1 %int_0 %45
%48 = OpLoad %v4short %47
OpStore %e %48
%50 = OpLoad %v4float %s
%51 = OpLoad %v4short %e
%54 = OpExtInst %v4float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4float %r
%61 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %59
OpStore %61 %60
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 int16 DATA
1
0
-1
-2
-14
-32763
-32764
-32765
1
0
-1
-2
-14
-32763
-32764
-32765
1
0
-1
-2
-14
-32763
-32764
-32765
1
0
-1
-2
-14
-32763
-32764
-32765
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
8
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
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec4 s = significands[idx];
const i16vec4 e = exponents[idx];
const f32vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4float ArrayStride 16
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_v4short ArrayStride 8
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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%short = OpTypeInt 16 1
%v4short = OpTypeVector %short 4
%_ptr_Function_v4short = OpTypePointer Function %v4short
%_runtimearr_v4short = OpTypeRuntimeArray %v4short
%ExponentsBlock = OpTypeStruct %_runtimearr_v4short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4short = OpTypePointer Uniform %v4short
%v4int = OpTypeVector %int 4
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4short Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4short %__1 %int_0 %45
%48 = OpLoad %v4short %47
OpStore %e %48
%50 = OpLoad %v4float %s
%51 = OpLoad %v4short %e
%54 = OpExtInst %v4float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4float %r
%61 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,299 @@
#!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: 63
; 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_v4float ArrayStride 16
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_v4int ArrayStride 16
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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%_runtimearr_v4int = OpTypeRuntimeArray %v4int
%ExponentsBlock = OpTypeStruct %_runtimearr_v4int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4int = OpTypePointer Uniform %v4int
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4int Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v4int %__1 %int_0 %44
%47 = OpLoad %v4int %46
OpStore %e %47
%49 = OpLoad %v4float %s
%50 = OpLoad %v4int %e
%51 = OpExtInst %v4float %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v4float %r
%58 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %56
OpStore %58 %57
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
8
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
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i32vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec4 s = significands[idx];
const i32vec4 e = exponents[idx];
const f32vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,124 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; 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_v4float ArrayStride 16
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_v4int ArrayStride 16
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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%_runtimearr_v4int = OpTypeRuntimeArray %v4int
%ExponentsBlock = OpTypeStruct %_runtimearr_v4int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4int = OpTypePointer Uniform %v4int
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4int Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v4int %__1 %int_0 %44
%47 = OpLoad %v4int %46
OpStore %e %47
%49 = OpLoad %v4float %s
%50 = OpLoad %v4int %e
%51 = OpExtInst %v4float %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v4float %r
%58 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,302 @@
#!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.
DEVICE_FEATURE shaderInt64
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int64
%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_v4float ArrayStride 16
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_v4long ArrayStride 32
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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%long = OpTypeInt 64 1
%v4long = OpTypeVector %long 4
%_ptr_Function_v4long = OpTypePointer Function %v4long
%_runtimearr_v4long = OpTypeRuntimeArray %v4long
%ExponentsBlock = OpTypeStruct %_runtimearr_v4long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4long = OpTypePointer Uniform %v4long
%v4int = OpTypeVector %int 4
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4long Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4long %__1 %int_0 %45
%48 = OpLoad %v4long %47
OpStore %e %48
%50 = OpLoad %v4float %s
%51 = OpLoad %v4long %e
%54 = OpExtInst %v4float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4float %r
%61 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %59
OpStore %61 %60
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 int64 DATA
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-9223372036854775803
-9223372036854775804
-9223372036854775805
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
8
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
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec4 s = significands[idx];
const i16vec4 e = exponents[idx];
const f32vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,127 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int64
%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_v4float ArrayStride 16
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_v4long ArrayStride 32
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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%long = OpTypeInt 64 1
%v4long = OpTypeVector %long 4
%_ptr_Function_v4long = OpTypePointer Function %v4long
%_runtimearr_v4long = OpTypeRuntimeArray %v4long
%ExponentsBlock = OpTypeStruct %_runtimearr_v4long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4long = OpTypePointer Uniform %v4long
%v4int = OpTypeVector %int 4
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4long Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4long %__1 %int_0 %45
%48 = OpLoad %v4long %47
OpStore %e %48
%50 = OpLoad %v4float %s
%51 = OpLoad %v4long %e
%54 = OpExtInst %v4float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4float %r
%61 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,305 @@
#!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.
DEVICE_FEATURE Float16Int8Features.shaderInt8
DEVICE_FEATURE Storage8BitFeatures.uniformAndStorageBuffer8BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v4float ArrayStride 16
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_v4char 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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%char = OpTypeInt 8 1
%v4char = OpTypeVector %char 4
%_ptr_Function_v4char = OpTypePointer Function %v4char
%_runtimearr_v4char = OpTypeRuntimeArray %v4char
%ExponentsBlock = OpTypeStruct %_runtimearr_v4char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4char = OpTypePointer Uniform %v4char
%v4int = OpTypeVector %int 4
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4char Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4char %__1 %int_0 %45
%48 = OpLoad %v4char %47
OpStore %e %48
%50 = OpLoad %v4float %s
%51 = OpLoad %v4char %e
%54 = OpExtInst %v4float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4float %r
%61 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %59
OpStore %61 %60
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 int8 DATA
1
0
-1
-2
-14
-123
-124
-125
1
0
-1
-2
-14
-123
-124
-125
1
0
-1
-2
-14
-123
-124
-125
1
0
-1
-2
-14
-123
-124
-125
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
8
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 -9.4039548065783e-38
EXPECT results IDX 24 TOLERANCE .0001 EQ -4.70197740328915e-38
EXPECT results IDX 28 TOLERANCE .0001 EQ -2.350988701644575e-38
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 4.70197740328915e-38
EXPECT results IDX 56 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 60 TOLERANCE .0001 EQ 1.1754943508222875e-38
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 1.1754943508222875e-37
EXPECT results IDX 88 TOLERANCE .0001 EQ 5.877471754111438e-38
EXPECT results IDX 92 TOLERANCE .0001 EQ 2.938735877055719e-38
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 1.88079096131566e-37
EXPECT results IDX 120 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 124 TOLERANCE .0001 EQ 4.70197740328915e-38
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f32vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i8vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f32vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f32vec4 s = significands[idx];
const i8vec4 e = exponents[idx];
const f32vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,129 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v4float ArrayStride 16
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_v4char 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_v4float_0 ArrayStride 16
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
%v4float = OpTypeVector %float 4
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_runtimearr_v4float = OpTypeRuntimeArray %v4float
%SignificandBlock = OpTypeStruct %_runtimearr_v4float
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%char = OpTypeInt 8 1
%v4char = OpTypeVector %char 4
%_ptr_Function_v4char = OpTypePointer Function %v4char
%_runtimearr_v4char = OpTypeRuntimeArray %v4char
%ExponentsBlock = OpTypeStruct %_runtimearr_v4char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4char = OpTypePointer Uniform %v4char
%v4int = OpTypeVector %int 4
%_runtimearr_v4float_0 = OpTypeRuntimeArray %v4float
%ResultsBlock = OpTypeStruct %_runtimearr_v4float_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_v4float Function
%e = OpVariable %_ptr_Function_v4char Function
%r = OpVariable %_ptr_Function_v4float 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4float %__0 %int_0 %33
%36 = OpLoad %v4float %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4char %__1 %int_0 %45
%48 = OpLoad %v4char %47
OpStore %e %48
%50 = OpLoad %v4float %s
%51 = OpLoad %v4char %e
%54 = OpExtInst %v4float %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4float %r
%61 = OpAccessChain %_ptr_Uniform_v4float %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,308 @@
#!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.
DEVICE_FEATURE shaderFloat64
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2double ArrayStride 16
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_v2short 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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%short = OpTypeInt 16 1
%v2short = OpTypeVector %short 2
%_ptr_Function_v2short = OpTypePointer Function %v2short
%_runtimearr_v2short = OpTypeRuntimeArray %v2short
%ExponentsBlock = OpTypeStruct %_runtimearr_v2short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2short = OpTypePointer Uniform %v2short
%v2int = OpTypeVector %int 2
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2short Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2short %__1 %int_0 %45
%48 = OpLoad %v2short %47
OpStore %e %48
%50 = OpLoad %v2double %s
%51 = OpLoad %v2short %e
%54 = OpExtInst %v2double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2double %r
%61 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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 int16 DATA
1
0
-1
-2
-14
-126
-32764
-32765
1
0
-1
-2
-14
-126
-32764
-32765
1
0
-1
-2
-14
-126
-32764
-32765
1
0
-1
-2
-14
-126
-32764
-32765
END
BUFFER results DATA_TYPE double 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
16
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 56 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 184 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 248 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec2 s = significands[idx];
const i16vec2 e = exponents[idx];
const f64vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,130 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v2double ArrayStride 16
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_v2short 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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%short = OpTypeInt 16 1
%v2short = OpTypeVector %short 2
%_ptr_Function_v2short = OpTypePointer Function %v2short
%_runtimearr_v2short = OpTypeRuntimeArray %v2short
%ExponentsBlock = OpTypeStruct %_runtimearr_v2short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2short = OpTypePointer Uniform %v2short
%v2int = OpTypeVector %int 2
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2short Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2short %__1 %int_0 %45
%48 = OpLoad %v2short %47
OpStore %e %48
%50 = OpLoad %v2double %s
%51 = OpLoad %v2short %e
%54 = OpExtInst %v2double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2double %r
%61 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,300 @@
#!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.
DEVICE_FEATURE shaderFloat64
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float64
%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_v2double ArrayStride 16
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_v2int ArrayStride 8
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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_runtimearr_v2int = OpTypeRuntimeArray %v2int
%ExponentsBlock = OpTypeStruct %_runtimearr_v2int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2int Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v2int %__1 %int_0 %44
%47 = OpLoad %v2int %46
OpStore %e %47
%49 = OpLoad %v2double %s
%50 = OpLoad %v2int %e
%51 = OpExtInst %v2double %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v2double %r
%58 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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
-126
-2147483644
-2147483645
1
0
-1
-2
-14
-126
-2147483644
-2147483645
1
0
-1
-2
-14
-126
-2147483644
-2147483645
1
0
-1
-2
-14
-126
-2147483644
-2147483645
END
BUFFER results DATA_TYPE double 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
16
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 56 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 184 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 248 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i32vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec2 s = significands[idx];
const i32vec2 e = exponents[idx];
const f64vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,125 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float64
%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_v2double ArrayStride 16
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_v2int ArrayStride 8
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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%v2int = OpTypeVector %int 2
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_runtimearr_v2int = OpTypeRuntimeArray %v2int
%ExponentsBlock = OpTypeStruct %_runtimearr_v2int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2int = OpTypePointer Uniform %v2int
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2int Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v2int %__1 %int_0 %44
%47 = OpLoad %v2int %46
OpStore %e %47
%49 = OpLoad %v2double %s
%50 = OpLoad %v2int %e
%51 = OpExtInst %v2double %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v2double %r
%58 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,304 @@
#!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.
DEVICE_FEATURE shaderFloat64
DEVICE_FEATURE shaderInt64
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int64
%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_v2double ArrayStride 16
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_v2long ArrayStride 16
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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%long = OpTypeInt 64 1
%v2long = OpTypeVector %long 2
%_ptr_Function_v2long = OpTypePointer Function %v2long
%_runtimearr_v2long = OpTypeRuntimeArray %v2long
%ExponentsBlock = OpTypeStruct %_runtimearr_v2long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2long = OpTypePointer Uniform %v2long
%v2int = OpTypeVector %int 2
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2long Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2long %__1 %int_0 %45
%48 = OpLoad %v2long %47
OpStore %e %48
%50 = OpLoad %v2double %s
%51 = OpLoad %v2long %e
%54 = OpExtInst %v2double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2double %r
%61 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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 int64 DATA
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
END
BUFFER results DATA_TYPE double 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
16
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 56 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 184 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 248 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec2 s = significands[idx];
const i16vec2 e = exponents[idx];
const f64vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,128 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int64
%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_v2double ArrayStride 16
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_v2long ArrayStride 16
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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%long = OpTypeInt 64 1
%v2long = OpTypeVector %long 2
%_ptr_Function_v2long = OpTypePointer Function %v2long
%_runtimearr_v2long = OpTypeRuntimeArray %v2long
%ExponentsBlock = OpTypeStruct %_runtimearr_v2long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2long = OpTypePointer Uniform %v2long
%v2int = OpTypeVector %int 2
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2long Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2long %__1 %int_0 %45
%48 = OpLoad %v2long %47
OpStore %e %48
%50 = OpLoad %v2double %s
%51 = OpLoad %v2long %e
%54 = OpExtInst %v2double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2double %r
%61 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,307 @@
#!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.
DEVICE_FEATURE shaderFloat64
DEVICE_FEATURE Float16Int8Features.shaderInt8
DEVICE_FEATURE Storage8BitFeatures.uniformAndStorageBuffer8BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v2double ArrayStride 16
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_v2char ArrayStride 2
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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%char = OpTypeInt 8 1
%v2char = OpTypeVector %char 2
%_ptr_Function_v2char = OpTypePointer Function %v2char
%_runtimearr_v2char = OpTypeRuntimeArray %v2char
%ExponentsBlock = OpTypeStruct %_runtimearr_v2char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2char = OpTypePointer Uniform %v2char
%v2int = OpTypeVector %int 2
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2char Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2char %__1 %int_0 %45
%48 = OpLoad %v2char %47
OpStore %e %48
%50 = OpLoad %v2double %s
%51 = OpLoad %v2char %e
%54 = OpExtInst %v2double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2double %r
%61 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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 int8 DATA
1
0
-1
-2
-14
-126
-124
-125
1
0
-1
-2
-14
-126
-124
-125
1
0
-1
-2
-14
-126
-124
-125
1
0
-1
-2
-14
-126
-124
-125
END
BUFFER results DATA_TYPE double 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
16
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -4.70197740328915e-38
EXPECT results IDX 56 TOLERANCE .0001 EQ -2.350988701644575e-38
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 120 TOLERANCE .0001 EQ 1.1754943508222875e-38
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 5.877471754111438e-38
EXPECT results IDX 184 TOLERANCE .0001 EQ 2.938735877055719e-38
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 248 TOLERANCE .0001 EQ 4.70197740328915e-38
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec2 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i8vec2 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec2 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec2 s = significands[idx];
const i8vec2 e = exponents[idx];
const f64vec2 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,130 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v2double ArrayStride 16
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_v2char ArrayStride 2
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_v2double_0 ArrayStride 16
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
%double = OpTypeFloat 64
%v2double = OpTypeVector %double 2
%_ptr_Function_v2double = OpTypePointer Function %v2double
%_runtimearr_v2double = OpTypeRuntimeArray %v2double
%SignificandBlock = OpTypeStruct %_runtimearr_v2double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v2double = OpTypePointer Uniform %v2double
%char = OpTypeInt 8 1
%v2char = OpTypeVector %char 2
%_ptr_Function_v2char = OpTypePointer Function %v2char
%_runtimearr_v2char = OpTypeRuntimeArray %v2char
%ExponentsBlock = OpTypeStruct %_runtimearr_v2char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v2char = OpTypePointer Uniform %v2char
%v2int = OpTypeVector %int 2
%_runtimearr_v2double_0 = OpTypeRuntimeArray %v2double
%ResultsBlock = OpTypeStruct %_runtimearr_v2double_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_v2double Function
%e = OpVariable %_ptr_Function_v2char Function
%r = OpVariable %_ptr_Function_v2double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v2double %__0 %int_0 %33
%36 = OpLoad %v2double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v2char %__1 %int_0 %45
%48 = OpLoad %v2char %47
OpStore %e %48
%50 = OpLoad %v2double %s
%51 = OpLoad %v2char %e
%54 = OpExtInst %v2double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v2double %r
%61 = OpAccessChain %_ptr_Uniform_v2double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,308 @@
#!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.
DEVICE_FEATURE shaderFloat64
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4double ArrayStride 32
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_v4short ArrayStride 8
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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%short = OpTypeInt 16 1
%v4short = OpTypeVector %short 4
%_ptr_Function_v4short = OpTypePointer Function %v4short
%_runtimearr_v4short = OpTypeRuntimeArray %v4short
%ExponentsBlock = OpTypeStruct %_runtimearr_v4short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4short = OpTypePointer Uniform %v4short
%v4int = OpTypeVector %int 4
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4short Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4short %__1 %int_0 %45
%48 = OpLoad %v4short %47
OpStore %e %48
%50 = OpLoad %v4double %s
%51 = OpLoad %v4short %e
%54 = OpExtInst %v4double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4double %r
%61 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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 int16 DATA
1
0
-1
-2
-14
-126
-32764
-32765
1
0
-1
-2
-14
-126
-32764
-32765
1
0
-1
-2
-14
-126
-32764
-32765
1
0
-1
-2
-14
-126
-32764
-32765
END
BUFFER results DATA_TYPE double 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
8
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 56 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 184 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 248 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec4 s = significands[idx];
const i16vec4 e = exponents[idx];
const f64vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,130 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int16
OpCapability StorageBuffer16BitAccess
OpExtension "SPV_KHR_16bit_storage"
%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_v4double ArrayStride 32
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_v4short ArrayStride 8
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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%short = OpTypeInt 16 1
%v4short = OpTypeVector %short 4
%_ptr_Function_v4short = OpTypePointer Function %v4short
%_runtimearr_v4short = OpTypeRuntimeArray %v4short
%ExponentsBlock = OpTypeStruct %_runtimearr_v4short
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4short = OpTypePointer Uniform %v4short
%v4int = OpTypeVector %int 4
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4short Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4short %__1 %int_0 %45
%48 = OpLoad %v4short %47
OpStore %e %48
%50 = OpLoad %v4double %s
%51 = OpLoad %v4short %e
%54 = OpExtInst %v4double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4double %r
%61 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,300 @@
#!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.
DEVICE_FEATURE shaderFloat64
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float64
%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_v4double ArrayStride 32
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_v4int ArrayStride 16
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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%_runtimearr_v4int = OpTypeRuntimeArray %v4int
%ExponentsBlock = OpTypeStruct %_runtimearr_v4int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4int = OpTypePointer Uniform %v4int
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4int Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v4int %__1 %int_0 %44
%47 = OpLoad %v4int %46
OpStore %e %47
%49 = OpLoad %v4double %s
%50 = OpLoad %v4int %e
%51 = OpExtInst %v4double %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v4double %r
%58 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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
-126
-2147483644
-2147483645
1
0
-1
-2
-14
-126
-2147483644
-2147483645
1
0
-1
-2
-14
-126
-2147483644
-2147483645
1
0
-1
-2
-14
-126
-2147483644
-2147483645
END
BUFFER results DATA_TYPE double 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
8
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 56 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 184 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 248 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i32vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec4 s = significands[idx];
const i32vec4 e = exponents[idx];
const f64vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,125 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 63
; Schema: 0
OpCapability Shader
OpCapability Float64
%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_v4double ArrayStride 32
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_v4int ArrayStride 16
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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%v4int = OpTypeVector %int 4
%_ptr_Function_v4int = OpTypePointer Function %v4int
%_runtimearr_v4int = OpTypeRuntimeArray %v4int
%ExponentsBlock = OpTypeStruct %_runtimearr_v4int
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4int = OpTypePointer Uniform %v4int
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4int Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%44 = OpLoad %uint %idx
%46 = OpAccessChain %_ptr_Uniform_v4int %__1 %int_0 %44
%47 = OpLoad %v4int %46
OpStore %e %47
%49 = OpLoad %v4double %s
%50 = OpLoad %v4int %e
%51 = OpExtInst %v4double %1 Ldexp %49 %50
OpStore %r %51
%56 = OpLoad %uint %idx
%57 = OpLoad %v4double %r
%58 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %56
OpStore %58 %57
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,304 @@
#!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.
DEVICE_FEATURE shaderFloat64
DEVICE_FEATURE shaderInt64
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int64
%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_v4double ArrayStride 32
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_v4long ArrayStride 32
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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%long = OpTypeInt 64 1
%v4long = OpTypeVector %long 4
%_ptr_Function_v4long = OpTypePointer Function %v4long
%_runtimearr_v4long = OpTypeRuntimeArray %v4long
%ExponentsBlock = OpTypeStruct %_runtimearr_v4long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4long = OpTypePointer Uniform %v4long
%v4int = OpTypeVector %int 4
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4long Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4long %__1 %int_0 %45
%48 = OpLoad %v4long %47
OpStore %e %48
%50 = OpLoad %v4double %s
%51 = OpLoad %v4long %e
%54 = OpExtInst %v4double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4double %r
%61 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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 int64 DATA
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
1
0
-1
-2
-14
-126
-9223372036854775804
-9223372036854775805
END
BUFFER results DATA_TYPE double 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
8
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 56 TOLERANCE .0001 EQ -0.0
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 120 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 184 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 0.0
EXPECT results IDX 248 TOLERANCE .0001 EQ 0.0
@@ -0,0 +1,29 @@
#version 460
#extension GL_EXT_shader_explicit_arithmetic_types : enable
layout (local_size_x=64, local_size_y=1, local_size_z=1) in;
layout (set=0, binding=0, std430) readonly buffer SignificandBlock {
f64vec4 significands[];
};
layout (set=0, binding=1, std430) readonly buffer ExponentsBlock {
i16vec4 exponents[];
};
layout (set=0, binding=2, std430) buffer ResultsBlock {
f64vec4 results[];
};
layout (push_constant, std430) uniform PushConstantBlock {
uint count;
};
void main()
{
const uint idx = gl_LocalInvocationIndex;
if (idx < count) {
const f64vec4 s = significands[idx];
const i16vec4 e = exponents[idx];
const f64vec4 r = ldexp(s, e);
results[idx] = r;
}
}
Binary file not shown.
@@ -0,0 +1,128 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int64
%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_v4double ArrayStride 32
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_v4long ArrayStride 32
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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%long = OpTypeInt 64 1
%v4long = OpTypeVector %long 4
%_ptr_Function_v4long = OpTypePointer Function %v4long
%_runtimearr_v4long = OpTypeRuntimeArray %v4long
%ExponentsBlock = OpTypeStruct %_runtimearr_v4long
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4long = OpTypePointer Uniform %v4long
%v4int = OpTypeVector %int 4
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4long Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4long %__1 %int_0 %45
%48 = OpLoad %v4long %47
OpStore %e %48
%50 = OpLoad %v4double %s
%51 = OpLoad %v4long %e
%54 = OpExtInst %v4double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4double %r
%61 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
@@ -0,0 +1,307 @@
#!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.
DEVICE_FEATURE shaderFloat64
DEVICE_FEATURE Float16Int8Features.shaderInt8
DEVICE_FEATURE Storage8BitFeatures.uniformAndStorageBuffer8BitAccess
SHADER compute compute_shader SPIRV-ASM
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 11
; Bound: 66
; Schema: 0
OpCapability Shader
OpCapability Float64
OpCapability Int8
OpCapability UniformAndStorageBuffer8BitAccess
OpExtension "SPV_KHR_8bit_storage"
%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_v4double ArrayStride 32
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_v4char 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_v4double_0 ArrayStride 32
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
%double = OpTypeFloat 64
%v4double = OpTypeVector %double 4
%_ptr_Function_v4double = OpTypePointer Function %v4double
%_runtimearr_v4double = OpTypeRuntimeArray %v4double
%SignificandBlock = OpTypeStruct %_runtimearr_v4double
%_ptr_Uniform_SignificandBlock = OpTypePointer Uniform %SignificandBlock
%__0 = OpVariable %_ptr_Uniform_SignificandBlock Uniform
%_ptr_Uniform_v4double = OpTypePointer Uniform %v4double
%char = OpTypeInt 8 1
%v4char = OpTypeVector %char 4
%_ptr_Function_v4char = OpTypePointer Function %v4char
%_runtimearr_v4char = OpTypeRuntimeArray %v4char
%ExponentsBlock = OpTypeStruct %_runtimearr_v4char
%_ptr_Uniform_ExponentsBlock = OpTypePointer Uniform %ExponentsBlock
%__1 = OpVariable %_ptr_Uniform_ExponentsBlock Uniform
%_ptr_Uniform_v4char = OpTypePointer Uniform %v4char
%v4int = OpTypeVector %int 4
%_runtimearr_v4double_0 = OpTypeRuntimeArray %v4double
%ResultsBlock = OpTypeStruct %_runtimearr_v4double_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_v4double Function
%e = OpVariable %_ptr_Function_v4char Function
%r = OpVariable %_ptr_Function_v4double 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
%33 = OpLoad %uint %idx
%35 = OpAccessChain %_ptr_Uniform_v4double %__0 %int_0 %33
%36 = OpLoad %v4double %35
OpStore %s %36
%45 = OpLoad %uint %idx
%47 = OpAccessChain %_ptr_Uniform_v4char %__1 %int_0 %45
%48 = OpLoad %v4char %47
OpStore %e %48
%50 = OpLoad %v4double %s
%51 = OpLoad %v4char %e
%54 = OpExtInst %v4double %1 Ldexp %50 %51
OpStore %r %54
%59 = OpLoad %uint %idx
%60 = OpLoad %v4double %r
%61 = OpAccessChain %_ptr_Uniform_v4double %__2 %int_0 %59
OpStore %61 %60
OpBranch %24
%24 = OpLabel
OpReturn
OpFunctionEnd
END
BUFFER significands DATA_TYPE double 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 int8 DATA
1
0
-1
-2
-14
-126
-124
-125
1
0
-1
-2
-14
-126
-124
-125
1
0
-1
-2
-14
-126
-124
-125
1
0
-1
-2
-14
-126
-124
-125
END
BUFFER results DATA_TYPE double 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
8
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 8 TOLERANCE .0001 EQ -1.0
EXPECT results IDX 16 TOLERANCE .0001 EQ -0.5
EXPECT results IDX 24 TOLERANCE .0001 EQ -0.25
EXPECT results IDX 32 TOLERANCE .0001 EQ -6.103515625e-05
EXPECT results IDX 40 TOLERANCE .0001 EQ -1.1754943508222875e-38
EXPECT results IDX 48 TOLERANCE .0001 EQ -4.70197740328915e-38
EXPECT results IDX 56 TOLERANCE .0001 EQ -2.350988701644575e-38
EXPECT results IDX 64 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 72 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 80 TOLERANCE .0001 EQ 0.25
EXPECT results IDX 88 TOLERANCE .0001 EQ 0.125
EXPECT results IDX 96 TOLERANCE .0001 EQ 3.0517578125e-05
EXPECT results IDX 104 TOLERANCE .0001 EQ 5.877471754111438e-39
EXPECT results IDX 112 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 120 TOLERANCE .0001 EQ 1.1754943508222875e-38
EXPECT results IDX 128 TOLERANCE .0001 EQ 2.5
EXPECT results IDX 136 TOLERANCE .0001 EQ 1.25
EXPECT results IDX 144 TOLERANCE .0001 EQ 0.625
EXPECT results IDX 152 TOLERANCE .0001 EQ 0.3125
EXPECT results IDX 160 TOLERANCE .0001 EQ 7.62939453125e-05
EXPECT results IDX 168 TOLERANCE .0001 EQ 1.4693679385278594e-38
EXPECT results IDX 176 TOLERANCE .0001 EQ 5.877471754111438e-38
EXPECT results IDX 184 TOLERANCE .0001 EQ 2.938735877055719e-38
EXPECT results IDX 192 TOLERANCE .0001 EQ 4.0
EXPECT results IDX 200 TOLERANCE .0001 EQ 2.0
EXPECT results IDX 208 TOLERANCE .0001 EQ 1.0
EXPECT results IDX 216 TOLERANCE .0001 EQ 0.5
EXPECT results IDX 224 TOLERANCE .0001 EQ 0.0001220703125
EXPECT results IDX 232 TOLERANCE .0001 EQ 2.350988701644575e-38
EXPECT results IDX 240 TOLERANCE .0001 EQ 9.4039548065783e-38
EXPECT results IDX 248 TOLERANCE .0001 EQ 4.70197740328915e-38

Some files were not shown because too many files have changed in this diff Show More