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 21 22SHADER compute f16 GLSL 23#version 450 24#extension GL_AMD_gpu_shader_half_float : enable 25 26layout(set=0, binding=0) buffer Buf { 27 float16_t h[3]; 28} data; 29 30void main() { 31 int idx = int(gl_GlobalInvocationID.x); 32 data.h[idx] = data.h[idx] * 2.0hf; 33} 34END 35 36BUFFER buf DATA_TYPE float16 DATA 37-0.0 382.4 39-2.4 40END 41 42PIPELINE compute pipeline 43 ATTACH f16 44 45 BIND BUFFER buf AS storage DESCRIPTOR_SET 0 BINDING 0 46END 47 48RUN pipeline 3 1 1 49 50EXPECT buf IDX 0 TOLERANCE 0.1 EQ 0.0 51EXPECT buf IDX 2 TOLERANCE 0.1 EQ 4.8 52EXPECT buf IDX 4 TOLERANCE 0.1 EQ -4.8 53