Gather PCI device info through the adapter when possible
This will help migrate PCI info collection from the device to the adapter where it belongs. BUG=dawn:29 Change-Id: Ifa7d167249c97f1934f7c10d420f864f59babd37 Reviewed-on: https://dawn-review.googlesource.com/c/3843 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
7aae840a22
commit
ec18f9683c
|
@ -34,6 +34,9 @@ namespace dawn_native {
|
|||
|
||||
DeviceBase* CreateDevice();
|
||||
|
||||
protected:
|
||||
PCIInfo mPCIInfo = {};
|
||||
|
||||
private:
|
||||
virtual ResultOrError<DeviceBase*> CreateDeviceImpl() = 0;
|
||||
|
||||
|
@ -41,7 +44,6 @@ namespace dawn_native {
|
|||
|
||||
InstanceBase* mInstance = nullptr;
|
||||
BackendType mBackend;
|
||||
PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "dawn_native/Device.h"
|
||||
|
||||
#include "dawn_native/Adapter.h"
|
||||
#include "dawn_native/BindGroup.h"
|
||||
#include "dawn_native/BindGroupLayout.h"
|
||||
#include "dawn_native/Buffer.h"
|
||||
|
@ -49,7 +50,7 @@ namespace dawn_native {
|
|||
|
||||
// DeviceBase
|
||||
|
||||
DeviceBase::DeviceBase() {
|
||||
DeviceBase::DeviceBase(AdapterBase* adapter) : mAdapter(adapter) {
|
||||
mCaches = std::make_unique<DeviceBase::Caches>();
|
||||
mFenceSignalTracker = std::make_unique<FenceSignalTracker>(this);
|
||||
}
|
||||
|
@ -97,6 +98,11 @@ namespace dawn_native {
|
|||
mCaches->bindGroupLayouts.erase(obj);
|
||||
}
|
||||
|
||||
const PCIInfo& DeviceBase::GetPCIInfo() const {
|
||||
ASSERT(mAdapter != nullptr);
|
||||
return mAdapter->GetPCIInfo();
|
||||
}
|
||||
|
||||
// Object creation API methods
|
||||
|
||||
BindGroupBase* DeviceBase::CreateBindGroup(const BindGroupDescriptor* descriptor) {
|
||||
|
|
|
@ -29,11 +29,12 @@ namespace dawn_native {
|
|||
|
||||
using ErrorCallback = void (*)(const char* errorMessage, void* userData);
|
||||
|
||||
class AdapterBase;
|
||||
class FenceSignalTracker;
|
||||
|
||||
class DeviceBase {
|
||||
public:
|
||||
DeviceBase();
|
||||
DeviceBase(AdapterBase* adapter);
|
||||
virtual ~DeviceBase();
|
||||
|
||||
void HandleError(const char* message);
|
||||
|
@ -108,7 +109,7 @@ namespace dawn_native {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
virtual const PCIInfo& GetPCIInfo() const = 0;
|
||||
virtual const PCIInfo& GetPCIInfo() const;
|
||||
|
||||
private:
|
||||
virtual ResultOrError<BindGroupBase*> CreateBindGroupImpl(
|
||||
|
@ -156,6 +157,8 @@ namespace dawn_native {
|
|||
|
||||
void ConsumeError(ErrorData* error);
|
||||
|
||||
AdapterBase* mAdapter = nullptr;
|
||||
|
||||
// The object caches aren't exposed in the header as they would require a lot of
|
||||
// additional includes.
|
||||
struct Caches;
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
Device::Device() {
|
||||
Device::Device() : DeviceBase(nullptr) {
|
||||
mFunctions = std::make_unique<PlatformFunctions>();
|
||||
|
||||
{
|
||||
|
|
|
@ -128,7 +128,8 @@ namespace dawn_native { namespace metal {
|
|||
// Device
|
||||
|
||||
Device::Device()
|
||||
: mMtlDevice(MTLCreateSystemDefaultDevice()),
|
||||
: DeviceBase(nullptr),
|
||||
mMtlDevice(MTLCreateSystemDefaultDevice()),
|
||||
mMapTracker(new MapRequestTracker(this)),
|
||||
mResourceUploader(new ResourceUploader(this)) {
|
||||
[mMtlDevice retain];
|
||||
|
|
|
@ -26,12 +26,13 @@ namespace dawn_native { namespace null {
|
|||
class Adapter : public AdapterBase {
|
||||
public:
|
||||
Adapter(InstanceBase* instance) : AdapterBase(instance, BackendType::Null) {
|
||||
mPCIInfo.name = "Null backend";
|
||||
}
|
||||
virtual ~Adapter() = default;
|
||||
|
||||
private:
|
||||
ResultOrError<DeviceBase*> CreateDeviceImpl() override {
|
||||
return {new Device};
|
||||
return {new Device(this)};
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,8 +56,7 @@ namespace dawn_native { namespace null {
|
|||
|
||||
// Device
|
||||
|
||||
Device::Device() {
|
||||
InitFakePCIInfo();
|
||||
Device::Device(Adapter* adapter) : DeviceBase(adapter) {
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
|
@ -122,14 +122,6 @@ namespace dawn_native { namespace null {
|
|||
return new TextureView(texture, descriptor);
|
||||
}
|
||||
|
||||
void Device::InitFakePCIInfo() {
|
||||
mPCIInfo.name = "Null backend";
|
||||
}
|
||||
|
||||
const dawn_native::PCIInfo& Device::GetPCIInfo() const {
|
||||
return mPCIInfo;
|
||||
}
|
||||
|
||||
Serial Device::GetCompletedCommandSerial() const {
|
||||
return mCompletedSerial;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace dawn_native { namespace null {
|
|||
|
||||
class Device : public DeviceBase {
|
||||
public:
|
||||
Device();
|
||||
Device(Adapter* adapter);
|
||||
~Device();
|
||||
|
||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||
|
@ -98,8 +98,6 @@ namespace dawn_native { namespace null {
|
|||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
void AddPendingOperation(std::unique_ptr<PendingOperation> operation);
|
||||
void SubmitPendingOperations();
|
||||
|
||||
|
@ -123,12 +121,10 @@ namespace dawn_native { namespace null {
|
|||
ResultOrError<TextureViewBase*> CreateTextureViewImpl(
|
||||
TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor) override;
|
||||
void InitFakePCIInfo();
|
||||
|
||||
Serial mCompletedSerial = 0;
|
||||
Serial mLastSubmittedSerial = 0;
|
||||
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
class Buffer : public BufferBase {
|
||||
|
|
|
@ -32,6 +32,8 @@ namespace dawn_native { namespace opengl {
|
|||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
|
||||
|
||||
mPCIInfo.name = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
}
|
||||
virtual ~Adapter() = default;
|
||||
|
||||
|
@ -39,7 +41,7 @@ namespace dawn_native { namespace opengl {
|
|||
ResultOrError<DeviceBase*> CreateDeviceImpl() override {
|
||||
// There is no limit on the number of devices created from this adapter because they can
|
||||
// all share the same backing OpenGL context.
|
||||
return {new Device};
|
||||
return {new Device(this)};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
Device::Device() {
|
||||
CollectPCIInfo();
|
||||
Device::Device(AdapterBase* adapter) : DeviceBase(adapter) {
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
|
@ -145,12 +144,4 @@ namespace dawn_native { namespace opengl {
|
|||
}
|
||||
}
|
||||
|
||||
const dawn_native::PCIInfo& Device::GetPCIInfo() const {
|
||||
return mPCIInfo;
|
||||
}
|
||||
|
||||
void Device::CollectPCIInfo() {
|
||||
mPCIInfo.name = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
class Device : public DeviceBase {
|
||||
public:
|
||||
Device();
|
||||
Device(AdapterBase* adapter);
|
||||
~Device();
|
||||
|
||||
void SubmitFenceSync();
|
||||
|
@ -50,8 +50,6 @@ namespace dawn_native { namespace opengl {
|
|||
Serial GetLastSubmittedCommandSerial() const final override;
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
private:
|
||||
ResultOrError<BindGroupBase*> CreateBindGroupImpl(
|
||||
const BindGroupDescriptor* descriptor) override;
|
||||
|
@ -72,15 +70,12 @@ namespace dawn_native { namespace opengl {
|
|||
ResultOrError<TextureViewBase*> CreateTextureViewImpl(
|
||||
TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor) override;
|
||||
void CollectPCIInfo();
|
||||
|
||||
void CheckPassedFences();
|
||||
|
||||
Serial mCompletedSerial = 0;
|
||||
Serial mLastSubmittedSerial = 0;
|
||||
std::queue<std::pair<GLsync, Serial>> mFencesInFlight;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
// Device
|
||||
|
||||
Device::Device() {
|
||||
Device::Device() : DeviceBase(nullptr) {
|
||||
MaybeError maybeError = Initialize();
|
||||
|
||||
// In device initialization, the error callback can't have been set yet.
|
||||
|
|
Loading…
Reference in New Issue