diff --git a/CMakeLists.txt b/CMakeLists.txt index e8d4dbe3..302d4c2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/sunshine/platform/windows_dxgi.cpp b/sunshine/platform/windows_dxgi.cpp index 5f55981f..a755d407 100644 --- a/sunshine/platform/windows_dxgi.cpp +++ b/sunshine/platform/windows_dxgi.cpp @@ -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() { return disp; } -} \ No newline at end of file +} diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 00000000..f55c67d9 --- /dev/null +++ b/tools/CMakeLists.txt @@ -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}) \ No newline at end of file diff --git a/tools/dxgi.cpp b/tools/dxgi.cpp new file mode 100644 index 00000000..3b3f9c88 --- /dev/null +++ b/tools/dxgi.cpp @@ -0,0 +1,74 @@ +// +// Created by loki on 1/23/20. +// + +#include +#include + +#include + +#include "sunshine/utility.h" + +using namespace std::literals; +namespace dxgi { +template +void Release(T *dxgi) { + dxgi->Release(); +} + +using factory1_t = util::safe_ptr>; +using adapter_t = util::safe_ptr>; +using output_t = util::safe_ptr>; + +} + +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; +}