tint: add missing F16 conversion expression support

This CL add missing type conversions for f16, especially for SPIRV
backend which require special handling. A transform,
VectorizeMatrixConversions, are also added for SPIRV to replace a matrix
conversion to a matrix construction with converted column vectors.
Unittests for the transform and SPIRV writer, and end-to-end tests for
all conversion rules are added.

Bug: tint:1473, tint:1502, chromium:1356215
Change-Id: Iaff125e5dd295d35c4ab74757eb56b642802a51a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100483
Reviewed-by: David Neto <dneto@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Zhaoming Jiang 2022-09-01 03:08:20 +00:00 committed by Dawn LUCI CQ
parent 0df4e4aea3
commit 426b47e481
2066 changed files with 28825 additions and 84 deletions

View File

@ -547,6 +547,8 @@ libtint_source_set("libtint_core_all_src") {
"transform/utils/hoist_to_decl_before.h", "transform/utils/hoist_to_decl_before.h",
"transform/var_for_dynamic_index.cc", "transform/var_for_dynamic_index.cc",
"transform/var_for_dynamic_index.h", "transform/var_for_dynamic_index.h",
"transform/vectorize_matrix_conversions.cc",
"transform/vectorize_matrix_conversions.h",
"transform/vectorize_scalar_matrix_constructors.cc", "transform/vectorize_scalar_matrix_constructors.cc",
"transform/vectorize_scalar_matrix_constructors.h", "transform/vectorize_scalar_matrix_constructors.h",
"transform/vertex_pulling.cc", "transform/vertex_pulling.cc",
@ -1219,6 +1221,7 @@ if (tint_build_unittests) {
"transform/utils/get_insertion_point_test.cc", "transform/utils/get_insertion_point_test.cc",
"transform/utils/hoist_to_decl_before_test.cc", "transform/utils/hoist_to_decl_before_test.cc",
"transform/var_for_dynamic_index_test.cc", "transform/var_for_dynamic_index_test.cc",
"transform/vectorize_matrix_conversions_test.cc",
"transform/vectorize_scalar_matrix_constructors_test.cc", "transform/vectorize_scalar_matrix_constructors_test.cc",
"transform/vertex_pulling_test.cc", "transform/vertex_pulling_test.cc",
"transform/while_to_loop_test.cc", "transform/while_to_loop_test.cc",

View File

@ -459,6 +459,8 @@ set(TINT_LIB_SRCS
transform/utils/hoist_to_decl_before.h transform/utils/hoist_to_decl_before.h
transform/var_for_dynamic_index.cc transform/var_for_dynamic_index.cc
transform/var_for_dynamic_index.h transform/var_for_dynamic_index.h
transform/vectorize_matrix_conversions.cc
transform/vectorize_matrix_conversions.h
transform/vectorize_scalar_matrix_constructors.cc transform/vectorize_scalar_matrix_constructors.cc
transform/vectorize_scalar_matrix_constructors.h transform/vectorize_scalar_matrix_constructors.h
transform/vertex_pulling.cc transform/vertex_pulling.cc
@ -1131,6 +1133,7 @@ if(TINT_BUILD_TESTS)
transform/unshadow_test.cc transform/unshadow_test.cc
transform/unwind_discard_functions_test.cc transform/unwind_discard_functions_test.cc
transform/var_for_dynamic_index_test.cc transform/var_for_dynamic_index_test.cc
transform/vectorize_matrix_conversions_test.cc
transform/vectorize_scalar_matrix_constructors_test.cc transform/vectorize_scalar_matrix_constructors_test.cc
transform/vertex_pulling_test.cc transform/vertex_pulling_test.cc
transform/while_to_loop_test.cc transform/while_to_loop_test.cc

View File

@ -0,0 +1,136 @@
// Copyright 2022 The Tint Authors.
//
// 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.
#include "src/tint/transform/vectorize_matrix_conversions.h"
#include <tuple>
#include <unordered_map>
#include <utility>
#include "src/tint/program_builder.h"
#include "src/tint/sem/abstract_numeric.h"
#include "src/tint/sem/call.h"
#include "src/tint/sem/expression.h"
#include "src/tint/sem/type_conversion.h"
#include "src/tint/utils/hash.h"
#include "src/tint/utils/map.h"
TINT_INSTANTIATE_TYPEINFO(tint::transform::VectorizeMatrixConversions);
namespace tint::transform {
VectorizeMatrixConversions::VectorizeMatrixConversions() = default;
VectorizeMatrixConversions::~VectorizeMatrixConversions() = default;
bool VectorizeMatrixConversions::ShouldRun(const Program* program, const DataMap&) const {
for (auto* node : program->ASTNodes().Objects()) {
if (auto* sem = program->Sem().Get<sem::Expression>(node)) {
if (auto* call = sem->UnwrapMaterialize()->As<sem::Call>()) {
if (call->Target()->Is<sem::TypeConversion>() && call->Type()->Is<sem::Matrix>()) {
auto& args = call->Arguments();
if (args.Length() == 1 && args[0]->Type()->UnwrapRef()->is_float_matrix()) {
return true;
}
}
}
}
}
return false;
}
void VectorizeMatrixConversions::Run(CloneContext& ctx, const DataMap&, DataMap&) const {
using HelperFunctionKey =
utils::UnorderedKeyWrapper<std::tuple<const sem::Matrix*, const sem::Matrix*>>;
std::unordered_map<HelperFunctionKey, Symbol> matrix_convs;
ctx.ReplaceAll([&](const ast::CallExpression* expr) -> const ast::CallExpression* {
auto* call = ctx.src->Sem().Get(expr)->UnwrapMaterialize()->As<sem::Call>();
auto* ty_conv = call->Target()->As<sem::TypeConversion>();
if (!ty_conv) {
return nullptr;
}
auto* dst_type = call->Type()->As<sem::Matrix>();
if (!dst_type) {
return nullptr;
}
auto& args = call->Arguments();
if (args.Length() != 1) {
return nullptr;
}
auto& src = args[0];
auto* src_type = args[0]->Type()->UnwrapRef()->As<sem::Matrix>();
if (!src_type) {
return nullptr;
}
// The source and destination type of a matrix conversion must have a same shape.
if (!(src_type->rows() == dst_type->rows() && src_type->columns() == dst_type->columns())) {
TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "source and destination matrix has different shape in matrix conversion";
return nullptr;
}
auto build_vectorized_conversion_expression = [&](auto&& src_expression_builder) {
utils::Vector<const ast::Expression*, 4> columns;
for (uint32_t c = 0; c < dst_type->columns(); c++) {
auto* src_matrix_expr = src_expression_builder();
auto* src_column_expr =
ctx.dst->IndexAccessor(src_matrix_expr, ctx.dst->Expr(tint::AInt(c)));
columns.Push(ctx.dst->Construct(CreateASTTypeFor(ctx, dst_type->ColumnType()),
src_column_expr));
}
return ctx.dst->Construct(CreateASTTypeFor(ctx, dst_type), columns);
};
// Replace the matrix conversion to column vector conversions and a matrix construction.
if (!src->HasSideEffects()) {
// Simply use the argument's declaration if it has no side effects.
return build_vectorized_conversion_expression([&]() { //
return ctx.Clone(src->Declaration());
});
} else {
// If has side effects, use a helper function.
auto fn =
utils::GetOrCreate(matrix_convs, HelperFunctionKey{{src_type, dst_type}}, [&] {
auto name =
ctx.dst->Symbols().New("convert_mat" + std::to_string(src_type->columns()) +
"x" + std::to_string(src_type->rows()) + "_" +
ctx.dst->FriendlyName(src_type->type()) + "_" +
ctx.dst->FriendlyName(dst_type->type()));
ctx.dst->Func(
name,
utils::Vector{
ctx.dst->Param("value", CreateASTTypeFor(ctx, src_type)),
},
CreateASTTypeFor(ctx, dst_type),
utils::Vector{
ctx.dst->Return(build_vectorized_conversion_expression([&]() { //
return ctx.dst->Expr("value");
})),
});
return name;
});
return ctx.dst->Call(fn, ctx.Clone(args[0]->Declaration()));
}
});
ctx.Clone();
}
} // namespace tint::transform

View File

@ -0,0 +1,48 @@
// Copyright 2022 The Tint Authors.
//
// 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.
#ifndef SRC_TINT_TRANSFORM_VECTORIZE_MATRIX_CONVERSIONS_H_
#define SRC_TINT_TRANSFORM_VECTORIZE_MATRIX_CONVERSIONS_H_
#include "src/tint/transform/transform.h"
namespace tint::transform {
/// A transform that converts matrix conversions (between f32 and f16 matrices) to the vector form.
class VectorizeMatrixConversions final : public Castable<VectorizeMatrixConversions, Transform> {
public:
/// Constructor
VectorizeMatrixConversions();
/// Destructor
~VectorizeMatrixConversions() override;
/// @param program the program to inspect
/// @param data optional extra transform-specific input data
/// @returns true if this transform should be run for the given program
bool ShouldRun(const Program* program, const DataMap& data = {}) const override;
protected:
/// Runs the transform using the CloneContext built for transforming a
/// program. Run() is responsible for calling Clone() on the CloneContext.
/// @param ctx the CloneContext primed with the input program and
/// ProgramBuilder
/// @param inputs optional extra transform-specific input data
/// @param outputs optional extra transform-specific output data
void Run(CloneContext& ctx, const DataMap& inputs, DataMap& outputs) const override;
};
} // namespace tint::transform
#endif // SRC_TINT_TRANSFORM_VECTORIZE_MATRIX_CONVERSIONS_H_

View File

@ -0,0 +1,411 @@
// Copyright 2022 The Tint Authors.
//
// 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.
#include "src/tint/transform/vectorize_matrix_conversions.h"
#include <string>
#include <utility>
#include "src/tint/transform/test_helper.h"
#include "src/tint/utils/string.h"
namespace tint::transform {
namespace {
using VectorizeMatrixConversionsTest = TransformTestWithParam<std::pair<uint32_t, uint32_t>>;
TEST_F(VectorizeMatrixConversionsTest, ShouldRunEmptyModule) {
auto* src = R"()";
EXPECT_FALSE(ShouldRun<VectorizeMatrixConversions>(src));
}
// Test that VectorizeMatrixConversions transforms the matRxC<f32> to matRxC<f16> conversion as
// expected.
//
// Example input:
//
// enable f16;
//
// @fragment
// fn main() {
// let m = mat3x2<f32>(vec2<f32>(0.0, 1.0), vec2<f32>(2.0, 3.0), vec2<f32>(4.0, 5.0));
// let n : mat3x2<f16> = mat3x2<f16>(m);
// }
//
// Example output:
//
// enable f16;
//
// @fragment
// fn main() {
// let m = mat3x2<f32>(vec2<f32>(0.0, 1.0), vec2<f32>(2.0, 3.0), vec2<f32>(4.0, 5.0));
// let n : mat3x2<f16> = mat3x2<f16>(vec2<f16>(m[0]), vec2<f16>(m[1]), vec2<f16>(m[2]));
// }
TEST_P(VectorizeMatrixConversionsTest, Conversion_F32ToF16) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string src_mat_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows) + "<f32>";
std::string src_vec_type = "vec" + std::to_string(rows) + "<f32>";
std::string dst_mat_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows) + "<f16>";
std::string dst_vec_type = "vec" + std::to_string(rows) + "<f16>";
std::string vector_values;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
vector_values += ", ";
}
vector_values += src_vec_type + "(";
for (uint32_t r = 0; r < rows; r++) {
if (r > 0) {
vector_values += ", ";
}
auto value = std::to_string(c * rows + r) + ".0";
vector_values += value;
}
vector_values += ")";
}
std::string vectorized_args = "";
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
vectorized_args += ", ";
}
vectorized_args += dst_vec_type + "(m[" + std::to_string(c) + "])";
}
std::string tmpl = R"(
enable f16;
@fragment
fn main() {
let m = ${src_mat_type}(${values});
let n : ${dst_mat_type} = ${dst_mat_type}(${args});
}
)";
tmpl = utils::ReplaceAll(tmpl, "${src_mat_type}", src_mat_type);
tmpl = utils::ReplaceAll(tmpl, "${dst_mat_type}", dst_mat_type);
tmpl = utils::ReplaceAll(tmpl, "${values}", vector_values);
auto src = utils::ReplaceAll(tmpl, "${args}", "m");
auto expect = utils::ReplaceAll(tmpl, "${args}", vectorized_args);
EXPECT_TRUE(ShouldRun<VectorizeMatrixConversions>(src));
auto got = Run<VectorizeMatrixConversions>(src);
EXPECT_EQ(expect, str(got));
}
// Test that VectorizeMatrixConversions transforms the matRxC<f32> to matRxC<f16> conversion as
// expected.
//
// Example input:
//
// enable f16;
//
// @fragment
// fn main() {
// let m = mat3x2<f16>(vec2<f16>(0.0, 1.0), vec2<f16>(2.0, 3.0), vec2<f16>(4.0, 5.0));
// let n : mat3x2<f32> = mat3x2<f32>(m);
// }
//
// Example output:
//
// enable f16;
//
// @fragment
// fn main() {
// let m = mat3x2<f16>(vec2<f16>(0.0, 1.0), vec2<f16>(2.0, 3.0), vec2<f16>(4.0, 5.0));
// let n : mat3x2<f32> = mat3x2<f32>(vec2<f32>(m[0]), vec2<f32>(m[1]), vec2<f32>(m[2]));
// }
TEST_P(VectorizeMatrixConversionsTest, Conversion_F16ToF32) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string src_mat_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows) + "<f16>";
std::string src_vec_type = "vec" + std::to_string(rows) + "<f16>";
std::string dst_mat_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows) + "<f32>";
std::string dst_vec_type = "vec" + std::to_string(rows) + "<f32>";
std::string vector_values;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
vector_values += ", ";
}
vector_values += src_vec_type + "(";
for (uint32_t r = 0; r < rows; r++) {
if (r > 0) {
vector_values += ", ";
}
auto value = std::to_string(c * rows + r) + ".0";
vector_values += value;
}
vector_values += ")";
}
std::string vectorized_args = "";
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
vectorized_args += ", ";
}
vectorized_args += dst_vec_type + "(m[" + std::to_string(c) + "])";
}
std::string tmpl = R"(
enable f16;
@fragment
fn main() {
let m = ${src_mat_type}(${values});
let n : ${dst_mat_type} = ${dst_mat_type}(${args});
}
)";
tmpl = utils::ReplaceAll(tmpl, "${src_mat_type}", src_mat_type);
tmpl = utils::ReplaceAll(tmpl, "${dst_mat_type}", dst_mat_type);
tmpl = utils::ReplaceAll(tmpl, "${values}", vector_values);
auto src = utils::ReplaceAll(tmpl, "${args}", "m");
auto expect = utils::ReplaceAll(tmpl, "${args}", vectorized_args);
EXPECT_TRUE(ShouldRun<VectorizeMatrixConversions>(src));
auto got = Run<VectorizeMatrixConversions>(src);
EXPECT_EQ(expect, str(got));
}
// Test that VectorizeMatrixConversions transform generates help functions for conversions of which
// input expression has side effect.
//
// Example input:
//
// enable f16;
//
// var<private> i : i32 = 0;
//
// fn mat_f32() -> mat2x2<f32> {
// i = (i + 1);
// return mat2x2<f32>(vec2<f32>(f32(i), f32(i)), vec2<f32>(f32(i), f32(i)));
// }
//
// fn mat_f16() -> mat2x2<f16> {
// i = (i + 1);
// return mat2x2<f16>(vec2<f16>(f16(i), f16(i)), vec2<f16>(f16(i), f16(i)));
// }
//
// @fragment
// fn main() {
// let m32 : mat2x2<f32> = mat2x2<f32>(mat_f16());
// let m16 : mat2x2<f16> = mat2x2<f16>(mat_f32());
// }
//
// Example output:
//
// enable f16;
//
// var<private> i : i32 = 0;
//
// fn mat_f32() -> mat2x2<f32> {
// i = (i + 1);
// return mat2x2<f32>(vec2<f32>(f32(i), f32(i)), vec2<f32>(f32(i), f32(i)));
// }
//
// fn mat_f16() -> mat2x2<f16> {
// i = (i + 1);
// return mat2x2<f16>(vec2<f16>(f16(i), f16(i)), vec2<f16>(f16(i), f16(i)));
// }
//
// fn convert_mat2x2_f16_f32(value : mat2x2<f16>) -> mat2x2<f32> {
// return mat2x2<f32>(vec2<f32>(value[0]), vec2<f32>(value[1]));
// }
//
// fn convert_mat2x2_f32_f16(value : mat2x2<f32>) -> mat2x2<f16> {
// return mat2x2<f16>(vec2<f16>(value[0]), vec2<f16>(value[1]));
// }
//
// @fragment
// fn main() {
// let m32 : mat2x2<f32> = convert_mat2x2_f16_f32(mat_f16());
// let m16 : mat2x2<f16> = convert_mat2x2_f32_f16(mat_f32());
// }
TEST_P(VectorizeMatrixConversionsTest, Conversion_WithSideEffect) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string mat_shape = "mat" + std::to_string(cols) + "x" + std::to_string(rows);
std::string f32_mat_type = mat_shape + "<f32>";
std::string f32_vec_type = "vec" + std::to_string(rows) + "<f32>";
std::string f16_mat_type = mat_shape + "<f16>";
std::string f16_vec_type = "vec" + std::to_string(rows) + "<f16>";
std::string f32_vector_values;
std::string f16_vector_values;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
f32_vector_values += ", ";
f16_vector_values += ", ";
}
f32_vector_values += f32_vec_type + "(";
f16_vector_values += f16_vec_type + "(";
for (uint32_t r = 0; r < rows; r++) {
if (r > 0) {
f32_vector_values += ", ";
f16_vector_values += ", ";
}
f32_vector_values += "f32(i)";
f16_vector_values += "f16(i)";
}
f32_vector_values += ")";
f16_vector_values += ")";
}
std::string f32_vectorized_args = "";
std::string f16_vectorized_args = "";
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
f32_vectorized_args += ", ";
f16_vectorized_args += ", ";
}
f32_vectorized_args += f32_vec_type + "(value[" + std::to_string(c) + "])";
f16_vectorized_args += f16_vec_type + "(value[" + std::to_string(c) + "])";
}
std::string tmpl = R"(
enable f16;
var<private> i : i32 = 0;
fn mat_f32() -> ${f32_mat_type} {
i = (i + 1);
return ${f32_mat_type}(${f32_values});
}
fn mat_f16() -> ${f16_mat_type} {
i = (i + 1);
return ${f16_mat_type}(${f16_values});
}
${helper_function}
@fragment
fn main() {
let m32 : ${f32_mat_type} = ${f32_matrix_conversion};
let m16 : ${f16_mat_type} = ${f16_matrix_conversion};
}
)";
tmpl = utils::ReplaceAll(tmpl, "${f32_values}", f32_vector_values);
tmpl = utils::ReplaceAll(tmpl, "${f16_values}", f16_vector_values);
auto src = utils::ReplaceAll(tmpl, "${f32_matrix_conversion}", "${f32_mat_type}(mat_f16())");
src = utils::ReplaceAll(src, "${f16_matrix_conversion}", "${f16_mat_type}(mat_f32())");
src = utils::ReplaceAll(src, "${helper_function}", "");
src = utils::ReplaceAll(src, "${f32_mat_type}", f32_mat_type);
src = utils::ReplaceAll(src, "${f16_mat_type}", f16_mat_type);
auto helper_function = std::string(R"(
fn convert_${mat_shape}_f16_f32(value : ${f16_mat_type}) -> ${f32_mat_type} {
return ${f32_mat_type}(${f32_vectorized_args});
}
fn convert_${mat_shape}_f32_f16(value : ${f32_mat_type}) -> ${f16_mat_type} {
return ${f16_mat_type}(${f16_vectorized_args});
}
)");
auto expect = utils::ReplaceAll(tmpl, "${helper_function}", helper_function);
expect = utils::ReplaceAll(expect, "${f32_mat_type}", f32_mat_type);
expect = utils::ReplaceAll(expect, "${f16_mat_type}", f16_mat_type);
expect = utils::ReplaceAll(expect, "${f32_matrix_conversion}",
"convert_${mat_shape}_f16_f32(mat_f16())");
expect = utils::ReplaceAll(expect, "${f16_matrix_conversion}",
"convert_${mat_shape}_f32_f16(mat_f32())");
expect = utils::ReplaceAll(expect, "${mat_shape}", mat_shape);
expect = utils::ReplaceAll(expect, "${f32_vectorized_args}", f32_vectorized_args);
expect = utils::ReplaceAll(expect, "${f16_vectorized_args}", f16_vectorized_args);
EXPECT_TRUE(ShouldRun<VectorizeMatrixConversions>(src));
auto got = Run<VectorizeMatrixConversions>(src);
EXPECT_EQ(expect, str(got));
}
// Test that VectorizeMatrixConversions transform will not run for matrix constructor.
TEST_P(VectorizeMatrixConversionsTest, NonConversion_ConstructorFromVectors) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string mat_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows) + "<f32>";
std::string vec_type = "vec" + std::to_string(rows) + "<f32>";
std::string columns;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
columns += ", ";
}
columns += vec_type + "()";
}
std::string tmpl = R"(
@fragment
fn main() {
let m = ${matrix}(${columns});
}
)";
tmpl = utils::ReplaceAll(tmpl, "${matrix}", mat_type);
auto src = utils::ReplaceAll(tmpl, "${columns}", columns);
auto expect = src;
EXPECT_FALSE(ShouldRun<VectorizeMatrixConversions>(src));
auto got = Run<VectorizeMatrixConversions>(src);
EXPECT_EQ(expect, str(got));
}
// Test that VectorizeMatrixConversions transform will not run for identity matrix constructor,
// which also take a single matrix as input.
TEST_P(VectorizeMatrixConversionsTest, NonConversion_IdentityConstructor) {
uint32_t cols = GetParam().first;
uint32_t rows = GetParam().second;
std::string mat_type = "mat" + std::to_string(cols) + "x" + std::to_string(rows) + "<f32>";
std::string vec_type = "vec" + std::to_string(rows) + "<f32>";
std::string columns;
for (uint32_t c = 0; c < cols; c++) {
if (c > 0) {
columns += ", ";
}
columns += vec_type + "()";
}
std::string tmpl = R"(
@fragment
fn main() {
let m = ${matrix}(${columns});
let n : ${matrix} = ${matrix}(m);
}
)";
tmpl = utils::ReplaceAll(tmpl, "${matrix}", mat_type);
auto src = utils::ReplaceAll(tmpl, "${columns}", columns);
auto expect = src;
EXPECT_FALSE(ShouldRun<VectorizeMatrixConversions>(src));
auto got = Run<VectorizeMatrixConversions>(src);
EXPECT_EQ(expect, str(got));
}
INSTANTIATE_TEST_SUITE_P(VectorizeMatrixConversionsTest,
VectorizeMatrixConversionsTest,
testing::Values(std::make_pair(2, 2),
std::make_pair(2, 3),
std::make_pair(2, 4),
std::make_pair(3, 2),
std::make_pair(3, 3),
std::make_pair(3, 4),
std::make_pair(4, 2),
std::make_pair(4, 3),
std::make_pair(4, 4)));
} // namespace
} // namespace tint::transform

