Lluvia
ll::CommandBuffer Class Reference

Class for command buffer. More...

#include <CommandBuffer.h>

Public Member Functions

 CommandBuffer ()=delete
 
 CommandBuffer (const CommandBuffer &cmdBuffer)=delete
 
 CommandBuffer (CommandBuffer &&cmdBuffer)=delete
 
 CommandBuffer (const std::shared_ptr< ll::vulkan::Device > &device)
 
 ~CommandBuffer ()
 
CommandBufferoperator= (const CommandBuffer &cmdBuffer)=delete
 
CommandBufferoperator= (CommandBuffer &&cmdBuffer)=delete
 
const vk::CommandBuffer & getVkCommandBuffer () const noexcept
 
void begin ()
 begins recording. More...
 
void end ()
 ends recording. More...
 
void run (const ll::ComputeNode &node)
 Records running a ll::ComputeNode. More...
 
void run (const ll::ContainerNode &node)
 Records running a ll::ContainerNode. More...
 
void copyBuffer (const ll::Buffer &src, const ll::Buffer &dst)
 Copies src buffer into dst. More...
 
void copyBufferToImage (const ll::Buffer &src, const ll::Image &dst)
 Copies the content of src buffer into dst image. More...
 
void copyImageToBuffer (const ll::Image &src, const ll::Buffer &dst)
 Copies the content of src image into dst buffer. More...
 
void copyImageToImage (const ll::Image &src, const ll::Image &dst)
 Copies the content of src image into dst image. More...
 
void changeImageLayout (ll::Image &image, const ll::ImageLayout newLayout)
 Change image layout. More...
 
void changeImageLayout (ll::ImageView &imageView, const ll::ImageLayout newLayout)
 Change imageView underlying image layout. More...
 
void memoryBarrier ()
 Adds a memory barrier. More...
 
void clearImage (ll::Image &image)
 Clears the pixels of an image to zero. More...
 
void clearImage (ll::ImageView &imageVide)
 Clears the pixels of an image to zero. More...
 
void durationStart (ll::Duration &duration)
 Starts recording the elapsed time between two points. More...
 
void durationEnd (ll::Duration &duration)
 Stops recording the elapsed time between two points. More...
 

Detailed Description

Class for command buffer.

A command buffer object records operations to be submitted to the Vulkan device. Such operations include running a ll::ComputeNode, copying ll::Buffer objects, changing layout of ll::Image objects or creating memory barriers.

ll::CommandBuffers are created through ll::Session objects.

auto session = ll::Session::create();
auto cmdBuffer = session->createCommandBuffer();
cmdBuffer->begin();
cmdBuffer->changeImageLayout(*image, vk::ImageLayout::eTransferDstOptimal);
cmdBuffer->copyBufferToImage(*stageBuffer, *image);
cmdBuffer->changeImageLayout(*image, vk::ImageLayout::eGeneral);
// bind parameters to a ll::ComputeNode object.
// the image view can only be bound after the underlying
// image is in the correct layout.
node->bind(0, imageView);
node->bind(1, outputBuffer);
cmdBuffer->run(*node);
// finish recording and submit for execution
cmdBuffer->end();
session->run(cmdBuffer);
static std::shared_ptr< ll::Session > create()
Creates a new ll::Session object.

Constructor & Destructor Documentation

◆ CommandBuffer() [1/4]

ll::CommandBuffer::CommandBuffer ( )
delete

◆ CommandBuffer() [2/4]

ll::CommandBuffer::CommandBuffer ( const CommandBuffer cmdBuffer)
delete

◆ CommandBuffer() [3/4]

ll::CommandBuffer::CommandBuffer ( CommandBuffer &&  cmdBuffer)
delete

◆ CommandBuffer() [4/4]

ll::CommandBuffer::CommandBuffer ( const std::shared_ptr< ll::vulkan::Device > &  device)

◆ ~CommandBuffer()

ll::CommandBuffer::~CommandBuffer ( )

Member Function Documentation

◆ begin()

