Created tool to display the names of the dxgi devices

This commit is contained in:
loki 2020-01-23 23:43:39 +01:00
parent 8da7739728
commit 95f90501e4
4 changed files with 92 additions and 5 deletions

View File

@ -1,7 +1,6 @@
cmake_minimum_required(VERSION 2.8)
project(Sunshine)
# set up include-directories
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
@ -12,7 +11,10 @@ find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(FFmpeg REQUIRED)
list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
if(WIN32)
add_subdirectory(tools) #This is temporary, only tools for Windows are needed, for now
list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps_windows.json")
include_directories(
ViGEmClient/include)
@ -109,8 +111,6 @@ include_directories(
${PLATFORM_INCLUDE_DIRS}
)
list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare)
string(TOUPPER "x${CMAKE_BUILD_TYPE}" BUILD_TYPE)
if("${BUILD_TYPE}" STREQUAL "XDEBUG")
list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3)

View File

@ -439,10 +439,11 @@ public:
return -1;
}
DXGI_ADAPTER_DESC adapter_desc;
adapter->GetDesc(&adapter_desc);
BOOST_LOG(info)
<< "Device Description : "sv << adapter_desc.Description << std::endl
<< "Device Vendor ID : 0x"sv << util::hex(adapter_desc.VendorId).to_string_view() << std::endl
<< "Device Device ID : 0x"sv << util::hex(adapter_desc.DeviceId).to_string_view() << std::endl
<< "Device Video Mem : "sv << adapter_desc.DedicatedVideoMemory / 1048576 << " MiB"sv << std::endl
@ -705,4 +706,4 @@ std::shared_ptr<display_t> display() {
return disp;
}
}
}

12
tools/CMakeLists.txt Normal file
View File

@ -0,0 +1,12 @@
cmake_minimum_required(VERSION 2.8)
project(sunshine_tools)
include_directories(${CMAKE_SOURCE_DIR})
add_executable(dxgi-info dxgi.cpp)
set_target_properties(dxgi-info PROPERTIES CXX_STANDARD 17)
target_link_libraries(dxgi-info
${CMAKE_THREAD_LIBS_INIT}
dxgi)
target_compile_options(dxgi-info PRIVATE ${SUNSHINE_COMPILE_OPTIONS})

74
tools/dxgi.cpp Normal file
View File

@ -0,0 +1,74 @@
//
// Created by loki on 1/23/20.
//
#include <dxgi.h>
#include <d3dcommon.h>
#include <iostream>
#include "sunshine/utility.h"
using namespace std::literals;
namespace dxgi {
template<class T>
void Release(T *dxgi) {
dxgi->Release();
}
using factory1_t = util::safe_ptr<IDXGIFactory1, Release<IDXGIFactory1>>;
using adapter_t = util::safe_ptr<IDXGIAdapter1, Release<IDXGIAdapter1>>;
using output_t = util::safe_ptr<IDXGIOutput, Release<IDXGIOutput>>;
}
int main(int argc, char *argv[]) {
HRESULT status;
dxgi::factory1_t::pointer factory_p {};
status = CreateDXGIFactory1(IID_IDXGIFactory1, (void**)&factory_p);
dxgi::factory1_t factory { factory_p };
if(FAILED(status)) {
std::cout << "Failed to create DXGIFactory1 [0x"sv << util::hex(status).to_string_view() << ']' << std::endl;
return -1;
}
dxgi::adapter_t::pointer adapter_p {};
for(int x = 0; factory->EnumAdapters1(x, &adapter_p) != DXGI_ERROR_NOT_FOUND; ++x) {
dxgi::adapter_t adapter { adapter_p };
DXGI_ADAPTER_DESC1 adapter_desc;
adapter->GetDesc1(&adapter_desc);
std::cout
<< "====== ADAPTER ====="sv << std::endl;
std::wcout
<< L"Device Name : "sv << adapter_desc.Description << std::endl;
std::cout
<< "Device Vendor ID : 0x"sv << util::hex(adapter_desc.VendorId).to_string_view() << std::endl
<< "Device Device ID : 0x"sv << util::hex(adapter_desc.DeviceId).to_string_view() << std::endl
<< "Device Video Mem : "sv << adapter_desc.DedicatedVideoMemory / 1048576 << " MiB"sv << std::endl
<< "Device Sys Mem : "sv << adapter_desc.DedicatedSystemMemory / 1048576 << " MiB"sv << std::endl
<< "Share Sys Mem : "sv << adapter_desc.SharedSystemMemory / 1048576 << " MiB"sv << std::endl << std::endl
<< " ====== OUTPUT ======"sv << std::endl;
dxgi::output_t::pointer output_p {};
for(int y = 0; adapter->EnumOutputs(y, &output_p) != DXGI_ERROR_NOT_FOUND; ++y) {
dxgi::output_t output {output_p };
DXGI_OUTPUT_DESC desc;
output->GetDesc(&desc);
auto width = desc.DesktopCoordinates.right - desc.DesktopCoordinates.left;
auto height = desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top;
std::wcout
<< L" Output Name : "sv << desc.DeviceName << std::endl;
std::cout
<< " AttachedToDesktop : "sv << (desc.AttachedToDesktop ? "yes"sv : "no"sv) << std::endl
<< " Resolution : "sv << width << 'x' << height << std::endl << std::endl;
}
}
return 0;
}