Skip to content

Commit

Permalink
Updated Graphics API CMakeLists.txt for shader includes.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRichards-Code committed Dec 12, 2024
1 parent 9c80377 commit 423d811
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 44 deletions.
7 changes: 1 addition & 6 deletions DirectX11/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@ file(GLOB SHADERS
)

file(GLOB SHADER_INCLUDES
"${SIMUL_PLATFORM_DIR}/Shaders/SL/*.sl"
"${SIMUL_PLATFORM_DIR}/DirectX11/Sfx/*.sl"
)
file(GLOB SHADER_DEFS
"${SIMUL_PLATFORM_DIR}/DirectX11/Sfx/*.json"
)

file(GLOB SHADER_DEFS
"${CMAKE_CURRENT_SOURCE_DIR}/Sfx/*.json"
)

source_group("Shaders" FILES ${SHADERS} )
source_group("Shader Includes" FILES ${SHADER_INCLUDES} )

add_static_library( SimulDirectX11 SOURCES ${SOURCES} ${HEADERS} ${SHADER_DEFS} DEFINITIONS SIMUL_DIRECTX11_DLL=1 SIMUL_WIN8_SDK=1 PLATFORM_D3D11_SFX=1 PLATFORM_TYPED_UAV_FORMATS=1 PROPERTIES FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX}
add_static_library( SimulDirectX11 SOURCES ${SOURCES} ${HEADERS} ${SHADERS} ${SHADER_INCLUDES} ${SHADER_DEFS} DEFINITIONS SIMUL_DIRECTX11_DLL=1 SIMUL_WIN8_SDK=1 PLATFORM_D3D11_SFX=1 PLATFORM_TYPED_UAV_FORMATS=1 PROPERTIES FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX}
INCLUDES "${SIMUL_PLATFORM_DIR}/External/DirectX/DirectXTex/DirectXTex" PUBLICINCLUDES "${SIMUL_PLATFORM_DIR}/DirectX11" )

if (SIMUL_DLL_SDK_LIBRARY)
Expand Down
35 changes: 18 additions & 17 deletions DirectX12/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@ file(GLOB HEADERS
"*.h" "**/*.h"
)

file(GLOB SHADER_DEFS
"${CMAKE_CURRENT_SOURCE_DIR}/Sfx/*.json"
)


file(GLOB JSON
"${CMAKE_CURRENT_SOURCE_DIR}/HLSL/*.json"
"${SIMUL_PLATFORM_DIR}/XboxOne/HLSL/*.json"
)
if(PLATFORM_SPECTRUM)
set( FOLDER "Spectrum" )
elseif(PLATFORM_XBOXONE)
set( FOLDER "XboxOne" )
else()
set( FOLDER "DirectX12" )
endif()

file(GLOB SHADERS
"${SIMUL_PLATFORM_DIR}/Shaders/Sfx/*.sfx"
"${SIMUL_PLATFORM_DIR}/${FOLDER}/Sfx/*.sfx"
)

file(GLOB SHADER_INCLUDES
"${SIMUL_PLATFORM_DIR}/Shaders/SL/*.sl"
"${SIMUL_PLATFORM_DIR}/DirectX12/HLSL/*.sl"
"${SIMUL_PLATFORM_DIR}/${FOLDER}/Sfx/*.sl"
)
file(GLOB SHADER_DEFS
"${SIMUL_PLATFORM_DIR}/${FOLDER}/Sfx/*.json"
)

source_group("NV" src FILES "**/*.cpp" "**/*.h" )
source_group("Shaders" FILES ${SHADERS} )
source_group("Shader Includes" FILES ${SHADER_INCLUDES} )

set(DX12_DEFS SIMUL_DIRECTX12_DLL=1
PLATFORM_SUPPORT_D3D12_RAYTRACING=$<BOOL:${PLATFORM_SUPPORT_D3D12_RAYTRACING}>
Expand All @@ -63,7 +65,7 @@ endif()
set(HEADERS ${HEADERS} "${SIMUL_PLATFORM_DIR}/External/D3D12MemoryAllocator/include/D3D12MemAlloc.h")
set(SOURCES ${SOURCES} "${SIMUL_PLATFORM_DIR}/External/D3D12MemoryAllocator/src/D3D12MemAlloc.cpp")

add_static_library( SimulDirectX12 SOURCES ${SOURCES} ${HEADERS} ${SHADER_DEFS} DEFINITIONS ${DX12_DEFS} PROPERTIES FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX}
add_static_library( SimulDirectX12 SOURCES ${SOURCES} ${HEADERS} ${SHADERS} ${SHADER_INCLUDES} ${SHADER_DEFS} DEFINITIONS ${DX12_DEFS} PROPERTIES FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX}
INCLUDES "${SIMUL_PLATFORM_DIR}/External/DirectX/DirectXTex/DirectXTex" PUBLICINCLUDES "${SIMUL_PLATFORM_DIR}/DirectX12")
add_dependencies(SimulDirectX12${STATIC_LINK_SUFFIX} SimulCrossPlatform${STATIC_LINK_SUFFIX})

