Tint/E2E: Add f16 uniform/storage buffer E2E tests

This CL add Tint E2E tests for f16 types in uniform and storage buffers.

Bug: tint:1473, tint:1502
Change-Id: I325524d2df326240cc1b080a90abf5bd076b3da1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/107543
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
Zhaoming Jiang
2022-11-30 02:47:27 +00:00
committed by Dawn LUCI CQ
parent 205e16de63
commit 776b221ae2
2995 changed files with 113726 additions and 2997 deletions

View File

@@ -0,0 +1,17 @@
enable f16;
@group(0) @binding(0) var<uniform> a : array<mat2x3<f16>, 4>;
var<private> counter = 0;
fn i() -> i32 { counter++; return counter; }
@compute @workgroup_size(1)
fn f() {
let p_a = &a;
let p_a_i = &((*p_a)[i()]);
let p_a_i_i = &((*p_a_i)[i()]);
let l_a : array<mat2x3<f16>, 4> = *p_a;
let l_a_i : mat2x3<f16> = *p_a_i;
let l_a_i_i : vec3<f16> = *p_a_i_i;
}

View File

@@ -0,0 +1,49 @@
cbuffer cbuffer_a : register(b0, space0) {
uint4 a[4];
};
static int counter = 0;
int i() {
counter = (counter + 1);
return counter;
}
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1] = tint_symbol_1(buffer, (offset + (i_1 * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
const int p_a_i_save = i();
const int p_a_i_i_save = i();
const matrix<float16_t, 2, 3> l_a[4] = tint_symbol(a, 0u);
const matrix<float16_t, 2, 3> l_a_i = tint_symbol_1(a, (16u * uint(p_a_i_save)));
const uint scalar_offset_2 = (((16u * uint(p_a_i_save)) + (8u * uint(p_a_i_i_save)))) / 4;
uint4 ubo_load_5 = a[scalar_offset_2 / 4];
uint2 ubo_load_4 = ((scalar_offset_2 & 2) ? ubo_load_5.zw : ubo_load_5.xy);
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
const vector<float16_t, 3> l_a_i_i = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]);
return;
}

View File

@@ -0,0 +1,54 @@
SKIP: FAILED
cbuffer cbuffer_a : register(b0, space0) {
uint4 a[4];
};
static int counter = 0;
int i() {
counter = (counter + 1);
return counter;
}
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1] = tint_symbol_1(buffer, (offset + (i_1 * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
const int p_a_i_save = i();
const int p_a_i_i_save = i();
const matrix<float16_t, 2, 3> l_a[4] = tint_symbol(a, 0u);
const matrix<float16_t, 2, 3> l_a_i = tint_symbol_1(a, (16u * uint(p_a_i_save)));
const uint scalar_offset_2 = (((16u * uint(p_a_i_save)) + (8u * uint(p_a_i_i_save)))) / 4;
uint4 ubo_load_5 = a[scalar_offset_2 / 4];
uint2 ubo_load_4 = ((scalar_offset_2 & 2) ? ubo_load_5.zw : ubo_load_5.xy);
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
const vector<float16_t, 3> l_a_i_i = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]);
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000001F4D5AC4540(11,8-16): error X3000: syntax error: unexpected token 'float16_t'

View File

@@ -0,0 +1,65 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform a_block_std140_ubo {
mat2x3_f16 inner[4];
} a;
int counter = 0;
int i() {
counter = (counter + 1);
return counter;
}
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
f16mat2x3[4] conv_arr4_mat2x3_f16(mat2x3_f16 val[4]) {
f16mat2x3 arr[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_mat2x3_f16(val[i]);
}
}
return arr;
}
f16vec3 load_a_inner_p0_p1(uint p0, uint p1) {
switch(p1) {
case 0u: {
return a.inner[p0].col0;
break;
}
case 1u: {
return a.inner[p0].col1;
break;
}
default: {
return f16vec3(0.0hf);
break;
}
}
}
void f() {
f16mat2x3 p_a[4] = conv_arr4_mat2x3_f16(a.inner);
int tint_symbol = i();
f16mat2x3 p_a_i = conv_mat2x3_f16(a.inner[tint_symbol]);
int tint_symbol_1 = i();
f16vec3 p_a_i_i = load_a_inner_p0_p1(uint(tint_symbol), uint(tint_symbol_1));
f16mat2x3 l_a[4] = conv_arr4_mat2x3_f16(a.inner);
f16mat2x3 l_a_i = conv_mat2x3_f16(a.inner[tint_symbol]);
f16vec3 l_a_i_i = load_a_inner_p0_p1(uint(tint_symbol), uint(tint_symbol_1));
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,33 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
int i() {
thread int tint_symbol_2 = 0;
tint_symbol_2 = as_type<int>((as_type<uint>(tint_symbol_2) + as_type<uint>(1)));
return tint_symbol_2;
}
kernel void f(const constant tint_array<half2x3, 4>* tint_symbol_3 [[buffer(0)]]) {
int const tint_symbol = i();
int const p_a_i_save = tint_symbol;
int const tint_symbol_1 = i();
int const p_a_i_i_save = tint_symbol_1;
tint_array<half2x3, 4> const l_a = *(tint_symbol_3);
half2x3 const l_a_i = (*(tint_symbol_3))[p_a_i_save];
half3 const l_a_i_i = (*(tint_symbol_3))[p_a_i_save][p_a_i_i_save];
return;
}

View File

@@ -0,0 +1,165 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 98
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %a_block_std140 "a_block_std140"
OpMemberName %a_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %a "a"
OpName %counter "counter"
OpName %i "i"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %conv_arr4_mat2x3_f16 "conv_arr4_mat2x3_f16"
OpName %val_0 "val"
OpName %arr "arr"
OpName %i_0 "i"
OpName %var_for_index "var_for_index"
OpName %load_a_inner_p0_p1 "load_a_inner_p0_p1"
OpName %p0 "p0"
OpName %p1 "p1"
OpName %f "f"
OpDecorate %a_block_std140 Block
OpMemberDecorate %a_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %a NonWritable
OpDecorate %a DescriptorSet 0
OpDecorate %a Binding 0
OpDecorate %_arr_mat2v3half_uint_4 ArrayStride 16
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%a_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_a_block_std140 = OpTypePointer Uniform %a_block_std140
%a = OpVariable %_ptr_Uniform_a_block_std140 Uniform
%int = OpTypeInt 32 1
%11 = OpConstantNull %int
%_ptr_Private_int = OpTypePointer Private %int
%counter = OpVariable %_ptr_Private_int Private %11
%14 = OpTypeFunction %int
%int_1 = OpConstant %int 1
%mat2v3half = OpTypeMatrix %v3half 2
%21 = OpTypeFunction %mat2v3half %mat2x3_f16
%_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4
%29 = OpTypeFunction %_arr_mat2v3half_uint_4 %_arr_mat2x3_f16_uint_4
%_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4
%36 = OpConstantNull %_arr_mat2v3half_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%39 = OpConstantNull %uint
%bool = OpTypeBool
%_ptr_Function__arr_mat2x3_f16_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_uint_4
%52 = OpConstantNull %_arr_mat2x3_f16_uint_4
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%_ptr_Function_mat2x3_f16 = OpTypePointer Function %mat2x3_f16
%uint_1 = OpConstant %uint 1
%65 = OpTypeFunction %v3half %uint %uint
%uint_0 = OpConstant %uint 0
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%80 = OpConstantNull %v3half
%void = OpTypeVoid
%81 = OpTypeFunction %void
%_ptr_Uniform__arr_mat2x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%i = OpFunction %int None %14
%16 = OpLabel
%17 = OpLoad %int %counter
%19 = OpIAdd %int %17 %int_1
OpStore %counter %19
%20 = OpLoad %int %counter
OpReturnValue %20
OpFunctionEnd
%conv_mat2x3_f16 = OpFunction %mat2v3half None %21
%val = OpFunctionParameter %mat2x3_f16
%25 = OpLabel
%26 = OpCompositeExtract %v3half %val 0
%27 = OpCompositeExtract %v3half %val 1
%28 = OpCompositeConstruct %mat2v3half %26 %27
OpReturnValue %28
OpFunctionEnd
%conv_arr4_mat2x3_f16 = OpFunction %_arr_mat2v3half_uint_4 None %29
%val_0 = OpFunctionParameter %_arr_mat2x3_f16_uint_4
%33 = OpLabel
%arr = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %36
%i_0 = OpVariable %_ptr_Function_uint Function %39
%var_for_index = OpVariable %_ptr_Function__arr_mat2x3_f16_uint_4 Function %52
OpBranch %40
%40 = OpLabel
OpLoopMerge %41 %42 None
OpBranch %43
%43 = OpLabel
%45 = OpLoad %uint %i_0
%46 = OpULessThan %bool %45 %uint_4
%44 = OpLogicalNot %bool %46
OpSelectionMerge %48 None
OpBranchConditional %44 %49 %48
%49 = OpLabel
OpBranch %41
%48 = OpLabel
OpStore %var_for_index %val_0
%53 = OpLoad %uint %i_0
%55 = OpAccessChain %_ptr_Function_mat2v3half %arr %53
%57 = OpLoad %uint %i_0
%59 = OpAccessChain %_ptr_Function_mat2x3_f16 %var_for_index %57
%60 = OpLoad %mat2x3_f16 %59
%56 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %60
OpStore %55 %56
OpBranch %42
%42 = OpLabel
%61 = OpLoad %uint %i_0
%63 = OpIAdd %uint %61 %uint_1
OpStore %i_0 %63
OpBranch %40
%41 = OpLabel
%64 = OpLoad %_arr_mat2v3half_uint_4 %arr
OpReturnValue %64
OpFunctionEnd
%load_a_inner_p0_p1 = OpFunction %v3half None %65
%p0 = OpFunctionParameter %uint
%p1 = OpFunctionParameter %uint
%69 = OpLabel
OpSelectionMerge %70 None
OpSwitch %p1 %71 0 %72 1 %73
%72 = OpLabel
%76 = OpAccessChain %_ptr_Uniform_v3half %a %uint_0 %p0 %uint_0
%77 = OpLoad %v3half %76
OpReturnValue %77
%73 = OpLabel
%78 = OpAccessChain %_ptr_Uniform_v3half %a %uint_0 %p0 %uint_1
%79 = OpLoad %v3half %78
OpReturnValue %79
%71 = OpLabel
OpReturnValue %80
%70 = OpLabel
OpReturnValue %80
OpFunctionEnd
%f = OpFunction %void None %81
%84 = OpLabel
%85 = OpFunctionCall %int %i
%86 = OpFunctionCall %int %i
%89 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_uint_4 %a %uint_0
%90 = OpLoad %_arr_mat2x3_f16_uint_4 %89
%87 = OpFunctionCall %_arr_mat2v3half_uint_4 %conv_arr4_mat2x3_f16 %90
%93 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %a %uint_0 %85
%94 = OpLoad %mat2x3_f16 %93
%91 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %94
%96 = OpBitcast %uint %85
%97 = OpBitcast %uint %86
%95 = OpFunctionCall %v3half %load_a_inner_p0_p1 %96 %97
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,20 @@
enable f16;
@group(0) @binding(0) var<uniform> a : array<mat2x3<f16>, 4>;
var<private> counter = 0;
fn i() -> i32 {
counter++;
return counter;
}
@compute @workgroup_size(1)
fn f() {
let p_a = &(a);
let p_a_i = &((*(p_a))[i()]);
let p_a_i_i = &((*(p_a_i))[i()]);
let l_a : array<mat2x3<f16>, 4> = *(p_a);
let l_a_i : mat2x3<f16> = *(p_a_i);
let l_a_i_i : vec3<f16> = *(p_a_i_i);
}

View File

@@ -0,0 +1,14 @@
enable f16;
@group(0) @binding(0) var<uniform> a : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
let p_a = &a;
let p_a_2 = &((*p_a)[2]);
let p_a_2_1 = &((*p_a_2)[1]);
let l_a : array<mat2x3<f16>, 4> = *p_a;
let l_a_i : mat2x3<f16> = *p_a_2;
let l_a_i_i : vec3<f16> = *p_a_2_1;
}

