@@ -580,7 +580,11 @@ if(_NBL_COMPILE_WITH_GLI_)
580
580
endif ()
581
581
582
582
# DXC
583
- add_dependencies (Nabla dxc )
583
+ if (_NBL_ENABLE_DXC_COMPILE_TESTS_ )
584
+ add_dependencies (Nabla HLSL_NABLA_COMPILE_TEST )
585
+ else ()
586
+ add_dependencies (Nabla dxc )
587
+ endif ()
584
588
target_include_directories (Nabla PRIVATE
585
589
"${DXC_BINARY_DIR_GE} /tools/clang/tools/dxcompiler"
586
590
"${DXC_SOURCE_DIR} /tools/clang/tools/dxcompiler"
@@ -594,118 +598,6 @@ target_include_directories(Nabla PRIVATE
594
598
)
595
599
target_link_libraries (Nabla INTERFACE "${DXC_DXCOMPILER_LIB} " )
596
600
597
- ############################################################################
598
- # list files you want to compile with DXC in _NBL_ENABLE_DXC_COMPILE_TESTS_
599
- # once we have guarantee all of shaders in Nabla can be compiled with DXC,
600
- # we can simply grep all of those files/use existing vars holding paths to
601
- # shaders and remove manual adding the files bellow
602
- ###################################################
603
-
604
- if (_NBL_ENABLE_DXC_COMPILE_TESTS_ )
605
- set (_NBL_DXC_CT_INCLUDE_ROOT_ "${NBL_ROOT_PATH} /include" ) # Nabla include root path for shaders
606
- set (_NBL_DXC_CT_BINARY_BIN_ "${CMAKE_CURRENT_BINARY_DIR} /DXC/CT" ) # compile-test directory
607
-
608
- if (_NBL_DXC_COMPILE_TESTS_ENABLE_CMAKE_LOG_ )
609
- message ("${_NBL_DXC_CT_PREFIX_CMAKE_LOG_DEBUG_} _NBL_DXC_CT_INCLUDE_ROOT_ = '${_NBL_DXC_CT_INCLUDE_ROOT_} '" )
610
- message ("${_NBL_DXC_CT_PREFIX_CMAKE_LOG_DEBUG_} _NBL_DXC_CT_BINARY_BIN_ = '${_NBL_DXC_CT_BINARY_BIN_} '" )
611
- endif ()
612
-
613
- # this is how you add file for compilation test
614
- set (_NBL_DXC_CT_SHADER_FILES_
615
- "${_NBL_DXC_CT_INCLUDE_ROOT_} /nbl/builtin/hlsl/barycentric/utils.hlsl"
616
- )
617
-
618
- foreach (_SHADER_FILE_PATH_ IN LISTS _NBL_DXC_CT_SHADER_FILES_ )
619
- if (_NBL_DXC_COMPILE_TESTS_ENABLE_CMAKE_LOG_ )
620
- message ("${_NBL_DXC_CT_PREFIX_CMAKE_LOG_DEBUG_} adding _SHADER_FILE_PATH_ = '${_SHADER_FILE_PATH_} ' as INPUT of DXC CT target" )
621
- endif ()
622
-
623
- cmake_path (RELATIVE_PATH _SHADER_FILE_PATH_ BASE_DIRECTORY "${_NBL_DXC_CT_INCLUDE_ROOT_} " OUTPUT_VARIABLE _SHADER_NEW_RELATIVE_FILE_PATH_ )
624
- cmake_path (GET _SHADER_NEW_RELATIVE_FILE_PATH_ STEM LAST_ONLY _SHADER_NEW_STEAM_ )
625
- cmake_path (REMOVE_EXTENSION _SHADER_NEW_RELATIVE_FILE_PATH_ LAST_ONLY OUTPUT_VARIABLE _SHADER_NEW_RELATIVE_OUTPUT_DIR_ )
626
-
627
- set (_NBL_DXC_CT_CURRENT_OUTPUT_BIN_DIR_ "${_NBL_DXC_CT_BINARY_BIN_} /${_SHADER_NEW_RELATIVE_OUTPUT_DIR_} /bin" )
628
- set (_NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_ "${_NBL_DXC_CT_CURRENT_OUTPUT_BIN_DIR_} /${_SHADER_NEW_STEAM_} .bin" )
629
-
630
- # MSVC and other generators have "SetEnv" task - we need to make sure our enviroment is clean while invoking DXC compilation
631
- string (APPEND _TMP_CLEAN_ENV_ "set PATH=$ENV{PATH} \n set CAExcludePath=\n set LIB=\n set LIBPATH=\n set INCLUDE=\n set EXTERNAL_INCLUDE=\n " )
632
-
633
- # include-dependency input file chain
634
- set (_NBL_DXC_CT_CURRENT_DEPENDS_FILEPATH_ "${_NBL_DXC_CT_CURRENT_OUTPUT_BIN_DIR_} /depends.txt" )
635
- set (_NBL_DXC_CT_CURRENT_IDC_FILEPATH_ "${_NBL_DXC_CT_CURRENT_OUTPUT_BIN_DIR_} /depends.cmd" )
636
- string (APPEND _NBL_DXC_CT_WRAPPER_IDC_COMMAND_ "${_TMP_CLEAN_ENV_} \" ${DXC_EXECUTABLE} \" -HV 2021 -T lib_6_7 -I\" ${_NBL_DXC_CT_INCLUDE_ROOT_} \" -Zi -MF \" ${_NBL_DXC_CT_CURRENT_DEPENDS_FILEPATH_} \" \" ${_SHADER_FILE_PATH_} \" " )
637
- file (WRITE "${_NBL_DXC_CT_CURRENT_IDC_FILEPATH_} " "${_NBL_DXC_CT_WRAPPER_IDC_COMMAND_} " )
638
-
639
- # create a file contating paths to all input file's dependencies scanned recursively
640
- if (_NBL_DXC_COMPILE_TESTS_ENABLE_CMAKE_LOG_ )
641
- execute_process (COMMAND "${_NBL_DXC_CT_CURRENT_IDC_FILEPATH_} " )
642
- else ()
643
- execute_process (COMMAND "${_NBL_DXC_CT_CURRENT_IDC_FILEPATH_} "
644
- OUTPUT_QUIET
645
- ERROR_QUIET
646
- )
647
- endif ()
648
-
649
- file (READ "${_NBL_DXC_CT_CURRENT_DEPENDS_FILEPATH_} " _NBL_DXC_CT_DEPENDENCIES_ )
650
- unset (_NBL_DXC_CT_WRAPPER_IDC_COMMAND_ )
651
-
652
- # filter DXC output MF's file dependencies and put them into CMake list
653
- string (REPLACE ": " ";" _NBL_DXC_CT_DEPENDENCIES_S_ "${_NBL_DXC_CT_DEPENDENCIES_} " )
654
- string (REPLACE " \\ " ";" _NBL_DXC_CT_DEPENDENCIES_S_ "${_NBL_DXC_CT_DEPENDENCIES_S_} " )
655
- string (REPLACE "\r " "" _NBL_DXC_CT_DEPENDENCIES_S_ "${_NBL_DXC_CT_DEPENDENCIES_S_} " )
656
- string (REPLACE "\n " "" _NBL_DXC_CT_DEPENDENCIES_S_ "${_NBL_DXC_CT_DEPENDENCIES_S_} " )
657
- string (STRIP "${_NBL_DXC_CT_DEPENDENCIES_S_} " _NBL_DXC_CT_DEPENDENCIES_S_ )
658
- list (APPEND _NBL_DXC_CT_DEPENDENCIES_L_ "${_NBL_DXC_CT_DEPENDENCIES_S_} " )
659
- list (TRANSFORM _NBL_DXC_CT_DEPENDENCIES_L_ STRIP )
660
- list (REMOVE_DUPLICATES _NBL_DXC_CT_DEPENDENCIES_L_ )
661
-
662
- set (_NBL_DXC_CT_CURRENT_DEPS_LIST_ ${_NBL_DXC_CT_DEPENDENCIES_L_} )
663
- unset (_NBL_DXC_CT_DEPENDENCIES_ )
664
- unset (_NBL_DXC_CT_DEPENDENCIES_S_ )
665
- unset (_NBL_DXC_CT_DEPENDENCIES_L_ )
666
-
667
- # compile command
668
- string (APPEND _NBL_DXC_CT_WRAPPER_COMPILE_COMMAND_ "${_TMP_CLEAN_ENV_} \" ${DXC_EXECUTABLE} \" -HV 2021 -T lib_6_7 -I\" ${_NBL_DXC_CT_INCLUDE_ROOT_} \" -Zi -Fo \" ${_NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_} \" \" ${_SHADER_FILE_PATH_} \" " )
669
- set (_NBL_DXC_CT_CURRENT_SHADER_COMPILE_FILEPATH_ "${_NBL_DXC_CT_CURRENT_OUTPUT_BIN_DIR_} /compile.cmd" )
670
- file (WRITE "${_NBL_DXC_CT_CURRENT_SHADER_COMPILE_FILEPATH_} " "${_NBL_DXC_CT_WRAPPER_COMPILE_COMMAND_} " )
671
-
672
- unset (_NBL_DXC_CT_WRAPPER_COMPILE_COMMAND_ )
673
- unset (_TMP_CLEAN_ENV_ )
674
-
675
- if (_NBL_DXC_COMPILE_TESTS_ENABLE_CMAKE_LOG_ )
676
- message ("${_NBL_DXC_CT_PREFIX_CMAKE_LOG_DEBUG_} adding _NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_ = '${_NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_} ' as OUTPUT of DXC CT target" )
677
- endif ()
678
-
679
- list (APPEND _NBL_DXC_CT_BIN_OUTPUTS_ "${_NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_} " )
680
-
681
- # create custom command per input file with it's all dependencies listed as DEPENDS
682
- add_custom_command (
683
- OUTPUT "${_NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_} "
684
- COMMAND "${_NBL_DXC_CT_CURRENT_SHADER_COMPILE_FILEPATH_} "
685
- DEPENDS ${_NBL_DXC_CT_CURRENT_DEPS_LIST_}
686
- WORKING_DIRECTORY "${_NBL_DXC_CT_CURRENT_OUTPUT_BIN_DIR_} "
687
- USES_TERMINAL
688
- VERBATIM
689
- )
690
-
691
- unset (_NBL_DXC_CT_CURRENT_OUTPUT_FILEPATH_ )
692
- unset (_NBL_DXC_CT_CURRENT_SHADER_COMPILE_FILEPATH_ )
693
- unset (_NBL_DXC_CT_CURRENT_DEPS_LIST_ )
694
- endforeach ()
695
-
696
- # create custom targets for which DEPENDS are all of input files for DXC compile test
697
- add_custom_target (HLSL_NABLA_COMPILE_TEST DEPENDS ${_NBL_DXC_CT_BIN_OUTPUTS_}
698
- COMMENT "${CMAKE_COMMAND} " -E echo "Launching Nabla HLSL compile test..."
699
- )
700
-
701
- add_dependencies (HLSL_NABLA_COMPILE_TEST dxc )
702
-
703
- unset (_NBL_DXC_CT_BIN_OUTPUTS_ )
704
- unset (_NBL_DXC_CT_BINARY_BIN_ )
705
- unset (_NBL_DXC_CT_SHADER_FILES_ )
706
- unset (_NBL_DXC_CT_INCLUDE_ROOT_ )
707
- endif ()
708
-
709
601
# Linux Display Systems
710
602
if (UNIX AND NOT ANDROID AND NOT APPLE )
711
603
target_include_directories (Nabla PUBLIC
0 commit comments