mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
d3d12: Add support for fences for external images
DXGI external images can now be imported with both fence and texture shared handles. Fence wait and signal values can be specified for ProduceTexture. Keyed mutex functionality is kept as is with no change. The D3D12 resource wrapping tests now run in both keyed mutex and fence modes. Bug: dawn:576 Change-Id: Ic793bcc828e5a8850c1367ecffabedd1c67184d9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/78604 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Sunny Sachanandani <sunnyps@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
faf98b1bbc
commit
7ce85091b9
@@ -52,20 +52,43 @@ struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImag
|
||||
ExternalImageDescriptorDXGISharedHandle();
|
||||
|
||||
// Note: SharedHandle must be a handle to a texture object.
|
||||
HANDLE sharedHandle;
|
||||
// TODO(dawn:576): Remove after changing Chromium code to set textureSharedHandle.
|
||||
HANDLE sharedHandle = nullptr;
|
||||
HANDLE textureSharedHandle = nullptr;
|
||||
|
||||
// Optional shared handle to a D3D11/12 fence which can be used to synchronize using wait/signal
|
||||
// values specified in the access descriptor below. If null, the texture will be assumed to have
|
||||
// an associated DXGI keyed mutex which will be used with a fixed key of 0 for synchronization.
|
||||
HANDLE fenceSharedHandle = nullptr;
|
||||
};
|
||||
|
||||
// Keyed mutex acquire/release uses a fixed key of 0 to match Chromium behavior.
|
||||
constexpr UINT64 kDXGIKeyedMutexAcquireReleaseKey = 0;
|
||||
|
||||
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGIKeyedMutex
|
||||
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGISharedHandle
|
||||
: ExternalImageAccessDescriptor {
|
||||
public:
|
||||
// Value used for fence wait. A value of 0 is valid, but essentially a no-op since the fence
|
||||
// lifetime starts with the 0 value signaled. A value of UINT64_MAX is ignored since it's also
|
||||
// used by the D3D runtime to indicate that the device was removed.
|
||||
uint64_t fenceWaitValue = 0;
|
||||
|
||||
// Value to signal the fence with after the texture is destroyed. A value of 0 means the fence
|
||||
// will not be signaled.
|
||||
uint64_t fenceSignalValue = 0;
|
||||
|
||||
// Whether the texture is for a WebGPU swap chain.
|
||||
bool isSwapChainTexture = false;
|
||||
};
|
||||
|
||||
// TODO(dawn:576): Remove after changing Chromium code to use the new struct name.
|
||||
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptorDXGIKeyedMutex
|
||||
: ExternalImageAccessDescriptorDXGISharedHandle {
|
||||
public:
|
||||
// TODO(chromium:1241533): Remove deprecated keyed mutex params after removing associated
|
||||
// code from Chromium - we use a fixed key of 0 for acquire and release everywhere now.
|
||||
uint64_t acquireMutexKey;
|
||||
uint64_t releaseMutexKey;
|
||||
bool isSwapChainTexture = false;
|
||||
};
|
||||
|
||||
class DAWN_NATIVE_EXPORT ExternalImageDXGI {
|
||||
@@ -78,13 +101,15 @@ class DAWN_NATIVE_EXPORT ExternalImageDXGI {
|
||||
const ExternalImageDescriptorDXGISharedHandle* descriptor);
|
||||
|
||||
WGPUTexture ProduceTexture(WGPUDevice device,
|
||||
const ExternalImageAccessDescriptorDXGIKeyedMutex* descriptor);
|
||||
const ExternalImageAccessDescriptorDXGISharedHandle* descriptor);
|
||||
|
||||
private:
|
||||
ExternalImageDXGI(Microsoft::WRL::ComPtr<ID3D12Resource> d3d12Resource,
|
||||
Microsoft::WRL::ComPtr<ID3D12Fence> d3d12Fence,
|
||||
const WGPUTextureDescriptor* descriptor);
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> mD3D12Resource;
|
||||
Microsoft::WRL::ComPtr<ID3D12Fence> mD3D12Fence;
|
||||
|
||||
// Contents of WGPUTextureDescriptor are stored individually since the descriptor
|
||||
// could outlive this image.
|
||||
|
||||
@@ -237,13 +237,13 @@ struct DAWN_NATIVE_EXPORT ExternalImageDescriptor {
|
||||
|
||||
struct DAWN_NATIVE_EXPORT ExternalImageAccessDescriptor {
|
||||
public:
|
||||
bool isInitialized; // Whether the texture is initialized on import
|
||||
WGPUTextureUsageFlags usage;
|
||||
bool isInitialized = false; // Whether the texture is initialized on import
|
||||
WGPUTextureUsageFlags usage = WGPUTextureUsage_None;
|
||||
};
|
||||
|
||||
struct DAWN_NATIVE_EXPORT ExternalImageExportInfo {
|
||||
public:
|
||||
bool isInitialized; // Whether the texture is initialized after export
|
||||
bool isInitialized = false; // Whether the texture is initialized after export
|
||||
ExternalImageType GetType() const;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user