Collect GPU device information for end2end tests - Part I
This patch is the first one to support inspecting GPU information for dawn_end2end_tests. In this patch, we support collecting the device name, device id and vendor id on D3D12 and Vulkan. We also support collecting the device name on OpenGL. The collection on Metal will be supported in the next patch. Using this information we implement a series of APIs to inspect the information of both OS and GPU vendor. We also skip two failed tests on Windows Intel Vulkan backends. BUG=dawn:10 Change-Id: If52a960c0bae3922a0b5650500218eff1400d77a Reviewed-on: https://dawn-review.googlesource.com/1460 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
cd5e5756fd
commit
58809d413b
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_native/Device.h"
|
||||
|
||||
// Contains the entry-points into dawn_native
|
||||
|
||||
|
@ -24,4 +25,9 @@ namespace dawn_native {
|
|||
return GetProcsAutogen();
|
||||
}
|
||||
|
||||
const PCIInfo& GetPCIInfo(dawnDevice device) {
|
||||
DeviceBase* deviceBase = reinterpret_cast<DeviceBase*>(device);
|
||||
return deviceBase->GetPCIInfo();
|
||||
}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "dawn_native/Forward.h"
|
||||
#include "dawn_native/RefCounted.h"
|
||||
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_native/dawn_platform.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -105,6 +106,8 @@ namespace dawn_native {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
virtual const PCIInfo& GetPCIInfo() const = 0;
|
||||
|
||||
private:
|
||||
virtual ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
|
||||
const BindGroupLayoutDescriptor* descriptor) = 0;
|
||||
|
|
|
@ -40,6 +40,8 @@
|
|||
#include "dawn_native/d3d12/SwapChainD3D12.h"
|
||||
#include "dawn_native/d3d12/TextureD3D12.h"
|
||||
|
||||
#include <locale>
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
dawnDevice CreateDevice() {
|
||||
|
@ -133,6 +135,9 @@ namespace dawn_native { namespace d3d12 {
|
|||
ASSERT_SUCCESS(mFunctions->d3d12CreateDevice(mHardwareAdapter.Get(), D3D_FEATURE_LEVEL_11_0,
|
||||
IID_PPV_ARGS(&mD3d12Device)));
|
||||
|
||||
// Collect GPU information
|
||||
CollectPCIInfo();
|
||||
|
||||
// Create device-global objects
|
||||
D3D12_COMMAND_QUEUE_DESC queueDesc = {};
|
||||
queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
|
@ -231,6 +236,10 @@ namespace dawn_native { namespace d3d12 {
|
|||
NextSerial();
|
||||
}
|
||||
|
||||
const dawn_native::PCIInfo& Device::GetPCIInfo() const {
|
||||
return mPCIInfo;
|
||||
}
|
||||
|
||||
uint64_t Device::GetSerial() const {
|
||||
return mSerial;
|
||||
}
|
||||
|
@ -329,4 +338,18 @@ namespace dawn_native { namespace d3d12 {
|
|||
return new TextureView(texture);
|
||||
}
|
||||
|
||||
void Device::CollectPCIInfo() {
|
||||
memset(&mPCIInfo, 0, sizeof(mPCIInfo));
|
||||
|
||||
DXGI_ADAPTER_DESC1 adapterDesc;
|
||||
mHardwareAdapter->GetDesc1(&adapterDesc);
|
||||
|
||||
mPCIInfo.deviceId = adapterDesc.DeviceId;
|
||||
mPCIInfo.vendorId = adapterDesc.VendorId;
|
||||
|
||||
std::wstring_convert<std::codecvt<wchar_t, char, std::mbstate_t>> converter(
|
||||
"Error converting");
|
||||
mPCIInfo.name = converter.to_bytes(adapterDesc.Description);
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -55,6 +55,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
ComPtr<IDXGIFactory4> GetFactory();
|
||||
ComPtr<ID3D12Device> GetD3D12Device();
|
||||
ComPtr<ID3D12CommandQueue> GetCommandQueue();
|
||||
|
@ -89,6 +91,7 @@ namespace dawn_native { namespace d3d12 {
|
|||
ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
|
||||
const ShaderModuleDescriptor* descriptor) override;
|
||||
ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||
void CollectPCIInfo();
|
||||
|
||||
// Keep mFunctions as the first member so that in the destructor it is freed. Otherwise the
|
||||
// D3D12 DLLs are unloaded before we are done using it.
|
||||
|
@ -115,6 +118,8 @@ namespace dawn_native { namespace d3d12 {
|
|||
std::unique_ptr<MapRequestTracker> mMapRequestTracker;
|
||||
std::unique_ptr<ResourceAllocator> mResourceAllocator;
|
||||
std::unique_ptr<ResourceUploader> mResourceUploader;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
|
|
@ -51,6 +51,8 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
id<MTLDevice> GetMTLDevice();
|
||||
|
||||
id<MTLCommandBuffer> GetPendingCommandBuffer();
|
||||
|
@ -73,6 +75,7 @@ namespace dawn_native { namespace metal {
|
|||
ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
|
||||
const ShaderModuleDescriptor* descriptor) override;
|
||||
ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||
void CollectPCIInfo();
|
||||
|
||||
void OnCompletedHandler();
|
||||
|
||||
|
@ -84,6 +87,8 @@ namespace dawn_native { namespace metal {
|
|||
Serial mFinishedCommandSerial = 0;
|
||||
Serial mPendingCommandSerial = 1;
|
||||
id<MTLCommandBuffer> mPendingCommands = nil;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace dawn_native { namespace metal {
|
|||
mResourceUploader(new ResourceUploader(this)) {
|
||||
[mMtlDevice retain];
|
||||
mCommandQueue = [mMtlDevice newCommandQueue];
|
||||
CollectPCIInfo();
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
|
@ -144,6 +145,10 @@ namespace dawn_native { namespace metal {
|
|||
SubmitPendingCommandBuffer();
|
||||
}
|
||||
|
||||
const dawn_native::PCIInfo& Device::GetPCIInfo() const {
|
||||
return mPCIInfo;
|
||||
}
|
||||
|
||||
id<MTLDevice> Device::GetMTLDevice() {
|
||||
return mMtlDevice;
|
||||
}
|
||||
|
@ -193,4 +198,8 @@ namespace dawn_native { namespace metal {
|
|||
return mResourceUploader.get();
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): collect device information on Metal
|
||||
void Device::CollectPCIInfo() {
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
|
|
@ -28,6 +28,7 @@ namespace dawn_native { namespace null {
|
|||
// Device
|
||||
|
||||
Device::Device() {
|
||||
InitFakePCIInfo();
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
|
@ -98,6 +99,14 @@ namespace dawn_native { namespace null {
|
|||
return new TextureView(texture);
|
||||
}
|
||||
|
||||
void Device::InitFakePCIInfo() {
|
||||
mPCIInfo.name = "Null backend";
|
||||
}
|
||||
|
||||
const dawn_native::PCIInfo& Device::GetPCIInfo() const {
|
||||
return mPCIInfo;
|
||||
}
|
||||
|
||||
void Device::TickImpl() {
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,8 @@ namespace dawn_native { namespace null {
|
|||
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
void AddPendingOperation(std::unique_ptr<PendingOperation> operation);
|
||||
std::vector<std::unique_ptr<PendingOperation>> AcquirePendingOperations();
|
||||
|
||||
|
@ -125,8 +127,10 @@ namespace dawn_native { namespace null {
|
|||
ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
|
||||
const ShaderModuleDescriptor* descriptor) override;
|
||||
ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||
void InitFakePCIInfo();
|
||||
|
||||
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
class Buffer : public BufferBase {
|
||||
|
|
|
@ -46,6 +46,10 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
// Device
|
||||
|
||||
Device::Device() {
|
||||
CollectPCIInfo();
|
||||
}
|
||||
|
||||
BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
|
||||
return new BindGroup(builder);
|
||||
}
|
||||
|
@ -109,4 +113,12 @@ namespace dawn_native { namespace opengl {
|
|||
void Device::TickImpl() {
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -32,6 +32,7 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
class Device : public DeviceBase {
|
||||
public:
|
||||
Device();
|
||||
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
||||
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
||||
|
@ -46,6 +47,8 @@ namespace dawn_native { namespace opengl {
|
|||
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
private:
|
||||
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
|
||||
const BindGroupLayoutDescriptor* descriptor) override;
|
||||
|
@ -59,6 +62,9 @@ namespace dawn_native { namespace opengl {
|
|||
ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
|
||||
const ShaderModuleDescriptor* descriptor) override;
|
||||
ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
|
||||
void CollectPCIInfo();
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
|
|
@ -151,6 +151,10 @@ namespace dawn_native { namespace vulkan {
|
|||
mMapRequestTracker = std::make_unique<MapRequestTracker>(this);
|
||||
mMemoryAllocator = std::make_unique<MemoryAllocator>(this);
|
||||
mRenderPassCache = std::make_unique<RenderPassCache>(this);
|
||||
|
||||
mPCIInfo.deviceId = mDeviceInfo.properties.deviceID;
|
||||
mPCIInfo.vendorId = mDeviceInfo.properties.vendorID;
|
||||
mPCIInfo.name = mDeviceInfo.properties.deviceName;
|
||||
}
|
||||
|
||||
Device::~Device() {
|
||||
|
@ -290,6 +294,10 @@ namespace dawn_native { namespace vulkan {
|
|||
}
|
||||
}
|
||||
|
||||
const dawn_native::PCIInfo& Device::GetPCIInfo() const {
|
||||
return mPCIInfo;
|
||||
}
|
||||
|
||||
const VulkanDeviceInfo& Device::GetDeviceInfo() const {
|
||||
return mDeviceInfo;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ namespace dawn_native { namespace vulkan {
|
|||
|
||||
void TickImpl() override;
|
||||
|
||||
const dawn_native::PCIInfo& GetPCIInfo() const override;
|
||||
|
||||
private:
|
||||
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
|
||||
const BindGroupLayoutDescriptor* descriptor) override;
|
||||
|
@ -155,6 +157,8 @@ namespace dawn_native { namespace vulkan {
|
|||
std::vector<CommandPoolAndBuffer> mUnusedCommands;
|
||||
CommandPoolAndBuffer mPendingCommands;
|
||||
std::vector<VkSemaphore> mWaitSemaphores;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::vulkan
|
||||
|
|
|
@ -18,11 +18,20 @@
|
|||
#include <dawn/dawn.h>
|
||||
#include <dawn_native/dawn_native_export.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace dawn_native {
|
||||
struct PCIInfo {
|
||||
uint32_t deviceId = 0;
|
||||
uint32_t vendorId = 0;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
// Backend-agnostic API for dawn_native
|
||||
DAWN_NATIVE_EXPORT dawnProcTable GetProcs();
|
||||
|
||||
DAWN_NATIVE_EXPORT const PCIInfo& GetPCIInfo(dawnDevice device);
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
#endif // DAWNNATIVE_DAWNNATIVE_H_
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "common/Assert.h"
|
||||
#include "common/Constants.h"
|
||||
#include "common/Math.h"
|
||||
#include "common/Platform.h"
|
||||
#include "dawn_native/DawnNative.h"
|
||||
#include "dawn_wire/Wire.h"
|
||||
#include "utils/BackendBinding.h"
|
||||
|
@ -125,6 +126,54 @@ bool DawnTest::IsVulkan() const {
|
|||
return GetParam() == VulkanBackend;
|
||||
}
|
||||
|
||||
bool DawnTest::IsAMD() const {
|
||||
return mPCIInfo.vendorId == kVendorID_AMD;
|
||||
}
|
||||
|
||||
bool DawnTest::IsARM() const {
|
||||
return mPCIInfo.vendorId == kVendorID_ARM;
|
||||
}
|
||||
|
||||
bool DawnTest::IsImgTec() const {
|
||||
return mPCIInfo.vendorId == kVendorID_ImgTec;
|
||||
}
|
||||
|
||||
bool DawnTest::IsIntel() const {
|
||||
return mPCIInfo.vendorId == kVendorID_Intel;
|
||||
}
|
||||
|
||||
bool DawnTest::IsNvidia() const {
|
||||
return mPCIInfo.vendorId == kVendorID_Nvidia;
|
||||
}
|
||||
|
||||
bool DawnTest::IsQualcomm() const {
|
||||
return mPCIInfo.vendorId == kVendorID_Qualcomm;
|
||||
}
|
||||
|
||||
bool DawnTest::IsWindows() const {
|
||||
#ifdef DAWN_PLATFORM_WINDOWS
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DawnTest::IsLinux() const {
|
||||
#ifdef DAWN_PLATFORM_LINUX
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool DawnTest::IsMacOS() const {
|
||||
#ifdef DAWN_PLATFORM_APPLE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool gTestUsesWire = false;
|
||||
|
||||
void DawnTest::SetUp() {
|
||||
|
@ -180,6 +229,8 @@ void DawnTest::SetUp() {
|
|||
|
||||
// The end2end tests should never cause validation errors. These should be tested in unittests.
|
||||
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
|
||||
|
||||
mPCIInfo = dawn_native::GetPCIInfo(backendDevice);
|
||||
}
|
||||
|
||||
void DawnTest::TearDown() {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "dawn/dawncpp.h"
|
||||
#include "dawn_native/DawnNative.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <memory>
|
||||
|
@ -64,6 +65,13 @@ enum BackendType {
|
|||
};
|
||||
std::ostream& operator<<(std::ostream& stream, BackendType backend);
|
||||
|
||||
constexpr uint32_t kVendorID_AMD = 0x1002;
|
||||
constexpr uint32_t kVendorID_ARM = 0x13B5;
|
||||
constexpr uint32_t kVendorID_ImgTec = 0x1010;
|
||||
constexpr uint32_t kVendorID_Intel = 0x8086;
|
||||
constexpr uint32_t kVendorID_Nvidia = 0x10DE;
|
||||
constexpr uint32_t kVendorID_Qualcomm = 0x5143;
|
||||
|
||||
namespace utils {
|
||||
class BackendBinding;
|
||||
class TerribleCommandBuffer;
|
||||
|
@ -90,6 +98,17 @@ class DawnTest : public ::testing::TestWithParam<BackendType> {
|
|||
bool IsOpenGL() const;
|
||||
bool IsVulkan() const;
|
||||
|
||||
bool IsAMD() const;
|
||||
bool IsARM() const;
|
||||
bool IsImgTec() const;
|
||||
bool IsIntel() const;
|
||||
bool IsNvidia() const;
|
||||
bool IsQualcomm() const;
|
||||
|
||||
bool IsWindows() const;
|
||||
bool IsLinux() const;
|
||||
bool IsMacOS() const;
|
||||
|
||||
protected:
|
||||
dawn::Device device;
|
||||
dawn::Queue queue;
|
||||
|
@ -167,6 +186,8 @@ class DawnTest : public ::testing::TestWithParam<BackendType> {
|
|||
void ResolveExpectations();
|
||||
|
||||
std::unique_ptr<utils::BackendBinding> mBinding;
|
||||
|
||||
dawn_native::PCIInfo mPCIInfo;
|
||||
};
|
||||
|
||||
// Instantiate the test once for each backend provided after the first argument. Use it like this:
|
||||
|
|
|
@ -686,6 +686,7 @@ TEST_P(BlendStateTest, ColorWriteMaskBlendingDisabled) {
|
|||
|
||||
// Test that independent blend states on render targets works
|
||||
TEST_P(BlendStateTest, IndependentBlendState) {
|
||||
DAWN_SKIP_TEST_IF(IsWindows() && IsVulkan() && IsIntel());
|
||||
|
||||
std::array<dawn::Texture, 4> renderTargets;
|
||||
std::array<dawn::TextureView, 4> renderTargetViews;
|
||||
|
|
|
@ -90,6 +90,7 @@ TEST_P(ScissorTest, LargerThanAttachment) {
|
|||
// Test setting an empty scissor rect
|
||||
TEST_P(ScissorTest, EmptyRect) {
|
||||
DAWN_SKIP_TEST_IF(IsMetal());
|
||||
DAWN_SKIP_TEST_IF(IsWindows() && IsVulkan() && IsIntel());
|
||||
|
||||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
|
||||
dawn::RenderPipeline pipeline = CreateQuadPipeline(renderPass.colorFormat);
|
||||
|
|
Loading…
Reference in New Issue