Enumerate devices on DX12
This commit is contained in:
parent
a039d43d2e
commit
5d7e98c4be
3 changed files with 36 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
|||
add_library(GFXDX12 STATIC src/gfx_dx12.cpp)
|
||||
target_include_directories(GFXDX12 PUBLIC include)
|
||||
target_link_libraries(GFXDX12 PUBLIC GFX)
|
||||
target_link_libraries(GFXDX12 PUBLIC GFX d3d12.lib dxgi.lib)
|
|
@ -1,7 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <dxgi1_6.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <wrl.h>
|
||||
|
||||
#include "gfx.hpp"
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
class gfx_dx12 : public GFX {
|
||||
public:
|
||||
bool is_supported() override { return true; }
|
||||
|
@ -10,4 +17,9 @@ public:
|
|||
bool initialize(const GFXCreateInfo& info) override;
|
||||
|
||||
const char* get_name() override;
|
||||
|
||||
private:
|
||||
void get_device();
|
||||
|
||||
ComPtr<ID3D12Device> device;
|
||||
};
|
||||
|
|
|
@ -6,14 +6,35 @@
|
|||
|
||||
#include <wrl.h>
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
// from https://stackoverflow.com/a/18374698
|
||||
std::string ws2s(const std::wstring& wstr) {
|
||||
using convert_typeX = std::codecvt_utf8<wchar_t>;
|
||||
std::wstring_convert<convert_typeX, wchar_t> converterX;
|
||||
|
||||
ComPtr<ID3D12Device> g_Device;
|
||||
return converterX.to_bytes(wstr);
|
||||
}
|
||||
|
||||
bool gfx_dx12::initialize(const GFXCreateInfo& info) {
|
||||
get_device();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void gfx_dx12::get_device() {
|
||||
ComPtr<IDXGIFactory4> dxgiFactory;
|
||||
UINT createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
|
||||
|
||||
CreateDXGIFactory2(createFactoryFlags, IID_PPV_ARGS(&dxgiFactory));
|
||||
|
||||
ComPtr<IDXGIAdapter1> adapter;
|
||||
for (UINT i = 0; dxgiFactory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND; i++) {
|
||||
DXGI_ADAPTER_DESC1 dxgiAdapterDesc1;
|
||||
adapter->GetDesc1(&dxgiAdapterDesc1);
|
||||
|
||||
prism::log("GPU: {}", ws2s(dxgiAdapterDesc1.Description));
|
||||
}
|
||||
}
|
||||
|
||||
const char* gfx_dx12::get_name() {
|
||||
return "DX12";
|
||||
}
|
||||
|
|
Reference in a new issue