TextureVk: Make a Create function for swapchain textures.
This aligns this constructor to be used via Create like the other vulkan::Texture constructors. Bug: dawn:269 Change-Id: Ib85874bf24bfe49b644b4faa63c9248c540811c8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/20882 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
07328ba0bb
commit
3874434bf1
|
@ -49,7 +49,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
VkImage nativeTexture =
|
||||
VkImage::CreateFromHandle(reinterpret_cast<::VkImage>(next.texture.u64));
|
||||
return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
|
||||
return Texture::CreateForSwapChain(ToBackend(GetDevice()), descriptor, nativeTexture)
|
||||
.Detach();
|
||||
}
|
||||
|
||||
MaybeError SwapChain::OnBeforePresent(TextureBase* texture) {
|
||||
|
|
|
@ -432,6 +432,16 @@ namespace dawn_native { namespace vulkan {
|
|||
return texture.Detach();
|
||||
}
|
||||
|
||||
// static
|
||||
Ref<Texture> Texture::CreateForSwapChain(Device* device,
|
||||
const TextureDescriptor* descriptor,
|
||||
VkImage nativeImage) {
|
||||
Ref<Texture> texture =
|
||||
AcquireRef(new Texture(device, descriptor, TextureState::OwnedExternal));
|
||||
texture->InitializeForSwapChain(nativeImage);
|
||||
return std::move(texture);
|
||||
}
|
||||
|
||||
MaybeError Texture::InitializeAsInternalTexture() {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
|
@ -491,11 +501,6 @@ namespace dawn_native { namespace vulkan {
|
|||
return {};
|
||||
}
|
||||
|
||||
// With this constructor, the lifetime of the resource is externally managed.
|
||||
Texture::Texture(Device* device, const TextureDescriptor* descriptor, VkImage nativeImage)
|
||||
: TextureBase(device, descriptor, TextureState::OwnedExternal), mHandle(nativeImage) {
|
||||
}
|
||||
|
||||
// Internally managed, but imported from external handle
|
||||
MaybeError Texture::InitializeFromExternal(const ExternalImageDescriptor* descriptor,
|
||||
external_memory::Service* externalMemoryService) {
|
||||
|
@ -529,6 +534,10 @@ namespace dawn_native { namespace vulkan {
|
|||
return {};
|
||||
}
|
||||
|
||||
void Texture::InitializeForSwapChain(VkImage nativeImage) {
|
||||
mHandle = nativeImage;
|
||||
}
|
||||
|
||||
MaybeError Texture::BindExternalMemory(const ExternalImageDescriptor* descriptor,
|
||||
VkSemaphore signalSemaphore,
|
||||
VkDeviceMemory externalMemoryAllocation,
|
||||
|
|
|
@ -52,7 +52,10 @@ namespace dawn_native { namespace vulkan {
|
|||
const TextureDescriptor* textureDescriptor,
|
||||
external_memory::Service* externalMemoryService);
|
||||
|
||||
Texture(Device* device, const TextureDescriptor* descriptor, VkImage nativeImage);
|
||||
// Creates a texture that wraps a swapchain-allocated VkImage.
|
||||
static Ref<Texture> CreateForSwapChain(Device* device,
|
||||
const TextureDescriptor* descriptor,
|
||||
VkImage nativeImage);
|
||||
|
||||
VkImage GetHandle() const;
|
||||
VkImageAspectFlags GetVkAspectMask() const;
|
||||
|
@ -79,10 +82,11 @@ namespace dawn_native { namespace vulkan {
|
|||
private:
|
||||
~Texture() override;
|
||||
using TextureBase::TextureBase;
|
||||
MaybeError InitializeAsInternalTexture();
|
||||
|
||||
MaybeError InitializeAsInternalTexture();
|
||||
MaybeError InitializeFromExternal(const ExternalImageDescriptor* descriptor,
|
||||
external_memory::Service* externalMemoryService);
|
||||
void InitializeForSwapChain(VkImage nativeImage);
|
||||
|
||||
void DestroyImpl() override;
|
||||
MaybeError ClearTexture(CommandRecordingContext* recordingContext,
|
||||
|
|
Loading…
Reference in New Issue