41 lines
1,018 B
C++
Executable file
41 lines
1,018 B
C++
Executable file
#include "gfx_dx12.hpp"
|
|
|
|
#include <d3d12.h>
|
|
#include <dxgi1_6.h>
|
|
#include <d3dcompiler.h>
|
|
|
|
#include <wrl.h>
|
|
#include <codecvt>
|
|
|
|
// 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;
|
|
|
|
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";
|
|
}
|