Skip to content

Commit

Permalink
Use more framework functionality in mobile_nerf (#946)
Browse files Browse the repository at this point in the history
* Add additional one-off command-buffer support

* Use framework code for mobile_nerf
  • Loading branch information
jherico authored Feb 27, 2024
1 parent 6683c7f commit dc50ad6
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 268 deletions.
13 changes: 12 additions & 1 deletion framework/api_vulkan_sample.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2019-2023, Sascha Willems
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -1316,3 +1316,14 @@ void ApiVulkanSample::with_command_buffer(const std::function<void(VkCommandBuff
f(command_buffer);
device->flush_command_buffer(command_buffer, queue, true, signalSemaphore);
}

void ApiVulkanSample::with_vkb_command_buffer(const std::function<void(vkb::CommandBuffer &command_buffer)> &f)
{
auto &cmd = device->request_command_buffer();
cmd.begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, VK_NULL_HANDLE);
f(cmd);
cmd.end();
auto &queue = device->get_queue_by_flags(VK_QUEUE_GRAPHICS_BIT, 0);
queue.submit(cmd, device->request_fence());
device->get_fence_pool().wait();
}
8 changes: 7 additions & 1 deletion framework/api_vulkan_sample.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2019-2023, Sascha Willems
/* Copyright (c) 2019-2024, Sascha Willems
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -254,6 +254,12 @@ class ApiVulkanSample : public vkb::VulkanSample
*/
void with_command_buffer(const std::function<void(VkCommandBuffer command_buffer)> &f, VkSemaphore signalSemaphore = VK_NULL_HANDLE);

/**
* @brief Synchronously execute a block code within a command buffer vkb wrapper, then submit the command buffer and wait for completion.
* @param f a block of code which is passed a command buffer which is already in the begin state.
*/
void with_vkb_command_buffer(const std::function<void(vkb::CommandBuffer &command_buffer)> &f);

public:
/**
* @brief Called when a view change occurs, can be overriden in derived samples to handle updating uniforms
Expand Down
Loading

0 comments on commit dc50ad6

Please sign in to comment.