mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 14:08:04 +00:00
Add wrapping for using external vulkan images as textures
This change adds platform-dependent services that handle creating semaphores and importing image memory. Then, we use them to wrap a texture from an outside source, and release a signal semaphore back when we're done with it. This will be used to allow chrome to render dawn on Vulkan platforms. Bug: chromium:976495 Change-Id: I9f07eaf436e10aa6bd88cffdc74fd23834d62ee0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8340 Commit-Queue: Idan Raiter <idanr@google.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
8cb23933b1
commit
74e4834d3d
@@ -23,12 +23,44 @@
|
||||
#include <vector>
|
||||
|
||||
namespace dawn_native { namespace vulkan {
|
||||
|
||||
// Common properties of external images
|
||||
struct ExternalImageDescriptor {
|
||||
const DawnTextureDescriptor* cTextureDescriptor; // Must match image creation params
|
||||
bool isCleared; // Sets whether the texture will be cleared before use
|
||||
VkDeviceSize allocationSize; // Must match VkMemoryAllocateInfo from image creation
|
||||
uint32_t memoryTypeIndex; // Must match VkMemoryAllocateInfo from image creation
|
||||
};
|
||||
|
||||
DAWN_NATIVE_EXPORT VkInstance GetInstance(DawnDevice device);
|
||||
|
||||
DAWN_NATIVE_EXPORT DawnSwapChainImplementation CreateNativeSwapChainImpl(DawnDevice device,
|
||||
VkSurfaceKHR surface);
|
||||
DAWN_NATIVE_EXPORT DawnTextureFormat
|
||||
GetNativeSwapChainPreferredFormat(const DawnSwapChainImplementation* swapChain);
|
||||
|
||||
// Can't use DAWN_PLATFORM_LINUX since header included in both dawn and chrome
|
||||
#ifdef __linux__
|
||||
// Descriptor for opaque file descriptor image import
|
||||
struct ExternalImageDescriptorOpaqueFD : ExternalImageDescriptor {
|
||||
int memoryFD; // A file descriptor from an export of the memory of the image
|
||||
std::vector<int> waitFDs; // File descriptors of semaphores which will be waited on
|
||||
};
|
||||
|
||||
// Imports an external vulkan image from an opaque file descriptor. Internally, this uses
|
||||
// external memory / semaphore extensions to import the image. Then, waits on the provided
|
||||
// |descriptor->waitFDs| before the texture can be used. Finally, a signal semaphore
|
||||
// can be exported, transferring control back to the caller.
|
||||
// On failure, returns a nullptr
|
||||
DAWN_NATIVE_EXPORT DawnTexture
|
||||
WrapVulkanImageOpaqueFD(DawnDevice cDevice,
|
||||
const ExternalImageDescriptorOpaqueFD* descriptor);
|
||||
|
||||
// Exports a signal semaphore from a wrapped texture. This must be called on wrapped
|
||||
// textures before they are destroyed. On failure, returns -1
|
||||
DAWN_NATIVE_EXPORT int ExportSignalSemaphoreOpaqueFD(DawnDevice cDevice,
|
||||
DawnTexture cTexture);
|
||||
#endif // __linux__
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
||||
#endif // DAWNNATIVE_VULKANBACKEND_H_
|
||||
|
||||
Reference in New Issue
Block a user