diff --git a/src/dawn_native/ExternalTexture.cpp b/src/dawn_native/ExternalTexture.cpp index db211045fe..c3126d834f 100644 --- a/src/dawn_native/ExternalTexture.cpp +++ b/src/dawn_native/ExternalTexture.cpp @@ -125,7 +125,31 @@ namespace dawn::native { const ExternalTextureDescriptor* descriptor) { // Store any passed in TextureViews associated with individual planes. mTextureViews[0] = descriptor->plane0; - mTextureViews[1] = descriptor->plane1; + + if (descriptor->plane1) { + mTextureViews[1] = descriptor->plane1; + } else { + TextureDescriptor textureDesc; + textureDesc.dimension = wgpu::TextureDimension::e2D; + textureDesc.format = wgpu::TextureFormat::RGBA8Unorm; + textureDesc.label = "Dawn_External_Texture_Dummy_Texture"; + textureDesc.size = {1, 1, 1}; + textureDesc.usage = wgpu::TextureUsage::TextureBinding; + + DAWN_TRY_ASSIGN(mDummyTexture, device->CreateTexture(&textureDesc)); + + TextureViewDescriptor textureViewDesc; + textureViewDesc.arrayLayerCount = 1; + textureViewDesc.aspect = wgpu::TextureAspect::All; + textureViewDesc.baseArrayLayer = 0; + textureViewDesc.dimension = wgpu::TextureViewDimension::e2D; + textureViewDesc.format = wgpu::TextureFormat::RGBA8Unorm; + textureViewDesc.label = "Dawn_External_Texture_Dummy_Texture_View"; + textureViewDesc.mipLevelCount = 1; + + DAWN_TRY_ASSIGN(mTextureViews[1], + device->CreateTextureView(mDummyTexture.Get(), &textureViewDesc)); + } // We must create a buffer to store parameters needed by a shader that operates on this // external texture. diff --git a/src/dawn_native/ExternalTexture.h b/src/dawn_native/ExternalTexture.h index 6a2476af1f..27df552827 100644 --- a/src/dawn_native/ExternalTexture.h +++ b/src/dawn_native/ExternalTexture.h @@ -65,6 +65,7 @@ namespace dawn::native { ExternalTextureBase(DeviceBase* device, const ExternalTextureDescriptor* descriptor); ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag); + Ref mDummyTexture; Ref mParamsBuffer; std::array, kMaxPlanesPerFormat> mTextureViews; diff --git a/src/dawn_native/PassResourceUsageTracker.cpp b/src/dawn_native/PassResourceUsageTracker.cpp index 2acb20794c..5fa4717587 100644 --- a/src/dawn_native/PassResourceUsageTracker.cpp +++ b/src/dawn_native/PassResourceUsageTracker.cpp @@ -131,9 +131,6 @@ namespace dawn::native { const std::array, kMaxPlanesPerFormat>& textureViews = externalTexture->GetTextureViews(); - // Only single-plane formats are supported right now, so assert only one - // view exists. - ASSERT(textureViews[1].Get() == nullptr); ASSERT(textureViews[2].Get() == nullptr); mExternalTextureUsages.insert(externalTexture); @@ -205,9 +202,6 @@ namespace dawn::native { const std::array, kMaxPlanesPerFormat>& textureViews = externalTexture->GetTextureViews(); - // Only single-plane formats are supported right now, so assert only one - // view exists. - ASSERT(textureViews[1].Get() == nullptr); ASSERT(textureViews[2].Get() == nullptr); mUsage.referencedExternalTextures.insert(externalTexture); diff --git a/src/dawn_native/d3d12/BindGroupD3D12.cpp b/src/dawn_native/d3d12/BindGroupD3D12.cpp index 7957bd5763..9e7522c1d0 100644 --- a/src/dawn_native/d3d12/BindGroupD3D12.cpp +++ b/src/dawn_native/d3d12/BindGroupD3D12.cpp @@ -180,9 +180,6 @@ namespace dawn::native::d3d12 { const std::array, kMaxPlanesPerFormat>& views = GetBindingAsExternalTexture(bindingIndex)->GetTextureViews(); - // Only single-plane formats are supported right now, so assert only one view - // exists. - ASSERT(views[1].Get() == nullptr); ASSERT(views[2].Get() == nullptr); auto& srv = ToBackend(views[0])->GetSRVDescriptor(); diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index 55c85e8c26..59716b729c 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -495,9 +495,6 @@ namespace dawn::native::metal { const std::array, kMaxPlanesPerFormat>& views = group->GetBindingAsExternalTexture(bindingIndex)->GetTextureViews(); - // Only single-plane formats are supported right now, so assert only one - // view exists. - ASSERT(views[1].Get() == nullptr); ASSERT(views[2].Get() == nullptr); TextureView* textureView = ToBackend(views[0].Get()); diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 2601d613dd..12f31c958d 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -370,9 +370,6 @@ namespace dawn::native::opengl { ->GetBindingAsExternalTexture(bindingIndex) ->GetTextureViews(); - // Only single-plane formats are supported right now, so assert only one - // view exists. - ASSERT(textureViews[1].Get() == nullptr); ASSERT(textureViews[2].Get() == nullptr); TextureView* view = ToBackend(textureViews[0].Get()); diff --git a/src/dawn_native/vulkan/BindGroupVk.cpp b/src/dawn_native/vulkan/BindGroupVk.cpp index fca8d88869..f94fa2dce9 100644 --- a/src/dawn_native/vulkan/BindGroupVk.cpp +++ b/src/dawn_native/vulkan/BindGroupVk.cpp @@ -134,9 +134,6 @@ namespace dawn::native::vulkan { const std::array, kMaxPlanesPerFormat>& textureViews = GetBindingAsExternalTexture(bindingIndex)->GetTextureViews(); - // Only single-plane formats are supported right now, so ensure only one view - // exists. - ASSERT(textureViews[1].Get() == nullptr); ASSERT(textureViews[2].Get() == nullptr); TextureView* view = ToBackend(textureViews[0].Get());