Zhaoming Jiang c2657b21d5 Dawn: Promote DisallowUnsafeAPIs as instance toggle
This CL add Instance and Adapter toggle stage, and promote
DisallowUnsafeAPIs as an instance toggle, and can be required using
DawnTogglesDescriptor chained in instance descriptor when creating
instance. The instance's toggles state will get inherited to adapters
and devices it create. Related tests are implemented and updated.

Toggles inheritance can be overriden if not forced, so requiring
DisallowUnsafeAPIs when creating device is still available and working
like before.

Note that currently we don't have toggle of adapter stage, and can not
require toggles when creating adapter, until follow up CLs implement it.
Currently the toggles state of a adapter is simply inherited from
instance.

Bug: dawn:1495
Change-Id: I6bf7aa0f950a99451afcc2cab5322c924b7d9520
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122021
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
2023-03-07 02:03:54 +00:00

68 lines
2.2 KiB
C++

// Copyright 2019 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 SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_
#define SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_
#include "dawn/native/Adapter.h"
#include "dawn/common/RefCounted.h"
#include "dawn/common/vulkan_platform.h"
#include "dawn/native/vulkan/VulkanInfo.h"
namespace dawn::native::vulkan {
class VulkanInstance;
class Adapter : public AdapterBase {
public:
Adapter(InstanceBase* instance,
VulkanInstance* vulkanInstance,
VkPhysicalDevice physicalDevice,
const TogglesState& adapterToggles);
~Adapter() override;
// AdapterBase Implementation
bool SupportsExternalImages() const override;
const VulkanDeviceInfo& GetDeviceInfo() const;
VkPhysicalDevice GetPhysicalDevice() const;
VulkanInstance* GetVulkanInstance() const;
bool IsDepthStencilFormatSupported(VkFormat format) const;
bool IsAndroidQualcomm() const;
private:
MaybeError InitializeImpl() override;
void InitializeSupportedFeaturesImpl() override;
MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) override;
MaybeError ValidateFeatureSupportedWithDeviceTogglesImpl(
wgpu::FeatureName feature,
const TogglesState& deviceToggles) override;
void SetupBackendDeviceToggles(TogglesState* deviceToggles) const override;
ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
const TogglesState& deviceToggles) override;
VkPhysicalDevice mPhysicalDevice;
Ref<VulkanInstance> mVulkanInstance;
VulkanDeviceInfo mDeviceInfo = {};
};
} // namespace dawn::native::vulkan
#endif // SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_