Skip to content

Commit 6a17dc8

Browse files
authored
Merge pull request #478 from Devsh-Graphics-Programming/paritially-fix-dxc
partially fix dxc
2 parents fb58be4 + b7d83a6 commit 6a17dc8

23 files changed

+100
-37
lines changed

3rdparty/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ add_subdirectory(openssl openssl EXCLUDE_FROM_ALL)
2121

2222
# DXC
2323
set(SPIRV-Headers_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dxc/dxc/external/SPIRV-Headers")
24-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
24+
if(WIN32)
25+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
26+
elseif(UNIX)
27+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math")
28+
endif()
2529
option(_NBL_ENABLE_DXC_COMPILE_TESTS_ "Enable it in order to test compilation of Nabla shaders at build time" OFF)
2630
option(_NBL_DXC_COMPILE_TESTS_ENABLE_CMAKE_LOG_ "Enable more verbose log when creating DXC compile test target - only for Nabla developers!" OFF)
2731
set(_NBL_DXC_CT_PREFIX_CMAKE_LOG_DEBUG_ "[DXC_CT]:" CACHE INTERNAL "only for Nabla developers")
@@ -48,7 +52,7 @@ endif()
4852

4953

5054
# TODO: redo
51-
find_package(Wayland) # TODO: remove, load Wayland dynamically
55+
# find_package(Wayland) # TODO: remove, load Wayland dynamically
5256

5357

5458
# zlib (target is zlibstatic)

3rdparty/dxc/CMakeLists.txt

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,24 @@ else()
6060
endif()
6161

6262
set(DXC_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/build" CACHE INTERNAL "")
63-
execute_process(COMMAND "${CMAKE_COMMAND}" -S "${CMAKE_CURRENT_SOURCE_DIR}/dxc" -B "${DXC_BUILD_DIR}" -G "${CMAKE_GENERATOR}" "-Ax64" -T "${CMAKE_GENERATOR_TOOLSET}" ${NBL_DXC_CMAKE_OPTIONS}
64-
RESULT_VARIABLE DXC_CMAKE_RESULT
65-
OUTPUT_VARIABLE DXC_CMAKE_STREAM_PIPE
66-
)
63+
64+
if(WIN32)
65+
execute_process(COMMAND "${CMAKE_COMMAND}" -C "${CMAKE_CURRENT_SOURCE_DIR}/dxc/cmake/caches/PredefinedParams.cmake" -S "${CMAKE_CURRENT_SOURCE_DIR}/dxc" -B "${DXC_BUILD_DIR}" -G "${CMAKE_GENERATOR}" "-Ax64" -T "${CMAKE_GENERATOR_TOOLSET}" ${NBL_DXC_CMAKE_OPTIONS}
66+
RESULT_VARIABLE DXC_CMAKE_RESULT
67+
OUTPUT_VARIABLE DXC_CMAKE_STREAM_PIPE
68+
)
69+
else()
70+
execute_process(COMMAND "${CMAKE_COMMAND}"
71+
-S "${CMAKE_CURRENT_SOURCE_DIR}/dxc"
72+
-C "${CMAKE_CURRENT_SOURCE_DIR}/dxc/cmake/caches/PredefinedParams.cmake"
73+
-G "${CMAKE_GENERATOR}"
74+
-T "${CMAKE_GENERATOR_TOOLSET}"
75+
-B "${DXC_BUILD_DIR}"
76+
-D "CMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
77+
RESULT_VARIABLE DXC_CMAKE_RESULT
78+
OUTPUT_VARIABLE DXC_CMAKE_STREAM_PIPE
79+
)
80+
endif()
6781

6882
if(NOT "${DXC_CMAKE_RESULT}" STREQUAL "0")
6983
message(FATAL_ERROR "${DXC_CMAKE_STREAM_PIPE}")

3rdparty/dxc/test/test.cpp

-293 Bytes
Binary file not shown.

3rdparty/pstl/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # only non-multi-generators and clang supported
1+
if(NBL_BUILD_DPL AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # only non-multi-generators and clang ifsupported
22
get_filename_component(CCBD_ABSOLUTE "${CMAKE_CURRENT_BINARY_DIR}" ABSOLUTE)
33

4+
if (NBL_BUILD_DPL)
5+
set(_NBL_BUILD_DPL_ ${NBL_BUILD_DPL})
6+
endif()
7+
48
set(TBB_INSTALL_VARS ON CACHE BOOL "" FORCE)
59
set(TBB_TEST OFF CACHE BOOL "" FORCE)
610
set(TBB_STRICT ON CACHE BOOL "" FORCE)
@@ -45,7 +49,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # only non-multi-generators and clang
4549
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/oneDPL
4650
BINARY_DIR ${ONEDPL_BUILD}
4751
CMAKE_ARGS ${CMAKE_ARGS_ONEDPL}
48-
BUILD_COMMAND cmake --build ${ONEDPL_BUILD} --target build-all
52+
BUILD_COMMAND cmake --build ${ONEDPL_BUILD}
4953
INSTALL_COMMAND cmake --install ${ONEDPL_BUILD} --prefix ${ONEDPL_INSTALL_DIR}
5054
USES_TERMINAL_BUILD 1
5155
COMMENT "Building oneDPL..."

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ include(ExternalProject)
1212
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchains/android/build.cmake)
1313

1414
project(Nabla LANGUAGES CXX C)
15+
enable_language(C CXX ASM)
1516

1617
option(NBL_STATIC_BUILD "" ON) # ON for static builds, OFF for shared
1718
option(NBL_DYNAMIC_MSVC_RUNTIME "" OFF)
@@ -260,6 +261,8 @@ endif()
260261
#uncomment in the future
261262
#option(NBL_TARGET_ARCH_ARM "Build for ARM?" OFF)
262263

264+
option(NBL_BUILD_DPL "Enable DPL (Dynamic Parallelism Library)" OFF)
265+
263266
option(NBL_PCH "Enable pre-compiled header" ON)
264267

265268
option(NBL_FAST_MATH "Enable fast low-precision math" ON)

include/nbl/asset/utils/CCompilerSet.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ namespace nbl::asset
1515
{
1616
public:
1717
CCompilerSet(core::smart_refctd_ptr<system::ISystem>&& sys)
18-
: m_HLSLCompiler(core::make_smart_refctd_ptr<CHLSLCompiler>(core::smart_refctd_ptr(sys)))
19-
, m_GLSLCompiler(core::make_smart_refctd_ptr<CGLSLCompiler>(core::smart_refctd_ptr(sys)))
18+
:
19+
#ifdef _NBL_PLATFORM_WINDOWS_
20+
m_HLSLCompiler(core::make_smart_refctd_ptr<CHLSLCompiler>(core::smart_refctd_ptr(sys))),
21+
#endif
22+
m_GLSLCompiler(core::make_smart_refctd_ptr<CGLSLCompiler>(core::smart_refctd_ptr(sys)))
2023
{}
2124

2225
core::smart_refctd_ptr<ICPUShader> compileToSPIRV(const asset::ICPUShader* shader, const IShaderCompiler::SCompilerOptions& options) const;
@@ -25,16 +28,24 @@ namespace nbl::asset
2528

2629
inline core::smart_refctd_ptr<IShaderCompiler> getShaderCompiler(IShader::E_CONTENT_TYPE contentType) const
2730
{
28-
if (contentType == IShader::E_CONTENT_TYPE::ECT_HLSL)
31+
32+
if (contentType == IShader::E_CONTENT_TYPE::ECT_HLSL) {
33+
34+
#ifdef _NBL_PLATFORM_WINDOWS_
2935
return m_HLSLCompiler;
36+
#endif
37+
}
3038
else if (contentType == IShader::E_CONTENT_TYPE::ECT_GLSL)
3139
return m_GLSLCompiler;
3240
else
3341
return nullptr;
3442
}
3543

3644
protected:
45+
46+
#ifdef _NBL_PLATFORM_WINDOWS_
3747
core::smart_refctd_ptr<CHLSLCompiler> m_HLSLCompiler = nullptr;
48+
#endif
3849
core::smart_refctd_ptr<CGLSLCompiler> m_GLSLCompiler = nullptr;
3950
};
4051
}

include/nbl/asset/utils/CHLSLCompiler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "nbl/asset/utils/ISPIRVOptimizer.h"
99
#include "nbl/asset/utils/IShaderCompiler.h"
1010

11+
#ifdef _NBL_PLATFORM_WINDOWS_
12+
1113
namespace nbl::asset::hlsl::impl
1214
{
1315
class DXC;
@@ -66,4 +68,6 @@ class NBL_API2 CHLSLCompiler final : public IShaderCompiler
6668

6769
}
6870

71+
#endif
72+
6973
#endif

include/nbl/config/BuildConfigOptions.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
#cmakedefine __NBL_FAST_MATH
6464
#cmakedefine _NBL_EMBED_BUILTIN_RESOURCES_
6565

66+
#cmakedefine _NBL_BUILD_DPL_
67+
6668
// TODO: This has to disapppear from the main header and go to the OptiX extension header + config
6769
#cmakedefine OPTIX_INCLUDE_DIR "@OPTIX_INCLUDE_DIR@"
6870

include/nbl/core/execution.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#ifndef _NBL_CORE_EXECUTION_H_INCLUDED_
66
#define _NBL_CORE_EXECUTION_H_INCLUDED_
77

8-
#if !defined (__clang__)
8+
#if __has_include (<execution>)
99
#include <execution>
1010
#include <algorithm>
1111
#else
@@ -26,7 +26,7 @@ inline auto highLevelF(Args&&... args) -> decltype(lowLevelF(std::forward<Args>(
2626

2727
namespace nbl::core
2828
{
29-
#if !defined (__clang__)
29+
#if __has_include(<execution>)
3030
namespace execution = std::execution;
3131

3232
ALIAS_TEMPLATE_FUNCTION(for_each_n, std::for_each_n)

include/nbl/core/string/StringLiteral.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef _NBL_CORE_STRING_LITERAL_H_INCLUDED_
55
#define _NBL_CORE_STRING_LITERAL_H_INCLUDED_
66

7+
#include <algorithm>
8+
79
namespace nbl::core
810
{
911

0 commit comments

Comments
 (0)