View File

@ -1390,8 +1390,7 @@ uint32_t Builder::GenerateTypeConstructorOrConversion(const sem::Call* call,
auto* value_type = args[0]->Type()->UnwrapRef(); auto* value_type = args[0]->Type()->UnwrapRef();
if (auto* val_mat = value_type->As<sem::Matrix>()) { if (auto* val_mat = value_type->As<sem::Matrix>()) {
// Generate passthrough for matrices of the same type // Generate passthrough for matrices of the same type
can_cast_or_copy = can_cast_or_copy = res_mat == val_mat;
(res_mat->columns() == val_mat->columns()) && (res_mat->rows() == val_mat->rows());
} }
} }
@ -1578,13 +1577,19 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const sem::Type* to_type,
} else if ((from_type->is_float_scalar() && to_type->Is<sem::U32>()) || } else if ((from_type->is_float_scalar() && to_type->Is<sem::U32>()) ||
(from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) { (from_type->is_float_vector() && to_type->is_unsigned_integer_vector())) {
op = spv::Op::OpConvertFToU; op = spv::Op::OpConvertFToU;
} else if ((from_type->Is<sem::Bool>() && to_type->Is<sem::Bool>()) || } else if (from_type
(from_type->Is<sem::U32>() && to_type->Is<sem::U32>()) || ->IsAnyOf<sem::Bool, sem::F32, sem::I32, sem::U32, sem::F16, sem::Vector>() &&
(from_type->Is<sem::I32>() && to_type->Is<sem::I32>()) || from_type == to_type) {
(from_type->Is<sem::F32>() && to_type->Is<sem::F32>()) || // Identity constructor for scalar and vector types
(from_type->Is<sem::F16>() && to_type->Is<sem::F16>()) ||
(from_type->Is<sem::Vector>() && (from_type == to_type))) {
return val_id; return val_id;
} else if ((from_type->is_float_scalar() && to_type->is_float_scalar()) ||
(from_type->is_float_vector() && to_type->is_float_vector() &&
from_type->As<sem::Vector>()->Width() == to_type->As<sem::Vector>()->Width())) {
// Convert between f32 and f16 types.
// OpFConvert requires the scalar component types to be different, and the case of from_type
// and to_type being the same floating point scalar or vector type, i.e. identity
// constructor, is already handled in the previous else-if clause.
op = spv::Op::OpFConvert;
} else if ((from_type->Is<sem::I32>() && to_type->Is<sem::U32>()) || } else if ((from_type->Is<sem::I32>() && to_type->Is<sem::U32>()) ||
(from_type->Is<sem::U32>() && to_type->Is<sem::I32>()) || (from_type->Is<sem::U32>() && to_type->Is<sem::I32>()) ||
(from_type->is_signed_integer_vector() && to_type->is_unsigned_integer_vector()) || (from_type->is_signed_integer_vector() && to_type->is_unsigned_integer_vector()) ||
@ -1644,8 +1649,18 @@ uint32_t Builder::GenerateCastOrCopyOrPassthrough(const sem::Type* to_type,
} }
return result_id; return result_id;
} else if (from_type->Is<sem::Matrix>()) { } else if (from_type->Is<sem::Matrix>() && to_type->Is<sem::Matrix>()) {
return val_id; // SPIRV does not support matrix conversion, the only valid case is matrix identity
// constructor. Matrix conversion between f32 and f16 should be transformed into vector
// conversions for each column vectors by VectorizeMatrixConversions.
auto* from_mat = from_type->As<sem::Matrix>();
auto* to_mat = to_type->As<sem::Matrix>();
if (from_mat == to_mat) {
return val_id;
}
TINT_ICE(Writer, builder_.Diagnostics())
<< "matrix conversion is not supported and should have been handled by "
"VectorizeMatrixConversions";
} else { } else {
TINT_ICE(Writer, builder_.Diagnostics()) << "Invalid from_type"; TINT_ICE(Writer, builder_.Diagnostics()) << "Invalid from_type";
} }