View File

@@ -0,0 +1,39 @@
cbuffer cbuffer_a : register(b0, space0) {
uint4 a[4];
};
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = tint_symbol_1(buffer, (offset + (i * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
const matrix<float16_t, 2, 3> l_a[4] = tint_symbol(a, 0u);
const matrix<float16_t, 2, 3> l_a_i = tint_symbol_1(a, 32u);
uint2 ubo_load_4 = a[2].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
const vector<float16_t, 3> l_a_i_i = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]);
return;
}

View File

@@ -0,0 +1,44 @@
SKIP: FAILED
cbuffer cbuffer_a : register(b0, space0) {
uint4 a[4];
};
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = tint_symbol_1(buffer, (offset + (i * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
const matrix<float16_t, 2, 3> l_a[4] = tint_symbol(a, 0u);
const matrix<float16_t, 2, 3> l_a_i = tint_symbol_1(a, 32u);
uint2 ubo_load_4 = a[2].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
const vector<float16_t, 3> l_a_i_i = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]);
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x0000016DBC7DD4E0(5,8-16): error X3000: syntax error: unexpected token 'float16_t'

View File

@@ -0,0 +1,40 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform a_block_std140_ubo {
mat2x3_f16 inner[4];
} a;
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
f16mat2x3[4] conv_arr4_mat2x3_f16(mat2x3_f16 val[4]) {
f16mat2x3 arr[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_mat2x3_f16(val[i]);
}
}
return arr;
}
void f() {
f16mat2x3 p_a[4] = conv_arr4_mat2x3_f16(a.inner);
f16mat2x3 p_a_2 = conv_mat2x3_f16(a.inner[2u]);
f16vec3 p_a_2_1 = a.inner[2u].col1;
f16mat2x3 l_a[4] = conv_arr4_mat2x3_f16(a.inner);
f16mat2x3 l_a_i = conv_mat2x3_f16(a.inner[2u]);
f16vec3 l_a_i_i = a.inner[2u].col1;
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,23 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
kernel void f(const constant tint_array<half2x3, 4>* tint_symbol [[buffer(0)]]) {
tint_array<half2x3, 4> const l_a = *(tint_symbol);
half2x3 const l_a_i = (*(tint_symbol))[2];
half3 const l_a_i_i = (*(tint_symbol))[2][1];
return;
}

View File

@@ -0,0 +1,123 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 71
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %a_block_std140 "a_block_std140"
OpMemberName %a_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %a "a"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %conv_arr4_mat2x3_f16 "conv_arr4_mat2x3_f16"
OpName %val_0 "val"
OpName %arr "arr"
OpName %i "i"
OpName %var_for_index "var_for_index"
OpName %f "f"
OpDecorate %a_block_std140 Block
OpMemberDecorate %a_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %a NonWritable
OpDecorate %a DescriptorSet 0
OpDecorate %a Binding 0
OpDecorate %_arr_mat2v3half_uint_4 ArrayStride 16
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%a_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_a_block_std140 = OpTypePointer Uniform %a_block_std140
%a = OpVariable %_ptr_Uniform_a_block_std140 Uniform
%mat2v3half = OpTypeMatrix %v3half 2
%10 = OpTypeFunction %mat2v3half %mat2x3_f16
%_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4
%18 = OpTypeFunction %_arr_mat2v3half_uint_4 %_arr_mat2x3_f16_uint_4
%_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4
%25 = OpConstantNull %_arr_mat2v3half_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%28 = OpConstantNull %uint
%bool = OpTypeBool
%_ptr_Function__arr_mat2x3_f16_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_uint_4
%41 = OpConstantNull %_arr_mat2x3_f16_uint_4
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%_ptr_Function_mat2x3_f16 = OpTypePointer Function %mat2x3_f16
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%54 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_Uniform__arr_mat2x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_uint_4
%uint_2 = OpConstant %uint 2
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%conv_mat2x3_f16 = OpFunction %mat2v3half None %10
%val = OpFunctionParameter %mat2x3_f16
%14 = OpLabel
%15 = OpCompositeExtract %v3half %val 0
%16 = OpCompositeExtract %v3half %val 1
%17 = OpCompositeConstruct %mat2v3half %15 %16
OpReturnValue %17
OpFunctionEnd
%conv_arr4_mat2x3_f16 = OpFunction %_arr_mat2v3half_uint_4 None %18
%val_0 = OpFunctionParameter %_arr_mat2x3_f16_uint_4
%22 = OpLabel
%arr = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %25
%i = OpVariable %_ptr_Function_uint Function %28
%var_for_index = OpVariable %_ptr_Function__arr_mat2x3_f16_uint_4 Function %41
OpBranch %29
%29 = OpLabel
OpLoopMerge %30 %31 None
OpBranch %32
%32 = OpLabel
%34 = OpLoad %uint %i
%35 = OpULessThan %bool %34 %uint_4
%33 = OpLogicalNot %bool %35
OpSelectionMerge %37 None
OpBranchConditional %33 %38 %37
%38 = OpLabel
OpBranch %30
%37 = OpLabel
OpStore %var_for_index %val_0
%42 = OpLoad %uint %i
%44 = OpAccessChain %_ptr_Function_mat2v3half %arr %42
%46 = OpLoad %uint %i
%48 = OpAccessChain %_ptr_Function_mat2x3_f16 %var_for_index %46
%49 = OpLoad %mat2x3_f16 %48
%45 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %49
OpStore %44 %45
OpBranch %31
%31 = OpLabel
%50 = OpLoad %uint %i
%52 = OpIAdd %uint %50 %uint_1
OpStore %i %52
OpBranch %29
%30 = OpLabel
%53 = OpLoad %_arr_mat2v3half_uint_4 %arr
OpReturnValue %53
OpFunctionEnd
%f = OpFunction %void None %54
%57 = OpLabel
%61 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_uint_4 %a %uint_0
%62 = OpLoad %_arr_mat2x3_f16_uint_4 %61
%58 = OpFunctionCall %_arr_mat2v3half_uint_4 %conv_arr4_mat2x3_f16 %62
%66 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %a %uint_0 %uint_2
%67 = OpLoad %mat2x3_f16 %66
%63 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %67
%69 = OpAccessChain %_ptr_Uniform_v3half %a %uint_0 %uint_2 %uint_1
%70 = OpLoad %v3half %69
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,13 @@
enable f16;
@group(0) @binding(0) var<uniform> a : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
let p_a = &(a);
let p_a_2 = &((*(p_a))[2]);
let p_a_2_1 = &((*(p_a_2))[1]);
let l_a : array<mat2x3<f16>, 4> = *(p_a);
let l_a_i : mat2x3<f16> = *(p_a_2);
let l_a_i_i : vec3<f16> = *(p_a_2_1);
}

