tint: const eval of bitcast operator
Bug: tint:1581 Change-Id: Ida43b34118282eeb99ae099c91a6465eb3040ca6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/115080 Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
ffa83ad1f7
commit
056618541f
|
@ -1186,6 +1186,7 @@ if (tint_build_unittests) {
|
|||
"resolver/compound_assignment_validation_test.cc",
|
||||
"resolver/compound_statement_test.cc",
|
||||
"resolver/const_eval_binary_op_test.cc",
|
||||
"resolver/const_eval_bitcast_test.cc",
|
||||
"resolver/const_eval_builtin_test.cc",
|
||||
"resolver/const_eval_construction_test.cc",
|
||||
"resolver/const_eval_conversion_test.cc",
|
||||
|
|
|
@ -894,6 +894,7 @@ if(TINT_BUILD_TESTS)
|
|||
resolver/compound_assignment_validation_test.cc
|
||||
resolver/compound_statement_test.cc
|
||||
resolver/const_eval_binary_op_test.cc
|
||||
resolver/const_eval_bitcast_test.cc
|
||||
resolver/const_eval_builtin_test.cc
|
||||
resolver/const_eval_construction_test.cc
|
||||
resolver/const_eval_conversion_test.cc
|
||||
|
|
|
@ -68,6 +68,17 @@ auto Dispatch_iu32(F&& f, CONSTANTS&&... cs) {
|
|||
[&](const type::U32*) { return f(cs->template ValueAs<u32>()...); });
|
||||
}
|
||||
|
||||
/// Helper that calls `f` passing in the value of all `cs`.
|
||||
/// Calls `f` with all constants cast to the type of the first `cs` argument.
|
||||
template <typename F, typename... CONSTANTS>
|
||||
auto Dispatch_fiu32(F&& f, CONSTANTS&&... cs) {
|
||||
return Switch(
|
||||
First(cs...)->Type(), //
|
||||
[&](const type::F32*) { return f(cs->template ValueAs<f32>()...); },
|
||||
[&](const type::I32*) { return f(cs->template ValueAs<i32>()...); },
|
||||
[&](const type::U32*) { return f(cs->template ValueAs<u32>()...); });
|
||||
}
|
||||
|
||||
/// Helper that calls `f` passing in the value of all `cs`.
|
||||
/// Calls `f` with all constants cast to the type of the first `cs` argument.
|
||||
template <typename F, typename... CONSTANTS>
|
||||
|
@ -1319,10 +1330,34 @@ ConstEval::Result ConstEval::Swizzle(const type::Type* ty,
|
|||
return builder.create<constant::Composite>(ty, std::move(values));
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::Bitcast(const type::Type*, const sem::Expression*) {
|
||||
// TODO(crbug.com/tint/1581): Implement @const intrinsics
|
||||
ConstEval::Result ConstEval::Bitcast(const type::Type* ty, const sem::Expression* expr) {
|
||||
auto* value = expr->ConstantValue();
|
||||
if (!value) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* el_ty = type::Type::DeepestElementOf(ty);
|
||||
auto& source = expr->Declaration()->source;
|
||||
auto transform = [&](const constant::Value* c0) {
|
||||
auto create = [&](auto e) {
|
||||
return Switch(
|
||||
el_ty,
|
||||
[&](const type::U32*) { //
|
||||
auto r = utils::Bitcast<u32>(e);
|
||||
return CreateScalar(builder, source, el_ty, r);
|
||||
},
|
||||
[&](const type::I32*) { //
|
||||
auto r = utils::Bitcast<i32>(e);
|
||||
return CreateScalar(builder, source, el_ty, r);
|
||||
},
|
||||
[&](const type::F32*) { //
|
||||
auto r = utils::Bitcast<f32>(e);
|
||||
return CreateScalar(builder, source, el_ty, r);
|
||||
});
|
||||
};
|
||||
return Dispatch_fiu32(create, c0);
|
||||
};
|
||||
return TransformElements(builder, ty, transform, value);
|
||||
}
|
||||
|
||||
ConstEval::Result ConstEval::OpComplement(const type::Type* ty,
|
||||
utils::VectorRef<const constant::Value*> args,
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
// 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/resolver/const_eval_test.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
namespace tint::resolver {
|
||||
namespace {
|
||||
|
||||
struct Case {
|
||||
Value input;
|
||||
struct Success {
|
||||
Value value;
|
||||
};
|
||||
struct Failure {
|
||||
builder::CreatePtrs create_ptrs;
|
||||
};
|
||||
utils::Result<Success, Failure> expected;
|
||||
};
|
||||
|
||||
static std::ostream& operator<<(std::ostream& o, const Case& c) {
|
||||
o << "input: " << c.input;
|
||||
if (c.expected) {
|
||||
o << ", expected: " << c.expected.Get().value;
|
||||
} else {
|
||||
o << ", expected failed bitcast to " << c.expected.Failure().create_ptrs;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename TO, typename FROM>
|
||||
Case Success(FROM input, TO expected) {
|
||||
return Case{input, Case::Success{expected}};
|
||||
}
|
||||
|
||||
template <typename TO, typename FROM>
|
||||
Case Failure(FROM input) {
|
||||
return Case{input, Case::Failure{builder::CreatePtrsFor<TO>()}};
|
||||
}
|
||||
|
||||
using ResolverConstEvalBitcastTest = ResolverTestWithParam<Case>;
|
||||
|
||||
TEST_P(ResolverConstEvalBitcastTest, Test) {
|
||||
const auto& input = GetParam().input;
|
||||
const auto& expected = GetParam().expected;
|
||||
|
||||
// Get the target type CreatePtrs
|
||||
builder::CreatePtrs target_create_ptrs;
|
||||
if (expected) {
|
||||
target_create_ptrs = expected.Get().value.create_ptrs;
|
||||
} else {
|
||||
target_create_ptrs = expected.Failure().create_ptrs;
|
||||
}
|
||||
|
||||
auto* target_ty = target_create_ptrs.ast(*this);
|
||||
ASSERT_NE(target_ty, nullptr);
|
||||
auto* input_val = input.Expr(*this);
|
||||
const ast::Expression* expr = Bitcast(target_ty, input_val);
|
||||
|
||||
WrapInFunction(expr);
|
||||
|
||||
auto* target_sem_ty = target_create_ptrs.sem(*this);
|
||||
|
||||
if (expected) {
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
auto* sem = Sem().Get(expr);
|
||||
ASSERT_NE(sem, nullptr);
|
||||
EXPECT_TYPE(sem->Type(), target_sem_ty);
|
||||
ASSERT_NE(sem->ConstantValue(), nullptr);
|
||||
EXPECT_TYPE(sem->ConstantValue()->Type(), target_sem_ty);
|
||||
|
||||
auto expected_values = expected.Get().value.args;
|
||||
auto got_values = ScalarsFrom(sem->ConstantValue());
|
||||
EXPECT_EQ(expected_values, got_values);
|
||||
} else {
|
||||
ASSERT_FALSE(r()->Resolve());
|
||||
EXPECT_THAT(r()->error(), testing::HasSubstr("cannot be represented as"));
|
||||
}
|
||||
}
|
||||
|
||||
const u32 nan_as_u32 = utils::Bitcast<u32>(std::numeric_limits<float>::quiet_NaN());
|
||||
const i32 nan_as_i32 = utils::Bitcast<i32>(std::numeric_limits<float>::quiet_NaN());
|
||||
const u32 inf_as_u32 = utils::Bitcast<u32>(std::numeric_limits<float>::infinity());
|
||||
const i32 inf_as_i32 = utils::Bitcast<i32>(std::numeric_limits<float>::infinity());
|
||||
const u32 neg_inf_as_u32 = utils::Bitcast<u32>(-std::numeric_limits<float>::infinity());
|
||||
const i32 neg_inf_as_i32 = utils::Bitcast<i32>(-std::numeric_limits<float>::infinity());
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(Bitcast,
|
||||
ResolverConstEvalBitcastTest,
|
||||
testing::ValuesIn({
|
||||
// Bitcast to same (concrete) type, no change
|
||||
Success(Val(0_u), Val(0_u)), //
|
||||
Success(Val(0_i), Val(0_i)), //
|
||||
Success(Val(0_f), Val(0_f)), //
|
||||
Success(Val(123_u), Val(123_u)), //
|
||||
Success(Val(123_i), Val(123_i)), //
|
||||
Success(Val(123.456_f), Val(123.456_f)), //
|
||||
Success(Val(u32::Highest()), Val(u32::Highest())), //
|
||||
Success(Val(u32::Lowest()), Val(u32::Lowest())), //
|
||||
Success(Val(i32::Highest()), Val(i32::Highest())), //
|
||||
Success(Val(i32::Lowest()), Val(i32::Lowest())), //
|
||||
Success(Val(f32::Highest()), Val(f32::Highest())), //
|
||||
Success(Val(f32::Lowest()), Val(f32::Lowest())), //
|
||||
|
||||
// Bitcast to different type
|
||||
Success(Val(0_u), Val(0_i)), //
|
||||
Success(Val(0_u), Val(0_f)), //
|
||||
Success(Val(0_i), Val(0_u)), //
|
||||
Success(Val(0_i), Val(0_f)), //
|
||||
Success(Val(0.0_f), Val(0_i)), //
|
||||
Success(Val(0.0_f), Val(0_u)), //
|
||||
Success(Val(1_u), Val(1_i)), //
|
||||
Success(Val(1_u), Val(1.4013e-45_f)), //
|
||||
Success(Val(1_i), Val(1_u)), //
|
||||
Success(Val(1_i), Val(1.4013e-45_f)), //
|
||||
Success(Val(1.0_f), Val(0x3F800000_u)), //
|
||||
Success(Val(1.0_f), Val(0x3F800000_i)), //
|
||||
Success(Val(123_u), Val(123_i)), //
|
||||
Success(Val(123_u), Val(1.7236e-43_f)), //
|
||||
Success(Val(123_i), Val(123_u)), //
|
||||
Success(Val(123_i), Val(1.7236e-43_f)), //
|
||||
Success(Val(123.0_f), Val(0x42F60000_u)), //
|
||||
Success(Val(123.0_f), Val(0x42F60000_i)), //
|
||||
|
||||
// Bitcast from abstract materializes lhs first,
|
||||
// so same results as above.
|
||||
Success(Val(0_a), Val(0_i)), //
|
||||
Success(Val(0_a), Val(0_f)), //
|
||||
Success(Val(0_a), Val(0_u)), //
|
||||
Success(Val(0_a), Val(0_f)), //
|
||||
Success(Val(0_a), Val(0_i)), //
|
||||
Success(Val(0_a), Val(0_u)), //
|
||||
Success(Val(1_a), Val(1_i)), //
|
||||
Success(Val(1_a), Val(1.4013e-45_f)), //
|
||||
Success(Val(1_a), Val(1_u)), //
|
||||
Success(Val(1_a), Val(1.4013e-45_f)), //
|
||||
Success(Val(1.0_a), Val(0x3F800000_u)), //
|
||||
Success(Val(1.0_a), Val(0x3F800000_i)), //
|
||||
Success(Val(123_a), Val(123_i)), //
|
||||
Success(Val(123_a), Val(1.7236e-43_f)), //
|
||||
Success(Val(123_a), Val(123_u)), //
|
||||
Success(Val(123_a), Val(1.7236e-43_f)), //
|
||||
Success(Val(123.0_a), Val(0x42F60000_u)), //
|
||||
Success(Val(123.0_a), Val(0x42F60000_i)), //
|
||||
|
||||
// u32 <-> i32 sign bit
|
||||
Success(Val(0xFFFFFFFF_u), Val(-1_i)), //
|
||||
Success(Val(-1_i), Val(0xFFFFFFFF_u)), //
|
||||
Success(Val(0x80000000_u), Val(i32::Lowest())), //
|
||||
Success(Val(i32::Lowest()), Val(0x80000000_u)), //
|
||||
|
||||
// Vector tests
|
||||
Success(Vec(0_u, 1_u, 123_u), Vec(0_i, 1_i, 123_i)),
|
||||
Success(Vec(0.0_f, 1.0_f, 123.0_f),
|
||||
Vec(0_i, 0x3F800000_i, 0x42F60000_i)),
|
||||
|
||||
// Unrepresentable
|
||||
Failure<f32>(Val(nan_as_u32)), //
|
||||
Failure<f32>(Val(nan_as_i32)), //
|
||||
Failure<f32>(Val(inf_as_u32)), //
|
||||
Failure<f32>(Val(inf_as_i32)), //
|
||||
Failure<f32>(Val(neg_inf_as_u32)), //
|
||||
Failure<f32>(Val(neg_inf_as_i32)), //
|
||||
Failure<builder::vec2<f32>>(Vec(nan_as_u32, 0_u)), //
|
||||
Failure<builder::vec2<f32>>(Vec(nan_as_i32, 0_i)), //
|
||||
Failure<builder::vec2<f32>>(Vec(inf_as_u32, 0_u)), //
|
||||
Failure<builder::vec2<f32>>(Vec(inf_as_i32, 0_i)), //
|
||||
Failure<builder::vec2<f32>>(Vec(neg_inf_as_u32, 0_u)), //
|
||||
Failure<builder::vec2<f32>>(Vec(neg_inf_as_i32, 0_i)), //
|
||||
Failure<builder::vec2<f32>>(Vec(0_u, nan_as_u32)), //
|
||||
Failure<builder::vec2<f32>>(Vec(0_i, nan_as_i32)), //
|
||||
Failure<builder::vec2<f32>>(Vec(0_u, inf_as_u32)), //
|
||||
Failure<builder::vec2<f32>>(Vec(0_i, inf_as_i32)), //
|
||||
Failure<builder::vec2<f32>>(Vec(0_u, neg_inf_as_u32)), //
|
||||
Failure<builder::vec2<f32>>(Vec(0_i, neg_inf_as_i32)), //
|
||||
}));
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::resolver
|
|
@ -789,11 +789,11 @@ enum class Method {
|
|||
// let a = abstract_expr;
|
||||
kLet,
|
||||
|
||||
// bitcast<f32>(abstract_expr)
|
||||
kBitcastF32Arg,
|
||||
// bitcast<i32>(abstract_expr)
|
||||
kBitcastI32Arg,
|
||||
|
||||
// bitcast<vec3<f32>>(abstract_expr)
|
||||
kBitcastVec3F32Arg,
|
||||
// bitcast<vec3<i32>>(abstract_expr)
|
||||
kBitcastVec3I32Arg,
|
||||
|
||||
// array<i32, abstract_expr>()
|
||||
kArrayLength,
|
||||
|
@ -825,10 +825,10 @@ static std::ostream& operator<<(std::ostream& o, Method m) {
|
|||
return o << "var";
|
||||
case Method::kLet:
|
||||
return o << "let";
|
||||
case Method::kBitcastF32Arg:
|
||||
return o << "bitcast-f32-arg";
|
||||
case Method::kBitcastVec3F32Arg:
|
||||
return o << "bitcast-vec3-f32-arg";
|
||||
case Method::kBitcastI32Arg:
|
||||
return o << "bitcast-i32-arg";
|
||||
case Method::kBitcastVec3I32Arg:
|
||||
return o << "bitcast-vec3-i32-arg";
|
||||
case Method::kArrayLength:
|
||||
return o << "array-length";
|
||||
case Method::kSwitch:
|
||||
|
@ -903,12 +903,12 @@ TEST_P(MaterializeAbstractNumericToDefaultType, Test) {
|
|||
WrapInFunction(Decl(Let("a", abstract_expr())));
|
||||
break;
|
||||
}
|
||||
case Method::kBitcastF32Arg: {
|
||||
WrapInFunction(Bitcast<f32>(abstract_expr()));
|
||||
case Method::kBitcastI32Arg: {
|
||||
WrapInFunction(Bitcast<i32>(abstract_expr()));
|
||||
break;
|
||||
}
|
||||
case Method::kBitcastVec3F32Arg: {
|
||||
WrapInFunction(Bitcast(ty.vec3<f32>(), abstract_expr()));
|
||||
case Method::kBitcastVec3I32Arg: {
|
||||
WrapInFunction(Bitcast(ty.vec3<i32>(), abstract_expr()));
|
||||
break;
|
||||
}
|
||||
case Method::kArrayLength: {
|
||||
|
@ -977,7 +977,7 @@ TEST_P(MaterializeAbstractNumericToDefaultType, Test) {
|
|||
constexpr Method kScalarMethods[] = {
|
||||
Method::kLet,
|
||||
Method::kVar,
|
||||
Method::kBitcastF32Arg,
|
||||
Method::kBitcastI32Arg,
|
||||
Method::kTintMaterializeBuiltin,
|
||||
};
|
||||
|
||||
|
@ -985,7 +985,7 @@ constexpr Method kScalarMethods[] = {
|
|||
constexpr Method kVectorMethods[] = {
|
||||
Method::kLet,
|
||||
Method::kVar,
|
||||
Method::kBitcastVec3F32Arg,
|
||||
Method::kBitcastVec3I32Arg,
|
||||
Method::kRuntimeIndex,
|
||||
Method::kTintMaterializeBuiltin,
|
||||
};
|
||||
|
|
|
@ -1957,24 +1957,27 @@ sem::Expression* Resolver::Bitcast(const ast::BitcastExpression* expr) {
|
|||
if (!ty) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!validator_.Bitcast(expr, ty)) {
|
||||
return nullptr;
|
||||
}
|
||||
//
|
||||
|
||||
const constant::Value* val = nullptr;
|
||||
sem::EvaluationStage stage = sem::EvaluationStage::kRuntime;
|
||||
// TODO(crbug.com/tint/1582): short circuit 'expr' once const eval of Bitcast is implemented.
|
||||
if (auto r = const_eval_.Bitcast(ty, inner)) {
|
||||
val = r.Get();
|
||||
if (val) {
|
||||
stage = sem::EvaluationStage::kConstant;
|
||||
}
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
auto stage = sem::EvaluationStage::kRuntime; // TODO(crbug.com/tint/1581)
|
||||
auto* sem = builder_->create<sem::Expression>(expr, ty, stage, current_statement_,
|
||||
std::move(val), inner->HasSideEffects());
|
||||
|
||||
sem->Behaviors() = inner->Behaviors();
|
||||
|
||||
if (!validator_.Bitcast(expr, ty)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return sem;
|
||||
}
|
||||
|
||||
|
|
|
@ -755,15 +755,18 @@ struct Value {
|
|||
static_assert(IsDataTypeSpecializedFor<T>, "No DataType<T> specialization exists");
|
||||
using EL_TY = typename builder::DataType<T>::ElementType;
|
||||
return Value{
|
||||
std::move(args), CreatePtrsFor<T>().expr, tint::IsAbstract<EL_TY>,
|
||||
tint::IsIntegral<EL_TY>, tint::FriendlyName<EL_TY>(),
|
||||
std::move(args), //
|
||||
CreatePtrsFor<T>(), //
|
||||
tint::IsAbstract<EL_TY>, //
|
||||
tint::IsIntegral<EL_TY>, //
|
||||
tint::FriendlyName<EL_TY>(),
|
||||
};
|
||||
}
|
||||
|
||||
/// Creates an `ast::Expression` for the type T passing in previously stored args
|
||||
/// @param b the ProgramBuilder
|
||||
/// @returns an expression node
|
||||
const ast::Expression* Expr(ProgramBuilder& b) const { return (*create)(b, args); }
|
||||
const ast::Expression* Expr(ProgramBuilder& b) const { return (*create_ptrs.expr)(b, args); }
|
||||
|
||||
/// Prints this value to the output stream
|
||||
/// @param o the output stream
|
||||
|
@ -782,8 +785,8 @@ struct Value {
|
|||
|
||||
/// The arguments used to construct the value
|
||||
utils::Vector<Scalar, 4> args;
|
||||
/// Function used to construct an expression with the given value
|
||||
builder::ast_expr_func_ptr create;
|
||||
/// CreatePtrs for value's type used to create an expression with `args`
|
||||
builder::CreatePtrs create_ptrs;
|
||||
/// True if the element type is abstract
|
||||
bool is_abstract = false;
|
||||
/// True if the element type is an integer
|
||||
|
@ -809,9 +812,11 @@ Value Val(T v) {
|
|||
}
|
||||
|
||||
/// Creates a Value of DataType<vec<N, T>> from N scalar `args`
|
||||
template <typename... T>
|
||||
Value Vec(T... args) {
|
||||
using FirstT = std::tuple_element_t<0, std::tuple<T...>>;
|
||||
template <typename... Ts>
|
||||
Value Vec(Ts... args) {
|
||||
using FirstT = std::tuple_element_t<0, std::tuple<Ts...>>;
|
||||
static_assert(std::conjunction_v<std::is_same<FirstT, Ts>...>,
|
||||
"Vector args must all be the same type");
|
||||
constexpr size_t N = sizeof...(args);
|
||||
utils::Vector<Scalar, sizeof...(args)> v{args...};
|
||||
return Value::Create<vec<N, FirstT>>(std::move(v));
|
||||
|
|
|
@ -22,36 +22,39 @@ namespace {
|
|||
using GlslGeneratorImplTest_Bitcast = TestHelper;
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_i));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "intBitsToFloat(1)");
|
||||
EXPECT_EQ(out.str(), "intBitsToFloat(a)");
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), Expr(1_u));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_u));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "int(1u)");
|
||||
EXPECT_EQ(out.str(), "int(a)");
|
||||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_i));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "uint(1)");
|
||||
EXPECT_EQ(out.str(), "uint(a)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -22,36 +22,39 @@ namespace {
|
|||
using HlslGeneratorImplTest_Bitcast = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_i));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "asfloat(1)");
|
||||
EXPECT_EQ(out.str(), "asfloat(a)");
|
||||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), Expr(1_u));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_u));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "asint(1u)");
|
||||
EXPECT_EQ(out.str(), "asint(a)");
|
||||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_i));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "asuint(1)");
|
||||
EXPECT_EQ(out.str(), "asuint(a)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -22,14 +22,15 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(1_i));
|
||||
WrapInFunction(bitcast);
|
||||
auto* a = Let("a", Expr(1_i));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr("a"));
|
||||
WrapInFunction(a, bitcast);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
std::stringstream out;
|
||||
ASSERT_TRUE(gen.EmitExpression(out, bitcast)) << gen.error();
|
||||
EXPECT_EQ(out.str(), "as_type<float>(1)");
|
||||
EXPECT_EQ(out.str(), "as_type<float>(a)");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -6,7 +6,7 @@ void main_1() {
|
|||
const uint4 x_18 = Src.Load(int3(0, 0, 0));
|
||||
srcValue = x_18;
|
||||
const uint x_22 = srcValue.x;
|
||||
srcValue.x = (x_22 + asuint(1));
|
||||
srcValue.x = (x_22 + 1u);
|
||||
const uint4 x_27 = srcValue;
|
||||
Dst[(0).xx] = x_27;
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@ void main_1() {
|
|||
const uint4 x_18 = Src.Load(int3(0, 0, 0));
|
||||
srcValue = x_18;
|
||||
const uint x_22 = srcValue.x;
|
||||
srcValue.x = (x_22 + asuint(1));
|
||||
srcValue.x = (x_22 + 1u);
|
||||
const uint4 x_27 = srcValue;
|
||||
Dst[(0).xx] = x_27;
|
||||
return;
|
||||
|
|
|
@ -7,7 +7,7 @@ void main_1() {
|
|||
uvec4 x_18 = texelFetch(Src_1, ivec2(0), 0);
|
||||
srcValue = x_18;
|
||||
uint x_22 = srcValue.x;
|
||||
srcValue.x = (x_22 + uint(1));
|
||||
srcValue.x = (x_22 + 1u);
|
||||
uvec4 x_27 = srcValue;
|
||||
imageStore(Dst, ivec2(0), x_27);
|
||||
return;
|
||||
|
|
|
@ -6,7 +6,7 @@ void main_1(texture2d<uint, access::sample> tint_symbol_1, texture2d<uint, acces
|
|||
uint4 const x_18 = tint_symbol_1.read(uint2(int2(0)), 0);
|
||||
srcValue = x_18;
|
||||
uint const x_22 = srcValue[0];
|
||||
srcValue[0] = (x_22 + as_type<uint>(1));
|
||||
srcValue[0] = (x_22 + 1u);
|
||||
uint4 const x_27 = srcValue;
|
||||
tint_symbol_2.write(x_27, uint2(int2(0)));
|
||||
return;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 36
|
||||
; Bound: 35
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -35,7 +35,7 @@
|
|||
%21 = OpConstantNull %int
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||
%int_1 = OpConstant %int 1
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%main_1 = OpFunction %void None %8
|
||||
%11 = OpLabel
|
||||
%srcValue = OpVariable %_ptr_Function_v4uint Function %15
|
||||
|
@ -45,16 +45,15 @@
|
|||
%24 = OpAccessChain %_ptr_Function_uint %srcValue %uint_0
|
||||
%25 = OpLoad %uint %24
|
||||
%26 = OpAccessChain %_ptr_Function_uint %srcValue %uint_0
|
||||
%27 = OpBitcast %uint %int_1
|
||||
%29 = OpIAdd %uint %25 %27
|
||||
OpStore %26 %29
|
||||
%30 = OpLoad %v4uint %srcValue
|
||||
%32 = OpLoad %7 %Dst
|
||||
OpImageWrite %32 %20 %30
|
||||
%28 = OpIAdd %uint %25 %uint_1
|
||||
OpStore %26 %28
|
||||
%29 = OpLoad %v4uint %srcValue
|
||||
%31 = OpLoad %7 %Dst
|
||||
OpImageWrite %31 %20 %29
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%main = OpFunction %void None %8
|
||||
%34 = OpLabel
|
||||
%35 = OpFunctionCall %void %main_1
|
||||
%33 = OpLabel
|
||||
%34 = OpFunctionCall %void %main_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint b = asuint(-2147483648);
|
||||
const uint b = 2147483648u;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[numthreads(1, 1, 1)]
|
||||
void f() {
|
||||
const uint b = asuint(-2147483648);
|
||||
const uint b = 2147483648u;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#version 310 es
|
||||
|
||||
void f() {
|
||||
uint b = uint(-2147483648);
|
||||
uint b = 2147483648u;
|
||||
}
|
||||
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
using namespace metal;
|
||||
kernel void f() {
|
||||
uint const b = as_type<uint>((-2147483647 - 1));
|
||||
uint const b = 2147483648u;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
; SPIR-V
|
||||
; Version: 1.3
|
||||
; Generator: Google Tint Compiler; 0
|
||||
; Bound: 9
|
||||
; Bound: 7
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
|
@ -11,10 +11,8 @@
|
|||
%void = OpTypeVoid
|
||||
%1 = OpTypeFunction %void
|
||||
%uint = OpTypeInt 32 0
|
||||
%int = OpTypeInt 32 1
|
||||
%int_n2147483648 = OpConstant %int -2147483648
|
||||
%uint_2147483648 = OpConstant %uint 2147483648
|
||||
%f = OpFunction %void None %1
|
||||
%4 = OpLabel
|
||||
%5 = OpBitcast %uint %int_n2147483648
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -33,7 +34,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
%100 = OpFunction %void None %3
|
||||
%25 = OpLabel
|
||||
%1 = OpShiftLeftLogical %int %int_30 %int_40
|
||||
%1 = OpShiftLeftLogical %int %int_30 %int_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -33,7 +34,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
%100 = OpFunction %void None %3
|
||||
%25 = OpLabel
|
||||
%1 = OpShiftLeftLogical %uint %uint_10 %int_40
|
||||
%1 = OpShiftLeftLogical %uint %uint_10 %int_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -28,7 +29,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%19 = OpConstantComposite %v2uint %uint_10 %uint_20
|
||||
%20 = OpConstantComposite %v2uint %uint_20 %uint_10
|
||||
%21 = OpConstantComposite %v2int %int_30 %int_40
|
||||
%22 = OpConstantComposite %v2int %int_40 %int_30
|
||||
%22 = OpConstantComposite %v2int %int_1 %int_1
|
||||
%23 = OpConstantComposite %v2float %float_50 %float_60
|
||||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
%100 = OpFunction %void None %3
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -33,7 +34,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
%100 = OpFunction %void None %3
|
||||
%25 = OpLabel
|
||||
%1 = OpShiftRightArithmetic %int %int_30 %int_40
|
||||
%1 = OpShiftRightArithmetic %int %int_30 %int_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -27,7 +28,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%v2float = OpTypeVector %float 2
|
||||
%19 = OpConstantComposite %v2uint %uint_10 %uint_20
|
||||
%20 = OpConstantComposite %v2uint %uint_20 %uint_10
|
||||
%21 = OpConstantComposite %v2int %int_30 %int_40
|
||||
%21 = OpConstantComposite %v2int %int_1 %int_1
|
||||
%22 = OpConstantComposite %v2int %int_40 %int_30
|
||||
%23 = OpConstantComposite %v2float %float_50 %float_60
|
||||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -27,7 +28,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%v2float = OpTypeVector %float 2
|
||||
%19 = OpConstantComposite %v2uint %uint_10 %uint_20
|
||||
%20 = OpConstantComposite %v2uint %uint_20 %uint_10
|
||||
%21 = OpConstantComposite %v2int %int_30 %int_40
|
||||
%21 = OpConstantComposite %v2int %int_1 %int_1
|
||||
%22 = OpConstantComposite %v2int %int_40 %int_30
|
||||
%23 = OpConstantComposite %v2float %float_50 %float_60
|
||||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -33,7 +34,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
%100 = OpFunction %void None %3
|
||||
%25 = OpLabel
|
||||
%1 = OpShiftRightLogical %int %int_30 %int_40
|
||||
%1 = OpShiftRightLogical %int %int_30 %int_1
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -27,7 +28,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%v2float = OpTypeVector %float 2
|
||||
%19 = OpConstantComposite %v2uint %uint_10 %uint_20
|
||||
%20 = OpConstantComposite %v2uint %uint_20 %uint_10
|
||||
%21 = OpConstantComposite %v2int %int_30 %int_40
|
||||
%21 = OpConstantComposite %v2int %int_1 %int_1
|
||||
%22 = OpConstantComposite %v2int %int_40 %int_30
|
||||
%23 = OpConstantComposite %v2float %float_50 %float_60
|
||||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
|
|
|
@ -15,6 +15,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%float = OpTypeFloat 32
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%uint_20 = OpConstant %uint 20
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_30 = OpConstant %int 30
|
||||
%int_40 = OpConstant %int 40
|
||||
%float_50 = OpConstant %float 50
|
||||
|
@ -27,7 +28,7 @@ OpExecutionMode %100 OriginUpperLeft
|
|||
%v2float = OpTypeVector %float 2
|
||||
%19 = OpConstantComposite %v2uint %uint_10 %uint_20
|
||||
%20 = OpConstantComposite %v2uint %uint_20 %uint_10
|
||||
%21 = OpConstantComposite %v2int %int_30 %int_40
|
||||
%21 = OpConstantComposite %v2int %int_1 %int_1
|
||||
%22 = OpConstantComposite %v2int %int_40 %int_30
|
||||
%23 = OpConstantComposite %v2float %float_50 %float_60
|
||||
%24 = OpConstantComposite %v2float %float_60 %float_50
|
||||
|
|
|
@ -1,143 +0,0 @@
|
|||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %_GLF_color
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource ESSL 310
|
||||
OpName %main "main"
|
||||
OpName %nan "nan"
|
||||
OpName %undefined "undefined"
|
||||
OpName %buf1 "buf1"
|
||||
OpMemberName %buf1 0 "_GLF_uniform_int_values"
|
||||
OpName %_ ""
|
||||
OpName %buf0 "buf0"
|
||||
OpMemberName %buf0 0 "_GLF_uniform_float_values"
|
||||
OpName %__0 ""
|
||||
OpName %_GLF_color "_GLF_color"
|
||||
OpDecorate %_arr_int_uint_10 ArrayStride 16
|
||||
OpMemberDecorate %buf1 0 Offset 0
|
||||
OpDecorate %buf1 Block
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 1
|
||||
OpDecorate %_arr_float_uint_1 ArrayStride 16
|
||||
OpMemberDecorate %buf0 0 Offset 0
|
||||
OpDecorate %buf0 Block
|
||||
OpDecorate %__0 DescriptorSet 0
|
||||
OpDecorate %__0 Binding 0
|
||||
OpDecorate %_GLF_color Location 0
|
||||
%void = OpTypeVoid
|
||||
%13 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_n1 = OpConstant %int -1
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_10 = OpConstant %uint 10
|
||||
%_arr_int_uint_10 = OpTypeArray %int %uint_10
|
||||
%buf1 = OpTypeStruct %_arr_int_uint_10
|
||||
%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1
|
||||
%_ = OpVariable %_ptr_Uniform_buf1 Uniform
|
||||
%int_0 = OpConstant %int 0
|
||||
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_2 = OpConstant %int 2
|
||||
%int_3 = OpConstant %int 3
|
||||
%int_4 = OpConstant %int 4
|
||||
%int_5 = OpConstant %int 5
|
||||
%int_6 = OpConstant %int 6
|
||||
%int_7 = OpConstant %int 7
|
||||
%bool = OpTypeBool
|
||||
%int_9 = OpConstant %int 9
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_arr_float_uint_1 = OpTypeArray %float %uint_1
|
||||
%buf0 = OpTypeStruct %_arr_float_uint_1
|
||||
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
|
||||
%__0 = OpVariable %_ptr_Uniform_buf0 Uniform
|
||||
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%_GLF_color = OpVariable %_ptr_Output_v4float Output
|
||||
%int_8 = OpConstant %int 8
|
||||
%main = OpFunction %void None %13
|
||||
%40 = OpLabel
|
||||
%nan = OpVariable %_ptr_Function_float Function
|
||||
%undefined = OpVariable %_ptr_Function_v4float Function
|
||||
%41 = OpBitcast %float %int_n1
|
||||
OpStore %nan %41
|
||||
%42 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
|
||||
%43 = OpLoad %int %42
|
||||
%44 = OpConvertSToF %float %43
|
||||
%45 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_1
|
||||
%46 = OpLoad %int %45
|
||||
%47 = OpConvertSToF %float %46
|
||||
%48 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_2
|
||||
%49 = OpLoad %int %48
|
||||
%50 = OpConvertSToF %float %49
|
||||
%51 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_3
|
||||
%52 = OpLoad %int %51
|
||||
%53 = OpConvertSToF %float %52
|
||||
%54 = OpCompositeConstruct %v4float %44 %47 %50 %53
|
||||
%55 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_4
|
||||
%56 = OpLoad %int %55
|
||||
%57 = OpConvertSToF %float %56
|
||||
%58 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_5
|
||||
%59 = OpLoad %int %58
|
||||
%60 = OpConvertSToF %float %59
|
||||
%61 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_6
|
||||
%62 = OpLoad %int %61
|
||||
%63 = OpConvertSToF %float %62
|
||||
%64 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_7
|
||||
%65 = OpLoad %int %64
|
||||
%66 = OpConvertSToF %float %65
|
||||
%67 = OpCompositeConstruct %v4float %57 %60 %63 %66
|
||||
%68 = OpLoad %float %nan
|
||||
%69 = OpCompositeConstruct %v4float %68 %68 %68 %68
|
||||
%70 = OpExtInst %v4float %1 FMix %54 %67 %69
|
||||
OpStore %undefined %70
|
||||
%71 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
|
||||
%72 = OpLoad %int %71
|
||||
%73 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_9
|
||||
%74 = OpLoad %int %73
|
||||
%75 = OpIEqual %bool %72 %74
|
||||
%76 = OpLogicalNot %bool %75
|
||||
OpSelectionMerge %77 None
|
||||
OpBranchConditional %76 %78 %77
|
||||
%78 = OpLabel
|
||||
%79 = OpAccessChain %_ptr_Function_float %undefined %uint_0
|
||||
%80 = OpLoad %float %79
|
||||
%81 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %int_0
|
||||
%82 = OpLoad %float %81
|
||||
%83 = OpFOrdGreaterThan %bool %80 %82
|
||||
OpBranch %77
|
||||
%77 = OpLabel
|
||||
%84 = OpPhi %bool %75 %40 %83 %78
|
||||
OpSelectionMerge %85 None
|
||||
OpBranchConditional %84 %86 %87
|
||||
%86 = OpLabel
|
||||
%88 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
|
||||
%89 = OpLoad %int %88
|
||||
%90 = OpConvertSToF %float %89
|
||||
%91 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_8
|
||||
%92 = OpLoad %int %91
|
||||
%93 = OpConvertSToF %float %92
|
||||
%94 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_8
|
||||
%95 = OpLoad %int %94
|
||||
%96 = OpConvertSToF %float %95
|
||||
%97 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
|
||||
%98 = OpLoad %int %97
|
||||
%99 = OpConvertSToF %float %98
|
||||
%100 = OpCompositeConstruct %v4float %90 %93 %96 %99
|
||||
OpStore %_GLF_color %100
|
||||
OpBranch %85
|
||||
%87 = OpLabel
|
||||
%101 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_8
|
||||
%102 = OpLoad %int %101
|
||||
%103 = OpConvertSToF %float %102
|
||||
%104 = OpCompositeConstruct %v4float %103 %103 %103 %103
|
||||
OpStore %_GLF_color %104
|
||||
OpBranch %85
|
||||
%85 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
|
@ -1,79 +0,0 @@
|
|||
struct strided_arr {
|
||||
@size(16)
|
||||
el : i32,
|
||||
}
|
||||
|
||||
type Arr = array<strided_arr, 10u>;
|
||||
|
||||
struct buf1 {
|
||||
x_GLF_uniform_int_values : Arr,
|
||||
}
|
||||
|
||||
struct strided_arr_1 {
|
||||
@size(16)
|
||||
el : f32,
|
||||
}
|
||||
|
||||
type Arr_1 = array<strided_arr_1, 1u>;
|
||||
|
||||
struct buf0 {
|
||||
x_GLF_uniform_float_values : Arr_1,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var<uniform> x_7 : buf1;
|
||||
|
||||
@group(0) @binding(0) var<uniform> x_9 : buf0;
|
||||
|
||||
var<private> x_GLF_color : vec4<f32>;
|
||||
|
||||
fn main_1() {
|
||||
var nan : f32;
|
||||
var undefined : vec4<f32>;
|
||||
var x_83 : bool;
|
||||
var x_84_phi : bool;
|
||||
nan = bitcast<f32>(-1);
|
||||
let x_43 : i32 = x_7.x_GLF_uniform_int_values[0].el;
|
||||
let x_46 : i32 = x_7.x_GLF_uniform_int_values[1].el;
|
||||
let x_49 : i32 = x_7.x_GLF_uniform_int_values[2].el;
|
||||
let x_52 : i32 = x_7.x_GLF_uniform_int_values[3].el;
|
||||
let x_56 : i32 = x_7.x_GLF_uniform_int_values[4].el;
|
||||
let x_59 : i32 = x_7.x_GLF_uniform_int_values[5].el;
|
||||
let x_62 : i32 = x_7.x_GLF_uniform_int_values[6].el;
|
||||
let x_65 : i32 = x_7.x_GLF_uniform_int_values[7].el;
|
||||
let x_68 : f32 = nan;
|
||||
undefined = mix(vec4<f32>(f32(x_43), f32(x_46), f32(x_49), f32(x_52)), vec4<f32>(f32(x_56), f32(x_59), f32(x_62), f32(x_65)), vec4<f32>(x_68, x_68, x_68, x_68));
|
||||
let x_72 : i32 = x_7.x_GLF_uniform_int_values[0].el;
|
||||
let x_74 : i32 = x_7.x_GLF_uniform_int_values[9].el;
|
||||
let x_75 : bool = (x_72 == x_74);
|
||||
x_84_phi = x_75;
|
||||
if (!(x_75)) {
|
||||
let x_80 : f32 = undefined.x;
|
||||
let x_82 : f32 = x_9.x_GLF_uniform_float_values[0].el;
|
||||
x_83 = (x_80 > x_82);
|
||||
x_84_phi = x_83;
|
||||
}
|
||||
let x_84 : bool = x_84_phi;
|
||||
if (x_84) {
|
||||
let x_89 : i32 = x_7.x_GLF_uniform_int_values[0].el;
|
||||
let x_92 : i32 = x_7.x_GLF_uniform_int_values[8].el;
|
||||
let x_95 : i32 = x_7.x_GLF_uniform_int_values[8].el;
|
||||
let x_98 : i32 = x_7.x_GLF_uniform_int_values[0].el;
|
||||
x_GLF_color = vec4<f32>(f32(x_89), f32(x_92), f32(x_95), f32(x_98));
|
||||
} else {
|
||||
let x_102 : i32 = x_7.x_GLF_uniform_int_values[8].el;
|
||||
let x_103 : f32 = f32(x_102);
|
||||
x_GLF_color = vec4<f32>(x_103, x_103, x_103, x_103);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct main_out {
|
||||
@location(0)
|
||||
x_GLF_color_1 : vec4<f32>,
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_GLF_color);
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %_GLF_color
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource ESSL 320
|
||||
OpName %main "main"
|
||||
OpName %a "a"
|
||||
OpName %i "i"
|
||||
OpName %buf0 "buf0"
|
||||
OpMemberName %buf0 0 "one"
|
||||
OpName %_ ""
|
||||
OpName %_GLF_color "_GLF_color"
|
||||
OpMemberDecorate %buf0 0 Offset 0
|
||||
OpDecorate %buf0 Block
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 0
|
||||
OpDecorate %_GLF_color Location 0
|
||||
%void = OpTypeVoid
|
||||
%9 = OpTypeFunction %void
|
||||
%int = OpTypeInt 32 1
|
||||
%_ptr_Function_int = OpTypePointer Function %int
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_5 = OpConstant %int 5
|
||||
%bool = OpTypeBool
|
||||
%buf0 = OpTypeStruct %int
|
||||
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
|
||||
%_ = OpVariable %_ptr_Uniform_buf0 Uniform
|
||||
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
||||
%int_n4194304 = OpConstant %int -4194304
|
||||
%float = OpTypeFloat 32
|
||||
%float_0 = OpConstant %float 0
|
||||
%int_n1 = OpConstant %int -1
|
||||
%int_1 = OpConstant %int 1
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%_GLF_color = OpVariable %_ptr_Output_v4float Output
|
||||
%float_1 = OpConstant %float 1
|
||||
%25 = OpConstantComposite %v4float %float_1 %float_0 %float_0 %float_1
|
||||
%26 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
|
||||
%main = OpFunction %void None %9
|
||||
%27 = OpLabel
|
||||
%a = OpVariable %_ptr_Function_int Function
|
||||
%i = OpVariable %_ptr_Function_int Function
|
||||
OpStore %a %int_0
|
||||
OpStore %i %int_0
|
||||
OpBranch %28
|
||||
%28 = OpLabel
|
||||
OpLoopMerge %29 %30 None
|
||||
OpBranch %31
|
||||
%31 = OpLabel
|
||||
%32 = OpLoad %int %i
|
||||
%33 = OpSLessThan %bool %32 %int_5
|
||||
OpBranchConditional %33 %34 %29
|
||||
%34 = OpLabel
|
||||
%35 = OpAccessChain %_ptr_Uniform_int %_ %int_0
|
||||
%36 = OpLoad %int %35
|
||||
%37 = OpIEqual %bool %36 %int_0
|
||||
OpSelectionMerge %38 None
|
||||
OpBranchConditional %37 %39 %38
|
||||
%39 = OpLabel
|
||||
%40 = OpBitcast %float %int_n4194304
|
||||
%41 = OpExtInst %float %1 Floor %40
|
||||
%42 = OpFOrdGreaterThan %bool %41 %float_0
|
||||
OpSelectionMerge %43 None
|
||||
OpBranchConditional %42 %44 %43
|
||||
%44 = OpLabel
|
||||
OpStore %a %int_n1
|
||||
OpBranch %29
|
||||
%43 = OpLabel
|
||||
OpBranch %38
|
||||
%38 = OpLabel
|
||||
%45 = OpLoad %int %a
|
||||
%46 = OpIAdd %int %45 %int_1
|
||||
OpStore %a %46
|
||||
OpBranch %30
|
||||
%30 = OpLabel
|
||||
%47 = OpLoad %int %i
|
||||
%48 = OpIAdd %int %47 %int_1
|
||||
OpStore %i %48
|
||||
OpBranch %28
|
||||
%29 = OpLabel
|
||||
%49 = OpLoad %int %a
|
||||
%50 = OpIEqual %bool %49 %int_5
|
||||
OpSelectionMerge %51 None
|
||||
OpBranchConditional %50 %52 %53
|
||||
%52 = OpLabel
|
||||
OpStore %_GLF_color %25
|
||||
OpBranch %51
|
||||
%53 = OpLabel
|
||||
OpStore %_GLF_color %26
|
||||
OpBranch %51
|
||||
%51 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
|
@ -1,53 +0,0 @@
|
|||
struct buf0 {
|
||||
one : i32,
|
||||
}
|
||||
|
||||
@group(0) @binding(0) var<uniform> x_7 : buf0;
|
||||
|
||||
var<private> x_GLF_color : vec4<f32>;
|
||||
|
||||
fn main_1() {
|
||||
var a : i32;
|
||||
var i : i32;
|
||||
a = 0;
|
||||
i = 0;
|
||||
loop {
|
||||
let x_32 : i32 = i;
|
||||
if ((x_32 < 5)) {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
let x_36 : i32 = x_7.one;
|
||||
if ((x_36 == 0)) {
|
||||
if ((floor(bitcast<f32>(-4194304)) > 0.0)) {
|
||||
a = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let x_45 : i32 = a;
|
||||
a = (x_45 + 1);
|
||||
|
||||
continuing {
|
||||
let x_47 : i32 = i;
|
||||
i = (x_47 + 1);
|
||||
}
|
||||
}
|
||||
let x_49 : i32 = a;
|
||||
if ((x_49 == 5)) {
|
||||
x_GLF_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
} else {
|
||||
x_GLF_color = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct main_out {
|
||||
@location(0)
|
||||
x_GLF_color_1 : vec4<f32>,
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main() -> main_out {
|
||||
main_1();
|
||||
return main_out(x_GLF_color);
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %gl_FragCoord %_GLF_color
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource ESSL 320
|
||||
OpName %main "main"
|
||||
OpName %f "f"
|
||||
OpName %gl_FragCoord "gl_FragCoord"
|
||||
OpName %buf0 "buf0"
|
||||
OpMemberName %buf0 0 "_GLF_uniform_float_values"
|
||||
OpName %_ ""
|
||||
OpName %_GLF_color "_GLF_color"
|
||||
OpName %buf1 "buf1"
|
||||
OpMemberName %buf1 0 "_GLF_uniform_int_values"
|
||||
OpName %__0 ""
|
||||
OpDecorate %gl_FragCoord BuiltIn FragCoord
|
||||
OpDecorate %_arr_float_uint_1 ArrayStride 16
|
||||
OpMemberDecorate %buf0 0 Offset 0
|
||||
OpDecorate %buf0 Block
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 0
|
||||
OpDecorate %_GLF_color Location 0
|
||||
OpDecorate %_arr_int_uint_2 ArrayStride 16
|
||||
OpMemberDecorate %buf1 0 Offset 0
|
||||
OpDecorate %buf1 Block
|
||||
OpDecorate %__0 DescriptorSet 0
|
||||
OpDecorate %__0 Binding 1
|
||||
%void = OpTypeVoid
|
||||
%13 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%_ptr_Function_float = OpTypePointer Function %float
|
||||
%int = OpTypeInt 32 1
|
||||
%int_n1 = OpConstant %int -1
|
||||
%float_1 = OpConstant %float 1
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Input_v4float = OpTypePointer Input %v4float
|
||||
%gl_FragCoord = OpVariable %_ptr_Input_v4float Input
|
||||
%uint = OpTypeInt 32 0
|
||||
%uint_0 = OpConstant %uint 0
|
||||
%_ptr_Input_float = OpTypePointer Input %float
|
||||
%uint_1 = OpConstant %uint 1
|
||||
%_arr_float_uint_1 = OpTypeArray %float %uint_1
|
||||
%buf0 = OpTypeStruct %_arr_float_uint_1
|
||||
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
|
||||
%_ = OpVariable %_ptr_Uniform_buf0 Uniform
|
||||
%int_0 = OpConstant %int 0
|
||||
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
||||
%bool = OpTypeBool
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%_GLF_color = OpVariable %_ptr_Output_v4float Output
|
||||
%uint_2 = OpConstant %uint 2
|
||||
%_arr_int_uint_2 = OpTypeArray %int %uint_2
|
||||
%buf1 = OpTypeStruct %_arr_int_uint_2
|
||||
%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1
|
||||
%__0 = OpVariable %_ptr_Uniform_buf1 Uniform
|
||||
%int_1 = OpConstant %int 1
|
||||
%_ptr_Uniform_int = OpTypePointer Uniform %int
|
||||
%main = OpFunction %void None %13
|
||||
%34 = OpLabel
|
||||
%f = OpVariable %_ptr_Function_float Function
|
||||
%35 = OpBitcast %float %int_n1
|
||||
%36 = OpExtInst %float %1 FMin %35 %float_1
|
||||
OpStore %f %36
|
||||
%37 = OpAccessChain %_ptr_Input_float %gl_FragCoord %uint_0
|
||||
%38 = OpLoad %float %37
|
||||
%39 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_0
|
||||
%40 = OpLoad %float %39
|
||||
%41 = OpFOrdGreaterThan %bool %38 %40
|
||||
OpSelectionMerge %42 None
|
||||
OpBranchConditional %41 %43 %44
|
||||
%43 = OpLabel
|
||||
%45 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_1
|
||||
%46 = OpLoad %int %45
|
||||
%47 = OpConvertSToF %float %46
|
||||
%48 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_0
|
||||
%49 = OpLoad %int %48
|
||||
%50 = OpConvertSToF %float %49
|
||||
%51 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_0
|
||||
%52 = OpLoad %int %51
|
||||
%53 = OpConvertSToF %float %52
|
||||
%54 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_1
|
||||
%55 = OpLoad %int %54
|
||||
%56 = OpConvertSToF %float %55
|
||||
%57 = OpCompositeConstruct %v4float %47 %50 %53 %56
|
||||
OpStore %_GLF_color %57
|
||||
OpBranch %42
|
||||
%44 = OpLabel
|
||||
%58 = OpLoad %float %f
|
||||
%59 = OpCompositeConstruct %v4float %58 %58 %58 %58
|
||||
OpStore %_GLF_color %59
|
||||
OpBranch %42
|
||||
%42 = OpLabel
|
||||
OpReturn
|
||||
OpFunctionEnd
|
|
@ -1,59 +0,0 @@
|
|||
struct strided_arr {
|
||||
@size(16)
|
||||
el : f32,
|
||||
}
|
||||
|
||||
type Arr = array<strided_arr, 1u>;
|
||||
|
||||
struct buf0 {
|
||||
x_GLF_uniform_float_values : Arr,
|
||||
}
|
||||
|
||||
struct strided_arr_1 {
|
||||
@size(16)
|
||||
el : i32,
|
||||
}
|
||||
|
||||
type Arr_1 = array<strided_arr_1, 2u>;
|
||||
|
||||
struct buf1 {
|
||||
x_GLF_uniform_int_values : Arr_1,
|
||||
}
|
||||
|
||||
var<private> gl_FragCoord : vec4<f32>;
|
||||
|
||||
@group(0) @binding(0) var<uniform> x_7 : buf0;
|
||||
|
||||
var<private> x_GLF_color : vec4<f32>;
|
||||
|
||||
@group(0) @binding(1) var<uniform> x_9 : buf1;
|
||||
|
||||
fn main_1() {
|
||||
var f : f32;
|
||||
f = min(bitcast<f32>(-1), 1.0);
|
||||
let x_38 : f32 = gl_FragCoord.x;
|
||||
let x_40 : f32 = x_7.x_GLF_uniform_float_values[0].el;
|
||||
if ((x_38 > x_40)) {
|
||||
let x_46 : i32 = x_9.x_GLF_uniform_int_values[1].el;
|
||||
let x_49 : i32 = x_9.x_GLF_uniform_int_values[0].el;
|
||||
let x_52 : i32 = x_9.x_GLF_uniform_int_values[0].el;
|
||||
let x_55 : i32 = x_9.x_GLF_uniform_int_values[1].el;
|
||||
x_GLF_color = vec4<f32>(f32(x_46), f32(x_49), f32(x_52), f32(x_55));
|
||||
} else {
|
||||
let x_58 : f32 = f;
|
||||
x_GLF_color = vec4<f32>(x_58, x_58, x_58, x_58);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
struct main_out {
|
||||
@location(0)
|
||||
x_GLF_color_1 : vec4<f32>,
|
||||
}
|
||||
|
||||
@fragment
|
||||
fn main(@builtin(position) gl_FragCoord_param : vec4<f32>) -> main_out {
|
||||
gl_FragCoord = gl_FragCoord_param;
|
||||
main_1();
|
||||
return main_out(x_GLF_color);
|
||||
}
|
Loading…
Reference in New Issue