Skip to content

Commit 6077a62

Browse files
committed
Merge branch 'dtm'
# Conflicts: # examples_tests
2 parents 5bbf887 + a6791b4 commit 6077a62

File tree

7 files changed

+123
-101
lines changed

7 files changed

+123
-101
lines changed

include/nbl/builtin/hlsl/algorithm.hlsl

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#define _NBL_BUILTIN_HLSL_ALGORITHM_INCLUDED_
66

77
#include "nbl/builtin/hlsl/functional.hlsl"
8+
#include "nbl/builtin/hlsl/math/intutil.hlsl"
89

910
namespace nbl
1011
{
@@ -91,16 +92,10 @@ NBL_CONSTEXPR_INLINE_FUNC void swap(NBL_REF_ARG(T) lhs, NBL_REF_ARG(T) rhs)
9192
namespace impl
9293
{
9394

94-
// TODO: move this to some other header
95-
bool isNPoT(const uint x)
96-
{
97-
return x&(x-1);
98-
}
99-
10095
template<class Accessor, class Comparator>
10196
struct bound_t
10297
{
103-
static bound_t<Accessor,Comparator> setup(uint begin, const uint end, const typename Accessor::value_type _value, const Comparator _comp)
98+
static bound_t<Accessor,Comparator> setup(uint32_t begin, const uint32_t end, const typename Accessor::value_type _value, const Comparator _comp)
10499
{
105100
bound_t<Accessor,Comparator> retval;
106101
retval.comp = _comp;
@@ -111,12 +106,12 @@ struct bound_t
111106
}
112107

113108

114-
uint operator()(NBL_REF_ARG(Accessor) accessor)
109+
uint32_t operator()(NBL_REF_ARG(Accessor) accessor)
115110
{
116111
if (isNPoT(len))
117112
{
118-
const uint newLen = 0x1u<<firstbithigh(len);
119-
const uint testPoint = it+(len-newLen);
113+
const uint32_t newLen = 0x1u<<nbl::hlsl::findMSB(len);
114+
const uint32_t testPoint = it+(len-newLen);
120115
len = newLen;
121116
comp_step(accessor,testPoint);
122117
}
@@ -133,24 +128,24 @@ struct bound_t
133128
void iteration(NBL_REF_ARG(Accessor) accessor)
134129
{
135130
len >>= 1;
136-
const uint mid = it+len;
131+
const uint32_t mid = it+len;
137132
comp_step(accessor,mid);
138133
}
139134

140-
void comp_step(NBL_REF_ARG(Accessor) accessor, const uint testPoint, const uint rightBegin)
135+
void comp_step(NBL_REF_ARG(Accessor) accessor, const uint32_t testPoint, const uint32_t rightBegin)
141136
{
142137
if (comp(accessor[testPoint],value))
143138
it = rightBegin;
144139
}
145-
void comp_step(NBL_REF_ARG(Accessor) accessor, const uint testPoint)
140+
void comp_step(NBL_REF_ARG(Accessor) accessor, const uint32_t testPoint)
146141
{
147142
comp_step(accessor,testPoint,testPoint);
148143
}
149144

150145
Comparator comp;
151146
typename Accessor::value_type value;
152-
uint it;
153-
uint len;
147+
uint32_t it;
148+
uint32_t len;
154149
};
155150

156151
template<class Accessor, class Comparator>
@@ -168,14 +163,14 @@ struct lower_to_upper_comparator_transform_t
168163

169164

170165
template<class Accessor, class Comparator>
171-
uint lower_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint end, const typename Accessor::value_type value, const Comparator comp)
166+
uint32_t lower_bound(NBL_REF_ARG(Accessor) accessor, const uint32_t begin, const uint32_t end, const typename Accessor::value_type value, const Comparator comp)
172167
{
173168
impl::bound_t<Accessor,Comparator> implementation = impl::bound_t<Accessor,Comparator>::setup(begin,end,value,comp);
174169
return implementation(accessor);
175170
}
176171

177172
template<class Accessor, class Comparator>
178-
uint upper_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint end, const typename Accessor::value_type value, const Comparator comp)
173+
uint32_t upper_bound(NBL_REF_ARG(Accessor) accessor, const uint32_t begin, const uint32_t end, const typename Accessor::value_type value, const Comparator comp)
179174
{
180175
//using TransformedComparator = impl::lower_to_upper_comparator_transform_t<Accessor,Comparator>;
181176
//TransformedComparator transformedComparator;
@@ -191,7 +186,7 @@ namespace impl
191186

192187
// extra indirection due to https://github.com/microsoft/DirectXShaderCompiler/issues/4771
193188
template<class Accessor, typename T>
194-
uint lower_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint end, const T value)
189+
uint32_t lower_bound(NBL_REF_ARG(Accessor) accessor, const uint32_t begin, const uint32_t end, const T value)
195190
{
196191
//using Comparator = nbl::hlsl::less<T>;
197192
//Comparator comp;
@@ -200,7 +195,7 @@ uint lower_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint en
200195
return nbl::hlsl::lower_bound<Accessor, nbl::hlsl::less<T> >(accessor,begin,end,value,comp);
201196
}
202197
template<class Accessor, typename T>
203-
uint upper_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint end, const T value)
198+
uint32_t upper_bound(NBL_REF_ARG(Accessor) accessor, const uint32_t begin, const uint32_t end, const T value)
204199
{
205200
//using Comparator = nbl::hlsl::less<T>;
206201
//Comparator comp;
@@ -212,12 +207,12 @@ uint upper_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint en
212207
}
213208

