mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-20 02:41:48 +00:00
This patch refactors the current implementation of BC formats to treat it as the first extension in Dawn and adds all the related tests. Note that in Dawn all the extensions are disabled unless we enable them when we create the device, which means the BC formats can only be used when we enable the related extension on the creation of the device, and the creation of the device will fail if the adapter does not support the extension BUG=dawn:42 TEST=dawn_end2end_tests TEST=dawn_unittests Change-Id: I04d818b0218ebb3b1b7a70a4fea71779f308f85f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9520 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Austin Eng <enga@chromium.org>
84 lines
2.7 KiB
C++
84 lines
2.7 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.
|
|
|
|
#include "dawn_native/Adapter.h"
|
|
|
|
#include "dawn_native/Instance.h"
|
|
|
|
namespace dawn_native {
|
|
|
|
AdapterBase::AdapterBase(InstanceBase* instance, BackendType backend)
|
|
: mInstance(instance), mBackend(backend) {
|
|
}
|
|
|
|
BackendType AdapterBase::GetBackendType() const {
|
|
return mBackend;
|
|
}
|
|
|
|
DeviceType AdapterBase::GetDeviceType() const {
|
|
return mDeviceType;
|
|
}
|
|
|
|
const PCIInfo& AdapterBase::GetPCIInfo() const {
|
|
return mPCIInfo;
|
|
}
|
|
|
|
InstanceBase* AdapterBase::GetInstance() const {
|
|
return mInstance;
|
|
}
|
|
|
|
ExtensionsSet AdapterBase::GetSupportedExtensions() const {
|
|
return mSupportedExtensions;
|
|
}
|
|
|
|
bool AdapterBase::SupportsAllRequestedExtensions(
|
|
const std::vector<const char*>& requestedExtensions) const {
|
|
for (const char* extensionStr : requestedExtensions) {
|
|
Extension extensionEnum = mInstance->ExtensionNameToEnum(extensionStr);
|
|
if (extensionEnum == Extension::InvalidEnum) {
|
|
return false;
|
|
}
|
|
if (!mSupportedExtensions.IsEnabled(extensionEnum)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
DeviceBase* AdapterBase::CreateDevice(const DeviceDescriptor* descriptor) {
|
|
DeviceBase* result = nullptr;
|
|
|
|
if (mInstance->ConsumedError(CreateDeviceInternal(&result, descriptor))) {
|
|
return nullptr;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
MaybeError AdapterBase::CreateDeviceInternal(DeviceBase** result,
|
|
const DeviceDescriptor* descriptor) {
|
|
if (descriptor != nullptr) {
|
|
if (!SupportsAllRequestedExtensions(descriptor->requiredExtensions)) {
|
|
return DAWN_VALIDATION_ERROR("One or more requested extensions are not supported");
|
|
}
|
|
}
|
|
|
|
// TODO(cwallez@chromium.org): This will eventually have validation that the device
|
|
// descriptor is valid and is a subset what's allowed on this adapter.
|
|
DAWN_TRY_ASSIGN(*result, CreateDeviceImpl(descriptor));
|
|
return {};
|
|
}
|
|
|
|
} // namespace dawn_native
|