Skip to content
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

Add a new sample - subgroups operations #715

Open
wants to merge 90 commits into
base: main
Choose a base branch
from

Conversation

Patryk-Jastrzebski-Mobica
Copy link
Contributor

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:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the samples readme

@Patryk-Jastrzebski-Mobica Patryk-Jastrzebski-Mobica changed the title WIP: Add a new sample - subgroups operation WIP: Add a new sample - subgroups operations Jun 12, 2023
VK_CHECK(vkAllocateDescriptorSets(get_device().get_handle(), &alloc_info, &compute.descriptor_set));
}

void SubgroupsOperations::preapre_compute_pipeline_layout()

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);

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

Copy link
Contributor Author

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);

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);

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);

Copy link
Contributor Author

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);

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

Copy link
Contributor Author

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);

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);

Copy link
Contributor Author

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;

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

Copy link
Contributor Author

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 = {

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out to date

@asuessenbach
Copy link
Contributor

That's a nice little sample!
Is it still work in progress, as the title says?
Would it be easy to extend that sample by adding a non-subgroups path for comparison?

@Patryk-Jastrzebski-Mobica
Copy link
Contributor Author

Hi @asuessenbach,
Yes, I'm still working on this sample. I'm currently implementing the FFT algorithm. Next week, I plan to push another commit/change with the vertex animation ready.
And as for the last question, I cannot answer you yet.

@SaschaWillems
Copy link
Collaborator

Any update on this? Having a subgroups sample would be very much appreciated :)

@SaschaWillems
Copy link
Collaborator

Any updates on this sample? Having a subgroup sample would be a great addition :)

@Patryk-Jastrzebski-Mobica
Copy link
Contributor Author

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:

  • implement BRDF reflections,

  • fixing problems with pipeline barriers - on the Intel Iris Xe the sample runs stable, but on the RTX 2060 it crash after a few seconds,

  • adding a description to the README file.

@SaschaWillems
Copy link
Collaborator

No need to apologize. Your work is very much appreciated and I'm happy to hear that this sample is coming along :)

@SaschaWillems
Copy link
Collaborator

Any update on this?

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2024

CLA assistant check
All committers have signed the CLA.

@marty-johnson59
Copy link
Contributor

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

@Patryk-Jastrzebski-Mobica
Copy link
Contributor Author

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 :).

@marty-johnson59
Copy link
Contributor

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!

@Patryk-Jastrzebski-Mobica
Copy link
Contributor Author

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.

@marty-johnson59
Copy link
Contributor

Awesome, thank you! (and NP on the delay - just following up and letting you know there is still strong interest in this sample :) )

@Patryk-Jastrzebski-Mobica
Copy link
Contributor Author

Patryk-Jastrzebski-Mobica commented Oct 16, 2024

Hi,
I have added the option to disable/enable subgroups. After adding shaders without subgroups enabled something like this started to happen to the mesh? @marty-johnson59 or @SaschaWillems do you have any idea where this problem is coming from? I'm not able to figure out myself if this is a problem with SPIR-V, the graphics driver or my implementation.
I need help with this issue.
image

@Patryk-Jastrzebski-Mobica Patryk-Jastrzebski-Mobica changed the title WIP: Add a new sample - subgroups operations Add a new sample - subgroups operations Oct 16, 2024
@asuessenbach
Copy link
Contributor

I don't know why, but this little patch makes the subgroups enabled case look correct again.
0001-Make-subgroups-enabled-work.patch

@cforfang
Copy link
Contributor

cforfang commented Oct 23, 2024

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:
Semi-related, it would probably be good if the readme explained how subgroups are used by the sample, and why this is useful/good compared to alternative approaches.

@SaschaWillems
Copy link
Collaborator

@cforfang : The sample is still work-in-progress

@cforfang
Copy link
Contributor

@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 :)

@marty-johnson59
Copy link
Contributor

Hi @Patryk-Jastrzebski-Mobica, just checking status on this one. Is it still in flight? Any help you need? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.