214209
template<class Accessor>
215-
uint lower_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint end, const typename Accessor::value_type value)
210+
uint32_t lower_bound(NBL_REF_ARG(Accessor) accessor, const uint32_t begin, const uint32_t end, const typename Accessor::value_type value)
216211
{
217212
return impl::lower_bound<Accessor,typename Accessor::value_type>(accessor,begin,end,value);
218213
}
219214
template<class Accessor>
220-
uint upper_bound(NBL_REF_ARG(Accessor) accessor, const uint begin, const uint end, const typename Accessor::value_type value)
215+
uint32_t upper_bound(NBL_REF_ARG(Accessor) accessor, const uint32_t begin, const uint32_t end, const typename Accessor::value_type value)
221216
{
222217
return impl::upper_bound<Accessor,typename Accessor::value_type>(accessor,begin,end,value);
223218
}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,20 @@ namespace hlsl
154154
if ((data | ieee754::traits<float64_t>::signMask) == (rhs.data | ieee754::traits<float64_t>::signMask))
155155
return _static_cast<this_t>(0ull);
156156

157-
uint64_t rhsNormMantissaHigh = shiftAmount >= 64 ? 0ull : rhsNormMantissa >> shiftAmount;
157+
uint64_t rhsNormMantissaHigh = shiftAmount >= 64u ? 0ull : rhsNormMantissa >> shiftAmount;
158158
uint64_t rhsNormMantissaLow = 0ull;
159159
if (shiftAmount < 128)
160160
{
161161
if (shiftAmount >= 64)
162+
{
162163
rhsNormMantissaLow = rhsNormMantissa >> (shiftAmount - 64);
164+
}
163165
else
164-
rhsNormMantissaLow = rhsNormMantissa << (64 - shiftAmount);
166+
{
167+
const uint32_t lowMantissaShiftAmount = 64 - shiftAmount;
168+
if(lowMantissaShiftAmount < 64)
169+
rhsNormMantissaLow = rhsNormMantissa << lowMantissaShiftAmount;
170+
}
165171
}
166172

167173
const int64_t mantissaDiff = int64_t(lhsNormMantissa) - int64_t(rhsNormMantissaHigh);
@@ -179,7 +185,7 @@ namespace hlsl
179185
}
180186
else
181187
{
182-
rhsNormMantissa >>= shiftAmount;
188+
rhsNormMantissa = shiftAmount > 63 ? 0ull : rhsNormMantissa >> shiftAmount;
183189
resultMantissa = lhsNormMantissa + rhsNormMantissa;
184190

185191
if (resultMantissa & 1ull << 53)

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ std::string CHLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
382382
);
383383

384384
// for debugging cause MSVC doesn't like to show more than 21k LoC in TextVisualizer
385-
if constexpr (true)
385+
if constexpr (false)
386386
{
387387
system::ISystem::future_t<core::smart_refctd_ptr<system::IFile>> future;
388388
m_system->createFile(future,system::path(preprocessOptions.sourceIdentifier).parent_path()/"preprocessed.hlsl",system::IFileBase::ECF_WRITE);

src/nbl/video/CVulkanConnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ core::smart_refctd_ptr<CVulkanConnection> CVulkanConnection::create(core::smart_
286286
}
287287

288288
VkDebugUtilsMessengerEXT vk_debugMessenger = VK_NULL_HANDLE;
289-
if (debugCallback)
289+
if (enabledFeatures.debugUtils && debugCallback)
290290
{
291291
if (vkCreateDebugUtilsMessengerEXT(vk_instance,&debugMessengerCreateInfo,nullptr,&vk_debugMessenger) != VK_SUCCESS)
292292
{

0 commit comments

Comments
 (0)