Add Device.CreateErrorExternalTexture()
Creating GPUExternalTexture from destroyed device should return an error external texture instead of a valid one. Adding this API for such usage. Bug: 1336713, 1338182 Change-Id: Ie7d13811a9c1e8890ba91045c88af63f3fb09687 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94534 Commit-Queue: Shaobo Yan <shaobo.yan@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
54b3da95f8
commit
7ce3c2da35
|
@ -1022,6 +1022,11 @@
|
||||||
{"name": "external texture descriptor", "type": "external texture descriptor", "annotation": "const*"}
|
{"name": "external texture descriptor", "type": "external texture descriptor", "annotation": "const*"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "create error external texture",
|
||||||
|
"returns": "external texture",
|
||||||
|
"tags": ["dawn"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "create pipeline layout",
|
"name": "create pipeline layout",
|
||||||
"returns": "pipeline layout",
|
"returns": "pipeline layout",
|
||||||
|
|
|
@ -1222,6 +1222,10 @@ BufferBase* DeviceBase::APICreateErrorBuffer() {
|
||||||
return BufferBase::MakeError(this, &desc);
|
return BufferBase::MakeError(this, &desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExternalTextureBase* DeviceBase::APICreateErrorExternalTexture() {
|
||||||
|
return ExternalTextureBase::MakeError(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Other Device API methods
|
// Other Device API methods
|
||||||
|
|
||||||
// Returns true if future ticking is needed.
|
// Returns true if future ticking is needed.
|
||||||
|
|
|
@ -264,6 +264,8 @@ class DeviceBase : public RefCountedWithExternalCount {
|
||||||
// For Dawn Wire
|
// For Dawn Wire
|
||||||
BufferBase* APICreateErrorBuffer();
|
BufferBase* APICreateErrorBuffer();
|
||||||
|
|
||||||
|
ExternalTextureBase* APICreateErrorExternalTexture();
|
||||||
|
|
||||||
QueueBase* APIGetQueue();
|
QueueBase* APIGetQueue();
|
||||||
|
|
||||||
bool APIGetLimits(SupportedLimits* limits) const;
|
bool APIGetLimits(SupportedLimits* limits) const;
|
||||||
|
|
|
@ -123,8 +123,9 @@ ExternalTextureBase::ExternalTextureBase(DeviceBase* device)
|
||||||
TrackInDevice();
|
TrackInDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error external texture cannot be used in bind group.
|
||||||
ExternalTextureBase::ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
ExternalTextureBase::ExternalTextureBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||||
: ApiObjectBase(device, tag) {}
|
: ApiObjectBase(device, tag), mState(ExternalTextureState::Destroyed) {}
|
||||||
|
|
||||||
ExternalTextureBase::~ExternalTextureBase() = default;
|
ExternalTextureBase::~ExternalTextureBase() = default;
|
||||||
|
|
||||||
|
|
|
@ -541,4 +541,28 @@ TEST_F(ExternalTextureTest, BindGroupDoesNotMatchLayout) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure that bind group validation catches error external textures.
|
||||||
|
TEST_F(ExternalTextureTest, UseErrorExternalTextureInBindGroup) {
|
||||||
|
// Control case should succeed.
|
||||||
|
{
|
||||||
|
wgpu::TextureDescriptor textureDescriptor = CreateTextureDescriptor();
|
||||||
|
wgpu::Texture texture = device.CreateTexture(&textureDescriptor);
|
||||||
|
|
||||||
|
wgpu::ExternalTextureDescriptor externalDesc = CreateDefaultExternalTextureDescriptor();
|
||||||
|
externalDesc.plane0 = texture.CreateView();
|
||||||
|
wgpu::ExternalTexture externalTexture = device.CreateExternalTexture(&externalDesc);
|
||||||
|
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||||
|
device, {{0, wgpu::ShaderStage::Fragment, &utils::kExternalTextureBindingLayout}});
|
||||||
|
utils::MakeBindGroup(device, bgl, {{0, externalTexture}});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind group creation should fail when an error external texture is present.
|
||||||
|
{
|
||||||
|
wgpu::ExternalTexture errorExternalTexture = device.CreateErrorExternalTexture();
|
||||||
|
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||||
|
device, {{0, wgpu::ShaderStage::Fragment, &utils::kExternalTextureBindingLayout}});
|
||||||
|
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bgl, {{0, errorExternalTexture}}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
Loading…
Reference in New Issue