7
7
#define STATIC_ASSERT(C) { nbl::hlsl::conditional<C, int, void>::type a = 0; }
8
8
9
9
#define IS_SAME(L,R) nbl::hlsl::is_same<L,R>::value
10
- #define SHADER_CRASHING_ASSERT(expr) \
11
- { \
12
- bool con = (expr); \
13
- do { \
14
- [branch] if (!con) \
15
- vk::RawBufferStore<uint32_t>(0xdeadbeefBADC0FFbull,0x45u,4u); \
16
- } while(!con); \
17
- }
18
10
19
11
#include <nbl/builtin/hlsl/cmath.hlsl>
20
12
@@ -145,10 +137,10 @@ void main(uint3 invocationID : SV_DispatchThreadID)
145
137
// uint32_t rotrResult0 = nbl::hlsl::mpl::rotr<uint32_t, 2u, 1>::value;
146
138
// uint32_t rotrResult1 = nbl::hlsl::mpl::rotr<uint32_t, 2u, -1>::value;
147
139
148
- // SHADER_CRASHING_ASSERT (rotlResult0 == mplRotlResult0);
149
- // SHADER_CRASHING_ASSERT (rotlResult1 == mplRotlResult1);
150
- // SHADER_CRASHING_ASSERT (rotrResult0 == mplRotrResult0);
151
- // SHADER_CRASHING_ASSERT (rotrResult1 == mplRotrResult1);
140
+ // assert (rotlResult0 == mplRotlResult0);
141
+ // assert (rotlResult1 == mplRotlResult1);
142
+ // assert (rotrResult0 == mplRotrResult0);
143
+ // assert (rotrResult1 == mplRotrResult1);
152
144
153
145
// TODO: more tests and compare with cpp version as well
154
146
fill(invocationID, 5);
@@ -165,27 +157,27 @@ void main(uint3 invocationID : SV_DispatchThreadID)
165
157
uint16_t compileTimeCountLZero = nbl::hlsl::mpl::countl_zero<uint16_t, TEST_VALUE_0>::value;
166
158
uint16_t runTimeCountLZero = nbl::hlsl::countl_zero(TEST_VALUE_0);
167
159
fill(invocationID, float4(5.1, compileTimeCountLZero, runTimeCountLZero, 0));
168
- SHADER_CRASHING_ASSERT (compileTimeCountLZero == runTimeCountLZero);
160
+ assert (compileTimeCountLZero == runTimeCountLZero);
169
161
170
162
compileTimeCountLZero = nbl::hlsl::mpl::countl_zero<uint32_t, TEST_VALUE_1>::value;
171
163
runTimeCountLZero = nbl::hlsl::countl_zero(TEST_VALUE_1);
172
164
fill(invocationID, float4(5.2, compileTimeCountLZero, runTimeCountLZero, 0));
173
- SHADER_CRASHING_ASSERT (compileTimeCountLZero == runTimeCountLZero);
165
+ assert (compileTimeCountLZero == runTimeCountLZero);
174
166
175
167
compileTimeCountLZero = nbl::hlsl::mpl::countl_zero<uint32_t, TEST_VALUE_2>::value;
176
168
runTimeCountLZero = nbl::hlsl::countl_zero(TEST_VALUE_2);
177
169
fill(invocationID, float4(5.3, compileTimeCountLZero, runTimeCountLZero, 0));
178
- SHADER_CRASHING_ASSERT (compileTimeCountLZero == runTimeCountLZero);
170
+ assert (compileTimeCountLZero == runTimeCountLZero);
179
171
180
172
compileTimeCountLZero = nbl::hlsl::mpl::countl_zero<uint32_t, TEST_VALUE_3>::value;
181
173
runTimeCountLZero = nbl::hlsl::countl_zero(TEST_VALUE_3);
182
174
fill(invocationID, float4(5.4, compileTimeCountLZero, runTimeCountLZero, 0));
183
- SHADER_CRASHING_ASSERT (compileTimeCountLZero == runTimeCountLZero);
175
+ assert (compileTimeCountLZero == runTimeCountLZero);
184
176
185
177
compileTimeCountLZero = nbl::hlsl::mpl::countl_zero<uint32_t, TEST_VALUE_4>::value;
186
178
runTimeCountLZero = nbl::hlsl::countl_zero(TEST_VALUE_4);
187
179
fill(invocationID, float4(5.5, compileTimeCountLZero, runTimeCountLZero, 0));
188
- SHADER_CRASHING_ASSERT (compileTimeCountLZero == runTimeCountLZero);
180
+ assert (compileTimeCountLZero == runTimeCountLZero);
189
181
}
190
182
191
183
{
@@ -201,7 +193,7 @@ void main(uint3 invocationID : SV_DispatchThreadID)
201
193
{
202
194
float4 v;
203
195
fill(invocationID, float4(alignof(v.x), alignof(v), 0, 0));
204
- SHADER_CRASHING_ASSERT (alignof(v.x) == alignof(v));
196
+ assert (alignof(v.x) == alignof(v));
205
197
}
206
198
207
199
{
@@ -266,7 +258,7 @@ void main(uint3 invocationID : SV_DispatchThreadID)
266
258
decltype(fn(__VA_ARGS__)) lhs = nbl::hlsl::fn(__VA_ARGS__); \
267
259
decltype(lhs) rhs = fn(__VA_ARGS__); \
268
260
fill(invocationID, float4(idx, lhs, rhs)); \
269
- SHADER_CRASHING_ASSERT (abs(lhs - rhs) < nbl::hlsl::numeric_limits<decltype(lhs)>::epsilon) \
261
+ assert (abs(lhs - rhs) < nbl::hlsl::numeric_limits<decltype(lhs)>::epsilon) \
270
262
}
271
263
TEST_FN(float2(10, 1), cos, 1.44f)
272
264
TEST_FN(float2(10, 2), sin, 1.44f)
0 commit comments