Create 1x1 Dummy Texture For Single-Plane External Textures
Creates a 1x1x1 dummy texture that will be bound, but unused to shaders that use external textures. It is expected that a special texture type will be introduced and used in the future to optimize backends that allow null bindings. Bug: dawn:1082 Change-Id: I0c49f58f6a725290ec9b73b09578c0f85e5b38d7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78940 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
This commit is contained in:
parent
2fbc170827
commit
012840b752
|
@ -125,7 +125,31 @@ namespace dawn::native {
|
|||
const ExternalTextureDescriptor* descriptor) {
|
||||
// Store any passed in TextureViews associated with individual planes.
|
||||
mTextureViews[0] = descriptor->plane0;
|
||||
|
||||
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.
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace dawn::native {
|
|||
ExternalTextureBase(DeviceBase* device, const ExternalTextureDescriptor* descriptor);
|
||||
ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
Ref<TextureBase> mDummyTexture;
|
||||
Ref<BufferBase> mParamsBuffer;
|
||||
std::array<Ref<TextureViewBase>, kMaxPlanesPerFormat> mTextureViews;
|
||||
|
||||
|
|
|
@ -131,9 +131,6 @@ namespace dawn::native {
|
|||
const std::array<Ref<TextureViewBase>, 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<Ref<TextureViewBase>, 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);
|
||||
|
|
|
@ -180,9 +180,6 @@ namespace dawn::native::d3d12 {
|
|||
const std::array<Ref<TextureViewBase>, 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();
|
||||
|
|
|
@ -495,9 +495,6 @@ namespace dawn::native::metal {
|
|||
const std::array<Ref<TextureViewBase>, 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());
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -134,9 +134,6 @@ namespace dawn::native::vulkan {
|
|||
const std::array<Ref<dawn::native::TextureViewBase>, 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());
|
||||
|
|
Loading…
Reference in New Issue