nvpro-samples / vk_raytrace

Ray tracing glTF scene with Vulkan
Apache License 2.0
575 stars 35 forks source link

cfgmgr32.h is a windows-specific header file preventing compilation in Linux #3

Closed chrisdonlan closed 3 years ago

chrisdonlan commented 3 years ago

The cfgmgr.h is a windows-specific dependency preventing compilation on Linux.

[ 86%] Building CXX object CMakeFiles/vk_raytrace.dir/home/chris/lab/ray-tracing/shared_sources/imgui/imgui_camera_widget.cpp.o
[ 88%] Building CXX object CMakeFiles/vk_raytrace.dir/home/chris/lab/ray-tracing/shared_sources/imgui/imgui_impl_vk.cpp.o
In file included from /home/chris/lab/ray-tracing/vk_raytrace/sample_example.cpp:55:
/home/chris/lab/ray-tracing/vk_raytrace/nvml_monitor.hpp:19:10: fatal error: cfgmgr32.h: No such file or directory
   19 | #include <cfgmgr32.h>
      |          ^~~~~~~~~~~
chrisdonlan commented 3 years ago

In order to get around this, I deleted the following function entirely (there are no uses in the project):

  void* LoadNmvlLibrary()

And I commented out the content here:

  float getCpuLoad()
  {
      /*
    static uint64_t _previousTotalTicks = 0;
    static uint64_t _previousIdleTicks  = 0;

    FILETIME idleTime, kernelTime, userTime;
    GetSystemTimes(&idleTime, &kernelTime, &userTime);

    auto FileTimeToInt64 = [](const FILETIME& ft) {
      return (((uint64_t)(ft.dwHighDateTime)) << 32) | ((uint64_t)ft.dwLowDateTime);
    };

    auto totalTicks = FileTimeToInt64(kernelTime) + FileTimeToInt64(userTime);
    auto idleTicks  = FileTimeToInt64(idleTime);

    uint64_t totalTicksSinceLastTime = totalTicks - _previousTotalTicks;
    uint64_t idleTicksSinceLastTime  = idleTicks - _previousIdleTicks;

    float result = 1.0f - ((totalTicksSinceLastTime > 0) ? ((float)idleTicksSinceLastTime) / totalTicksSinceLastTime : 0);

    _previousTotalTicks = totalTicks;
    _previousIdleTicks  = idleTicks;
       */

    // return result * 100.f;
    return -1 * 100.f;
  }

The CPU function seems approachable, so I am working on a linux work-around to get the CPU load in either a cross platform manner, or a switchable manner with macros.

But, I would have no idea where to start in LoadNmvlLibrary().

mklefrancois commented 3 years ago

We should have it working under Linux. Thanks for reporting.