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 161 of file blit_command_vk.cc.

161  {
162  const auto& cmd_buffer = encoder.GetCommandBuffer();
163 
164  // cast destination to TextureVK
165  const auto& dst = TextureVK::Cast(*destination);
166  const auto& src = DeviceBufferVK::Cast(*source.buffer);
167 
168  if (!encoder.Track(source.buffer) || !encoder.Track(destination)) {
169  return false;
170  }
171 
172  BarrierVK dst_barrier;
173  dst_barrier.cmd_buffer = cmd_buffer;
174  dst_barrier.new_layout = vk::ImageLayout::eTransferDstOptimal;
175  dst_barrier.src_access = {};
176  dst_barrier.src_stage = vk::PipelineStageFlagBits::eTopOfPipe;
177  dst_barrier.dst_access =
178  vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eTransferWrite;
179  dst_barrier.dst_stage = vk::PipelineStageFlagBits::eFragmentShader |
180  vk::PipelineStageFlagBits::eTransfer;
181 
182  vk::BufferImageCopy image_copy;
183  image_copy.setBufferOffset(source.range.offset);
184  image_copy.setBufferRowLength(0);
185  image_copy.setBufferImageHeight(0);
186  image_copy.setImageSubresource(
187  vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
188  image_copy.setImageOffset(
189  vk::Offset3D(destination_origin.x, destination_origin.y, 0));
190  image_copy.setImageExtent(vk::Extent3D(destination->GetSize().width,
191  destination->GetSize().height, 1));
192 
193  if (!dst.SetLayout(dst_barrier)) {
194  VALIDATION_LOG << "Could not encode layout transition.";
195  return false;
196  }
197 
198  cmd_buffer.copyBufferToImage(src.GetBuffer(), //
199  dst.GetImage(), //
200  dst_barrier.new_layout, //
201  image_copy //
202  );
203 
204  return true;
205 }

References impeller::BufferView::buffer, impeller::BackendCast< DeviceBufferVK, Buffer >::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 157 of file blit_command_vk.cc.

157  {
158  return label;
159 }

References impeller::BlitCommand::label.


The documentation for this struct was generated from the following files:
impeller::TPoint::y
Type y
Definition: point.h:26
impeller::Range::offset
size_t offset
Definition: range.h:15
impeller::BufferView::range
Range range
Definition: buffer_view.h:16
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:15
impeller::BlitCopyBufferToTextureCommand::source
BufferView source
Definition: blit_command.h:33
impeller::BufferView::buffer
std::shared_ptr< const Buffer > buffer
Definition: buffer_view.h:14
impeller::TPoint::x
Type x
Definition: point.h:25
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:67
impeller::BackendCast< TextureVK, Texture >::Cast
static TextureVK & Cast(Texture &base)
Definition: backend_cast.h:15
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