Skip to content

Commit

Permalink
Transcoded version of api sample oit_linked_lists based on Vulkan-Hpp. (
Browse files Browse the repository at this point in the history
  • Loading branch information
asuessenbach authored Jan 15, 2024
1 parent e20de83 commit 27d1c21
Show file tree
Hide file tree
Showing 11 changed files with 703 additions and 21 deletions.
27 changes: 14 additions & 13 deletions antora/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,29 @@
* xref:framework/README.adoc[Sample framework]
* xref:samples/api/README.adoc[Api usage samples]
** xref:samples/api/compute_nbody/README.adoc[Compute N-body]
*** xref:samples/api/hpp_compute_nbody/README.adoc[Compute N-body (Vulkan.hpp)]
*** xref:samples/api/hpp_compute_nbody/README.adoc[Compute N-body (Vulkan-Hpp)]
** xref:samples/api/dynamic_uniform_buffers/README.adoc[Dynamic uniform buffers]
*** xref:samples/api/hpp_dynamic_uniform_buffers/README.adoc[Dynamic Uniform Buffers (Vulkan.hpp)]
*** xref:samples/api/hpp_dynamic_uniform_buffers/README.adoc[Dynamic Uniform Buffers (Vulkan-Hpp)]
** xref:samples/api/hdr/README.adoc[HDR]
*** xref:samples/api/hpp_hdr/README.adoc[HDR (Vulkan.hpp)]
*** xref:samples/api/hpp_hdr/README.adoc[HDR (Vulkan-Hpp)]
** xref:samples/api/hello_triangle/README.adoc[Hello Triangle]
*** xref:samples/api/hpp_hello_triangle/README.adoc[Hello Triangle (Vulkan.hpp)]
*** xref:samples/api/hpp_hello_triangle/README.adoc[Hello Triangle (Vulkan-Hpp)]
** xref:samples/api/hlsl_shaders/README.adoc[HLSL Shaders]
*** xref:samples/api/hpp_hlsl_shaders/README.adoc[HLSL Shaders (Vulkan.hpp)]
*** xref:samples/api/hpp_hlsl_shaders/README.adoc[HLSL Shaders (Vulkan-Hpp)]
** xref:samples/api/instancing/README.adoc[Instancing]
*** xref:samples/api/hpp_instancing/README.adoc[Instancing (Vulkan.hpp)]
*** xref:samples/api/hpp_instancing/README.adoc[Instancing (Vulkan-Hpp)]
** xref:samples/api/separate_image_sampler/README.adoc[Separate image sampler]
*** xref:samples/api/hpp_separate_image_sampler/README.adoc[Separate image sampler (Vulkan.hpp)]
*** xref:samples/api/hpp_separate_image_sampler/README.adoc[Separate image sampler (Vulkan-Hpp)]
** xref:samples/api/terrain_tessellation/README.adoc[Terrain tessellation]
*** xref:samples/api/hpp_terrain_tessellation/README.adoc[Terrain tessellation (Vulkan.hpp)]
*** xref:samples/api/hpp_terrain_tessellation/README.adoc[Terrain tessellation (Vulkan-Hpp)]
** xref:samples/api/texture_loading/README.adoc[Texture loading]
*** xref:samples/api/hpp_texture_loading/README.adoc[Texture loading (Vulkan.hpp)]
*** xref:samples/api/hpp_texture_loading/README.adoc[Texture loading (Vulkan-Hpp)]
** xref:samples/api/texture_mipmap_generation/README.adoc[Texture mipmap generation]
*** xref:samples/api/hpp_texture_mipmap_generation/README.adoc[Texture mipmap generation (Vulkan.hpp)]
*** xref:samples/api/hpp_texture_mipmap_generation/README.adoc[Texture mipmap generation (Vulkan-Hpp)]
** xref:samples/api/timestamp_queries/README.adoc[Timestamp queries]
*** xref:samples/api/hpp_timestamp_queries/README.adoc[Timestamp queries (Vulkan.hpp)]
*** xref:samples/api/hpp_timestamp_queries/README.adoc[Timestamp queries (Vulkan-Hpp)]
** xref:samples/api/oit_linked_lists/README.adoc[OIT linked lists]
** xref:samples/api/hpp_oit_linked_lists/README.adoc[OIT linked lists (Vulkan-Hpp)]
* xref:samples/extensions/README.adoc[Extension usage samples]
** xref:samples/extensions/buffer_device_address/README.adoc[Buffer device address]
** xref:samples/extensions/calibrated_timestamps/README.adoc[Calibrated timestamps]
Expand Down Expand Up @@ -92,13 +93,13 @@
** xref:samples/performance/multi_draw_indirect/README.adoc[Multi draw indirect]
** xref:samples/performance/pipeline_barriers/README.adoc[Pipeline barriers]
** xref:samples/performance/pipeline_cache/README.adoc[Pipeline cache]
*** xref:samples/performance/hpp_pipeline_cache/README.adoc[Pipeline cache (Vulkan.hpp)]
*** xref:samples/performance/hpp_pipeline_cache/README.adoc[Pipeline cache (Vulkan-Hpp)]
** xref:samples/performance/render_passes/README.adoc[Render passes]
** xref:samples/performance/specialization_constants/README.adoc[Specialization constants]
** xref:samples/performance/subpasses/README.adoc[Subpasses]
** xref:samples/performance/surface_rotation/README.adoc[Surface rotation]
** xref:samples/performance/swapchain_images/README.adoc[Swapchain images]
*** xref:samples/performance/hpp_swapchain_images/README.adoc[Swapchain images (Vulkan.hpp)]
*** xref:samples/performance/hpp_swapchain_images/README.adoc[Swapchain images (Vulkan-Hpp)]
** xref:samples/performance/texture_compression_basisu/README.adoc[Texture compression basisu]
** xref:samples/performance/texture_compression_comparison/README.adoc[Texture compression comparison]
** xref:samples/performance/wait_idle/README.adoc[Wait idle]
Expand Down
25 changes: 23 additions & 2 deletions framework/common/hpp_vk_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ inline void image_layout_transition(vk::CommandBuffer command_buffer,
vk::ImageLayout old_layout,
vk::ImageLayout new_layout)
{
vkb::image_layout_transition(command_buffer,
vkb::image_layout_transition(static_cast<VkCommandBuffer>(command_buffer),
static_cast<VkImage>(image),
static_cast<VkImageLayout>(old_layout),
static_cast<VkImageLayout>(new_layout));
Expand All @@ -124,13 +124,34 @@ inline void image_layout_transition(vk::CommandBuffer command_buffer,
vk::ImageLayout new_layout,
vk::ImageSubresourceRange subresource_range)
{
vkb::image_layout_transition(command_buffer,
vkb::image_layout_transition(static_cast<VkCommandBuffer>(command_buffer),
static_cast<VkImage>(image),
static_cast<VkImageLayout>(old_layout),
static_cast<VkImageLayout>(new_layout),
static_cast<VkImageSubresourceRange>(subresource_range));
}

inline void image_layout_transition(vk::CommandBuffer command_buffer,
vk::Image image,
vk::PipelineStageFlags src_stage_mask,
vk::PipelineStageFlags dst_stage_mask,
vk::AccessFlags src_access_mask,
vk::AccessFlags dst_access_mask,
vk::ImageLayout old_layout,
vk::ImageLayout new_layout,
vk::ImageSubresourceRange const &subresource_range)
{
vkb::image_layout_transition(static_cast<VkCommandBuffer>(command_buffer),
static_cast<VkImage>(image),
static_cast<VkPipelineStageFlags>(src_stage_mask),
static_cast<VkPipelineStageFlags>(dst_stage_mask),
static_cast<VkAccessFlags>(src_access_mask),
static_cast<VkAccessFlags>(dst_access_mask),
static_cast<VkImageLayout>(old_layout),
static_cast<VkImageLayout>(new_layout),
static_cast<VkImageSubresourceRange const &>(subresource_range));
}

inline vk::SurfaceFormatKHR select_surface_format(vk::PhysicalDevice gpu,
vk::SurfaceKHR surface,
std::vector<vk::Format> const &preferred_formats = {
Expand Down
4 changes: 2 additions & 2 deletions framework/hpp_api_vulkan_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ std::unique_ptr<vkb::scene_graph::components::HPPSubMesh> HPPApiVulkanSample::lo
return model;
}

void HPPApiVulkanSample::draw_model(std::unique_ptr<vkb::scene_graph::components::HPPSubMesh> &model, vk::CommandBuffer command_buffer)
void HPPApiVulkanSample::draw_model(std::unique_ptr<vkb::scene_graph::components::HPPSubMesh> &model, vk::CommandBuffer command_buffer, uint32_t instance_count)
{
vk::DeviceSize offset = 0;

Expand All @@ -1043,7 +1043,7 @@ void HPPApiVulkanSample::draw_model(std::unique_ptr<vkb::scene_graph::components

command_buffer.bindVertexBuffers(0, vertex_buffer.get_handle(), offset);
command_buffer.bindIndexBuffer(index_buffer.get_handle(), 0, model->get_index_type());
command_buffer.drawIndexed(model->vertex_indices, 1, 0, 0, 0);
command_buffer.drawIndexed(model->vertex_indices, instance_count, 0, 0, 0);
}

void HPPApiVulkanSample::with_command_buffer(const std::function<void(vk::CommandBuffer command_buffer)> &f, vk::Semaphore signalSemaphore)
Expand Down
3 changes: 2 additions & 1 deletion framework/hpp_api_vulkan_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ class HPPApiVulkanSample : public vkb::HPPVulkanSample
* @brief Records the necessary drawing commands to a command buffer
* @param model The model to draw
* @param command_buffer The command buffer to record to
* @param instance_count The number of instances (default: 1)
*/
void draw_model(std::unique_ptr<vkb::scene_graph::components::HPPSubMesh> &model, vk::CommandBuffer command_buffer);
void draw_model(std::unique_ptr<vkb::scene_graph::components::HPPSubMesh> &model, vk::CommandBuffer command_buffer, uint32_t instance_count = 1);

/**
* @brief Synchronously execute a block code within a command buffer, then submit the command buffer and wait for completion.
Expand Down
1 change: 1 addition & 0 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ set(ORDER_LIST
"hpp_hello_triangle"
"hpp_hlsl_shaders"
"hpp_instancing"
"hpp_oit_linked_lists"
"hpp_separate_image_sampler"
"hpp_terrain_tessellation"
"hpp_texture_loading"
Expand Down
4 changes: 4 additions & 0 deletions samples/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ A transcoded version of the API sample <<hlsl_shaders,HLSL Shaders>> that illust

A transcoded version of the API sample <<instancing,Instancing>> that illustrates the usage of the C{pp} bindings of Vulkan provided by vulkan.hpp.

=== xref:./api/hpp_oit_linked_lists/README.adoc[HPP OIT Linked Lists]

A transcoded version of the API sample <<oit_linked_lists,OIT Linked Lists>> that illustrates the usage of the C{pp} bindings of Vulkan provided by vulkan.hpp.

=== xref:./api/hpp_separate_image_sampler/README.adoc[HPP Separate image sampler]

A transcoded version of the API sample <<separate_image_sampler,Separate image sampler>> that illustrates the usage of the C{pp} bindings of vulkan provided by vulkan.hpp.
Expand Down
35 changes: 35 additions & 0 deletions samples/api/hpp_oit_linked_lists/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved.
#
# 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 "Google"
NAME "hpp_oit_linked_lists"
DESCRIPTION "Order-independent transparency using per-pixel ordered linked lists, using vulkan.hpp"
SHADER_FILES_GLSL
"oit_linked_lists/background.frag"
"oit_linked_lists/combine.frag"
"oit_linked_lists/combine.vert"
"oit_linked_lists/fullscreen.vert"
"oit_linked_lists/gather.frag"
"oit_linked_lists/gather.vert")

26 changes: 26 additions & 0 deletions samples/api/hpp_oit_linked_lists/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
////
- Copyright (c) 2023, NVIDIA
-
- 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.
-
////
= Order-independent transparency with per-pixel ordered linked lists with Vulkan-Hpp

ifdef::site-gen-antora[]
TIP: The source for this sample can be found in the https://github.com/KhronosGroup/Vulkan-Samples/tree/main/samples/api/hpp_oit_linked_lists[Khronos Vulkan samples github repository].
endif::[]

NOTE: This is a transcoded version of the API sample https://github.com/KhronosGroup/Vulkan-Samples/tree/main/samples/api/oit_linked_lists[OIT linked lists] that illustrates the usage of the C{pp} bindings of vulkan provided by vulkan.hpp. Please see there for the documentation on this sample.
Loading

0 comments on commit 27d1c21

Please sign in to comment.