builtins: Add countLeadingZeros
Requires polyfilling for all but the MSL backend. CTS tests: https://github.com/gpuweb/cts/pull/1001 Bug: tint:1367 Change-Id: I75097de945909e3242ede9001124d8821bc832bc Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/81380 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
1fcb2a7a24
commit
27aa57ccac
7
Doxyfile
7
Doxyfile
|
@ -1081,13 +1081,6 @@ VERBATIM_HEADERS = YES
|
||||||
|
|
||||||
ALPHABETICAL_INDEX = YES
|
ALPHABETICAL_INDEX = YES
|
||||||
|
|
||||||
# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
|
|
||||||
# which the alphabetical index list will be split.
|
|
||||||
# Minimum value: 1, maximum value: 20, default value: 5.
|
|
||||||
# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
|
|
||||||
|
|
||||||
COLS_IN_ALPHA_INDEX = 5
|
|
||||||
|
|
||||||
# In case all classes in a project start with a common prefix, all classes will
|
# In case all classes in a project start with a common prefix, all classes will
|
||||||
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
|
# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
|
||||||
# can be used to specify a prefix (or a list of prefixes) that should be ignored
|
# can be used to specify a prefix (or a list of prefixes) that should be ignored
|
||||||
|
|
|
@ -436,6 +436,8 @@ libtint_source_set("libtint_core_all_src") {
|
||||||
"transform/array_length_from_uniform.h",
|
"transform/array_length_from_uniform.h",
|
||||||
"transform/binding_remapper.cc",
|
"transform/binding_remapper.cc",
|
||||||
"transform/binding_remapper.h",
|
"transform/binding_remapper.h",
|
||||||
|
"transform/builtin_polyfill.cc",
|
||||||
|
"transform/builtin_polyfill.h",
|
||||||
"transform/calculate_array_length.cc",
|
"transform/calculate_array_length.cc",
|
||||||
"transform/calculate_array_length.h",
|
"transform/calculate_array_length.h",
|
||||||
"transform/canonicalize_entry_point_io.cc",
|
"transform/canonicalize_entry_point_io.cc",
|
||||||
|
|
|
@ -312,6 +312,8 @@ set(TINT_LIB_SRCS
|
||||||
transform/array_length_from_uniform.h
|
transform/array_length_from_uniform.h
|
||||||
transform/binding_remapper.cc
|
transform/binding_remapper.cc
|
||||||
transform/binding_remapper.h
|
transform/binding_remapper.h
|
||||||
|
transform/builtin_polyfill.cc
|
||||||
|
transform/builtin_polyfill.h
|
||||||
transform/calculate_array_length.cc
|
transform/calculate_array_length.cc
|
||||||
transform/calculate_array_length.h
|
transform/calculate_array_length.h
|
||||||
transform/combine_samplers.cc
|
transform/combine_samplers.cc
|
||||||
|
@ -1006,6 +1008,7 @@ if(TINT_BUILD_TESTS)
|
||||||
transform/add_spirv_block_attribute_test.cc
|
transform/add_spirv_block_attribute_test.cc
|
||||||
transform/array_length_from_uniform_test.cc
|
transform/array_length_from_uniform_test.cc
|
||||||
transform/binding_remapper_test.cc
|
transform/binding_remapper_test.cc
|
||||||
|
transform/builtin_polyfill_test.cc
|
||||||
transform/calculate_array_length_test.cc
|
transform/calculate_array_length_test.cc
|
||||||
transform/canonicalize_entry_point_io_test.cc
|
transform/canonicalize_entry_point_io_test.cc
|
||||||
transform/combine_samplers_test.cc
|
transform/combine_samplers_test.cc
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -286,6 +286,8 @@ fn cos(f32) -> f32
|
||||||
fn cos<N: num>(vec<N, f32>) -> vec<N, f32>
|
fn cos<N: num>(vec<N, f32>) -> vec<N, f32>
|
||||||
fn cosh(f32) -> f32
|
fn cosh(f32) -> f32
|
||||||
fn cosh<N: num>(vec<N, f32>) -> vec<N, f32>
|
fn cosh<N: num>(vec<N, f32>) -> vec<N, f32>
|
||||||
|
fn countLeadingZeros<T: iu32>(T) -> T
|
||||||
|
fn countLeadingZeros<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
|
||||||
fn countOneBits<T: iu32>(T) -> T
|
fn countOneBits<T: iu32>(T) -> T
|
||||||
fn countOneBits<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
|
fn countOneBits<N: num, T: iu32>(vec<N, T>) -> vec<N, T>
|
||||||
fn cross(vec3<f32>, vec3<f32>) -> vec3<f32>
|
fn cross(vec3<f32>, vec3<f32>) -> vec3<f32>
|
||||||
|
|
|
@ -1751,6 +1751,46 @@ class ProgramBuilder {
|
||||||
Expr(std::forward<RHS>(rhs)));
|
Expr(std::forward<RHS>(rhs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @param lhs the left hand argument to the greater than operation
|
||||||
|
/// @param rhs the right hand argument to the greater than operation
|
||||||
|
/// @returns a `ast::BinaryExpression` of `lhs` > `rhs`
|
||||||
|
template <typename LHS, typename RHS>
|
||||||
|
const ast::BinaryExpression* GreaterThan(LHS&& lhs, RHS&& rhs) {
|
||||||
|
return create<ast::BinaryExpression>(ast::BinaryOp::kGreaterThan,
|
||||||
|
Expr(std::forward<LHS>(lhs)),
|
||||||
|
Expr(std::forward<RHS>(rhs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param lhs the left hand argument to the greater than or equal operation
|
||||||
|
/// @param rhs the right hand argument to the greater than or equal operation
|
||||||
|
/// @returns a `ast::BinaryExpression` of `lhs` >= `rhs`
|
||||||
|
template <typename LHS, typename RHS>
|
||||||
|
const ast::BinaryExpression* GreaterThanEqual(LHS&& lhs, RHS&& rhs) {
|
||||||
|
return create<ast::BinaryExpression>(ast::BinaryOp::kGreaterThanEqual,
|
||||||
|
Expr(std::forward<LHS>(lhs)),
|
||||||
|
Expr(std::forward<RHS>(rhs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param lhs the left hand argument to the less than operation
|
||||||
|
/// @param rhs the right hand argument to the less than operation
|
||||||
|
/// @returns a `ast::BinaryExpression` of `lhs` < `rhs`
|
||||||
|
template <typename LHS, typename RHS>
|
||||||
|
const ast::BinaryExpression* LessThan(LHS&& lhs, RHS&& rhs) {
|
||||||
|
return create<ast::BinaryExpression>(ast::BinaryOp::kLessThan,
|
||||||
|
Expr(std::forward<LHS>(lhs)),
|
||||||
|
Expr(std::forward<RHS>(rhs)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @param lhs the left hand argument to the less than or equal operation
|
||||||
|
/// @param rhs the right hand argument to the less than or equal operation
|
||||||
|
/// @returns a `ast::BinaryExpression` of `lhs` <= `rhs`
|
||||||
|
template <typename LHS, typename RHS>
|
||||||
|
const ast::BinaryExpression* LessThanEqual(LHS&& lhs, RHS&& rhs) {
|
||||||
|
return create<ast::BinaryExpression>(ast::BinaryOp::kLessThanEqual,
|
||||||
|
Expr(std::forward<LHS>(lhs)),
|
||||||
|
Expr(std::forward<RHS>(rhs)));
|
||||||
|
}
|
||||||
|
|
||||||
/// @param lhs the left hand argument to the equal expression
|
/// @param lhs the left hand argument to the equal expression
|
||||||
/// @param rhs the right hand argument to the equal expression
|
/// @param rhs the right hand argument to the equal expression
|
||||||
/// @returns a `ast::BinaryExpression` comparing `lhs` equal to `rhs`
|
/// @returns a `ast::BinaryExpression` comparing `lhs` equal to `rhs`
|
||||||
|
|
|
@ -66,6 +66,9 @@ BuiltinType ParseBuiltinType(const std::string& name) {
|
||||||
if (name == "cosh") {
|
if (name == "cosh") {
|
||||||
return BuiltinType::kCosh;
|
return BuiltinType::kCosh;
|
||||||
}
|
}
|
||||||
|
if (name == "countLeadingZeros") {
|
||||||
|
return BuiltinType::kCountLeadingZeros;
|
||||||
|
}
|
||||||
if (name == "countOneBits") {
|
if (name == "countOneBits") {
|
||||||
return BuiltinType::kCountOneBits;
|
return BuiltinType::kCountOneBits;
|
||||||
}
|
}
|
||||||
|
@ -367,6 +370,8 @@ const char* str(BuiltinType i) {
|
||||||
return "cos";
|
return "cos";
|
||||||
case BuiltinType::kCosh:
|
case BuiltinType::kCosh:
|
||||||
return "cosh";
|
return "cosh";
|
||||||
|
case BuiltinType::kCountLeadingZeros:
|
||||||
|
return "countLeadingZeros";
|
||||||
case BuiltinType::kCountOneBits:
|
case BuiltinType::kCountOneBits:
|
||||||
return "countOneBits";
|
return "countOneBits";
|
||||||
case BuiltinType::kCross:
|
case BuiltinType::kCross:
|
||||||
|
|
|
@ -46,6 +46,7 @@ enum class BuiltinType {
|
||||||
kClamp,
|
kClamp,
|
||||||
kCos,
|
kCos,
|
||||||
kCosh,
|
kCosh,
|
||||||
|
kCountLeadingZeros,
|
||||||
kCountOneBits,
|
kCountOneBits,
|
||||||
kCross,
|
kCross,
|
||||||
kDegrees,
|
kDegrees,
|
||||||
|
|
|
@ -0,0 +1,188 @@
|
||||||
|
// 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/builtin_polyfill.h"
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "src/tint/program_builder.h"
|
||||||
|
#include "src/tint/sem/builtin.h"
|
||||||
|
#include "src/tint/sem/call.h"
|
||||||
|
#include "src/tint/utils/map.h"
|
||||||
|
|
||||||
|
TINT_INSTANTIATE_TYPEINFO(tint::transform::BuiltinPolyfill);
|
||||||
|
TINT_INSTANTIATE_TYPEINFO(tint::transform::BuiltinPolyfill::Config);
|
||||||
|
|
||||||
|
namespace tint {
|
||||||
|
namespace transform {
|
||||||
|
|
||||||
|
/// The PIMPL state for the BuiltinPolyfill transform
|
||||||
|
struct BuiltinPolyfill::State {
|
||||||
|
/// Constructor
|
||||||
|
/// @param c the CloneContext
|
||||||
|
explicit State(CloneContext& c) : ctx(c) {}
|
||||||
|
|
||||||
|
/// The clone context
|
||||||
|
CloneContext& ctx;
|
||||||
|
/// The destination program builder
|
||||||
|
ProgramBuilder& b = *ctx.dst;
|
||||||
|
/// The source clone context
|
||||||
|
const sem::Info& sem = ctx.src->Sem();
|
||||||
|
|
||||||
|
/// Builds the polyfill function for the `countLeadingZeros` builtin
|
||||||
|
/// @param ty the parameter and return type for the function
|
||||||
|
/// @return the polyfill function name
|
||||||
|
Symbol countLeadingZeros(const sem::Type* ty) {
|
||||||
|
auto name = b.Symbols().New("tint_count_leading_zeros");
|
||||||
|
uint32_t width = 1;
|
||||||
|
if (auto* v = ty->As<sem::Vector>()) {
|
||||||
|
width = v->Width();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns either u32 or vecN<u32>
|
||||||
|
auto U = [&]() -> const ast::Type* {
|
||||||
|
if (width == 1) {
|
||||||
|
return b.ty.u32();
|
||||||
|
}
|
||||||
|
return b.ty.vec<ProgramBuilder::u32>(width);
|
||||||
|
};
|
||||||
|
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||||
|
if (width == 1) {
|
||||||
|
return b.Expr(value);
|
||||||
|
}
|
||||||
|
return b.Construct(b.ty.vec<ProgramBuilder::u32>(width), value);
|
||||||
|
};
|
||||||
|
b.Func(
|
||||||
|
name, {b.Param("v", T(ty))}, T(ty),
|
||||||
|
{
|
||||||
|
// var x = U(v);
|
||||||
|
b.Decl(b.Var("x", nullptr, b.Construct(U(), b.Expr("v")))),
|
||||||
|
// let b16 = select(0, 16, x <= 0x0000ffff);
|
||||||
|
b.Decl(b.Const("b16", nullptr,
|
||||||
|
b.Call("select", V(0), V(16),
|
||||||
|
b.LessThanEqual("x", V(0x0000ffff))))),
|
||||||
|
// x = x << b16;
|
||||||
|
b.Assign("x", b.Shl("x", "b16")),
|
||||||
|
// let b8 = select(0, 8, x <= 0x00ffffff);
|
||||||
|
b.Decl(b.Const("b8", nullptr,
|
||||||
|
b.Call("select", V(0), V(8),
|
||||||
|
b.LessThanEqual("x", V(0x00ffffff))))),
|
||||||
|
// x = x << b8;
|
||||||
|
b.Assign("x", b.Shl("x", "b8")),
|
||||||
|
// let b4 = select(0, 4, x <= 0x0fffffff);
|
||||||
|
b.Decl(b.Const("b4", nullptr,
|
||||||
|
b.Call("select", V(0), V(4),
|
||||||
|
b.LessThanEqual("x", V(0x0fffffff))))),
|
||||||
|
// x = x << b4;
|
||||||
|
b.Assign("x", b.Shl("x", "b4")),
|
||||||
|
// let b2 = select(0, 2, x <= 0x3fffffff);
|
||||||
|
b.Decl(b.Const("b2", nullptr,
|
||||||
|
b.Call("select", V(0), V(2),
|
||||||
|
b.LessThanEqual("x", V(0x3fffffff))))),
|
||||||
|
// x = x << b2;
|
||||||
|
b.Assign("x", b.Shl("x", "b2")),
|
||||||
|
// let b1 = select(0, 1, x <= 0x7fffffff);
|
||||||
|
b.Decl(b.Const("b1", nullptr,
|
||||||
|
b.Call("select", V(0), V(1),
|
||||||
|
b.LessThanEqual("x", V(0x7fffffff))))),
|
||||||
|
// let is_zero = select(0, 1, x == 0);
|
||||||
|
b.Decl(b.Const("is_zero", nullptr,
|
||||||
|
b.Call("select", V(0), V(1), b.Equal("x", V(0))))),
|
||||||
|
// return R((b16 | b8 | b4 | b2 | b1) + zero);
|
||||||
|
b.Return(b.Construct(
|
||||||
|
T(ty),
|
||||||
|
b.Add(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"),
|
||||||
|
"is_zero"))),
|
||||||
|
});
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const ast::Type* T(const sem::Type* ty) { return CreateASTTypeFor(ctx, ty); }
|
||||||
|
};
|
||||||
|
|
||||||
|
BuiltinPolyfill::BuiltinPolyfill() = default;
|
||||||
|
|
||||||
|
BuiltinPolyfill::~BuiltinPolyfill() = default;
|
||||||
|
|
||||||
|
bool BuiltinPolyfill::ShouldRun(const Program* program,
|
||||||
|
const DataMap& data) const {
|
||||||
|
if (auto* cfg = data.Get<Config>()) {
|
||||||
|
auto builtins = cfg->builtins;
|
||||||
|
auto& sem = program->Sem();
|
||||||
|
for (auto* node : program->ASTNodes().Objects()) {
|
||||||
|
if (auto* call = sem.Get<sem::Call>(node)) {
|
||||||
|
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
|
||||||
|
switch (builtin->Type()) {
|
||||||
|
case sem::BuiltinType::kCountLeadingZeros:
|
||||||
|
if (builtins.count_leading_zeros) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuiltinPolyfill::Run(CloneContext& ctx,
|
||||||
|
const DataMap& data,
|
||||||
|
DataMap&) const {
|
||||||
|
auto* cfg = data.Get<Config>();
|
||||||
|
if (!cfg) {
|
||||||
|
ctx.Clone();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unordered_map<const sem::Builtin*, Symbol> polyfills;
|
||||||
|
|
||||||
|
ctx.ReplaceAll(
|
||||||
|
[&](const ast::CallExpression* expr) -> const ast::CallExpression* {
|
||||||
|
auto builtins = cfg->builtins;
|
||||||
|
State s{ctx};
|
||||||
|
if (auto* call = s.sem.Get<sem::Call>(expr)) {
|
||||||
|
if (auto* builtin = call->Target()->As<sem::Builtin>()) {
|
||||||
|
Symbol polyfill;
|
||||||
|
switch (builtin->Type()) {
|
||||||
|
case sem::BuiltinType::kCountLeadingZeros:
|
||||||
|
if (builtins.count_leading_zeros) {
|
||||||
|
polyfill = utils::GetOrCreate(polyfills, builtin, [&] {
|
||||||
|
return s.countLeadingZeros(builtin->ReturnType());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (polyfill.IsValid()) {
|
||||||
|
return s.b.Call(polyfill, ctx.Clone(call->Declaration()->args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
});
|
||||||
|
|
||||||
|
ctx.Clone();
|
||||||
|
}
|
||||||
|
|
||||||
|
BuiltinPolyfill::Config::Config(const Builtins& b) : builtins(b) {}
|
||||||
|
BuiltinPolyfill::Config::Config(const Config&) = default;
|
||||||
|
BuiltinPolyfill::Config::~Config() = default;
|
||||||
|
|
||||||
|
} // namespace transform
|
||||||
|
} // namespace tint
|
|
@ -0,0 +1,77 @@
|
||||||
|
// 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_BUILTIN_POLYFILL_H_
|
||||||
|
#define SRC_TINT_TRANSFORM_BUILTIN_POLYFILL_H_
|
||||||
|
|
||||||
|
#include "src/tint/transform/transform.h"
|
||||||
|
|
||||||
|
namespace tint {
|
||||||
|
namespace transform {
|
||||||
|
|
||||||
|
/// Implements builtins for backends that do not have a native implementation.
|
||||||
|
class BuiltinPolyfill : public Castable<BuiltinPolyfill, Transform> {
|
||||||
|
public:
|
||||||
|
/// Constructor
|
||||||
|
BuiltinPolyfill();
|
||||||
|
/// Destructor
|
||||||
|
~BuiltinPolyfill() override;
|
||||||
|
|
||||||
|
/// Specifies the builtins that should be polyfilled by the transform.
|
||||||
|
struct Builtins {
|
||||||
|
/// Should `countLeadingZeros()` be polyfilled?
|
||||||
|
bool count_leading_zeros = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Config is consumed by the BuiltinPolyfill transform.
|
||||||
|
/// Config specifies the builtins that should be polyfilled.
|
||||||
|
struct Config : public Castable<Data, transform::Data> {
|
||||||
|
/// Constructor
|
||||||
|
/// @param b the list of builtins to polyfill
|
||||||
|
explicit Config(const Builtins& b);
|
||||||
|
|
||||||
|
/// Copy constructor
|
||||||
|
Config(const Config&);
|
||||||
|
|
||||||
|
/// Destructor
|
||||||
|
~Config() override;
|
||||||
|
|
||||||
|
/// The builtins to polyfill
|
||||||
|
const Builtins builtins;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @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:
|
||||||
|
struct State;
|
||||||
|
|
||||||
|
/// 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 transform
|
||||||
|
} // namespace tint
|
||||||
|
|
||||||
|
#endif // SRC_TINT_TRANSFORM_BUILTIN_POLYFILL_H_
|
|
@ -0,0 +1,199 @@
|
||||||
|
// 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/builtin_polyfill.h"
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include "src/tint/transform/test_helper.h"
|
||||||
|
|
||||||
|
namespace tint {
|
||||||
|
namespace transform {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using BuiltinPolyfillTest = TransformTest;
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, ShouldRunEmptyModule) {
|
||||||
|
auto* src = R"()";
|
||||||
|
|
||||||
|
EXPECT_FALSE(ShouldRun<BuiltinPolyfill>(src));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, EmptyModule) {
|
||||||
|
auto* src = R"()";
|
||||||
|
|
||||||
|
auto* expect = src;
|
||||||
|
|
||||||
|
auto got = Run<BuiltinPolyfill>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// countLeadingZeros
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
DataMap polyfillCountLeadingZeros() {
|
||||||
|
BuiltinPolyfill::Builtins builtins;
|
||||||
|
builtins.count_leading_zeros = true;
|
||||||
|
DataMap data;
|
||||||
|
data.Add<BuiltinPolyfill::Config>(builtins);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, ShouldRunCountLeadingZeros) {
|
||||||
|
auto* src = R"(
|
||||||
|
fn f() {
|
||||||
|
countLeadingZeros(0xf);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
EXPECT_FALSE(ShouldRun<BuiltinPolyfill>(src));
|
||||||
|
EXPECT_TRUE(ShouldRun<BuiltinPolyfill>(src, polyfillCountLeadingZeros()));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_i32) {
|
||||||
|
auto* src = R"(
|
||||||
|
fn f() {
|
||||||
|
let r : i32 = countLeadingZeros(15);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto* expect = R"(
|
||||||
|
fn tint_count_leading_zeros(v : i32) -> i32 {
|
||||||
|
var x = u32(v);
|
||||||
|
let b16 = select(0u, 16u, (x <= 65535u));
|
||||||
|
x = (x << b16);
|
||||||
|
let b8 = select(0u, 8u, (x <= 16777215u));
|
||||||
|
x = (x << b8);
|
||||||
|
let b4 = select(0u, 4u, (x <= 268435455u));
|
||||||
|
x = (x << b4);
|
||||||
|
let b2 = select(0u, 2u, (x <= 1073741823u));
|
||||||
|
x = (x << b2);
|
||||||
|
let b1 = select(0u, 1u, (x <= 2147483647u));
|
||||||
|
let is_zero = select(0u, 1u, (x == 0u));
|
||||||
|
return i32((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
let r : i32 = tint_count_leading_zeros(15);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<BuiltinPolyfill>(src, polyfillCountLeadingZeros());
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_u32) {
|
||||||
|
auto* src = R"(
|
||||||
|
fn f() {
|
||||||
|
let r : u32 = countLeadingZeros(15u);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto* expect = R"(
|
||||||
|
fn tint_count_leading_zeros(v : u32) -> u32 {
|
||||||
|
var x = u32(v);
|
||||||
|
let b16 = select(0u, 16u, (x <= 65535u));
|
||||||
|
x = (x << b16);
|
||||||
|
let b8 = select(0u, 8u, (x <= 16777215u));
|
||||||
|
x = (x << b8);
|
||||||
|
let b4 = select(0u, 4u, (x <= 268435455u));
|
||||||
|
x = (x << b4);
|
||||||
|
let b2 = select(0u, 2u, (x <= 1073741823u));
|
||||||
|
x = (x << b2);
|
||||||
|
let b1 = select(0u, 1u, (x <= 2147483647u));
|
||||||
|
let is_zero = select(0u, 1u, (x == 0u));
|
||||||
|
return u32((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
let r : u32 = tint_count_leading_zeros(15u);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<BuiltinPolyfill>(src, polyfillCountLeadingZeros());
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_vec3_i32) {
|
||||||
|
auto* src = R"(
|
||||||
|
fn f() {
|
||||||
|
let r : vec3<i32> = countLeadingZeros(vec3<i32>(15));
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto* expect = R"(
|
||||||
|
fn tint_count_leading_zeros(v : vec3<i32>) -> vec3<i32> {
|
||||||
|
var x = vec3<u32>(v);
|
||||||
|
let b16 = select(vec3<u32>(0u), vec3<u32>(16u), (x <= vec3<u32>(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
let b8 = select(vec3<u32>(0u), vec3<u32>(8u), (x <= vec3<u32>(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
let b4 = select(vec3<u32>(0u), vec3<u32>(4u), (x <= vec3<u32>(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
let b2 = select(vec3<u32>(0u), vec3<u32>(2u), (x <= vec3<u32>(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
let b1 = select(vec3<u32>(0u), vec3<u32>(1u), (x <= vec3<u32>(2147483647u)));
|
||||||
|
let is_zero = select(vec3<u32>(0u), vec3<u32>(1u), (x == vec3<u32>(0u)));
|
||||||
|
return vec3<i32>((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
let r : vec3<i32> = tint_count_leading_zeros(vec3<i32>(15));
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<BuiltinPolyfill>(src, polyfillCountLeadingZeros());
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuiltinPolyfillTest, CountLeadingZeros_vec3_u32) {
|
||||||
|
auto* src = R"(
|
||||||
|
fn f() {
|
||||||
|
let r : vec3<u32> = countLeadingZeros(vec3<u32>(15u));
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto* expect = R"(
|
||||||
|
fn tint_count_leading_zeros(v : vec3<u32>) -> vec3<u32> {
|
||||||
|
var x = vec3<u32>(v);
|
||||||
|
let b16 = select(vec3<u32>(0u), vec3<u32>(16u), (x <= vec3<u32>(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
let b8 = select(vec3<u32>(0u), vec3<u32>(8u), (x <= vec3<u32>(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
let b4 = select(vec3<u32>(0u), vec3<u32>(4u), (x <= vec3<u32>(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
let b2 = select(vec3<u32>(0u), vec3<u32>(2u), (x <= vec3<u32>(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
let b1 = select(vec3<u32>(0u), vec3<u32>(1u), (x <= vec3<u32>(2147483647u)));
|
||||||
|
let is_zero = select(vec3<u32>(0u), vec3<u32>(1u), (x == vec3<u32>(0u)));
|
||||||
|
return vec3<u32>((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
let r : vec3<u32> = tint_count_leading_zeros(vec3<u32>(15u));
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<BuiltinPolyfill>(src, polyfillCountLeadingZeros());
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace transform
|
||||||
|
} // namespace tint
|
|
@ -20,6 +20,7 @@
|
||||||
#include "src/tint/transform/add_empty_entry_point.h"
|
#include "src/tint/transform/add_empty_entry_point.h"
|
||||||
#include "src/tint/transform/add_spirv_block_attribute.h"
|
#include "src/tint/transform/add_spirv_block_attribute.h"
|
||||||
#include "src/tint/transform/binding_remapper.h"
|
#include "src/tint/transform/binding_remapper.h"
|
||||||
|
#include "src/tint/transform/builtin_polyfill.h"
|
||||||
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
||||||
#include "src/tint/transform/combine_samplers.h"
|
#include "src/tint/transform/combine_samplers.h"
|
||||||
#include "src/tint/transform/decompose_memory_access.h"
|
#include "src/tint/transform/decompose_memory_access.h"
|
||||||
|
@ -51,6 +52,13 @@ Output Glsl::Run(const Program* in, const DataMap& inputs) const {
|
||||||
|
|
||||||
auto* cfg = inputs.Get<Config>();
|
auto* cfg = inputs.Get<Config>();
|
||||||
|
|
||||||
|
{ // Builtin polyfills
|
||||||
|
BuiltinPolyfill::Builtins polyfills;
|
||||||
|
polyfills.count_leading_zeros = true;
|
||||||
|
data.Add<BuiltinPolyfill::Config>(polyfills);
|
||||||
|
manager.Add<BuiltinPolyfill>();
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg && !cfg->entry_point.empty()) {
|
if (cfg && !cfg->entry_point.empty()) {
|
||||||
manager.Add<SingleEntryPoint>();
|
manager.Add<SingleEntryPoint>();
|
||||||
data.Add<SingleEntryPoint::Config>(cfg->entry_point);
|
data.Add<SingleEntryPoint::Config>(cfg->entry_point);
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "src/tint/sem/variable.h"
|
#include "src/tint/sem/variable.h"
|
||||||
#include "src/tint/transform/add_empty_entry_point.h"
|
#include "src/tint/transform/add_empty_entry_point.h"
|
||||||
#include "src/tint/transform/array_length_from_uniform.h"
|
#include "src/tint/transform/array_length_from_uniform.h"
|
||||||
|
#include "src/tint/transform/builtin_polyfill.h"
|
||||||
#include "src/tint/transform/calculate_array_length.h"
|
#include "src/tint/transform/calculate_array_length.h"
|
||||||
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
||||||
#include "src/tint/transform/decompose_memory_access.h"
|
#include "src/tint/transform/decompose_memory_access.h"
|
||||||
|
@ -140,6 +141,13 @@ SanitizedResult Sanitize(
|
||||||
transform::Manager manager;
|
transform::Manager manager;
|
||||||
transform::DataMap data;
|
transform::DataMap data;
|
||||||
|
|
||||||
|
{ // Builtin polyfills
|
||||||
|
transform::BuiltinPolyfill::Builtins polyfills;
|
||||||
|
polyfills.count_leading_zeros = true;
|
||||||
|
data.Add<transform::BuiltinPolyfill::Config>(polyfills);
|
||||||
|
manager.Add<transform::BuiltinPolyfill>();
|
||||||
|
}
|
||||||
|
|
||||||
// Build the config for the internal ArrayLengthFromUniform transform.
|
// Build the config for the internal ArrayLengthFromUniform transform.
|
||||||
transform::ArrayLengthFromUniform::Config array_length_from_uniform_cfg(
|
transform::ArrayLengthFromUniform::Config array_length_from_uniform_cfg(
|
||||||
array_length_from_uniform.ubo_binding);
|
array_length_from_uniform.ubo_binding);
|
||||||
|
|
|
@ -1345,6 +1345,9 @@ std::string GeneratorImpl::generate_builtin_name(const sem::Builtin* builtin) {
|
||||||
out += "abs";
|
out += "abs";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case sem::BuiltinType::kCountLeadingZeros:
|
||||||
|
out += "clz";
|
||||||
|
break;
|
||||||
case sem::BuiltinType::kCountOneBits:
|
case sem::BuiltinType::kCountOneBits:
|
||||||
out += "popcount";
|
out += "popcount";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -124,6 +124,7 @@ const ast::CallExpression* GenerateCall(BuiltinType builtin,
|
||||||
} else {
|
} else {
|
||||||
return builder->Call(str.str(), "u2");
|
return builder->Call(str.str(), "u2");
|
||||||
}
|
}
|
||||||
|
case BuiltinType::kCountLeadingZeros:
|
||||||
case BuiltinType::kCountOneBits:
|
case BuiltinType::kCountOneBits:
|
||||||
case BuiltinType::kReverseBits:
|
case BuiltinType::kReverseBits:
|
||||||
return builder->Call(str.str(), "u2");
|
return builder->Call(str.str(), "u2");
|
||||||
|
@ -212,6 +213,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
BuiltinData{BuiltinType::kClamp, ParamType::kU32, "clamp"},
|
BuiltinData{BuiltinType::kClamp, ParamType::kU32, "clamp"},
|
||||||
BuiltinData{BuiltinType::kCos, ParamType::kF32, "cos"},
|
BuiltinData{BuiltinType::kCos, ParamType::kF32, "cos"},
|
||||||
BuiltinData{BuiltinType::kCosh, ParamType::kF32, "cosh"},
|
BuiltinData{BuiltinType::kCosh, ParamType::kF32, "cosh"},
|
||||||
|
BuiltinData{BuiltinType::kCountLeadingZeros, ParamType::kU32, "clz"},
|
||||||
BuiltinData{BuiltinType::kCountOneBits, ParamType::kU32, "popcount"},
|
BuiltinData{BuiltinType::kCountOneBits, ParamType::kU32, "popcount"},
|
||||||
BuiltinData{BuiltinType::kCross, ParamType::kF32, "cross"},
|
BuiltinData{BuiltinType::kCross, ParamType::kF32, "cross"},
|
||||||
BuiltinData{BuiltinType::kDeterminant, ParamType::kF32, "determinant"},
|
BuiltinData{BuiltinType::kDeterminant, ParamType::kF32, "determinant"},
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "src/tint/sem/vector_type.h"
|
#include "src/tint/sem/vector_type.h"
|
||||||
#include "src/tint/transform/add_empty_entry_point.h"
|
#include "src/tint/transform/add_empty_entry_point.h"
|
||||||
#include "src/tint/transform/add_spirv_block_attribute.h"
|
#include "src/tint/transform/add_spirv_block_attribute.h"
|
||||||
|
#include "src/tint/transform/builtin_polyfill.h"
|
||||||
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
#include "src/tint/transform/canonicalize_entry_point_io.h"
|
||||||
#include "src/tint/transform/external_texture_transform.h"
|
#include "src/tint/transform/external_texture_transform.h"
|
||||||
#include "src/tint/transform/fold_constants.h"
|
#include "src/tint/transform/fold_constants.h"
|
||||||
|
@ -258,6 +259,13 @@ SanitizedResult Sanitize(const Program* in,
|
||||||
transform::Manager manager;
|
transform::Manager manager;
|
||||||
transform::DataMap data;
|
transform::DataMap data;
|
||||||
|
|
||||||
|
{ // Builtin polyfills
|
||||||
|
transform::BuiltinPolyfill::Builtins polyfills;
|
||||||
|
polyfills.count_leading_zeros = true;
|
||||||
|
data.Add<transform::BuiltinPolyfill::Config>(polyfills);
|
||||||
|
manager.Add<transform::BuiltinPolyfill>();
|
||||||
|
}
|
||||||
|
|
||||||
manager.Add<transform::Unshadow>();
|
manager.Add<transform::Unshadow>();
|
||||||
if (!disable_workgroup_init) {
|
if (!disable_workgroup_init) {
|
||||||
manager.Add<transform::ZeroInitWorkgroupMemory>();
|
manager.Add<transform::ZeroInitWorkgroupMemory>();
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(u32) -> u32
|
||||||
|
fn countLeadingZeros_208d46() {
|
||||||
|
var res: u32 = countLeadingZeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(i32) -> i32
|
||||||
|
fn countLeadingZeros_6d4656() {
|
||||||
|
var res: i32 = countLeadingZeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<2, u32>) -> vec<2, u32>
|
||||||
|
fn countLeadingZeros_70783f() {
|
||||||
|
var res: vec2<u32> = countLeadingZeros(vec2<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<3, i32>) -> vec<3, i32>
|
||||||
|
fn countLeadingZeros_7c38a6() {
|
||||||
|
var res: vec3<i32> = countLeadingZeros(vec3<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<2, i32>) -> vec<2, i32>
|
||||||
|
fn countLeadingZeros_858d40() {
|
||||||
|
var res: vec2<i32> = countLeadingZeros(vec2<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<3, u32>) -> vec<3, u32>
|
||||||
|
fn countLeadingZeros_ab6345() {
|
||||||
|
var res: vec3<u32> = countLeadingZeros(vec3<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<4, i32>) -> vec<4, i32>
|
||||||
|
fn countLeadingZeros_eab32b() {
|
||||||
|
var res: vec4<i32> = countLeadingZeros(vec4<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<4, u32>) -> vec<4, u32>
|
||||||
|
fn countLeadingZeros_f70103() {
|
||||||
|
var res: vec4<u32> = countLeadingZeros(vec4<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
|
@ -310,6 +310,7 @@ tint_unittests_source_set("tint_unittests_transform_src") {
|
||||||
"../../src/tint/transform/add_empty_entry_point_test.cc",
|
"../../src/tint/transform/add_empty_entry_point_test.cc",
|
||||||
"../../src/tint/transform/add_spirv_block_attribute_test.cc",
|
"../../src/tint/transform/add_spirv_block_attribute_test.cc",
|
||||||
"../../src/tint/transform/array_length_from_uniform_test.cc",
|
"../../src/tint/transform/array_length_from_uniform_test.cc",
|
||||||
|
"../../src/tint/transform/builtin_polyfill_test.cc",
|
||||||
"../../src/tint/transform/binding_remapper_test.cc",
|
"../../src/tint/transform/binding_remapper_test.cc",
|
||||||
"../../src/tint/transform/calculate_array_length_test.cc",
|
"../../src/tint/transform/calculate_array_length_test.cc",
|
||||||
"../../src/tint/transform/canonicalize_entry_point_io_test.cc",
|
"../../src/tint/transform/canonicalize_entry_point_io_test.cc",
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(u32) -> u32
|
||||||
|
fn countLeadingZeros_208d46() {
|
||||||
|
var res: u32 = countLeadingZeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uint tint_count_leading_zeros(uint v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_208d46() {
|
||||||
|
uint res = tint_count_leading_zeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
uint tint_count_leading_zeros(uint v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_208d46() {
|
||||||
|
uint res = tint_count_leading_zeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uint tint_count_leading_zeros(uint v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_208d46() {
|
||||||
|
uint res = tint_count_leading_zeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
uint tint_count_leading_zeros(uint v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
const uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
const uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
const uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
const uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
const uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
const uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return uint((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_208d46() {
|
||||||
|
uint res = tint_count_leading_zeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_208d46() {
|
||||||
|
uint res = clz(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,124 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 82
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_208d46 "countLeadingZeros_208d46"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%9 = OpTypeFunction %uint %uint
|
||||||
|
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||||
|
%17 = OpConstantNull %uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%62 = OpTypeFunction %void
|
||||||
|
%68 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %uint None %9
|
||||||
|
%v = OpFunctionParameter %uint
|
||||||
|
%13 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_uint Function %17
|
||||||
|
OpStore %x %v
|
||||||
|
%19 = OpLoad %uint %x
|
||||||
|
%21 = OpULessThanEqual %bool %19 %uint_65535
|
||||||
|
%18 = OpSelect %uint %21 %uint_16 %uint_0
|
||||||
|
%25 = OpLoad %uint %x
|
||||||
|
%26 = OpShiftLeftLogical %uint %25 %18
|
||||||
|
OpStore %x %26
|
||||||
|
%28 = OpLoad %uint %x
|
||||||
|
%30 = OpULessThanEqual %bool %28 %uint_16777215
|
||||||
|
%27 = OpSelect %uint %30 %uint_8 %uint_0
|
||||||
|
%32 = OpLoad %uint %x
|
||||||
|
%33 = OpShiftLeftLogical %uint %32 %27
|
||||||
|
OpStore %x %33
|
||||||
|
%35 = OpLoad %uint %x
|
||||||
|
%37 = OpULessThanEqual %bool %35 %uint_268435455
|
||||||
|
%34 = OpSelect %uint %37 %uint_4 %uint_0
|
||||||
|
%39 = OpLoad %uint %x
|
||||||
|
%40 = OpShiftLeftLogical %uint %39 %34
|
||||||
|
OpStore %x %40
|
||||||
|
%42 = OpLoad %uint %x
|
||||||
|
%44 = OpULessThanEqual %bool %42 %uint_1073741823
|
||||||
|
%41 = OpSelect %uint %44 %uint_2 %uint_0
|
||||||
|
%46 = OpLoad %uint %x
|
||||||
|
%47 = OpShiftLeftLogical %uint %46 %41
|
||||||
|
OpStore %x %47
|
||||||
|
%49 = OpLoad %uint %x
|
||||||
|
%51 = OpULessThanEqual %bool %49 %uint_2147483647
|
||||||
|
%48 = OpSelect %uint %51 %uint_1 %uint_0
|
||||||
|
%54 = OpLoad %uint %x
|
||||||
|
%55 = OpIEqual %bool %54 %uint_0
|
||||||
|
%53 = OpSelect %uint %55 %uint_1 %uint_0
|
||||||
|
%57 = OpBitwiseOr %uint %18 %27
|
||||||
|
%58 = OpBitwiseOr %uint %57 %34
|
||||||
|
%59 = OpBitwiseOr %uint %58 %41
|
||||||
|
%60 = OpBitwiseOr %uint %59 %48
|
||||||
|
%61 = OpIAdd %uint %60 %53
|
||||||
|
OpReturnValue %61
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_208d46 = OpFunction %void None %62
|
||||||
|
%65 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_uint Function %17
|
||||||
|
%66 = OpFunctionCall %uint %tint_count_leading_zeros %uint_1
|
||||||
|
OpStore %res %66
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %68
|
||||||
|
%70 = OpLabel
|
||||||
|
%71 = OpFunctionCall %void %countLeadingZeros_208d46
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %62
|
||||||
|
%73 = OpLabel
|
||||||
|
%74 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %74
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %62
|
||||||
|
%77 = OpLabel
|
||||||
|
%78 = OpFunctionCall %void %countLeadingZeros_208d46
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %62
|
||||||
|
%80 = OpLabel
|
||||||
|
%81 = OpFunctionCall %void %countLeadingZeros_208d46
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_208d46() {
|
||||||
|
var res : u32 = countLeadingZeros(1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_208d46();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(i32) -> i32
|
||||||
|
fn countLeadingZeros_6d4656() {
|
||||||
|
var res: i32 = countLeadingZeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
int tint_count_leading_zeros(int v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_6d4656() {
|
||||||
|
int res = tint_count_leading_zeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
int tint_count_leading_zeros(int v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_6d4656() {
|
||||||
|
int res = tint_count_leading_zeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
int tint_count_leading_zeros(int v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_6d4656() {
|
||||||
|
int res = tint_count_leading_zeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
int tint_count_leading_zeros(int v) {
|
||||||
|
uint x = uint(v);
|
||||||
|
const uint b16 = ((x <= 65535u) ? 16u : 0u);
|
||||||
|
x = (x << b16);
|
||||||
|
const uint b8 = ((x <= 16777215u) ? 8u : 0u);
|
||||||
|
x = (x << b8);
|
||||||
|
const uint b4 = ((x <= 268435455u) ? 4u : 0u);
|
||||||
|
x = (x << b4);
|
||||||
|
const uint b2 = ((x <= 1073741823u) ? 2u : 0u);
|
||||||
|
x = (x << b2);
|
||||||
|
const uint b1 = ((x <= 2147483647u) ? 1u : 0u);
|
||||||
|
const uint is_zero = ((x == 0u) ? 1u : 0u);
|
||||||
|
return int((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_6d4656() {
|
||||||
|
int res = tint_count_leading_zeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_6d4656() {
|
||||||
|
int res = clz(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,130 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 86
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_6d4656 "countLeadingZeros_6d4656"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%9 = OpTypeFunction %int %int
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%_ptr_Function_uint = OpTypePointer Function %uint
|
||||||
|
%18 = OpConstantNull %uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%63 = OpTypeFunction %void
|
||||||
|
%int_1 = OpConstant %int 1
|
||||||
|
%_ptr_Function_int = OpTypePointer Function %int
|
||||||
|
%71 = OpConstantNull %int
|
||||||
|
%72 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %int None %9
|
||||||
|
%v = OpFunctionParameter %int
|
||||||
|
%13 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_uint Function %18
|
||||||
|
%14 = OpBitcast %uint %v
|
||||||
|
OpStore %x %14
|
||||||
|
%20 = OpLoad %uint %x
|
||||||
|
%22 = OpULessThanEqual %bool %20 %uint_65535
|
||||||
|
%19 = OpSelect %uint %22 %uint_16 %uint_0
|
||||||
|
%26 = OpLoad %uint %x
|
||||||
|
%27 = OpShiftLeftLogical %uint %26 %19
|
||||||
|
OpStore %x %27
|
||||||
|
%29 = OpLoad %uint %x
|
||||||
|
%31 = OpULessThanEqual %bool %29 %uint_16777215
|
||||||
|
%28 = OpSelect %uint %31 %uint_8 %uint_0
|
||||||
|
%33 = OpLoad %uint %x
|
||||||
|
%34 = OpShiftLeftLogical %uint %33 %28
|
||||||
|
OpStore %x %34
|
||||||
|
%36 = OpLoad %uint %x
|
||||||
|
%38 = OpULessThanEqual %bool %36 %uint_268435455
|
||||||
|
%35 = OpSelect %uint %38 %uint_4 %uint_0
|
||||||
|
%40 = OpLoad %uint %x
|
||||||
|
%41 = OpShiftLeftLogical %uint %40 %35
|
||||||
|
OpStore %x %41
|
||||||
|
%43 = OpLoad %uint %x
|
||||||
|
%45 = OpULessThanEqual %bool %43 %uint_1073741823
|
||||||
|
%42 = OpSelect %uint %45 %uint_2 %uint_0
|
||||||
|
%47 = OpLoad %uint %x
|
||||||
|
%48 = OpShiftLeftLogical %uint %47 %42
|
||||||
|
OpStore %x %48
|
||||||
|
%50 = OpLoad %uint %x
|
||||||
|
%52 = OpULessThanEqual %bool %50 %uint_2147483647
|
||||||
|
%49 = OpSelect %uint %52 %uint_1 %uint_0
|
||||||
|
%55 = OpLoad %uint %x
|
||||||
|
%56 = OpIEqual %bool %55 %uint_0
|
||||||
|
%54 = OpSelect %uint %56 %uint_1 %uint_0
|
||||||
|
%58 = OpBitwiseOr %uint %19 %28
|
||||||
|
%59 = OpBitwiseOr %uint %58 %35
|
||||||
|
%60 = OpBitwiseOr %uint %59 %42
|
||||||
|
%61 = OpBitwiseOr %uint %60 %49
|
||||||
|
%62 = OpIAdd %uint %61 %54
|
||||||
|
%57 = OpBitcast %int %62
|
||||||
|
OpReturnValue %57
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_6d4656 = OpFunction %void None %63
|
||||||
|
%66 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_int Function %71
|
||||||
|
%67 = OpFunctionCall %int %tint_count_leading_zeros %int_1
|
||||||
|
OpStore %res %67
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %72
|
||||||
|
%74 = OpLabel
|
||||||
|
%75 = OpFunctionCall %void %countLeadingZeros_6d4656
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %63
|
||||||
|
%77 = OpLabel
|
||||||
|
%78 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %78
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %63
|
||||||
|
%81 = OpLabel
|
||||||
|
%82 = OpFunctionCall %void %countLeadingZeros_6d4656
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %63
|
||||||
|
%84 = OpLabel
|
||||||
|
%85 = OpFunctionCall %void %countLeadingZeros_6d4656
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_6d4656() {
|
||||||
|
var res : i32 = countLeadingZeros(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_6d4656();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<2, u32>) -> vec<2, u32>
|
||||||
|
fn countLeadingZeros_70783f() {
|
||||||
|
var res: vec2<u32> = countLeadingZeros(vec2<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uvec2 tint_count_leading_zeros(uvec2 v) {
|
||||||
|
uvec2 x = uvec2(v);
|
||||||
|
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
|
||||||
|
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
|
||||||
|
return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_70783f() {
|
||||||
|
uvec2 res = tint_count_leading_zeros(uvec2(0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
uvec2 tint_count_leading_zeros(uvec2 v) {
|
||||||
|
uvec2 x = uvec2(v);
|
||||||
|
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
|
||||||
|
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
|
||||||
|
return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_70783f() {
|
||||||
|
uvec2 res = tint_count_leading_zeros(uvec2(0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uvec2 tint_count_leading_zeros(uvec2 v) {
|
||||||
|
uvec2 x = uvec2(v);
|
||||||
|
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
|
||||||
|
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
|
||||||
|
return uvec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_70783f() {
|
||||||
|
uvec2 res = tint_count_leading_zeros(uvec2(0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
uint2 tint_count_leading_zeros(uint2 v) {
|
||||||
|
uint2 x = uint2(v);
|
||||||
|
const uint2 b16 = ((x <= uint2((65535u).xx)) ? uint2((16u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b16);
|
||||||
|
const uint2 b8 = ((x <= uint2((16777215u).xx)) ? uint2((8u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b8);
|
||||||
|
const uint2 b4 = ((x <= uint2((268435455u).xx)) ? uint2((4u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b4);
|
||||||
|
const uint2 b2 = ((x <= uint2((1073741823u).xx)) ? uint2((2u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b2);
|
||||||
|
const uint2 b1 = ((x <= uint2((2147483647u).xx)) ? uint2((1u).xx) : uint2((0u).xx));
|
||||||
|
const uint2 is_zero = ((x == uint2((0u).xx)) ? uint2((1u).xx) : uint2((0u).xx));
|
||||||
|
return uint2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_70783f() {
|
||||||
|
uint2 res = tint_count_leading_zeros(uint2(0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_70783f() {
|
||||||
|
uint2 res = clz(uint2());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 95
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_70783f "countLeadingZeros_70783f"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%v2uint = OpTypeVector %uint 2
|
||||||
|
%9 = OpTypeFunction %v2uint %v2uint
|
||||||
|
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
|
||||||
|
%18 = OpConstantNull %v2uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%22 = OpConstantComposite %v2uint %uint_65535 %uint_65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%v2bool = OpTypeVector %bool 2
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%27 = OpConstantComposite %v2uint %uint_16 %uint_16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%29 = OpConstantComposite %v2uint %uint_0 %uint_0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%35 = OpConstantComposite %v2uint %uint_16777215 %uint_16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%38 = OpConstantComposite %v2uint %uint_8 %uint_8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%44 = OpConstantComposite %v2uint %uint_268435455 %uint_268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%47 = OpConstantComposite %v2uint %uint_4 %uint_4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%53 = OpConstantComposite %v2uint %uint_1073741823 %uint_1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%56 = OpConstantComposite %v2uint %uint_2 %uint_2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%62 = OpConstantComposite %v2uint %uint_2147483647 %uint_2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%65 = OpConstantComposite %v2uint %uint_1 %uint_1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%75 = OpTypeFunction %void
|
||||||
|
%81 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %v2uint None %9
|
||||||
|
%v = OpFunctionParameter %v2uint
|
||||||
|
%14 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_v2uint Function %18
|
||||||
|
OpStore %x %v
|
||||||
|
%20 = OpLoad %v2uint %x
|
||||||
|
%23 = OpULessThanEqual %v2bool %20 %22
|
||||||
|
%19 = OpSelect %v2uint %23 %27 %29
|
||||||
|
%30 = OpLoad %v2uint %x
|
||||||
|
%31 = OpShiftLeftLogical %v2uint %30 %19
|
||||||
|
OpStore %x %31
|
||||||
|
%33 = OpLoad %v2uint %x
|
||||||
|
%36 = OpULessThanEqual %v2bool %33 %35
|
||||||
|
%32 = OpSelect %v2uint %36 %38 %29
|
||||||
|
%39 = OpLoad %v2uint %x
|
||||||
|
%40 = OpShiftLeftLogical %v2uint %39 %32
|
||||||
|
OpStore %x %40
|
||||||
|
%42 = OpLoad %v2uint %x
|
||||||
|
%45 = OpULessThanEqual %v2bool %42 %44
|
||||||
|
%41 = OpSelect %v2uint %45 %47 %29
|
||||||
|
%48 = OpLoad %v2uint %x
|
||||||
|
%49 = OpShiftLeftLogical %v2uint %48 %41
|
||||||
|
OpStore %x %49
|
||||||
|
%51 = OpLoad %v2uint %x
|
||||||
|
%54 = OpULessThanEqual %v2bool %51 %53
|
||||||
|
%50 = OpSelect %v2uint %54 %56 %29
|
||||||
|
%57 = OpLoad %v2uint %x
|
||||||
|
%58 = OpShiftLeftLogical %v2uint %57 %50
|
||||||
|
OpStore %x %58
|
||||||
|
%60 = OpLoad %v2uint %x
|
||||||
|
%63 = OpULessThanEqual %v2bool %60 %62
|
||||||
|
%59 = OpSelect %v2uint %63 %65 %29
|
||||||
|
%67 = OpLoad %v2uint %x
|
||||||
|
%68 = OpIEqual %v2bool %67 %29
|
||||||
|
%66 = OpSelect %v2uint %68 %65 %29
|
||||||
|
%70 = OpBitwiseOr %v2uint %19 %32
|
||||||
|
%71 = OpBitwiseOr %v2uint %70 %41
|
||||||
|
%72 = OpBitwiseOr %v2uint %71 %50
|
||||||
|
%73 = OpBitwiseOr %v2uint %72 %59
|
||||||
|
%74 = OpIAdd %v2uint %73 %66
|
||||||
|
OpReturnValue %74
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_70783f = OpFunction %void None %75
|
||||||
|
%78 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_v2uint Function %18
|
||||||
|
%79 = OpFunctionCall %v2uint %tint_count_leading_zeros %18
|
||||||
|
OpStore %res %79
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %81
|
||||||
|
%83 = OpLabel
|
||||||
|
%84 = OpFunctionCall %void %countLeadingZeros_70783f
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %75
|
||||||
|
%86 = OpLabel
|
||||||
|
%87 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %87
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %75
|
||||||
|
%90 = OpLabel
|
||||||
|
%91 = OpFunctionCall %void %countLeadingZeros_70783f
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %75
|
||||||
|
%93 = OpLabel
|
||||||
|
%94 = OpFunctionCall %void %countLeadingZeros_70783f
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_70783f() {
|
||||||
|
var res : vec2<u32> = countLeadingZeros(vec2<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_70783f();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<3, i32>) -> vec<3, i32>
|
||||||
|
fn countLeadingZeros_7c38a6() {
|
||||||
|
var res: vec3<i32> = countLeadingZeros(vec3<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
ivec3 tint_count_leading_zeros(ivec3 v) {
|
||||||
|
uvec3 x = uvec3(v);
|
||||||
|
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
|
||||||
|
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
|
||||||
|
return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_7c38a6() {
|
||||||
|
ivec3 res = tint_count_leading_zeros(ivec3(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
ivec3 tint_count_leading_zeros(ivec3 v) {
|
||||||
|
uvec3 x = uvec3(v);
|
||||||
|
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
|
||||||
|
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
|
||||||
|
return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_7c38a6() {
|
||||||
|
ivec3 res = tint_count_leading_zeros(ivec3(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
ivec3 tint_count_leading_zeros(ivec3 v) {
|
||||||
|
uvec3 x = uvec3(v);
|
||||||
|
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
|
||||||
|
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
|
||||||
|
return ivec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_7c38a6() {
|
||||||
|
ivec3 res = tint_count_leading_zeros(ivec3(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
int3 tint_count_leading_zeros(int3 v) {
|
||||||
|
uint3 x = uint3(v);
|
||||||
|
const uint3 b16 = ((x <= uint3((65535u).xxx)) ? uint3((16u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b16);
|
||||||
|
const uint3 b8 = ((x <= uint3((16777215u).xxx)) ? uint3((8u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b8);
|
||||||
|
const uint3 b4 = ((x <= uint3((268435455u).xxx)) ? uint3((4u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b4);
|
||||||
|
const uint3 b2 = ((x <= uint3((1073741823u).xxx)) ? uint3((2u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b2);
|
||||||
|
const uint3 b1 = ((x <= uint3((2147483647u).xxx)) ? uint3((1u).xxx) : uint3((0u).xxx));
|
||||||
|
const uint3 is_zero = ((x == uint3((0u).xxx)) ? uint3((1u).xxx) : uint3((0u).xxx));
|
||||||
|
return int3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_7c38a6() {
|
||||||
|
int3 res = tint_count_leading_zeros(int3(0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_7c38a6() {
|
||||||
|
int3 res = clz(int3());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 99
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_7c38a6 "countLeadingZeros_7c38a6"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v3int = OpTypeVector %int 3
|
||||||
|
%9 = OpTypeFunction %v3int %v3int
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%v3uint = OpTypeVector %uint 3
|
||||||
|
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||||
|
%20 = OpConstantNull %v3uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%24 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%v3bool = OpTypeVector %bool 3
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%29 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%31 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%37 = OpConstantComposite %v3uint %uint_16777215 %uint_16777215 %uint_16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%40 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%46 = OpConstantComposite %v3uint %uint_268435455 %uint_268435455 %uint_268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%49 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%55 = OpConstantComposite %v3uint %uint_1073741823 %uint_1073741823 %uint_1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%58 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%64 = OpConstantComposite %v3uint %uint_2147483647 %uint_2147483647 %uint_2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%67 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%77 = OpTypeFunction %void
|
||||||
|
%82 = OpConstantNull %v3int
|
||||||
|
%_ptr_Function_v3int = OpTypePointer Function %v3int
|
||||||
|
%85 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %v3int None %9
|
||||||
|
%v = OpFunctionParameter %v3int
|
||||||
|
%14 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_v3uint Function %20
|
||||||
|
%15 = OpBitcast %v3uint %v
|
||||||
|
OpStore %x %15
|
||||||
|
%22 = OpLoad %v3uint %x
|
||||||
|
%25 = OpULessThanEqual %v3bool %22 %24
|
||||||
|
%21 = OpSelect %v3uint %25 %29 %31
|
||||||
|
%32 = OpLoad %v3uint %x
|
||||||
|
%33 = OpShiftLeftLogical %v3uint %32 %21
|
||||||
|
OpStore %x %33
|
||||||
|
%35 = OpLoad %v3uint %x
|
||||||
|
%38 = OpULessThanEqual %v3bool %35 %37
|
||||||
|
%34 = OpSelect %v3uint %38 %40 %31
|
||||||
|
%41 = OpLoad %v3uint %x
|
||||||
|
%42 = OpShiftLeftLogical %v3uint %41 %34
|
||||||
|
OpStore %x %42
|
||||||
|
%44 = OpLoad %v3uint %x
|
||||||
|
%47 = OpULessThanEqual %v3bool %44 %46
|
||||||
|
%43 = OpSelect %v3uint %47 %49 %31
|
||||||
|
%50 = OpLoad %v3uint %x
|
||||||
|
%51 = OpShiftLeftLogical %v3uint %50 %43
|
||||||
|
OpStore %x %51
|
||||||
|
%53 = OpLoad %v3uint %x
|
||||||
|
%56 = OpULessThanEqual %v3bool %53 %55
|
||||||
|
%52 = OpSelect %v3uint %56 %58 %31
|
||||||
|
%59 = OpLoad %v3uint %x
|
||||||
|
%60 = OpShiftLeftLogical %v3uint %59 %52
|
||||||
|
OpStore %x %60
|
||||||
|
%62 = OpLoad %v3uint %x
|
||||||
|
%65 = OpULessThanEqual %v3bool %62 %64
|
||||||
|
%61 = OpSelect %v3uint %65 %67 %31
|
||||||
|
%69 = OpLoad %v3uint %x
|
||||||
|
%70 = OpIEqual %v3bool %69 %31
|
||||||
|
%68 = OpSelect %v3uint %70 %67 %31
|
||||||
|
%72 = OpBitwiseOr %v3uint %21 %34
|
||||||
|
%73 = OpBitwiseOr %v3uint %72 %43
|
||||||
|
%74 = OpBitwiseOr %v3uint %73 %52
|
||||||
|
%75 = OpBitwiseOr %v3uint %74 %61
|
||||||
|
%76 = OpIAdd %v3uint %75 %68
|
||||||
|
%71 = OpBitcast %v3int %76
|
||||||
|
OpReturnValue %71
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_7c38a6 = OpFunction %void None %77
|
||||||
|
%80 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_v3int Function %82
|
||||||
|
%81 = OpFunctionCall %v3int %tint_count_leading_zeros %82
|
||||||
|
OpStore %res %81
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %85
|
||||||
|
%87 = OpLabel
|
||||||
|
%88 = OpFunctionCall %void %countLeadingZeros_7c38a6
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %77
|
||||||
|
%90 = OpLabel
|
||||||
|
%91 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %91
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %77
|
||||||
|
%94 = OpLabel
|
||||||
|
%95 = OpFunctionCall %void %countLeadingZeros_7c38a6
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %77
|
||||||
|
%97 = OpLabel
|
||||||
|
%98 = OpFunctionCall %void %countLeadingZeros_7c38a6
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_7c38a6() {
|
||||||
|
var res : vec3<i32> = countLeadingZeros(vec3<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_7c38a6();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<2, i32>) -> vec<2, i32>
|
||||||
|
fn countLeadingZeros_858d40() {
|
||||||
|
var res: vec2<i32> = countLeadingZeros(vec2<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
ivec2 tint_count_leading_zeros(ivec2 v) {
|
||||||
|
uvec2 x = uvec2(v);
|
||||||
|
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
|
||||||
|
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
|
||||||
|
return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_858d40() {
|
||||||
|
ivec2 res = tint_count_leading_zeros(ivec2(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
ivec2 tint_count_leading_zeros(ivec2 v) {
|
||||||
|
uvec2 x = uvec2(v);
|
||||||
|
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
|
||||||
|
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
|
||||||
|
return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_858d40() {
|
||||||
|
ivec2 res = tint_count_leading_zeros(ivec2(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
ivec2 tint_count_leading_zeros(ivec2 v) {
|
||||||
|
uvec2 x = uvec2(v);
|
||||||
|
uvec2 b16 = mix(uvec2(0u), uvec2(16u), lessThanEqual(x, uvec2(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec2 b8 = mix(uvec2(0u), uvec2(8u), lessThanEqual(x, uvec2(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec2 b4 = mix(uvec2(0u), uvec2(4u), lessThanEqual(x, uvec2(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec2 b2 = mix(uvec2(0u), uvec2(2u), lessThanEqual(x, uvec2(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec2 b1 = mix(uvec2(0u), uvec2(1u), lessThanEqual(x, uvec2(2147483647u)));
|
||||||
|
uvec2 is_zero = mix(uvec2(0u), uvec2(1u), equal(x, uvec2(0u)));
|
||||||
|
return ivec2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_858d40() {
|
||||||
|
ivec2 res = tint_count_leading_zeros(ivec2(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
int2 tint_count_leading_zeros(int2 v) {
|
||||||
|
uint2 x = uint2(v);
|
||||||
|
const uint2 b16 = ((x <= uint2((65535u).xx)) ? uint2((16u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b16);
|
||||||
|
const uint2 b8 = ((x <= uint2((16777215u).xx)) ? uint2((8u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b8);
|
||||||
|
const uint2 b4 = ((x <= uint2((268435455u).xx)) ? uint2((4u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b4);
|
||||||
|
const uint2 b2 = ((x <= uint2((1073741823u).xx)) ? uint2((2u).xx) : uint2((0u).xx));
|
||||||
|
x = (x << b2);
|
||||||
|
const uint2 b1 = ((x <= uint2((2147483647u).xx)) ? uint2((1u).xx) : uint2((0u).xx));
|
||||||
|
const uint2 is_zero = ((x == uint2((0u).xx)) ? uint2((1u).xx) : uint2((0u).xx));
|
||||||
|
return int2((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_858d40() {
|
||||||
|
int2 res = tint_count_leading_zeros(int2(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_858d40() {
|
||||||
|
int2 res = clz(int2());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 99
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_858d40 "countLeadingZeros_858d40"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v2int = OpTypeVector %int 2
|
||||||
|
%9 = OpTypeFunction %v2int %v2int
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%v2uint = OpTypeVector %uint 2
|
||||||
|
%_ptr_Function_v2uint = OpTypePointer Function %v2uint
|
||||||
|
%20 = OpConstantNull %v2uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%24 = OpConstantComposite %v2uint %uint_65535 %uint_65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%v2bool = OpTypeVector %bool 2
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%29 = OpConstantComposite %v2uint %uint_16 %uint_16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%31 = OpConstantComposite %v2uint %uint_0 %uint_0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%37 = OpConstantComposite %v2uint %uint_16777215 %uint_16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%40 = OpConstantComposite %v2uint %uint_8 %uint_8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%46 = OpConstantComposite %v2uint %uint_268435455 %uint_268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%49 = OpConstantComposite %v2uint %uint_4 %uint_4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%55 = OpConstantComposite %v2uint %uint_1073741823 %uint_1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%58 = OpConstantComposite %v2uint %uint_2 %uint_2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%64 = OpConstantComposite %v2uint %uint_2147483647 %uint_2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%67 = OpConstantComposite %v2uint %uint_1 %uint_1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%77 = OpTypeFunction %void
|
||||||
|
%82 = OpConstantNull %v2int
|
||||||
|
%_ptr_Function_v2int = OpTypePointer Function %v2int
|
||||||
|
%85 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %v2int None %9
|
||||||
|
%v = OpFunctionParameter %v2int
|
||||||
|
%14 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_v2uint Function %20
|
||||||
|
%15 = OpBitcast %v2uint %v
|
||||||
|
OpStore %x %15
|
||||||
|
%22 = OpLoad %v2uint %x
|
||||||
|
%25 = OpULessThanEqual %v2bool %22 %24
|
||||||
|
%21 = OpSelect %v2uint %25 %29 %31
|
||||||
|
%32 = OpLoad %v2uint %x
|
||||||
|
%33 = OpShiftLeftLogical %v2uint %32 %21
|
||||||
|
OpStore %x %33
|
||||||
|
%35 = OpLoad %v2uint %x
|
||||||
|
%38 = OpULessThanEqual %v2bool %35 %37
|
||||||
|
%34 = OpSelect %v2uint %38 %40 %31
|
||||||
|
%41 = OpLoad %v2uint %x
|
||||||
|
%42 = OpShiftLeftLogical %v2uint %41 %34
|
||||||
|
OpStore %x %42
|
||||||
|
%44 = OpLoad %v2uint %x
|
||||||
|
%47 = OpULessThanEqual %v2bool %44 %46
|
||||||
|
%43 = OpSelect %v2uint %47 %49 %31
|
||||||
|
%50 = OpLoad %v2uint %x
|
||||||
|
%51 = OpShiftLeftLogical %v2uint %50 %43
|
||||||
|
OpStore %x %51
|
||||||
|
%53 = OpLoad %v2uint %x
|
||||||
|
%56 = OpULessThanEqual %v2bool %53 %55
|
||||||
|
%52 = OpSelect %v2uint %56 %58 %31
|
||||||
|
%59 = OpLoad %v2uint %x
|
||||||
|
%60 = OpShiftLeftLogical %v2uint %59 %52
|
||||||
|
OpStore %x %60
|
||||||
|
%62 = OpLoad %v2uint %x
|
||||||
|
%65 = OpULessThanEqual %v2bool %62 %64
|
||||||
|
%61 = OpSelect %v2uint %65 %67 %31
|
||||||
|
%69 = OpLoad %v2uint %x
|
||||||
|
%70 = OpIEqual %v2bool %69 %31
|
||||||
|
%68 = OpSelect %v2uint %70 %67 %31
|
||||||
|
%72 = OpBitwiseOr %v2uint %21 %34
|
||||||
|
%73 = OpBitwiseOr %v2uint %72 %43
|
||||||
|
%74 = OpBitwiseOr %v2uint %73 %52
|
||||||
|
%75 = OpBitwiseOr %v2uint %74 %61
|
||||||
|
%76 = OpIAdd %v2uint %75 %68
|
||||||
|
%71 = OpBitcast %v2int %76
|
||||||
|
OpReturnValue %71
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_858d40 = OpFunction %void None %77
|
||||||
|
%80 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_v2int Function %82
|
||||||
|
%81 = OpFunctionCall %v2int %tint_count_leading_zeros %82
|
||||||
|
OpStore %res %81
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %85
|
||||||
|
%87 = OpLabel
|
||||||
|
%88 = OpFunctionCall %void %countLeadingZeros_858d40
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %77
|
||||||
|
%90 = OpLabel
|
||||||
|
%91 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %91
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %77
|
||||||
|
%94 = OpLabel
|
||||||
|
%95 = OpFunctionCall %void %countLeadingZeros_858d40
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %77
|
||||||
|
%97 = OpLabel
|
||||||
|
%98 = OpFunctionCall %void %countLeadingZeros_858d40
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_858d40() {
|
||||||
|
var res : vec2<i32> = countLeadingZeros(vec2<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_858d40();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<3, u32>) -> vec<3, u32>
|
||||||
|
fn countLeadingZeros_ab6345() {
|
||||||
|
var res: vec3<u32> = countLeadingZeros(vec3<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uvec3 tint_count_leading_zeros(uvec3 v) {
|
||||||
|
uvec3 x = uvec3(v);
|
||||||
|
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
|
||||||
|
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
|
||||||
|
return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_ab6345() {
|
||||||
|
uvec3 res = tint_count_leading_zeros(uvec3(0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
uvec3 tint_count_leading_zeros(uvec3 v) {
|
||||||
|
uvec3 x = uvec3(v);
|
||||||
|
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
|
||||||
|
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
|
||||||
|
return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_ab6345() {
|
||||||
|
uvec3 res = tint_count_leading_zeros(uvec3(0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uvec3 tint_count_leading_zeros(uvec3 v) {
|
||||||
|
uvec3 x = uvec3(v);
|
||||||
|
uvec3 b16 = mix(uvec3(0u), uvec3(16u), lessThanEqual(x, uvec3(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec3 b8 = mix(uvec3(0u), uvec3(8u), lessThanEqual(x, uvec3(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec3 b4 = mix(uvec3(0u), uvec3(4u), lessThanEqual(x, uvec3(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec3 b2 = mix(uvec3(0u), uvec3(2u), lessThanEqual(x, uvec3(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec3 b1 = mix(uvec3(0u), uvec3(1u), lessThanEqual(x, uvec3(2147483647u)));
|
||||||
|
uvec3 is_zero = mix(uvec3(0u), uvec3(1u), equal(x, uvec3(0u)));
|
||||||
|
return uvec3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_ab6345() {
|
||||||
|
uvec3 res = tint_count_leading_zeros(uvec3(0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
uint3 tint_count_leading_zeros(uint3 v) {
|
||||||
|
uint3 x = uint3(v);
|
||||||
|
const uint3 b16 = ((x <= uint3((65535u).xxx)) ? uint3((16u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b16);
|
||||||
|
const uint3 b8 = ((x <= uint3((16777215u).xxx)) ? uint3((8u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b8);
|
||||||
|
const uint3 b4 = ((x <= uint3((268435455u).xxx)) ? uint3((4u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b4);
|
||||||
|
const uint3 b2 = ((x <= uint3((1073741823u).xxx)) ? uint3((2u).xxx) : uint3((0u).xxx));
|
||||||
|
x = (x << b2);
|
||||||
|
const uint3 b1 = ((x <= uint3((2147483647u).xxx)) ? uint3((1u).xxx) : uint3((0u).xxx));
|
||||||
|
const uint3 is_zero = ((x == uint3((0u).xxx)) ? uint3((1u).xxx) : uint3((0u).xxx));
|
||||||
|
return uint3((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_ab6345() {
|
||||||
|
uint3 res = tint_count_leading_zeros(uint3(0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_ab6345() {
|
||||||
|
uint3 res = clz(uint3());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 95
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_ab6345 "countLeadingZeros_ab6345"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%v3uint = OpTypeVector %uint 3
|
||||||
|
%9 = OpTypeFunction %v3uint %v3uint
|
||||||
|
%_ptr_Function_v3uint = OpTypePointer Function %v3uint
|
||||||
|
%18 = OpConstantNull %v3uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%22 = OpConstantComposite %v3uint %uint_65535 %uint_65535 %uint_65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%v3bool = OpTypeVector %bool 3
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%27 = OpConstantComposite %v3uint %uint_16 %uint_16 %uint_16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%29 = OpConstantComposite %v3uint %uint_0 %uint_0 %uint_0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%35 = OpConstantComposite %v3uint %uint_16777215 %uint_16777215 %uint_16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%38 = OpConstantComposite %v3uint %uint_8 %uint_8 %uint_8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%44 = OpConstantComposite %v3uint %uint_268435455 %uint_268435455 %uint_268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%47 = OpConstantComposite %v3uint %uint_4 %uint_4 %uint_4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%53 = OpConstantComposite %v3uint %uint_1073741823 %uint_1073741823 %uint_1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%56 = OpConstantComposite %v3uint %uint_2 %uint_2 %uint_2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%62 = OpConstantComposite %v3uint %uint_2147483647 %uint_2147483647 %uint_2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%65 = OpConstantComposite %v3uint %uint_1 %uint_1 %uint_1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%75 = OpTypeFunction %void
|
||||||
|
%81 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %v3uint None %9
|
||||||
|
%v = OpFunctionParameter %v3uint
|
||||||
|
%14 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_v3uint Function %18
|
||||||
|
OpStore %x %v
|
||||||
|
%20 = OpLoad %v3uint %x
|
||||||
|
%23 = OpULessThanEqual %v3bool %20 %22
|
||||||
|
%19 = OpSelect %v3uint %23 %27 %29
|
||||||
|
%30 = OpLoad %v3uint %x
|
||||||
|
%31 = OpShiftLeftLogical %v3uint %30 %19
|
||||||
|
OpStore %x %31
|
||||||
|
%33 = OpLoad %v3uint %x
|
||||||
|
%36 = OpULessThanEqual %v3bool %33 %35
|
||||||
|
%32 = OpSelect %v3uint %36 %38 %29
|
||||||
|
%39 = OpLoad %v3uint %x
|
||||||
|
%40 = OpShiftLeftLogical %v3uint %39 %32
|
||||||
|
OpStore %x %40
|
||||||
|
%42 = OpLoad %v3uint %x
|
||||||
|
%45 = OpULessThanEqual %v3bool %42 %44
|
||||||
|
%41 = OpSelect %v3uint %45 %47 %29
|
||||||
|
%48 = OpLoad %v3uint %x
|
||||||
|
%49 = OpShiftLeftLogical %v3uint %48 %41
|
||||||
|
OpStore %x %49
|
||||||
|
%51 = OpLoad %v3uint %x
|
||||||
|
%54 = OpULessThanEqual %v3bool %51 %53
|
||||||
|
%50 = OpSelect %v3uint %54 %56 %29
|
||||||
|
%57 = OpLoad %v3uint %x
|
||||||
|
%58 = OpShiftLeftLogical %v3uint %57 %50
|
||||||
|
OpStore %x %58
|
||||||
|
%60 = OpLoad %v3uint %x
|
||||||
|
%63 = OpULessThanEqual %v3bool %60 %62
|
||||||
|
%59 = OpSelect %v3uint %63 %65 %29
|
||||||
|
%67 = OpLoad %v3uint %x
|
||||||
|
%68 = OpIEqual %v3bool %67 %29
|
||||||
|
%66 = OpSelect %v3uint %68 %65 %29
|
||||||
|
%70 = OpBitwiseOr %v3uint %19 %32
|
||||||
|
%71 = OpBitwiseOr %v3uint %70 %41
|
||||||
|
%72 = OpBitwiseOr %v3uint %71 %50
|
||||||
|
%73 = OpBitwiseOr %v3uint %72 %59
|
||||||
|
%74 = OpIAdd %v3uint %73 %66
|
||||||
|
OpReturnValue %74
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_ab6345 = OpFunction %void None %75
|
||||||
|
%78 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_v3uint Function %18
|
||||||
|
%79 = OpFunctionCall %v3uint %tint_count_leading_zeros %18
|
||||||
|
OpStore %res %79
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %81
|
||||||
|
%83 = OpLabel
|
||||||
|
%84 = OpFunctionCall %void %countLeadingZeros_ab6345
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %75
|
||||||
|
%86 = OpLabel
|
||||||
|
%87 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %87
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %75
|
||||||
|
%90 = OpLabel
|
||||||
|
%91 = OpFunctionCall %void %countLeadingZeros_ab6345
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %75
|
||||||
|
%93 = OpLabel
|
||||||
|
%94 = OpFunctionCall %void %countLeadingZeros_ab6345
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_ab6345() {
|
||||||
|
var res : vec3<u32> = countLeadingZeros(vec3<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_ab6345();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<4, i32>) -> vec<4, i32>
|
||||||
|
fn countLeadingZeros_eab32b() {
|
||||||
|
var res: vec4<i32> = countLeadingZeros(vec4<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
ivec4 tint_count_leading_zeros(ivec4 v) {
|
||||||
|
uvec4 x = uvec4(v);
|
||||||
|
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
|
||||||
|
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
|
||||||
|
return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_eab32b() {
|
||||||
|
ivec4 res = tint_count_leading_zeros(ivec4(0, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
ivec4 tint_count_leading_zeros(ivec4 v) {
|
||||||
|
uvec4 x = uvec4(v);
|
||||||
|
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
|
||||||
|
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
|
||||||
|
return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_eab32b() {
|
||||||
|
ivec4 res = tint_count_leading_zeros(ivec4(0, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
ivec4 tint_count_leading_zeros(ivec4 v) {
|
||||||
|
uvec4 x = uvec4(v);
|
||||||
|
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
|
||||||
|
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
|
||||||
|
return ivec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_eab32b() {
|
||||||
|
ivec4 res = tint_count_leading_zeros(ivec4(0, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
int4 tint_count_leading_zeros(int4 v) {
|
||||||
|
uint4 x = uint4(v);
|
||||||
|
const uint4 b16 = ((x <= uint4((65535u).xxxx)) ? uint4((16u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b16);
|
||||||
|
const uint4 b8 = ((x <= uint4((16777215u).xxxx)) ? uint4((8u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b8);
|
||||||
|
const uint4 b4 = ((x <= uint4((268435455u).xxxx)) ? uint4((4u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b4);
|
||||||
|
const uint4 b2 = ((x <= uint4((1073741823u).xxxx)) ? uint4((2u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b2);
|
||||||
|
const uint4 b1 = ((x <= uint4((2147483647u).xxxx)) ? uint4((1u).xxxx) : uint4((0u).xxxx));
|
||||||
|
const uint4 is_zero = ((x == uint4((0u).xxxx)) ? uint4((1u).xxxx) : uint4((0u).xxxx));
|
||||||
|
return int4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_eab32b() {
|
||||||
|
int4 res = tint_count_leading_zeros(int4(0, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_eab32b() {
|
||||||
|
int4 res = clz(int4());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,143 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 99
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_eab32b "countLeadingZeros_eab32b"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%int = OpTypeInt 32 1
|
||||||
|
%v4int = OpTypeVector %int 4
|
||||||
|
%9 = OpTypeFunction %v4int %v4int
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%v4uint = OpTypeVector %uint 4
|
||||||
|
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
|
||||||
|
%20 = OpConstantNull %v4uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%24 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%v4bool = OpTypeVector %bool 4
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%29 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%31 = OpConstantComposite %v4uint %uint_0 %uint_0 %uint_0 %uint_0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%37 = OpConstantComposite %v4uint %uint_16777215 %uint_16777215 %uint_16777215 %uint_16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%40 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%46 = OpConstantComposite %v4uint %uint_268435455 %uint_268435455 %uint_268435455 %uint_268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%49 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%55 = OpConstantComposite %v4uint %uint_1073741823 %uint_1073741823 %uint_1073741823 %uint_1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%58 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%64 = OpConstantComposite %v4uint %uint_2147483647 %uint_2147483647 %uint_2147483647 %uint_2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%67 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%77 = OpTypeFunction %void
|
||||||
|
%82 = OpConstantNull %v4int
|
||||||
|
%_ptr_Function_v4int = OpTypePointer Function %v4int
|
||||||
|
%85 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %v4int None %9
|
||||||
|
%v = OpFunctionParameter %v4int
|
||||||
|
%14 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_v4uint Function %20
|
||||||
|
%15 = OpBitcast %v4uint %v
|
||||||
|
OpStore %x %15
|
||||||
|
%22 = OpLoad %v4uint %x
|
||||||
|
%25 = OpULessThanEqual %v4bool %22 %24
|
||||||
|
%21 = OpSelect %v4uint %25 %29 %31
|
||||||
|
%32 = OpLoad %v4uint %x
|
||||||
|
%33 = OpShiftLeftLogical %v4uint %32 %21
|
||||||
|
OpStore %x %33
|
||||||
|
%35 = OpLoad %v4uint %x
|
||||||
|
%38 = OpULessThanEqual %v4bool %35 %37
|
||||||
|
%34 = OpSelect %v4uint %38 %40 %31
|
||||||
|
%41 = OpLoad %v4uint %x
|
||||||
|
%42 = OpShiftLeftLogical %v4uint %41 %34
|
||||||
|
OpStore %x %42
|
||||||
|
%44 = OpLoad %v4uint %x
|
||||||
|
%47 = OpULessThanEqual %v4bool %44 %46
|
||||||
|
%43 = OpSelect %v4uint %47 %49 %31
|
||||||
|
%50 = OpLoad %v4uint %x
|
||||||
|
%51 = OpShiftLeftLogical %v4uint %50 %43
|
||||||
|
OpStore %x %51
|
||||||
|
%53 = OpLoad %v4uint %x
|
||||||
|
%56 = OpULessThanEqual %v4bool %53 %55
|
||||||
|
%52 = OpSelect %v4uint %56 %58 %31
|
||||||
|
%59 = OpLoad %v4uint %x
|
||||||
|
%60 = OpShiftLeftLogical %v4uint %59 %52
|
||||||
|
OpStore %x %60
|
||||||
|
%62 = OpLoad %v4uint %x
|
||||||
|
%65 = OpULessThanEqual %v4bool %62 %64
|
||||||
|
%61 = OpSelect %v4uint %65 %67 %31
|
||||||
|
%69 = OpLoad %v4uint %x
|
||||||
|
%70 = OpIEqual %v4bool %69 %31
|
||||||
|
%68 = OpSelect %v4uint %70 %67 %31
|
||||||
|
%72 = OpBitwiseOr %v4uint %21 %34
|
||||||
|
%73 = OpBitwiseOr %v4uint %72 %43
|
||||||
|
%74 = OpBitwiseOr %v4uint %73 %52
|
||||||
|
%75 = OpBitwiseOr %v4uint %74 %61
|
||||||
|
%76 = OpIAdd %v4uint %75 %68
|
||||||
|
%71 = OpBitcast %v4int %76
|
||||||
|
OpReturnValue %71
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_eab32b = OpFunction %void None %77
|
||||||
|
%80 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_v4int Function %82
|
||||||
|
%81 = OpFunctionCall %v4int %tint_count_leading_zeros %82
|
||||||
|
OpStore %res %81
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %85
|
||||||
|
%87 = OpLabel
|
||||||
|
%88 = OpFunctionCall %void %countLeadingZeros_eab32b
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %77
|
||||||
|
%90 = OpLabel
|
||||||
|
%91 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %91
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %77
|
||||||
|
%94 = OpLabel
|
||||||
|
%95 = OpFunctionCall %void %countLeadingZeros_eab32b
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %77
|
||||||
|
%97 = OpLabel
|
||||||
|
%98 = OpFunctionCall %void %countLeadingZeros_eab32b
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_eab32b() {
|
||||||
|
var res : vec4<i32> = countLeadingZeros(vec4<i32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_eab32b();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// File generated by tools/builtin-gen
|
||||||
|
// using the template:
|
||||||
|
// test/tint/builtins/builtins.wgsl.tmpl
|
||||||
|
// and the builtin defintion file:
|
||||||
|
// src/tint/builtins.def
|
||||||
|
//
|
||||||
|
// Do not modify this file directly
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
// fn countLeadingZeros(vec<4, u32>) -> vec<4, u32>
|
||||||
|
fn countLeadingZeros_f70103() {
|
||||||
|
var res: vec4<u32> = countLeadingZeros(vec4<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
|
@ -0,0 +1,93 @@
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uvec4 tint_count_leading_zeros(uvec4 v) {
|
||||||
|
uvec4 x = uvec4(v);
|
||||||
|
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
|
||||||
|
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
|
||||||
|
return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_f70103() {
|
||||||
|
uvec4 res = tint_count_leading_zeros(uvec4(0u, 0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec4 vertex_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return vec4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 inner_result = vertex_main();
|
||||||
|
gl_Position = inner_result;
|
||||||
|
gl_Position.y = -(gl_Position.y);
|
||||||
|
gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
precision mediump float;
|
||||||
|
|
||||||
|
uvec4 tint_count_leading_zeros(uvec4 v) {
|
||||||
|
uvec4 x = uvec4(v);
|
||||||
|
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
|
||||||
|
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
|
||||||
|
return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_f70103() {
|
||||||
|
uvec4 res = tint_count_leading_zeros(uvec4(0u, 0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
fragment_main();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#version 310 es
|
||||||
|
|
||||||
|
uvec4 tint_count_leading_zeros(uvec4 v) {
|
||||||
|
uvec4 x = uvec4(v);
|
||||||
|
uvec4 b16 = mix(uvec4(0u), uvec4(16u), lessThanEqual(x, uvec4(65535u)));
|
||||||
|
x = (x << b16);
|
||||||
|
uvec4 b8 = mix(uvec4(0u), uvec4(8u), lessThanEqual(x, uvec4(16777215u)));
|
||||||
|
x = (x << b8);
|
||||||
|
uvec4 b4 = mix(uvec4(0u), uvec4(4u), lessThanEqual(x, uvec4(268435455u)));
|
||||||
|
x = (x << b4);
|
||||||
|
uvec4 b2 = mix(uvec4(0u), uvec4(2u), lessThanEqual(x, uvec4(1073741823u)));
|
||||||
|
x = (x << b2);
|
||||||
|
uvec4 b1 = mix(uvec4(0u), uvec4(1u), lessThanEqual(x, uvec4(2147483647u)));
|
||||||
|
uvec4 is_zero = mix(uvec4(0u), uvec4(1u), equal(x, uvec4(0u)));
|
||||||
|
return uvec4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_f70103() {
|
||||||
|
uvec4 res = tint_count_leading_zeros(uvec4(0u, 0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
||||||
|
|
||||||
|
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||||
|
void main() {
|
||||||
|
compute_main();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
uint4 tint_count_leading_zeros(uint4 v) {
|
||||||
|
uint4 x = uint4(v);
|
||||||
|
const uint4 b16 = ((x <= uint4((65535u).xxxx)) ? uint4((16u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b16);
|
||||||
|
const uint4 b8 = ((x <= uint4((16777215u).xxxx)) ? uint4((8u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b8);
|
||||||
|
const uint4 b4 = ((x <= uint4((268435455u).xxxx)) ? uint4((4u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b4);
|
||||||
|
const uint4 b2 = ((x <= uint4((1073741823u).xxxx)) ? uint4((2u).xxxx) : uint4((0u).xxxx));
|
||||||
|
x = (x << b2);
|
||||||
|
const uint4 b1 = ((x <= uint4((2147483647u).xxxx)) ? uint4((1u).xxxx) : uint4((0u).xxxx));
|
||||||
|
const uint4 is_zero = ((x == uint4((0u).xxxx)) ? uint4((1u).xxxx) : uint4((0u).xxxx));
|
||||||
|
return uint4((((((b16 | b8) | b4) | b2) | b1) + is_zero));
|
||||||
|
}
|
||||||
|
|
||||||
|
void countLeadingZeros_f70103() {
|
||||||
|
uint4 res = tint_count_leading_zeros(uint4(0u, 0u, 0u, 0u));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value : SV_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
tint_symbol vertex_main() {
|
||||||
|
const float4 inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = (tint_symbol)0;
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void compute_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
#include <metal_stdlib>
|
||||||
|
|
||||||
|
using namespace metal;
|
||||||
|
void countLeadingZeros_f70103() {
|
||||||
|
uint4 res = clz(uint4());
|
||||||
|
}
|
||||||
|
|
||||||
|
struct tint_symbol {
|
||||||
|
float4 value [[position]];
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 vertex_main_inner() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return float4();
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex tint_symbol vertex_main() {
|
||||||
|
float4 const inner_result = vertex_main_inner();
|
||||||
|
tint_symbol wrapper_result = {};
|
||||||
|
wrapper_result.value = inner_result;
|
||||||
|
return wrapper_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment void fragment_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kernel void compute_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
; SPIR-V
|
||||||
|
; Version: 1.3
|
||||||
|
; Generator: Google Tint Compiler; 0
|
||||||
|
; Bound: 95
|
||||||
|
; Schema: 0
|
||||||
|
OpCapability Shader
|
||||||
|
OpMemoryModel Logical GLSL450
|
||||||
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
OpEntryPoint GLCompute %compute_main "compute_main"
|
||||||
|
OpExecutionMode %fragment_main OriginUpperLeft
|
||||||
|
OpExecutionMode %compute_main LocalSize 1 1 1
|
||||||
|
OpName %value "value"
|
||||||
|
OpName %vertex_point_size "vertex_point_size"
|
||||||
|
OpName %tint_count_leading_zeros "tint_count_leading_zeros"
|
||||||
|
OpName %v "v"
|
||||||
|
OpName %x "x"
|
||||||
|
OpName %countLeadingZeros_f70103 "countLeadingZeros_f70103"
|
||||||
|
OpName %res "res"
|
||||||
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
OpName %vertex_main "vertex_main"
|
||||||
|
OpName %fragment_main "fragment_main"
|
||||||
|
OpName %compute_main "compute_main"
|
||||||
|
OpDecorate %value BuiltIn Position
|
||||||
|
OpDecorate %vertex_point_size BuiltIn PointSize
|
||||||
|
%float = OpTypeFloat 32
|
||||||
|
%v4float = OpTypeVector %float 4
|
||||||
|
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||||
|
%5 = OpConstantNull %v4float
|
||||||
|
%value = OpVariable %_ptr_Output_v4float Output %5
|
||||||
|
%_ptr_Output_float = OpTypePointer Output %float
|
||||||
|
%8 = OpConstantNull %float
|
||||||
|
%vertex_point_size = OpVariable %_ptr_Output_float Output %8
|
||||||
|
%uint = OpTypeInt 32 0
|
||||||
|
%v4uint = OpTypeVector %uint 4
|
||||||
|
%9 = OpTypeFunction %v4uint %v4uint
|
||||||
|
%_ptr_Function_v4uint = OpTypePointer Function %v4uint
|
||||||
|
%18 = OpConstantNull %v4uint
|
||||||
|
%uint_65535 = OpConstant %uint 65535
|
||||||
|
%22 = OpConstantComposite %v4uint %uint_65535 %uint_65535 %uint_65535 %uint_65535
|
||||||
|
%bool = OpTypeBool
|
||||||
|
%v4bool = OpTypeVector %bool 4
|
||||||
|
%uint_16 = OpConstant %uint 16
|
||||||
|
%27 = OpConstantComposite %v4uint %uint_16 %uint_16 %uint_16 %uint_16
|
||||||
|
%uint_0 = OpConstant %uint 0
|
||||||
|
%29 = OpConstantComposite %v4uint %uint_0 %uint_0 %uint_0 %uint_0
|
||||||
|
%uint_16777215 = OpConstant %uint 16777215
|
||||||
|
%35 = OpConstantComposite %v4uint %uint_16777215 %uint_16777215 %uint_16777215 %uint_16777215
|
||||||
|
%uint_8 = OpConstant %uint 8
|
||||||
|
%38 = OpConstantComposite %v4uint %uint_8 %uint_8 %uint_8 %uint_8
|
||||||
|
%uint_268435455 = OpConstant %uint 268435455
|
||||||
|
%44 = OpConstantComposite %v4uint %uint_268435455 %uint_268435455 %uint_268435455 %uint_268435455
|
||||||
|
%uint_4 = OpConstant %uint 4
|
||||||
|
%47 = OpConstantComposite %v4uint %uint_4 %uint_4 %uint_4 %uint_4
|
||||||
|
%uint_1073741823 = OpConstant %uint 1073741823
|
||||||
|
%53 = OpConstantComposite %v4uint %uint_1073741823 %uint_1073741823 %uint_1073741823 %uint_1073741823
|
||||||
|
%uint_2 = OpConstant %uint 2
|
||||||
|
%56 = OpConstantComposite %v4uint %uint_2 %uint_2 %uint_2 %uint_2
|
||||||
|
%uint_2147483647 = OpConstant %uint 2147483647
|
||||||
|
%62 = OpConstantComposite %v4uint %uint_2147483647 %uint_2147483647 %uint_2147483647 %uint_2147483647
|
||||||
|
%uint_1 = OpConstant %uint 1
|
||||||
|
%65 = OpConstantComposite %v4uint %uint_1 %uint_1 %uint_1 %uint_1
|
||||||
|
%void = OpTypeVoid
|
||||||
|
%75 = OpTypeFunction %void
|
||||||
|
%81 = OpTypeFunction %v4float
|
||||||
|
%float_1 = OpConstant %float 1
|
||||||
|
%tint_count_leading_zeros = OpFunction %v4uint None %9
|
||||||
|
%v = OpFunctionParameter %v4uint
|
||||||
|
%14 = OpLabel
|
||||||
|
%x = OpVariable %_ptr_Function_v4uint Function %18
|
||||||
|
OpStore %x %v
|
||||||
|
%20 = OpLoad %v4uint %x
|
||||||
|
%23 = OpULessThanEqual %v4bool %20 %22
|
||||||
|
%19 = OpSelect %v4uint %23 %27 %29
|
||||||
|
%30 = OpLoad %v4uint %x
|
||||||
|
%31 = OpShiftLeftLogical %v4uint %30 %19
|
||||||
|
OpStore %x %31
|
||||||
|
%33 = OpLoad %v4uint %x
|
||||||
|
%36 = OpULessThanEqual %v4bool %33 %35
|
||||||
|
%32 = OpSelect %v4uint %36 %38 %29
|
||||||
|
%39 = OpLoad %v4uint %x
|
||||||
|
%40 = OpShiftLeftLogical %v4uint %39 %32
|
||||||
|
OpStore %x %40
|
||||||
|
%42 = OpLoad %v4uint %x
|
||||||
|
%45 = OpULessThanEqual %v4bool %42 %44
|
||||||
|
%41 = OpSelect %v4uint %45 %47 %29
|
||||||
|
%48 = OpLoad %v4uint %x
|
||||||
|
%49 = OpShiftLeftLogical %v4uint %48 %41
|
||||||
|
OpStore %x %49
|
||||||
|
%51 = OpLoad %v4uint %x
|
||||||
|
%54 = OpULessThanEqual %v4bool %51 %53
|
||||||
|
%50 = OpSelect %v4uint %54 %56 %29
|
||||||
|
%57 = OpLoad %v4uint %x
|
||||||
|
%58 = OpShiftLeftLogical %v4uint %57 %50
|
||||||
|
OpStore %x %58
|
||||||
|
%60 = OpLoad %v4uint %x
|
||||||
|
%63 = OpULessThanEqual %v4bool %60 %62
|
||||||
|
%59 = OpSelect %v4uint %63 %65 %29
|
||||||
|
%67 = OpLoad %v4uint %x
|
||||||
|
%68 = OpIEqual %v4bool %67 %29
|
||||||
|
%66 = OpSelect %v4uint %68 %65 %29
|
||||||
|
%70 = OpBitwiseOr %v4uint %19 %32
|
||||||
|
%71 = OpBitwiseOr %v4uint %70 %41
|
||||||
|
%72 = OpBitwiseOr %v4uint %71 %50
|
||||||
|
%73 = OpBitwiseOr %v4uint %72 %59
|
||||||
|
%74 = OpIAdd %v4uint %73 %66
|
||||||
|
OpReturnValue %74
|
||||||
|
OpFunctionEnd
|
||||||
|
%countLeadingZeros_f70103 = OpFunction %void None %75
|
||||||
|
%78 = OpLabel
|
||||||
|
%res = OpVariable %_ptr_Function_v4uint Function %18
|
||||||
|
%79 = OpFunctionCall %v4uint %tint_count_leading_zeros %18
|
||||||
|
OpStore %res %79
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main_inner = OpFunction %v4float None %81
|
||||||
|
%83 = OpLabel
|
||||||
|
%84 = OpFunctionCall %void %countLeadingZeros_f70103
|
||||||
|
OpReturnValue %5
|
||||||
|
OpFunctionEnd
|
||||||
|
%vertex_main = OpFunction %void None %75
|
||||||
|
%86 = OpLabel
|
||||||
|
%87 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
|
OpStore %value %87
|
||||||
|
OpStore %vertex_point_size %float_1
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%fragment_main = OpFunction %void None %75
|
||||||
|
%90 = OpLabel
|
||||||
|
%91 = OpFunctionCall %void %countLeadingZeros_f70103
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %75
|
||||||
|
%93 = OpLabel
|
||||||
|
%94 = OpFunctionCall %void %countLeadingZeros_f70103
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
|
@ -0,0 +1,19 @@
|
||||||
|
fn countLeadingZeros_f70103() {
|
||||||
|
var res : vec4<u32> = countLeadingZeros(vec4<u32>());
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(vertex)
|
||||||
|
fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
return vec4<f32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(fragment)
|
||||||
|
fn fragment_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
||||||
|
|
||||||
|
@stage(compute) @workgroup_size(1)
|
||||||
|
fn compute_main() {
|
||||||
|
countLeadingZeros_f70103();
|
||||||
|
}
|
Loading…
Reference in New Issue