ExternalTextureTransform: Fix undefined behavior
WGSL now supports type inferencing with `let` declarations, so `var->type()` may return nullptr. Calling a method (`Is<T>()`) on a nullptr object is UB. Instead used the free-function form which can handle nullptr objects. Change-Id: I8faf875e1550eac1306ad731a65f3662bc4e5b43 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50307 Auto-Submit: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Brandon Jones <brandon1.jones@intel.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
1f68519dee
commit
8f96595540
|
@ -28,7 +28,7 @@ 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()->Is<ast::ExternalTexture>()) {
|
||||
if (Is<ast::ExternalTexture>(var->type())) {
|
||||
// Replace a single-plane external texture with a 2D, f32 sampled
|
||||
// texture.
|
||||
auto newType = ctx.dst->ty.sampled_texture(ast::TextureDimension::k2d,
|
||||
|
|
Loading…
Reference in New Issue