Skip to content

Commit 973e4fa

Browse files
committed
merge master functions.hlsl fixes, resolve conflicts
2 parents 107ca80 + 4f98026 commit 973e4fa

File tree

16 files changed

+390
-194
lines changed

16 files changed

+390
-194
lines changed

CMakeLists.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,64 @@ option(NBL_BUILD_BULLET "Enable Bullet Physics building and integration?" OFF)
193193
option(NBL_BUILD_DOCS "Enable building documentation?" OFF) # No one has doxygen installed, plus we dont know when was the last time we generated working doxy and we'll use SphinX in the future
194194
option(NBL_ENABLE_PROJECT_JSON_CONFIG_VALIDATION "" ON)
195195
option(NBL_EMBED_BUILTIN_RESOURCES "Embed built-in resources?" ON)
196+
option(NBL_ENABLE_DOCKER_INTEGRATION "Enables docker integration, if client is not found Docker Desktop will be installed" OFF)
197+
198+
if (NBL_ENABLE_DOCKER_INTEGRATION)
199+
if (NOT CMAKE_HOST_WIN32)
200+
message(FATAL_ERROR "NBL_ENABLE_DOCKER_INTEGRATION works only with Windows host machines. Please disable this option")
201+
endif()
202+
203+
find_program(DOCKER_EXECUTABLE docker REQUIRED)
204+
205+
if (DOCKER_EXECUTABLE)
206+
message(STATUS "Found docker executable: ${DOCKER_EXECUTABLE}")
207+
else()
208+
execute_process(COMMAND powershell -Command "& {
209+
Invoke-WebRequest -Uri https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe -OutFile DockerDesktopInstaller.exe;
210+
$exitCode = Start-Process -Wait -FilePath .\\DockerDesktopInstaller.exe -ArgumentList 'install','--quiet','--accept-license','--backend=wsl-2','--always-run-service';
211+
Remove-Item -Force DockerDesktopInstaller.exe;
212+
exit $exitCode;
213+
}" RESULT_VARIABLE DOCKER_INSTALLER_EXIT_CODE)
214+
215+
if (DOCKER_INSTALLER_EXIT_CODE NOT EQUAL 0)
216+
message(FATAL_ERROR "Docker installer exited with non-zero return code")
217+
endif()
218+
endif()
219+
220+
message(STATUS "Docker endpoint healty check..")
221+
set(DDT_MAX_ATTEMPTS 10)
222+
set(DDT_DOCKER_RESPONDING False)
223+
foreach(ATTEMPT RANGE 1 ${DDT_MAX_ATTEMPTS})
224+
message(STATUS "Attempt ${ATTEMPT} of ${DDT_MAX_ATTEMPTS}: Checking Docker Endpoint")
225+
NBL_DOCKER(info)
226+
227+
if (DOCKER_EXIT_CODE EQUAL 0)
228+
set(DDT_DOCKER_RESPONDING True)
229+
message(STATUS "Docker endpoint detected, the engine is running.")
230+
message(STATUS "${DOCKER_OUTPUT_VAR}")
231+
break()
232+
endif()
233+
234+
NBL_WAIT_FOR(5)
235+
endforeach()
236+
237+
if (NOT DDT_DOCKER_RESPONDING)
238+
message(FATAL_ERROR "Docker Daemon is not responding. Please make sure it's running in the background!")
239+
endif()
240+
241+
set(DNT_NETWORK_NAME "docker_default")
242+
NBL_DOCKER(network inspect ${DNT_NETWORK_NAME})
243+
if (NOT DOCKER_EXIT_CODE EQUAL 0)
244+
message(STATUS "Default docker network doesn't exist, creating \"${DNT_NETWORK_NAME}\" network..")
245+
NBL_DOCKER(network create -d nat ${DNT_NETWORK_NAME})
246+
247+
if (NOT DOCKER_EXIT_CODE EQUAL 0)
248+
message(STATUS "Could not create default docker \"${DNT_NETWORK_NAME}\" network!")
249+
endif()
250+
endif()
251+
252+
message(STATUS "Default docker network: \"${DNT_NETWORK_NAME}\"")
253+
endif()
196254

197255
set(THIRD_PARTY_SOURCE_DIR "${PROJECT_SOURCE_DIR}/3rdparty")
198256
set(THIRD_PARTY_BINARY_DIR "${PROJECT_BINARY_DIR}/3rdparty")

cmake/common.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,4 +1334,16 @@ macro(NBL_TARGET_FORCE_ASSEMBLER_EXECUTABLE _NBL_TARGET_ _NBL_ASM_DIALECT_ _NBL_
13341334
TARGET_DIRECTORY "${_NBL_TARGET_}"
13351335
PROPERTIES LANGUAGE "${_NBL_ASM_DIALECT_}"
13361336
)
1337+
endmacro()
1338+
1339+
macro(NBL_WAIT_FOR SLEEP_DURATION)
1340+
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${SLEEP_DURATION})
1341+
endmacro()
1342+
1343+
# helper macro for calling docker, takes args as a list of strings
1344+
macro(NBL_DOCKER)
1345+
execute_process(COMMAND ${DOCKER_EXECUTABLE} ${ARGN}
1346+
RESULT_VARIABLE DOCKER_EXIT_CODE
1347+
OUTPUT_VARIABLE DOCKER_OUTPUT_VAR
1348+
)
13371349
endmacro()

cmake/submodules/update.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ execute_process(COMMAND "${GIT_EXECUTABLE}" ${NBL_CONFIG_SETUP_CMD} submodule up
139139

140140
# tests
141141
NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./tests FALSE "")
142+
143+
# docker
144+
NBL_WRAPPER_COMMAND_EXCLUSIVE("" ./docker FALSE "")
142145
endmacro()
143146

144147
NBL_IMPL_INIT_COMMON_SUBMODULES()

include/nbl/builtin/hlsl/bxdf/fresnel.hlsl

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,19 @@ bool getOrientedEtas(NBL_REF_ARG(T) orientedEta, NBL_REF_ARG(T) rcpOrientedEta,
5555
return impl::orientedEtas<T>::__call(orientedEta, rcpOrientedEta, NdotI, eta);
5656
}
5757

58-
}
59-
6058

61-
template <typename T NBL_FUNC_REQUIRES(vector_traits<T>::Dimensions == 3)
62-
T reflect(NBL_CONST_REF_ARG(T) I, NBL_CONST_REF_ARG(T) N, typename vector_traits<T>::scalar_type NdotI)
59+
template <typename T NBL_FUNC_REQUIRES(concepts::Vectorial<T>)
60+
T reflect(T I, T N, typename vector_traits<T>::scalar_type NdotI)
6361
{
6462
return N * 2.0f * NdotI - I;
6563
}
6664

67-
template <typename T NBL_FUNC_REQUIRES(vector_traits<T>::Dimensions == 3)
68-
T reflect(NBL_CONST_REF_ARG(T) I, NBL_CONST_REF_ARG(T) N)
69-
{
70-
typename vector_traits<T>::scalar_type NdotI = nbl::hlsl::dot<T>(N, I);
71-
return reflect<T>(I, N, NdotI);
72-
}
73-
7465
template<typename T NBL_PRIMARY_REQUIRES(vector_traits<T>::Dimensions == 3)
7566
struct refract
7667
{
77-
using this_t = refract;
78-
using scalar_type = typename vector_traits<T>::scalar_type;
68+
using this_t = refract<T>;
7969
using vector_type = T;
70+
using scalar_type = typename vector_traits<T>::scalar_type;
8071

8172
static this_t create(NBL_CONST_REF_ARG(vector_type) I, NBL_CONST_REF_ARG(vector_type) N, bool backside, scalar_type NdotI, scalar_type NdotI2, scalar_type rcpOrientedEta, scalar_type rcpOrientedEta2)
8273
{
@@ -97,7 +88,7 @@ struct refract
9788
retval.I = I;
9889
retval.N = N;
9990
T orientedEta;
100-
retval.backside = bxdf::getOrientedEtas<scalar_type>(orientedEta, retval.rcpOrientedEta, NdotI, eta);
91+
retval.backside = getOrientedEtas<scalar_type>(orientedEta, retval.rcpOrientedEta, NdotI, eta);
10192
retval.NdotI = NdotI;
10293
retval.NdotI2 = NdotI * NdotI;
10394
retval.rcpOrientedEta2 = retval.rcpOrientedEta * retval.rcpOrientedEta;
@@ -109,9 +100,9 @@ struct refract
109100
this_t retval;
110101
retval.I = I;
111102
retval.N = N;
112-
retval.NdotI = nbl::hlsl::dot<vector_type>(N, I);
103+
retval.NdotI = dot<vector_type>(N, I);
113104
scalar_type orientedEta;
114-
retval.backside = bxdf::getOrientedEtas<scalar_type>(orientedEta, retval.rcpOrientedEta, retval.NdotI, eta);
105+
retval.backside = getOrientedEtas<scalar_type>(orientedEta, retval.rcpOrientedEta, retval.NdotI, eta);
115106
retval.NdotI2 = retval.NdotI * retval.NdotI;
116107
retval.rcpOrientedEta2 = retval.rcpOrientedEta * retval.rcpOrientedEta;
117108
return retval;
@@ -120,7 +111,7 @@ struct refract
120111
static scalar_type computeNdotT(bool backside, scalar_type NdotI2, scalar_type rcpOrientedEta2)
121112
{
122113
scalar_type NdotT2 = rcpOrientedEta2 * NdotI2 + 1.0 - rcpOrientedEta2;
123-
scalar_type absNdotT = nbl::hlsl::sqrt<scalar_type>(NdotT2);
114+
scalar_type absNdotT = sqrt<scalar_type>(NdotT2);
124115
return backside ? absNdotT : -(absNdotT);
125116
}
126117

@@ -143,12 +134,14 @@ struct refract
143134
vector_type I;
144135
vector_type N;
145136
bool backside;
146-
T NdotI;
147-
T NdotI2;
148-
T rcpOrientedEta;
149-
T rcpOrientedEta2;
137+
scalar_type NdotI;
138+
scalar_type NdotI2;
139+
scalar_type rcpOrientedEta;
140+
scalar_type rcpOrientedEta2;
150141
};
151142

143+
}
144+
152145
}
153146
}
154147