View File

@ -3927,30 +3927,6 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_I32) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_U32) {
auto* var = Decl(Var("x", ty.i32(), Expr(2_i)));
auto* cast = Construct<u32>("x");
WrapInFunction(var, cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateStatement(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeInt 32 1
%2 = OpConstant %1 2
%4 = OpTypePointer Function %1
%5 = OpConstantNull %1
%7 = OpTypeInt 32 0
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %3 %2
%8 = OpLoad %1 %3
%6 = OpBitcast %7 %8
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_I32) {
auto* var = Decl(Var("x", ty.f32(), Expr(2.4_f))); auto* var = Decl(Var("x", ty.f32(), Expr(2.4_f)));
auto* cast = Construct<i32>("x"); auto* cast = Construct<i32>("x");
@ -4001,6 +3977,30 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_F16_To_I32) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_U32) {
auto* var = Decl(Var("x", ty.i32(), Expr(2_i)));
auto* cast = Construct<u32>("x");
WrapInFunction(var, cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateStatement(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeInt 32 1
%2 = OpConstant %1 2
%4 = OpTypePointer Function %1
%5 = OpConstantNull %1
%7 = OpTypeInt 32 0
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %3 %2
%8 = OpLoad %1 %3
%6 = OpBitcast %7 %8
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_U32) {
auto* var = Decl(Var("x", ty.f32(), Expr(2.4_f))); auto* var = Decl(Var("x", ty.f32(), Expr(2.4_f)));
auto* cast = Construct<u32>("x"); auto* cast = Construct<u32>("x");
@ -4075,6 +4075,56 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F32) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F32) {
auto* var = Decl(Var("x", ty.u32(), Expr(2_u)));
auto* cast = Construct<f32>("x");
WrapInFunction(var, cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateStatement(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeInt 32 0
%2 = OpConstant %1 2
%4 = OpTypePointer Function %1
%5 = OpConstantNull %1
%7 = OpTypeFloat 32
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %3 %2
%8 = OpLoad %1 %3
%6 = OpConvertUToF %7 %8
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_F16_To_F32) {
Enable(ast::Extension::kF16);
auto* var = Decl(Var("x", ty.f16(), Expr(2_h)));
auto* cast = Construct<f32>("x");
WrapInFunction(var, cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateStatement(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeFloat 16
%2 = OpConstant %1 0x1p+1
%4 = OpTypePointer Function %1
%5 = OpConstantNull %1
%7 = OpTypeFloat 32
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %3 %2
%8 = OpLoad %1 %3
%6 = OpFConvert %7 %8
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F16) { TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F16) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
@ -4101,30 +4151,6 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_I32_To_F16) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F32) {
auto* var = Decl(Var("x", ty.u32(), Expr(2_u)));
auto* cast = Construct<f32>("x");
WrapInFunction(var, cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateStatement(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeInt 32 0
%2 = OpConstant %1 2
%4 = OpTypePointer Function %1
%5 = OpConstantNull %1
%7 = OpTypeFloat 32
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %3 %2
%8 = OpLoad %1 %3
%6 = OpConvertUToF %7 %8
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F16) { TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F16) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
@ -4151,6 +4177,32 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F16) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_F32_To_F16) {
Enable(ast::Extension::kF16);
auto* var = Decl(Var("x", ty.f32(), Expr(2_f)));
auto* cast = Construct<f16>("x");
WrapInFunction(var, cast);
spirv::Builder& b = Build();
b.push_function(Function{});
EXPECT_TRUE(b.GenerateStatement(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeFloat 32
%2 = OpConstant %1 2
%4 = OpTypePointer Function %1
%5 = OpConstantNull %1
%7 = OpTypeFloat 16
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(OpStore %3 %2
%8 = OpLoad %1 %3
%6 = OpFConvert %7 %8
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) {
auto* var = GlobalVar("i", ty.vec3<u32>(), ast::StorageClass::kPrivate); auto* var = GlobalVar("i", ty.vec3<u32>(), ast::StorageClass::kPrivate);
@ -4337,6 +4389,60 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F32) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F32) {
auto* var = GlobalVar("i", ty.vec3<u32>(), ast::StorageClass::kPrivate);
auto* cast = vec3<f32>("i");
WrapInFunction(cast);
spirv::Builder& b = Build();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 0
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
%5 = OpConstantNull %3
%1 = OpVariable %2 Private %5
%8 = OpTypeFloat 32
%7 = OpTypeVector %8 3
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%9 = OpLoad %3 %1
%6 = OpConvertUToF %7 %9
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F16_to_F32) {
Enable(ast::Extension::kF16);
auto* var = GlobalVar("i", ty.vec3<f16>(), ast::StorageClass::kPrivate);
auto* cast = vec3<f32>("i");
WrapInFunction(cast);
spirv::Builder& b = Build();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 16
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
%5 = OpConstantNull %3
%1 = OpVariable %2 Private %5
%8 = OpTypeFloat 32
%7 = OpTypeVector %8 3
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%9 = OpLoad %3 %1
%6 = OpFConvert %7 %9
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F16) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F16) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
@ -4365,32 +4471,6 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F16) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F32) {
auto* var = GlobalVar("i", ty.vec3<u32>(), ast::StorageClass::kPrivate);
auto* cast = vec3<f32>("i");
WrapInFunction(cast);
spirv::Builder& b = Build();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeInt 32 0
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
%5 = OpConstantNull %3
%1 = OpVariable %2 Private %5
%8 = OpTypeFloat 32
%7 = OpTypeVector %8 3
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%9 = OpLoad %3 %1
%6 = OpConvertUToF %7 %9
)");
}
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F16) { TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F16) {
Enable(ast::Extension::kF16); Enable(ast::Extension::kF16);
@ -4419,6 +4499,34 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F16) {
)"); )");
} }
TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_F16) {
Enable(ast::Extension::kF16);
auto* var = GlobalVar("i", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* cast = vec3<f16>("i");
WrapInFunction(cast);
spirv::Builder& b = Build();
b.push_function(Function{});
ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error();
EXPECT_EQ(b.GenerateExpression(cast), 6u) << b.error();
EXPECT_EQ(DumpInstructions(b.types()), R"(%4 = OpTypeFloat 32
%3 = OpTypeVector %4 3
%2 = OpTypePointer Private %3
%5 = OpConstantNull %3
%1 = OpVariable %2 Private %5
%8 = OpTypeFloat 16
%7 = OpTypeVector %8 3
)");
EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()),
R"(%9 = OpLoad %3 %1
%6 = OpFConvert %7 %9
)");
}
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstConstructors) { TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVectorWithAllConstConstructors) {
// vec3<f32>(1.0, 2.0, 3.0) -> true // vec3<f32>(1.0, 2.0, 3.0) -> true
auto* t = vec3<f32>(1_f, 2_f, 3_f); auto* t = vec3<f32>(1_f, 2_f, 3_f);

View File

@ -32,6 +32,7 @@
#include "src/tint/transform/unshadow.h" #include "src/tint/transform/unshadow.h"
#include "src/tint/transform/unwind_discard_functions.h" #include "src/tint/transform/unwind_discard_functions.h"
#include "src/tint/transform/var_for_dynamic_index.h" #include "src/tint/transform/var_for_dynamic_index.h"
#include "src/tint/transform/vectorize_matrix_conversions.h"
#include "src/tint/transform/vectorize_scalar_matrix_constructors.h" #include "src/tint/transform/vectorize_scalar_matrix_constructors.h"
#include "src/tint/transform/while_to_loop.h" #include "src/tint/transform/while_to_loop.h"
#include "src/tint/transform/zero_init_workgroup_memory.h" #include "src/tint/transform/zero_init_workgroup_memory.h"
@ -78,6 +79,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options) {
manager.Add<transform::SimplifyPointers>(); // Required for arrayLength() manager.Add<transform::SimplifyPointers>(); // Required for arrayLength()
manager.Add<transform::RemovePhonies>(); manager.Add<transform::RemovePhonies>();
manager.Add<transform::VectorizeScalarMatrixConstructors>(); manager.Add<transform::VectorizeScalarMatrixConstructors>();
manager.Add<transform::VectorizeMatrixConversions>();
manager.Add<transform::ForLoopToLoop>(); // Must come after manager.Add<transform::ForLoopToLoop>(); // Must come after
manager.Add<transform::WhileToLoop>(); // ZeroInitWorkgroupMemory manager.Add<transform::WhileToLoop>(); // ZeroInitWorkgroupMemory
manager.Add<transform::CanonicalizeEntryPointIO>(); manager.Add<transform::CanonicalizeEntryPointIO>();

View File

@ -0,0 +1,10 @@
enable f16;
var<private> t : f16;
fn m() -> mat2x2<f16> {
t = t + 1.0h;
return mat2x2<f16>(1.0h, 2.0h,
3.0h, 4.0h);
}
fn f() {
var v : mat2x2<f32> = mat2x2<f32>(m());
}

View File

@ -0,0 +1,16 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float16_t t = float16_t(0.0h);
matrix<float16_t, 2, 2> m() {
t = (t + float16_t(1.0h));
return matrix<float16_t, 2, 2>(vector<float16_t, 2>(float16_t(1.0h), float16_t(2.0h)), vector<float16_t, 2>(float16_t(3.0h), float16_t(4.0h)));
}
void f() {
const matrix<float16_t, 2, 2> tint_symbol = m();
float2x2 v = float2x2(tint_symbol);
}

View File

@ -0,0 +1,21 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float16_t t = float16_t(0.0h);
matrix<float16_t, 2, 2> m() {
t = (t + float16_t(1.0h));
return matrix<float16_t, 2, 2>(vector<float16_t, 2>(float16_t(1.0h), float16_t(2.0h)), vector<float16_t, 2>(float16_t(3.0h), float16_t(4.0h)));
}
void f() {
const matrix<float16_t, 2, 2> tint_symbol = m();
float2x2 v = float2x2(tint_symbol);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x0000026A2F8678E0(6,8-16): error X3000: unrecognized identifier 'float16_t'

View File

@ -0,0 +1,18 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
float16_t t = 0.0hf;
f16mat2 m() {
t = (t + 1.0hf);
return f16mat2(f16vec2(1.0hf, 2.0hf), f16vec2(3.0hf, 4.0hf));
}
void f() {
f16mat2 tint_symbol = m();
mat2 v = mat2(tint_symbol);
}

View File

@ -0,0 +1,14 @@
#include <metal_stdlib>
using namespace metal;
half2x2 m() {
thread half tint_symbol_1 = 0.0h;
tint_symbol_1 = (tint_symbol_1 + 1.0h);
return half2x2(half2(1.0h, 2.0h), half2(3.0h, 4.0h));
}
void f() {
half2x2 const tint_symbol = m();
float2x2 v = float2x2(tint_symbol);
}

View File

@ -0,0 +1,65 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 40
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %t "t"
OpName %unused_entry_point "unused_entry_point"
OpName %m "m"
OpName %f "f"
OpName %v "v"
%half = OpTypeFloat 16
%_ptr_Private_half = OpTypePointer Private %half
%4 = OpConstantNull %half
%t = OpVariable %_ptr_Private_half Private %4
%void = OpTypeVoid
%5 = OpTypeFunction %void
%v2half = OpTypeVector %half 2
%mat2v2half = OpTypeMatrix %v2half 2
%9 = OpTypeFunction %mat2v2half
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%18 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%half_0x1p_2 = OpConstant %half 0x1p+2
%21 = OpConstantComposite %v2half %half_0x1_8p_1 %half_0x1p_2
%22 = OpConstantComposite %mat2v2half %18 %21
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%int = OpTypeInt 32 1
%31 = OpConstantNull %int
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float
%39 = OpConstantNull %mat2v2float
%unused_entry_point = OpFunction %void None %5
%8 = OpLabel
OpReturn
OpFunctionEnd
%m = OpFunction %mat2v2half None %9
%13 = OpLabel
%14 = OpLoad %half %t
%16 = OpFAdd %half %14 %half_0x1p_0
OpStore %t %16
OpReturnValue %22
OpFunctionEnd
%f = OpFunction %void None %5
%24 = OpLabel
%v = OpVariable %_ptr_Function_mat2v2float Function %39
%25 = OpFunctionCall %mat2v2half %m
%32 = OpCompositeExtract %v2half %25 0
%29 = OpFConvert %v2float %32
%35 = OpCompositeExtract %v2half %25 1
%33 = OpFConvert %v2float %35
%36 = OpCompositeConstruct %mat2v2float %29 %33
OpStore %v %36
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,12 @@
enable f16;
var<private> t : f16;
fn m() -> mat2x2<f16> {
t = (t + 1.0h);
return mat2x2<f16>(1.0h, 2.0h, 3.0h, 4.0h);
}
fn f() {
var v : mat2x2<f32> = mat2x2<f32>(m());
}

View File

@ -0,0 +1,10 @@
enable f16;
var<private> t : f32;
fn m() -> mat2x2<f32> {
t = t + 1.0f;
return mat2x2<f32>(1.0f, 2.0f,
3.0f, 4.0f);
}
fn f() {
var v : mat2x2<f16> = mat2x2<f16>(m());
}

View File

@ -0,0 +1,16 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float t = 0.0f;
float2x2 m() {
t = (t + 1.0f);
return float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
}
void f() {
const float2x2 tint_symbol = m();
matrix<float16_t, 2, 2> v = matrix<float16_t, 2, 2>(tint_symbol);
}

View File

@ -0,0 +1,21 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float t = 0.0f;
float2x2 m() {
t = (t + 1.0f);
return float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
}
void f() {
const float2x2 tint_symbol = m();
matrix<float16_t, 2, 2> v = matrix<float16_t, 2, 2>(tint_symbol);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x000002331C288CF0(15,10-18): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,18 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
float t = 0.0f;
mat2 m() {
t = (t + 1.0f);
return mat2(vec2(1.0f, 2.0f), vec2(3.0f, 4.0f));
}
void f() {
mat2 tint_symbol = m();
f16mat2 v = f16mat2(tint_symbol);
}

View File

@ -0,0 +1,14 @@
#include <metal_stdlib>
using namespace metal;
float2x2 m() {
thread float tint_symbol_1 = 0.0f;
tint_symbol_1 = (tint_symbol_1 + 1.0f);
return float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
}
void f() {
float2x2 const tint_symbol = m();
half2x2 v = half2x2(tint_symbol);
}

View File

@ -0,0 +1,65 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 40
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %t "t"
OpName %unused_entry_point "unused_entry_point"
OpName %m "m"
OpName %f "f"
OpName %v "v"
%float = OpTypeFloat 32
%_ptr_Private_float = OpTypePointer Private %float
%4 = OpConstantNull %float
%t = OpVariable %_ptr_Private_float Private %4
%void = OpTypeVoid
%5 = OpTypeFunction %void
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%9 = OpTypeFunction %mat2v2float
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%18 = OpConstantComposite %v2float %float_1 %float_2
%float_3 = OpConstant %float 3
%float_4 = OpConstant %float 4
%21 = OpConstantComposite %v2float %float_3 %float_4
%22 = OpConstantComposite %mat2v2float %18 %21
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%mat2v2half = OpTypeMatrix %v2half 2
%int = OpTypeInt 32 1
%31 = OpConstantNull %int
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v2half = OpTypePointer Function %mat2v2half
%39 = OpConstantNull %mat2v2half
%unused_entry_point = OpFunction %void None %5
%8 = OpLabel
OpReturn
OpFunctionEnd
%m = OpFunction %mat2v2float None %9
%13 = OpLabel
%14 = OpLoad %float %t
%16 = OpFAdd %float %14 %float_1
OpStore %t %16
OpReturnValue %22
OpFunctionEnd
%f = OpFunction %void None %5
%24 = OpLabel
%v = OpVariable %_ptr_Function_mat2v2half Function %39
%25 = OpFunctionCall %mat2v2float %m
%32 = OpCompositeExtract %v2float %25 0
%29 = OpFConvert %v2half %32
%35 = OpCompositeExtract %v2float %25 1
%33 = OpFConvert %v2half %35
%36 = OpCompositeConstruct %mat2v2half %29 %33
OpStore %v %36
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,12 @@
enable f16;
var<private> t : f32;
fn m() -> mat2x2<f32> {
t = (t + 1.0f);
return mat2x2<f32>(1.0f, 2.0f, 3.0f, 4.0f);
}
fn f() {
var v : mat2x2<f16> = mat2x2<f16>(m());
}

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x2<f32> = mat2x2<f32>(mat2x2<f16>(1.0h, 2.0h,
3.0h, 4.0h));

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x2 u = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x2 u = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));

View File

@ -0,0 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
mat2 u = mat2(vec2(1.0f, 2.0f), vec2(3.0f, 4.0f));

View File

@ -0,0 +1,3 @@
#include <metal_stdlib>
using namespace metal;

View File

@ -0,0 +1,33 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 17
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%6 = OpConstantComposite %v2float %float_1 %float_2
%float_3 = OpConstant %float 3
%float_4 = OpConstant %float 4
%9 = OpConstantComposite %v2float %float_3 %float_4
%10 = OpConstantComposite %mat2v2float %6 %9
%_ptr_Private_mat2v2float = OpTypePointer Private %mat2v2float
%u = OpVariable %_ptr_Private_mat2v2float Private %10
%void = OpTypeVoid
%13 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %13
%16 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x2<f32> = mat2x2<f32>(mat2x2<f16>(1.0h, 2.0h, 3.0h, 4.0h));

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x2<f16> = mat2x2<f16>(mat2x2<f32>(1.0f, 2.0f,
3.0f, 4.0f));

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 2> u = matrix<float16_t, 2, 2>(vector<float16_t, 2>(float16_t(1.0h), float16_t(2.0h)), vector<float16_t, 2>(float16_t(3.0h), float16_t(4.0h)));

View File

@ -0,0 +1,11 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 2> u = matrix<float16_t, 2, 2>(vector<float16_t, 2>(float16_t(1.0h), float16_t(2.0h)), vector<float16_t, 2>(float16_t(3.0h), float16_t(4.0h)));
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x0000017A260403B0(6,15-23): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
f16mat2 u = f16mat2(f16vec2(1.0hf, 2.0hf), f16vec2(3.0hf, 4.0hf));

View File

@ -0,0 +1,3 @@
#include <metal_stdlib>
using namespace metal;

View File

@ -0,0 +1,33 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 17
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%mat2v2half = OpTypeMatrix %v2half 2
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%6 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%half_0x1p_2 = OpConstant %half 0x1p+2
%9 = OpConstantComposite %v2half %half_0x1_8p_1 %half_0x1p_2
%10 = OpConstantComposite %mat2v2half %6 %9
%_ptr_Private_mat2v2half = OpTypePointer Private %mat2v2half
%u = OpVariable %_ptr_Private_mat2v2half Private %10
%void = OpTypeVoid
%13 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %13
%16 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x2<f16> = mat2x2<f16>(mat2x2<f32>(1.0f, 2.0f, 3.0f, 4.0f));

View File

@ -0,0 +1,6 @@
enable f16;
var<private> u = mat2x2<f16>(1.0h, 2.0h,
3.0h, 4.0h);
fn f() {
var v : mat2x2<f32> = mat2x2<f32>(u);
}

View File

@ -0,0 +1,10 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 2> u = matrix<float16_t, 2, 2>(vector<float16_t, 2>(float16_t(1.0h), float16_t(2.0h)), vector<float16_t, 2>(float16_t(3.0h), float16_t(4.0h)));
void f() {
float2x2 v = float2x2(u);
}

View File

@ -0,0 +1,15 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 2> u = matrix<float16_t, 2, 2>(vector<float16_t, 2>(float16_t(1.0h), float16_t(2.0h)), vector<float16_t, 2>(float16_t(3.0h), float16_t(4.0h)));
void f() {
float2x2 v = float2x2(u);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x0000023103DB6760(6,15-23): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,12 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
f16mat2 u = f16mat2(f16vec2(1.0hf, 2.0hf), f16vec2(3.0hf, 4.0hf));
void f() {
mat2 v = mat2(u);
}

View File

@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
void f() {
thread half2x2 tint_symbol = half2x2(half2(1.0h, 2.0h), half2(3.0h, 4.0h));
float2x2 v = float2x2(tint_symbol);
}

View File

@ -0,0 +1,57 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 36
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %v "v"
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%mat2v2half = OpTypeMatrix %v2half 2
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%6 = OpConstantComposite %v2half %half_0x1p_0 %half_0x1p_1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%half_0x1p_2 = OpConstant %half 0x1p+2
%9 = OpConstantComposite %v2half %half_0x1_8p_1 %half_0x1p_2
%10 = OpConstantComposite %mat2v2half %6 %9
%_ptr_Private_mat2v2half = OpTypePointer Private %mat2v2half
%u = OpVariable %_ptr_Private_mat2v2half Private %10
%void = OpTypeVoid
%13 = OpTypeFunction %void
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%int = OpTypeInt 32 1
%24 = OpConstantNull %int
%_ptr_Private_v2half = OpTypePointer Private %v2half
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v2float = OpTypePointer Function %mat2v2float
%35 = OpConstantNull %mat2v2float
%unused_entry_point = OpFunction %void None %13
%16 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %13
%18 = OpLabel
%v = OpVariable %_ptr_Function_mat2v2float Function %35
%26 = OpAccessChain %_ptr_Private_v2half %u %24
%27 = OpLoad %v2half %26
%22 = OpFConvert %v2float %27
%30 = OpAccessChain %_ptr_Private_v2half %u %int_1
%31 = OpLoad %v2half %30
%28 = OpFConvert %v2float %31
%32 = OpCompositeConstruct %mat2v2float %22 %28
OpStore %v %32
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,7 @@
enable f16;
var<private> u = mat2x2<f16>(1.0h, 2.0h, 3.0h, 4.0h);
fn f() {
var v : mat2x2<f32> = mat2x2<f32>(u);
}

View File

@ -0,0 +1,6 @@
enable f16;
var<private> u = mat2x2<f32>(1.0f, 2.0f,
3.0f, 4.0f);
fn f() {
var v : mat2x2<f16> = mat2x2<f16>(u);
}

View File

@ -0,0 +1,10 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x2 u = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
void f() {
matrix<float16_t, 2, 2> v = matrix<float16_t, 2, 2>(u);
}

View File

@ -0,0 +1,15 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x2 u = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
void f() {
matrix<float16_t, 2, 2> v = matrix<float16_t, 2, 2>(u);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x0000022E5A1842F0(9,10-18): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,12 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
mat2 u = mat2(vec2(1.0f, 2.0f), vec2(3.0f, 4.0f));
void f() {
f16mat2 v = f16mat2(u);
}

View File

@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
void f() {
thread float2x2 tint_symbol = float2x2(float2(1.0f, 2.0f), float2(3.0f, 4.0f));
half2x2 v = half2x2(tint_symbol);
}

View File

@ -0,0 +1,57 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 36
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %v "v"
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%mat2v2float = OpTypeMatrix %v2float 2
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%6 = OpConstantComposite %v2float %float_1 %float_2
%float_3 = OpConstant %float 3
%float_4 = OpConstant %float 4
%9 = OpConstantComposite %v2float %float_3 %float_4
%10 = OpConstantComposite %mat2v2float %6 %9
%_ptr_Private_mat2v2float = OpTypePointer Private %mat2v2float
%u = OpVariable %_ptr_Private_mat2v2float Private %10
%void = OpTypeVoid
%13 = OpTypeFunction %void
%half = OpTypeFloat 16
%v2half = OpTypeVector %half 2
%mat2v2half = OpTypeMatrix %v2half 2
%int = OpTypeInt 32 1
%24 = OpConstantNull %int
%_ptr_Private_v2float = OpTypePointer Private %v2float
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v2half = OpTypePointer Function %mat2v2half
%35 = OpConstantNull %mat2v2half
%unused_entry_point = OpFunction %void None %13
%16 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %13
%18 = OpLabel
%v = OpVariable %_ptr_Function_mat2v2half Function %35
%26 = OpAccessChain %_ptr_Private_v2float %u %24
%27 = OpLoad %v2float %26
%22 = OpFConvert %v2half %27
%30 = OpAccessChain %_ptr_Private_v2float %u %int_1
%31 = OpLoad %v2float %30
%28 = OpFConvert %v2half %31
%32 = OpCompositeConstruct %mat2v2half %22 %28
OpStore %v %32
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,7 @@
enable f16;
var<private> u = mat2x2<f32>(1.0f, 2.0f, 3.0f, 4.0f);
fn f() {
var v : mat2x2<f16> = mat2x2<f16>(u);
}

View File

@ -0,0 +1,10 @@
enable f16;
var<private> t : f16;
fn m() -> mat2x3<f16> {
t = t + 1.0h;
return mat2x3<f16>(1.0h, 2.0h, 3.0h,
4.0h, 5.0h, 6.0h);
}
fn f() {
var v : mat2x3<f32> = mat2x3<f32>(m());
}

View File

@ -0,0 +1,16 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float16_t t = float16_t(0.0h);
matrix<float16_t, 2, 3> m() {
t = (t + float16_t(1.0h));
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
}
void f() {
const matrix<float16_t, 2, 3> tint_symbol = m();
float2x3 v = float2x3(tint_symbol);
}

View File

@ -0,0 +1,21 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float16_t t = float16_t(0.0h);
matrix<float16_t, 2, 3> m() {
t = (t + float16_t(1.0h));
return matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
}
void f() {
const matrix<float16_t, 2, 3> tint_symbol = m();
float2x3 v = float2x3(tint_symbol);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x00000175F40071F0(6,8-16): error X3000: unrecognized identifier 'float16_t'

View File

@ -0,0 +1,18 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
float16_t t = 0.0hf;
f16mat2x3 m() {
t = (t + 1.0hf);
return f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(4.0hf, 5.0hf, 6.0hf));
}
void f() {
f16mat2x3 tint_symbol = m();
mat2x3 v = mat2x3(tint_symbol);
}

View File

@ -0,0 +1,14 @@
#include <metal_stdlib>
using namespace metal;
half2x3 m() {
thread half tint_symbol_1 = 0.0h;
tint_symbol_1 = (tint_symbol_1 + 1.0h);
return half2x3(half3(1.0h, 2.0h, 3.0h), half3(4.0h, 5.0h, 6.0h));
}
void f() {
half2x3 const tint_symbol = m();
float2x3 v = float2x3(tint_symbol);
}

View File

@ -0,0 +1,67 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 42
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %t "t"
OpName %unused_entry_point "unused_entry_point"
OpName %m "m"
OpName %f "f"
OpName %v "v"
%half = OpTypeFloat 16
%_ptr_Private_half = OpTypePointer Private %half
%4 = OpConstantNull %half
%t = OpVariable %_ptr_Private_half Private %4
%void = OpTypeVoid
%5 = OpTypeFunction %void
%v3half = OpTypeVector %half 3
%mat2v3half = OpTypeMatrix %v3half 2
%9 = OpTypeFunction %mat2v3half
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%19 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_1 %half_0x1_8p_1
%half_0x1p_2 = OpConstant %half 0x1p+2
%half_0x1_4p_2 = OpConstant %half 0x1.4p+2
%half_0x1_8p_2 = OpConstant %half 0x1.8p+2
%23 = OpConstantComposite %v3half %half_0x1p_2 %half_0x1_4p_2 %half_0x1_8p_2
%24 = OpConstantComposite %mat2v3half %19 %23
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%int = OpTypeInt 32 1
%33 = OpConstantNull %int
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float
%41 = OpConstantNull %mat2v3float
%unused_entry_point = OpFunction %void None %5
%8 = OpLabel
OpReturn
OpFunctionEnd
%m = OpFunction %mat2v3half None %9
%13 = OpLabel
%14 = OpLoad %half %t
%16 = OpFAdd %half %14 %half_0x1p_0
OpStore %t %16
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %5
%26 = OpLabel
%v = OpVariable %_ptr_Function_mat2v3float Function %41
%27 = OpFunctionCall %mat2v3half %m
%34 = OpCompositeExtract %v3half %27 0
%31 = OpFConvert %v3float %34
%37 = OpCompositeExtract %v3half %27 1
%35 = OpFConvert %v3float %37
%38 = OpCompositeConstruct %mat2v3float %31 %35
OpStore %v %38
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,12 @@
enable f16;
var<private> t : f16;
fn m() -> mat2x3<f16> {
t = (t + 1.0h);
return mat2x3<f16>(1.0h, 2.0h, 3.0h, 4.0h, 5.0h, 6.0h);
}
fn f() {
var v : mat2x3<f32> = mat2x3<f32>(m());
}

View File

@ -0,0 +1,10 @@
enable f16;
var<private> t : f32;
fn m() -> mat2x3<f32> {
t = t + 1.0f;
return mat2x3<f32>(1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f);
}
fn f() {
var v : mat2x3<f16> = mat2x3<f16>(m());
}

View File

@ -0,0 +1,16 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float t = 0.0f;
float2x3 m() {
t = (t + 1.0f);
return float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
}
void f() {
const float2x3 tint_symbol = m();
matrix<float16_t, 2, 3> v = matrix<float16_t, 2, 3>(tint_symbol);
}

View File

@ -0,0 +1,21 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float t = 0.0f;
float2x3 m() {
t = (t + 1.0f);
return float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
}
void f() {
const float2x3 tint_symbol = m();
matrix<float16_t, 2, 3> v = matrix<float16_t, 2, 3>(tint_symbol);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x0000029F80D27980(15,10-18): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,18 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
float t = 0.0f;
mat2x3 m() {
t = (t + 1.0f);
return mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f));
}
void f() {
mat2x3 tint_symbol = m();
f16mat2x3 v = f16mat2x3(tint_symbol);
}

View File

@ -0,0 +1,14 @@
#include <metal_stdlib>
using namespace metal;
float2x3 m() {
thread float tint_symbol_1 = 0.0f;
tint_symbol_1 = (tint_symbol_1 + 1.0f);
return float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
}
void f() {
float2x3 const tint_symbol = m();
half2x3 v = half2x3(tint_symbol);
}

View File

@ -0,0 +1,67 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 42
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %t "t"
OpName %unused_entry_point "unused_entry_point"
OpName %m "m"
OpName %f "f"
OpName %v "v"
%float = OpTypeFloat 32
%_ptr_Private_float = OpTypePointer Private %float
%4 = OpConstantNull %float
%t = OpVariable %_ptr_Private_float Private %4
%void = OpTypeVoid
%5 = OpTypeFunction %void
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%9 = OpTypeFunction %mat2v3float
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%19 = OpConstantComposite %v3float %float_1 %float_2 %float_3
%float_4 = OpConstant %float 4
%float_5 = OpConstant %float 5
%float_6 = OpConstant %float 6
%23 = OpConstantComposite %v3float %float_4 %float_5 %float_6
%24 = OpConstantComposite %mat2v3float %19 %23
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2v3half = OpTypeMatrix %v3half 2
%int = OpTypeInt 32 1
%33 = OpConstantNull %int
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%41 = OpConstantNull %mat2v3half
%unused_entry_point = OpFunction %void None %5
%8 = OpLabel
OpReturn
OpFunctionEnd
%m = OpFunction %mat2v3float None %9
%13 = OpLabel
%14 = OpLoad %float %t
%16 = OpFAdd %float %14 %float_1
OpStore %t %16
OpReturnValue %24
OpFunctionEnd
%f = OpFunction %void None %5
%26 = OpLabel
%v = OpVariable %_ptr_Function_mat2v3half Function %41
%27 = OpFunctionCall %mat2v3float %m
%34 = OpCompositeExtract %v3float %27 0
%31 = OpFConvert %v3half %34
%37 = OpCompositeExtract %v3float %27 1
%35 = OpFConvert %v3half %37
%38 = OpCompositeConstruct %mat2v3half %31 %35
OpStore %v %38
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,12 @@
enable f16;
var<private> t : f32;
fn m() -> mat2x3<f32> {
t = (t + 1.0f);
return mat2x3<f32>(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);
}
fn f() {
var v : mat2x3<f16> = mat2x3<f16>(m());
}

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x3<f32> = mat2x3<f32>(mat2x3<f16>(1.0h, 2.0h, 3.0h,
4.0h, 5.0h, 6.0h));

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x3 u = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x3 u = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));