void ll::CommandBuffer::begin ( )

begins recording.

This method should be called before any record operation. Otherwise the behaviour is undefined.

◆ changeImageLayout() [1/2]

void ll::CommandBuffer::changeImageLayout ( ll::Image image,
const ll::ImageLayout  newLayout 
)

Change image layout.

The actual change in image layout is performed when this command buffer is submitted to execution. However, calling image.getLayout() right after this call will return the new layout value.

This is necessary to keep track of the current image layout of image parameter after this call.

Parameters
imageThe image
[in]newLayoutThe new layout

◆ changeImageLayout() [2/2]

void ll::CommandBuffer::changeImageLayout ( ll::ImageView imageView,
const ll::ImageLayout  newLayout 
)

Change imageView underlying image layout.

The actual change in image layout is performed when this command buffer is submitted to execution. However, calling imageView.getImage()->getLayout() right after this call will return the new layout value.

This is necessary to keep track of the current image layout of image parameter after this call.

Parameters
imageViewThe image view.
[in]newLayoutThe new layout

◆ clearImage() [1/2]

void ll::CommandBuffer::clearImage ( ll::Image image)

Clears the pixels of an image to zero.

◆ clearImage() [2/2]

void ll::CommandBuffer::clearImage ( ll::ImageView imageVide)

Clears the pixels of an image to zero.

◆ copyBuffer()

void ll::CommandBuffer::copyBuffer ( const ll::Buffer src,
const ll::Buffer dst 
)

Copies src buffer into dst.

The parameters must satisfy dst.getSize() >= src.getSize().

Parameters
[in]srcThe source buffer.
[in]dstThe destination buffer.
Exceptions
std::system_errowith error code ll::ErrorCode::BufferCopyError if dst.getSize() < src.getSize().

◆ copyBufferToImage()

void ll::CommandBuffer::copyBufferToImage ( const ll::Buffer src,
const ll::Image dst 
)

Copies the content of src buffer into dst image.

TODO:** assert image size.

Parameters
[in]srcThe source
[in]dstThe destination

◆ copyImageToBuffer()

void ll::CommandBuffer::copyImageToBuffer ( const ll::Image src,
const ll::Buffer dst 
)

Copies the content of src image into dst buffer.

TODO:* assert buffer size.

Parameters
[in]srcThe source
[in]dstThe destination

◆ copyImageToImage()

void ll::CommandBuffer::copyImageToImage ( const ll::Image src,
const ll::Image dst 
)

Copies the content of src image into dst image.

Parameters
[in]srcThe source
[in]dstThe destination

◆ durationEnd()

void ll::CommandBuffer::durationEnd ( ll::Duration duration)

Stops recording the elapsed time between two points.

Parameters
durationThe duration object.

◆ durationStart()

void ll::CommandBuffer::durationStart ( ll::Duration duration)

Starts recording the elapsed time between two points.

Parameters
durationThe duration object.

◆ end()

void ll::CommandBuffer::end ( )

ends recording.

Any following call to recording methods after this call have undefined behavior.

◆ getVkCommandBuffer()

const vk::CommandBuffer& ll::CommandBuffer::getVkCommandBuffer ( ) const
noexcept

◆ memoryBarrier()

void ll::CommandBuffer::memoryBarrier ( )

Adds a memory barrier.

TODO:* details.

◆ operator=() [1/2]

CommandBuffer& ll::CommandBuffer::operator= ( CommandBuffer &&  cmdBuffer)
delete

◆ operator=() [2/2]

CommandBuffer& ll::CommandBuffer::operator= ( const CommandBuffer cmdBuffer)
delete

◆ run() [1/2]

void ll::CommandBuffer::run ( const ll::ComputeNode node)

Records running a ll::ComputeNode.

Parameters
[in]nodeThe node

◆ run() [2/2]

void ll::CommandBuffer::run ( const ll::ContainerNode node)

Records running a ll::ContainerNode.

Parameters
[in]nodeThe node

The documentation for this class was generated from the following file: