Skip to content

Commit

Permalink
Small fixes for building with gcc (#116)
Browse files Browse the repository at this point in the history
* Correct include file case

* Correct cast from GetProcAddr result

* Add missing include for std::list

* Make NVAPI support an option
  • Loading branch information
expipiplus1 authored Dec 19, 2024
1 parent 4abb09e commit b5e49c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(SLANG_RHI_HAS_WGPU ON)
endif()

if((SLANG_RHI_ENABLE_D3D11 OR SLANG_RHI_ENABLE_D3D12) AND (CMAKE_SYSTEM_NAME STREQUAL "Windows") AND (SLANG_RHI_ARCHITECTURE MATCHES "x86_64") AND MSVC)
set(SLANG_RHI_HAS_NVAPI ON)
endif()

# Backend options
option(SLANG_RHI_ENABLE_CPU "Enable CPU backend" ON)
cmake_dependent_option(SLANG_RHI_ENABLE_D3D11 "Enable D3D11 backend" ON "SLANG_RHI_HAS_D3D11" OFF)
Expand All @@ -73,6 +77,7 @@ cmake_dependent_option(SLANG_RHI_ENABLE_VULKAN "Enable Vulkan backend" ON "SLANG
cmake_dependent_option(SLANG_RHI_ENABLE_METAL "Enable Metal backend" ON "SLANG_RHI_HAS_METAL" OFF)
cmake_dependent_option(SLANG_RHI_ENABLE_CUDA "Enable CUDA backend" ON "SLANG_RHI_HAS_CUDA" OFF)
cmake_dependent_option(SLANG_RHI_ENABLE_WGPU "Enable WebGPU backend" ON "SLANG_RHI_HAS_WGPU" OFF)
cmake_dependent_option(SLANG_RHI_ENABLE_NVAPI "Enable NVAPI" ON "SLANG_RHI_HAS_NVAPI" OFF)
option(SLANG_RHI_FETCH_DXC "Fetch dxc (DirectX Shader Compiler)" ON)
option(SLANG_RHI_FETCH_AGILITY_SDK "Fetch Agility SDK" ON)

Expand Down Expand Up @@ -183,7 +188,7 @@ else()
endif()

# Fetch NVAPI
if((SLANG_RHI_ENABLE_D3D11 OR SLANG_RHI_ENABLE_D3D12) AND (CMAKE_SYSTEM_NAME STREQUAL "Windows") AND (SLANG_RHI_ARCHITECTURE MATCHES "x86_64"))
if(SLANG_RHI_ENABLE_NVAPI)
# NVAPI
set(NVAPI_VERSION "4ba3384657149d63aa193f5a34e20efe1e42bf31")
FetchPackage(nvapi URL "https://github.com/NVIDIA/nvapi/archive/${NVAPI_VERSION}.zip")
Expand All @@ -193,9 +198,6 @@ if((SLANG_RHI_ENABLE_D3D11 OR SLANG_RHI_ENABLE_D3D12) AND (CMAKE_SYSTEM_NAME STR
target_include_directories(slang-rhi-nvapi INTERFACE ${NVAPI_ROOT_DIR})
target_link_libraries(slang-rhi-nvapi INTERFACE ${NVAPI_ROOT_DIR}/amd64/nvapi64.lib)
target_link_libraries(slang-rhi PRIVATE slang-rhi-nvapi)
set(SLANG_RHI_ENABLE_NVAPI ON)
else()
set(SLANG_RHI_ENABLE_NVAPI OFF)
endif()

# Fetch and setup Google Dawn library (WebGPU implementation)
Expand Down
4 changes: 2 additions & 2 deletions src/core/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#if SLANG_WINDOWS_FAMILY
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <windows.h>
#elif SLANG_LINUX_FAMILY || SLANG_APPLE_FAMILY
#include <dlfcn.h>
#else
Expand Down Expand Up @@ -43,7 +43,7 @@ void unloadSharedLibrary(SharedLibraryHandle handle)
void* findSymbolAddressByName(SharedLibraryHandle handle, char const* name)
{
#if SLANG_WINDOWS_FAMILY
return GetProcAddress(static_cast<HMODULE>(handle), name);
return reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(handle), name));
#elif SLANG_LINUX_FAMILY || SLANG_APPLE_FAMILY
return dlsym(handle, name);
#else
Expand Down
1 change: 1 addition & 0 deletions src/d3d12/d3d12-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../buffer-pool.h"

#include <deque>
#include <list>

namespace rhi::d3d12 {

Expand Down

0 comments on commit b5e49c6

Please sign in to comment.