D3D12: Use typed integers for the ExternalMutexSerial
This will prevent mixing it up with other serial types in the future. Bug: dawn:442 Change-Id: Ia1ec00572fa268e48349f7d9e39234ec8f5d3953 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28961 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
cac14e0067
commit
ad4a66ec8f
|
@ -64,7 +64,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
const ExternalImageDescriptorDXGISharedHandle* descriptor) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
Ref<TextureBase> texture = backendDevice->WrapSharedHandle(
|
||||
descriptor, descriptor->sharedHandle, descriptor->acquireMutexKey,
|
||||
descriptor, descriptor->sharedHandle, ExternalMutexSerial(descriptor->acquireMutexKey),
|
||||
descriptor->isSwapChainTexture);
|
||||
return reinterpret_cast<WGPUTexture>(texture.Detach());
|
||||
}
|
||||
|
|
|
@ -407,7 +407,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
Ref<TextureBase> Device::WrapSharedHandle(const ExternalImageDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey,
|
||||
ExternalMutexSerial acquireMutexKey,
|
||||
bool isSwapChainTexture) {
|
||||
Ref<TextureBase> dawnTexture;
|
||||
if (ConsumedError(Texture::Create(this, descriptor, sharedHandle, acquireMutexKey,
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
Ref<TextureBase> WrapSharedHandle(const ExternalImageDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey,
|
||||
ExternalMutexSerial acquireMutexKey,
|
||||
bool isSwapChainTexture);
|
||||
ResultOrError<ComPtr<IDXGIKeyedMutex>> CreateKeyedMutexForTexture(
|
||||
ID3D12Resource* d3d12Resource);
|
||||
|
|
|
@ -26,6 +26,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
// BindGroup allocations.
|
||||
using HeapVersionID = TypedInteger<struct HeapVersionIDT, uint64_t>;
|
||||
|
||||
// The monotonically increasing serial for external D3D12 mutexes imported in Dawn.
|
||||
using ExternalMutexSerial = TypedInteger<struct ExternalMutexSerialT, uint64_t>;
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
||||
#endif // DAWNNATIVE_D3D12_INTEGERTYPES_H_
|
||||
|
|
|
@ -389,7 +389,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
ResultOrError<Ref<TextureBase>> Texture::Create(Device* device,
|
||||
const ExternalImageDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey,
|
||||
ExternalMutexSerial acquireMutexKey,
|
||||
bool isSwapChainTexture) {
|
||||
const TextureDescriptor* textureDescriptor =
|
||||
reinterpret_cast<const TextureDescriptor*>(descriptor->cTextureDescriptor);
|
||||
|
@ -405,7 +405,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
MaybeError Texture::InitializeAsExternalTexture(const TextureDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey,
|
||||
ExternalMutexSerial acquireMutexKey,
|
||||
bool isSwapChainTexture) {
|
||||
Device* dawnDevice = ToBackend(GetDevice());
|
||||
DAWN_TRY(ValidateTextureDescriptor(dawnDevice, descriptor));
|
||||
|
@ -422,7 +422,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
DAWN_TRY_ASSIGN(dxgiKeyedMutex,
|
||||
dawnDevice->CreateKeyedMutexForTexture(d3d12Resource.Get()));
|
||||
|
||||
DAWN_TRY(CheckHRESULT(dxgiKeyedMutex->AcquireSync(acquireMutexKey, INFINITE),
|
||||
DAWN_TRY(CheckHRESULT(dxgiKeyedMutex->AcquireSync(uint64_t(acquireMutexKey), INFINITE),
|
||||
"D3D12 acquiring shared mutex"));
|
||||
|
||||
mAcquireMutexKey = acquireMutexKey;
|
||||
|
@ -529,7 +529,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
device->DeallocateMemory(mResourceAllocation);
|
||||
|
||||
if (mDxgiKeyedMutex != nullptr) {
|
||||
mDxgiKeyedMutex->ReleaseSync(mAcquireMutexKey + 1);
|
||||
mDxgiKeyedMutex->ReleaseSync(uint64_t(mAcquireMutexKey) + 1);
|
||||
device->ReleaseKeyedMutexForTexture(std::move(mDxgiKeyedMutex));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_native/PassResourceUsage.h"
|
||||
#include "dawn_native/d3d12/IntegerTypes.h"
|
||||
#include "dawn_native/d3d12/ResourceHeapAllocationD3D12.h"
|
||||
#include "dawn_native/d3d12/d3d12_platform.h"
|
||||
|
||||
|
@ -40,7 +41,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
static ResultOrError<Ref<TextureBase>> Create(Device* device,
|
||||
const ExternalImageDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey,
|
||||
ExternalMutexSerial acquireMutexKey,
|
||||
bool isSwapChainTexture);
|
||||
Texture(Device* device,
|
||||
const TextureDescriptor* descriptor,
|
||||
|
@ -85,7 +86,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
MaybeError InitializeAsInternalTexture();
|
||||
MaybeError InitializeAsExternalTexture(const TextureDescriptor* descriptor,
|
||||
HANDLE sharedHandle,
|
||||
uint64_t acquireMutexKey,
|
||||
ExternalMutexSerial acquireMutexKey,
|
||||
bool isSwapChainTexture);
|
||||
|
||||
// Dawn API
|
||||
|
@ -118,7 +119,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
ResourceHeapAllocation mResourceAllocation;
|
||||
bool mSwapChainTexture = false;
|
||||
|
||||
Serial mAcquireMutexKey = 0;
|
||||
ExternalMutexSerial mAcquireMutexKey = ExternalMutexSerial(0);
|
||||
ComPtr<IDXGIKeyedMutex> mDxgiKeyedMutex;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue