Flutter Impeller
impeller::BlitCopyBufferToTextureCommandVK Struct Reference

#include <blit_command_vk.h>

Inheritance diagram for impeller::BlitCopyBufferToTextureCommandVK:
impeller::BlitCopyBufferToTextureCommand impeller::BlitEncodeVK impeller::BlitCommand impeller::BackendCast< BlitEncodeVK, BlitCommand >

Public Member Functions

 ~BlitCopyBufferToTextureCommandVK () override
 
std::string GetLabel () const override
 
bool Encode (CommandEncoderVK &encoder) const override
 
- Public Member Functions inherited from impeller::BlitEncodeVK
virtual ~BlitEncodeVK ()
 

Additional Inherited Members

- Static Public Member Functions inherited from impeller::BackendCast< BlitEncodeVK, BlitCommand >
static BlitEncodeVKCast (BlitCommand &base)
 
static const BlitEncodeVKCast (const BlitCommand &base)
 
static BlitEncodeVKCast (BlitCommand *base)
 
static const BlitEncodeVKCast (const BlitCommand *base)
 
- Public Attributes inherited from impeller::BlitCopyBufferToTextureCommand
BufferView source
 
std::shared_ptr< Texturedestination
 
IPoint destination_origin
 
- Public Attributes inherited from impeller::BlitCommand
std::string label
 

Detailed Description

Definition at line 47 of file blit_command_vk.h.

Constructor & Destructor Documentation

◆ ~BlitCopyBufferToTextureCommandVK()

impeller::BlitCopyBufferToTextureCommandVK::~BlitCopyBufferToTextureCommandVK ( )
overridedefault

Member Function Documentation

◆ Encode()

bool impeller::BlitCopyBufferToTextureCommandVK::Encode ( CommandEncoderVK encoder) const
overridevirtual

Implements impeller::BlitEncodeVK.

Definition at line 187 of file blit_command_vk.cc.

187  {
188  const auto& cmd_buffer = encoder.GetCommandBuffer();
189 
190  // cast destination to TextureVK
191  const auto& dst = TextureVK::Cast(*destination);
192  const auto& src = DeviceBufferVK::Cast(*source.buffer);
193 
194  if (!encoder.Track(source.buffer) || !encoder.Track(destination)) {
195  return false;
196  }
197 
198  BarrierVK dst_barrier;
199  dst_barrier.cmd_buffer = cmd_buffer;
200  dst_barrier.new_layout = vk::ImageLayout::eTransferDstOptimal;
201  dst_barrier.src_access = {};
202  dst_barrier.src_stage = vk::PipelineStageFlagBits::eTopOfPipe;
203  dst_barrier.dst_access =
204  vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eTransferWrite;
205  dst_barrier.dst_stage = vk::PipelineStageFlagBits::eFragmentShader |
206  vk::PipelineStageFlagBits::eTransfer;
207 
208  vk::BufferImageCopy image_copy;
209  image_copy.setBufferOffset(source.range.offset);
210  image_copy.setBufferRowLength(0);
211  image_copy.setBufferImageHeight(0);
212  image_copy.setImageSubresource(
213  vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
214  image_copy.setImageOffset(
215  vk::Offset3D(destination_origin.x, destination_origin.y, 0));
216  image_copy.setImageExtent(vk::Extent3D(destination->GetSize().width,
217  destination->GetSize().height, 1));
218 
219  if (!dst.SetLayout(dst_barrier)) {
220  VALIDATION_LOG << "Could not encode layout transition.";
221  return false;
222  }
223 
224  cmd_buffer.copyBufferToImage(src.GetBuffer(), //
225  dst.GetImage(), //
226  dst_barrier.new_layout, //
227  image_copy //
228  );
229 
230  return true;
231 }

References impeller::BufferView::buffer, impeller::BackendCast< DeviceBufferVK, DeviceBuffer >::Cast(), impeller::BackendCast< TextureVK, Texture >::Cast(), impeller::BarrierVK::cmd_buffer, impeller::BlitCopyBufferToTextureCommand::destination, impeller::BlitCopyBufferToTextureCommand::destination_origin, impeller::BarrierVK::dst_access, impeller::BarrierVK::dst_stage, impeller::CommandEncoderVK::GetCommandBuffer(), impeller::BarrierVK::new_layout, impeller::Range::offset, impeller::BufferView::range, impeller::BlitCopyBufferToTextureCommand::source, impeller::BarrierVK::src_access, impeller::BarrierVK::src_stage, impeller::CommandEncoderVK::Track(), VALIDATION_LOG, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

Referenced by impeller::testing::TEST().

◆ GetLabel()

std::string impeller::BlitCopyBufferToTextureCommandVK::GetLabel ( ) const
overridevirtual

Implements impeller::BlitEncodeVK.

Definition at line 183 of file blit_command_vk.cc.

183  {
184  return label;
185 }

References impeller::BlitCommand::label.


The documentation for this struct was generated from the following files:
impeller::TPoint::y
Type y
Definition: point.h:31
impeller::Range::offset
size_t offset
Definition: range.h:15
impeller::BufferView::range
Range range
Definition: buffer_view.h:17
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:15
impeller::BlitCopyBufferToTextureCommand::source
BufferView source
Definition: blit_command.h:33
impeller::TPoint::x
Type x
Definition: point.h:30
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:73
impeller::BackendCast< TextureVK, Texture >::Cast
static TextureVK & Cast(Texture &base)
Definition: backend_cast.h:13
impeller::BufferView::buffer
std::shared_ptr< const DeviceBuffer > buffer
Definition: buffer_view.h:16
impeller::BlitCopyBufferToTextureCommand::destination_origin
IPoint destination_origin
Definition: blit_command.h:35
impeller::BlitCopyBufferToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:34