Rename AdapterBase -> PhysicalDeviceBase.
AdapterBase will become a (thin) wrapper class in an upcoming patch, allowing a single PhysicalDeviceBase to be wrapped in multiple AdapterBases, each with different toggles and flags. For now, alias AdapterBase to PhysicalDeviceBase. Design doc: https://docs.google.com/document/d/1Ag3UAD6D1OVt9-MwKltzLefVhwKRdX0RqML2etrYVS4/edit Change-Id: Ie77e99508be5285b651aa24ccb412bc9ff8b0111 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/130300 Reviewed-by: Austin Eng <enga@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen White <senorblanco@chromium.org>
This commit is contained in:
parent
0e2a833da8
commit
e4877b7e68
|
@ -34,8 +34,7 @@ struct DeviceDescriptor;
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
class InstanceBase;
|
class InstanceBase;
|
||||||
class AdapterBase;
|
class PhysicalDeviceBase;
|
||||||
|
|
||||||
// An optional parameter of Adapter::CreateDevice() to send additional information when creating
|
// An optional parameter of Adapter::CreateDevice() to send additional information when creating
|
||||||
// a Device. For example, we can use it to enable a workaround, optimization or feature.
|
// a Device. For example, we can use it to enable a workaround, optimization or feature.
|
||||||
struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
|
struct DAWN_NATIVE_EXPORT DawnDeviceDescriptor {
|
||||||
|
@ -85,8 +84,10 @@ struct FeatureInfo {
|
||||||
class DAWN_NATIVE_EXPORT Adapter {
|
class DAWN_NATIVE_EXPORT Adapter {
|
||||||
public:
|
public:
|
||||||
Adapter();
|
Adapter();
|
||||||
|
// TODO(dawn:1774): all references to PhysicalDeviceBase in this class will go back to
|
||||||
|
// using AdapterBase once the latter becomes a real class again.
|
||||||
// NOLINTNEXTLINE(runtime/explicit)
|
// NOLINTNEXTLINE(runtime/explicit)
|
||||||
Adapter(AdapterBase* impl);
|
Adapter(PhysicalDeviceBase* impl);
|
||||||
~Adapter();
|
~Adapter();
|
||||||
|
|
||||||
Adapter(const Adapter& other);
|
Adapter(const Adapter& other);
|
||||||
|
@ -131,7 +132,7 @@ class DAWN_NATIVE_EXPORT Adapter {
|
||||||
void ResetInternalDeviceForTesting();
|
void ResetInternalDeviceForTesting();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AdapterBase* mImpl = nullptr;
|
PhysicalDeviceBase* mImpl = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base class for options passed to Instance::DiscoverAdapters.
|
// Base class for options passed to Instance::DiscoverAdapters.
|
||||||
|
|
|
@ -15,127 +15,12 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_ADAPTER_H_
|
#ifndef SRC_DAWN_NATIVE_ADAPTER_H_
|
||||||
#define SRC_DAWN_NATIVE_ADAPTER_H_
|
#define SRC_DAWN_NATIVE_ADAPTER_H_
|
||||||
|
|
||||||
#include <string>
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "dawn/native/DawnNative.h"
|
|
||||||
|
|
||||||
#include "dawn/common/GPUInfo.h"
|
|
||||||
#include "dawn/common/RefCounted.h"
|
|
||||||
#include "dawn/common/ityp_span.h"
|
|
||||||
#include "dawn/native/Error.h"
|
|
||||||
#include "dawn/native/Features.h"
|
|
||||||
#include "dawn/native/Limits.h"
|
|
||||||
#include "dawn/native/Toggles.h"
|
|
||||||
#include "dawn/native/dawn_platform.h"
|
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
class DeviceBase;
|
using AdapterBase = PhysicalDeviceBase;
|
||||||
|
|
||||||
class AdapterBase : public RefCounted {
|
}
|
||||||
public:
|
|
||||||
AdapterBase(InstanceBase* instance,
|
|
||||||
wgpu::BackendType backend,
|
|
||||||
const TogglesState& adapterToggles);
|
|
||||||
~AdapterBase() override;
|
|
||||||
|
|
||||||
MaybeError Initialize();
|
|
||||||
|
|
||||||
// WebGPU API
|
|
||||||
InstanceBase* APIGetInstance() const;
|
|
||||||
bool APIGetLimits(SupportedLimits* limits) const;
|
|
||||||
void APIGetProperties(AdapterProperties* properties) const;
|
|
||||||
bool APIHasFeature(wgpu::FeatureName feature) const;
|
|
||||||
size_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
|
|
||||||
void APIRequestDevice(const DeviceDescriptor* descriptor,
|
|
||||||
WGPURequestDeviceCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
DeviceBase* APICreateDevice(const DeviceDescriptor* descriptor = nullptr);
|
|
||||||
|
|
||||||
uint32_t GetVendorId() const;
|
|
||||||
uint32_t GetDeviceId() const;
|
|
||||||
const gpu_info::DriverVersion& GetDriverVersion() const;
|
|
||||||
wgpu::BackendType GetBackendType() const;
|
|
||||||
|
|
||||||
// This method differs from APIGetInstance() in that it won't increase the ref count of the
|
|
||||||
// instance.
|
|
||||||
InstanceBase* GetInstance() const;
|
|
||||||
|
|
||||||
void ResetInternalDeviceForTesting();
|
|
||||||
|
|
||||||
FeaturesSet GetSupportedFeatures() const;
|
|
||||||
bool SupportsAllRequiredFeatures(
|
|
||||||
const ityp::span<size_t, const wgpu::FeatureName>& features) const;
|
|
||||||
|
|
||||||
bool GetLimits(SupportedLimits* limits) const;
|
|
||||||
|
|
||||||
void SetUseTieredLimits(bool useTieredLimits);
|
|
||||||
|
|
||||||
// Get the actual toggles state of the adapter.
|
|
||||||
const TogglesState& GetTogglesState() const;
|
|
||||||
|
|
||||||
virtual bool SupportsExternalImages() const = 0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint32_t mVendorId = 0xFFFFFFFF;
|
|
||||||
std::string mVendorName;
|
|
||||||
std::string mArchitectureName;
|
|
||||||
uint32_t mDeviceId = 0xFFFFFFFF;
|
|
||||||
std::string mName;
|
|
||||||
wgpu::AdapterType mAdapterType = wgpu::AdapterType::Unknown;
|
|
||||||
gpu_info::DriverVersion mDriverVersion;
|
|
||||||
std::string mDriverDescription;
|
|
||||||
|
|
||||||
// Mark a feature as enabled in mSupportedFeatures.
|
|
||||||
void EnableFeature(Feature feature);
|
|
||||||
// Check if a feature os supported by this adapter AND suitable with given toggles.
|
|
||||||
// TODO(dawn:1495): After implementing adapter toggles, remove this and use adapter toggles
|
|
||||||
// instead of device toggles to validate supported features.
|
|
||||||
MaybeError ValidateFeatureSupportedWithToggles(wgpu::FeatureName feature,
|
|
||||||
const TogglesState& toggles) const;
|
|
||||||
// Used for the tests that intend to use an adapter without all features enabled.
|
|
||||||
void SetSupportedFeaturesForTesting(const std::vector<wgpu::FeatureName>& requiredFeatures);
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Backend-specific force-setting and defaulting device toggles
|
|
||||||
virtual void SetupBackendDeviceToggles(TogglesState* deviceToggles) const = 0;
|
|
||||||
|
|
||||||
virtual ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
|
||||||
const TogglesState& deviceToggles) = 0;
|
|
||||||
|
|
||||||
virtual MaybeError InitializeImpl() = 0;
|
|
||||||
|
|
||||||
// Check base WebGPU features and discover supported features.
|
|
||||||
virtual void InitializeSupportedFeaturesImpl() = 0;
|
|
||||||
|
|
||||||
// Check base WebGPU limits and populate supported limits.
|
|
||||||
virtual MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) = 0;
|
|
||||||
|
|
||||||
virtual void InitializeVendorArchitectureImpl();
|
|
||||||
|
|
||||||
virtual MaybeError ValidateFeatureSupportedWithTogglesImpl(
|
|
||||||
wgpu::FeatureName feature,
|
|
||||||
const TogglesState& toggles) const = 0;
|
|
||||||
|
|
||||||
ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(const DeviceDescriptor* descriptor);
|
|
||||||
|
|
||||||
virtual MaybeError ResetInternalDeviceForTestingImpl();
|
|
||||||
Ref<InstanceBase> mInstance;
|
|
||||||
wgpu::BackendType mBackend;
|
|
||||||
|
|
||||||
// Adapter toggles state, currently only inherited from instance toggles state.
|
|
||||||
TogglesState mTogglesState;
|
|
||||||
|
|
||||||
// Features set that CAN be supported by devices of this adapter. Some features in this set may
|
|
||||||
// be guarded by toggles, and creating a device with these features required may result in a
|
|
||||||
// validation error if proper toggles are not enabled/disabled.
|
|
||||||
FeaturesSet mSupportedFeatures;
|
|
||||||
|
|
||||||
CombinedLimits mLimits;
|
|
||||||
bool mUseTieredLimits = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace dawn::native
|
|
||||||
|
|
||||||
#endif // SRC_DAWN_NATIVE_ADAPTER_H_
|
#endif // SRC_DAWN_NATIVE_ADAPTER_H_
|
||||||
|
|
|
@ -184,7 +184,6 @@ source_set("sources") {
|
||||||
|
|
||||||
sources = get_target_outputs(":utils_gen")
|
sources = get_target_outputs(":utils_gen")
|
||||||
sources += [
|
sources += [
|
||||||
"Adapter.cpp",
|
|
||||||
"Adapter.h",
|
"Adapter.h",
|
||||||
"ApplyClearColorValueWithDrawHelper.cpp",
|
"ApplyClearColorValueWithDrawHelper.cpp",
|
||||||
"ApplyClearColorValueWithDrawHelper.h",
|
"ApplyClearColorValueWithDrawHelper.h",
|
||||||
|
@ -290,6 +289,8 @@ source_set("sources") {
|
||||||
"PassResourceUsageTracker.h",
|
"PassResourceUsageTracker.h",
|
||||||
"PerStage.cpp",
|
"PerStage.cpp",
|
||||||
"PerStage.h",
|
"PerStage.h",
|
||||||
|
"PhysicalDevice.cpp",
|
||||||
|
"PhysicalDevice.h",
|
||||||
"Pipeline.cpp",
|
"Pipeline.cpp",
|
||||||
"Pipeline.h",
|
"Pipeline.h",
|
||||||
"PipelineCache.cpp",
|
"PipelineCache.cpp",
|
||||||
|
|
|
@ -28,7 +28,7 @@ InstanceBase* BackendConnection::GetInstance() const {
|
||||||
return mInstance;
|
return mInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> BackendConnection::DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> BackendConnection::DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* options,
|
const AdapterDiscoveryOptionsBase* options,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
return DAWN_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend.");
|
return DAWN_VALIDATION_ERROR("DiscoverAdapters not implemented for this backend.");
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
|
||||||
#include "dawn/native/DawnNative.h"
|
#include "dawn/native/DawnNative.h"
|
||||||
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/Toggles.h"
|
#include "dawn/native/Toggles.h"
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
@ -36,11 +36,11 @@ class BackendConnection {
|
||||||
|
|
||||||
// Returns all the adapters for the system that can be created by the backend, without extra
|
// Returns all the adapters for the system that can be created by the backend, without extra
|
||||||
// options (such as debug adapters, custom driver libraries, etc.)
|
// options (such as debug adapters, custom driver libraries, etc.)
|
||||||
virtual std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
virtual std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters(
|
||||||
const TogglesState& adapterToggles) = 0;
|
const TogglesState& adapterToggles) = 0;
|
||||||
|
|
||||||
// Returns new adapters created with the backend-specific options.
|
// Returns new adapters created with the backend-specific options.
|
||||||
virtual ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(
|
virtual ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* options,
|
const AdapterDiscoveryOptionsBase* options,
|
||||||
const TogglesState& adapterToggles);
|
const TogglesState& adapterToggles);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ target_sources(dawn_native PRIVATE
|
||||||
"${DAWN_INCLUDE_DIR}/dawn/native/DawnNative.h"
|
"${DAWN_INCLUDE_DIR}/dawn/native/DawnNative.h"
|
||||||
"${DAWN_INCLUDE_DIR}/dawn/native/dawn_native_export.h"
|
"${DAWN_INCLUDE_DIR}/dawn/native/dawn_native_export.h"
|
||||||
${DAWN_NATIVE_UTILS_GEN_SOURCES}
|
${DAWN_NATIVE_UTILS_GEN_SOURCES}
|
||||||
"Adapter.cpp"
|
|
||||||
"Adapter.h"
|
"Adapter.h"
|
||||||
"ApplyClearColorValueWithDrawHelper.cpp"
|
"ApplyClearColorValueWithDrawHelper.cpp"
|
||||||
"ApplyClearColorValueWithDrawHelper.h"
|
"ApplyClearColorValueWithDrawHelper.h"
|
||||||
|
@ -136,6 +135,8 @@ target_sources(dawn_native PRIVATE
|
||||||
"PassResourceUsageTracker.h"
|
"PassResourceUsageTracker.h"
|
||||||
"PerStage.cpp"
|
"PerStage.cpp"
|
||||||
"PerStage.h"
|
"PerStage.h"
|
||||||
|
"PhysicalDevice.cpp"
|
||||||
|
"PhysicalDevice.h"
|
||||||
"Pipeline.cpp"
|
"Pipeline.cpp"
|
||||||
"Pipeline.h"
|
"Pipeline.h"
|
||||||
"PipelineCache.cpp"
|
"PipelineCache.cpp"
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
#include "dawn/common/BitSetIterator.h"
|
#include "dawn/common/BitSetIterator.h"
|
||||||
#include "dawn/common/Numeric.h"
|
#include "dawn/common/Numeric.h"
|
||||||
#include "dawn/native/Adapter.h"
|
|
||||||
#include "dawn/native/BindGroup.h"
|
#include "dawn/native/BindGroup.h"
|
||||||
#include "dawn/native/Buffer.h"
|
#include "dawn/native/Buffer.h"
|
||||||
#include "dawn/native/CommandBufferStateTracker.h"
|
#include "dawn/native/CommandBufferStateTracker.h"
|
||||||
|
@ -30,6 +29,7 @@
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
#include "dawn/native/Instance.h"
|
#include "dawn/native/Instance.h"
|
||||||
#include "dawn/native/PassResourceUsage.h"
|
#include "dawn/native/PassResourceUsage.h"
|
||||||
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/QuerySet.h"
|
#include "dawn/native/QuerySet.h"
|
||||||
#include "dawn/native/RenderBundle.h"
|
#include "dawn/native/RenderBundle.h"
|
||||||
#include "dawn/native/RenderPipeline.h"
|
#include "dawn/native/RenderPipeline.h"
|
||||||
|
|
|
@ -81,7 +81,7 @@ DawnDeviceDescriptor::~DawnDeviceDescriptor() = default;
|
||||||
|
|
||||||
Adapter::Adapter() = default;
|
Adapter::Adapter() = default;
|
||||||
|
|
||||||
Adapter::Adapter(AdapterBase* impl) : mImpl(impl) {
|
Adapter::Adapter(PhysicalDeviceBase* impl) : mImpl(impl) {
|
||||||
if (mImpl != nullptr) {
|
if (mImpl != nullptr) {
|
||||||
mImpl->Reference();
|
mImpl->Reference();
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ bool Instance::DiscoverAdapters(const AdapterDiscoveryOptionsBase* options) {
|
||||||
std::vector<Adapter> Instance::GetAdapters() const {
|
std::vector<Adapter> Instance::GetAdapters() const {
|
||||||
// Adapters are owned by mImpl so it is safe to return non RAII pointers to them
|
// Adapters are owned by mImpl so it is safe to return non RAII pointers to them
|
||||||
std::vector<Adapter> adapters;
|
std::vector<Adapter> adapters;
|
||||||
for (const Ref<AdapterBase>& adapter : mImpl->GetAdapters()) {
|
for (const Ref<PhysicalDeviceBase>& adapter : mImpl->GetAdapters()) {
|
||||||
adapters.push_back(Adapter(adapter.Get()));
|
adapters.push_back(Adapter(adapter.Get()));
|
||||||
}
|
}
|
||||||
return adapters;
|
return adapters;
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
#include "dawn/common/Log.h"
|
#include "dawn/common/Log.h"
|
||||||
#include "dawn/common/Version_autogen.h"
|
#include "dawn/common/Version_autogen.h"
|
||||||
#include "dawn/native/Adapter.h"
|
|
||||||
#include "dawn/native/AsyncTask.h"
|
#include "dawn/native/AsyncTask.h"
|
||||||
#include "dawn/native/AttachmentState.h"
|
#include "dawn/native/AttachmentState.h"
|
||||||
#include "dawn/native/BindGroup.h"
|
#include "dawn/native/BindGroup.h"
|
||||||
|
@ -42,6 +41,7 @@
|
||||||
#include "dawn/native/Instance.h"
|
#include "dawn/native/Instance.h"
|
||||||
#include "dawn/native/InternalPipelineStore.h"
|
#include "dawn/native/InternalPipelineStore.h"
|
||||||
#include "dawn/native/ObjectType_autogen.h"
|
#include "dawn/native/ObjectType_autogen.h"
|
||||||
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/PipelineCache.h"
|
#include "dawn/native/PipelineCache.h"
|
||||||
#include "dawn/native/QuerySet.h"
|
#include "dawn/native/QuerySet.h"
|
||||||
#include "dawn/native/Queue.h"
|
#include "dawn/native/Queue.h"
|
||||||
|
@ -719,7 +719,7 @@ ApiObjectList* DeviceBase::GetObjectTrackingList(ObjectType type) {
|
||||||
return &mObjectLists[type];
|
return &mObjectLists[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
AdapterBase* DeviceBase::GetAdapter() const {
|
PhysicalDeviceBase* DeviceBase::GetAdapter() const {
|
||||||
return mAdapter.Get();
|
return mAdapter.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1345,7 +1345,7 @@ MaybeError DeviceBase::Tick() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
AdapterBase* DeviceBase::APIGetAdapter() {
|
PhysicalDeviceBase* DeviceBase::APIGetAdapter() {
|
||||||
mAdapter->Reference();
|
mAdapter->Reference();
|
||||||
return mAdapter.Get();
|
return mAdapter.Get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ namespace dawn::native {
|
||||||
|
|
||||||
enum class ObjectType : uint32_t;
|
enum class ObjectType : uint32_t;
|
||||||
|
|
||||||
class AdapterBase;
|
|
||||||
class BindGroupBase;
|
class BindGroupBase;
|
||||||
class BindGroupLayoutBase;
|
class BindGroupLayoutBase;
|
||||||
class BufferBase;
|
class BufferBase;
|
||||||
|
@ -34,6 +33,7 @@ class CommandEncoder;
|
||||||
class ComputePassEncoder;
|
class ComputePassEncoder;
|
||||||
class ExternalTextureBase;
|
class ExternalTextureBase;
|
||||||
class InstanceBase;
|
class InstanceBase;
|
||||||
|
class PhysicalDeviceBase;
|
||||||
class PipelineBase;
|
class PipelineBase;
|
||||||
class PipelineCacheBase;
|
class PipelineCacheBase;
|
||||||
class PipelineLayoutBase;
|
class PipelineLayoutBase;
|
||||||
|
@ -51,6 +51,8 @@ class SwapChainBase;
|
||||||
class TextureBase;
|
class TextureBase;
|
||||||
class TextureViewBase;
|
class TextureViewBase;
|
||||||
|
|
||||||
|
using AdapterBase = PhysicalDeviceBase;
|
||||||
|
|
||||||
class DeviceBase;
|
class DeviceBase;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -27,16 +27,16 @@
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
||||||
AdapterBase::AdapterBase(InstanceBase* instance,
|
PhysicalDeviceBase::PhysicalDeviceBase(InstanceBase* instance,
|
||||||
wgpu::BackendType backend,
|
wgpu::BackendType backend,
|
||||||
const TogglesState& adapterToggles)
|
const TogglesState& adapterToggles)
|
||||||
: mInstance(instance), mBackend(backend), mTogglesState(adapterToggles) {
|
: mInstance(instance), mBackend(backend), mTogglesState(adapterToggles) {
|
||||||
ASSERT(adapterToggles.GetStage() == ToggleStage::Adapter);
|
ASSERT(adapterToggles.GetStage() == ToggleStage::Adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdapterBase::~AdapterBase() = default;
|
PhysicalDeviceBase::~PhysicalDeviceBase() = default;
|
||||||
|
|
||||||
MaybeError AdapterBase::Initialize() {
|
MaybeError PhysicalDeviceBase::Initialize() {
|
||||||
DAWN_TRY_CONTEXT(InitializeImpl(), "initializing adapter (backend=%s)", mBackend);
|
DAWN_TRY_CONTEXT(InitializeImpl(), "initializing adapter (backend=%s)", mBackend);
|
||||||
InitializeVendorArchitectureImpl();
|
InitializeVendorArchitectureImpl();
|
||||||
|
|
||||||
|
@ -84,18 +84,18 @@ MaybeError AdapterBase::Initialize() {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceBase* AdapterBase::APIGetInstance() const {
|
InstanceBase* PhysicalDeviceBase::APIGetInstance() const {
|
||||||
auto instance = GetInstance();
|
auto instance = GetInstance();
|
||||||
ASSERT(instance != nullptr);
|
ASSERT(instance != nullptr);
|
||||||
instance->APIReference();
|
instance->APIReference();
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdapterBase::APIGetLimits(SupportedLimits* limits) const {
|
bool PhysicalDeviceBase::APIGetLimits(SupportedLimits* limits) const {
|
||||||
return GetLimits(limits);
|
return GetLimits(limits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::APIGetProperties(AdapterProperties* properties) const {
|
void PhysicalDeviceBase::APIGetProperties(AdapterProperties* properties) const {
|
||||||
MaybeError result = ValidateSingleSType(properties->nextInChain,
|
MaybeError result = ValidateSingleSType(properties->nextInChain,
|
||||||
wgpu::SType::DawnAdapterPropertiesPowerPreference);
|
wgpu::SType::DawnAdapterPropertiesPowerPreference);
|
||||||
if (result.IsError()) {
|
if (result.IsError()) {
|
||||||
|
@ -119,15 +119,15 @@ void AdapterBase::APIGetProperties(AdapterProperties* properties) const {
|
||||||
properties->backendType = mBackend;
|
properties->backendType = mBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdapterBase::APIHasFeature(wgpu::FeatureName feature) const {
|
bool PhysicalDeviceBase::APIHasFeature(wgpu::FeatureName feature) const {
|
||||||
return mSupportedFeatures.IsEnabled(feature);
|
return mSupportedFeatures.IsEnabled(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AdapterBase::APIEnumerateFeatures(wgpu::FeatureName* features) const {
|
size_t PhysicalDeviceBase::APIEnumerateFeatures(wgpu::FeatureName* features) const {
|
||||||
return mSupportedFeatures.EnumerateFeatures(features);
|
return mSupportedFeatures.EnumerateFeatures(features);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceBase* AdapterBase::APICreateDevice(const DeviceDescriptor* descriptor) {
|
DeviceBase* PhysicalDeviceBase::APICreateDevice(const DeviceDescriptor* descriptor) {
|
||||||
DeviceDescriptor defaultDesc = {};
|
DeviceDescriptor defaultDesc = {};
|
||||||
if (descriptor == nullptr) {
|
if (descriptor == nullptr) {
|
||||||
descriptor = &defaultDesc;
|
descriptor = &defaultDesc;
|
||||||
|
@ -140,9 +140,9 @@ DeviceBase* AdapterBase::APICreateDevice(const DeviceDescriptor* descriptor) {
|
||||||
return result.AcquireSuccess().Detach();
|
return result.AcquireSuccess().Detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::APIRequestDevice(const DeviceDescriptor* descriptor,
|
void PhysicalDeviceBase::APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||||
WGPURequestDeviceCallback callback,
|
WGPURequestDeviceCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
static constexpr DeviceDescriptor kDefaultDescriptor = {};
|
static constexpr DeviceDescriptor kDefaultDescriptor = {};
|
||||||
if (descriptor == nullptr) {
|
if (descriptor == nullptr) {
|
||||||
descriptor = &kDefaultDescriptor;
|
descriptor = &kDefaultDescriptor;
|
||||||
|
@ -165,36 +165,36 @@ void AdapterBase::APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||||
callback(status, ToAPI(device.Detach()), nullptr, userdata);
|
callback(status, ToAPI(device.Detach()), nullptr, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::InitializeVendorArchitectureImpl() {
|
void PhysicalDeviceBase::InitializeVendorArchitectureImpl() {
|
||||||
mVendorName = gpu_info::GetVendorName(mVendorId);
|
mVendorName = gpu_info::GetVendorName(mVendorId);
|
||||||
mArchitectureName = gpu_info::GetArchitectureName(mVendorId, mDeviceId);
|
mArchitectureName = gpu_info::GetArchitectureName(mVendorId, mDeviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AdapterBase::GetVendorId() const {
|
uint32_t PhysicalDeviceBase::GetVendorId() const {
|
||||||
return mVendorId;
|
return mVendorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AdapterBase::GetDeviceId() const {
|
uint32_t PhysicalDeviceBase::GetDeviceId() const {
|
||||||
return mDeviceId;
|
return mDeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gpu_info::DriverVersion& AdapterBase::GetDriverVersion() const {
|
const gpu_info::DriverVersion& PhysicalDeviceBase::GetDriverVersion() const {
|
||||||
return mDriverVersion;
|
return mDriverVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpu::BackendType AdapterBase::GetBackendType() const {
|
wgpu::BackendType PhysicalDeviceBase::GetBackendType() const {
|
||||||
return mBackend;
|
return mBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceBase* AdapterBase::GetInstance() const {
|
InstanceBase* PhysicalDeviceBase::GetInstance() const {
|
||||||
return mInstance.Get();
|
return mInstance.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FeaturesSet AdapterBase::GetSupportedFeatures() const {
|
FeaturesSet PhysicalDeviceBase::GetSupportedFeatures() const {
|
||||||
return mSupportedFeatures;
|
return mSupportedFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdapterBase::SupportsAllRequiredFeatures(
|
bool PhysicalDeviceBase::SupportsAllRequiredFeatures(
|
||||||
const ityp::span<size_t, const wgpu::FeatureName>& features) const {
|
const ityp::span<size_t, const wgpu::FeatureName>& features) const {
|
||||||
for (wgpu::FeatureName f : features) {
|
for (wgpu::FeatureName f : features) {
|
||||||
if (!mSupportedFeatures.IsEnabled(f)) {
|
if (!mSupportedFeatures.IsEnabled(f)) {
|
||||||
|
@ -204,7 +204,7 @@ bool AdapterBase::SupportsAllRequiredFeatures(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdapterBase::GetLimits(SupportedLimits* limits) const {
|
bool PhysicalDeviceBase::GetLimits(SupportedLimits* limits) const {
|
||||||
ASSERT(limits != nullptr);
|
ASSERT(limits != nullptr);
|
||||||
if (limits->nextInChain != nullptr) {
|
if (limits->nextInChain != nullptr) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -217,16 +217,17 @@ bool AdapterBase::GetLimits(SupportedLimits* limits) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TogglesState& AdapterBase::GetTogglesState() const {
|
const TogglesState& PhysicalDeviceBase::GetTogglesState() const {
|
||||||
return mTogglesState;
|
return mTogglesState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::EnableFeature(Feature feature) {
|
void PhysicalDeviceBase::EnableFeature(Feature feature) {
|
||||||
mSupportedFeatures.EnableFeature(feature);
|
mSupportedFeatures.EnableFeature(feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError AdapterBase::ValidateFeatureSupportedWithToggles(wgpu::FeatureName feature,
|
MaybeError PhysicalDeviceBase::ValidateFeatureSupportedWithToggles(
|
||||||
const TogglesState& toggles) const {
|
wgpu::FeatureName feature,
|
||||||
|
const TogglesState& toggles) const {
|
||||||
DAWN_TRY(ValidateFeatureName(feature));
|
DAWN_TRY(ValidateFeatureName(feature));
|
||||||
DAWN_INVALID_IF(!mSupportedFeatures.IsEnabled(feature),
|
DAWN_INVALID_IF(!mSupportedFeatures.IsEnabled(feature),
|
||||||
"Requested feature %s is not supported.", feature);
|
"Requested feature %s is not supported.", feature);
|
||||||
|
@ -243,7 +244,7 @@ MaybeError AdapterBase::ValidateFeatureSupportedWithToggles(wgpu::FeatureName fe
|
||||||
return ValidateFeatureSupportedWithTogglesImpl(feature, toggles);
|
return ValidateFeatureSupportedWithTogglesImpl(feature, toggles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::SetSupportedFeaturesForTesting(
|
void PhysicalDeviceBase::SetSupportedFeaturesForTesting(
|
||||||
const std::vector<wgpu::FeatureName>& requiredFeatures) {
|
const std::vector<wgpu::FeatureName>& requiredFeatures) {
|
||||||
mSupportedFeatures = {};
|
mSupportedFeatures = {};
|
||||||
for (wgpu::FeatureName f : requiredFeatures) {
|
for (wgpu::FeatureName f : requiredFeatures) {
|
||||||
|
@ -251,7 +252,7 @@ void AdapterBase::SetSupportedFeaturesForTesting(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<Ref<DeviceBase>> AdapterBase::CreateDeviceInternal(
|
ResultOrError<Ref<DeviceBase>> PhysicalDeviceBase::CreateDeviceInternal(
|
||||||
const DeviceDescriptor* descriptor) {
|
const DeviceDescriptor* descriptor) {
|
||||||
ASSERT(descriptor != nullptr);
|
ASSERT(descriptor != nullptr);
|
||||||
|
|
||||||
|
@ -291,15 +292,15 @@ ResultOrError<Ref<DeviceBase>> AdapterBase::CreateDeviceInternal(
|
||||||
return CreateDeviceImpl(descriptor, deviceToggles);
|
return CreateDeviceImpl(descriptor, deviceToggles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::SetUseTieredLimits(bool useTieredLimits) {
|
void PhysicalDeviceBase::SetUseTieredLimits(bool useTieredLimits) {
|
||||||
mUseTieredLimits = useTieredLimits;
|
mUseTieredLimits = useTieredLimits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdapterBase::ResetInternalDeviceForTesting() {
|
void PhysicalDeviceBase::ResetInternalDeviceForTesting() {
|
||||||
mInstance->ConsumedError(ResetInternalDeviceForTestingImpl());
|
mInstance->ConsumedError(ResetInternalDeviceForTestingImpl());
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError AdapterBase::ResetInternalDeviceForTestingImpl() {
|
MaybeError PhysicalDeviceBase::ResetInternalDeviceForTestingImpl() {
|
||||||
return DAWN_INTERNAL_ERROR(
|
return DAWN_INTERNAL_ERROR(
|
||||||
"ResetInternalDeviceForTesting should only be used with the D3D12 backend.");
|
"ResetInternalDeviceForTesting should only be used with the D3D12 backend.");
|
||||||
}
|
}
|
|
@ -0,0 +1,141 @@
|
||||||
|
// 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 SRC_DAWN_NATIVE_PHYSICALDEVICE_H_
|
||||||
|
#define SRC_DAWN_NATIVE_PHYSICALDEVICE_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "dawn/native/DawnNative.h"
|
||||||
|
|
||||||
|
#include "dawn/common/GPUInfo.h"
|
||||||
|
#include "dawn/common/RefCounted.h"
|
||||||
|
#include "dawn/common/ityp_span.h"
|
||||||
|
#include "dawn/native/Error.h"
|
||||||
|
#include "dawn/native/Features.h"
|
||||||
|
#include "dawn/native/Limits.h"
|
||||||
|
#include "dawn/native/Toggles.h"
|
||||||
|
#include "dawn/native/dawn_platform.h"
|
||||||
|
|
||||||
|
namespace dawn::native {
|
||||||
|
|
||||||
|
class DeviceBase;
|
||||||
|
|
||||||
|
class PhysicalDeviceBase : public RefCounted {
|
||||||
|
public:
|
||||||
|
PhysicalDeviceBase(InstanceBase* instance,
|
||||||
|
wgpu::BackendType backend,
|
||||||
|
const TogglesState& adapterToggles);
|
||||||
|
~PhysicalDeviceBase() override;
|
||||||
|
|
||||||
|
MaybeError Initialize();
|
||||||
|
|
||||||
|
// WebGPU API
|
||||||
|
InstanceBase* APIGetInstance() const;
|
||||||
|
bool APIGetLimits(SupportedLimits* limits) const;
|
||||||
|
void APIGetProperties(AdapterProperties* properties) const;
|
||||||
|
bool APIHasFeature(wgpu::FeatureName feature) const;
|
||||||
|
size_t APIEnumerateFeatures(wgpu::FeatureName* features) const;
|
||||||
|
void APIRequestDevice(const DeviceDescriptor* descriptor,
|
||||||
|
WGPURequestDeviceCallback callback,
|
||||||
|
void* userdata);
|
||||||
|
DeviceBase* APICreateDevice(const DeviceDescriptor* descriptor = nullptr);
|
||||||
|
|
||||||
|
uint32_t GetVendorId() const;
|
||||||
|
uint32_t GetDeviceId() const;
|
||||||
|
const gpu_info::DriverVersion& GetDriverVersion() const;
|
||||||
|
wgpu::BackendType GetBackendType() const;
|
||||||
|
|
||||||
|
// This method differs from APIGetInstance() in that it won't increase the ref count of the
|
||||||
|
// instance.
|
||||||
|
InstanceBase* GetInstance() const;
|
||||||
|
|
||||||
|
void ResetInternalDeviceForTesting();
|
||||||
|
|
||||||
|
FeaturesSet GetSupportedFeatures() const;
|
||||||
|
bool SupportsAllRequiredFeatures(
|
||||||
|
const ityp::span<size_t, const wgpu::FeatureName>& features) const;
|
||||||
|
|
||||||
|
bool GetLimits(SupportedLimits* limits) const;
|
||||||
|
|
||||||
|
void SetUseTieredLimits(bool useTieredLimits);
|
||||||
|
|
||||||
|
// Get the actual toggles state of the adapter.
|
||||||
|
const TogglesState& GetTogglesState() const;
|
||||||
|
|
||||||
|
virtual bool SupportsExternalImages() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint32_t mVendorId = 0xFFFFFFFF;
|
||||||
|
std::string mVendorName;
|
||||||
|
std::string mArchitectureName;
|
||||||
|
uint32_t mDeviceId = 0xFFFFFFFF;
|
||||||
|
std::string mName;
|
||||||
|
wgpu::AdapterType mAdapterType = wgpu::AdapterType::Unknown;
|
||||||
|
gpu_info::DriverVersion mDriverVersion;
|
||||||
|
std::string mDriverDescription;
|
||||||
|
|
||||||
|
// Mark a feature as enabled in mSupportedFeatures.
|
||||||
|
void EnableFeature(Feature feature);
|
||||||
|
// Check if a feature os supported by this adapter AND suitable with given toggles.
|
||||||
|
// TODO(dawn:1495): After implementing adapter toggles, remove this and use adapter toggles
|
||||||
|
// instead of device toggles to validate supported features.
|
||||||
|
MaybeError ValidateFeatureSupportedWithToggles(wgpu::FeatureName feature,
|
||||||
|
const TogglesState& toggles) const;
|
||||||
|
// Used for the tests that intend to use an adapter without all features enabled.
|
||||||
|
void SetSupportedFeaturesForTesting(const std::vector<wgpu::FeatureName>& requiredFeatures);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Backend-specific force-setting and defaulting device toggles
|
||||||
|
virtual void SetupBackendDeviceToggles(TogglesState* deviceToggles) const = 0;
|
||||||
|
|
||||||
|
virtual ResultOrError<Ref<DeviceBase>> CreateDeviceImpl(const DeviceDescriptor* descriptor,
|
||||||
|
const TogglesState& deviceToggles) = 0;
|
||||||
|
|
||||||
|
virtual MaybeError InitializeImpl() = 0;
|
||||||
|
|
||||||
|
// Check base WebGPU features and discover supported features.
|
||||||
|
virtual void InitializeSupportedFeaturesImpl() = 0;
|
||||||
|
|
||||||
|
// Check base WebGPU limits and populate supported limits.
|
||||||
|
virtual MaybeError InitializeSupportedLimitsImpl(CombinedLimits* limits) = 0;
|
||||||
|
|
||||||
|
virtual void InitializeVendorArchitectureImpl();
|
||||||
|
|
||||||
|
virtual MaybeError ValidateFeatureSupportedWithTogglesImpl(
|
||||||
|
wgpu::FeatureName feature,
|
||||||
|
const TogglesState& toggles) const = 0;
|
||||||
|
|
||||||
|
ResultOrError<Ref<DeviceBase>> CreateDeviceInternal(const DeviceDescriptor* descriptor);
|
||||||
|
|
||||||
|
virtual MaybeError ResetInternalDeviceForTestingImpl();
|
||||||
|
Ref<InstanceBase> mInstance;
|
||||||
|
wgpu::BackendType mBackend;
|
||||||
|
|
||||||
|
// Adapter toggles state, currently only inherited from instance toggles state.
|
||||||
|
TogglesState mTogglesState;
|
||||||
|
|
||||||
|
// Features set that CAN be supported by devices of this adapter. Some features in this set may
|
||||||
|
// be guarded by toggles, and creating a device with these features required may result in a
|
||||||
|
// validation error if proper toggles are not enabled/disabled.
|
||||||
|
FeaturesSet mSupportedFeatures;
|
||||||
|
|
||||||
|
CombinedLimits mLimits;
|
||||||
|
bool mUseTieredLimits = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dawn::native
|
||||||
|
|
||||||
|
#endif // SRC_DAWN_NATIVE_PHYSICALDEVICE_H_
|
|
@ -15,9 +15,9 @@
|
||||||
#include "dawn/native/SwapChain.h"
|
#include "dawn/native/SwapChain.h"
|
||||||
|
|
||||||
#include "dawn/common/Constants.h"
|
#include "dawn/common/Constants.h"
|
||||||
#include "dawn/native/Adapter.h"
|
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
#include "dawn/native/ObjectType_autogen.h"
|
#include "dawn/native/ObjectType_autogen.h"
|
||||||
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/Surface.h"
|
#include "dawn/native/Surface.h"
|
||||||
#include "dawn/native/Texture.h"
|
#include "dawn/native/Texture.h"
|
||||||
#include "dawn/native/ValidationUtils_autogen.h"
|
#include "dawn/native/ValidationUtils_autogen.h"
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
#include "dawn/common/Assert.h"
|
#include "dawn/common/Assert.h"
|
||||||
#include "dawn/common/Constants.h"
|
#include "dawn/common/Constants.h"
|
||||||
#include "dawn/common/Math.h"
|
#include "dawn/common/Math.h"
|
||||||
#include "dawn/native/Adapter.h"
|
|
||||||
#include "dawn/native/ChainUtils_autogen.h"
|
#include "dawn/native/ChainUtils_autogen.h"
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
#include "dawn/native/EnumMaskIterator.h"
|
#include "dawn/native/EnumMaskIterator.h"
|
||||||
#include "dawn/native/ObjectType_autogen.h"
|
#include "dawn/native/ObjectType_autogen.h"
|
||||||
#include "dawn/native/PassResourceUsage.h"
|
#include "dawn/native/PassResourceUsage.h"
|
||||||
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/ValidationUtils_autogen.h"
|
#include "dawn/native/ValidationUtils_autogen.h"
|
||||||
|
|
||||||
namespace dawn::native {
|
namespace dawn::native {
|
||||||
|
|
|
@ -24,7 +24,7 @@ template <typename T, typename BackendTraits>
|
||||||
struct ToBackendTraits;
|
struct ToBackendTraits;
|
||||||
|
|
||||||
template <typename BackendTraits>
|
template <typename BackendTraits>
|
||||||
struct ToBackendTraits<AdapterBase, BackendTraits> {
|
struct ToBackendTraits<PhysicalDeviceBase, BackendTraits> {
|
||||||
using BackendType = typename BackendTraits::AdapterType;
|
using BackendType = typename BackendTraits::AdapterType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ Adapter::Adapter(Backend* backend,
|
||||||
ComPtr<IDXGIAdapter3> hardwareAdapter,
|
ComPtr<IDXGIAdapter3> hardwareAdapter,
|
||||||
wgpu::BackendType backendType,
|
wgpu::BackendType backendType,
|
||||||
const TogglesState& adapterToggles)
|
const TogglesState& adapterToggles)
|
||||||
: AdapterBase(backend->GetInstance(), backendType, adapterToggles),
|
: PhysicalDeviceBase(backend->GetInstance(), backendType, adapterToggles),
|
||||||
mHardwareAdapter(std::move(hardwareAdapter)),
|
mHardwareAdapter(std::move(hardwareAdapter)),
|
||||||
mBackend(backend) {}
|
mBackend(backend) {}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_
|
#ifndef SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_
|
||||||
#define SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_
|
#define SRC_DAWN_NATIVE_D3D_ADAPTERD3D_H_
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
|
|
||||||
#include "dawn/native/d3d/d3d_platform.h"
|
#include "dawn/native/d3d/d3d_platform.h"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace dawn::native::d3d {
|
||||||
|
|
||||||
class Backend;
|
class Backend;
|
||||||
|
|
||||||
class Adapter : public AdapterBase {
|
class Adapter : public PhysicalDeviceBase {
|
||||||
public:
|
public:
|
||||||
Adapter(Backend* backend,
|
Adapter(Backend* backend,
|
||||||
ComPtr<IDXGIAdapter3> hardwareAdapter,
|
ComPtr<IDXGIAdapter3> hardwareAdapter,
|
||||||
|
|
|
@ -238,26 +238,27 @@ const PlatformFunctions* Backend::GetFunctions() const {
|
||||||
return mFunctions.get();
|
return mFunctions.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesState& adapterToggles) {
|
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters(
|
||||||
|
const TogglesState& adapterToggles) {
|
||||||
AdapterDiscoveryOptions options(ToAPI(GetType()), nullptr);
|
AdapterDiscoveryOptions options(ToAPI(GetType()), nullptr);
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<PhysicalDeviceBase>> adapters;
|
||||||
if (GetInstance()->ConsumedError(DiscoverAdapters(&options, adapterToggles), &adapters)) {
|
if (GetInstance()->ConsumedError(DiscoverAdapters(&options, adapterToggles), &adapters)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return adapters;
|
return adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
ASSERT(optionsBase->backendType == ToAPI(GetType()));
|
ASSERT(optionsBase->backendType == ToAPI(GetType()));
|
||||||
const AdapterDiscoveryOptions* options =
|
const AdapterDiscoveryOptions* options =
|
||||||
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
|
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<PhysicalDeviceBase>> adapters;
|
||||||
if (options->dxgiAdapter != nullptr) {
|
if (options->dxgiAdapter != nullptr) {
|
||||||
// |dxgiAdapter| was provided. Discover just that adapter.
|
// |dxgiAdapter| was provided. Discover just that adapter.
|
||||||
Ref<AdapterBase> adapter;
|
Ref<PhysicalDeviceBase> adapter;
|
||||||
DAWN_TRY_ASSIGN(adapter,
|
DAWN_TRY_ASSIGN(adapter,
|
||||||
CreateAdapterFromIDXGIAdapter(options->dxgiAdapter, adapterToggles));
|
CreateAdapterFromIDXGIAdapter(options->dxgiAdapter, adapterToggles));
|
||||||
adapters.push_back(std::move(adapter));
|
adapters.push_back(std::move(adapter));
|
||||||
|
@ -272,7 +273,7 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(dxgiAdapter != nullptr);
|
ASSERT(dxgiAdapter != nullptr);
|
||||||
Ref<AdapterBase> adapter;
|
Ref<PhysicalDeviceBase> adapter;
|
||||||
if (GetInstance()->ConsumedError(CreateAdapterFromIDXGIAdapter(dxgiAdapter, adapterToggles),
|
if (GetInstance()->ConsumedError(CreateAdapterFromIDXGIAdapter(dxgiAdapter, adapterToggles),
|
||||||
&adapter)) {
|
&adapter)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -75,14 +75,14 @@ class Backend : public BackendConnection {
|
||||||
|
|
||||||
const PlatformFunctions* GetFunctions() const;
|
const PlatformFunctions* GetFunctions() const;
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters(
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ResultOrError<Ref<AdapterBase>> CreateAdapterFromIDXGIAdapter(
|
virtual ResultOrError<Ref<PhysicalDeviceBase>> CreateAdapterFromIDXGIAdapter(
|
||||||
ComPtr<IDXGIAdapter> dxgiAdapter,
|
ComPtr<IDXGIAdapter> dxgiAdapter,
|
||||||
const TogglesState& adapterToggles) = 0;
|
const TogglesState& adapterToggles) = 0;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Adapter : public d3d::Adapter {
|
||||||
const TogglesState& adapterToggles);
|
const TogglesState& adapterToggles);
|
||||||
~Adapter() override;
|
~Adapter() override;
|
||||||
|
|
||||||
// AdapterBase Implementation
|
// PhysicalDeviceBase Implementation
|
||||||
bool SupportsExternalImages() const override;
|
bool SupportsExternalImages() const override;
|
||||||
|
|
||||||
const DeviceInfo& GetDeviceInfo() const;
|
const DeviceInfo& GetDeviceInfo() const;
|
||||||
|
|
|
@ -41,7 +41,7 @@ const PlatformFunctions* Backend::GetFunctions() const {
|
||||||
return static_cast<const PlatformFunctions*>(Base::GetFunctions());
|
return static_cast<const PlatformFunctions*>(Base::GetFunctions());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<Ref<AdapterBase>> Backend::CreateAdapterFromIDXGIAdapter(
|
ResultOrError<Ref<PhysicalDeviceBase>> Backend::CreateAdapterFromIDXGIAdapter(
|
||||||
ComPtr<IDXGIAdapter> dxgiAdapter,
|
ComPtr<IDXGIAdapter> dxgiAdapter,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
ComPtr<IDXGIAdapter3> dxgiAdapter3;
|
ComPtr<IDXGIAdapter3> dxgiAdapter3;
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Backend : public d3d::Backend {
|
||||||
const PlatformFunctions* GetFunctions() const;
|
const PlatformFunctions* GetFunctions() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ResultOrError<Ref<AdapterBase>> CreateAdapterFromIDXGIAdapter(
|
ResultOrError<Ref<PhysicalDeviceBase>> CreateAdapterFromIDXGIAdapter(
|
||||||
ComPtr<IDXGIAdapter> dxgiAdapter,
|
ComPtr<IDXGIAdapter> dxgiAdapter,
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_
|
#ifndef SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_
|
||||||
#define SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_
|
#define SRC_DAWN_NATIVE_D3D12_ADAPTERD3D12_H_
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
|
|
||||||
#include "dawn/native/d3d/AdapterD3D.h"
|
#include "dawn/native/d3d/AdapterD3D.h"
|
||||||
#include "dawn/native/d3d12/D3D12Info.h"
|
#include "dawn/native/d3d12/D3D12Info.h"
|
||||||
|
@ -32,7 +32,7 @@ class Adapter : public d3d::Adapter {
|
||||||
const TogglesState& adapterToggles);
|
const TogglesState& adapterToggles);
|
||||||
~Adapter() override;
|
~Adapter() override;
|
||||||
|
|
||||||
// AdapterBase Implementation
|
// PhysicalDeviceBase Implementation
|
||||||
bool SupportsExternalImages() const override;
|
bool SupportsExternalImages() const override;
|
||||||
|
|
||||||
const D3D12DeviceInfo& GetDeviceInfo() const;
|
const D3D12DeviceInfo& GetDeviceInfo() const;
|
||||||
|
|
|
@ -63,7 +63,7 @@ const PlatformFunctions* Backend::GetFunctions() const {
|
||||||
return static_cast<const PlatformFunctions*>(Base::GetFunctions());
|
return static_cast<const PlatformFunctions*>(Base::GetFunctions());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<Ref<AdapterBase>> Backend::CreateAdapterFromIDXGIAdapter(
|
ResultOrError<Ref<PhysicalDeviceBase>> Backend::CreateAdapterFromIDXGIAdapter(
|
||||||
ComPtr<IDXGIAdapter> dxgiAdapter,
|
ComPtr<IDXGIAdapter> dxgiAdapter,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
ComPtr<IDXGIAdapter3> dxgiAdapter3;
|
ComPtr<IDXGIAdapter3> dxgiAdapter3;
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Backend final : public d3d::Backend {
|
||||||
const PlatformFunctions* GetFunctions() const;
|
const PlatformFunctions* GetFunctions() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ResultOrError<Ref<AdapterBase>> CreateAdapterFromIDXGIAdapter(
|
ResultOrError<Ref<PhysicalDeviceBase>> CreateAdapterFromIDXGIAdapter(
|
||||||
ComPtr<IDXGIAdapter> dxgiAdapter,
|
ComPtr<IDXGIAdapter> dxgiAdapter,
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ class Backend : public BackendConnection {
|
||||||
explicit Backend(InstanceBase* instance);
|
explicit Backend(InstanceBase* instance);
|
||||||
~Backend() override;
|
~Backend() override;
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters(
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -253,10 +253,11 @@ DAWN_NOINLINE bool IsGPUCounterSupported(id<MTLDevice> device,
|
||||||
|
|
||||||
// The Metal backend's Adapter.
|
// The Metal backend's Adapter.
|
||||||
|
|
||||||
class Adapter : public AdapterBase {
|
class Adapter : public PhysicalDeviceBase {
|
||||||
public:
|
public:
|
||||||
Adapter(InstanceBase* instance, id<MTLDevice> device, const TogglesState& requiredAdapterToggle)
|
Adapter(InstanceBase* instance, id<MTLDevice> device, const TogglesState& requiredAdapterToggle)
|
||||||
: AdapterBase(instance, wgpu::BackendType::Metal, requiredAdapterToggle), mDevice(device) {
|
: PhysicalDeviceBase(instance, wgpu::BackendType::Metal, requiredAdapterToggle),
|
||||||
|
mDevice(device) {
|
||||||
mName = std::string([[*mDevice name] UTF8String]);
|
mName = std::string([[*mDevice name] UTF8String]);
|
||||||
|
|
||||||
PCIIDs ids;
|
PCIIDs ids;
|
||||||
|
@ -283,7 +284,7 @@ class Adapter : public AdapterBase {
|
||||||
mDriverDescription = "Metal driver on " + std::string(systemName) + [osVersion UTF8String];
|
mDriverDescription = "Metal driver on " + std::string(systemName) + [osVersion UTF8String];
|
||||||
}
|
}
|
||||||
|
|
||||||
// AdapterBase Implementation
|
// PhysicalDeviceBase Implementation
|
||||||
bool SupportsExternalImages() const override {
|
bool SupportsExternalImages() const override {
|
||||||
// Via dawn::native::metal::WrapIOSurface
|
// Via dawn::native::metal::WrapIOSurface
|
||||||
return true;
|
return true;
|
||||||
|
@ -786,7 +787,8 @@ Backend::Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::Bac
|
||||||
|
|
||||||
Backend::~Backend() = default;
|
Backend::~Backend() = default;
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesState& adapterToggles) {
|
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters(
|
||||||
|
const TogglesState& adapterToggles) {
|
||||||
AdapterDiscoveryOptions options;
|
AdapterDiscoveryOptions options;
|
||||||
auto result = DiscoverAdapters(&options, adapterToggles);
|
auto result = DiscoverAdapters(&options, adapterToggles);
|
||||||
if (result.IsError()) {
|
if (result.IsError()) {
|
||||||
|
@ -796,12 +798,12 @@ std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesStat
|
||||||
return result.AcquireSuccess();
|
return result.AcquireSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
ASSERT(optionsBase->backendType == WGPUBackendType_Metal);
|
ASSERT(optionsBase->backendType == WGPUBackendType_Metal);
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<PhysicalDeviceBase>> adapters;
|
||||||
#if DAWN_PLATFORM_IS(MACOS)
|
#if DAWN_PLATFORM_IS(MACOS)
|
||||||
NSRef<NSArray<id<MTLDevice>>> devices = AcquireNSRef(MTLCopyAllDevices());
|
NSRef<NSArray<id<MTLDevice>>> devices = AcquireNSRef(MTLCopyAllDevices());
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ Adapter::Adapter(InstanceBase* instance)
|
||||||
TogglesState(ToggleStage::Adapter).InheritFrom(instance->GetTogglesState())) {}
|
TogglesState(ToggleStage::Adapter).InheritFrom(instance->GetTogglesState())) {}
|
||||||
|
|
||||||
Adapter::Adapter(InstanceBase* instance, const TogglesState& adapterToggles)
|
Adapter::Adapter(InstanceBase* instance, const TogglesState& adapterToggles)
|
||||||
: AdapterBase(instance, wgpu::BackendType::Null, adapterToggles) {
|
: PhysicalDeviceBase(instance, wgpu::BackendType::Null, adapterToggles) {
|
||||||
mVendorId = 0;
|
mVendorId = 0;
|
||||||
mDeviceId = 0;
|
mDeviceId = 0;
|
||||||
mName = "Null backend";
|
mName = "Null backend";
|
||||||
|
@ -83,11 +83,11 @@ class Backend : public BackendConnection {
|
||||||
explicit Backend(InstanceBase* instance)
|
explicit Backend(InstanceBase* instance)
|
||||||
: BackendConnection(instance, wgpu::BackendType::Null) {}
|
: BackendConnection(instance, wgpu::BackendType::Null) {}
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters(
|
||||||
const TogglesState& adapterToggles) override {
|
const TogglesState& adapterToggles) override {
|
||||||
// There is always a single Null adapter because it is purely CPU based and doesn't
|
// There is always a single Null adapter because it is purely CPU based and doesn't
|
||||||
// depend on the system.
|
// depend on the system.
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<PhysicalDeviceBase>> adapters;
|
||||||
Ref<Adapter> adapter = AcquireRef(new Adapter(GetInstance(), adapterToggles));
|
Ref<Adapter> adapter = AcquireRef(new Adapter(GetInstance(), adapterToggles));
|
||||||
adapters.push_back(std::move(adapter));
|
adapters.push_back(std::move(adapter));
|
||||||
return adapters;
|
return adapters;
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
|
||||||
#include "dawn/native/BindGroup.h"
|
#include "dawn/native/BindGroup.h"
|
||||||
#include "dawn/native/BindGroupLayout.h"
|
#include "dawn/native/BindGroupLayout.h"
|
||||||
#include "dawn/native/Buffer.h"
|
#include "dawn/native/Buffer.h"
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include "dawn/native/CommandEncoder.h"
|
#include "dawn/native/CommandEncoder.h"
|
||||||
#include "dawn/native/ComputePipeline.h"
|
#include "dawn/native/ComputePipeline.h"
|
||||||
#include "dawn/native/Device.h"
|
#include "dawn/native/Device.h"
|
||||||
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/PipelineLayout.h"
|
#include "dawn/native/PipelineLayout.h"
|
||||||
#include "dawn/native/QuerySet.h"
|
#include "dawn/native/QuerySet.h"
|
||||||
#include "dawn/native/Queue.h"
|
#include "dawn/native/Queue.h"
|
||||||
|
@ -170,7 +170,7 @@ class Device final : public DeviceBase {
|
||||||
size_t mMemoryUsage = 0;
|
size_t mMemoryUsage = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Adapter : public AdapterBase {
|
class Adapter : public PhysicalDeviceBase {
|
||||||
public:
|
public:
|
||||||
// Create null adapter without providing toggles state for testing, only inherit instance's
|
// Create null adapter without providing toggles state for testing, only inherit instance's
|
||||||
// toggles state
|
// toggles state
|
||||||
|
@ -178,11 +178,11 @@ class Adapter : public AdapterBase {
|
||||||
Adapter(InstanceBase* instance, const TogglesState& adapterToggles);
|
Adapter(InstanceBase* instance, const TogglesState& adapterToggles);
|
||||||
~Adapter() override;
|
~Adapter() override;
|
||||||
|
|
||||||
// AdapterBase Implementation
|
// PhysicalDeviceBase Implementation
|
||||||
bool SupportsExternalImages() const override;
|
bool SupportsExternalImages() const override;
|
||||||
|
|
||||||
// Used for the tests that intend to use an adapter without all features enabled.
|
// Used for the tests that intend to use an adapter without all features enabled.
|
||||||
using AdapterBase::SetSupportedFeaturesForTesting;
|
using PhysicalDeviceBase::SetSupportedFeaturesForTesting;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MaybeError InitializeImpl() override;
|
MaybeError InitializeImpl() override;
|
||||||
|
|
|
@ -56,7 +56,7 @@ uint32_t GetVendorIdFromVendors(const char* vendor) {
|
||||||
Adapter::Adapter(InstanceBase* instance,
|
Adapter::Adapter(InstanceBase* instance,
|
||||||
wgpu::BackendType backendType,
|
wgpu::BackendType backendType,
|
||||||
const TogglesState& adapterToggle)
|
const TogglesState& adapterToggle)
|
||||||
: AdapterBase(instance, backendType, adapterToggle) {}
|
: PhysicalDeviceBase(instance, backendType, adapterToggle) {}
|
||||||
|
|
||||||
MaybeError Adapter::InitializeGLFunctions(void* (*getProc)(const char*)) {
|
MaybeError Adapter::InitializeGLFunctions(void* (*getProc)(const char*)) {
|
||||||
// Use getProc to populate the dispatch table
|
// Use getProc to populate the dispatch table
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_OPENGL_ADAPTERGL_H_
|
#ifndef SRC_DAWN_NATIVE_OPENGL_ADAPTERGL_H_
|
||||||
#define SRC_DAWN_NATIVE_OPENGL_ADAPTERGL_H_
|
#define SRC_DAWN_NATIVE_OPENGL_ADAPTERGL_H_
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
#include "dawn/native/opengl/EGLFunctions.h"
|
#include "dawn/native/opengl/EGLFunctions.h"
|
||||||
#include "dawn/native/opengl/OpenGLFunctions.h"
|
#include "dawn/native/opengl/OpenGLFunctions.h"
|
||||||
|
|
||||||
namespace dawn::native::opengl {
|
namespace dawn::native::opengl {
|
||||||
|
|
||||||
class Adapter : public AdapterBase {
|
class Adapter : public PhysicalDeviceBase {
|
||||||
public:
|
public:
|
||||||
Adapter(InstanceBase* instance,
|
Adapter(InstanceBase* instance,
|
||||||
wgpu::BackendType backendType,
|
wgpu::BackendType backendType,
|
||||||
|
@ -31,7 +31,7 @@ class Adapter : public AdapterBase {
|
||||||
|
|
||||||
~Adapter() override = default;
|
~Adapter() override = default;
|
||||||
|
|
||||||
// AdapterBase Implementation
|
// PhysicalDeviceBase Implementation
|
||||||
bool SupportsExternalImages() const override;
|
bool SupportsExternalImages() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -33,8 +33,9 @@ namespace dawn::native::opengl {
|
||||||
Backend::Backend(InstanceBase* instance, wgpu::BackendType backendType)
|
Backend::Backend(InstanceBase* instance, wgpu::BackendType backendType)
|
||||||
: BackendConnection(instance, backendType) {}
|
: BackendConnection(instance, backendType) {}
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesState& adapterToggles) {
|
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters(
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
const TogglesState& adapterToggles) {
|
||||||
|
std::vector<Ref<PhysicalDeviceBase>> adapters;
|
||||||
#if DAWN_PLATFORM_IS(WINDOWS)
|
#if DAWN_PLATFORM_IS(WINDOWS)
|
||||||
const char* eglLib = "libEGL.dll";
|
const char* eglLib = "libEGL.dll";
|
||||||
#elif DAWN_PLATFORM_IS(MACOS)
|
#elif DAWN_PLATFORM_IS(MACOS)
|
||||||
|
@ -83,7 +84,7 @@ std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesStat
|
||||||
return adapters;
|
return adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
// TODO(cwallez@chromium.org): For now only create a single OpenGL adapter because don't
|
// TODO(cwallez@chromium.org): For now only create a single OpenGL adapter because don't
|
||||||
|
@ -102,7 +103,7 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
DAWN_TRY(adapter->Initialize());
|
DAWN_TRY(adapter->Initialize());
|
||||||
|
|
||||||
mCreatedAdapter = true;
|
mCreatedAdapter = true;
|
||||||
std::vector<Ref<AdapterBase>> adapters{std::move(adapter)};
|
std::vector<Ref<PhysicalDeviceBase>> adapters{std::move(adapter)};
|
||||||
return std::move(adapters);
|
return std::move(adapters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ class Backend : public BackendConnection {
|
||||||
public:
|
public:
|
||||||
Backend(InstanceBase* instance, wgpu::BackendType backendType);
|
Backend(InstanceBase* instance, wgpu::BackendType backendType);
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters(
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* option,
|
const AdapterDiscoveryOptionsBase* option,
|
||||||
const TogglesState& adapterToggless) override;
|
const TogglesState& adapterToggless) override;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ Adapter::Adapter(InstanceBase* instance,
|
||||||
VulkanInstance* vulkanInstance,
|
VulkanInstance* vulkanInstance,
|
||||||
VkPhysicalDevice physicalDevice,
|
VkPhysicalDevice physicalDevice,
|
||||||
const TogglesState& adapterToggles)
|
const TogglesState& adapterToggles)
|
||||||
: AdapterBase(instance, wgpu::BackendType::Vulkan, adapterToggles),
|
: PhysicalDeviceBase(instance, wgpu::BackendType::Vulkan, adapterToggles),
|
||||||
mPhysicalDevice(physicalDevice),
|
mPhysicalDevice(physicalDevice),
|
||||||
mVulkanInstance(vulkanInstance) {}
|
mVulkanInstance(vulkanInstance) {}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_
|
#ifndef SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_
|
||||||
#define SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_
|
#define SRC_DAWN_NATIVE_VULKAN_ADAPTERVK_H_
|
||||||
|
|
||||||
#include "dawn/native/Adapter.h"
|
#include "dawn/native/PhysicalDevice.h"
|
||||||
|
|
||||||
#include "dawn/common/RefCounted.h"
|
#include "dawn/common/RefCounted.h"
|
||||||
#include "dawn/common/vulkan_platform.h"
|
#include "dawn/common/vulkan_platform.h"
|
||||||
|
@ -25,7 +25,7 @@ namespace dawn::native::vulkan {
|
||||||
|
|
||||||
class VulkanInstance;
|
class VulkanInstance;
|
||||||
|
|
||||||
class Adapter : public AdapterBase {
|
class Adapter : public PhysicalDeviceBase {
|
||||||
public:
|
public:
|
||||||
Adapter(InstanceBase* instance,
|
Adapter(InstanceBase* instance,
|
||||||
VulkanInstance* vulkanInstance,
|
VulkanInstance* vulkanInstance,
|
||||||
|
@ -33,7 +33,7 @@ class Adapter : public AdapterBase {
|
||||||
const TogglesState& adapterToggles);
|
const TogglesState& adapterToggles);
|
||||||
~Adapter() override;
|
~Adapter() override;
|
||||||
|
|
||||||
// AdapterBase Implementation
|
// PhysicalDeviceBase Implementation
|
||||||
bool SupportsExternalImages() const override;
|
bool SupportsExternalImages() const override;
|
||||||
|
|
||||||
const VulkanDeviceInfo& GetDeviceInfo() const;
|
const VulkanDeviceInfo& GetDeviceInfo() const;
|
||||||
|
|
|
@ -457,7 +457,8 @@ Backend::Backend(InstanceBase* instance) : BackendConnection(instance, wgpu::Bac
|
||||||
|
|
||||||
Backend::~Backend() = default;
|
Backend::~Backend() = default;
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesState& adapterToggles) {
|
std::vector<Ref<PhysicalDeviceBase>> Backend::DiscoverDefaultAdapters(
|
||||||
|
const TogglesState& adapterToggles) {
|
||||||
AdapterDiscoveryOptions options;
|
AdapterDiscoveryOptions options;
|
||||||
auto result = DiscoverAdapters(&options, adapterToggles);
|
auto result = DiscoverAdapters(&options, adapterToggles);
|
||||||
if (result.IsError()) {
|
if (result.IsError()) {
|
||||||
|
@ -467,7 +468,7 @@ std::vector<Ref<AdapterBase>> Backend::DiscoverDefaultAdapters(const TogglesStat
|
||||||
return result.AcquireSuccess();
|
return result.AcquireSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> Backend::DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) {
|
const TogglesState& adapterToggles) {
|
||||||
ASSERT(optionsBase->backendType == WGPUBackendType_Vulkan);
|
ASSERT(optionsBase->backendType == WGPUBackendType_Vulkan);
|
||||||
|
@ -475,7 +476,7 @@ ResultOrError<std::vector<Ref<AdapterBase>>> Backend::DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptions* options =
|
const AdapterDiscoveryOptions* options =
|
||||||
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
|
static_cast<const AdapterDiscoveryOptions*>(optionsBase);
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> adapters;
|
std::vector<Ref<PhysicalDeviceBase>> adapters;
|
||||||
|
|
||||||
InstanceBase* instance = GetInstance();
|
InstanceBase* instance = GetInstance();
|
||||||
for (ICD icd : kICDs) {
|
for (ICD icd : kICDs) {
|
||||||
|
|
|
@ -91,9 +91,9 @@ class Backend : public BackendConnection {
|
||||||
|
|
||||||
MaybeError Initialize();
|
MaybeError Initialize();
|
||||||
|
|
||||||
std::vector<Ref<AdapterBase>> DiscoverDefaultAdapters(
|
std::vector<Ref<PhysicalDeviceBase>> DiscoverDefaultAdapters(
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
ResultOrError<std::vector<Ref<AdapterBase>>> DiscoverAdapters(
|
ResultOrError<std::vector<Ref<PhysicalDeviceBase>>> DiscoverAdapters(
|
||||||
const AdapterDiscoveryOptionsBase* optionsBase,
|
const AdapterDiscoveryOptionsBase* optionsBase,
|
||||||
const TogglesState& adapterToggles) override;
|
const TogglesState& adapterToggles) override;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "dawn/common/Assert.h"
|
#include "dawn/common/Assert.h"
|
||||||
#include "dawn/common/SystemUtils.h"
|
#include "dawn/common/SystemUtils.h"
|
||||||
#include "dawn/dawn_proc.h"
|
#include "dawn/dawn_proc.h"
|
||||||
|
#include "dawn/native/Adapter.h"
|
||||||
#include "dawn/native/NullBackend.h"
|
#include "dawn/native/NullBackend.h"
|
||||||
#include "dawn/tests/ToggleParser.h"
|
#include "dawn/tests/ToggleParser.h"
|
||||||
#include "dawn/tests/unittests/validation/ValidationTest.h"
|
#include "dawn/tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
Loading…
Reference in New Issue