Build fixes
Two incompatible changes landed simultaniously.
Also fix a warning about variable shadowing.
Change-Id: I84c9ba48fb87a348a5b0e622ca2fdb191f95a6b2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/49964
Commit-Queue: Ben Clayton <bclayton@google.com>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc
index 488bc6c..e098271 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -397,6 +397,9 @@
}
return nullptr;
}
+ if (auto* t = ty->As<ast::ExternalTexture>()) {
+ return builder_->create<sem::ExternalTexture>();
+ }
if (auto* t = ty->As<ast::TypeName>()) {
auto it = named_types_.find(t->name());
if (it == named_types_.end()) {
diff --git a/src/transform/external_texture_transform.cc b/src/transform/external_texture_transform.cc
index 841b386..eade354 100644
--- a/src/transform/external_texture_transform.cc
+++ b/src/transform/external_texture_transform.cc
@@ -28,23 +28,18 @@
// Scan the AST nodes for external texture declarations.
for (auto* node : ctx.src->ASTNodes().Objects()) {
if (auto* var = node->As<ast::Variable>()) {
- if (var->type().ast->Is<ast::ExternalTexture>()) {
+ if (var->type()->Is<ast::ExternalTexture>()) {
// Replace a single-plane external texture with a 2D, f32 sampled
// texture.
- auto* newAstType = ctx.dst->create<ast::SampledTexture>(
- ast::TextureDimension::k2d, ctx.dst->create<ast::F32>());
- auto* newSemType = ctx.dst->create<sem::SampledTexture>(
- ast::TextureDimension::k2d, ctx.dst->ty.f32());
-
+ auto newType = ctx.dst->ty.sampled_texture(ast::TextureDimension::k2d,
+ ctx.dst->ty.f32());
auto clonedSrc = ctx.Clone(var->source());
auto clonedSym = ctx.Clone(var->symbol());
auto* clonedConstructor = ctx.Clone(var->constructor());
auto clonedDecorations = ctx.Clone(var->decorations());
-
auto* newVar = ctx.dst->create<ast::Variable>(
- clonedSrc, clonedSym, var->declared_storage_class(),
- typ::Type(newAstType, newSemType), var->is_const(),
- clonedConstructor, clonedDecorations);
+ clonedSrc, clonedSym, var->declared_storage_class(), newType,
+ var->is_const(), clonedConstructor, clonedDecorations);
ctx.Replace(var, newVar);
}
diff --git a/src/transform/external_texture_transform_test.cc b/src/transform/external_texture_transform_test.cc
index bf16ddd..e5cce21 100644
--- a/src/transform/external_texture_transform_test.cc
+++ b/src/transform/external_texture_transform_test.cc
@@ -24,33 +24,24 @@
TEST_F(ExternalTextureTransformTest, SinglePlane) {
auto* src = R"(
-[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
-
[[group(0), binding(0)]] var s : sampler;
[[group(0), binding(1)]] var t : texture_external;
-[[location(0)]] var<out> FragColor : vec4<f32>;
[[stage(fragment)]]
-fn main() {
- FragColor = textureSample(t, s, (FragCoord.xy / vec2<f32>(4.0, 4.0)));
- return;
+fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
+ return textureSample(t, s, (coord.xy / vec2<f32>(4.0, 4.0)));
}
)";
auto* expect = R"(
-[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
-
[[group(0), binding(0)]] var s : sampler;
[[group(0), binding(1)]] var t : texture_2d<f32>;
-[[location(0)]] var<out> FragColor : vec4<f32>;
-
[[stage(fragment)]]
-fn main() {
- FragColor = textureSample(t, s, (FragCoord.xy / vec2<f32>(4.0, 4.0)));
- return;
+fn main([[builtin(position)]] coord : vec4<f32>) -> [[location(0)]] vec4<f32> {
+ return textureSample(t, s, (coord.xy / vec2<f32>(4.0, 4.0)));
}
)";
diff --git a/src/transform/spirv.cc b/src/transform/spirv.cc
index f0459ae..df9461c 100644
--- a/src/transform/spirv.cc
+++ b/src/transform/spirv.cc
@@ -377,8 +377,7 @@
}
}
-Spirv::Config::Config(bool emit_vertex_point_size)
- : emit_vertex_point_size(emit_vertex_point_size) {}
+Spirv::Config::Config(bool emit_vps) : emit_vertex_point_size(emit_vps) {}
Spirv::Config::Config(const Config&) = default;
Spirv::Config::~Config() = default;