Skip to content

Commit fb9d777

Browse files
author
devsh
committed
1 parent 2b338b7 commit fb9d777

File tree

6 files changed

+45
-26
lines changed

6 files changed

+45
-26
lines changed
Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,39 @@
11
// Copyright (C) 2018-2025 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
5-
#ifndef _NBL_BUILTIN_GLSL_RANDOM_LCG_HLSL_INCLUDED_
6-
#define _NBL_BUILTIN_GLSL_RANDOM_LCG_HLSL_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_RANDOM_LCG_HLSL_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_RANDOM_LCG_HLSL_INCLUDED_
76

87
namespace nbl
98
{
109
namespace hlsl
1110
{
11+
namespace random
12+
{
1213

1314
struct Lcg
1415
{
15-
static Lcg construct(NBL_CONST_REF_ARG(uint32_t) state)
16+
static Lcg create(const uint32_t _state)
1617
{
17-
return Lcg(state);
18+
Lcg retval;
19+
retval.state = _state;
20+
return retval;
1821
}
1922

20-
uint32_t2 operator()()
23+
uint32_t operator()()
2124
{
2225
uint32_t LCG_A = 1664525u;
2326
uint32_t LCG_C = 1013904223u;
2427
state = (LCG_A * state + LCG_C);
28+
// is this mask supposed to be here? because usually we turn random uints to float by dividing by UINT32_MAX
2529
state &= 0x00FFFFFF;
2630
return state;
2731
}
2832

2933
uint32_t state;
3034
};
3135

36+
}
3237
}
3338
}
3439
#endif
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
// Copyright (C) 2018-2025 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
5-
#ifndef _NBL_BUILTIN_GLSL_RANDOM_PCG_HLSL_INCLUDED_
6-
#define _NBL_BUILTIN_GLSL_RANDOM_PCG_HLSL_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_RANDOM_PCG_HLSL_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_RANDOM_PCG_HLSL_INCLUDED_
76

87
namespace nbl
98
{
109
namespace hlsl
1110
{
11+
namespace random
12+
{
1213

1314
struct Pcg
1415
{
15-
static Pcg construct(NBL_CONST_REF_ARG(uint32_t) initialState)
16+
static Pcg create(const uint32_t initialState)
1617
{
17-
uint32_t state = {initialState};
18-
return Pcg(state);
18+
Pcg retval;
19+
retval.state = initialState;
20+
return retval;
1921
}
2022

2123
uint32_t operator()()
@@ -29,6 +31,7 @@ struct Pcg
2931
uint32_t state;
3032
};
3133

34+
}
3235
}
3336
}
3437
#endif
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
// Copyright (C) 2018-2025 - DevSH Graphics Programming Sp. z O.O.
22
// This file is part of the "Nabla Engine".
33
// For conditions of distribution and use, see copyright notice in nabla.h
4-
5-
#ifndef _NBL_BUILTIN_GLSL_RANDOM_TEA_HLSL_INCLUDED_
6-
#define _NBL_BUILTIN_GLSL_RANDOM_TEA_HLSL_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_RANDOM_TEA_HLSL_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_RANDOM_TEA_HLSL_INCLUDED_
76

87
namespace nbl
98
{
109
namespace hlsl
1110
{
11+
namespace random
12+
{
1213

1314
struct Tea
1415
{
15-
static Tea construct()
16+
static Tea create()
1617
{
17-
Tea tea = {};
18+
Tea tea;
1819
return tea;
1920
}
2021

21-
uint32_t2 operator()(uint32_t stream, uint32_t sequence, uint32_t roundCount)
22+
static uint32_t2 __call(const uint32_t stream, const uint32_t sequence, const uint32_t roundCount)
2223
{
2324
uint32_t sum = 0;
2425
uint32_t v0 = stream;
@@ -32,9 +33,14 @@ struct Tea
3233

3334
return uint32_t2(v0, v1);
3435
}
35-
36+
37+
uint32_t2 operator()(const uint32_t stream, const uint32_t sequence, const uint32_t roundCount) NBL_CONST_MEMBER_FUNC
38+
{
39+
return __call(stream,sequence,roundCount);
40+
}
3641
};
3742

43+
}
3844
}
3945
}
4046
#endif

include/nbl/builtin/hlsl/random/xoroshiro.hlsl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
21
// Copyright (C) 2018-2020 - DevSH Graphics Programming Sp. z O.O.
32
// This file is part of the "Nabla Engine".
43
// For conditions of distribution and use, see copyright notice in nabla.h
5-
6-
#ifndef _NBL_BUILTIN_GLSL_RANDOM_XOROSHIRO_HLSL_INCLUDED_
7-
#define _NBL_BUILTIN_GLSL_RANDOM_XOROSHIRO_HLSL_INCLUDED_
4+
#ifndef _NBL_BUILTIN_HLSL_RANDOM_XOROSHIRO_HLSL_INCLUDED_
5+
#define _NBL_BUILTIN_HLSL_RANDOM_XOROSHIRO_HLSL_INCLUDED_
86

97
#include <nbl/builtin/hlsl/cpp_compat/vector.hlsl>
108

@@ -14,6 +12,9 @@ namespace nbl
1412
{
1513
namespace hlsl
1614
{
15+
// TODO
16+
//namespace random
17+
//{
1718

1819
struct Xoroshiro64StateHolder
1920
{
@@ -29,6 +30,7 @@ struct Xoroshiro64StateHolder
2930

3031
struct Xoroshiro64Star
3132
{
33+
// TODO: create
3234
static Xoroshiro64Star construct(NBL_CONST_REF_ARG(uint32_t2) initialState)
3335
{
3436
Xoroshiro64StateHolder stateHolder = {initialState};
@@ -48,6 +50,7 @@ struct Xoroshiro64Star
4850

4951
struct Xoroshiro64StarStar
5052
{
53+
// TODO: create
5154
static Xoroshiro64StarStar construct(NBL_CONST_REF_ARG(uint32_t2) initialState)
5255
{
5356
Xoroshiro64StateHolder stateHolder = {initialState};
@@ -65,6 +68,7 @@ struct Xoroshiro64StarStar
6568
Xoroshiro64StateHolder stateHolder;
6669
};
6770

71+
//}
6872
}
6973
}
7074

src/nbl/video/IGPUCommandBuffer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,9 +1899,10 @@ bool IGPUCommandBuffer::setRayTracingPipelineStackSize(uint32_t pipelineStackSiz
18991899
{
19001900
if (!checkStateBeforeRecording(queue_flags_t::COMPUTE_BIT,RENDERPASS_SCOPE::OUTSIDE))
19011901
return false;
1902-
if (m_boundRayTracingPipeline != nullptr && m_boundRayTracingPipeline->getCachedCreationParams().dynamicStackSize)
1902+
if (!m_boundRayTracingPipeline || !m_boundRayTracingPipeline->getCachedCreationParams().dynamicStackSize)
19031903
{
1904-
NBL_LOG_ERROR("Cannot set dynamic state when state is not mark as dynamic on bound pipeline!");
1904+
NBL_LOG_ERROR("Cannot set dynamic state when state is not mark as dynamic on bound pipeline!");
1905+
return false;
19051906
}
19061907
m_haveRtPipelineStackSize = true;
19071908
return setRayTracingPipelineStackSize_impl(pipelineStackSize);

0 commit comments

Comments
 (0)