View File

@ -0,0 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
mat2x3 u = mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f));

View File

@ -0,0 +1,3 @@
#include <metal_stdlib>
using namespace metal;

View File

@ -0,0 +1,35 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 19
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%7 = OpConstantComposite %v3float %float_1 %float_2 %float_3
%float_4 = OpConstant %float 4
%float_5 = OpConstant %float 5
%float_6 = OpConstant %float 6
%11 = OpConstantComposite %v3float %float_4 %float_5 %float_6
%12 = OpConstantComposite %mat2v3float %7 %11
%_ptr_Private_mat2v3float = OpTypePointer Private %mat2v3float
%u = OpVariable %_ptr_Private_mat2v3float Private %12
%void = OpTypeVoid
%15 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %15
%18 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x3<f32> = mat2x3<f32>(mat2x3<f16>(1.0h, 2.0h, 3.0h, 4.0h, 5.0h, 6.0h));

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x3<f16> = mat2x3<f16>(mat2x3<f32>(1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f));

View File

@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 3> u = matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));

View File

@ -0,0 +1,11 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 3> u = matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x000001558B1D0610(6,15-23): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,8 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
f16mat2x3 u = f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(4.0hf, 5.0hf, 6.0hf));

View File

@ -0,0 +1,3 @@
#include <metal_stdlib>
using namespace metal;

