mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 23:56:16 +00:00
Tint/GLSL: fix null ptr deref in Texture1D -> 2D.
Bug: 1405676 Change-Id: If6edb0ba2b6c1ddd5d75421d234e168297e1b622 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116700 Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
ab00dd0725
commit
477744b7b5
@@ -126,7 +126,10 @@ struct Texture1DTo2D::State {
|
||||
return nullptr;
|
||||
}
|
||||
const auto& signature = builtin->Signature();
|
||||
auto texture = signature.Parameter(sem::ParameterUsage::kTexture);
|
||||
auto* texture = signature.Parameter(sem::ParameterUsage::kTexture);
|
||||
if (!texture) {
|
||||
return nullptr;
|
||||
}
|
||||
auto* tex = texture->Type()->As<type::Texture>();
|
||||
if (tex->dim() != ast::TextureDimension::k1d) {
|
||||
return nullptr;
|
||||
|
||||
@@ -275,5 +275,30 @@ fn main() {
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
TEST_F(Texture1DTo2DTest, TextureAndNonTextureBuiltin) {
|
||||
auto* src = R"(
|
||||
@group(0) @binding(0) var tex : texture_1d<i32>;
|
||||
|
||||
fn d() {
|
||||
textureLoad(tex, 1, 0);
|
||||
let l = sin(3.0);
|
||||
}
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
@group(0) @binding(0) var tex : texture_2d<i32>;
|
||||
|
||||
fn d() {
|
||||
textureLoad(tex, vec2<i32>(1, 0), 0);
|
||||
let l = sin(3.0);
|
||||
}
|
||||
)";
|
||||
|
||||
DataMap data;
|
||||
auto got = Run<Texture1DTo2D>(src, data);
|
||||
|
||||
EXPECT_EQ(expect, str(got));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace tint::transform
|
||||
|
||||
Reference in New Issue
Block a user