Skip to content

Commit 3ae793b

Browse files
committed
Pass CountingPushData into CountingParameters
1 parent 9dafb9a commit 3ae793b

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

CountingSort/app_resources/prefix_sum_shader.comp.hlsl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ uint32_t3 nbl::hlsl::glsl::gl_WorkGroupSize()
4242
[numthreads(WorkgroupSize,1,1)]
4343
void main(uint32_t3 ID : SV_GroupThreadID, uint32_t3 GroupID : SV_GroupID)
4444
{
45+
nbl::hlsl::sort::CountingParameters < uint32_t > params;
46+
params.dataElementCount = pushData.dataElementCount;
47+
params.elementsPerWT = pushData.elementsPerWT;
48+
params.minimum = pushData.minimum;
49+
params.maximum = pushData.maximum;
50+
4551
nbl::hlsl::sort::counting <uint32_t, PtrAccessor, PtrAccessor, PtrAccessor> counter;
4652
PtrAccessor input_accessor = PtrAccessor::create(pushData.inputKeyAddress);
4753
PtrAccessor scratch_accessor = PtrAccessor::create(pushData.scratchAddress);
48-
/*counter.histogram(
54+
counter.histogram(
4955
input_accessor,
5056
scratch_accessor,
51-
pushData
52-
);*/
57+
params
58+
);
5359
}

CountingSort/app_resources/scatter_shader.comp.hlsl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,20 @@ uint32_t3 nbl::hlsl::glsl::gl_WorkGroupSize()
6767
[numthreads(WorkgroupSize, 1, 1)]
6868
void main(uint32_t3 ID : SV_GroupThreadID, uint32_t3 GroupID : SV_GroupID)
6969
{
70+
nbl::hlsl::sort::CountingParameters < uint32_t > params;
71+
params.dataElementCount = pushData.dataElementCount;
72+
params.elementsPerWT = pushData.elementsPerWT;
73+
params.minimum = pushData.minimum;
74+
params.maximum = pushData.maximum;
75+
7076
nbl::hlsl::sort::counting <uint32_t, DoublePtrAccessor, DoublePtrAccessor, PtrAccessor> counter;
7177
DoublePtrAccessor key_accessor = DoublePtrAccessor::create(pushData.inputKeyAddress, pushData.outputKeyAddress);
7278
DoublePtrAccessor value_accessor = DoublePtrAccessor::create(pushData.inputValueAddress, pushData.outputValueAddress);
7379
PtrAccessor scratch_accessor = PtrAccessor::create(pushData.scratchAddress);
74-
/*counter.scatter(
80+
counter.scatter(
7581
key_accessor,
7682
value_accessor,
7783
scratch_accessor,
78-
pushData
79-
);*/
84+
params
85+
);
8086
}

CountingSort/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class CountingSortApp final : public application_templates::MonoDeviceApplicatio
3232
auto limits = m_physicalDevice->getLimits();
3333
const uint32_t WorkgroupSize = limits.maxComputeWorkGroupInvocations;
3434
const uint32_t MaxBucketCount = (limits.maxComputeSharedMemorySize / sizeof(uint32_t)) / 2;
35-
constexpr size_t element_count = 100000;
36-
const size_t bucket_count = std::min((uint32_t)3000, MaxBucketCount);
35+
constexpr uint32_t element_count = 100000;
36+
const uint32_t bucket_count = std::min((uint32_t)3000, MaxBucketCount);
3737
const uint32_t elements_per_thread = ceil((float)ceil((float)element_count / limits.computeUnits) / WorkgroupSize);
3838

3939
// this time we load a shader directly from a file
@@ -171,7 +171,6 @@ class CountingSortApp final : public application_templates::MonoDeviceApplicatio
171171

172172
// Generate random data
173173
constexpr uint32_t minimum = 0;
174-
constexpr uint32_t maximum = 10000;
175174
const uint32_t range = bucket_count;
176175
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
177176
std::mt19937 g(seed);
@@ -212,7 +211,7 @@ class CountingSortApp final : public application_templates::MonoDeviceApplicatio
212211
.dataElementCount = element_count,
213212
.elementsPerWT = elements_per_thread,
214213
.minimum = minimum,
215-
.maximum = maximum,
214+
.maximum = minimum + bucket_count - 1,
216215
};
217216

218217
smart_refctd_ptr<nbl::video::IGPUCommandBuffer> cmdBuf;

0 commit comments

Comments
 (0)