Add wgpu::Device::ValidateTextureDescriptor

Bug: chromium:1266549
Change-Id: Iaef63ca6f4e447450953dfb0633b43931d8c2552
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116294
Reviewed-by: Brandon Jones <bajones@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2023-01-10 15:17:26 +00:00 committed by Dawn LUCI CQ
parent 42fed14a21
commit 0963142273
4 changed files with 27 additions and 0 deletions

View File

@ -1229,6 +1229,13 @@
"args": [
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen"}
]
},
{
"name": "validate texture descriptor",
"tags": ["dawn"],
"args": [
{"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
]
}
]
},

View File

@ -1386,6 +1386,10 @@ void DeviceBase::APIInjectError(wgpu::ErrorType type, const char* message) {
HandleError(FromWGPUErrorType(type), message);
}
void DeviceBase::APIValidateTextureDescriptor(const TextureDescriptor* desc) {
ConsumedError(ValidateTextureDescriptor(this, desc));
}
QueueBase* DeviceBase::GetQueue() const {
ASSERT(mQueue != nullptr);
return mQueue.Get();

View File

@ -284,6 +284,7 @@ class DeviceBase : public RefCountedWithExternalCount {
size_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
void APIInjectError(wgpu::ErrorType type, const char* message);
bool APITick();
void APIValidateTextureDescriptor(const TextureDescriptor* desc);
void APISetDeviceLostCallback(wgpu::DeviceLostCallback callback, void* userdata);
void APISetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);

View File

@ -997,4 +997,19 @@ TEST_F(TextureValidationTest, CreationParameterReflectionForCreateErrorTexture)
CheckTextureMatchesDescriptor(tex, desc);
}
// A tiny test that Device::ValidateTextureDescriptor works, under the assumption that all the
// texture validation logic is implemented through it (so there is no need to re-test every possible
// failure case).
TEST_F(TextureValidationTest, APIValidateTextureDescriptor) {
wgpu::TextureDescriptor desc;
desc.format = wgpu::TextureFormat::RGBA8Unorm;
desc.size = {1, 1, 1};
desc.usage = wgpu::TextureUsage::RenderAttachment;
device.ValidateTextureDescriptor(&desc);
desc.size.width = 0;
ASSERT_DEVICE_ERROR(device.ValidateTextureDescriptor(&desc));
}
} // namespace