Skip to content

Commit 045a5ae

Browse files
committed
small ports of some other scan module components
1 parent fa7ee6e commit 045a5ae

File tree

2 files changed

+73
-7
lines changed

2 files changed

+73
-7
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#ifndef _NBL_HLSL_SCAN_DECLARATIONS_INCLUDED_
2+
#define _NBL_HLSL_SCAN_DECLARATIONS_INCLUDED_
3+
4+
// REVIEW: Not sure if this file is needed in HLSL implementation
5+
6+
#include <nbl/builtin/hlsl/scan/parameters_struct.hlsl>
7+
8+
9+
#ifndef _NBL_HLSL_SCAN_GET_PARAMETERS_DECLARED_
10+
namespace nbl
11+
{
12+
namespace hlsl
13+
{
14+
namespace scan
15+
{
16+
Parameters_t getParameters();
17+
}
18+
}
19+
}
20+
#define _NBL_HLSL_SCAN_GET_PARAMETERS_DECLARED_
21+
#endif
22+
23+
#ifndef _NBL_HLSL_SCAN_GET_PADDED_DATA_DECLARED_
24+
namespace nbl
25+
{
26+
namespace hlsl
27+
{
28+
namespace scan
29+
{
30+
template<typename Storage_t>
31+
void getData(
32+
inout Storage_t data,
33+
in uint levelInvocationIndex,
34+
in uint localWorkgroupIndex,
35+
in uint treeLevel,
36+
in uint pseudoLevel
37+
);
38+
}
39+
}
40+
}
41+
#define _NBL_HLSL_SCAN_GET_PADDED_DATA_DECLARED_
42+
#endif
43+
44+
#ifndef _NBL_HLSL_SCAN_SET_DATA_DECLARED_
45+
namespace nbl
46+
{
47+
namespace hlsl
48+
{
49+
namespace scan
50+
{
51+
template<typename Storage_t>
52+
void setData(
53+
in Storage_t data,
54+
in uint levelInvocationIndex,
55+
in uint localWorkgroupIndex,
56+
in uint treeLevel,
57+
in uint pseudoLevel,
58+
in bool inRange
59+
);
60+
}
61+
}
62+
}
63+
#define _NBL_HLSL_SCAN_SET_DATA_DECLARED_
64+
#endif
65+
66+
#endif

include/nbl/builtin/hlsl/scan/default_scheduler.hlsl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#ifndef _NBL_GLSL_SCAN_DEFAULT_SCHEDULER_INCLUDED_
2-
#define _NBL_GLSL_SCAN_DEFAULT_SCHEDULER_INCLUDED_
1+
#ifndef _NBL_HLSL_SCAN_DEFAULT_SCHEDULER_INCLUDED_
2+
#define _NBL_HLSL_SCAN_DEFAULT_SCHEDULER_INCLUDED_
33

4-
#include <nbl/builtin/glsl/scan/parameters_struct.hlsl>
4+
#include <nbl/builtin/hlsl/scan/parameters_struct.hlsl>
55

66
#ifdef __cplusplus
77
#define uint uint32_t
@@ -139,7 +139,7 @@ namespace scheduler
139139
if(gl_LocalInvocationIndex == 0u)
140140
{
141141
uint64_t original;
142-
InterlockedAdd(scanScratch.workgroupsStarted, 1u, original); // TODO (PentaKon): Refactor this when the ScanScratch descriptor set is declared
142+
InterlockedAdd(scanScratch.workgroupsStarted, 1u, original); // REVIEW: Refactor InterlockedAdd with GLSL terminology? // TODO (PentaKon): Refactor this when the ScanScratch descriptor set is declared
143143
sharedScratch.set(gl_LocalInvocationIndex, original);
144144
}
145145
else if (gl_LocalInvocationIndex == 1u)
@@ -189,16 +189,16 @@ namespace scheduler
189189
dependentsFinishedFlagOffset /= _NBL_HLSL_WORKGROUP_SIZE_;
190190
dependentsFinishedFlagOffset += params.finishedFlagOffset[prevLevel];
191191
while (scanScratch.data[dependentsFinishedFlagOffset]!=dependentsCount) // TODO (PentaKon): Refactor this when the ScanScratch descriptor set is declared
192-
GroupMemoryBarrierWithGroupSync();
192+
GroupMemoryBarrierWithGroupSync(); // TODO (PentaKon): Possibly refactor?
193193
}
194194
}
195-
GroupMemoryBarrierWithGroupSync();
195+
GroupMemoryBarrierWithGroupSync(); // TODO (PentaKon): Possibly refactor?
196196
return false;
197197
}
198198

199199
void markComplete(in DefaultSchedulerParameters_t params, in uint topLevel, in uint treeLevel, in uint localWorkgroupIndex)
200200
{
201-
GroupMemoryBarrierWithGroupSync(); // must complete writing the data before flags itself as complete
201+
GroupMemoryBarrierWithGroupSync(); // must complete writing the data before flags itself as complete // TODO (PentaKon): Possibly refactor?
202202
if (gl_LocalInvocationIndex==0u)
203203
{
204204
uint finishedFlagOffset = params.finishedFlagOffset[treeLevel];

0 commit comments

Comments
 (0)