blob: d38c9b685f9b973963dfb3888b1a39cac7c1a121 [file] [log] [blame]
#!amber
# Copyright 2021 Google LLC.
# Copyright 2021 The Khronos Group Inc.
#
# 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.
# Matrix 4x4 inverse precision test 16bit storage 32bit
DEVICE_EXTENSION VK_KHR_storage_buffer_storage_class
DEVICE_EXTENSION VK_KHR_16bit_storage
DEVICE_FEATURE Float16Int8Features.shaderFloat16
SHADER compute compute_shader GLSL
#version 450
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable
const int NUMMATRICES = 10;
layout(set = 0, binding = 0) buffer block0
{
mat4 matIns[NUMMATRICES];
};
layout(set = 0, binding = 1) buffer block1
{
mat4 invOutM[NUMMATRICES];
};
void main()
{
for (int ndx = 0; ndx < NUMMATRICES; ndx++)
{
f16mat4 matIn_16 = f16mat4(matIns[ndx]);
f16mat4 matInv_16 = inverse(matIn_16);
for (int row = 0; row < 4; row++)
{
for (int col = 0; col < 4; col++)
{
invOutM[ndx][row][col] = uintBitsToFloat(packFloat2x16(f16vec2(matInv_16[row][col], float16_t(-1.0))));
// Some GPUs are handling -0.0 as 0.0 when others don't.
if (matInv_16[row][col] == -0.0) invOutM[ndx][row][col] = uintBitsToFloat(packFloat2x16(f16vec2(0.0, float16_t(-1.0))));
}
}
}
}
END
BUFFER bufIn DATA_TYPE mat4x4<float> DATA
-1.0 1.0 4.0 2.0
2.0 -1.0 2.0 5.0
1.0 2.0 3.0 4.0
3.0 4.0 -1.0 2.0
1.0 0.0 0.0 0.0
0.0 0.0 1.0 0.0
0.0 1.0 0.0 0.0
0.0 0.0 0.0 1.0
-0.08837890625 0.1569824219 0.001299858093 0.2451171875
0.0380859375 0.7124023438 -0.003200531006 0.9111328125
0.07598876953 0.09777832031 -1.060546875 1.904296875
-0.4968261719 1.595703125 0.01309967041 -2.6953125
42 0.3000488281 -0.04800415039 -270
15 4.80078125 -4.8984375 -41
-0.1800537109 -0.7001953125 -0.02299499512 0.3701171875
-0.000500202179 -0.002799987793 -0.7998046875 -0.2900390625
500 -3.599609375 -15 37
2.900390625 -0.4699707031 3.19921875 4.69921875
0.09997558594 0.04400634766 0.005001068115 -0.02799987793
-48 19 -1.099609375 0.03799438477
-17 -1100 -100 -0.01800537109
6 43 -3.099609375 20
-2.30078125 0.002700805664 -0.000500202179 -1.900390625
0.3601074219 0.3100585938 -0.00479888916 0.02699279785
-3.384765625 3.154296875 -9.8671875 1.489257812
-1.336914062 1.853515625 13.1875 4.7734375
-2.580078125 54.8125 -5.62890625 -1.877929688
-0.7348632812 -1.95703125 1.390625 5.82421875
0.033935546875 0.0477600097656 -0.0791015625 0.40380859375
0.0431823730469 0.0899047851563 0.033966064453 -0.00238609313965
0.10986328125 -0.4140625 0.184326171875 -0.00595855712891
-7.19921875 0.0353088378906 -0.020690917969 -0.02047729492188
-11.9375 3.626953125 1.5517578125 -2.2109375
0.9501953125 3.873046875 2.546875 5.64453125
9.3515625 -1.462890625 -1.759765625 1.2939453125
5.953125 -8.5546875 -1.806640625 -2.95703125
-13.421875 -1.57421875 4.17578125 4.421875
-1.33300781 2.875 -5.18359375 1.84960938
-1.30273438 -5.03125 -0.909179688 1.53710938
-17.03125 1.13378906 2.16601562 -1.44628906
END
BUFFER bufOut DATA_TYPE mat4x4<float> SIZE 10 FILL 0.0
PIPELINE compute pipeline
ATTACH compute_shader
BIND BUFFER bufIn AS storage DESCRIPTOR_SET 0 BINDING 0
BIND BUFFER bufOut AS storage DESCRIPTOR_SET 0 BINDING 1
END
RUN pipeline 1 1 1
EXPECT bufOut IDX 0 TOLERANCE 0.00000762939453125 EQ -0.00782783236 -0.00782695226 -0.00785884447 -0.0078271348 -0.0078559285 -0.0078559285 -0.00782629196 -0.00785431452 -0.00782746542 -0.00782621838 -0.00785833132 -0.00782643817 -0.00785790943 -0.00785658881 -0.00782788731 -0.0078571029
EXPECT bufOut IDX 64 TOLERANCE 0.00000762939453125 EQ -0.007826805115 -0.0078125 -0.0078125 -0.0078125 -0.0078125 -0.0078125 -0.007826805115 -0.0078125 -0.0078125 -0.007826805115 -0.0078125 -0.0078125 -0.0078125 -0.0078125 -0.0078125 -0.007826805115
EXPECT bufOut IDX 128 TOLERANCE 0.00000762939453125 EQ -0.00786039233 -0.00782793667 -0.00785188843 -0.007854064 -0.0078573348 -0.00782684796 -0.00784798525 -0.00782493595 -0.00782715902 -0.00782603491 -0.00785722211 -0.00785577018 -0.00782700069 -0.00782439206 -0.0078483494 -0.00785503723
EXPECT bufOut IDX 192 TOLERANCE 0.00000762939453125 EQ -0.00785167329 -0.0078239264 -0.00782650989 -0.00785690639 -0.00781713333 -0.00785195641 -0.00785787124 -0.00782433804 -0.00781839062 -0.00785044394 -0.00785288401 -0.0078575192 -0.00785028189 -0.00782130379 -0.00782398041 -0.00785440393
EXPECT bufOut IDX 256 TOLERANCE 0.00000762939453125 EQ -0.007817515172 -0.007817740552 -0.007827628404 -0.007849726826 -0.007818487473 -0.007821098901 -0.007829193957 -0.007822289132 -0.007850944996 -0.007824616507 -0.007830985822 -0.007853064686 -0.007819803432 -0.007823077962 -0.007861092687 -0.007822276093
EXPECT bufOut IDX 320 TOLERANCE 0.00000762939453125 EQ -0.007815311663 -0.007851086557 -0.007853861898 -0.00782796368 -0.007846281864 -0.007820436731 -0.007823815569 -0.007825960405 -0.007850256748 -0.007854256779 -0.007857577875 -0.007859832607 -0.007846044376 -0.007820869796 -0.007856068201 -0.007858723402
EXPECT bufOut IDX 384 TOLERANCE 0.00000762939453125 EQ -0.007855568081 -0.007855271921 -0.007822129875 -0.00782499183 -0.007851642556 -0.007850030437 -0.00782134477 -0.007820996456 -0.007851278409 -0.007823110558 -0.007849549875 -0.007853295654 -0.007852789946 -0.007853059098 -0.007820624858 -0.007824704051
EXPECT bufOut IDX 448 TOLERANCE 0.00000762939453125 EQ -0.007851495408 -0.007852491923 -0.007852577604 -0.007855524309 -0.007822327316 -0.007830150425 -0.007858371362 -0.007822272368 -0.007824943401 -0.007831288502 -0.007829180919 -0.007824919187 -0.007828950882 -0.007828669623 -0.007827216759 -0.007823087275
EXPECT bufOut IDX 512 TOLERANCE 0.00000762939453125 EQ -0.007829133421 -0.007827866822 -0.007829137146 -0.007827980444 -0.007828807458 -0.007827293128 -0.007828824222 -0.007827327587 -0.007830743678 -0.007829512469 -0.007830690593 -0.007829671726 -0.007860678248 -0.007859318517 -0.007860636339 -0.0078594964
EXPECT bufOut IDX 576 TOLERANCE 0.00000762939453125 EQ -0.00784824509 -0.00785185397 -0.0078520542 -0.00785325561 -0.00782216899 -0.00782270823 -0.00785490777 -0.00785175525 -0.00782322045 -0.0078544952 -0.00785419904 -0.00785290636 -0.00782421976 -0.00782327354 -0.00785262417 -0.00785450544