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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e275c44
Add a new sample - subgroups operation
Patryk-Jastrzebski-Mobica Jun 12, 2023
00fe99c
Add ocean fft
Patryk-Jastrzebski-Mobica Jun 13, 2023
fe0326f
Fix grid generation algorithm
Patryk-Jastrzebski-Mobica Jun 14, 2023
0cd32b8
Add compute pipeline and compute queue
Patryk-Jastrzebski-Mobica Jun 14, 2023
44aa375
Add ability to resize the grid in the UI and a few small changes
Patryk-Jastrzebski-Mobica Jun 16, 2023
3ea91d5
Animated grid using the sine and cosine functions
Patryk-Jastrzebski-Mobica Jun 23, 2023
fc9009f
Add a new compute pipeline
Patryk-Jastrzebski-Mobica Jul 5, 2023
8026831
Fixed a descriptor set, the function generating random numbers has be…
Patryk-Jastrzebski-Mobica Jul 6, 2023
b62b93f
Transfer of philips spectrum calculation from GPU to CPU.
Patryk-Jastrzebski-Mobica Aug 18, 2023
db0b8b2
Refactoring and changes in graphic pipeline
Patryk-Jastrzebski-Mobica Sep 6, 2023
b3dce47
Add the FBAttachment type
Krzysztof-Dmitruk-Mobica Sep 12, 2023
063784f
Add butterfly precomp shader and texture
Krzysztof-Dmitruk-Mobica Sep 20, 2023
b2b74ac
Add tilde textures and pipeline
Patryk-Jastrzebski-Mobica Sep 21, 2023
d5f02b8
Refactor and add butterfly and tild texture generation
Patryk-Jastrzebski-Mobica Sep 26, 2023
ea1ec9a
Some fixes
Patryk-Jastrzebski-Mobica Sep 26, 2023
afd5394
Fix access to input buffers
Patryk-Jastrzebski-Mobica Sep 26, 2023
833f876
Add fft pipeline for rows
Patryk-Jastrzebski-Mobica Sep 28, 2023
069325f
Add vertical fft calculation
Patryk-Jastrzebski-Mobica Sep 29, 2023
e2f56c3
Add invert fft and clean-up
Patryk-Jastrzebski-Mobica Sep 29, 2023
bdf453c
Fix validation layer errors and fix tessellation shaders
Patryk-Jastrzebski-Mobica Oct 4, 2023
0cdb18f
some fixes
Patryk-Jastrzebski-Mobica Oct 4, 2023
7616cb0
Fix tilde_h_0 indexation
kdmitruk Oct 4, 2023
1a77ac4
Fix log_2_N rounding
Krzysztof-Dmitruk-Mobica Oct 6, 2023
b5851d4
Some fixes, add tessellation
Patryk-Jastrzebski-Mobica Oct 11, 2023
085e026
Fix a buttlefly pipeline
Patryk-Jastrzebski-Mobica Oct 11, 2023
f6396bb
Add tilde_h_0 shader
Krzysztof-Dmitruk-Mobica Oct 10, 2023
74371bd
Split fft steps into separate calls
Krzysztof-Dmitruk-Mobica Oct 13, 2023
7070474
Fix input data randomization
Krzysztof-Dmitruk-Mobica Oct 13, 2023
20dd48b
Code cleanup
Krzysztof-Dmitruk-Mobica Oct 13, 2023
a318c32
rewrite the grid generation
Patryk-Jastrzebski-Mobica Oct 14, 2023
9db394f
fixed validation layers issues and add changes to ocean pipeline
Patryk-Jastrzebski-Mobica Oct 16, 2023
5595c3e
animation fix
Patryk-Jastrzebski-Mobica Oct 16, 2023
263aed9
add normal map
Patryk-Jastrzebski-Mobica Oct 17, 2023
3a1820b
Fix interpolation of a tessellated grid
Krzysztof-Dmitruk-Mobica Oct 17, 2023
418b72a
some fixes and new ui params
Patryk-Jastrzebski-Mobica Oct 17, 2023
8c6d419
ui update
Patryk-Jastrzebski-Mobica Oct 17, 2023
d10c00b
Add wind coordinate conversion
Krzysztof-Dmitruk-Mobica Oct 17, 2023
364b71a
refactor
Patryk-Jastrzebski-Mobica Oct 18, 2023
c95ec21
shader clean-up
Patryk-Jastrzebski-Mobica Oct 18, 2023
2da30e5
add skybox
Patryk-Jastrzebski-Mobica Oct 18, 2023
a159bf4
rebase
Patryk-Jastrzebski-Mobica Oct 18, 2023
cd0835c
update ui
Patryk-Jastrzebski-Mobica Oct 18, 2023
732a961
fix normal map
Patryk-Jastrzebski-Mobica Oct 18, 2023
6ec6f78
add a new ui elements
Patryk-Jastrzebski-Mobica Oct 18, 2023
651489c
Fix skybox cliping issue
Patryk-Jastrzebski-Mobica Oct 24, 2023
680532d
Add (broken) reflection
Krzysztof-Dmitruk-Mobica Oct 20, 2023
e3d04bd
A rebase fix
Patryk-Jastrzebski-Mobica Oct 24, 2023
33ab6f1
use initialisation functions to initialise objects
Patryk-Jastrzebski-Mobica Oct 25, 2023
00a1ba2
[WIP] reflections experiments
Patryk-Jastrzebski-Mobica Nov 2, 2023
ba96ffa
Convert a README.md file to a README.adoc file
Patryk-Jastrzebski-Mobica Nov 8, 2023
b430bc4
[WIP] Add BRDF reflection
Patryk-Jastrzebski-Mobica Nov 15, 2023
9e57d20
Add pipeline barriers, update README file
Patryk-Jastrzebski-Mobica Nov 20, 2023
cec852f
Add a new sample - subgroups operation
Patryk-Jastrzebski-Mobica Jun 12, 2023
570de4b
Fix build issues after merging main and remove VL errors
Seweryn-Zielas-Mobica Apr 2, 2024
60d9f9b
Fixing synchronization in barriers - still in progress
Seweryn-Zielas-Mobica Apr 14, 2024
9f5540f
Removed write/read hazards
Seweryn-Zielas-Mobica Apr 19, 2024
acdaaf1
Add image memory barriers
Piotr-Plebanski-Mobica Jul 17, 2024
e415e0d
Rebase and update
Piotr-Plebanski-Mobica Jul 17, 2024
8756cb3
Fix tesselation shaders
Piotr-Plebanski-Mobica Jul 17, 2024
163099e
WIP optimize barriers
Piotr-Plebanski-Mobica Sep 30, 2024
c37fdaf
[WIP3] subgroups -Rebase and compilation fix
Patryk-Jastrzebski-Mobica Oct 8, 2024
85d4bab
shaders update
Patryk-Jastrzebski-Mobica Oct 10, 2024
3968ef7
WIP subgroups - fixed normal map generation, fixed reflections
Patryk-Jastrzebski-Mobica Oct 11, 2024
52a231f
Add a new sample - subgroups operation
Patryk-Jastrzebski-Mobica Jun 12, 2023
269d664
Add ocean fft
Patryk-Jastrzebski-Mobica Jun 13, 2023
68fc42b
Add compute pipeline and compute queue
Patryk-Jastrzebski-Mobica Jun 14, 2023
827d8c4
Add ability to resize the grid in the UI and a few small changes
Patryk-Jastrzebski-Mobica Jun 16, 2023
8af8b9c
Animated grid using the sine and cosine functions
Patryk-Jastrzebski-Mobica Jun 23, 2023
88aa8a4
Add a new compute pipeline
Patryk-Jastrzebski-Mobica Jul 5, 2023
d3fd571
Fixed a descriptor set, the function generating random numbers has be…
Patryk-Jastrzebski-Mobica Jul 6, 2023
81233dd
Transfer of philips spectrum calculation from GPU to CPU.
Patryk-Jastrzebski-Mobica Aug 18, 2023
112c260
Refactoring and changes in graphic pipeline
Patryk-Jastrzebski-Mobica Sep 6, 2023
0972161
Add the FBAttachment type
Krzysztof-Dmitruk-Mobica Sep 12, 2023
e92e60a
Add butterfly precomp shader and texture
Krzysztof-Dmitruk-Mobica Sep 20, 2023
33691ae
Add tilde textures and pipeline
Patryk-Jastrzebski-Mobica Sep 21, 2023
259a74d
Refactor and add butterfly and tild texture generation
Patryk-Jastrzebski-Mobica Sep 26, 2023
7501909
Add invert fft and clean-up
Patryk-Jastrzebski-Mobica Sep 29, 2023
64f366d
Some fixes, add tessellation
Patryk-Jastrzebski-Mobica Oct 11, 2023
b7b7798
add skybox
Patryk-Jastrzebski-Mobica Oct 18, 2023
ec7b26c
Convert a README.md file to a README.adoc file
Patryk-Jastrzebski-Mobica Nov 8, 2023
204bfb4
Add pipeline barriers, update README file
Patryk-Jastrzebski-Mobica Nov 20, 2023
c0065a5
Add a new sample - subgroups operation
Patryk-Jastrzebski-Mobica Jun 12, 2023
4d94890
[WIP3] subgroups -Rebase and compilation fix
Patryk-Jastrzebski-Mobica Oct 8, 2024
213059b
Add a new sample - subgroups operation
Patryk-Jastrzebski-Mobica Jun 12, 2023
5fa5527
A rebase fix
Patryk-Jastrzebski-Mobica Oct 24, 2023
acbbaac
[WIP] reflections experiments
Patryk-Jastrzebski-Mobica Nov 2, 2023
f1936a7
Add a new sample - subgroups operation
Patryk-Jastrzebski-Mobica Jun 12, 2023
dae01a0
[WIP] Remove skybox to make sample simpler. Update copyright data and…
Patryk-Jastrzebski-Mobica Oct 15, 2024
8340fc9
[WIP] Add missing description, enable subgroup basic feature in fft_t…
Patryk-Jastrzebski-Mobica Oct 15, 2024
1f26700
Update README and add option to disable/enable subgroups
Patryk-Jastrzebski-Mobica Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/api_vulkan_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class ApiVulkanSample : public vkb::VulkanSampleC
/**
* @brief Creates a new (graphics) command pool object storing command buffers
*/
void create_command_pool();
virtual void create_command_pool();

