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>
This commit is contained in:
Ben Clayton 2021-05-05 18:00:52 +00:00 committed by Commit Bot service account
parent 8e1d177590
commit 58f93c9e26
4 changed files with 13 additions and 25 deletions

View File

@ -397,6 +397,9 @@ const sem::Type* Resolver::Type(const ast::Type* ty) {
}
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()) {

View File

@ -28,23 +28,18 @@ Output ExternalTextureTransform::Run(const Program* in, const DataMap&) {
// 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);
}

View File

@ -24,33 +24,24 @@ using ExternalTextureTransformTest = TransformTest;
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)));
}
)";

View File

@ -377,8 +377,7 @@ void Spirv::HoistToOutputVariables(CloneContext& ctx,
}
}
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;