From 46d5441557de26762af5b660972fa0fe39cb0985 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Wed, 18 Apr 2018 15:17:53 -0400 Subject: [PATCH] Vulkan: Implement compute CommandBuffer operations --- src/backend/vulkan/CommandBufferVk.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/backend/vulkan/CommandBufferVk.cpp b/src/backend/vulkan/CommandBufferVk.cpp index 4272825ac2..a1ce47626d 100644 --- a/src/backend/vulkan/CommandBufferVk.cpp +++ b/src/backend/vulkan/CommandBufferVk.cpp @@ -17,6 +17,7 @@ #include "backend/Commands.h" #include "backend/vulkan/BindGroupVk.h" #include "backend/vulkan/BufferVk.h" +#include "backend/vulkan/ComputePipelineVk.h" #include "backend/vulkan/FramebufferVk.h" #include "backend/vulkan/PipelineLayoutVk.h" #include "backend/vulkan/RenderPassVk.h" @@ -289,6 +290,21 @@ namespace backend { namespace vulkan { // Do nothing because the single subpass is ended in vkEndRenderPass } break; + case Command::BeginComputePass: { + mCommands.NextCommand(); + descriptorSets.OnBeginPass(); + } break; + + case Command::EndComputePass: { + mCommands.NextCommand(); + } break; + + case Command::Dispatch: { + DispatchCmd* dispatch = mCommands.NextCommand(); + descriptorSets.Flush(device, commands, VK_PIPELINE_BIND_POINT_COMPUTE); + device->fn.CmdDispatch(commands, dispatch->x, dispatch->y, dispatch->z); + } break; + case Command::SetBindGroup: { SetBindGroupCmd* cmd = mCommands.NextCommand(); VkDescriptorSet set = ToBackend(cmd->group.Get())->GetHandle(); @@ -319,6 +335,15 @@ namespace backend { namespace vulkan { commands, indexBuffer, static_cast(cmd->offset), indexType); } break; + case Command::SetComputePipeline: { + SetComputePipelineCmd* cmd = mCommands.NextCommand(); + ComputePipeline* pipeline = ToBackend(cmd->pipeline).Get(); + + device->fn.CmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_COMPUTE, + pipeline->GetHandle()); + descriptorSets.OnPipelineLayoutChange(ToBackend(pipeline->GetLayout())); + } break; + case Command::SetRenderPipeline: { SetRenderPipelineCmd* cmd = mCommands.NextCommand(); RenderPipeline* pipeline = ToBackend(cmd->pipeline).Get();