Validate texture usage is non-zero in createTexture
Validate that texture usage is not 0 (None) when creating buffer. Bug: dawn:1266 Change-Id: I1bbb766319b8680d1303f214632708f5234bd9d6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77760 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
This commit is contained in:
parent
8e9fbbe7ca
commit
fd3505ba43
|
@ -246,6 +246,8 @@ namespace dawn::native {
|
||||||
const Format* format) {
|
const Format* format) {
|
||||||
DAWN_TRY(dawn::native::ValidateTextureUsage(usage));
|
DAWN_TRY(dawn::native::ValidateTextureUsage(usage));
|
||||||
|
|
||||||
|
DAWN_INVALID_IF(usage == wgpu::TextureUsage::None, "The texture usage must not be 0.");
|
||||||
|
|
||||||
constexpr wgpu::TextureUsage kValidCompressedUsages =
|
constexpr wgpu::TextureUsage kValidCompressedUsages =
|
||||||
wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::CopySrc |
|
wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::CopySrc |
|
||||||
wgpu::TextureUsage::CopyDst;
|
wgpu::TextureUsage::CopyDst;
|
||||||
|
|
|
@ -70,6 +70,25 @@ namespace {
|
||||||
wgpu::TextureFormat::RGBA8Unorm;
|
wgpu::TextureFormat::RGBA8Unorm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Test the validation of non-zero texture usage
|
||||||
|
TEST_F(TextureValidationTest, UsageNonZero) {
|
||||||
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
||||||
|
// Descriptor with proper usage is allowed
|
||||||
|
{
|
||||||
|
descriptor.usage = wgpu::TextureUsage::RenderAttachment;
|
||||||
|
|
||||||
|
device.CreateTexture(&descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// It is an error to create a texture with zero usage
|
||||||
|
{
|
||||||
|
descriptor.usage = wgpu::TextureUsage::None;
|
||||||
|
|
||||||
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test the validation of sample count
|
// Test the validation of sample count
|
||||||
TEST_F(TextureValidationTest, SampleCount) {
|
TEST_F(TextureValidationTest, SampleCount) {
|
||||||
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor defaultDescriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace {
|
||||||
// Test texture views compatibility rules.
|
// Test texture views compatibility rules.
|
||||||
TEST_F(VideoViewsValidation, CreateViewFails) {
|
TEST_F(VideoViewsValidation, CreateViewFails) {
|
||||||
wgpu::Texture videoTexture = CreateVideoTextureForTest(
|
wgpu::Texture videoTexture = CreateVideoTextureForTest(
|
||||||
wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::None);
|
wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::TextureBinding);
|
||||||
|
|
||||||
wgpu::TextureViewDescriptor viewDesc = {};
|
wgpu::TextureViewDescriptor viewDesc = {};
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ namespace {
|
||||||
wgpu::TextureDescriptor desc;
|
wgpu::TextureDescriptor desc;
|
||||||
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
desc.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
desc.dimension = wgpu::TextureDimension::e2D;
|
desc.dimension = wgpu::TextureDimension::e2D;
|
||||||
desc.usage = wgpu::TextureUsage::None;
|
desc.usage = wgpu::TextureUsage::TextureBinding;
|
||||||
desc.size = {1, 1, 1};
|
desc.size = {1, 1, 1};
|
||||||
|
|
||||||
wgpu::Texture texture = device.CreateTexture(&desc);
|
wgpu::Texture texture = device.CreateTexture(&desc);
|
||||||
|
@ -91,7 +91,7 @@ namespace {
|
||||||
// Test texture views compatibility rules.
|
// Test texture views compatibility rules.
|
||||||
TEST_F(VideoViewsValidation, CreateViewSucceeds) {
|
TEST_F(VideoViewsValidation, CreateViewSucceeds) {
|
||||||
wgpu::Texture yuvTexture = CreateVideoTextureForTest(
|
wgpu::Texture yuvTexture = CreateVideoTextureForTest(
|
||||||
wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::None);
|
wgpu::TextureFormat::R8BG8Biplanar420Unorm, wgpu::TextureUsage::TextureBinding);
|
||||||
|
|
||||||
// Per plane view formats unspecified.
|
// Per plane view formats unspecified.
|
||||||
wgpu::TextureViewDescriptor planeViewDesc = {};
|
wgpu::TextureViewDescriptor planeViewDesc = {};
|
||||||
|
|
Loading…
Reference in New Issue