From 337980881abd649089dec0ea76d72814bbb22d10 Mon Sep 17 00:00:00 2001 From: "Eduardo P. Gomez" Date: Tue, 10 Oct 2023 19:14:51 -0300 Subject: [PATCH] DRM GPU logging --- CMakeLists.txt | 4 ++++ build.sh | 1 + libs/d3d9/d3d9.cpp | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ec75a35..b67e42a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ find_path(_INCLUDE_DIR find_library(_LIBRARY NAMES HINTS ${PC__LIBDIR} ${PC__LIBRARY_DIRS} ) pkg_check_modules(GTK4 REQUIRED gtk4) +pkg_check_modules(LIBDRM REQUIRED libdrm) set(_LIBRARIES ${_LIBRARY} ) set(_INCLUDE_DIRS ${_INCLUDE_DIR} ) @@ -67,6 +68,8 @@ find_package(PkgConfig REQUIRED) #dependency include_directories(${GTK4_INCLUDE_DIRS}) link_directories(${GTK4_LIBRARY_DIRS}) +include_directories(${LIBDRM_INCLUDE_DIRS}) +link_directories(${LIBDRM_LIBRARY_DIRS}) #libopendx.so: set(OPENDX_CPP libs/opendx/opendx.cpp) @@ -82,6 +85,7 @@ add_library(dsetup SHARED ${DSETUP_CPP}) #libd3d9.so: add_library(d3d9 SHARED libs/d3d9/d3d9.cpp) +target_link_libraries(d3d9 ${LIBDRM_LIBRARIES}) #dxdiag: add_executable(dxdiag tools/dxdiag/main.cpp) diff --git a/build.sh b/build.sh index 80fdf187..863ee9ab 100755 --- a/build.sh +++ b/build.sh @@ -13,6 +13,7 @@ function check_package { check_package "gcc" check_package "cmake" check_package "make" +check_package "libdrm-dev" check_package "libgtk-4-dev" # Build the project diff --git a/libs/d3d9/d3d9.cpp b/libs/d3d9/d3d9.cpp index 7c046b54..bff407a0 100644 --- a/libs/d3d9/d3d9.cpp +++ b/libs/d3d9/d3d9.cpp @@ -9,7 +9,8 @@ #include #include #include - +#include +#include IDirect3D9::IDirect3D9 (UINT SDKVersion) { #ifdef DEBUG @@ -33,6 +34,9 @@ IDirect3D9::IDirect3D9 (UINT SDKVersion) { drm_get_cap gpuType; int ioctlResult = ioctl(fd, DRM_IOCTL_GET_CAP, &gpuType); + //get device vendor id: + drmVersion* version = drmGetVersion(fd); + if (ioctlResult != 0) { std::cerr << "\033[1;31m" << "ODX ERROR: Failed to get device info" << std::endl @@ -47,7 +51,7 @@ IDirect3D9::IDirect3D9 (UINT SDKVersion) { #ifdef DEBUG std::cout << "\033[1;32m" //GREEN BOLD - << "ODX INFO: Device is " << (gpuType.value == DRM_CAP_DUMB_BUFFER ? "Software" : "Hardware") << std::endl + << "ODX INFO: Device \"" << version->name << '(' << version->desc << ' ' << version->version_minor << '.' << version->version_patchlevel << ')' << "\" is " << (gpuType.value == DRM_CAP_DUMB_BUFFER ? "Software" : "Hardware") << std::endl << "\033[0;0m" << std::endl; #endif