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>
This commit is contained in:
Corentin Wallez 2019-09-10 08:30:43 +00:00 committed by Commit Bot service account
parent b8ea84cbb8
commit dbe74bc4a2
3 changed files with 24 additions and 1 deletions

View File

@ -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)"

View File

@ -235,6 +235,11 @@ namespace dawn_native {
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");

View File

@ -345,4 +345,21 @@ TEST_F(TextureViewValidationTest, DestroyCreateTextureView) {
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