/**
* @brief Setup default depth and stencil views
Expand Down
177 changes: 84 additions & 93 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,99 +48,90 @@ endforeach ()

# Order of the sample ids
set(ORDER_LIST
#API Samples
"hello_triangle"
"dynamic_uniform_buffers"
"texture_loading"
"hdr"
"instancing"
"compute_nbody"
"terrain_tessellation"
"hlsl"
"oit_linked_lists"
"oit_depth_peeling"

#Extension Samples
"dynamic_rendering"
"conservative_rasterization"
"fragment_shading_rate"
"fragment_shading_rate_dynamic"
"full_screen_exclusive"
"calibrated_timestamps"
"graphics_pipeline_library"
"memory_budget"
"mesh_shader_culling"
"push_descriptors"
"ray_queries"
"ray_tracing_basic"
"ray_tracing_extended"
"ray_tracing_reflection"
"timeline_semaphore"
"shader_object"
"shader_debugprintf"
"synchronization_2"
"buffer_device_address"
"descriptor_indexing"
"portability"
"vertex_dynamic_state"
"extended_dynamic_state2"
"logic_op_dynamic_state"
"patch_control_points"
"fragment_shader_barycentric"
"gshader_to_mshader"
"color_write_enable"
"sparse_image"
"dynamic_primitive_clipping"

#Performance Samples
"swapchain_images"
"surface_rotation"
"pipeline_cache"
"descriptor_management"
"constant_data"
"render_passes"
"msaa"
"subpasses"
"pipeline_barriers"
"wait_idle"
"layout_transitions"
"specialization_constants"
"command_buffer_usage"
"multithreading_render_passes"
"afbc"
"16bit_storage_input_output"
"16bit_arithmetic"
"async_compute"
"multi_draw_indirect"
"texture_compression_comparison"

#Tooling samples
"profiles"

#HPP API Samples
"hpp_compute_nbody"
"hpp_dynamic_uniform_buffers"
"hpp_hdr"
"hpp_hello_triangle"
"hpp_hlsl_shaders"
"hpp_instancing"
"hpp_oit_depth_peeling"
"hpp_oit_linked_lists"
"hpp_separate_image_sampler"
"hpp_terrain_tessellation"
"hpp_texture_loading"
"hpp_texture_mipmap_generation"

#HPP Extension Samples
"hpp_mesh_shading"

#HPP Performance Samples
"hpp_pipeline_cache"
"hpp_swapchain_images"
"hpp_texture_compression_comparison"

#General Samples
"mobile_nerf")
#API Samples
"hello_triangle"
"dynamic_uniform_buffers"
"texture_loading"
"hdr"
"instancing"
"compute_nbody"
"terrain_tessellation"
"hlsl"

#Extension Samples
"dynamic_rendering"
"conservative_rasterization"
"fragment_shading_rate"
"fragment_shading_rate_dynamic"
"full_screen_exclusive"
"calibrated_timestamps"
"graphics_pipeline_library"
"memory_budget"
"mesh_shader_culling"
"push_descriptors"
"ray_queries"
"ray_tracing_basic"
"ray_tracing_extended"
"ray_tracing_reflection"
"timeline_semaphore"
"shader_object"
"synchronization_2"
"buffer_device_address"
"descriptor_indexing"
"portability"
"vertex_dynamic_state"
"extended_dynamic_state2"
"logic_op_dynamic_state"
"patch_control_points"
"fragment_shader_barycentric"
"gshader_to_mshader"
"color_write_enable"
"subgroups_operations"

#Performance Samples
"swapchain_images"
"surface_rotation"
"pipeline_cache"
"descriptor_management"
"constant_data"
"render_passes"
"msaa"
"subpasses"
"pipeline_barriers"
"wait_idle"
"layout_transitions"
"specialization_constants"
"command_buffer_usage"
"multithreading_render_passes"
"afbc"
"16bit_storage_input_output"
"16bit_arithmetic"
"async_compute"
"multi_draw_indirect"
"texture_compression_comparison"

#Tooling samples
"profiles"

#HPP API Samples
"hpp_compute_nbody"
"hpp_dynamic_uniform_buffers"
"hpp_hdr"
"hpp_hello_triangle"
"hpp_hlsl_shaders"
"hpp_instancing"
"hpp_separate_image_sampler"
"hpp_terrain_tessellation"
"hpp_texture_loading"
"hpp_texture_mipmap_generation"

#HPP Performance Samples
"hpp_pipeline_cache"
"hpp_swapchain_images"
"hpp_texture_compression_comparison"

#General Samples
"mobile_nerf")

# Orders the sample ids by the order list above
set(ORDERED_LIST)
Expand Down
43 changes: 43 additions & 0 deletions samples/extensions/subgroups_operations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2024, Mobica Limited
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

get_filename_component(FOLDER_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_LIST_DIR} PATH)
get_filename_component(CATEGORY_NAME ${PARENT_DIR} NAME)

add_sample(
ID ${FOLDER_NAME}
CATEGORY ${CATEGORY_NAME}
AUTHOR "Mobica"
NAME "subgroups_operations"
DESCRIPTION "Demonstrates the use of a subgroups operations feature"
SHADER_FILES_GLSL
"subgroups_operations/ocean.vert"
"subgroups_operations/ocean.frag"
"subgroups_operations/ocean.tesc"
"subgroups_operations/ocean.tese"
"subgroups_operations/fft_invert.comp"
"subgroups_operations/butterfly_precomp.comp"
"subgroups_operations/fft_tilde_h.comp"
"subgroups_operations/fft_tilde_h0.comp"
"subgroups_operations/fft_normal_map.comp"
"subgroups_operations/fft.comp"
"subgroups_operations/fft_invert_subgroups_off.comp"
"subgroups_operations/butterfly_precomp_subgroups_off.comp"
"subgroups_operations/fft_tilde_h_subgroups_off.comp"
"subgroups_operations/fft_tilde_h0_subgroups_off.comp"
"subgroups_operations/fft_normal_map_subgroups_off.comp"
"subgroups_operations/fft_subgroups_off.comp")
98 changes: 98 additions & 0 deletions samples/extensions/subgroups_operations/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
////
Copyright (c) 2024, Mobica Limited

SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 the "License";
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
////

= Subgroups Operations

== Overview

The example demonstrates the use of the feature subgroups operations. An ocean animation based on the FFT is implemented to demonstrate this feature (Fast Fourier Transform https://en.wikipedia.org/wiki/Fast_Fourier_transform).
image:image/image.png[]

Subgroups operation feature introduces a mechanism to share data between the invocations that run in parallel on a single compute unit.


== GLSL Shaders

To make full use of the feature subgroups operation, one of the following extensions must be enabled:

* `#extension GL_KHR_shader_subgroup_basic`

* `#extension GL_KHR_shader_subgroup_vote`

* `#extension GL_KHR_shader_subgroup_ballot`

* `#extension GL_KHR_shader_subgroup_arithmetic`

* `#extension GL_KHR_shader_subgroup_shuffle`

* `#extension GL_KHR_shader_subgroup_shuffle_relative`

* `#extension GL_KHR_shader_subgroup_clustered`

* `#extension GL_KHR_shader_subgroup_quad`


This sample focuse on `GL_KHR_shader_subgroup_basic` extension.
More about subgroups you can read in this article https://www.khronos.org/blog/vulkan-subgroup-tutorial.


== Enabling the Feature

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.
It is also required to enable `VK_KHR_spirv_1_4` and `VK_KHR_shader_float_controls` in addition (`VK_KHR_spirv_1_4` requires this).


To get the properties of the supported subgroups, the following should be taken:
[,cpp]
----
VkPhysicalDeviceSubgroupProperties subgroups_properties;
subgroups_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES;
subgroups_properties.pNext = VK_NULL_HANDLE;

VkPhysicalDeviceProperties2 device_properties2 = {};
device_properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
device_properties2.pNext = &subgroups_properties;
vkGetPhysicalDeviceProperties2(gpu.get_handle(), &device_properties2);
----


== Documentation

* https://docs.vulkan.org/guide/latest/subgroups.html

* https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceSubgroupProperties.html

* https://www.khronos.org/blog/vulkan-subgroup-tutorial


== Sources
The implementation was based on the following sources:

* https://tore.tuhh.de/entities/publication/1cd390d3-732b-41c1-aa2b-07b71a64edd2
* https://people.computing.clemson.edu/~jtessen/reports/papers_files/coursenotes2004.pdf
* https://github.com/achalpandeyy/OceanFFT
* https://github.com/deiss/fftocean
* https://github.com/iamyoukou/fftWater

== Authors
* Patryk Jastrzębski
* Krzysztof Dmitruk
* Seweryn Zielas
* Piotr Plenański
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading