From c8ab96cdd907c53a6147beaf3e2dcda943818e3f Mon Sep 17 00:00:00 2001 From: "Yan, Shaobo" Date: Tue, 16 Jul 2019 08:37:49 +0000 Subject: [PATCH] Add an end2end test to ensure dawn cache system considers dynamic attributes Binding layout uses an attribute to mark dynamic resource. And this should be taken into consideration when determining whether two bindingInfo are equal. Otherwise, dawn cache system may take two different bind group layouts(they have same binding resource type, masks and visibilities but one bind group has dynamic resource and the other not) as the same. This will return wrong bind group layout object to user and cause validation error when user tries to use dynamic buffer offset. BUG=dawn:188 Change-Id: I11b158724c7592718af434b48c9e3f2f9bb72b93 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8901 Reviewed-by: Corentin Wallez Commit-Queue: Corentin Wallez --- src/tests/end2end/ObjectCachingTests.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tests/end2end/ObjectCachingTests.cpp b/src/tests/end2end/ObjectCachingTests.cpp index 749b56e839..c96b3adfba 100644 --- a/src/tests/end2end/ObjectCachingTests.cpp +++ b/src/tests/end2end/ObjectCachingTests.cpp @@ -32,6 +32,19 @@ TEST_P(ObjectCachingTest, BindGroupLayoutDeduplication) { EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire()); } +// Test that two similar bind group layouts won't refer to the same one. +TEST_P(ObjectCachingTest, BindGroupLayoutDynamic) { + dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout( + device, {{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer, true}}); + dawn::BindGroupLayout sameBgl = utils::MakeBindGroupLayout( + device, {{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer, true}}); + dawn::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( + device, {{1, dawn::ShaderStageBit::Fragment, dawn::BindingType::UniformBuffer, false}}); + + EXPECT_NE(bgl.Get(), otherBgl.Get()); + EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire()); +} + // Test that an error object doesn't try to uncache itself TEST_P(ObjectCachingTest, ErrorObjectDoesntUncache) { ASSERT_DEVICE_ERROR(