-
Notifications
You must be signed in to change notification settings - Fork 781
Add a new sample - subgroups operations #715
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
base: main
Are you sure you want to change the base?
Add a new sample - subgroups operations #715
Conversation
| VK_CHECK(vkAllocateDescriptorSets(get_device().get_handle(), &alloc_info, &compute.descriptor_set)); | ||
| } | ||
|
|
||
| void SubgroupsOperations::preapre_compute_pipeline_layout() |
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.
typo. Should be "prepare_compute_pipeline_layout"
| VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, | ||
| 1u, | ||
| &image_descriptor)}; | ||
| vkUpdateDescriptorSets(get_device().get_handle(), static_cast<uint32_t>(write_descriptor_sets.size()), write_descriptor_sets.data(), 0u, NULL); |
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.
How about using nullptr instead of NULL? The last argument of vkUpdateDescriptorSets is a pointer to an array of VkCopyDescriptorSet so nullptr better suggest that is the pointer
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.
out to date
| VkViewport viewport = vkb::initializers::viewport(static_cast<float>(width), static_cast<float>(height), 0.0f, 1.0f); | ||
| vkCmdSetViewport(draw_cmd_buffers[i], 0u, 1u, &viewport); | ||
|
|
||
| VkRect2D scissor = vkb::initializers::rect2D(width, height, 0, 0); |
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.
Perhaps it can be explicitly cast by static_cast<int32_t>(width) and static_cast<int32_t>(height). This is not necessary, just a small suggestion
|
|
||
| // draw texture | ||
| { | ||
| vkCmdBindDescriptorSets(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, texture_object.pipeline.pipeline_layout, 0, 1, &texture_object.descriptor_set, 0, nullptr); |
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.
For code style consistency I suggest to add "u" to numbers
vkCmdBindDescriptorSets(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, texture_object.pipeline.pipeline_layout, 0u, 1u, &texture_object.descriptor_set, 0u, nullptr);
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.
out to date
| vkCmdBindPipeline(draw_cmd_buffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, texture_object.pipeline.pipeline); | ||
|
|
||
| VkDeviceSize offset[] = {0}; | ||
| vkCmdBindVertexBuffers(draw_cmd_buffers[i], 0, 1, texture_object.buffers.vertex->get(), offset); |
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.
For code style consistency I suggest to add "u" to unsigned int arguments
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.
out to date
| vkCmdBindVertexBuffers(draw_cmd_buffers[i], 0, 1, texture_object.buffers.vertex->get(), offset); | ||
| vkCmdBindIndexBuffer(draw_cmd_buffers[i], texture_object.buffers.index->get_handle(), 0, VK_INDEX_TYPE_UINT32); | ||
|
|
||
| vkCmdDrawIndexed(draw_cmd_buffers[i], texture_object.buffers.index_count, 1u, 0u, 0u, 0u); |
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.
vertexOffset argument is int32_t so it should be
vkCmdDrawIndexed(draw_cmd_buffers[i], texture_object.buffers.index_count, 1u, 0u, 0, 0u);
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.
out to date
|
|
||
| struct GuiSettings | ||
| { | ||
| int32_t selected_filtr = 0; |
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.
typo. Should be selected_filter
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.
out to date
| int32_t selected_filtr = 0; | ||
| static std::vector<std::string> init_filters_name() | ||
| { | ||
| std::vector<std::string> filtrs = { |
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.
typo. Should be std::vectorstd::string filters
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.
out to date
|
That's a nice little sample! |
|
Hi @asuessenbach, |
|
Any update on this? Having a subgroups sample would be very much appreciated :) |
|
Any updates on this sample? Having a subgroup sample would be a great addition :) |
6a2eef8 to
a67ff3e
Compare
|
Hi @SaschaWillems, I apologise for not updating for such a long time. Unfortunately the implementation of the sample is not yet finished. I still have some work left to do:
|
|
No need to apologize. Your work is very much appreciated and I'm happy to hear that this sample is coming along :) |
|
Any update on this? |
|
|
|
Hi @Patryk-Jastrzebski-Mobica, we noticed there's an issue with the CLA on this one - looks like the test got confused with the login alias (kdmitruk). Can you look into this? Not quite sure what the fix is - perhaps sign the CLA again using the alias? Thanks |
|
Hi @marty-johnson59, I will to do something about it this week. I hope to find some time in the near future to finish the sample :). |
|
Hi @Patryk-Jastrzebski-Mobica, quick reminder on this. We briefly discussed this on the Samples call this week and there's definitely interest in seeing this sample released. Let us know if/how we can help. Thanks! |
|
Hi @marty-johnson59, I am very sorry for such a long delay. I got back to work on this example this week. For now, I am pushing the fixes onto my own branch https://github.com/Mobica/Vulkan-Samples/tree/subgroups_operations_WIP3 . As soon as I have fixed the reflections on the model, I will immediately start to rebase this branch and deliver the code. |
|
Awesome, thank you! (and NP on the delay - just following up and letting you know there is still strong interest in this sample :) ) |
a67ff3e to
f1936a7
Compare
… remove useless shaders
…ilde_h0 shader and removed commented lines
|
Hi, |
|
I don't know why, but this little patch makes the subgroups enabled case look correct again. |
|
Hey, I wanted to check -- does this sample work for all possible legal subgroup sizes? I didn't notice any checks for the exposed subgroupSize, nor any logic to handle different ones. It wasn't clear to me how/if the algorithm is such that it 'just works' whatever size is exposed or not. EDIT: |
|
@cforfang : The sample is still work-in-progress |
Understood, just to highlight already now in case incompatibility might come up as a problem later for example :) |
|
Hi @Patryk-Jastrzebski-Mobica, just checking status on this one. Is it still in flight? Any help you need? Thanks |
|
Re-assigning to Steve for now. |
|
HI @Patryk-Jastrzebski-Mobica, @Krzysztof-Dmitruk-Mobica, @Piotr-Plebanski-Mobica, @Seweryn-Zielas-Mobica, @kdmitruk The CLA still hasn't been signed. Could I ask you guys to take a look and ensure that is handled? I have updated this PR locally and might have a few fixes for the bugs observed above. I'll push what I have once I have it completely working. |
|
Mobica#9 <-- I think I've fixed everything in this PR including merging with master. All pipelines work and there are no more VVL errors or warnings. Please give it a look Mobica guys when you get a chance and let's hopefully get this excellent PR merged. |
| "hpp_texture_compression_comparison" | ||
|
|
||
| #General Samples | ||
| "mobile_nerf") |
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.
Seems, you've removed a couple of samples?
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.
Mobica#9 <-- hopefully they are not removed after the merge.
| * `#extension GL_KHR_shader_subgroup_quad` | ||
| This sample focuse on `GL_KHR_shader_subgroup_basic` extension. |
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.
Typo: focuse -> focuses
| In order to use subgroups operations, the required extensions must be enabled, an instance of the Vulkan API must be created with a minimum of version 1.1 and SPIR-V 1.4 must be used. | ||
| VkDevice must be created with this `VK_EXT_subgroup_size_control` extension. |
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.
Typo this -> the?
| prepare_uniform_buffers(); | ||
| prepare_compute(); | ||
|
|
||
| // prepare grpahics pipeline |
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.
Typo: grpahics -> graphics
asuessenbach
left a comment
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.
I did not try to get all the math used here... maybe worth to extend the README.adoc a bit?
| auto rndVal = []() -> float { | ||
| std::random_device rndDevice; | ||
| std::mt19937 mt(rndDevice()); | ||
| std::uniform_real_distribution<float> dis(0.0f, 1.0f); |
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.
You could make those three variables static, to prevent their construction on every random number generation.
| do | ||
| { | ||
| x1 = 2.0f * rndVal() - 1.0f; | ||
| x2 = 2.0f * rndVal() - 1.0f; |
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.
Instead of re-mapping a random value from [0.0, 1.0] to [-1.0, 1.0], you could just generate a value in that range by using
std::uniform_real_distribution<float> dis(-1.0f, 1.0f);
|
|
||
| void SubgroupsOperations::generate_plane() | ||
| { | ||
| uint32_t dim_gird = grid_size; |
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.
Typo: dim_gird -> dim_grid?
And... why are you introducing that variable at all? You could just directly use grid_size.
| void SubgroupsOperations::generate_plane() | ||
| { | ||
| uint32_t dim_gird = grid_size; | ||
| uint32_t vertex_count = dim_gird + 1u; |
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.
I think, the name vertex_count might be a bit misleading. This is not the number of vertices (in total), but the number of vertices per row (or per column).
| struct GridBuffers | ||
| { | ||
| std::unique_ptr<vkb::core::BufferC> vertex = {VK_NULL_HANDLE}; | ||
| std::unique_ptr<vkb::core::BufferC> index = {VK_NULL_HANDLE}; |
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.
Wouldn't vertices and indices be better names here?
| vkb::initializers::descriptor_pool_size(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 20u), | ||
| vkb::initializers::descriptor_pool_size(VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 20u)}; | ||
| VkDescriptorPoolCreateInfo descriptor_pool_create_info = | ||
| vkb::initializers::descriptor_pool_create_info(static_cast<uint32_t>(pool_sizes.size()), pool_sizes.data(), 15u); |
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.
Some magic values 20u and 15u here? Where do they come from?
| vkUpdateDescriptorSets(get_device().get_handle(), static_cast<uint32_t>(write_descriptor_sets.size()), write_descriptor_sets.data(), 0u, nullptr); | ||
| } | ||
|
|
||
| VkDescriptorImageInfo SubgroupsOperations::create_ia_descriptor(ImageAttachment &attachment) |
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.
What does ia in create_ia_descriptor stand for?
|
When I start this sample, I get this VVL warning: |
Mobica#9 <-- VVL error is fixed here. |

Description
Please include a summary of the change, new sample or fixed issue. Please also include relevant motivation and context.
Please read the contribution guidelines
Fixes #
General Checklist:
Please ensure the following points are checked:
Sample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: