mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 17:35:30 +00:00
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>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
e5ca66806f
commit
c2657b21d5
@@ -53,8 +53,10 @@ uint32_t GetVendorIdFromVendors(const char* vendor) {
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
Adapter::Adapter(InstanceBase* instance, wgpu::BackendType backendType)
|
||||
: AdapterBase(instance, backendType) {}
|
||||
Adapter::Adapter(InstanceBase* instance,
|
||||
wgpu::BackendType backendType,
|
||||
const TogglesState& adapterToggle)
|
||||
: AdapterBase(instance, backendType, adapterToggle) {}
|
||||
|
||||
MaybeError Adapter::InitializeGLFunctions(void* (*getProc)(const char*)) {
|
||||
// Use getProc to populate the dispatch table
|
||||
|
||||
@@ -23,7 +23,9 @@ namespace dawn::native::opengl {
|
||||
|
||||
class Adapter : public AdapterBase {
|
||||
public:
|
||||
Adapter(InstanceBase* instance, wgpu::BackendType backendType);
|
||||
Adapter(InstanceBase* instance,
|
||||
wgpu::BackendType backendType,
|
||||
const TogglesState& adapterToggle);
|
||||
|
||||
MaybeError InitializeGLFunctions(void* (*getProc)(const char*));
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace dawn::native::opengl {
|
||||
Backend::Backend(InstanceBase* instance, wgpu::BackendType backendType)
|
||||
: BackendConnection(instance, backendType) {}
|
||||
|
||||
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters() {
|
||||
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesState& adapterToggles) {
|
||||
std::vector<Ref<AdapterBase>> adapters;
|
||||
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||
const char* eglLib = "libEGL.dll";
|
||||
@@ -69,7 +69,7 @@ std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters() {
|
||||
|
||||
context->MakeCurrent();
|
||||
|
||||
auto result = DiscoverAdapters(&options);
|
||||
auto result = DiscoverAdapters(&options, adapterToggles);
|
||||
|
||||
if (result.IsError()) {
|
||||
GetInstance()->ConsumedError(result.AcquireError());
|
||||
@@ -84,7 +84,8 @@ std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters() {
|
||||
}
|
||||
|
||||
ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||
const AdapterDiscoveryOptionsBase* optionsBase) {
|
||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||
const TogglesState& adapterToggles) {
|
||||
// TODO(cwallez@chromium.org): For now only create a single OpenGL adapter because don't
|
||||
// know how to handle MakeCurrent.
|
||||
DAWN_INVALID_IF(mCreatedAdapter, "The OpenGL backend can only create a single adapter.");
|
||||
@@ -95,8 +96,8 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||
|
||||
DAWN_INVALID_IF(options->getProc == nullptr, "AdapterDiscoveryOptions::getProc must be set");
|
||||
|
||||
Ref<Adapter> adapter = AcquireRef(
|
||||
new Adapter(GetInstance(), static_cast<wgpu::BackendType>(optionsBase->backendType)));
|
||||
Ref<Adapter> adapter = AcquireRef(new Adapter(
|
||||
GetInstance(), static_cast<wgpu::BackendType>(optionsBase->backendType), adapterToggles));
|
||||
DAWN_TRY(adapter->InitializeGLFunctions(options->getProc));
|
||||
DAWN_TRY(adapter->Initialize());
|
||||
|
||||
|
||||
@@ -26,9 +26,11 @@ class Backend : public BackendConnection {
|
||||
public:
|
||||
Backend(InstanceBase* instance, wgpu::BackendType backendType);
|
||||
|
||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters() override;
|
||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
||||
const TogglesState& adapterToggles) override;
|
||||
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(
|
||||
const AdapterDiscoveryOptionsBase* options) override;
|
||||
const AdapterDiscoveryOptionsBase* option,
|
||||
const TogglesState& adapterToggless) override;
|
||||
|
||||
private:
|
||||
bool mCreatedAdapter = false;
|
||||
|
||||
Reference in New Issue
Block a user