16 case VK_IMAGE_LAYOUT_UNDEFINED:
18 case VK_IMAGE_LAYOUT_PREINITIALIZED:
19 return VK_ACCESS_HOST_WRITE_BIT;
20 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
21 return VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
22 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
23 return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
24 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
25 return VK_ACCESS_TRANSFER_READ_BIT;
26 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
27 return VK_ACCESS_TRANSFER_WRITE_BIT;
28 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
29 return VK_ACCESS_SHADER_READ_BIT;
38 case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
39 return VK_ACCESS_TRANSFER_WRITE_BIT;
40 case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
41 return VK_ACCESS_TRANSFER_READ_BIT;
42 case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
43 return VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
44 case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
45 return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
46 case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
47 return VK_ACCESS_SHADER_READ_BIT;
55 std::vector<VkMemoryBarrier>& vkMemoryBarriers,
56 const std::vector<CommandBuffer::CmdPipelineBarrier::MemoryBarrier>& memoryBarriers
58 vkMemoryBarriers.resize(memoryBarriers.size());
59 for (uint8_t i = 0; i < memoryBarriers.size(); ++i) {
60 vkMemoryBarriers[i].sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
61 vkMemoryBarriers[i].pNext =
nullptr;
62 vkMemoryBarriers[i].srcAccessMask = memoryBarriers[i].srcAccessMask;
63 vkMemoryBarriers[i].dstAccessMask = memoryBarriers[i].dstAccessMask;
68 std::vector<VkBufferMemoryBarrier>& vkBufferMemoryBarriers,
69 const std::vector<CommandBuffer::CmdPipelineBarrier::BufferMemoryBarrier>& bufferMemoryBarriers
71 vkBufferMemoryBarriers.resize(bufferMemoryBarriers.size());
72 for (uint8_t i = 0; i < bufferMemoryBarriers.size(); ++i){
73 vkBufferMemoryBarriers[i].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
74 vkBufferMemoryBarriers[i].pNext =
nullptr;
75 vkBufferMemoryBarriers[i].srcAccessMask = bufferMemoryBarriers[i].srcAccessMask;
76 vkBufferMemoryBarriers[i].dstAccessMask = bufferMemoryBarriers[i].dstAccessMask;
77 vkBufferMemoryBarriers[i].srcQueueFamilyIndex = bufferMemoryBarriers[i].srcQueueFamilyIndex;
78 vkBufferMemoryBarriers[i].dstQueueFamilyIndex = bufferMemoryBarriers[i].dstQueueFamilyIndex;
79 vkBufferMemoryBarriers[i].buffer =
static_cast<VkBuffer
>(*bufferMemoryBarriers[i].buffer);
80 vkBufferMemoryBarriers[i].offset = bufferMemoryBarriers[i].offset;
81 vkBufferMemoryBarriers[i].size = bufferMemoryBarriers[i].size;
86 std::vector<VkImageMemoryBarrier>& vkImageMemoryBarriers,
87 const std::vector<CommandBuffer::CmdPipelineBarrier::ImageMemoryBarrier>& imageMemoryBarriers
89 vkImageMemoryBarriers.resize(imageMemoryBarriers.size());
90 for (uint8_t i = 0; i < imageMemoryBarriers.size(); ++i){
91 vkImageMemoryBarriers[i].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
92 vkImageMemoryBarriers[i].pNext =
nullptr;
93 vkImageMemoryBarriers[i].srcAccessMask = imageMemoryBarriers[i].srcAccessMask;
94 vkImageMemoryBarriers[i].dstAccessMask = imageMemoryBarriers[i].dstAccessMask;
95 vkImageMemoryBarriers[i].oldLayout = imageMemoryBarriers[i].oldLayout;
96 vkImageMemoryBarriers[i].newLayout = imageMemoryBarriers[i].newLayout;
97 vkImageMemoryBarriers[i].srcQueueFamilyIndex = imageMemoryBarriers[i].srcQueueFamilyIndex;
98 vkImageMemoryBarriers[i].dstQueueFamilyIndex = imageMemoryBarriers[i].dstQueueFamilyIndex;
99 vkImageMemoryBarriers[i].image =
static_cast<VkImage
>(*imageMemoryBarriers[i].image);
100 vkImageMemoryBarriers[i].subresourceRange.aspectMask = imageMemoryBarriers[i].subresourceRange.aspectMask;
101 vkImageMemoryBarriers[i].subresourceRange.baseMipLevel = imageMemoryBarriers[i].subresourceRange.baseMipLevel;
102 vkImageMemoryBarriers[i].subresourceRange.levelCount = imageMemoryBarriers[i].subresourceRange.levelCount;
103 vkImageMemoryBarriers[i].subresourceRange.baseArrayLayer = imageMemoryBarriers[i].subresourceRange.baseArrayLayer;
104 vkImageMemoryBarriers[i].subresourceRange.layerCount = imageMemoryBarriers[i].subresourceRange.layerCount;
106 if (vkImageMemoryBarriers[i].srcAccessMask == 0xFFFFFFFF) {
109 if (vkImageMemoryBarriers[i].dstAccessMask == 0xFFFFFFFF) {
113 if (vkImageMemoryBarriers[i].srcAccessMask == 0 &&
114 vkImageMemoryBarriers[i].newLayout == VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) {
115 vkImageMemoryBarriers[i].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
122 VkDependencyFlags dependencyFlags,
123 VkPipelineStageFlags srcStageMask,
124 VkPipelineStageFlags dstStageMask
127 std::vector<VkMemoryBarrier> vkMemoryBarriers;
128 std::vector<VkBufferMemoryBarrier> vkBufferMemoryBarriers;
129 std::vector<VkImageMemoryBarrier> vkImageMemoryBarriers;
135 vkCmdPipelineBarrier(
140 static_cast<uint32_t>(vkMemoryBarriers.size()),
141 vkMemoryBarriers.data(),
142 static_cast<uint32_t
>(vkBufferMemoryBarriers.size()),
143 vkBufferMemoryBarriers.data(),
144 static_cast<uint32_t
>(vkImageMemoryBarriers.size()),
145 vkImageMemoryBarriers.data()
153 static_cast<VkPipeline>(pipeline)
158 const std::vector<const API::Buffer*>& buffers,
159 const std::vector<VkDeviceSize>& offsets,
160 uint32_t firstBinding
164 std::vector<VkBuffer> vkBuffers(buffers.size());
166 std::begin(buffers), std::end(buffers), std::begin(vkBuffers),
167 [](
const API::Buffer* buffer){
return static_cast<VkBuffer
>(*buffer); }
170 vkCmdBindVertexBuffers(
173 static_cast<uint32_t>(vkBuffers.size()),
180 vkCmdBindIndexBuffer(
182 static_cast<VkBuffer>(buffer),
192 static_cast<uint32_t>(viewports.size()),
201 static_cast<uint32_t>(scissors.size()),
static void setupMemoryBarriers(std::vector< VkMemoryBarrier > &vkMemoryBarriers, const std::vector< CommandBuffer::CmdPipelineBarrier::MemoryBarrier > &memoryBarriers)
VkShaderStageFlags stageFlags
std::vector< ImageMemoryBarrier > imageMemoryBarriers
std::vector< MemoryBarrier > memoryBarriers
static VkAccessFlags getImageDstAccessMask(VkImageLayout newLayout)
void setBlendConstants(const float blendConstants[4]) const
void pipelineBarrier(const CmdPipelineBarrier ¶meters, VkDependencyFlags dependencyFlags=VK_DEPENDENCY_BY_REGION_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) const
static void setupBufferBarriers(std::vector< VkBufferMemoryBarrier > &vkBufferMemoryBarriers, const std::vector< CommandBuffer::CmdPipelineBarrier::BufferMemoryBarrier > &bufferMemoryBarriers)
void bindPipeline(const API::GraphicsPipeline &pipeline, VkPipelineBindPoint pipelineBindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS) const
void bindIndexBuffer(const API::Buffer &buffer, VkIndexType indexType, VkDeviceSize offset=0) const
std::vector< BufferMemoryBarrier > bufferMemoryBarriers
void setScissor(const std::vector< VkRect2D > &scissors, uint32_t firstScissor=0) const
void setViewport(const std::vector< VkViewport > &viewports, uint32_t firstViewport=0) const
void bindVertexBuffers(const std::vector< const API::Buffer *> &buffers, const std::vector< VkDeviceSize > &offsets, uint32_t firstBinding=0) const
void pushConstants(const CmdPushConstants ¶meters) const
static VkAccessFlags getImageSrcAccessMask(VkImageLayout oldLayout)
VkCommandBuffer _commandBuffer
static void setupImageBarriers(std::vector< VkImageMemoryBarrier > &vkImageMemoryBarriers, const std::vector< CommandBuffer::CmdPipelineBarrier::ImageMemoryBarrier > &imageMemoryBarriers)