Add TextureViewDescriptor.aspect.
This is to match the WebGPU IDL, but currently that member defaults and
must be set to "all".
BUG=dawn:22
Change-Id: I5f4d160163cb45e0ef043853518fe91b47b00d0f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10961
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/dawn.json b/dawn.json
index 45be7bb..386d8ad 100644
--- a/dawn.json
+++ b/dawn.json
@@ -1319,7 +1319,8 @@
{"name": "base mip level", "type": "uint32_t", "default": "0"},
{"name": "mip level count", "type": "uint32_t", "default": "0"},
{"name": "base array layer", "type": "uint32_t", "default": "0"},
- {"name": "array layer count", "type": "uint32_t", "default": "0"}
+ {"name": "array layer count", "type": "uint32_t", "default": "0"},
+ {"name": "aspect", "type": "texture aspect", "default": "all"}
],
"TODO": [
"jiawei.shao@intel.com: Allow choosing the aspect (depth vs. stencil)"
diff --git a/src/dawn_native/Texture.cpp b/src/dawn_native/Texture.cpp
index f6370a8..e5e2c49 100644
--- a/src/dawn_native/Texture.cpp
+++ b/src/dawn_native/Texture.cpp
@@ -235,6 +235,11 @@
DAWN_TRY(ValidateTextureFormat(descriptor->format));
+ DAWN_TRY(ValidateTextureAspect(descriptor->aspect));
+ if (descriptor->aspect != dawn::TextureAspect::All) {
+ return DAWN_VALIDATION_ERROR("Texture aspect must be 'all'");
+ }
+
// TODO(jiawei.shao@intel.com): check stuff based on resource limits
if (descriptor->arrayLayerCount == 0 || descriptor->mipLevelCount == 0) {
return DAWN_VALIDATION_ERROR("Cannot create an empty texture view");
diff --git a/src/tests/unittests/validation/TextureViewValidationTests.cpp b/src/tests/unittests/validation/TextureViewValidationTests.cpp
index 8d7d219..f68f46c 100644
--- a/src/tests/unittests/validation/TextureViewValidationTests.cpp
+++ b/src/tests/unittests/validation/TextureViewValidationTests.cpp
@@ -345,4 +345,21 @@
texture.Destroy();
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
+
+// Test that only TextureAspect::All is supported
+TEST_F(TextureViewValidationTest, AspectMustBeAll) {
+ dawn::TextureDescriptor descriptor = {};
+ descriptor.size = {1, 1, 1};
+ descriptor.format = dawn::TextureFormat::Depth32Float;
+ descriptor.usage = dawn::TextureUsage::Sampled | dawn::TextureUsage::OutputAttachment;
+ dawn::Texture texture = device.CreateTexture(&descriptor);
+
+ dawn::TextureViewDescriptor viewDescriptor = {};
+ viewDescriptor.aspect = dawn::TextureAspect::All;
+ texture.CreateView(&viewDescriptor);
+
+ viewDescriptor.aspect = dawn::TextureAspect::DepthOnly;
+ ASSERT_DEVICE_ERROR(texture.CreateView(&viewDescriptor));
}
+
+} // anonymous namespace