Add ComputeParticlesTest

Renderer: Add a way to execute commands on the device
This commit is contained in:
SirLynix
2023-01-04 17:57:26 +01:00
committed by Jérôme Leclercq
parent 9e7b98a017
commit e34ba8c05d
13 changed files with 736 additions and 4 deletions

View File

@@ -320,7 +320,7 @@ namespace Nz
void VulkanCommandBufferBuilder::PostTransferBarrier()
{
m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_UNIFORM_READ_BIT);
m_commandBuffer.MemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_UNIFORM_READ_BIT);
}
void VulkanCommandBufferBuilder::SetScissor(const Recti& scissorRegion)

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
#include <Nazara/VulkanRenderer/VulkanCommandBufferBuilder.hpp>
#include <Nazara/VulkanRenderer/VulkanCommandPool.hpp>
#include <Nazara/VulkanRenderer/VulkanComputePipeline.hpp>
#include <Nazara/VulkanRenderer/VulkanRenderPass.hpp>
@@ -13,12 +14,29 @@
#include <Nazara/VulkanRenderer/VulkanTexture.hpp>
#include <Nazara/VulkanRenderer/VulkanTextureFramebuffer.hpp>
#include <Nazara/VulkanRenderer/VulkanTextureSampler.hpp>
#include <Nazara/VulkanRenderer/Wrapper/QueueHandle.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
{
VulkanDevice::~VulkanDevice() = default;
void VulkanDevice::Execute(const FunctionRef<void(CommandBufferBuilder& builder)>& callback, QueueType queueType)
{
Vk::AutoCommandBuffer commandBuffer = AllocateCommandBuffer(queueType);
if (!commandBuffer->Begin(VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT))
throw std::runtime_error("failed to begin command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode()));
VulkanCommandBufferBuilder builder(commandBuffer);
callback(builder);
if (!commandBuffer->End())
throw std::runtime_error("failed to build command buffer: " + TranslateVulkanError(commandBuffer->GetLastErrorCode()));
GetQueue(GetDefaultFamilyIndex(queueType), 0).Submit(commandBuffer);
GetQueue(GetDefaultFamilyIndex(queueType), 0).WaitIdle();
}
const RenderDeviceInfo& VulkanDevice::GetDeviceInfo() const
{
return m_renderDeviceInfo;
@@ -144,4 +162,9 @@ namespace Nz
VkFormatProperties formatProperties = GetInstance().GetPhysicalDeviceFormatProperties(GetPhysicalDevice(), vulkanFormat);
return formatProperties.optimalTilingFeatures & flags; //< Assume optimal tiling
}
void VulkanDevice::WaitForIdle()
{
Device::WaitForIdle();
}
}