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