From 423d811ec8b04e8bd3b7880a22ca8a9bba536413 Mon Sep 17 00:00:00 2001 From: Andrew Richards Date: Thu, 12 Dec 2024 14:43:04 +0000 Subject: [PATCH] Updated Graphics API CMakeLists.txt for shader includes. --- DirectX11/CMakeLists.txt | 7 +------ DirectX12/CMakeLists.txt | 35 ++++++++++++++++++----------------- GLES/CMakeLists.txt | 16 ++++++++-------- OpenGL/CMakeLists.txt | 13 +++++++------ Vulkan/CMakeLists.txt | 13 ++++++------- 5 files changed, 40 insertions(+), 44 deletions(-) diff --git a/DirectX11/CMakeLists.txt b/DirectX11/CMakeLists.txt index 5e479def..6bd03833 100644 --- a/DirectX11/CMakeLists.txt +++ b/DirectX11/CMakeLists.txt @@ -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) diff --git a/DirectX12/CMakeLists.txt b/DirectX12/CMakeLists.txt index c80ec152..bf56f73d 100644 --- a/DirectX12/CMakeLists.txt +++ b/DirectX12/CMakeLists.txt @@ -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=$ @@ -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}) @@ -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) diff --git a/GLES/CMakeLists.txt b/GLES/CMakeLists.txt index e6bd3bab..49ce643b 100644 --- a/GLES/CMakeLists.txt +++ b/GLES/CMakeLists.txt @@ -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) diff --git a/OpenGL/CMakeLists.txt b/OpenGL/CMakeLists.txt index 07139560..9b097777 100644 --- a/OpenGL/CMakeLists.txt +++ b/OpenGL/CMakeLists.txt @@ -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") diff --git a/Vulkan/CMakeLists.txt b/Vulkan/CMakeLists.txt index 0a7475a7..f6c7060b 100644 --- a/Vulkan/CMakeLists.txt +++ b/Vulkan/CMakeLists.txt @@ -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=$) set(VK_DEFS ${VK_DEFS} PLATFORM_SUPPORT_VULKAN_SAMPLER_YCBCR=$) @@ -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)