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:
parent
b8ea84cbb8
commit
dbe74bc4a2
|
@ -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)"
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue