Skip to content

Commit 409e498

Browse files
committed
Resolved conflicts
2 parents b273bdb + 9254e55 commit 409e498

File tree

18 files changed

+1131
-54
lines changed

18 files changed

+1131
-54
lines changed

3rdparty/dxc/dxc

Submodule dxc updated 62 files

include/nbl/builtin/hlsl/bit.hlsl

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
#include <bit>
88

99
namespace nbl::hlsl
10-
{
11-
12-
NBL_ALIAS_TEMPLATE_FUNCTION(std::rotl, rotl);
13-
NBL_ALIAS_TEMPLATE_FUNCTION(std::rotr, rotr);
14-
10+
{
11+
12+
NBL_ALIAS_TEMPLATE_FUNCTION(std::rotl, rotl);
13+
NBL_ALIAS_TEMPLATE_FUNCTION(std::rotr, rotr);
14+
NBL_ALIAS_TEMPLATE_FUNCTION(std::countl_zero, countl_zero);
15+
1516
}
1617
#else
1718
namespace nbl
1819
{
19-
namespace hlsl
20+
namespace hlsl
2021
{
2122

2223
template<typename T, typename S>
@@ -36,7 +37,7 @@ T rotl(T x, S s)
3637
}
3738
else
3839
{
39-
return (x >> (-r)) | (x << (N - (-r)));
40+
return (x >> (-r)) | (x << (N - (-r)));
4041
}
4142
}
4243

@@ -52,11 +53,28 @@ T rotr(T x, S s)
5253
}
5354
else
5455
{
55-
return (x << (-r)) | (x >> (N - (-r)));
56+
return (x << (-r)) | (x >> (N - (-r)));
5657
}
5758
}
5859

59-
}
60+
template<typename T>
61+
uint16_t countl_zero(T n)
62+
{
63+
uint16_t result = 0u;
64+
for(uint32_t bits_log2 = 6u; bits_log2 >= 0u; bits_log2--)
65+
{
66+
const uint16_t shift = bits_log2 ? uint16_t(1)<<(bits_log2-1) : 0;
67+
const uint64_t loMask = bits_log2 ? (1ull<<shift)-1 : 0;
68+
const bool chooseHigh = n&(loMask<<shift);
69+
n = uint16_t((chooseHigh ? (n>shift):n)&loMask);
70+
71+
result += uint16_t(chooseHigh ? 0ull : shift);
72+
}
73+
74+
return result;
75+
}
76+
77+
}
6078
}
6179
#endif
6280

include/nbl/builtin/hlsl/colorspace/EOTF.hlsl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//#include <nbl/builtin/hlsl/common.hlsl>
1010
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
1111
#include <nbl/builtin/hlsl/cpp_compat/promote.hlsl>
12-
#include <nbl/builtin/hlsl/cpp_compat/type_traits.hlsl>
12+
#include <nbl/builtin/hlsl/type_traits.hlsl>
1313

1414
namespace nbl
1515
{
@@ -27,9 +27,9 @@ T identity(NBL_CONST_REF_ARG(T) nonlinear)
2727
}
2828

2929
template<typename T>
30-
T impl_shared_2_4(NBL_CONST_REF_ARG(T) nonlinear, typename scalar_type<T>::type vertex)
30+
T impl_shared_2_4(NBL_CONST_REF_ARG(T) nonlinear, typename type_traits::scalar_type<T>::type vertex)
3131
{
32-
typedef typename scalar_type<T>::type Val_t;
32+
typedef typename type_traits::scalar_type<T>::type Val_t;
3333
bool3 right = (nonlinear > promote<T, Val_t>(vertex));
3434
return lerp(nonlinear / Val_t(12.92), pow((nonlinear + promote<T, Val_t>(0.055)) / Val_t(1.055), promote<T, Val_t>(2.4)), right);
3535
}
@@ -38,7 +38,7 @@ T impl_shared_2_4(NBL_CONST_REF_ARG(T) nonlinear, typename scalar_type<T>::type
3838
template<typename T>
3939
T sRGB(NBL_CONST_REF_ARG(T) nonlinear)
4040
{
41-
typedef typename scalar_type<T>::type Val_t;
41+
typedef typename type_traits::scalar_type<T>::type Val_t;
4242
bool3 negatif = (nonlinear < promote<T, Val_t>(0.0));
4343
T absVal = impl_shared_2_4<T>(abs(nonlinear), 0.04045);
4444
return lerp(absVal, -absVal, negatif);
@@ -48,21 +48,21 @@ T sRGB(NBL_CONST_REF_ARG(T) nonlinear)
4848
template<typename T>
4949
T Display_P3(NBL_CONST_REF_ARG(T) nonlinear)
5050
{
51-
typedef typename scalar_type<T>::type Val_t;
51+
typedef typename type_traits::scalar_type<T>::type Val_t;
5252
return impl_shared_2_4<T>(nonlinear, 0.039000312);
5353
}
5454

5555
template<typename T>
5656
T DCI_P3_XYZ(NBL_CONST_REF_ARG(T) nonlinear)
5757
{
58-
typedef typename scalar_type<T>::type Val_t;
58+
typedef typename type_traits::scalar_type<T>::type Val_t;
5959
return pow(nonlinear * Val_t(52.37), promote<T, Val_t>(2.6));
6060
}
6161

6262
template<typename T>
6363
T SMPTE_170M(NBL_CONST_REF_ARG(T) nonlinear)
6464
{
65-
typedef typename scalar_type<T>::type Val_t;
65+
typedef typename type_traits::scalar_type<T>::type Val_t;
6666
// ITU specs (and the outlier BT.2020) give different constants for these, but they introduce discontinuities in the mapping
6767
// because HDR swapchains often employ the RGBA16_SFLOAT format, this would become apparent because its higher precision than 8,10,12 bits
6868
Val_t alpha = 1.099296826809443; // 1.099 for all ITU but the BT.2020 12 bit encoding, 1.0993 otherwise
@@ -73,7 +73,7 @@ T SMPTE_170M(NBL_CONST_REF_ARG(T) nonlinear)
7373
template<typename T>
7474
T SMPTE_ST2084(NBL_CONST_REF_ARG(T) nonlinear)
7575
{
76-
typedef typename scalar_type<T>::type Val_t;
76+
typedef typename type_traits::scalar_type<T>::type Val_t;
7777
const T invm2 = promote<T, Val_t>(1.0 / 78.84375);
7878
T _common = pow(invm2, invm2);
7979

@@ -89,7 +89,7 @@ T SMPTE_ST2084(NBL_CONST_REF_ARG(T) nonlinear)
8989
template<typename T>
9090
T HDR10_HLG(NBL_CONST_REF_ARG(T) nonlinear)
9191
{
92-
typedef typename scalar_type<T>::type Val_t;
92+
typedef typename type_traits::scalar_type<T>::type Val_t;
9393
// done with log2 so constants are different
9494
const Val_t a = 0.1239574303172;
9595
const T b = promote<T, Val_t>(0.02372241);
@@ -101,21 +101,21 @@ T HDR10_HLG(NBL_CONST_REF_ARG(T) nonlinear)
101101
template<typename T>
102102
T AdobeRGB(NBL_CONST_REF_ARG(T) nonlinear)
103103
{
104-
typedef typename scalar_type<T>::type Val_t;
104+
typedef typename type_traits::scalar_type<T>::type Val_t;
105105
return pow(nonlinear, promote<T, Val_t>(2.19921875));
106106
}
107107

108108
template<typename T>
109109
T Gamma_2_2(NBL_CONST_REF_ARG(T) nonlinear)
110110
{
111-
typedef typename scalar_type<T>::type Val_t;
111+
typedef typename type_traits::scalar_type<T>::type Val_t;
112112
return pow(nonlinear, promote<T, Val_t>(2.2));
113113
}
114114

115115
template<typename T>
116116
T ACEScc(NBL_CONST_REF_ARG(T) nonlinear)
117117
{
118-
typedef typename scalar_type<T>::type Val_t;
118+
typedef typename type_traits::scalar_type<T>::type Val_t;
119119
bool3 right = (nonlinear >= promote<T, Val_t>(-0.301369863));
120120
T _common = exp2(nonlinear * Val_t(17.52) - promote<T, Val_t>(9.72));
121121
return max(lerp(_common * Val_t(2.0) - promote<T, Val_t>(0.000030517578125), _common, right), promote<T, Val_t>(65504.0));
@@ -124,7 +124,7 @@ T ACEScc(NBL_CONST_REF_ARG(T) nonlinear)
124124
template<typename T>
125125
T ACEScct(NBL_CONST_REF_ARG(T) nonlinear)
126126
{
127-
typedef typename scalar_type<T>::type Val_t;
127+
typedef typename type_traits::scalar_type<T>::type Val_t;
128128
bool3 right = (nonlinear >= promote<T, Val_t>(0.155251141552511));
129129
return max(lerp((nonlinear - promote<T, Val_t>(0.0729055341958355)) / Val_t(10.5402377416545), exp2(nonlinear * Val_t(17.52) - promote<T, Val_t>(9.72)), right), promote<T, Val_t>(65504.0));
130130
}

include/nbl/builtin/hlsl/colorspace/OETF.hlsl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//#include <nbl/builtin/hlsl/common.hlsl>
1010
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
1111
#include <nbl/builtin/hlsl/cpp_compat/promote.hlsl>
12-
#include <nbl/builtin/hlsl/cpp_compat/type_traits.hlsl>
12+
#include <nbl/builtin/hlsl/type_traits.hlsl>
1313

1414
namespace nbl
1515
{
@@ -27,9 +27,9 @@ T identity(NBL_CONST_REF_ARG(T) _linear)
2727
}
2828

2929
template<typename T>
30-
T impl_shared_2_4(NBL_CONST_REF_ARG(T) _linear, typename scalar_type<T>::type vertex)
30+
T impl_shared_2_4(NBL_CONST_REF_ARG(T) _linear, typename type_traits::scalar_type<T>::type vertex)
3131
{
32-
typedef typename scalar_type<T>::type Val_t;
32+
typedef typename type_traits::scalar_type<T>::type Val_t;
3333
bool3 right = (_linear > promote<T, Val_t>(vertex));
3434
return lerp(_linear * Val_t(12.92), pow(_linear, promote<T, Val_t>(1.0 / 2.4)) * Val_t(1.055) - (Val_t(0.055)), right);
3535
}
@@ -38,7 +38,7 @@ T impl_shared_2_4(NBL_CONST_REF_ARG(T) _linear, typename scalar_type<T>::type ve
3838
template<typename T>
3939
T sRGB(NBL_CONST_REF_ARG(T) _linear)
4040
{
41-
typedef typename scalar_type<T>::type Val_t;
41+
typedef typename type_traits::scalar_type<T>::type Val_t;
4242
bool3 negatif = (_linear < promote<T, Val_t>(0.0));
4343
T absVal = impl_shared_2_4<T>(abs(_linear), 0.0031308);
4444
return lerp(absVal, -absVal, negatif);
@@ -54,14 +54,14 @@ T Display_P3(NBL_CONST_REF_ARG(T) _linear)
5454
template<typename T>
5555
T DCI_P3_XYZ(NBL_CONST_REF_ARG(T) _linear)
5656
{
57-
typedef typename scalar_type<T>::type Val_t;
57+
typedef typename type_traits::scalar_type<T>::type Val_t;
5858
return pow(_linear / Val_t(52.37), promote<T, Val_t>(1.0 / 2.6));
5959
}
6060

6161
template<typename T>
6262
T SMPTE_170M(NBL_CONST_REF_ARG(T) _linear)
6363
{
64-
typedef typename scalar_type<T>::type Val_t;
64+
typedef typename type_traits::scalar_type<T>::type Val_t;
6565
// ITU specs (and the outlier BT.2020) give different constants for these, but they introduce discontinuities in the mapping
6666
// because HDR swapchains often employ the RGBA16_SFLOAT format, this would become apparent because its higher precision than 8,10,12 bits
6767
const Val_t alpha = 1.099296826809443; // 1.099 for all ITU but the BT.2020 12 bit encoding, 1.0993 otherwise
@@ -72,7 +72,7 @@ T SMPTE_170M(NBL_CONST_REF_ARG(T) _linear)
7272
template<typename T>
7373
T SMPTE_ST2084(NBL_CONST_REF_ARG(T) _linear)
7474
{
75-
typedef typename scalar_type<T>::type Val_t;
75+
typedef typename type_traits::scalar_type<T>::type Val_t;
7676
const T m1 = promote<T, Val_t>(0.1593017578125);
7777
const T m2 = promote<T, Val_t>(78.84375);
7878
const Val_t c2 = 18.8515625;
@@ -87,7 +87,7 @@ T SMPTE_ST2084(NBL_CONST_REF_ARG(T) _linear)
8787
template<typename T>
8888
T HDR10_HLG(NBL_CONST_REF_ARG(T) _linear)
8989
{
90-
typedef typename scalar_type<T>::type Val_t;
90+
typedef typename type_traits::scalar_type<T>::type Val_t;
9191

9292
// done with log2 so constants are different
9393
const Val_t a = 0.1239574303172;
@@ -100,21 +100,21 @@ T HDR10_HLG(NBL_CONST_REF_ARG(T) _linear)
100100
template<typename T>
101101
T AdobeRGB(NBL_CONST_REF_ARG(T) _linear)
102102
{
103-
typedef typename scalar_type<T>::type Val_t;
103+
typedef typename type_traits::scalar_type<T>::type Val_t;
104104
return pow(_linear, promote<T, Val_t>(1.0 / 2.19921875));
105105
}
106106

107107
template<typename T>
108108
T Gamma_2_2(NBL_CONST_REF_ARG(T) _linear)
109109
{
110-
typedef typename scalar_type<T>::type Val_t;
110+
typedef typename type_traits::scalar_type<T>::type Val_t;
111111
return pow(_linear, promote<T, Val_t>(1.0 / 2.2));
112112
}
113113

114114
template<typename T>
115115
T ACEScc(NBL_CONST_REF_ARG(T) _linear)
116116
{
117-
typedef typename scalar_type<T>::type Val_t;
117+
typedef typename type_traits::scalar_type<T>::type Val_t;
118118
bool3 mid = (_linear >= promote<T, Val_t>(0.0));
119119
bool3 right = (_linear >= promote<T, Val_t>(0.000030517578125));
120120
return (log2(lerp(promote<T, Val_t>(0.0000152587890625), promote<T, Val_t>(0.0), right) + _linear * lerp(promote<T, Val_t>(0.0), lerp(promote<T, Val_t>(0.5), promote<T, Val_t>(1.0), right), mid)) + promote<T, Val_t>(9.72)) / Val_t(17.52);
@@ -123,7 +123,7 @@ T ACEScc(NBL_CONST_REF_ARG(T) _linear)
123123
template<typename T>
124124
T ACEScct(NBL_CONST_REF_ARG(T) _linear)
125125
{
126-
typedef typename scalar_type<T>::type Val_t;
126+
typedef typename type_traits::scalar_type<T>::type Val_t;
127127
bool3 right = (_linear > promote<T, Val_t>(0.0078125));
128128
return lerp(Val_t(10.5402377416545) * _linear + Val_t(0.0729055341958355), (log2(_linear) + promote<T, Val_t>(9.72)) / Val_t(17.52), right);
129129
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (C) 2023 - DevSH Graphics Programming Sp. z O.O.
2+
// This file is part of the "Nabla Engine".
3+
// For conditions of distribution and use, see copyright notice in nabla.h
4+
#ifndef _NBL_BUILTIN_HLSL_GLSL_COMPAT_CORE_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_GLSL_COMPAT_CORE_INCLUDED_
6+
7+
#include "nbl/builtin/hlsl/cpp_compat.hlsl"
8+
#include "nbl/builtin/hlsl/spirv_intrinsics/core.hlsl"
9+
10+
namespace nbl
11+
{
12+
namespace hlsl
13+
{
14+
namespace glsl
15+
{
16+
17+
template<typename T>
18+
T atomicAdd(NBL_REF_ARG(T) ptr, T value)
19+
{
20+
return spirv::atomicAdd<T>(ptr, 1, 0, value);
21+
}
22+
template<typename T>
23+
T atomicAnd(NBL_REF_ARG(T) ptr, T value)
24+
{
25+
return spirv::atomicAnd<T>(ptr, 1, 0, value);
26+
}
27+
template<typename T>
28+
T atomicOr(NBL_REF_ARG(T) ptr, T value)
29+
{
30+
return spirv::atomicOr<T>(ptr, 1, 0, value);
31+
}
32+
template<typename T>
33+
T atomicXor(NBL_REF_ARG(T) ptr, T value)
34+
{
35+
return spirv::atomicXor<T>(ptr, 1, 0, value);
36+
}
37+
template<typename T>
38+
T atomicMin(NBL_REF_ARG(T) ptr, T value)
39+
{
40+
return spirv::atomicMin<T>(ptr, 1, 0, value);
41+
}
42+
template<typename T>
43+
T atomicMax(NBL_REF_ARG(T) ptr, T value)
44+
{
45+
return spirv::atomicMax<T>(ptr, 1, 0, value);
46+
}
47+
template<typename T>
48+
T atomicExchange(NBL_REF_ARG(T) ptr, T value)
49+
{
50+
return spirv::atomicExchange<T>(ptr, 1, 0, value);
51+
}
52+
template<typename T>
53+
T atomicCompSwap(NBL_REF_ARG(T) ptr, T comparator, T value)
54+
{
55+
return spirv::atomicCompSwap<T>(ptr, 1, 0, 0, value, comparator);
56+
}
57+
58+
void barrier() {
59+
spirv::controlBarrier(2, 2, 0x8 | 0x100);
60+
}
61+
62+
void memoryBarrierShared() {
63+
spirv::memoryBarrier(1, 0x8 | 0x100);
64+
}
65+
66+
}
67+
}
68+
}
69+
70+
#endif

0 commit comments

Comments
 (0)