Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/gfx/dx12/src/gfx_dx12.cpp
2022-03-04 19:17:07 -05:00

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";
}