Check for deprecation warnings in ValidationTests

And adds EXPECT_DEPRECATION_WARNING where necessary in validation tests.

Bug: dawn:520, dawn:527
Change-Id: Ic8e103e4b7b5784a2009519e0a18ed16088632b1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/31300
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Kai Ninomiya 2020-10-30 17:54:46 +00:00 committed by Commit Bot service account
parent 25eb373eed
commit 5a1d786754
5 changed files with 48 additions and 16 deletions

View File

@ -950,18 +950,11 @@ TEST_F(BindGroupLayoutValidationTest, MultisampledTextureViewDimension) {
0, false, wgpu::TextureViewDimension::Undefined},
});
// Multisampled 2D storage texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture,
false, 0, true, wgpu::TextureViewDimension::e2D},
}));
// Multisampled 2D array texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0,
true, wgpu::TextureViewDimension::e2DArray},
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false,
0, false, wgpu::TextureViewDimension::e2DArray},
}));
// Multisampled cube texture is invalid.
@ -1032,14 +1025,15 @@ TEST_F(BindGroupLayoutValidationTest, MultisampledTextureComponentType) {
}));
}
// Test that it is an error to pass multisampled=true for non-texture bindings
TEST_F(BindGroupLayoutValidationTest, MultisampledMustBeTexture) {
// Test that it is an error to pass multisampled=true for non-texture bindings.
// TODO(crbug.com/dawn/527): Remove this test when multisampled=true is removed.
TEST_F(BindGroupLayoutValidationTest, MultisampledMustBeSampledTexture) {
// Base: Multisampled 2D texture works.
utils::MakeBindGroupLayout(
EXPECT_DEPRECATION_WARNING(utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0,
true, wgpu::TextureViewDimension::e2D},
});
}));
// Multisampled uniform buffer binding is invalid
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
@ -1060,6 +1054,13 @@ TEST_F(BindGroupLayoutValidationTest, MultisampledMustBeTexture) {
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::Sampler, false, 0, true},
}));
// Multisampled 2D storage texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture,
false, 0, true, wgpu::TextureViewDimension::e2D},
}));
}
constexpr uint64_t kBufferSize = 3 * kMinDynamicBufferOffsetAlignment + 8;

View File

@ -247,7 +247,6 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
TEST_F(GetBindGroupLayoutTests, Multisampled) {
wgpu::BindGroupLayoutEntry binding = {};
binding.binding = 0;
binding.type = wgpu::BindingType::SampledTexture;
binding.visibility = wgpu::ShaderStage::Fragment;
binding.hasDynamicOffset = false;
@ -256,6 +255,7 @@ TEST_F(GetBindGroupLayoutTests, Multisampled) {
desc.entries = &binding;
{
binding.type = wgpu::BindingType::SampledTexture;
binding.multisampled = false;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
@ -266,7 +266,8 @@ TEST_F(GetBindGroupLayoutTests, Multisampled) {
}
{
binding.multisampled = true;
binding.type = wgpu::BindingType::MultisampledTexture;
binding.multisampled = false;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform texture2DMS tex;
@ -274,6 +275,20 @@ TEST_F(GetBindGroupLayoutTests, Multisampled) {
void main() {})");
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
}
// TODO(crbug.com/dawn/527): Remove this block when multisampled=true is removed.
{
binding.type = wgpu::BindingType::SampledTexture;
binding.multisampled = true;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform texture2DMS tex;
void main() {})");
wgpu::BindGroupLayout bgl;
EXPECT_DEPRECATION_WARNING(bgl = device.CreateBindGroupLayout(&desc));
EXPECT_EQ(bgl.Get(), pipeline.GetBindGroupLayout(0).Get());
}
}
// Test that texture view dimension matches the shader.

View File

@ -585,7 +585,7 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
// TODO(crbug.com/dawn/502): Once setIndexBuffer requires an
// indexFormat. this should fail. For now it succeeds to allow
// backwards compatibility during the deprecation period.
device.CreateRenderPipeline(&descriptor);
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
}
}
}

View File

@ -72,6 +72,11 @@ ValidationTest::~ValidationTest() {
void ValidationTest::TearDown() {
ASSERT_FALSE(mExpectError);
if (device) {
EXPECT_EQ(mLastWarningCount,
dawn_native::GetDeprecationWarningCountForTesting(device.Get()));
}
}
void ValidationTest::StartExpectDeviceError() {

View File

@ -39,6 +39,15 @@
} \
} while (0)
#define EXPECT_DEPRECATION_WARNING(statement) \
do { \
size_t warningsBefore = dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
statement; \
size_t warningsAfter = dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
EXPECT_EQ(mLastWarningCount, warningsBefore); \
mLastWarningCount = warningsAfter; \
} while (0)
class ValidationTest : public testing::Test {
public:
ValidationTest();
@ -76,6 +85,8 @@ class ValidationTest : public testing::Test {
dawn_native::Adapter adapter;
std::unique_ptr<dawn_native::Instance> instance;
size_t mLastWarningCount = 0;
private:
static void OnDeviceError(WGPUErrorType type, const char* message, void* userdata);
std::string mDeviceErrorMessage;