View File

@@ -0,0 +1,10 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
let t = transpose(u[2]);
let l = length(u[0][1].zxy);
let a = abs(u[0][1].zxy.x);
}

View File

@@ -0,0 +1,31 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
matrix<float16_t, 2, 3> tint_symbol(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
[numthreads(1, 1, 1)]
void f() {
const matrix<float16_t, 3, 2> t = transpose(tint_symbol(u, 32u));
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
const float16_t l = length(vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy);
uint2 ubo_load_5 = u[0].zw;
vector<float16_t, 2> ubo_load_5_xz = vector<float16_t, 2>(f16tof32(ubo_load_5 & 0xFFFF));
float16_t ubo_load_5_y = f16tof32(ubo_load_5[0] >> 16);
const float16_t a = abs(vector<float16_t, 3>(ubo_load_5_xz[0], ubo_load_5_y, ubo_load_5_xz[1]).zxy.x);
return;
}

View File

@@ -0,0 +1,36 @@
SKIP: FAILED
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
matrix<float16_t, 2, 3> tint_symbol(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
[numthreads(1, 1, 1)]
void f() {
const matrix<float16_t, 3, 2> t = transpose(tint_symbol(u, 32u));
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
const float16_t l = length(vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy);
uint2 ubo_load_5 = u[0].zw;
vector<float16_t, 2> ubo_load_5_xz = vector<float16_t, 2>(f16tof32(ubo_load_5 & 0xFFFF));
float16_t ubo_load_5_y = f16tof32(ubo_load_5[0] >> 16);
const float16_t a = abs(vector<float16_t, 3>(ubo_load_5_xz[0], ubo_load_5_y, ubo_load_5_xz[1]).zxy.x);
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000001B4475A47D0(5,8-16): error X3000: syntax error: unexpected token 'float16_t'

View File

@@ -0,0 +1,27 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform u_block_std140_ubo {
mat2x3_f16 inner[4];
} u;
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
void f() {
f16mat3x2 t = transpose(conv_mat2x3_f16(u.inner[2u]));
float16_t l = length(u.inner[0u].col1.zxy);
float16_t a = abs(u.inner[0u].col1.zxy[0u]);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,23 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
kernel void f(const constant tint_array<half2x3, 4>* tint_symbol [[buffer(0)]]) {
half3x2 const t = transpose((*(tint_symbol))[2]);
half const l = length(half3((*(tint_symbol))[0][1]).zxy);
half const a = fabs(half3((*(tint_symbol))[0][1]).zxy[0]);
return;
}

View File

@@ -0,0 +1,77 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 44
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
%32 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %u_block_std140 "u_block_std140"
OpMemberName %u_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %u "u"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %f "f"
OpDecorate %u_block_std140 Block
OpMemberDecorate %u_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%u_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_u_block_std140 = OpTypePointer Uniform %u_block_std140
%u = OpVariable %_ptr_Uniform_u_block_std140 Uniform
%mat2v3half = OpTypeMatrix %v3half 2
%10 = OpTypeFunction %mat2v3half %mat2x3_f16
%void = OpTypeVoid
%18 = OpTypeFunction %void
%v2half = OpTypeVector %half 2
%mat3v2half = OpTypeMatrix %v2half 3
%uint_0 = OpConstant %uint 0
%uint_2 = OpConstant %uint 2
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%33 = OpConstantNull %uint
%uint_1 = OpConstant %uint 1
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%conv_mat2x3_f16 = OpFunction %mat2v3half None %10
%val = OpFunctionParameter %mat2x3_f16
%14 = OpLabel
%15 = OpCompositeExtract %v3half %val 0
%16 = OpCompositeExtract %v3half %val 1
%17 = OpCompositeConstruct %mat2v3half %15 %16
OpReturnValue %17
OpFunctionEnd
%f = OpFunction %void None %18
%21 = OpLabel
%29 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %u %uint_0 %uint_2
%30 = OpLoad %mat2x3_f16 %29
%25 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %30
%22 = OpTranspose %mat3v2half %25
%36 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %33 %uint_1
%37 = OpLoad %v3half %36
%38 = OpVectorShuffle %v3half %37 %37 2 0 1
%31 = OpExtInst %half %32 Length %38
%40 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %33 %uint_1
%41 = OpLoad %v3half %40
%42 = OpVectorShuffle %v3half %41 %41 2 0 1
%43 = OpCompositeExtract %half %42 0
%39 = OpExtInst %half %32 FAbs %43
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,10 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
let t = transpose(u[2]);
let l = length(u[0][1].zxy);
let a = abs(u[0][1].zxy.x);
}

View File

@@ -0,0 +1,16 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
fn a(a : array<mat2x3<f16>, 4>) {}
fn b(m : mat2x3<f16>) {}
fn c(v : vec3<f16>) {}
fn d(f : f16) {}
@compute @workgroup_size(1)
fn f() {
a(u);
b(u[1]);
c(u[1][0].zxy);
d(u[1][0].zxy.x);
}

View File

@@ -0,0 +1,55 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
void a(matrix<float16_t, 2, 3> a_1[4]) {
}
void b(matrix<float16_t, 2, 3> m) {
}
void c(vector<float16_t, 3> v) {
}
void d(float16_t f_1) {
}
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = tint_symbol_1(buffer, (offset + (i * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
a(tint_symbol(u, 0u));
b(tint_symbol_1(u, 16u));
uint2 ubo_load_4 = u[1].xy;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
c(vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy);
uint2 ubo_load_5 = u[1].xy;
vector<float16_t, 2> ubo_load_5_xz = vector<float16_t, 2>(f16tof32(ubo_load_5 & 0xFFFF));
float16_t ubo_load_5_y = f16tof32(ubo_load_5[0] >> 16);
d(vector<float16_t, 3>(ubo_load_5_xz[0], ubo_load_5_y, ubo_load_5_xz[1]).zxy.x);
return;
}

View File

@@ -0,0 +1,63 @@
SKIP: FAILED
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
void a(matrix<float16_t, 2, 3> a_1[4]) {
}
void b(matrix<float16_t, 2, 3> m) {
}
void c(vector<float16_t, 3> v) {
}
void d(float16_t f_1) {
}
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = tint_symbol_1(buffer, (offset + (i * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
a(tint_symbol(u, 0u));
b(tint_symbol_1(u, 16u));
uint2 ubo_load_4 = u[1].xy;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
c(vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy);
uint2 ubo_load_5 = u[1].xy;
vector<float16_t, 2> ubo_load_5_xz = vector<float16_t, 2>(f16tof32(ubo_load_5 & 0xFFFF));
float16_t ubo_load_5_y = f16tof32(ubo_load_5[0] >> 16);
d(vector<float16_t, 3>(ubo_load_5_xz[0], ubo_load_5_y, ubo_load_5_xz[1]).zxy.x);
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000002290980B6C0(5,15-23): error X3000: syntax error: unexpected token 'float16_t'
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000002290980B6C0(8,15-23): error X3000: syntax error: unexpected token 'float16_t'
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000002290980B6C0(11,15-23): error X3000: syntax error: unexpected token 'float16_t'
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000002290980B6C0(14,8-16): error X3000: unrecognized identifier 'float16_t'

View File

@@ -0,0 +1,50 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform u_block_std140_ubo {
mat2x3_f16 inner[4];
} u;
void a(f16mat2x3 a_1[4]) {
}
void b(f16mat2x3 m) {
}
void c(f16vec3 v) {
}
void d(float16_t f_1) {
}
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
f16mat2x3[4] conv_arr4_mat2x3_f16(mat2x3_f16 val[4]) {
f16mat2x3 arr[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_mat2x3_f16(val[i]);
}
}
return arr;
}
void f() {
a(conv_arr4_mat2x3_f16(u.inner));
b(conv_mat2x3_f16(u.inner[1u]));
c(u.inner[1u].col0.zxy);
d(u.inner[1u].col0.zxy[0u]);
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,36 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
void a(tint_array<half2x3, 4> a_1) {
}
void b(half2x3 m) {
}
void c(half3 v) {
}
void d(half f_1) {
}
kernel void f(const constant tint_array<half2x3, 4>* tint_symbol [[buffer(0)]]) {
a(*(tint_symbol));
b((*(tint_symbol))[1]);
c(half3((*(tint_symbol))[1][0]).zxy);
d(half3((*(tint_symbol))[1][0]).zxy[0]);
return;
}

View File

@@ -0,0 +1,163 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 95
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %u_block_std140 "u_block_std140"
OpMemberName %u_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %u "u"
OpName %a "a"
OpName %a_1 "a_1"
OpName %b "b"
OpName %m "m"
OpName %c "c"
OpName %v "v"
OpName %d "d"
OpName %f_1 "f_1"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %conv_arr4_mat2x3_f16 "conv_arr4_mat2x3_f16"
OpName %val_0 "val"
OpName %arr "arr"
OpName %i "i"
OpName %var_for_index "var_for_index"
OpName %f "f"
OpDecorate %u_block_std140 Block
OpMemberDecorate %u_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
OpDecorate %_arr_mat2v3half_uint_4 ArrayStride 16
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%u_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_u_block_std140 = OpTypePointer Uniform %u_block_std140
%u = OpVariable %_ptr_Uniform_u_block_std140 Uniform
%void = OpTypeVoid
%mat2v3half = OpTypeMatrix %v3half 2
%_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4
%10 = OpTypeFunction %void %_arr_mat2v3half_uint_4
%17 = OpTypeFunction %void %mat2v3half
%21 = OpTypeFunction %void %v3half
%25 = OpTypeFunction %void %half
%29 = OpTypeFunction %mat2v3half %mat2x3_f16
%36 = OpTypeFunction %_arr_mat2v3half_uint_4 %_arr_mat2x3_f16_uint_4
%_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4
%42 = OpConstantNull %_arr_mat2v3half_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%45 = OpConstantNull %uint
%bool = OpTypeBool
%_ptr_Function__arr_mat2x3_f16_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_uint_4
%58 = OpConstantNull %_arr_mat2x3_f16_uint_4
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%_ptr_Function_mat2x3_f16 = OpTypePointer Function %mat2x3_f16
%uint_1 = OpConstant %uint 1
%71 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_Uniform__arr_mat2x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%a = OpFunction %void None %10
%a_1 = OpFunctionParameter %_arr_mat2v3half_uint_4
%16 = OpLabel
OpReturn
OpFunctionEnd
%b = OpFunction %void None %17
%m = OpFunctionParameter %mat2v3half
%20 = OpLabel
OpReturn
OpFunctionEnd
%c = OpFunction %void None %21
%v = OpFunctionParameter %v3half
%24 = OpLabel
OpReturn
OpFunctionEnd
%d = OpFunction %void None %25
%f_1 = OpFunctionParameter %half
%28 = OpLabel
OpReturn
OpFunctionEnd
%conv_mat2x3_f16 = OpFunction %mat2v3half None %29
%val = OpFunctionParameter %mat2x3_f16
%32 = OpLabel
%33 = OpCompositeExtract %v3half %val 0
%34 = OpCompositeExtract %v3half %val 1
%35 = OpCompositeConstruct %mat2v3half %33 %34
OpReturnValue %35
OpFunctionEnd
%conv_arr4_mat2x3_f16 = OpFunction %_arr_mat2v3half_uint_4 None %36
%val_0 = OpFunctionParameter %_arr_mat2x3_f16_uint_4
%39 = OpLabel
%arr = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %42
%i = OpVariable %_ptr_Function_uint Function %45
%var_for_index = OpVariable %_ptr_Function__arr_mat2x3_f16_uint_4 Function %58
OpBranch %46
%46 = OpLabel
OpLoopMerge %47 %48 None
OpBranch %49
%49 = OpLabel
%51 = OpLoad %uint %i
%52 = OpULessThan %bool %51 %uint_4
%50 = OpLogicalNot %bool %52
OpSelectionMerge %54 None
OpBranchConditional %50 %55 %54
%55 = OpLabel
OpBranch %47
%54 = OpLabel
OpStore %var_for_index %val_0
%59 = OpLoad %uint %i
%61 = OpAccessChain %_ptr_Function_mat2v3half %arr %59
%63 = OpLoad %uint %i
%65 = OpAccessChain %_ptr_Function_mat2x3_f16 %var_for_index %63
%66 = OpLoad %mat2x3_f16 %65
%62 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %66
OpStore %61 %62
OpBranch %48
%48 = OpLabel
%67 = OpLoad %uint %i
%69 = OpIAdd %uint %67 %uint_1
OpStore %i %69
OpBranch %46
%47 = OpLabel
%70 = OpLoad %_arr_mat2v3half_uint_4 %arr
OpReturnValue %70
OpFunctionEnd
%f = OpFunction %void None %71
%73 = OpLabel
%78 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_uint_4 %u %uint_0
%79 = OpLoad %_arr_mat2x3_f16_uint_4 %78
%75 = OpFunctionCall %_arr_mat2v3half_uint_4 %conv_arr4_mat2x3_f16 %79
%74 = OpFunctionCall %void %a %75
%83 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %u %uint_0 %uint_1
%84 = OpLoad %mat2x3_f16 %83
%81 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %84
%80 = OpFunctionCall %void %b %81
%87 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %uint_1 %uint_0
%88 = OpLoad %v3half %87
%89 = OpVectorShuffle %v3half %88 %88 2 0 1
%85 = OpFunctionCall %void %c %89
%91 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %uint_1 %uint_0
%92 = OpLoad %v3half %91
%93 = OpVectorShuffle %v3half %92 %92 2 0 1
%94 = OpCompositeExtract %half %93 0
%90 = OpFunctionCall %void %d %94
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,23 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
fn a(a : array<mat2x3<f16>, 4>) {
}
fn b(m : mat2x3<f16>) {
}
fn c(v : vec3<f16>) {
}
fn d(f : f16) {
}
@compute @workgroup_size(1)
fn f() {
a(u);
b(u[1]);
c(u[1][0].zxy);
d(u[1][0].zxy.x);
}

View File

@@ -0,0 +1,12 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
var<private> p : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
p = u;
p[1] = u[2];
p[1][0] = u[0][1].zxy;
p[1][0].x = u[0][1].x;
}

View File

@@ -0,0 +1,41 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
static matrix<float16_t, 2, 3> p[4] = (matrix<float16_t, 2, 3>[4])0;
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = tint_symbol_1(buffer, (offset + (i * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
p = tint_symbol(u, 0u);
p[1] = tint_symbol_1(u, 32u);
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
p[1][0] = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy;
p[1][0].x = float16_t(f16tof32(((u[0].z) & 0xFFFF)));
return;
}

View File

@@ -0,0 +1,46 @@
SKIP: FAILED
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
static matrix<float16_t, 2, 3> p[4] = (matrix<float16_t, 2, 3>[4])0;
matrix<float16_t, 2, 3> tint_symbol_1(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_ret[4];
tint_symbol_ret tint_symbol(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = tint_symbol_1(buffer, (offset + (i * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
p = tint_symbol(u, 0u);
p[1] = tint_symbol_1(u, 32u);
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
p[1][0] = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy;
p[1][0].x = float16_t(f16tof32(((u[0].z) & 0xFFFF)));
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000001C62197B570(4,15-23): error X3000: syntax error: unexpected token 'float16_t'

View File

@@ -0,0 +1,39 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform u_block_std140_ubo {
mat2x3_f16 inner[4];
} u;
f16mat2x3 p[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
f16mat2x3[4] conv_arr4_mat2x3_f16(mat2x3_f16 val[4]) {
f16mat2x3 arr[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_mat2x3_f16(val[i]);
}
}
return arr;
}
void f() {
p = conv_arr4_mat2x3_f16(u.inner);
p[1] = conv_mat2x3_f16(u.inner[2u]);
p[1][0] = u.inner[0u].col1.zxy;
p[1][0].x = u.inner[0u].col1[0u];
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,25 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
kernel void f(const constant tint_array<half2x3, 4>* tint_symbol_1 [[buffer(0)]]) {
thread tint_array<half2x3, 4> tint_symbol = {};
tint_symbol = *(tint_symbol_1);
tint_symbol[1] = (*(tint_symbol_1))[2];
tint_symbol[1][0] = half3((*(tint_symbol_1))[0][1]).zxy;
tint_symbol[1][0][0] = (*(tint_symbol_1))[0][1][0];
return;
}

View File

@@ -0,0 +1,143 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 86
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %u_block_std140 "u_block_std140"
OpMemberName %u_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %u "u"
OpName %p "p"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %conv_arr4_mat2x3_f16 "conv_arr4_mat2x3_f16"
OpName %val_0 "val"
OpName %arr "arr"
OpName %i "i"
OpName %var_for_index "var_for_index"
OpName %f "f"
OpDecorate %u_block_std140 Block
OpMemberDecorate %u_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
OpDecorate %_arr_mat2v3half_uint_4 ArrayStride 16
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%u_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_u_block_std140 = OpTypePointer Uniform %u_block_std140
%u = OpVariable %_ptr_Uniform_u_block_std140 Uniform
%mat2v3half = OpTypeMatrix %v3half 2
%_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4
%_ptr_Private__arr_mat2v3half_uint_4 = OpTypePointer Private %_arr_mat2v3half_uint_4
%14 = OpConstantNull %_arr_mat2v3half_uint_4
%p = OpVariable %_ptr_Private__arr_mat2v3half_uint_4 Private %14
%15 = OpTypeFunction %mat2v3half %mat2x3_f16
%22 = OpTypeFunction %_arr_mat2v3half_uint_4 %_arr_mat2x3_f16_uint_4
%_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%30 = OpConstantNull %uint
%bool = OpTypeBool
%_ptr_Function__arr_mat2x3_f16_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_uint_4
%43 = OpConstantNull %_arr_mat2x3_f16_uint_4
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%_ptr_Function_mat2x3_f16 = OpTypePointer Function %mat2x3_f16
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%56 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_Uniform__arr_mat2x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_uint_4
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_ptr_Private_mat2v3half = OpTypePointer Private %mat2v3half
%uint_2 = OpConstant %uint 2
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%74 = OpConstantNull %int
%_ptr_Private_v3half = OpTypePointer Private %v3half
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%_ptr_Private_half = OpTypePointer Private %half
%_ptr_Uniform_half = OpTypePointer Uniform %half
%conv_mat2x3_f16 = OpFunction %mat2v3half None %15
%val = OpFunctionParameter %mat2x3_f16
%18 = OpLabel
%19 = OpCompositeExtract %v3half %val 0
%20 = OpCompositeExtract %v3half %val 1
%21 = OpCompositeConstruct %mat2v3half %19 %20
OpReturnValue %21
OpFunctionEnd
%conv_arr4_mat2x3_f16 = OpFunction %_arr_mat2v3half_uint_4 None %22
%val_0 = OpFunctionParameter %_arr_mat2x3_f16_uint_4
%25 = OpLabel
%arr = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %14
%i = OpVariable %_ptr_Function_uint Function %30
%var_for_index = OpVariable %_ptr_Function__arr_mat2x3_f16_uint_4 Function %43
OpBranch %31
%31 = OpLabel
OpLoopMerge %32 %33 None
OpBranch %34
%34 = OpLabel
%36 = OpLoad %uint %i
%37 = OpULessThan %bool %36 %uint_4
%35 = OpLogicalNot %bool %37
OpSelectionMerge %39 None
OpBranchConditional %35 %40 %39
%40 = OpLabel
OpBranch %32
%39 = OpLabel
OpStore %var_for_index %val_0
%44 = OpLoad %uint %i
%46 = OpAccessChain %_ptr_Function_mat2v3half %arr %44
%48 = OpLoad %uint %i
%50 = OpAccessChain %_ptr_Function_mat2x3_f16 %var_for_index %48
%51 = OpLoad %mat2x3_f16 %50
%47 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %51
OpStore %46 %47
OpBranch %33
%33 = OpLabel
%52 = OpLoad %uint %i
%54 = OpIAdd %uint %52 %uint_1
OpStore %i %54
OpBranch %31
%32 = OpLabel
%55 = OpLoad %_arr_mat2v3half_uint_4 %arr
OpReturnValue %55
OpFunctionEnd
%f = OpFunction %void None %56
%59 = OpLabel
%63 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_uint_4 %u %uint_0
%64 = OpLoad %_arr_mat2x3_f16_uint_4 %63
%60 = OpFunctionCall %_arr_mat2v3half_uint_4 %conv_arr4_mat2x3_f16 %64
OpStore %p %60
%68 = OpAccessChain %_ptr_Private_mat2v3half %p %int_1
%72 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %u %uint_0 %uint_2
%73 = OpLoad %mat2x3_f16 %72
%69 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %73
OpStore %68 %69
%76 = OpAccessChain %_ptr_Private_v3half %p %int_1 %74
%78 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %30 %uint_1
%79 = OpLoad %v3half %78
%80 = OpVectorShuffle %v3half %79 %79 2 0 1
OpStore %76 %80
%82 = OpAccessChain %_ptr_Private_half %p %int_1 %74 %uint_0
%84 = OpAccessChain %_ptr_Uniform_half %u %uint_0 %30 %uint_1 %30
%85 = OpLoad %half %84
OpStore %82 %85
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,13 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
var<private> p : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
p = u;
p[1] = u[2];
p[1][0] = u[0][1].zxy;
p[1][0].x = u[0][1].x;
}

View File

@@ -0,0 +1,12 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
@group(0) @binding(1) var<storage, read_write> s : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
s = u;
s[1] = u[2];
s[1][0] = u[0][1].zxy;
s[1][0].x = u[0][1].x;
}

View File

@@ -0,0 +1,55 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
RWByteAddressBuffer s : register(u1, space0);
void tint_symbol_1(RWByteAddressBuffer buffer, uint offset, matrix<float16_t, 2, 3> value) {
buffer.Store<vector<float16_t, 3> >((offset + 0u), value[0u]);
buffer.Store<vector<float16_t, 3> >((offset + 8u), value[1u]);
}
void tint_symbol(RWByteAddressBuffer buffer, uint offset, matrix<float16_t, 2, 3> value[4]) {
matrix<float16_t, 2, 3> array[4] = value;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
tint_symbol_1(buffer, (offset + (i * 16u)), array[i]);
}
}
}
matrix<float16_t, 2, 3> tint_symbol_4(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_3_ret[4];
tint_symbol_3_ret tint_symbol_3(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1] = tint_symbol_4(buffer, (offset + (i_1 * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
tint_symbol(s, 0u, tint_symbol_3(u, 0u));
tint_symbol_1(s, 16u, tint_symbol_4(u, 32u));
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
s.Store<vector<float16_t, 3> >(16u, vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy);
s.Store<float16_t>(16u, float16_t(f16tof32(((u[0].z) & 0xFFFF))));
return;
}

View File

@@ -0,0 +1,61 @@
SKIP: FAILED
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
RWByteAddressBuffer s : register(u1, space0);
void tint_symbol_1(RWByteAddressBuffer buffer, uint offset, matrix<float16_t, 2, 3> value) {
buffer.Store<vector<float16_t, 3> >((offset + 0u), value[0u]);
buffer.Store<vector<float16_t, 3> >((offset + 8u), value[1u]);
}
void tint_symbol(RWByteAddressBuffer buffer, uint offset, matrix<float16_t, 2, 3> value[4]) {
matrix<float16_t, 2, 3> array[4] = value;
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
tint_symbol_1(buffer, (offset + (i * 16u)), array[i]);
}
}
}
matrix<float16_t, 2, 3> tint_symbol_4(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_3_ret[4];
tint_symbol_3_ret tint_symbol_3(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1] = tint_symbol_4(buffer, (offset + (i_1 * 16u)));
}
}
return arr;
}
[numthreads(1, 1, 1)]
void f() {
tint_symbol(s, 0u, tint_symbol_3(u, 0u));
tint_symbol_1(s, 16u, tint_symbol_4(u, 32u));
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
s.Store<vector<float16_t, 3> >(16u, vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy);
s.Store<float16_t>(16u, float16_t(f16tof32(((u[0].z) & 0xFFFF))));
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000001AB590A03F0(6,68-76): error X3000: syntax error: unexpected token 'float16_t'
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x000001AB590A03F0(7,3-14): error X3018: invalid subscript 'Store'

View File

@@ -0,0 +1,42 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform u_block_std140_ubo {
mat2x3_f16 inner[4];
} u;
layout(binding = 1, std430) buffer u_block_ssbo {
f16mat2x3 inner[4];
} s;
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
f16mat2x3[4] conv_arr4_mat2x3_f16(mat2x3_f16 val[4]) {
f16mat2x3 arr[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_mat2x3_f16(val[i]);
}
}
return arr;
}
void f() {
s.inner = conv_arr4_mat2x3_f16(u.inner);
s.inner[1] = conv_mat2x3_f16(u.inner[2u]);
s.inner[1][0] = u.inner[0u].col1.zxy;
s.inner[1][0].x = u.inner[0u].col1[0u];
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f();
return;
}

View File

@@ -0,0 +1,24 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
kernel void f(device tint_array<half2x3, 4>* tint_symbol [[buffer(1)]], const constant tint_array<half2x3, 4>* tint_symbol_1 [[buffer(0)]]) {
*(tint_symbol) = *(tint_symbol_1);
(*(tint_symbol))[1] = (*(tint_symbol_1))[2];
(*(tint_symbol))[1][0] = half3((*(tint_symbol_1))[0][1]).zxy;
(*(tint_symbol))[1][0][0] = (*(tint_symbol_1))[0][1][0];
return;
}

View File

@@ -0,0 +1,154 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 89
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f"
OpExecutionMode %f LocalSize 1 1 1
OpName %u_block_std140 "u_block_std140"
OpMemberName %u_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %u "u"
OpName %u_block "u_block"
OpMemberName %u_block 0 "inner"
OpName %s "s"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %conv_arr4_mat2x3_f16 "conv_arr4_mat2x3_f16"
OpName %val_0 "val"
OpName %arr "arr"
OpName %i "i"
OpName %var_for_index "var_for_index"
OpName %f "f"
OpDecorate %u_block_std140 Block
OpMemberDecorate %u_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
OpDecorate %u_block Block
OpMemberDecorate %u_block 0 Offset 0
OpMemberDecorate %u_block 0 ColMajor
OpMemberDecorate %u_block 0 MatrixStride 8
OpDecorate %_arr_mat2v3half_uint_4 ArrayStride 16
OpDecorate %s DescriptorSet 0
OpDecorate %s Binding 1
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%u_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_u_block_std140 = OpTypePointer Uniform %u_block_std140
%u = OpVariable %_ptr_Uniform_u_block_std140 Uniform
%mat2v3half = OpTypeMatrix %v3half 2
%_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4
%u_block = OpTypeStruct %_arr_mat2v3half_uint_4
%_ptr_StorageBuffer_u_block = OpTypePointer StorageBuffer %u_block
%s = OpVariable %_ptr_StorageBuffer_u_block StorageBuffer
%15 = OpTypeFunction %mat2v3half %mat2x3_f16
%22 = OpTypeFunction %_arr_mat2v3half_uint_4 %_arr_mat2x3_f16_uint_4
%_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4
%28 = OpConstantNull %_arr_mat2v3half_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%31 = OpConstantNull %uint
%bool = OpTypeBool
%_ptr_Function__arr_mat2x3_f16_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_uint_4
%44 = OpConstantNull %_arr_mat2x3_f16_uint_4
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%_ptr_Function_mat2x3_f16 = OpTypePointer Function %mat2x3_f16
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%57 = OpTypeFunction %void
%uint_0 = OpConstant %uint 0
%_ptr_StorageBuffer__arr_mat2v3half_uint_4 = OpTypePointer StorageBuffer %_arr_mat2v3half_uint_4
%_ptr_Uniform__arr_mat2x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_uint_4
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_ptr_StorageBuffer_mat2v3half = OpTypePointer StorageBuffer %mat2v3half
%uint_2 = OpConstant %uint 2
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%77 = OpConstantNull %int
%_ptr_StorageBuffer_v3half = OpTypePointer StorageBuffer %v3half
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%_ptr_StorageBuffer_half = OpTypePointer StorageBuffer %half
%_ptr_Uniform_half = OpTypePointer Uniform %half
%conv_mat2x3_f16 = OpFunction %mat2v3half None %15
%val = OpFunctionParameter %mat2x3_f16
%18 = OpLabel
%19 = OpCompositeExtract %v3half %val 0
%20 = OpCompositeExtract %v3half %val 1
%21 = OpCompositeConstruct %mat2v3half %19 %20
OpReturnValue %21
OpFunctionEnd
%conv_arr4_mat2x3_f16 = OpFunction %_arr_mat2v3half_uint_4 None %22
%val_0 = OpFunctionParameter %_arr_mat2x3_f16_uint_4
%25 = OpLabel
%arr = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %28
%i = OpVariable %_ptr_Function_uint Function %31
%var_for_index = OpVariable %_ptr_Function__arr_mat2x3_f16_uint_4 Function %44
OpBranch %32
%32 = OpLabel
OpLoopMerge %33 %34 None
OpBranch %35
%35 = OpLabel
%37 = OpLoad %uint %i
%38 = OpULessThan %bool %37 %uint_4
%36 = OpLogicalNot %bool %38
OpSelectionMerge %40 None
OpBranchConditional %36 %41 %40
%41 = OpLabel
OpBranch %33
%40 = OpLabel
OpStore %var_for_index %val_0
%45 = OpLoad %uint %i
%47 = OpAccessChain %_ptr_Function_mat2v3half %arr %45
%49 = OpLoad %uint %i
%51 = OpAccessChain %_ptr_Function_mat2x3_f16 %var_for_index %49
%52 = OpLoad %mat2x3_f16 %51
%48 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %52
OpStore %47 %48
OpBranch %34
%34 = OpLabel
%53 = OpLoad %uint %i
%55 = OpIAdd %uint %53 %uint_1
OpStore %i %55
OpBranch %32
%33 = OpLabel
%56 = OpLoad %_arr_mat2v3half_uint_4 %arr
OpReturnValue %56
OpFunctionEnd
%f = OpFunction %void None %57
%60 = OpLabel
%63 = OpAccessChain %_ptr_StorageBuffer__arr_mat2v3half_uint_4 %s %uint_0
%66 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_uint_4 %u %uint_0
%67 = OpLoad %_arr_mat2x3_f16_uint_4 %66
%64 = OpFunctionCall %_arr_mat2v3half_uint_4 %conv_arr4_mat2x3_f16 %67
OpStore %63 %64
%71 = OpAccessChain %_ptr_StorageBuffer_mat2v3half %s %uint_0 %int_1
%75 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %u %uint_0 %uint_2
%76 = OpLoad %mat2x3_f16 %75
%72 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %76
OpStore %71 %72
%79 = OpAccessChain %_ptr_StorageBuffer_v3half %s %uint_0 %int_1 %77
%81 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %31 %uint_1
%82 = OpLoad %v3half %81
%83 = OpVectorShuffle %v3half %82 %82 2 0 1
OpStore %79 %83
%85 = OpAccessChain %_ptr_StorageBuffer_half %s %uint_0 %int_1 %77 %uint_0
%87 = OpAccessChain %_ptr_Uniform_half %u %uint_0 %31 %uint_1 %31
%88 = OpLoad %half %87
OpStore %85 %88
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,13 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
@group(0) @binding(1) var<storage, read_write> s : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
s = u;
s[1] = u[2];
s[1][0] = u[0][1].zxy;
s[1][0].x = u[0][1].x;
}

View File

@@ -0,0 +1,12 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
var<workgroup> w : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
w = u;
w[1] = u[2];
w[1][0] = u[0][1].zxy;
w[1][0].x = u[0][1].x;
}

View File

@@ -0,0 +1,56 @@
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
groupshared matrix<float16_t, 2, 3> w[4];
struct tint_symbol_1 {
uint local_invocation_index : SV_GroupIndex;
};
matrix<float16_t, 2, 3> tint_symbol_3(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_2_ret[4];
tint_symbol_2_ret tint_symbol_2(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1] = tint_symbol_3(buffer, (offset + (i_1 * 16u)));
}
}
return arr;
}
void f_inner(uint local_invocation_index) {
{
for(uint idx = local_invocation_index; (idx < 4u); idx = (idx + 1u)) {
const uint i = idx;
w[i] = matrix<float16_t, 2, 3>((float16_t(0.0h)).xxx, (float16_t(0.0h)).xxx);
}
}
GroupMemoryBarrierWithGroupSync();
w = tint_symbol_2(u, 0u);
w[1] = tint_symbol_3(u, 32u);
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
w[1][0] = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy;
w[1][0].x = float16_t(f16tof32(((u[0].z) & 0xFFFF)));
}
[numthreads(1, 1, 1)]
void f(tint_symbol_1 tint_symbol) {
f_inner(tint_symbol.local_invocation_index);
return;
}

View File

@@ -0,0 +1,61 @@
SKIP: FAILED
cbuffer cbuffer_u : register(b0, space0) {
uint4 u[4];
};
groupshared matrix<float16_t, 2, 3> w[4];
struct tint_symbol_1 {
uint local_invocation_index : SV_GroupIndex;
};
matrix<float16_t, 2, 3> tint_symbol_3(uint4 buffer[4], uint offset) {
const uint scalar_offset = ((offset + 0u)) / 4;
uint4 ubo_load_1 = buffer[scalar_offset / 4];
uint2 ubo_load = ((scalar_offset & 2) ? ubo_load_1.zw : ubo_load_1.xy);
vector<float16_t, 2> ubo_load_xz = vector<float16_t, 2>(f16tof32(ubo_load & 0xFFFF));
float16_t ubo_load_y = f16tof32(ubo_load[0] >> 16);
const uint scalar_offset_1 = ((offset + 8u)) / 4;
uint4 ubo_load_3 = buffer[scalar_offset_1 / 4];
uint2 ubo_load_2 = ((scalar_offset_1 & 2) ? ubo_load_3.zw : ubo_load_3.xy);
vector<float16_t, 2> ubo_load_2_xz = vector<float16_t, 2>(f16tof32(ubo_load_2 & 0xFFFF));
float16_t ubo_load_2_y = f16tof32(ubo_load_2[0] >> 16);
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(ubo_load_xz[0], ubo_load_y, ubo_load_xz[1]), vector<float16_t, 3>(ubo_load_2_xz[0], ubo_load_2_y, ubo_load_2_xz[1]));
}
typedef matrix<float16_t, 2, 3> tint_symbol_2_ret[4];
tint_symbol_2_ret tint_symbol_2(uint4 buffer[4], uint offset) {
matrix<float16_t, 2, 3> arr[4] = (matrix<float16_t, 2, 3>[4])0;
{
for(uint i_1 = 0u; (i_1 < 4u); i_1 = (i_1 + 1u)) {
arr[i_1] = tint_symbol_3(buffer, (offset + (i_1 * 16u)));
}
}
return arr;
}
void f_inner(uint local_invocation_index) {
{
for(uint idx = local_invocation_index; (idx < 4u); idx = (idx + 1u)) {
const uint i = idx;
w[i] = matrix<float16_t, 2, 3>((float16_t(0.0h)).xxx, (float16_t(0.0h)).xxx);
}
}
GroupMemoryBarrierWithGroupSync();
w = tint_symbol_2(u, 0u);
w[1] = tint_symbol_3(u, 32u);
uint2 ubo_load_4 = u[0].zw;
vector<float16_t, 2> ubo_load_4_xz = vector<float16_t, 2>(f16tof32(ubo_load_4 & 0xFFFF));
float16_t ubo_load_4_y = f16tof32(ubo_load_4[0] >> 16);
w[1][0] = vector<float16_t, 3>(ubo_load_4_xz[0], ubo_load_4_y, ubo_load_4_xz[1]).zxy;
w[1][0].x = float16_t(f16tof32(((u[0].z) & 0xFFFF)));
}
[numthreads(1, 1, 1)]
void f(tint_symbol_1 tint_symbol) {
f_inner(tint_symbol.local_invocation_index);
return;
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\buffer\Shader@0x0000019397EFCDD0(4,20-28): error X3000: syntax error: unexpected token 'float16_t'

View File

@@ -0,0 +1,46 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
struct mat2x3_f16 {
f16vec3 col0;
f16vec3 col1;
};
layout(binding = 0, std140) uniform u_block_std140_ubo {
mat2x3_f16 inner[4];
} u;
shared f16mat2x3 w[4];
f16mat2x3 conv_mat2x3_f16(mat2x3_f16 val) {
return f16mat2x3(val.col0, val.col1);
}
f16mat2x3[4] conv_arr4_mat2x3_f16(mat2x3_f16 val[4]) {
f16mat2x3 arr[4] = f16mat2x3[4](f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf), f16mat2x3(0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf, 0.0hf));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_mat2x3_f16(val[i]);
}
}
return arr;
}
void f(uint local_invocation_index) {
{
for(uint idx = local_invocation_index; (idx < 4u); idx = (idx + 1u)) {
uint i = idx;
w[i] = f16mat2x3(f16vec3(0.0hf), f16vec3(0.0hf));
}
}
barrier();
w = conv_arr4_mat2x3_f16(u.inner);
w[1] = conv_mat2x3_f16(u.inner[2u]);
w[1][0] = u.inner[0u].col1.zxy;
w[1][0].x = u.inner[0u].col1[0u];
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main() {
f(gl_LocalInvocationIndex);
return;
}

View File

@@ -0,0 +1,38 @@
#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
const constant T& operator[](size_t i) const constant { return elements[i]; }
device T& operator[](size_t i) device { return elements[i]; }
const device T& operator[](size_t i) const device { return elements[i]; }
thread T& operator[](size_t i) thread { return elements[i]; }
const thread T& operator[](size_t i) const thread { return elements[i]; }
threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
T elements[N];
};
struct tint_symbol_5 {
tint_array<half2x3, 4> w;
};
void f_inner(uint local_invocation_index, threadgroup tint_array<half2x3, 4>* const tint_symbol, const constant tint_array<half2x3, 4>* const tint_symbol_1) {
for(uint idx = local_invocation_index; (idx < 4u); idx = (idx + 1u)) {
uint const i = idx;
(*(tint_symbol))[i] = half2x3(half3(0.0h), half3(0.0h));
}
threadgroup_barrier(mem_flags::mem_threadgroup);
*(tint_symbol) = *(tint_symbol_1);
(*(tint_symbol))[1] = (*(tint_symbol_1))[2];
(*(tint_symbol))[1][0] = half3((*(tint_symbol_1))[0][1]).zxy;
(*(tint_symbol))[1][0][0] = (*(tint_symbol_1))[0][1][0];
}
kernel void f(const constant tint_array<half2x3, 4>* tint_symbol_4 [[buffer(0)]], threadgroup tint_symbol_5* tint_symbol_3 [[threadgroup(0)]], uint local_invocation_index [[thread_index_in_threadgroup]]) {
threadgroup tint_array<half2x3, 4>* const tint_symbol_2 = &((*(tint_symbol_3)).w);
f_inner(local_invocation_index, tint_symbol_2, tint_symbol_4);
return;
}

View File

@@ -0,0 +1,186 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 111
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %f "f" %local_invocation_index_1
OpExecutionMode %f LocalSize 1 1 1
OpName %local_invocation_index_1 "local_invocation_index_1"
OpName %u_block_std140 "u_block_std140"
OpMemberName %u_block_std140 0 "inner"
OpName %mat2x3_f16 "mat2x3_f16"
OpMemberName %mat2x3_f16 0 "col0"
OpMemberName %mat2x3_f16 1 "col1"
OpName %u "u"
OpName %w "w"
OpName %conv_mat2x3_f16 "conv_mat2x3_f16"
OpName %val "val"
OpName %conv_arr4_mat2x3_f16 "conv_arr4_mat2x3_f16"
OpName %val_0 "val"
OpName %arr "arr"
OpName %i "i"
OpName %var_for_index "var_for_index"
OpName %f_inner "f_inner"
OpName %local_invocation_index "local_invocation_index"
OpName %idx "idx"
OpName %f "f"
OpDecorate %local_invocation_index_1 BuiltIn LocalInvocationIndex
OpDecorate %u_block_std140 Block
OpMemberDecorate %u_block_std140 0 Offset 0
OpMemberDecorate %mat2x3_f16 0 Offset 0
OpMemberDecorate %mat2x3_f16 1 Offset 8
OpDecorate %_arr_mat2x3_f16_uint_4 ArrayStride 16
OpDecorate %u NonWritable
OpDecorate %u DescriptorSet 0
OpDecorate %u Binding 0
OpDecorate %_arr_mat2v3half_uint_4 ArrayStride 16
%uint = OpTypeInt 32 0
%_ptr_Input_uint = OpTypePointer Input %uint
%local_invocation_index_1 = OpVariable %_ptr_Input_uint Input
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2x3_f16 = OpTypeStruct %v3half %v3half
%uint_4 = OpConstant %uint 4
%_arr_mat2x3_f16_uint_4 = OpTypeArray %mat2x3_f16 %uint_4
%u_block_std140 = OpTypeStruct %_arr_mat2x3_f16_uint_4
%_ptr_Uniform_u_block_std140 = OpTypePointer Uniform %u_block_std140
%u = OpVariable %_ptr_Uniform_u_block_std140 Uniform
%mat2v3half = OpTypeMatrix %v3half 2
%_arr_mat2v3half_uint_4 = OpTypeArray %mat2v3half %uint_4
%_ptr_Workgroup__arr_mat2v3half_uint_4 = OpTypePointer Workgroup %_arr_mat2v3half_uint_4
%w = OpVariable %_ptr_Workgroup__arr_mat2v3half_uint_4 Workgroup
%16 = OpTypeFunction %mat2v3half %mat2x3_f16
%23 = OpTypeFunction %_arr_mat2v3half_uint_4 %_arr_mat2x3_f16_uint_4
%_ptr_Function__arr_mat2v3half_uint_4 = OpTypePointer Function %_arr_mat2v3half_uint_4
%29 = OpConstantNull %_arr_mat2v3half_uint_4
%_ptr_Function_uint = OpTypePointer Function %uint
%32 = OpConstantNull %uint
%bool = OpTypeBool
%_ptr_Function__arr_mat2x3_f16_uint_4 = OpTypePointer Function %_arr_mat2x3_f16_uint_4
%45 = OpConstantNull %_arr_mat2x3_f16_uint_4
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%_ptr_Function_mat2x3_f16 = OpTypePointer Function %mat2x3_f16
%uint_1 = OpConstant %uint 1
%void = OpTypeVoid
%58 = OpTypeFunction %void %uint
%_ptr_Workgroup_mat2v3half = OpTypePointer Workgroup %mat2v3half
%76 = OpConstantNull %mat2v3half
%uint_2 = OpConstant %uint 2
%uint_264 = OpConstant %uint 264
%uint_0 = OpConstant %uint 0
%_ptr_Uniform__arr_mat2x3_f16_uint_4 = OpTypePointer Uniform %_arr_mat2x3_f16_uint_4
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_ptr_Uniform_mat2x3_f16 = OpTypePointer Uniform %mat2x3_f16
%94 = OpConstantNull %int
%_ptr_Workgroup_v3half = OpTypePointer Workgroup %v3half
%_ptr_Uniform_v3half = OpTypePointer Uniform %v3half
%_ptr_Workgroup_half = OpTypePointer Workgroup %half
%_ptr_Uniform_half = OpTypePointer Uniform %half
%106 = OpTypeFunction %void
%conv_mat2x3_f16 = OpFunction %mat2v3half None %16
%val = OpFunctionParameter %mat2x3_f16
%19 = OpLabel
%20 = OpCompositeExtract %v3half %val 0
%21 = OpCompositeExtract %v3half %val 1
%22 = OpCompositeConstruct %mat2v3half %20 %21
OpReturnValue %22
OpFunctionEnd
%conv_arr4_mat2x3_f16 = OpFunction %_arr_mat2v3half_uint_4 None %23
%val_0 = OpFunctionParameter %_arr_mat2x3_f16_uint_4
%26 = OpLabel
%arr = OpVariable %_ptr_Function__arr_mat2v3half_uint_4 Function %29
%i = OpVariable %_ptr_Function_uint Function %32
%var_for_index = OpVariable %_ptr_Function__arr_mat2x3_f16_uint_4 Function %45
OpBranch %33
%33 = OpLabel
OpLoopMerge %34 %35 None
OpBranch %36
%36 = OpLabel
%38 = OpLoad %uint %i
%39 = OpULessThan %bool %38 %uint_4
%37 = OpLogicalNot %bool %39
OpSelectionMerge %41 None
OpBranchConditional %37 %42 %41
%42 = OpLabel
OpBranch %34
%41 = OpLabel
OpStore %var_for_index %val_0
%46 = OpLoad %uint %i
%48 = OpAccessChain %_ptr_Function_mat2v3half %arr %46
%50 = OpLoad %uint %i
%52 = OpAccessChain %_ptr_Function_mat2x3_f16 %var_for_index %50
%53 = OpLoad %mat2x3_f16 %52
%49 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %53
OpStore %48 %49
OpBranch %35
%35 = OpLabel
%54 = OpLoad %uint %i
%56 = OpIAdd %uint %54 %uint_1
OpStore %i %56
OpBranch %33
%34 = OpLabel
%57 = OpLoad %_arr_mat2v3half_uint_4 %arr
OpReturnValue %57
OpFunctionEnd
%f_inner = OpFunction %void None %58
%local_invocation_index = OpFunctionParameter %uint
%62 = OpLabel
%idx = OpVariable %_ptr_Function_uint Function %32
OpStore %idx %local_invocation_index
OpBranch %64
%64 = OpLabel
OpLoopMerge %65 %66 None
OpBranch %67
%67 = OpLabel
%69 = OpLoad %uint %idx
%70 = OpULessThan %bool %69 %uint_4
%68 = OpLogicalNot %bool %70
OpSelectionMerge %71 None
OpBranchConditional %68 %72 %71
%72 = OpLabel
OpBranch %65
%71 = OpLabel
%73 = OpLoad %uint %idx
%75 = OpAccessChain %_ptr_Workgroup_mat2v3half %w %73
OpStore %75 %76
OpBranch %66
%66 = OpLabel
%77 = OpLoad %uint %idx
%78 = OpIAdd %uint %77 %uint_1
OpStore %idx %78
OpBranch %64
%65 = OpLabel
OpControlBarrier %uint_2 %uint_2 %uint_264
%85 = OpAccessChain %_ptr_Uniform__arr_mat2x3_f16_uint_4 %u %uint_0
%86 = OpLoad %_arr_mat2x3_f16_uint_4 %85
%82 = OpFunctionCall %_arr_mat2v3half_uint_4 %conv_arr4_mat2x3_f16 %86
OpStore %w %82
%89 = OpAccessChain %_ptr_Workgroup_mat2v3half %w %int_1
%92 = OpAccessChain %_ptr_Uniform_mat2x3_f16 %u %uint_0 %uint_2
%93 = OpLoad %mat2x3_f16 %92
%90 = OpFunctionCall %mat2v3half %conv_mat2x3_f16 %93
OpStore %89 %90
%96 = OpAccessChain %_ptr_Workgroup_v3half %w %int_1 %94
%98 = OpAccessChain %_ptr_Uniform_v3half %u %uint_0 %32 %uint_1
%99 = OpLoad %v3half %98
%100 = OpVectorShuffle %v3half %99 %99 2 0 1
OpStore %96 %100
%102 = OpAccessChain %_ptr_Workgroup_half %w %int_1 %94 %uint_0
%104 = OpAccessChain %_ptr_Uniform_half %u %uint_0 %32 %uint_1 %32
%105 = OpLoad %half %104
OpStore %102 %105
OpReturn
OpFunctionEnd
%f = OpFunction %void None %106
%108 = OpLabel
%110 = OpLoad %uint %local_invocation_index_1
%109 = OpFunctionCall %void %f_inner %110
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,13 @@
enable f16;
@group(0) @binding(0) var<uniform> u : array<mat2x3<f16>, 4>;
var<workgroup> w : array<mat2x3<f16>, 4>;
@compute @workgroup_size(1)
fn f() {
w = u;
w[1] = u[2];
w[1][0] = u[0][1].zxy;
w[1][0].x = u[0][1].x;
}