View File

@ -0,0 +1,35 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 19
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2v3half = OpTypeMatrix %v3half 2
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%7 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_1 %half_0x1_8p_1
%half_0x1p_2 = OpConstant %half 0x1p+2
%half_0x1_4p_2 = OpConstant %half 0x1.4p+2
%half_0x1_8p_2 = OpConstant %half 0x1.8p+2
%11 = OpConstantComposite %v3half %half_0x1p_2 %half_0x1_4p_2 %half_0x1_8p_2
%12 = OpConstantComposite %mat2v3half %7 %11
%_ptr_Private_mat2v3half = OpTypePointer Private %mat2v3half
%u = OpVariable %_ptr_Private_mat2v3half Private %12
%void = OpTypeVoid
%15 = OpTypeFunction %void
%unused_entry_point = OpFunction %void None %15
%18 = OpLabel
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,3 @@
enable f16;
var<private> u : mat2x3<f16> = mat2x3<f16>(mat2x3<f32>(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f));

View File

@ -0,0 +1,6 @@
enable f16;
var<private> u = mat2x3<f16>(1.0h, 2.0h, 3.0h,
4.0h, 5.0h, 6.0h);
fn f() {
var v : mat2x3<f32> = mat2x3<f32>(u);
}

View File

@ -0,0 +1,10 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 3> u = matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
void f() {
float2x3 v = float2x3(u);
}