Expand All @@ -81,16 +83,15 @@ endif()
option( PLATFORM_SUPPORT_D3D12_RAYTRACING "" OFF)
if(SIMUL_SOURCE_BUILD)
if(PLATFORM_SPECTRUM)
set( JSON_FILE "${SIMUL_PLATFORM_DIR}/Spectrum/Sfx/Spectrum.json" )
set( PLATFORM_SUPPORT_D3D12_RAYTRACING True)
elseif(PLATFORM_XBOXONE)
set( JSON_FILE "${SIMUL_PLATFORM_DIR}/XboxOne/Sfx/XboxOne.json" )
set( PLATFORM_SUPPORT_D3D12_RAYTRACING False)
else()
set( JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Sfx/DirectX12.json" )
set( PLATFORM_SUPPORT_D3D12_RAYTRACING True)
endif()

set( JSON_FILE "${SIMUL_PLATFORM_DIR}/${FOLDER}/Sfx/${FOLDER}.json" )

#Note: Due to a CMake bug, we can't include the in_RootSignature file in SOURCES, or it will be default-compiled as an hlsl shader instead of the custom command below.

option(PLATFORM_DX12_LOAD_GFX "" OFF)
Expand Down
16 changes: 8 additions & 8 deletions GLES/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ file(GLOB HEADERS
)

file(GLOB SHADERS
"${SIMUL_PLATFORM_DIR}/Shaders/Sfx/*.sfx"
"${SIMUL_PLATFORM_DIR}/GLES/Sfx/*.sfx"
)

file(GLOB SHADER_INCLUDES
"${SIMUL_PLATFORM_DIR}/Shaders/SL/*.sl"
"${SIMUL_PLATFORM_DIR}/GLES/GLSL/*.sl"
"${SIMUL_PLATFORM_DIR}/GLES/Sfx/*.sl"
)
file(GLOB SHADER_DEFS
"${SIMUL_PLATFORM_DIR}/GLES/Sfx/*.*"
)
"${SIMUL_PLATFORM_DIR}/GLES/Sfx/*.json"
)

