Remove External Texture Format Member Validation

Removes validation of the format member of an external texture
descriptor. Replaces it with format information inferred from the passed
texture.

Bug: dawn:1082
Change-Id: I333c3659859501eff48a532aa4701f25a33124c2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77480
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
This commit is contained in:
Brandon Jones 2022-01-21 23:38:08 +00:00 committed by Dawn LUCI CQ
parent 7418eeff42
commit d90a4f50a1
2 changed files with 11 additions and 19 deletions

View File

@ -22,14 +22,7 @@
namespace dawn::native {
MaybeError ValidateExternalTexturePlane(const TextureViewBase* textureView,
wgpu::TextureFormat format) {
if (textureView->GetFormat().format != format) {
return DAWN_VALIDATION_ERROR(
"The external texture descriptor specifies a texture format that is different from "
"at least one of the passed texture views.");
}
MaybeError ValidateExternalTexturePlane(const TextureViewBase* textureView) {
DAWN_INVALID_IF(
(textureView->GetTexture()->GetUsage() & wgpu::TextureUsage::TextureBinding) == 0,
"The external texture plane (%s) usage (%s) doesn't include the required usage (%s)",
@ -57,22 +50,20 @@ namespace dawn::native {
DAWN_TRY(device->ValidateObject(descriptor->plane0));
const Format* format;
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format));
DAWN_UNUSED(format);
wgpu::TextureFormat plane0Format = descriptor->plane0->GetFormat().format;
switch (descriptor->format) {
switch (plane0Format) {
case wgpu::TextureFormat::RGBA8Unorm:
case wgpu::TextureFormat::BGRA8Unorm:
case wgpu::TextureFormat::RGBA16Float:
DAWN_TRY_CONTEXT(
ValidateExternalTexturePlane(descriptor->plane0, descriptor->format),
"validating plane0 against the external texture format (%s)",
descriptor->format);
DAWN_TRY(ValidateExternalTexturePlane(descriptor->plane0));
break;
default:
return DAWN_FORMAT_VALIDATION_ERROR(
"Format (%s) is not a supported external texture format.", descriptor->format);
"The external texture plane (%s) format (%s) is not a supported format "
"(%s, %s, %s).",
descriptor->plane0, plane0Format, wgpu::TextureFormat::RGBA8Unorm,
wgpu::TextureFormat::BGRA8Unorm, wgpu::TextureFormat::RGBA16Float);
}
return {};

View File

@ -357,9 +357,10 @@ TEST_F(BindGroupValidationTest, ExternalTextureBindingType) {
// Setting the external texture to an error external texture is an error.
{
wgpu::Texture errorTexture = CreateTexture(wgpu::TextureUsage::TextureBinding,
wgpu::TextureFormat::RGBA8UnormSrgb, 1);
wgpu::ExternalTextureDescriptor errorExternalDesciptor;
errorExternalDesciptor.plane0 = texture.CreateView();
errorExternalDesciptor.format = wgpu::TextureFormat::R8Uint;
errorExternalDesciptor.plane0 = errorTexture.CreateView();
wgpu::ExternalTexture errorExternalTexture;
ASSERT_DEVICE_ERROR(errorExternalTexture =