• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!amber
2# Copyright 2019 The Amber Authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     https://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16DEVICE_EXTENSION VK_KHR_shader_float16_int8
17DEVICE_EXTENSION VK_KHR_16bit_storage
18DEVICE_EXTENSION VK_KHR_storage_buffer_storage_class
19DEVICE_FEATURE Float16Int8Features.shaderFloat16
20DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
21DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
22
23SHADER compute f16 GLSL
24#version 450
25#extension GL_AMD_gpu_shader_half_float : enable
26
27layout(set=0, binding=0) buffer Buf {
28  float16_t h[3];
29} data;
30
31void main() {
32  int idx = int(gl_GlobalInvocationID.x);
33  data.h[idx] = data.h[idx] * 2.0hf;
34}
35END
36
37BUFFER buf DATA_TYPE float16 DATA
38-0.0
392.4
40-2.4
41END
42
43PIPELINE compute pipeline
44  ATTACH f16
45
46  BIND BUFFER buf AS storage DESCRIPTOR_SET 0 BINDING 0
47END
48
49RUN pipeline 3 1 1
50
51EXPECT buf IDX 0 TOLERANCE 0.1 EQ 0.0
52EXPECT buf IDX 2 TOLERANCE 0.1 EQ 4.8
53EXPECT buf IDX 4 TOLERANCE 0.1 EQ -4.8
54