View File

@ -0,0 +1,15 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static matrix<float16_t, 2, 3> u = matrix<float16_t, 2, 3>(vector<float16_t, 3>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h)), vector<float16_t, 3>(float16_t(4.0h), float16_t(5.0h), float16_t(6.0h)));
void f() {
float2x3 v = float2x3(u);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x0000022FCB692870(6,15-23): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,12 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
f16mat2x3 u = f16mat2x3(f16vec3(1.0hf, 2.0hf, 3.0hf), f16vec3(4.0hf, 5.0hf, 6.0hf));
void f() {
mat2x3 v = mat2x3(u);
}

View File

@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
void f() {
thread half2x3 tint_symbol = half2x3(half3(1.0h, 2.0h, 3.0h), half3(4.0h, 5.0h, 6.0h));
float2x3 v = float2x3(tint_symbol);
}

View File

@ -0,0 +1,59 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 38
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %v "v"
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2v3half = OpTypeMatrix %v3half 2
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%7 = OpConstantComposite %v3half %half_0x1p_0 %half_0x1p_1 %half_0x1_8p_1
%half_0x1p_2 = OpConstant %half 0x1p+2
%half_0x1_4p_2 = OpConstant %half 0x1.4p+2
%half_0x1_8p_2 = OpConstant %half 0x1.8p+2
%11 = OpConstantComposite %v3half %half_0x1p_2 %half_0x1_4p_2 %half_0x1_8p_2
%12 = OpConstantComposite %mat2v3half %7 %11
%_ptr_Private_mat2v3half = OpTypePointer Private %mat2v3half
%u = OpVariable %_ptr_Private_mat2v3half Private %12
%void = OpTypeVoid
%15 = OpTypeFunction %void
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%int = OpTypeInt 32 1
%26 = OpConstantNull %int
%_ptr_Private_v3half = OpTypePointer Private %v3half
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float
%37 = OpConstantNull %mat2v3float
%unused_entry_point = OpFunction %void None %15
%18 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %15
%20 = OpLabel
%v = OpVariable %_ptr_Function_mat2v3float Function %37
%28 = OpAccessChain %_ptr_Private_v3half %u %26
%29 = OpLoad %v3half %28
%24 = OpFConvert %v3float %29
%32 = OpAccessChain %_ptr_Private_v3half %u %int_1
%33 = OpLoad %v3half %32
%30 = OpFConvert %v3float %33
%34 = OpCompositeConstruct %mat2v3float %24 %30
OpStore %v %34
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,7 @@
enable f16;
var<private> u = mat2x3<f16>(1.0h, 2.0h, 3.0h, 4.0h, 5.0h, 6.0h);
fn f() {
var v : mat2x3<f32> = mat2x3<f32>(u);
}

View File

@ -0,0 +1,6 @@
enable f16;
var<private> u = mat2x3<f32>(1.0f, 2.0f, 3.0f,
4.0f, 5.0f, 6.0f);
fn f() {
var v : mat2x3<f16> = mat2x3<f16>(u);
}

View File

@ -0,0 +1,10 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x3 u = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
void f() {
matrix<float16_t, 2, 3> v = matrix<float16_t, 2, 3>(u);
}

View File

@ -0,0 +1,15 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float2x3 u = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
void f() {
matrix<float16_t, 2, 3> v = matrix<float16_t, 2, 3>(u);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x00000220E99769D0(9,10-18): error X3000: syntax error: unexpected token 'float16_t'

View File

@ -0,0 +1,12 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
mat2x3 u = mat2x3(vec3(1.0f, 2.0f, 3.0f), vec3(4.0f, 5.0f, 6.0f));
void f() {
f16mat2x3 v = f16mat2x3(u);
}

View File

@ -0,0 +1,8 @@
#include <metal_stdlib>
using namespace metal;
void f() {
thread float2x3 tint_symbol = float2x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
half2x3 v = half2x3(tint_symbol);
}

View File

@ -0,0 +1,59 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 38
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %u "u"
OpName %unused_entry_point "unused_entry_point"
OpName %f "f"
OpName %v "v"
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%float_1 = OpConstant %float 1
%float_2 = OpConstant %float 2
%float_3 = OpConstant %float 3
%7 = OpConstantComposite %v3float %float_1 %float_2 %float_3
%float_4 = OpConstant %float 4
%float_5 = OpConstant %float 5
%float_6 = OpConstant %float 6
%11 = OpConstantComposite %v3float %float_4 %float_5 %float_6
%12 = OpConstantComposite %mat2v3float %7 %11
%_ptr_Private_mat2v3float = OpTypePointer Private %mat2v3float
%u = OpVariable %_ptr_Private_mat2v3float Private %12
%void = OpTypeVoid
%15 = OpTypeFunction %void
%half = OpTypeFloat 16
%v3half = OpTypeVector %half 3
%mat2v3half = OpTypeMatrix %v3half 2
%int = OpTypeInt 32 1
%26 = OpConstantNull %int
%_ptr_Private_v3float = OpTypePointer Private %v3float
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v3half = OpTypePointer Function %mat2v3half
%37 = OpConstantNull %mat2v3half
%unused_entry_point = OpFunction %void None %15
%18 = OpLabel
OpReturn
OpFunctionEnd
%f = OpFunction %void None %15
%20 = OpLabel
%v = OpVariable %_ptr_Function_mat2v3half Function %37
%28 = OpAccessChain %_ptr_Private_v3float %u %26
%29 = OpLoad %v3float %28
%24 = OpFConvert %v3half %29
%32 = OpAccessChain %_ptr_Private_v3float %u %int_1
%33 = OpLoad %v3float %32
%30 = OpFConvert %v3half %33
%34 = OpCompositeConstruct %mat2v3half %24 %30
OpStore %v %34
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,7 @@
enable f16;
var<private> u = mat2x3<f32>(1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f);
fn f() {
var v : mat2x3<f16> = mat2x3<f16>(u);
}

View File

@ -0,0 +1,10 @@
enable f16;
var<private> t : f16;
fn m() -> mat2x4<f16> {
t = t + 1.0h;
return mat2x4<f16>(1.0h, 2.0h, 3.0h, 4.0h,
5.0h, 6.0h, 7.0h, 8.0h);
}
fn f() {
var v : mat2x4<f32> = mat2x4<f32>(m());
}

View File

@ -0,0 +1,16 @@
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float16_t t = float16_t(0.0h);
matrix<float16_t, 2, 4> m() {
t = (t + float16_t(1.0h));
return matrix<float16_t, 2, 4>(vector<float16_t, 4>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h), float16_t(4.0h)), vector<float16_t, 4>(float16_t(5.0h), float16_t(6.0h), float16_t(7.0h), float16_t(8.0h)));
}
void f() {
const matrix<float16_t, 2, 4> tint_symbol = m();
float2x4 v = float2x4(tint_symbol);
}

