mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-07 21:55:53 +00:00
Keyed mutex support was deprecated and the only known client using it, Chromium, has migrated to fences. Remove all related keyed mutex related code and tests. The useFenceSynchronization field is still present in the external image descriptor since it's set by Chromium (to true) - it'll be removed once Chromium stops setting it. Bug: dawn:1612 Change-Id: Iaec3c16b18bb8ddbde55a7f54eaf4b944d0f06c6 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129300 Reviewed-by: Austin Eng <enga@chromium.org> Auto-Submit: Sunny Sachanandani <sunnyps@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
115 lines
4.1 KiB
C++
115 lines
4.1 KiB
C++
// Copyright 2018 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#ifndef INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
|
|
#define INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
|
|
|
|
#include <DXGI1_4.h>
|
|
#include <d3d12.h>
|
|
#include <windows.h>
|
|
#include <wrl/client.h>
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "dawn/native/D3DBackend.h"
|
|
|
|
struct ID3D12Device;
|
|
struct ID3D12Resource;
|
|
|
|
namespace dawn::native::d3d12 {
|
|
|
|
class Device;
|
|
class ExternalImageDXGIImpl;
|
|
|
|
DAWN_NATIVE_EXPORT Microsoft::WRL::ComPtr<ID3D12Device> GetD3D12Device(WGPUDevice device);
|
|
|
|
enum MemorySegment {
|
|
Local,
|
|
NonLocal,
|
|
};
|
|
|
|
DAWN_NATIVE_EXPORT uint64_t SetExternalMemoryReservation(WGPUDevice device,
|
|
uint64_t requestedReservationSize,
|
|
MemorySegment memorySegment);
|
|
|
|
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDXGISharedHandle : ExternalImageDescriptor {
|
|
public:
|
|
ExternalImageDescriptorDXGISharedHandle();
|
|
|
|
// Note: SharedHandle must be a handle to a texture object.
|
|
HANDLE sharedHandle = nullptr;
|
|
|
|
// Deprecated: Fence synchronization is always used after keyed mutex support was removed.
|
|
// TODO(dawn:1612): Remove once Chromium stops setting this.
|
|
bool useFenceSynchronization = false;
|
|
};
|
|
|
|
struct DAWN_NATIVE_EXPORT ExternalImageDXGIFenceDescriptor {
|
|
// Shared handle for the fence. This never passes ownership to the callee (when used as an input
|
|
// parameter) or to the caller (when used as a return value or output parameter).
|
|
HANDLE fenceHandle = nullptr;
|
|
|
|
// The value that was previously signaled on this fence and should be waited on.
|
|
uint64_t fenceValue = 0;
|
|
};
|
|
|
|
struct DAWN_NATIVE_EXPORT ExternalImageDXGIBeginAccessDescriptor {
|
|
bool isInitialized = false; // Whether the texture is initialized on import
|
|
WGPUTextureUsageFlags usage = WGPUTextureUsage_None;
|
|
|
|
// A list of fences to wait on before accessing the texture.
|
|
std::vector<ExternalImageDXGIFenceDescriptor> waitFences;
|
|
|
|
// Whether the texture is for a WebGPU swap chain.
|
|
bool isSwapChainTexture = false;
|
|
};
|
|
|
|
class DAWN_NATIVE_EXPORT ExternalImageDXGI {
|
|
public:
|
|
~ExternalImageDXGI();
|
|
|
|
static std::unique_ptr<ExternalImageDXGI> Create(
|
|
WGPUDevice device,
|
|
const ExternalImageDescriptorDXGISharedHandle* descriptor);
|
|
|
|
// Returns true if the external image resources are still valid, otherwise BeginAccess() is
|
|
// guaranteed to fail e.g. after device destruction.
|
|
bool IsValid() const;
|
|
|
|
// Creates WGPUTexture wrapping the DXGI shared handle. The provided wait fences will be
|
|
// synchronized before using the texture in any command lists. Empty fences (nullptr handle) are
|
|
// ignored for convenience (EndAccess can return such fences).
|
|
WGPUTexture BeginAccess(const ExternalImageDXGIBeginAccessDescriptor* descriptor);
|
|
|
|
// Returns the signalFence that the client must wait on for correct synchronization. Can return
|
|
// an empty fence (nullptr handle) if the texture wasn't accessed by Dawn.
|
|
// Note that merely calling Destroy() on the WGPUTexture does not ensure synchronization.
|
|
void EndAccess(WGPUTexture texture, ExternalImageDXGIFenceDescriptor* signalFence);
|
|
|
|
private:
|
|
explicit ExternalImageDXGI(std::unique_ptr<ExternalImageDXGIImpl> impl);
|
|
|
|
std::unique_ptr<ExternalImageDXGIImpl> mImpl;
|
|
};
|
|
|
|
struct DAWN_NATIVE_EXPORT AdapterDiscoveryOptions : public d3d::AdapterDiscoveryOptions {
|
|
AdapterDiscoveryOptions();
|
|
explicit AdapterDiscoveryOptions(Microsoft::WRL::ComPtr<IDXGIAdapter> adapter);
|
|
};
|
|
|
|
} // namespace dawn::native::d3d12
|
|
|
|
#endif // INCLUDE_DAWN_NATIVE_D3D12BACKEND_H_
|