128 lines
3.7 KiB
C++
128 lines
3.7 KiB
C++
/*
|
|
* 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.
|
|
*
|
|
* Copyright:
|
|
* 2016, Danny Robson <danny@nerdcruft.net>
|
|
*/
|
|
|
|
#include "./command_buffer.hpp"
|
|
|
|
#include "./event.hpp"
|
|
#include "./pipeline.hpp"
|
|
|
|
#include <cruft/util/cast.hpp>
|
|
|
|
using vk::command_buffer;
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void
|
|
command_buffer::reset (VkCommandBufferResetFlags flags)
|
|
{
|
|
auto err = vkResetCommandBuffer (id (), flags);
|
|
error::try_code (err);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void
|
|
command_buffer::begin (const VkCommandBufferBeginInfo &info)
|
|
{
|
|
auto err = vkBeginCommandBuffer (id (), &info);
|
|
error::try_code (err);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
command_buffer::begin (const VkRenderPassBeginInfo &info, VkSubpassContents contents)
|
|
{
|
|
vkCmdBeginRenderPass (id (), &info, contents);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
command_buffer::end (void)
|
|
{
|
|
auto err = vkEndCommandBuffer (id ());
|
|
error::try_code (err);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
command_buffer::end_pass (void)
|
|
{
|
|
vkCmdEndRenderPass (id ());
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
template <size_t N>
|
|
void
|
|
command_buffer::execute (const command_buffer (&buffers)[N])
|
|
{
|
|
vkCmdExecuteCOmmands (id (), N, buffers);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
command_buffer::next_subpass (const VkSubpassContents contents)
|
|
{
|
|
vkCmdNextSubpass (id (), contents);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void
|
|
command_buffer::bind (VkPipelineBindPoint point, const pipeline &p)
|
|
{
|
|
vkCmdBindPipeline (id (), point, p.id ());
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void
|
|
command_buffer::set (const event &ev, VkPipelineStageFlags flags)
|
|
{
|
|
vkCmdSetEvent (id (), ev.id (), flags);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
command_buffer::reset (const event &ev, VkPipelineStageFlags flags)
|
|
{
|
|
vkCmdResetEvent (id (), ev.id (), flags);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
command_buffer::wait (util::view<const event*> events,
|
|
VkPipelineStageFlags src_mask,
|
|
VkPipelineStageFlags dst_mask,
|
|
util::view<const VkMemoryBarrier*> VkMemoryBarriers,
|
|
util::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
|
|
util::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
|
|
{
|
|
vkCmdWaitEvents (id (),
|
|
trunc_cast<uint32_t> (events.size ()), &events.cbegin ()->id (),
|
|
src_mask, dst_mask,
|
|
trunc_cast<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
|
|
trunc_cast<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
|
|
trunc_cast<uint32_t> (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ());
|
|
}
|