View File

@ -0,0 +1,21 @@
SKIP: FAILED
[numthreads(1, 1, 1)]
void unused_entry_point() {
return;
}
static float16_t t = float16_t(0.0h);
matrix<float16_t, 2, 4> m() {
t = (t + float16_t(1.0h));
return matrix<float16_t, 2, 4>(vector<float16_t, 4>(float16_t(1.0h), float16_t(2.0h), float16_t(3.0h), float16_t(4.0h)), vector<float16_t, 4>(float16_t(5.0h), float16_t(6.0h), float16_t(7.0h), float16_t(8.0h)));
}
void f() {
const matrix<float16_t, 2, 4> tint_symbol = m();
float2x4 v = float2x4(tint_symbol);
}
FXC validation failure:
D:\Projects\RampUp\dawn\test\tint\expressions\type_conv\Shader@0x00000197CB8872F0(6,8-16): error X3000: unrecognized identifier 'float16_t'

View File

@ -0,0 +1,18 @@
#version 310 es
#extension GL_AMD_gpu_shader_half_float : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void unused_entry_point() {
return;
}
float16_t t = 0.0hf;
f16mat2x4 m() {
t = (t + 1.0hf);
return f16mat2x4(f16vec4(1.0hf, 2.0hf, 3.0hf, 4.0hf), f16vec4(5.0hf, 6.0hf, 7.0hf, 8.0hf));
}
void f() {
f16mat2x4 tint_symbol = m();
mat2x4 v = mat2x4(tint_symbol);
}

View File

@ -0,0 +1,14 @@
#include <metal_stdlib>
using namespace metal;
half2x4 m() {
thread half tint_symbol_1 = 0.0h;
tint_symbol_1 = (tint_symbol_1 + 1.0h);
return half2x4(half4(1.0h, 2.0h, 3.0h, 4.0h), half4(5.0h, 6.0h, 7.0h, 8.0h));
}
void f() {
half2x4 const tint_symbol = m();
float2x4 v = float2x4(tint_symbol);
}

View File

@ -0,0 +1,69 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 44
; Schema: 0
OpCapability Shader
OpCapability Float16
OpCapability UniformAndStorageBuffer16BitAccess
OpCapability StorageBuffer16BitAccess
OpCapability StorageInputOutput16
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
OpExecutionMode %unused_entry_point LocalSize 1 1 1
OpName %t "t"
OpName %unused_entry_point "unused_entry_point"
OpName %m "m"
OpName %f "f"
OpName %v "v"
%half = OpTypeFloat 16
%_ptr_Private_half = OpTypePointer Private %half
%4 = OpConstantNull %half
%t = OpVariable %_ptr_Private_half Private %4
%void = OpTypeVoid
%5 = OpTypeFunction %void
%v4half = OpTypeVector %half 4
%mat2v4half = OpTypeMatrix %v4half 2
%9 = OpTypeFunction %mat2v4half
%half_0x1p_0 = OpConstant %half 0x1p+0
%half_0x1p_1 = OpConstant %half 0x1p+1
%half_0x1_8p_1 = OpConstant %half 0x1.8p+1
%half_0x1p_2 = OpConstant %half 0x1p+2
%20 = OpConstantComposite %v4half %half_0x1p_0 %half_0x1p_1 %half_0x1_8p_1 %half_0x1p_2
%half_0x1_4p_2 = OpConstant %half 0x1.4p+2
%half_0x1_8p_2 = OpConstant %half 0x1.8p+2
%half_0x1_cp_2 = OpConstant %half 0x1.cp+2
%half_0x1p_3 = OpConstant %half 0x1p+3
%25 = OpConstantComposite %v4half %half_0x1_4p_2 %half_0x1_8p_2 %half_0x1_cp_2 %half_0x1p_3
%26 = OpConstantComposite %mat2v4half %20 %25
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%mat2v4float = OpTypeMatrix %v4float 2
%int = OpTypeInt 32 1
%35 = OpConstantNull %int
%int_1 = OpConstant %int 1
%_ptr_Function_mat2v4float = OpTypePointer Function %mat2v4float
%43 = OpConstantNull %mat2v4float
%unused_entry_point = OpFunction %void None %5
%8 = OpLabel
OpReturn
OpFunctionEnd
%m = OpFunction %mat2v4half None %9
%13 = OpLabel
%14 = OpLoad %half %t
%16 = OpFAdd %half %14 %half_0x1p_0
OpStore %t %16
OpReturnValue %26
OpFunctionEnd
%f = OpFunction %void None %5
%28 = OpLabel
%v = OpVariable %_ptr_Function_mat2v4float Function %43
%29 = OpFunctionCall %mat2v4half %m
%36 = OpCompositeExtract %v4half %29 0
%33 = OpFConvert %v4float %36
%39 = OpCompositeExtract %v4half %29 1
%37 = OpFConvert %v4float %39
%40 = OpCompositeConstruct %mat2v4float %33 %37
OpStore %v %40
OpReturn
OpFunctionEnd

View File

@ -0,0 +1,12 @@
enable f16;
var<private> t : f16;
fn m() -> mat2x4<f16> {
t = (t + 1.0h);
return mat2x4<f16>(1.0h, 2.0h, 3.0h, 4.0h, 5.0h, 6.0h, 7.0h, 8.0h);
}
fn f() {
var v : mat2x4<f32> = mat2x4<f32>(m());
}

View File

@ -0,0 +1,10 @@
enable f16;
var<private> t : f32;
fn m() -> mat2x4<f32> {
t = t + 1.0f;
return mat2x4<f32>(1.0f, 2.0f, 3.0f, 4.0f,
5.0f, 6.0f, 7.0f, 8.0f);
}
fn f() {
var v : mat2x4<f16> = mat2x4<f16>(m());
}

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