tint/transform: Simplify Renamer transform
Take advantage of the fact that all AST nodes now use an `ast::Identifier` instead of directly using Symbols. This will be important for ensuring that un-keyworded identifiers will be preserved. Bug: tint:1810 Change-Id: If5c3e9f00b4c1c14a6f11bd617bd8b895250fb7e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/119285 Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
parent
f973d514a1
commit
4e4cada291
|
@ -15,7 +15,6 @@
|
||||||
#include "src/tint/transform/renamer.h"
|
#include "src/tint/transform/renamer.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_set>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "src/tint/program_builder.h"
|
#include "src/tint/program_builder.h"
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
#include "src/tint/sem/type_conversion.h"
|
#include "src/tint/sem/type_conversion.h"
|
||||||
#include "src/tint/sem/type_initializer.h"
|
#include "src/tint/sem/type_initializer.h"
|
||||||
#include "src/tint/text/unicode.h"
|
#include "src/tint/text/unicode.h"
|
||||||
#include "src/tint/type/builtin.h"
|
|
||||||
|
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer);
|
TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer);
|
||||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer::Data);
|
TINT_INSTANTIATE_TYPEINFO(tint::transform::Renamer::Data);
|
||||||
|
@ -1258,28 +1256,21 @@ Renamer::~Renamer() = default;
|
||||||
Transform::ApplyResult Renamer::Apply(const Program* src,
|
Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||||
const DataMap& inputs,
|
const DataMap& inputs,
|
||||||
DataMap& outputs) const {
|
DataMap& outputs) const {
|
||||||
ProgramBuilder b;
|
utils::Hashset<Symbol, 16> global_decls;
|
||||||
CloneContext ctx{&b, src, /* auto_clone_symbols */ false};
|
for (auto* decl : src->AST().TypeDecls()) {
|
||||||
|
global_decls.Add(decl->name->symbol);
|
||||||
|
}
|
||||||
|
|
||||||
// Identifiers that need to keep their symbols preserved.
|
// Identifiers that need to keep their symbols preserved.
|
||||||
utils::Hashset<const ast::Identifier*, 8> preserved_identifiers;
|
utils::Hashset<const ast::Identifier*, 16> preserved_identifiers;
|
||||||
|
|
||||||
auto is_type_short_name = [&](const Symbol& symbol) {
|
|
||||||
auto name = src->Symbols().NameFor(symbol);
|
|
||||||
if (type::ParseBuiltin(name) != type::Builtin::kUndefined) {
|
|
||||||
// Identifier *looks* like a builtin type, but check that the builtin type isn't being
|
|
||||||
// shadowed with a user declared type.
|
|
||||||
for (auto* decl : src->AST().TypeDecls()) {
|
|
||||||
if (decl->name->symbol == symbol) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto* node : src->ASTNodes().Objects()) {
|
for (auto* node : src->ASTNodes().Objects()) {
|
||||||
|
auto preserve_if_builtin_type = [&](const ast::Identifier* ident) {
|
||||||
|
if (!global_decls.Contains(ident->symbol)) {
|
||||||
|
preserved_identifiers.Add(ident);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Switch(
|
Switch(
|
||||||
node,
|
node,
|
||||||
[&](const ast::MemberAccessorExpression* accessor) {
|
[&](const ast::MemberAccessorExpression* accessor) {
|
||||||
|
@ -1294,38 +1285,24 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[&](const ast::CallExpression* call) {
|
|
||||||
if (auto* ident = call->target.name) {
|
|
||||||
Switch(
|
|
||||||
src->Sem().Get(call)->UnwrapMaterialize()->As<sem::Call>()->Target(),
|
|
||||||
[&](const sem::Builtin*) { preserved_identifiers.Add(ident); },
|
|
||||||
[&](const sem::TypeConversion*) {
|
|
||||||
if (is_type_short_name(ident->symbol)) {
|
|
||||||
preserved_identifiers.Add(ident);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[&](const sem::TypeInitializer*) {
|
|
||||||
if (is_type_short_name(ident->symbol)) {
|
|
||||||
preserved_identifiers.Add(ident);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[&](const ast::DiagnosticAttribute* diagnostic) {
|
[&](const ast::DiagnosticAttribute* diagnostic) {
|
||||||
preserved_identifiers.Add(diagnostic->control.rule_name);
|
preserved_identifiers.Add(diagnostic->control.rule_name);
|
||||||
},
|
},
|
||||||
[&](const ast::DiagnosticDirective* diagnostic) {
|
[&](const ast::DiagnosticDirective* diagnostic) {
|
||||||
preserved_identifiers.Add(diagnostic->control.rule_name);
|
preserved_identifiers.Add(diagnostic->control.rule_name);
|
||||||
},
|
},
|
||||||
[&](const ast::TypeName* type_name) {
|
[&](const ast::TypeName* ty) { preserve_if_builtin_type(ty->name); },
|
||||||
if (is_type_short_name(type_name->name->symbol)) {
|
[&](const ast::CallExpression* call) {
|
||||||
preserved_identifiers.Add(type_name->name);
|
if (auto* ident = call->target.name) {
|
||||||
|
Switch(
|
||||||
|
src->Sem().Get(call)->UnwrapMaterialize()->As<sem::Call>()->Target(),
|
||||||
|
[&](const sem::Builtin*) { preserved_identifiers.Add(ident); },
|
||||||
|
[&](const sem::TypeConversion*) { preserve_if_builtin_type(ident); },
|
||||||
|
[&](const sem::TypeInitializer*) { preserve_if_builtin_type(ident); });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::Remappings remappings;
|
|
||||||
|
|
||||||
Target target = Target::kAll;
|
Target target = Target::kAll;
|
||||||
bool preserve_unicode = false;
|
bool preserve_unicode = false;
|
||||||
|
|
||||||
|
@ -1334,62 +1311,70 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||||
preserve_unicode = cfg->preserve_unicode;
|
preserve_unicode = cfg->preserve_unicode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.ReplaceAll([&](Symbol sym_in) {
|
// Returns true if the symbol should be renamed based on the input configuration settings.
|
||||||
auto name_in = src->Symbols().NameFor(sym_in);
|
auto should_rename = [&](Symbol symbol) {
|
||||||
if (preserve_unicode || text::utf8::IsASCII(name_in)) {
|
if (target == Target::kAll) {
|
||||||
switch (target) {
|
return true;
|
||||||
case Target::kAll:
|
|
||||||
// Always rename.
|
|
||||||
break;
|
|
||||||
case Target::kGlslKeywords:
|
|
||||||
if (!std::binary_search(kReservedKeywordsGLSL,
|
|
||||||
kReservedKeywordsGLSL +
|
|
||||||
sizeof(kReservedKeywordsGLSL) / sizeof(const char*),
|
|
||||||
name_in) &&
|
|
||||||
name_in.compare(0, 3, "gl_")) {
|
|
||||||
// No match, just reuse the original name.
|
|
||||||
return ctx.dst->Symbols().New(name_in);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Target::kHlslKeywords:
|
|
||||||
if (!std::binary_search(kReservedKeywordsHLSL,
|
|
||||||
kReservedKeywordsHLSL +
|
|
||||||
sizeof(kReservedKeywordsHLSL) / sizeof(const char*),
|
|
||||||
name_in)) {
|
|
||||||
// No match, just reuse the original name.
|
|
||||||
return ctx.dst->Symbols().New(name_in);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Target::kMslKeywords:
|
|
||||||
if (!std::binary_search(kReservedKeywordsMSL,
|
|
||||||
kReservedKeywordsMSL +
|
|
||||||
sizeof(kReservedKeywordsMSL) / sizeof(const char*),
|
|
||||||
name_in)) {
|
|
||||||
// No match, just reuse the original name.
|
|
||||||
return ctx.dst->Symbols().New(name_in);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
auto name = src->Symbols().NameFor(symbol);
|
||||||
|
if (!text::utf8::IsASCII(name)) {
|
||||||
|
// name is non-ascii. All of the backend keywords are ascii, so rename if we're not
|
||||||
|
// preserving unicode symbols.
|
||||||
|
return !preserve_unicode;
|
||||||
|
}
|
||||||
|
switch (target) {
|
||||||
|
case Target::kGlslKeywords:
|
||||||
|
return std::binary_search(kReservedKeywordsGLSL,
|
||||||
|
kReservedKeywordsGLSL +
|
||||||
|
sizeof(kReservedKeywordsGLSL) / sizeof(const char*),
|
||||||
|
name) ||
|
||||||
|
name.compare(0, 3, "gl_") == 0;
|
||||||
|
case Target::kHlslKeywords:
|
||||||
|
return std::binary_search(
|
||||||
|
kReservedKeywordsHLSL,
|
||||||
|
kReservedKeywordsHLSL + sizeof(kReservedKeywordsHLSL) / sizeof(const char*),
|
||||||
|
name);
|
||||||
|
case Target::kMslKeywords:
|
||||||
|
return std::binary_search(
|
||||||
|
kReservedKeywordsMSL,
|
||||||
|
kReservedKeywordsMSL + sizeof(kReservedKeywordsMSL) / sizeof(const char*),
|
||||||
|
name);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
auto sym_out = ctx.dst->Sym();
|
utils::Hashmap<Symbol, Symbol, 32> remappings;
|
||||||
remappings.emplace(name_in, ctx.dst->Symbols().NameFor(sym_out));
|
|
||||||
return sym_out;
|
ProgramBuilder b;
|
||||||
});
|
CloneContext ctx{&b, src, /* auto_clone_symbols */ false};
|
||||||
|
|
||||||
ctx.ReplaceAll([&](const ast::Identifier* ident) -> const ast::Identifier* {
|
ctx.ReplaceAll([&](const ast::Identifier* ident) -> const ast::Identifier* {
|
||||||
if (preserved_identifiers.Contains(ident)) {
|
const auto symbol = ident->symbol;
|
||||||
auto sym_in = ident->symbol;
|
if (preserved_identifiers.Contains(ident) || !should_rename(symbol)) {
|
||||||
auto str = src->Symbols().NameFor(sym_in);
|
return nullptr; // Preserve symbol
|
||||||
auto sym_out = b.Symbols().Register(str);
|
|
||||||
return ctx.dst->create<ast::Identifier>(ctx.Clone(ident->source), sym_out);
|
|
||||||
}
|
}
|
||||||
return nullptr; // Clone ident. Uses the symbol remapping above.
|
|
||||||
|
// Create a replacement for this symbol, if we haven't already.
|
||||||
|
auto replacement = remappings.GetOrCreate(symbol, [&] { return b.Symbols().New(); });
|
||||||
|
|
||||||
|
// Reconstruct the identifier
|
||||||
|
if (auto* tmpl_ident = ident->As<ast::TemplatedIdentifier>()) {
|
||||||
|
auto args = ctx.Clone(tmpl_ident->arguments);
|
||||||
|
return ctx.dst->create<ast::TemplatedIdentifier>(ctx.Clone(ident->source), replacement,
|
||||||
|
std::move(args));
|
||||||
|
}
|
||||||
|
return ctx.dst->create<ast::Identifier>(ctx.Clone(ident->source), replacement);
|
||||||
});
|
});
|
||||||
|
|
||||||
ctx.Clone(); // Must come before the std::move()
|
ctx.Clone();
|
||||||
|
|
||||||
outputs.Add<Data>(std::move(remappings));
|
Data::Remappings out;
|
||||||
|
for (auto it : remappings) {
|
||||||
|
out[ctx.src->Symbols().NameFor(it.key)] = ctx.dst->Symbols().NameFor(it.value);
|
||||||
|
}
|
||||||
|
outputs.Add<Data>(std::move(out));
|
||||||
|
|
||||||
return Program(std::move(b));
|
return Program(std::move(b));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,10 +15,13 @@
|
||||||
#include "src/tint/transform/renamer.h"
|
#include "src/tint/transform/renamer.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <unordered_set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "gmock/gmock.h"
|
#include "gmock/gmock.h"
|
||||||
#include "src/tint/transform/test_helper.h"
|
#include "src/tint/transform/test_helper.h"
|
||||||
#include "src/tint/type/builtin.h"
|
#include "src/tint/type/builtin.h"
|
||||||
|
#include "src/tint/type/texel_format.h"
|
||||||
|
|
||||||
namespace tint::transform {
|
namespace tint::transform {
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -250,6 +253,30 @@ fn frag_main() {
|
||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RenamerTest, PreserveUnicodeRenameAll) {
|
||||||
|
auto src = R"(
|
||||||
|
@fragment
|
||||||
|
fn frag_main() {
|
||||||
|
var )" + std::string(kUnicodeIdentifier) +
|
||||||
|
R"( : i32;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto expect = R"(
|
||||||
|
@fragment
|
||||||
|
fn tint_symbol() {
|
||||||
|
var tint_symbol_1 : i32;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
DataMap inputs;
|
||||||
|
inputs.Add<Renamer::Config>(Renamer::Target::kAll,
|
||||||
|
/* preserve_unicode */ true);
|
||||||
|
auto got = Run<Renamer>(src, inputs);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(RenamerTest, AttemptSymbolCollision) {
|
TEST_F(RenamerTest, AttemptSymbolCollision) {
|
||||||
auto* src = R"(
|
auto* src = R"(
|
||||||
@vertex
|
@vertex
|
||||||
|
@ -287,6 +314,49 @@ fn tint_symbol() -> @builtin(position) vec4<f32> {
|
||||||
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
|
EXPECT_THAT(data->remappings, ContainerEq(expected_remappings));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(RenamerTest, PreserveTexelFormatAndAccess) {
|
||||||
|
auto src = R"(
|
||||||
|
@group(0) @binding(0) var texture : texture_storage_2d<rgba8unorm, write>;
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
var dims = textureDimensions(texture);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto expect = R"(
|
||||||
|
@group(0) @binding(0) var tint_symbol : texture_storage_2d<rgba8unorm, write>;
|
||||||
|
|
||||||
|
fn tint_symbol_1() {
|
||||||
|
var tint_symbol_2 = textureDimensions(tint_symbol);
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<Renamer>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(RenamerTest, PreserveAddressSpace) {
|
||||||
|
auto src = R"(
|
||||||
|
var<private> p : i32;
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
var v = p;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto expect = R"(
|
||||||
|
var<private> tint_symbol : i32;
|
||||||
|
|
||||||
|
fn tint_symbol_1() {
|
||||||
|
var tint_symbol_2 = tint_symbol;
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
auto got = Run<Renamer>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
using RenamerTestGlsl = TransformTestWithParam<std::string>;
|
using RenamerTestGlsl = TransformTestWithParam<std::string>;
|
||||||
using RenamerTestHlsl = TransformTestWithParam<std::string>;
|
using RenamerTestHlsl = TransformTestWithParam<std::string>;
|
||||||
using RenamerTestMsl = TransformTestWithParam<std::string>;
|
using RenamerTestMsl = TransformTestWithParam<std::string>;
|
||||||
|
@ -1500,7 +1570,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||||
// "while" // WGSL reserved keyword
|
// "while" // WGSL reserved keyword
|
||||||
kUnicodeIdentifier));
|
kUnicodeIdentifier));
|
||||||
|
|
||||||
const char* ExpandBuiltinType(std::string_view name) {
|
std::string ExpandBuiltinType(std::string_view name) {
|
||||||
if (name == "mat2x2f") {
|
if (name == "mat2x2f") {
|
||||||
return "mat2x2<f32>";
|
return "mat2x2<f32>";
|
||||||
}
|
}
|
||||||
|
@ -1591,13 +1661,47 @@ const char* ExpandBuiltinType(std::string_view name) {
|
||||||
if (name == "vec4u") {
|
if (name == "vec4u") {
|
||||||
return "vec4<u32>";
|
return "vec4<u32>";
|
||||||
}
|
}
|
||||||
ADD_FAILURE() << "unhandled type: " << name;
|
return std::string(name);
|
||||||
return "<invalid>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using RenamerTypeBuiltinTypesTest = TransformTestWithParam<const char*>;
|
/// @return all the identifiers parsed as keywords
|
||||||
|
std::unordered_set<std::string> Keywords() {
|
||||||
|
return {
|
||||||
|
"bool",
|
||||||
|
"f16",
|
||||||
|
"f32",
|
||||||
|
"i32",
|
||||||
|
"sampler_comparison",
|
||||||
|
"sampler",
|
||||||
|
"texture_depth_2d_array",
|
||||||
|
"texture_depth_2d",
|
||||||
|
"texture_depth_cube_array",
|
||||||
|
"texture_depth_cube",
|
||||||
|
"texture_depth_multisampled_2d",
|
||||||
|
"texture_external",
|
||||||
|
"texture_storage_1d",
|
||||||
|
"texture_storage_2d",
|
||||||
|
"texture_storage_2d_array",
|
||||||
|
"texture_storage_3d",
|
||||||
|
"u32",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
TEST_P(RenamerTypeBuiltinTypesTest, PreserveTypeUsage) {
|
/// @return WGSL builtin types that aren't keywords
|
||||||
|
std::vector<const char*> NonKeywordBuiltinTypes() {
|
||||||
|
auto keywords = Keywords();
|
||||||
|
std::vector<const char*> out;
|
||||||
|
for (auto* ident : type::kBuiltinStrings) {
|
||||||
|
if (!keywords.count(ident)) {
|
||||||
|
out.push_back(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
using RenamerBuiltinTypeTest = TransformTestWithParam<const char*>;
|
||||||
|
|
||||||
|
TEST_P(RenamerBuiltinTypeTest, PreserveTypeUsage) {
|
||||||
auto expand = [&](const char* source) {
|
auto expand = [&](const char* source) {
|
||||||
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
||||||
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
||||||
|
@ -1638,7 +1742,7 @@ struct tint_symbol_5 {
|
||||||
|
|
||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
TEST_P(RenamerTypeBuiltinTypesTest, PreserveTypeInitializer) {
|
TEST_P(RenamerBuiltinTypeTest, PreserveTypeInitializer) {
|
||||||
auto expand = [&](const char* source) {
|
auto expand = [&](const char* source) {
|
||||||
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
||||||
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
||||||
|
@ -1668,7 +1772,7 @@ fn tint_symbol() {
|
||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(RenamerTypeBuiltinTypesTest, PreserveTypeConversion) {
|
TEST_P(RenamerBuiltinTypeTest, PreserveTypeConversion) {
|
||||||
auto expand = [&](const char* source) {
|
auto expand = [&](const char* source) {
|
||||||
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
||||||
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
||||||
|
@ -1698,7 +1802,7 @@ fn tint_symbol() {
|
||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(RenamerTypeBuiltinTypesTest, RenameShadowedByAlias) {
|
TEST_P(RenamerBuiltinTypeTest, RenameShadowedByAlias) {
|
||||||
auto expand = [&](const char* source) {
|
auto expand = [&](const char* source) {
|
||||||
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
||||||
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
||||||
|
@ -1728,7 +1832,7 @@ fn tint_symbol_1() {
|
||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(RenamerTypeBuiltinTypesTest, RenameShadowedByStruct) {
|
TEST_P(RenamerBuiltinTypeTest, RenameShadowedByStruct) {
|
||||||
auto expand = [&](const char* source) {
|
auto expand = [&](const char* source) {
|
||||||
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
auto out = utils::ReplaceAll(source, "$name", GetParam());
|
||||||
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
out = utils::ReplaceAll(out, "$type", ExpandBuiltinType(GetParam()));
|
||||||
|
@ -1764,9 +1868,148 @@ fn tint_symbol_2() {
|
||||||
EXPECT_EQ(expect, str(got));
|
EXPECT_EQ(expect, str(got));
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTANTIATE_TEST_SUITE_P(RenamerTypeBuiltinTypesTest,
|
INSTANTIATE_TEST_SUITE_P(RenamerBuiltinTypeTest,
|
||||||
RenamerTypeBuiltinTypesTest,
|
RenamerBuiltinTypeTest,
|
||||||
testing::ValuesIn(type::kBuiltinStrings));
|
testing::ValuesIn(NonKeywordBuiltinTypes()));
|
||||||
|
|
||||||
|
/// @return WGSL builtin identifiers keywords
|
||||||
|
std::vector<const char*> NonKeywordIdentifiers() {
|
||||||
|
auto keywords = Keywords();
|
||||||
|
std::vector<const char*> out;
|
||||||
|
for (auto* ident : type::kBuiltinStrings) {
|
||||||
|
if (!keywords.count(ident)) {
|
||||||
|
out.push_back(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto* ident : type::kAddressSpaceStrings) {
|
||||||
|
if (!keywords.count(ident)) {
|
||||||
|
out.push_back(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto* ident : type::kTexelFormatStrings) {
|
||||||
|
if (!keywords.count(ident)) {
|
||||||
|
out.push_back(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto* ident : type::kAccessStrings) {
|
||||||
|
if (!keywords.count(ident)) {
|
||||||
|
out.push_back(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
using RenamerBuiltinIdentifierTest = TransformTestWithParam<const char*>;
|
||||||
|
|
||||||
|
TEST_P(RenamerBuiltinIdentifierTest, GlobalVarName) {
|
||||||
|
auto expand = [&](const char* source) {
|
||||||
|
return utils::ReplaceAll(source, "$name", GetParam());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto src = expand(R"(
|
||||||
|
var<private> $name = 42;
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
var v = $name;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto expect = expand(R"(
|
||||||
|
var<private> tint_symbol = 42;
|
||||||
|
|
||||||
|
fn tint_symbol_1() {
|
||||||
|
var tint_symbol_2 = tint_symbol;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto got = Run<Renamer>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(RenamerBuiltinIdentifierTest, LocalVarName) {
|
||||||
|
auto expand = [&](const char* source) {
|
||||||
|
return utils::ReplaceAll(source, "$name", GetParam());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto src = expand(R"(
|
||||||
|
fn f() {
|
||||||
|
var $name = 42;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto expect = expand(R"(
|
||||||
|
fn tint_symbol() {
|
||||||
|
var tint_symbol_1 = 42;
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto got = Run<Renamer>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(RenamerBuiltinIdentifierTest, FunctionName) {
|
||||||
|
auto expand = [&](const char* source) {
|
||||||
|
return utils::ReplaceAll(source, "$name", GetParam());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto src = expand(R"(
|
||||||
|
fn $name() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
$name();
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto expect = expand(R"(
|
||||||
|
fn tint_symbol() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tint_symbol_1() {
|
||||||
|
tint_symbol();
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto got = Run<Renamer>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(RenamerBuiltinIdentifierTest, StructName) {
|
||||||
|
auto expand = [&](const char* source) {
|
||||||
|
return utils::ReplaceAll(source, "$name", GetParam());
|
||||||
|
};
|
||||||
|
|
||||||
|
auto src = expand(R"(
|
||||||
|
struct $name {
|
||||||
|
i : i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
var x = $name();
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto expect = expand(R"(
|
||||||
|
struct tint_symbol {
|
||||||
|
tint_symbol_1 : i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tint_symbol_2() {
|
||||||
|
var tint_symbol_3 = tint_symbol();
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
|
||||||
|
auto got = Run<Renamer>(src);
|
||||||
|
|
||||||
|
EXPECT_EQ(expect, str(got));
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(RenamerBuiltinIdentifierTest,
|
||||||
|
RenamerBuiltinIdentifierTest,
|
||||||
|
testing::ValuesIn(NonKeywordIdentifiers()));
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace tint::transform
|
} // namespace tint::transform
|
||||||
|
|
|
@ -36,10 +36,10 @@ uint tint_mod(uint lhs, uint rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint3 toIndex4D(uint gridSize, uint index) {
|
uint3 toIndex4D(uint gridSize, uint index) {
|
||||||
uint z_1 = tint_div(gridSize, (index * index));
|
uint z = tint_div(gridSize, (index * index));
|
||||||
uint y_1 = tint_div((gridSize - ((gridSize * gridSize) * z_1)), gridSize);
|
uint y = tint_div((gridSize - ((gridSize * gridSize) * z)), gridSize);
|
||||||
uint x_1 = tint_mod(index, gridSize);
|
uint x = tint_mod(index, gridSize);
|
||||||
return uint3(z_1, y_1, y_1);
|
return uint3(z, y, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 loadPosition(uint vertexIndex) {
|
float3 loadPosition(uint vertexIndex) {
|
||||||
|
|
|
@ -36,10 +36,10 @@ uint tint_mod(uint lhs, uint rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint3 toIndex4D(uint gridSize, uint index) {
|
uint3 toIndex4D(uint gridSize, uint index) {
|
||||||
uint z_1 = tint_div(gridSize, (index * index));
|
uint z = tint_div(gridSize, (index * index));
|
||||||
uint y_1 = tint_div((gridSize - ((gridSize * gridSize) * z_1)), gridSize);
|
uint y = tint_div((gridSize - ((gridSize * gridSize) * z)), gridSize);
|
||||||
uint x_1 = tint_mod(index, gridSize);
|
uint x = tint_mod(index, gridSize);
|
||||||
return uint3(z_1, y_1, y_1);
|
return uint3(z, y, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 loadPosition(uint vertexIndex) {
|
float3 loadPosition(uint vertexIndex) {
|
||||||
|
|
|
@ -89,10 +89,10 @@ uint tint_mod(uint lhs, uint rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint3 toIndex4D(uint gridSize, uint index) {
|
uint3 toIndex4D(uint gridSize, uint index) {
|
||||||
uint z_1 = tint_div(gridSize, (index * index));
|
uint z = tint_div(gridSize, (index * index));
|
||||||
uint y_1 = tint_div((gridSize - ((gridSize * gridSize) * z_1)), gridSize);
|
uint y = tint_div((gridSize - ((gridSize * gridSize) * z)), gridSize);
|
||||||
uint x_1 = tint_mod(index, gridSize);
|
uint x = tint_mod(index, gridSize);
|
||||||
return uint3(z_1, y_1, y_1);
|
return uint3(z, y, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 loadPosition(uint vertexIndex, device F32s* const tint_symbol_1) {
|
float3 loadPosition(uint vertexIndex, device F32s* const tint_symbol_1) {
|
||||||
|
|
|
@ -33,10 +33,10 @@ uint tint_mod(uint lhs, uint rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint3 toIndex3D(uint gridSize, uint index) {
|
uint3 toIndex3D(uint gridSize, uint index) {
|
||||||
uint z_1 = tint_div(index, (gridSize * gridSize));
|
uint z = tint_div(index, (gridSize * gridSize));
|
||||||
uint y_1 = tint_div((index - ((gridSize * gridSize) * z_1)), gridSize);
|
uint y = tint_div((index - ((gridSize * gridSize) * z)), gridSize);
|
||||||
uint x_1 = tint_mod(index, gridSize);
|
uint x = tint_mod(index, gridSize);
|
||||||
return uint3(x_1, y_1, z_1);
|
return uint3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 loadPosition(uint vertexIndex) {
|
float3 loadPosition(uint vertexIndex) {
|
||||||
|
|
|
@ -33,10 +33,10 @@ uint tint_mod(uint lhs, uint rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint3 toIndex3D(uint gridSize, uint index) {
|
uint3 toIndex3D(uint gridSize, uint index) {
|
||||||
uint z_1 = tint_div(index, (gridSize * gridSize));
|
uint z = tint_div(index, (gridSize * gridSize));
|
||||||
uint y_1 = tint_div((index - ((gridSize * gridSize) * z_1)), gridSize);
|
uint y = tint_div((index - ((gridSize * gridSize) * z)), gridSize);
|
||||||
uint x_1 = tint_mod(index, gridSize);
|
uint x = tint_mod(index, gridSize);
|
||||||
return uint3(x_1, y_1, z_1);
|
return uint3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 loadPosition(uint vertexIndex) {
|
float3 loadPosition(uint vertexIndex) {
|
||||||
|
|
|
@ -86,10 +86,10 @@ uint tint_mod(uint lhs, uint rhs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint3 toIndex3D(uint gridSize, uint index) {
|
uint3 toIndex3D(uint gridSize, uint index) {
|
||||||
uint z_1 = tint_div(index, (gridSize * gridSize));
|
uint z = tint_div(index, (gridSize * gridSize));
|
||||||
uint y_1 = tint_div((index - ((gridSize * gridSize) * z_1)), gridSize);
|
uint y = tint_div((index - ((gridSize * gridSize) * z)), gridSize);
|
||||||
uint x_1 = tint_mod(index, gridSize);
|
uint x = tint_mod(index, gridSize);
|
||||||
return uint3(x_1, y_1, z_1);
|
return uint3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 loadPosition(uint vertexIndex, device F32s* const tint_symbol_2) {
|
float3 loadPosition(uint vertexIndex, device F32s* const tint_symbol_2) {
|
||||||
|
|
|
@ -54,10 +54,10 @@ void main_inner(uint3 GlobalInvocationID) {
|
||||||
const int TILE_COUNT_X = 2;
|
const int TILE_COUNT_X = 2;
|
||||||
const int TILE_COUNT_Y = 2;
|
const int TILE_COUNT_Y = 2;
|
||||||
{
|
{
|
||||||
for(int y_1 = 0; (y_1 < TILE_COUNT_Y); y_1 = (y_1 + 1)) {
|
for(int y = 0; (y < TILE_COUNT_Y); y = (y + 1)) {
|
||||||
{
|
{
|
||||||
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) {
|
for(int x = 0; (x < TILE_COUNT_X); x = (x + 1)) {
|
||||||
int2 tilePixel0Idx = int2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE));
|
int2 tilePixel0Idx = int2((x * TILE_SIZE), (y * TILE_SIZE));
|
||||||
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
||||||
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + int2((TILE_SIZE).xx)))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + int2((TILE_SIZE).xx)))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
||||||
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
||||||
|
@ -90,7 +90,7 @@ void main_inner(uint3 GlobalInvocationID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((dp >= 0.0f)) {
|
if ((dp >= 0.0f)) {
|
||||||
uint tileId = uint((x_1 + (y_1 * TILE_COUNT_X)));
|
uint tileId = uint((x + (y * TILE_COUNT_X)));
|
||||||
bool tint_tmp = (tileId < 0u);
|
bool tint_tmp = (tileId < 0u);
|
||||||
if (!tint_tmp) {
|
if (!tint_tmp) {
|
||||||
tint_tmp = (tileId >= config[0].y);
|
tint_tmp = (tileId >= config[0].y);
|
||||||
|
|
|
@ -54,10 +54,10 @@ void main_inner(uint3 GlobalInvocationID) {
|
||||||
const int TILE_COUNT_X = 2;
|
const int TILE_COUNT_X = 2;
|
||||||
const int TILE_COUNT_Y = 2;
|
const int TILE_COUNT_Y = 2;
|
||||||
{
|
{
|
||||||
for(int y_1 = 0; (y_1 < TILE_COUNT_Y); y_1 = (y_1 + 1)) {
|
for(int y = 0; (y < TILE_COUNT_Y); y = (y + 1)) {
|
||||||
{
|
{
|
||||||
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) {
|
for(int x = 0; (x < TILE_COUNT_X); x = (x + 1)) {
|
||||||
int2 tilePixel0Idx = int2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE));
|
int2 tilePixel0Idx = int2((x * TILE_SIZE), (y * TILE_SIZE));
|
||||||
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
||||||
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + int2((TILE_SIZE).xx)))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
float2 ceilCoord = (((2.0f * float2((tilePixel0Idx + int2((TILE_SIZE).xx)))) / asfloat(uniforms[10]).xy) - (1.0f).xx);
|
||||||
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
||||||
|
@ -90,7 +90,7 @@ void main_inner(uint3 GlobalInvocationID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((dp >= 0.0f)) {
|
if ((dp >= 0.0f)) {
|
||||||
uint tileId = uint((x_1 + (y_1 * TILE_COUNT_X)));
|
uint tileId = uint((x + (y * TILE_COUNT_X)));
|
||||||
bool tint_tmp = (tileId < 0u);
|
bool tint_tmp = (tileId < 0u);
|
||||||
if (!tint_tmp) {
|
if (!tint_tmp) {
|
||||||
tint_tmp = (tileId >= config[0].y);
|
tint_tmp = (tileId >= config[0].y);
|
||||||
|
|
|
@ -75,10 +75,10 @@ void tint_symbol_2(uvec3 GlobalInvocationID) {
|
||||||
int TILE_COUNT_X = 2;
|
int TILE_COUNT_X = 2;
|
||||||
int TILE_COUNT_Y = 2;
|
int TILE_COUNT_Y = 2;
|
||||||
{
|
{
|
||||||
for(int y_1 = 0; (y_1 < TILE_COUNT_Y); y_1 = (y_1 + 1)) {
|
for(int y = 0; (y < TILE_COUNT_Y); y = (y + 1)) {
|
||||||
{
|
{
|
||||||
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = (x_1 + 1)) {
|
for(int x = 0; (x < TILE_COUNT_X); x = (x + 1)) {
|
||||||
ivec2 tilePixel0Idx = ivec2((x_1 * TILE_SIZE), (y_1 * TILE_SIZE));
|
ivec2 tilePixel0Idx = ivec2((x * TILE_SIZE), (y * TILE_SIZE));
|
||||||
vec2 floorCoord = (((2.0f * vec2(tilePixel0Idx)) / uniforms.inner.fullScreenSize.xy) - vec2(1.0f));
|
vec2 floorCoord = (((2.0f * vec2(tilePixel0Idx)) / uniforms.inner.fullScreenSize.xy) - vec2(1.0f));
|
||||||
vec2 ceilCoord = (((2.0f * vec2((tilePixel0Idx + ivec2(TILE_SIZE)))) / uniforms.inner.fullScreenSize.xy) - vec2(1.0f));
|
vec2 ceilCoord = (((2.0f * vec2((tilePixel0Idx + ivec2(TILE_SIZE)))) / uniforms.inner.fullScreenSize.xy) - vec2(1.0f));
|
||||||
vec2 viewFloorCoord = vec2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
vec2 viewFloorCoord = vec2((((-(viewNear) * floorCoord.x) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord.y) - (M[2][1] * viewNear)) / M[1][1]));
|
||||||
|
@ -111,7 +111,7 @@ void tint_symbol_2(uvec3 GlobalInvocationID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((dp >= 0.0f)) {
|
if ((dp >= 0.0f)) {
|
||||||
uint tileId = uint((x_1 + (y_1 * TILE_COUNT_X)));
|
uint tileId = uint((x + (y * TILE_COUNT_X)));
|
||||||
bool tint_tmp = (tileId < 0u);
|
bool tint_tmp = (tileId < 0u);
|
||||||
if (!tint_tmp) {
|
if (!tint_tmp) {
|
||||||
tint_tmp = (tileId >= config.inner.numTiles);
|
tint_tmp = (tileId >= config.inner.numTiles);
|
||||||
|
|
|
@ -74,9 +74,9 @@ void tint_symbol_inner(uint3 GlobalInvocationID, const constant Config* const ti
|
||||||
int const TILE_SIZE = 16;
|
int const TILE_SIZE = 16;
|
||||||
int const TILE_COUNT_X = 2;
|
int const TILE_COUNT_X = 2;
|
||||||
int const TILE_COUNT_Y = 2;
|
int const TILE_COUNT_Y = 2;
|
||||||
for(int y_1 = 0; (y_1 < TILE_COUNT_Y); y_1 = as_type<int>((as_type<uint>(y_1) + as_type<uint>(1)))) {
|
for(int y = 0; (y < TILE_COUNT_Y); y = as_type<int>((as_type<uint>(y) + as_type<uint>(1)))) {
|
||||||
for(int x_1 = 0; (x_1 < TILE_COUNT_X); x_1 = as_type<int>((as_type<uint>(x_1) + as_type<uint>(1)))) {
|
for(int x = 0; (x < TILE_COUNT_X); x = as_type<int>((as_type<uint>(x) + as_type<uint>(1)))) {
|
||||||
int2 tilePixel0Idx = int2(as_type<int>((as_type<uint>(x_1) * as_type<uint>(TILE_SIZE))), as_type<int>((as_type<uint>(y_1) * as_type<uint>(TILE_SIZE))));
|
int2 tilePixel0Idx = int2(as_type<int>((as_type<uint>(x) * as_type<uint>(TILE_SIZE))), as_type<int>((as_type<uint>(y) * as_type<uint>(TILE_SIZE))));
|
||||||
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
|
float2 floorCoord = (((2.0f * float2(tilePixel0Idx)) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
|
||||||
float2 ceilCoord = (((2.0f * float2(as_type<int2>((as_type<uint2>(tilePixel0Idx) + as_type<uint2>(int2(TILE_SIZE)))))) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
|
float2 ceilCoord = (((2.0f * float2(as_type<int2>((as_type<uint2>(tilePixel0Idx) + as_type<uint2>(int2(TILE_SIZE)))))) / float4((*(tint_symbol_3)).fullScreenSize).xy) - float2(1.0f));
|
||||||
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord[0]) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord[1]) - (M[2][1] * viewNear)) / M[1][1]));
|
float2 viewFloorCoord = float2((((-(viewNear) * floorCoord[0]) - (M[2][0] * viewNear)) / M[0][0]), (((-(viewNear) * floorCoord[1]) - (M[2][1] * viewNear)) / M[1][1]));
|
||||||
|
@ -107,7 +107,7 @@ void tint_symbol_inner(uint3 GlobalInvocationID, const constant Config* const ti
|
||||||
dp = (dp + fmin(0.0f, dot(p, frustumPlanes[i])));
|
dp = (dp + fmin(0.0f, dot(p, frustumPlanes[i])));
|
||||||
}
|
}
|
||||||
if ((dp >= 0.0f)) {
|
if ((dp >= 0.0f)) {
|
||||||
uint tileId = uint(as_type<int>((as_type<uint>(x_1) + as_type<uint>(as_type<int>((as_type<uint>(y_1) * as_type<uint>(TILE_COUNT_X)))))));
|
uint tileId = uint(as_type<int>((as_type<uint>(x) + as_type<uint>(as_type<int>((as_type<uint>(y) * as_type<uint>(TILE_COUNT_X)))))));
|
||||||
if (((tileId < 0u) || (tileId >= (*(tint_symbol_1)).numTiles))) {
|
if (((tileId < 0u) || (tileId >= (*(tint_symbol_1)).numTiles))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ void unused_entry_point() {
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
const int vec3f_1 = 1;
|
const int vec3f = 1;
|
||||||
const int b = vec3f_1;
|
const int b = vec3f;
|
||||||
}
|
}
|
||||||
const float3 c = (0.0f).xxx;
|
const float3 c = (0.0f).xxx;
|
||||||
const float3 d = (0.0f).xxx;
|
const float3 d = (0.0f).xxx;
|
||||||
|
|
|
@ -5,8 +5,8 @@ void unused_entry_point() {
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
const int vec3f_1 = 1;
|
const int vec3f = 1;
|
||||||
const int b = vec3f_1;
|
const int b = vec3f;
|
||||||
}
|
}
|
||||||
const float3 c = (0.0f).xxx;
|
const float3 c = (0.0f).xxx;
|
||||||
const float3 d = (0.0f).xxx;
|
const float3 d = (0.0f).xxx;
|
||||||
|
|
|
@ -6,8 +6,8 @@ void unused_entry_point() {
|
||||||
}
|
}
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
int vec3f_1 = 1;
|
int vec3f = 1;
|
||||||
int b = vec3f_1;
|
int b = vec3f;
|
||||||
}
|
}
|
||||||
vec3 c = vec3(0.0f);
|
vec3 c = vec3(0.0f);
|
||||||
vec3 d = vec3(0.0f);
|
vec3 d = vec3(0.0f);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
int const vec3f_1 = 1;
|
int const vec3f = 1;
|
||||||
int const b = vec3f_1;
|
int const b = vec3f;
|
||||||
}
|
}
|
||||||
float3 const c = float3(0.0f);
|
float3 const c = float3(0.0f);
|
||||||
float3 const d = float3(0.0f);
|
float3 const d = float3(0.0f);
|
||||||
|
|
|
@ -5,8 +5,8 @@ void unused_entry_point() {
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
int vec3f_1 = 1;
|
int vec3f = 1;
|
||||||
int b = vec3f_1;
|
int b = vec3f;
|
||||||
}
|
}
|
||||||
float3 c = (0.0f).xxx;
|
float3 c = (0.0f).xxx;
|
||||||
float3 d = (0.0f).xxx;
|
float3 d = (0.0f).xxx;
|
||||||
|
|
|
@ -5,8 +5,8 @@ void unused_entry_point() {
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
int vec3f_1 = 1;
|
int vec3f = 1;
|
||||||
int b = vec3f_1;
|
int b = vec3f;
|
||||||
}
|
}
|
||||||
float3 c = (0.0f).xxx;
|
float3 c = (0.0f).xxx;
|
||||||
float3 d = (0.0f).xxx;
|
float3 d = (0.0f).xxx;
|
||||||
|
|
|
@ -6,8 +6,8 @@ void unused_entry_point() {
|
||||||
}
|
}
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
int vec3f_1 = 1;
|
int vec3f = 1;
|
||||||
int b = vec3f_1;
|
int b = vec3f;
|
||||||
}
|
}
|
||||||
vec3 c = vec3(0.0f);
|
vec3 c = vec3(0.0f);
|
||||||
vec3 d = vec3(0.0f);
|
vec3 d = vec3(0.0f);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
void f() {
|
void f() {
|
||||||
{
|
{
|
||||||
int vec3f_1 = 1;
|
int vec3f = 1;
|
||||||
int b = vec3f_1;
|
int b = vec3f;
|
||||||
}
|
}
|
||||||
float3 c = float3(0.0f);
|
float3 c = float3(0.0f);
|
||||||
float3 d = float3(0.0f);
|
float3 d = float3(0.0f);
|
||||||
|
|
Loading…
Reference in New Issue