-
Notifications
You must be signed in to change notification settings - Fork 67
copy examples to CE container in the build time #886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
YasInvolved
wants to merge
2
commits into
master
Choose a base branch
from
yas_godbolt_examples
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+205
−1
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
tools/nsc/docker/godbolt/examples/prefix_sum_shader.comp.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // this shader has to be compiled with: | ||
| // -T cs_6_0 -E main | ||
|
|
||
| #include "nbl/builtin/hlsl/sort/counting.hlsl" | ||
| #include "nbl/builtin/hlsl/bda/bda_accessor.hlsl" | ||
|
|
||
| #define WorkgroupSize 27 | ||
| #define BucketCount 27 | ||
|
|
||
| struct CountingPushData | ||
| { | ||
| uint64_t inputKeyAddress; | ||
| uint64_t inputValueAddress; | ||
| uint64_t histogramAddress; | ||
| uint64_t outputKeyAddress; | ||
| uint64_t outputValueAddress; | ||
| uint32_t dataElementCount; | ||
| uint32_t elementsPerWT; | ||
| uint32_t minimum; | ||
| uint32_t maximum; | ||
| }; | ||
|
|
||
| using | ||
| namespace nbl:: | ||
| hlsl; | ||
|
|
||
| usingPtr = bda::__ptr<uint32_t>; | ||
| using PtrAccessor = BdaAccessor < uint32_t >; | ||
|
|
||
| groupshared uint32_t sdata[BucketCount]; | ||
|
|
||
| struct SharedAccessor | ||
| { | ||
| void get(const uint32_t index, NBL_REF_ARG( uint32_t) value) | ||
| { | ||
| value = | ||
| sdata[ index]; | ||
| } | ||
|
|
||
| void set( | ||
| const uint32_t index, const uint32_tvalue) | ||
| { | ||
| sdata[index] = | ||
| value; | ||
| } | ||
|
|
||
| uint32_t atomicAdd(const uint32_t index, const uint32_t value) | ||
| { | ||
| return glsl::atomicAdd(sdata[index], value); | ||
| } | ||
|
|
||
| void workgroupExecutionAndMemoryBarrier() | ||
| { | ||
| glsl::barrier(); | ||
| } | ||
| }; | ||
|
|
||
| uint32_t3 glsl::gl_WorkGroupSize() | ||
| { | ||
| return uint32_t3(WorkgroupSize, 1, 1); | ||
| } | ||
|
|
||
|
|
||
| [[vk::push_constant]] CountingPushData pushData; | ||
|
|
||
| [numthreads(WorkgroupSize, 1, 1)] | ||
| void main(uint32_t3 ID : SV_GroupThreadID, uint32_t3 GroupID : SV_GroupID) | ||
| { | ||
| sort::CountingParameters < uint32_t > params; | ||
| params.dataElementCount = pushData.dataElementCount; | ||
| params.elementsPerWT = pushData.elementsPerWT; | ||
| params.minimum = pushData.minimum; | ||
| params.maximum = pushData.maximum; | ||
|
|
||
| using Counter = sort::counting < WorkgroupSize, BucketCount, PtrAccessor, PtrAccessor, PtrAccessor, SharedAccessor, PtrAccessor::type_t >; | ||
| Counter counter = Counter::create(glsl::gl_WorkGroupID().x); | ||
|
|
||
| const Ptr input_ptr = Ptr::create(pushData.inputKeyAddress); | ||
| const Ptr histogram_ptr = Ptr::create(pushData.histogramAddress); | ||
|
|
||
| PtrAccessor input_accessor = PtrAccessor::create(input_ptr); | ||
| PtrAccessor histogram_accessor = PtrAccessor::create(histogram_ptr); | ||
| SharedAccessor shared_accessor; | ||
| counter.histogram( | ||
| input_accessor, | ||
| histogram_accessor, | ||
| shared_accessor, | ||
| params | ||
| ); | ||
| } |
102 changes: 102 additions & 0 deletions
102
tools/nsc/docker/godbolt/examples/scatter_shader.comp.hlsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // this shader has to be compiled with: | ||
| // -T cs_6_0 -E main | ||
|
|
||
| #include "nbl/builtin/hlsl/sort/counting.hlsl" | ||
| #include "nbl/builtin/hlsl/bda/bda_accessor.hlsl" | ||
|
|
||
| #define WorkgroupSize 27 | ||
| #define BucketCount 27 | ||
|
|
||
| struct CountingPushData | ||
| { | ||
| uint64_t inputKeyAddress; | ||
| uint64_t inputValueAddress; | ||
| uint64_t histogramAddress; | ||
| uint64_t outputKeyAddress; | ||
| uint64_t outputValueAddress; | ||
| uint32_t dataElementCount; | ||
| uint32_t elementsPerWT; | ||
| uint32_t minimum; | ||
| uint32_t maximum; | ||
| }; | ||
|
|
||
| using | ||
| namespace nbl:: | ||
| hlsl; | ||
|
|
||
| usingPtr = bda::__ptr<uint32_t>; | ||
| using PtrAccessor = BdaAccessor < uint32_t >; | ||
|
|
||
| groupshared uint32_t sdata[BucketCount]; | ||
|
|
||
| struct SharedAccessor | ||
| { | ||
| void get(const uint32_t index, NBL_REF_ARG( uint32_t) value) | ||
| { | ||
| value = | ||
| sdata[ index]; | ||
| } | ||
|
|
||
| void set( | ||
| const uint32_t index, const uint32_tvalue) | ||
| { | ||
| sdata[index] = | ||
| value; | ||
| } | ||
|
|
||
| uint32_t atomicAdd(const uint32_t index, const uint32_t value) | ||
| { | ||
| return glsl::atomicAdd(sdata[index], value); | ||
| } | ||
|
|
||
| void workgroupExecutionAndMemoryBarrier() | ||
| { | ||
| glsl::barrier(); | ||
| } | ||
| }; | ||
|
|
||
| uint32_t3 glsl::gl_WorkGroupSize() | ||
| { | ||
| return uint32_t3(WorkgroupSize, 1, 1); | ||
| } | ||
|
|
||
| [[vk::push_constant]] CountingPushData pushData; | ||
|
|
||
| using DoublePtrAccessor = DoubleBdaAccessor < uint32_t >; | ||
|
|
||
| [numthreads(WorkgroupSize, 1, 1)] | ||
| void main(uint32_t3 ID : SV_GroupThreadID, uint32_t3 GroupID : SV_GroupID) | ||
| { | ||
| sort::CountingParameters < uint32_t > params; | ||
| params.dataElementCount = pushData.dataElementCount; | ||
| params.elementsPerWT = pushData.elementsPerWT; | ||
| params.minimum = pushData.minimum; | ||
| params.maximum = pushData.maximum; | ||
|
|
||
| using Counter = sort::counting < WorkgroupSize, BucketCount, DoublePtrAccessor, DoublePtrAccessor, PtrAccessor, SharedAccessor, PtrAccessor::type_t >; | ||
| Counter counter = Counter::create(glsl::gl_WorkGroupID().x); | ||
|
|
||
| const Ptr input_key_ptr = Ptr::create(pushData.inputKeyAddress); | ||
| const Ptr input_value_ptr = Ptr::create(pushData.inputValueAddress); | ||
| const Ptr histogram_ptr = Ptr::create(pushData.histogramAddress); | ||
| const Ptr output_key_ptr = Ptr::create(pushData.outputKeyAddress); | ||
| const Ptr output_value_ptr = Ptr::create(pushData.outputValueAddress); | ||
|
|
||
| DoublePtrAccessor key_accessor = DoublePtrAccessor::create( | ||
| input_key_ptr, | ||
| output_key_ptr | ||
| ); | ||
| DoublePtrAccessor value_accessor = DoublePtrAccessor::create( | ||
| input_value_ptr, | ||
| output_value_ptr | ||
| ); | ||
| PtrAccessor histogram_accessor = PtrAccessor::create(histogram_ptr); | ||
| SharedAccessor shared_accessor; | ||
| counter.scatter( | ||
| key_accessor, | ||
| value_accessor, | ||
| histogram_accessor, | ||
| shared_accessor, | ||
| params | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to remove, unused