if(SIMUL_SOURCE_BUILD)
add_static_library(SimulGLES SOURCES ${SOURCES} ${HEADERS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX} DEFINITIONS GL_GLEXT_PROTOTYPES INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../External/stb" "${PLATFORM_ANGLE_DIR}" "${PLATFORM_ANGLE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../External/glfw/include" LINK_DIRS ${PLATFORM_ANGLE_LIB_DIR}${PLATFORM_ANGLE_LIB_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../External/glfw/build_mt/lib/${CMAKE_BUILD_TYPE})
source_group("Shaders" FILES ${SHADERS} )
source_group("Shader Includes" FILES ${SHADER_INCLUDES} )

add_static_library(SimulGLES SOURCES ${SOURCES} ${HEADERS} ${SHADERS} ${SHADER_INCLUDES} ${SHADER_DEFS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX} DEFINITIONS GL_GLEXT_PROTOTYPES INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../External/stb" "${PLATFORM_ANGLE_DIR}" "${PLATFORM_ANGLE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../External/glfw/include" LINK_DIRS ${PLATFORM_ANGLE_LIB_DIR}${PLATFORM_ANGLE_LIB_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../External/glfw/build_mt/lib/${CMAKE_BUILD_TYPE})
if(SIMUL_SOURCE_BUILD)
set( JSON_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Sfx/GLES.json" )
add_dynamic_library(SimulGLES SOURCES ${SOURCES} ${HEADERS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX} LINK_DIRS ${PLATFORM_ANGLE_LIB_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../External/glfw/build_md/lib/${CMAKE_BUILD_TYPE} INCLUDES "${PLATFORM_ANGLE_DIR}" "${PLATFORM_ANGLE_DIR}/include" "${CMAKE_CURRENT_SOURCE_DIR}/../External/glfw/include" LINK SimulGLES_MD SimulCrossPlatform_MD SimulMath_MD Core_MD libGLESv2.dll.lib libEGL.dll.lib DEFINITIONS SIMUL_DYNAMIC_LINK=1 SIMUL_GLES_DLL=1 GL_GLEXT_PROTOTYPES)
add_sfx_shader_project( GLESCoreShaders ${JSON_FILE} INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/Sfx" "${CMAKE_CURRENT_SOURCE_DIR}/../Shaders/SL" SOURCES ${SHADERS} ${SHADER_INCLUDES} ${SHADER_DEFS} ${in_rs} OPTIONS -w -l OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GLES/shaderbin" INTERMEDIATE "${CMAKE_CURRENT_BINARY_DIR}/../GLES/sfx_intermediate" FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX}/Shaders)
Expand Down
13 changes: 7 additions & 6 deletions OpenGL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ file(GLOB HEADERS
)

file(GLOB SHADERS
"${SIMUL_PLATFORM_DIR}/Shaders/Sfx/*.sfx"
"${SIMUL_PLATFORM_DIR}/OpenGL/Sfx/*.sfx"
)

file(GLOB SHADER_INCLUDES
"${SIMUL_PLATFORM_DIR}/Shaders/SL/*.sl"
"${SIMUL_PLATFORM_DIR}/OpenGL/Sfx/*.sl"
)
file(GLOB SHADER_DEFS
"${SIMUL_PLATFORM_DIR}/OpenGL/Sfx/*.json"
)
"${SIMUL_PLATFORM_DIR}/OpenGL/Sfx/*.json"
)

source_group("Shaders" FILES ${SHADERS} )
source_group("Shader Includes" FILES ${SHADER_INCLUDES} )

add_static_library(SimulOpenGL SOURCES ${SOURCES} ${HEADERS} ${SHADER_DEFS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX})
add_static_library(SimulOpenGL SOURCES ${SOURCES} ${HEADERS} ${SHADERS} ${SHADER_INCLUDES} ${SHADER_DEFS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX})
if(SIMUL_SOURCE_BUILD)
target_include_directories(SimulOpenGL${STATIC_LINK_SUFFIX} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../External/stb")
target_include_directories(SimulOpenGL${STATIC_LINK_SUFFIX} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../OpenGL")
Expand Down
13 changes: 6 additions & 7 deletions Vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ file(GLOB SOURCES "*.cpp" )
file(GLOB HEADERS "*.h" )

file(GLOB SHADERS
"${SIMUL_PLATFORM_DIR}/Shaders/SFX/*.sfx"
"${SIMUL_PLATFORM_DIR}/Vulkan/Sfx/*.sfx"
)

file(GLOB SHADER_INCLUDES
"${SIMUL_PLATFORM_DIR}/Shaders/SL/*.sl"
"${SIMUL_PLATFORM_DIR}/Vulkan/Sfx/*.sl"
)

file(GLOB SHADER_DEFS
"${CMAKE_CURRENT_SOURCE_DIR}/Sfx/*.json"
"${SIMUL_PLATFORM_DIR}/Vulkan/Sfx/*.json"
)

source_group("Shaders" FILES ${SHADERS} )
source_group("Shader Includes" FILES ${SHADER_INCLUDES} )

set(VK_DEFS SIMUL_VULKAN_DLL=1 VK_PROTOTYPES)
set(VK_DEFS ${VK_DEFS} PLATFORM_SUPPORT_VULKAN_MULTIVIEW=$<BOOL:${PLATFORM_SUPPORT_VULKAN_MULTIVIEW}>)
set(VK_DEFS ${VK_DEFS} PLATFORM_SUPPORT_VULKAN_SAMPLER_YCBCR=$<BOOL:${PLATFORM_SUPPORT_VULKAN_SAMPLER_YCBCR}>)
Expand All @@ -36,8 +36,7 @@ endif()
# Add in vk_mem_alloc.h
set(HEADERS ${HEADERS} "${SIMUL_PLATFORM_DIR}/External/VulkanMemoryAllocator/include/vk_mem_alloc.h")


add_static_library( SimulVulkan SOURCES ${SOURCES} ${HEADERS} ${SHADER_DEFS} ${SHADER_INCLUDES} DEFINITIONS ${VK_DEFS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX})
add_static_library( SimulVulkan SOURCES ${SOURCES} ${HEADERS} ${SHADERS} ${SHADER_INCLUDES} ${SHADER_DEFS} DEFINITIONS ${VK_DEFS} FOLDER ${SIMUL_PLATFORM_FOLDER_PREFIX})
if(SIMUL_SOURCE_BUILD)
add_dependencies(SimulVulkan${STATIC_LINK_SUFFIX} SimulCrossPlatform${STATIC_LINK_SUFFIX})
if(PLATFORM_WINDOWS)
Expand Down

0 comments on commit 423d811

Please sign in to comment.