mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 09:25:25 +00:00
Make TextureDescriptor match WebGPU IDL
This patch updates the definition of TextureDescriptor to make it match WebGPU IDL: 1. Rename 'arrayLayer' to 'arraySize' 2. Add the missing member "sampleCount" and check that currently sampleCount can only be 1. BUG=dawn:56 TEST=dawn_unittests Change-Id: I642186529f045865ae344cb5545ac80e14445c59 Reviewed-on: https://dawn-review.googlesource.com/c/3180 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
d86edb310a
commit
8bff3b22be
68
src/tests/unittests/validation/TextureValidationTests.cpp
Normal file
68
src/tests/unittests/validation/TextureValidationTests.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018 The Dawn Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "tests/unittests/validation/ValidationTest.h"
|
||||
|
||||
#include "common/Constants.h"
|
||||
#include "utils/DawnHelpers.h"
|
||||
|
||||
namespace {
|
||||
|
||||
class TextureValidationTest : public ValidationTest {
|
||||
};
|
||||
|
||||
constexpr uint32_t kWidth = 32;
|
||||
constexpr uint32_t kHeight = 32;
|
||||
constexpr uint32_t kDefaultArraySize = 1;
|
||||
constexpr uint32_t kDefaultMipLevels = 1;
|
||||
constexpr uint32_t kDefaultSampleCount = 1;
|
||||
|
||||
constexpr dawn::TextureFormat kDefaultTextureFormat = dawn::TextureFormat::R8G8B8A8Unorm;
|
||||
|
||||
dawn::TextureDescriptor CreateDefaultTextureDescriptor() {
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.nextInChain = nullptr;
|
||||
descriptor.size.width = kWidth;
|
||||
descriptor.size.height = kHeight;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arraySize = kDefaultArraySize;
|
||||
descriptor.levelCount = kDefaultMipLevels;
|
||||
descriptor.sampleCount = kDefaultSampleCount;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.format = kDefaultTextureFormat;
|
||||
descriptor.usage = dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::Sampled;
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
// Test the validation of sample count
|
||||
TEST_F(TextureValidationTest, SampleCount) {
|
||||
dawn::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||
|
||||
// sampleCount == 1 is allowed.
|
||||
{
|
||||
dawn::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.sampleCount = 1;
|
||||
|
||||
device.CreateTexture(&descriptor);
|
||||
}
|
||||
|
||||
// It is an error to create a texture with an invalid sampleCount.
|
||||
{
|
||||
dawn::TextureDescriptor descriptor = defaultDescriptor;
|
||||
descriptor.sampleCount = 3;
|
||||
|
||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user