#include "dawn/native/Instance.h"
#include <utility>
#include "dawn/common/Assert.h"
#include "dawn/common/FutureUtils.h"
#include "dawn/common/GPUInfo.h"
#include "dawn/common/Log.h"
#include "dawn/common/SystemUtils.h"
#include "dawn/common/WGSLFeatureMapping.h"
#include "dawn/native/CallbackTaskManager.h"
#include "dawn/native/ChainUtils.h"
#include "dawn/native/Device.h"
#include "dawn/native/ErrorData.h"
#include "dawn/native/Surface.h"
#include "dawn/native/Toggles.h"
#include "dawn/native/ValidationUtils_autogen.h"
#include "dawn/platform/DawnPlatform.h"
#include "partition_alloc/pointers/raw_ptr.h"
#include "tint/lang/wgsl/features/status.h"
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
#include "dawn/native/VulkanBackend.h"
#endif
#if defined(DAWN_ENABLE_BACKEND_D3D11) || defined(DAWN_ENABLE_BACKEND_D3D12)
#include "dawn/native/D3DBackend.h"
#include "dawn/native/d3d/BackendD3D.h"
#include "dawn/native/d3d/D3DError.h"
#endif
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
#include "dawn/native/OpenGLBackend.h"
#endif
#if defined(DAWN_USE_X11)
#include "dawn/native/X11Functions.h"
#endif
namespace dawn::native {
#if defined(DAWN_ENABLE_BACKEND_D3D11)
namespace d3d11 {
BackendConnection* Connect(InstanceBase* instance);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_D3D12)
namespace d3d12 {
BackendConnection* Connect(InstanceBase* instance);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_METAL)
namespace metal {
BackendConnection* Connect(InstanceBase* instance);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_NULL)
namespace null {
BackendConnection* Connect(InstanceBase* instance);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
namespace opengl {
BackendConnection* Connect(InstanceBase* instance, wgpu::BackendType backendType);
}
#endif
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
namespace vulkan {
BackendConnection* Connect(InstanceBase* instance);
}
#endif
namespace {
wgpu::WGSLFeatureName ToWGPUFeature(tint::wgsl::LanguageFeature f) { … }
}
wgpu::Status APIGetInstanceFeatures(InstanceFeatures* features) { … }
InstanceBase* APICreateInstance(const InstanceDescriptor* descriptor) { … }
struct InstanceBase::DeprecationWarnings { … };
ResultOrError<Ref<InstanceBase>> InstanceBase::Create(const InstanceDescriptor* descriptor) { … }
InstanceBase::InstanceBase(const TogglesState& instanceToggles)
: … { … }
InstanceBase::~InstanceBase() = default;
void InstanceBase::DeleteThis() { … }
void InstanceBase::DisconnectDawnPlatform() { … }
void InstanceBase::WillDropLastExternalRef() { … }
MaybeError InstanceBase::Initialize(const UnpackedPtr<InstanceDescriptor>& descriptor) { … }
void InstanceBase::APIRequestAdapter(const RequestAdapterOptions* options,
WGPURequestAdapterCallback callback,
void* userdata) { … }
Future InstanceBase::APIRequestAdapterF(const RequestAdapterOptions* options,
const RequestAdapterCallbackInfo& callbackInfo) { … }
Future InstanceBase::APIRequestAdapter2(const RequestAdapterOptions* options,
const WGPURequestAdapterCallbackInfo2& callbackInfo) { … }
Ref<AdapterBase> InstanceBase::CreateAdapter(Ref<PhysicalDeviceBase> physicalDevice,
FeatureLevel featureLevel,
const DawnTogglesDescriptor* requiredAdapterToggles,
wgpu::PowerPreference powerPreference) { … }
const TogglesState& InstanceBase::GetTogglesState() const { … }
const ToggleInfo* InstanceBase::GetToggleInfo(const char* toggleName) { … }
Toggle InstanceBase::ToggleNameToEnum(const char* toggleName) { … }
std::vector<Ref<AdapterBase>> InstanceBase::EnumerateAdapters(
const RequestAdapterOptions* options) { … }
BackendConnection* InstanceBase::GetBackendConnection(wgpu::BackendType backendType) { … }
std::vector<Ref<PhysicalDeviceBase>> InstanceBase::EnumeratePhysicalDevices(
const UnpackedPtr<RequestAdapterOptions>& options) { … }
bool InstanceBase::ConsumedErrorAndWarnOnce(MaybeError maybeErr) { … }
bool InstanceBase::IsBackendValidationEnabled() const { … }
void InstanceBase::SetBackendValidationLevel(BackendValidationLevel level) { … }
BackendValidationLevel InstanceBase::GetBackendValidationLevel() const { … }
bool InstanceBase::IsBeginCaptureOnStartupEnabled() const { … }
void InstanceBase::SetPlatform(dawn::platform::Platform* platform) { … }
void InstanceBase::SetPlatformForTesting(dawn::platform::Platform* platform) { … }
dawn::platform::Platform* InstanceBase::GetPlatform() { … }
uint64_t InstanceBase::GetDeprecationWarningCountForTesting() { … }
void InstanceBase::EmitDeprecationWarning(const std::string& message) { … }
uint64_t InstanceBase::GetDeviceCountForTesting() const { … }
void InstanceBase::AddDevice(DeviceBase* device) { … }
void InstanceBase::RemoveDevice(DeviceBase* device) { … }
bool InstanceBase::ProcessEvents() { … }
void InstanceBase::APIProcessEvents() { … }
wgpu::WaitStatus InstanceBase::APIWaitAny(size_t count,
FutureWaitInfo* futures,
uint64_t timeoutNS) { … }
const std::vector<std::string>& InstanceBase::GetRuntimeSearchPaths() const { … }
const Ref<CallbackTaskManager>& InstanceBase::GetCallbackTaskManager() const { … }
EventManager* InstanceBase::GetEventManager() { … }
void InstanceBase::ConsumeError(std::unique_ptr<ErrorData> error,
InternalErrorType additionalAllowedErrors) { … }
const X11Functions* InstanceBase::GetOrLoadX11Functions() { … }
Surface* InstanceBase::APICreateSurface(const SurfaceDescriptor* descriptor) { … }
const absl::flat_hash_set<tint::wgsl::LanguageFeature>&
InstanceBase::GetAllowedWGSLLanguageFeatures() const { … }
void InstanceBase::GatherWGSLFeatures(const DawnWGSLBlocklist* wgslBlocklist) { … }
bool InstanceBase::APIHasWGSLLanguageFeature(wgpu::WGSLFeatureName feature) const { … }
size_t InstanceBase::APIEnumerateWGSLLanguageFeatures(wgpu::WGSLFeatureName* features) const { … }
}