include/nbl/builtin/hlsl/cpp_compat/impl/intrinsics_impl.hlsl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ namespace hlsl
2323
namespace cpp_compat_intrinsics_impl
2424
{
2525

26+
template<typename UnsignedInteger NBL_FUNC_REQUIRES(hlsl::is_integral_v<UnsignedInteger>&& hlsl::is_unsigned_v<UnsignedInteger>)
27+
inline bool isnan_uint_impl(UnsignedInteger val)
28+
{
29+
using AsFloat = typename float_of_size<sizeof(UnsignedInteger)>::type;
30+
NBL_CONSTEXPR UnsignedInteger Mask = (UnsignedInteger(0) - 1) >> 1;
31+
UnsignedInteger absVal = val & Mask;
32+
return absVal > (ieee754::traits<AsFloat>::specialValueExp << ieee754::traits<AsFloat>::mantissaBitCnt);
33+
}
34+
35+
template<typename UnsignedInteger NBL_FUNC_REQUIRES(hlsl::is_integral_v<UnsignedInteger>&& hlsl::is_unsigned_v<UnsignedInteger>)
36+
inline bool isinf_uint_impl(UnsignedInteger val)
37+
{
38+
using AsFloat = typename float_of_size<sizeof(UnsignedInteger)>::type;
39+
return (val & (~ieee754::traits<AsFloat>::signMask)) == ieee754::traits<AsFloat>::inf;
40+
}
41+
2642
template<typename T NBL_STRUCT_CONSTRAINABLE>
2743
struct dot_helper;
2844
template<typename T NBL_STRUCT_CONSTRAINABLE>
@@ -252,22 +268,6 @@ struct cross_helper<T NBL_PARTIAL_REQ_BOT(concepts::FloatingPointVector<T> && (v
252268

253269
#else // C++ only specializations
254270

255-
template<typename UnsignedInteger NBL_FUNC_REQUIRES(hlsl::is_integral_v<UnsignedInteger>&& hlsl::is_unsigned_v<UnsignedInteger>)
256-
inline bool isnan_uint_impl(UnsignedInteger val)
257-
{
258-
using AsFloat = typename float_of_size<sizeof(UnsignedInteger)>::type;
259-
constexpr UnsignedInteger Mask = (static_cast<UnsignedInteger>(0) - 1) >> 1;
260-
UnsignedInteger absVal = val & Mask;
261-
return absVal > (ieee754::traits<AsFloat>::specialValueExp << ieee754::traits<AsFloat>::mantissaBitCnt);
262-
}
263-
264-
template<typename UnsignedInteger NBL_FUNC_REQUIRES(hlsl::is_integral_v<UnsignedInteger>&& hlsl::is_unsigned_v<UnsignedInteger>)
265-
inline bool isinf_uint_impl(UnsignedInteger val)
266-
{
267-
using AsFloat = typename float_of_size<sizeof(UnsignedInteger)>::type;
268-
return (val & (~ieee754::traits<AsFloat>::signMask)) == ieee754::traits<AsFloat>::inf;
269-
}
270-
271271
#define DECL_ARG(r,data,i,_T) BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(i,0)) const _T arg##i
272272
#define WRAP(r,data,i,_T) BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(i,0)) _T
273273
#define ARG(r,data,i,_T) BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(i,0)) arg##i
@@ -659,8 +659,8 @@ struct clamp_helper<T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT) >
659659
};
660660

661661
template<typename T>
662-
NBL_PARTIAL_REQ_TOP(VECTOR_SPECIALIZATION_CONCEPT && concepts::FloatingPointLikeVectorial<T> && (vector_traits<T>::Dimension == 3))
663-
struct cross_helper<T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT && concepts::FloatingPointLikeVectorial<T> && (vector_traits<T>::Dimension == 3)) >
662+
NBL_PARTIAL_REQ_TOP(VECTOR_SPECIALIZATION_CONCEPT && concepts::Vectorial<T> && (vector_traits<T>::Dimension == 3))
663+
struct cross_helper<T NBL_PARTIAL_REQ_BOT(VECTOR_SPECIALIZATION_CONCEPT && concepts::Vectorial<T> && (vector_traits<T>::Dimension == 3)) >
664664
{
665665
static T __call(NBL_CONST_REF_ARG(T) lhs, NBL_CONST_REF_ARG(T) rhs)
666666
{

include/nbl/builtin/hlsl/emulated/float64_t.hlsl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ namespace hlsl
9797
{
9898
if(!FastMath)
9999
{
100-
const bool isRhsInf = tgmath_impl::isinf_uint_impl(rhs.data);
101-
if (tgmath_impl::isinf_uint_impl(data))
100+
const bool isRhsInf = cpp_compat_intrinsics_impl::isinf_uint_impl(rhs.data);
101+
if (cpp_compat_intrinsics_impl::isinf_uint_impl(data))
102102
{
103103
if (isRhsInf && ((data ^ rhs.data) & ieee754::traits<float64_t>::signMask))
104104
return bit_cast<this_t>(ieee754::traits<float64_t>::quietNaN | ieee754::traits<float64_t>::signMask);
@@ -116,7 +116,7 @@ namespace hlsl
116116

117117
if(!FastMath)
118118
{
119-
if (tgmath_impl::isinf_uint_impl(data))
119+
if (cpp_compat_intrinsics_impl::isinf_uint_impl(data))
120120
return bit_cast<this_t>(ieee754::traits<float64_t>::inf | ieee754::extractSignPreserveBitPattern(max(data, rhs.data)));
121121
}
122122

@@ -226,9 +226,9 @@ namespace hlsl
226226
uint64_t sign = (data ^ rhs.data) & ieee754::traits<float64_t>::signMask;
227227
if (!FastMath)
228228
{
229-
if (tgmath_impl::isnan_uint_impl(data) || tgmath_impl::isnan_uint_impl(rhs.data))
229+
if (cpp_compat_intrinsics_impl::isnan_uint_impl(data) || cpp_compat_intrinsics_impl::isnan_uint_impl(rhs.data))
230230
return bit_cast<this_t>(ieee754::traits<float64_t>::quietNaN | sign);
231-
if (tgmath_impl::isinf_uint_impl(data) || tgmath_impl::isinf_uint_impl(rhs.data))
231+
if (cpp_compat_intrinsics_impl::isinf_uint_impl(data) || cpp_compat_intrinsics_impl::isinf_uint_impl(rhs.data))
232232
return bit_cast<this_t>(ieee754::traits<float64_t>::inf | sign);
233233
if (emulated_float64_t_impl::isZero(data) || emulated_float64_t_impl::isZero(rhs.data))
234234
return bit_cast<this_t>(sign);
@@ -289,17 +289,17 @@ namespace hlsl
289289

290290
if(!FastMath)
291291
{
292-
if (tgmath_impl::isnan_uint_impl<uint64_t>(data) || tgmath_impl::isnan_uint_impl<uint64_t>(rhs.data))
292+
if (cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(data) || cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(rhs.data))
293293
return bit_cast<this_t>(ieee754::traits<float64_t>::quietNaN);
294294
if (emulated_float64_t_impl::areBothZero(data, rhs.data))
295295
return bit_cast<this_t>(ieee754::traits<float64_t>::quietNaN | sign);
296296
if (emulated_float64_t_impl::isZero(rhs.data))
297297
return bit_cast<this_t>(ieee754::traits<float64_t>::inf | sign);
298298
if (emulated_float64_t_impl::areBothInfinity(data, rhs.data))
299299
return bit_cast<this_t>(ieee754::traits<float64_t>::quietNaN | ieee754::traits<float64_t>::signMask);
300-
if (tgmath_impl::isinf_uint_impl(data))
300+
if (cpp_compat_intrinsics_impl::isinf_uint_impl(data))
301301
return bit_cast<this_t>(ieee754::traits<float64_t>::inf | sign);
302-
if (tgmath_impl::isinf_uint_impl(rhs.data))
302+
if (cpp_compat_intrinsics_impl::isinf_uint_impl(rhs.data))
303303
return bit_cast<this_t>(sign);
304304
}
305305

@@ -346,7 +346,7 @@ namespace hlsl
346346
{
347347
if (!FastMath)
348348
{
349-
if (tgmath_impl::isnan_uint_impl<uint64_t>(data) || tgmath_impl::isnan_uint_impl<uint64_t>(rhs.data))
349+
if (cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(data) || cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(rhs.data))
350350
return false;
351351
if (emulated_float64_t_impl::areBothZero(data, rhs.data))
352352
return true;
@@ -356,7 +356,7 @@ namespace hlsl
356356
}
357357
bool operator!=(this_t rhs) NBL_CONST_MEMBER_FUNC
358358
{
359-
if (!FastMath && (tgmath_impl::isnan_uint_impl<uint64_t>(data) || tgmath_impl::isnan_uint_impl<uint64_t>(rhs.data)))
359+
if (!FastMath && (cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(data) || cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(rhs.data)))
360360
return false;
361361

362362
return !(bit_cast<this_t>(data) == rhs);
@@ -371,14 +371,14 @@ namespace hlsl
371371
}
372372
bool operator<=(this_t rhs) NBL_CONST_MEMBER_FUNC
373373
{
374-
if (!FastMath && (tgmath_impl::isnan_uint_impl<uint64_t>(data) || tgmath_impl::isnan_uint_impl<uint64_t>(rhs.data)))
374+
if (!FastMath && (cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(data) || cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(rhs.data)))
375375
return false;
376376

377377
return !(bit_cast<this_t>(data) > bit_cast<this_t>(rhs.data));
378378
}
379379
bool operator>=(this_t rhs)
380380
{
381-
if (!FastMath && (tgmath_impl::isnan_uint_impl<uint64_t>(data) || tgmath_impl::isnan_uint_impl<uint64_t>(rhs.data)))
381+
if (!FastMath && (cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(data) || cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(rhs.data)))
382382
return false;
383383

384384
return !(bit_cast<this_t>(data) < bit_cast<this_t>(rhs.data));
@@ -498,7 +498,7 @@ struct static_cast_helper<To,emulated_float64_t<FastMath,FlushDenormToZero>,void
498498
return bit_cast<To>(ieee754::traits<ToAsFloat>::inf);
499499
if (exponent < ieee754::traits<ToAsFloat>::exponentMin)
500500
return bit_cast<To>(-ieee754::traits<ToAsFloat>::inf);
501-
if (tgmath_impl::isnan_uint_impl(v.data))
501+
if (cpp_compat_intrinsics_impl::isinf_uint_impl(v.data))
502502
return bit_cast<To>(ieee754::traits<ToAsFloat>::quietNaN);
503503
}
504504

include/nbl/builtin/hlsl/emulated/float64_t_impl.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ NBL_CONSTEXPR_INLINE_FUNC bool operatorLessAndGreaterCommonImplementation(uint64
171171
{
172172
if (!FastMath)
173173
{
174-
if (tgmath_impl::isnan_uint_impl<uint64_t>(lhs) || tgmath_impl::isnan_uint_impl<uint64_t>(rhs))
174+
if (cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(lhs) || cpp_compat_intrinsics_impl::isnan_uint_impl<uint64_t>(rhs))
175175
return false;
176176
if (emulated_float64_t_impl::areBothZero(lhs, rhs))
177177
return false;

0 commit comments

Comments
 (0)