Flutter Impeller
impeller::BlitCopyTextureToBufferCommandVK Struct Reference

#include <blit_command_vk.h>

Inheritance diagram for impeller::BlitCopyTextureToBufferCommandVK:
impeller::BlitCopyTextureToBufferCommand impeller::BlitEncodeVK impeller::BlitCommand impeller::BackendCast< BlitEncodeVK, BlitCommand >

Public Member Functions

 ~BlitCopyTextureToBufferCommandVK () 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::BlitCopyTextureToBufferCommand
std::shared_ptr< Texturesource
 
std::shared_ptr< DeviceBufferdestination
 
IRect source_region
 
size_t destination_offset
 
- Public Attributes inherited from impeller::BlitCommand
std::string label
 

Detailed Description

Definition at line 38 of file blit_command_vk.h.

Constructor & Destructor Documentation

◆ ~BlitCopyTextureToBufferCommandVK()

impeller::BlitCopyTextureToBufferCommandVK::~BlitCopyTextureToBufferCommandVK ( )
overridedefault

Member Function Documentation

◆ Encode()

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

Implements impeller::BlitEncodeVK.

Definition at line 101 of file blit_command_vk.cc.

101  {
102  const auto& cmd_buffer = encoder.GetCommandBuffer();
103 
104  // cast source and destination to TextureVK
105  const auto& src = TextureVK::Cast(*source);
106 
107  if (!encoder.Track(source) || !encoder.Track(destination)) {
108  return false;
109  }
110 
111  BarrierVK barrier;
112  barrier.cmd_buffer = cmd_buffer;
113  barrier.new_layout = vk::ImageLayout::eTransferSrcOptimal;
114  barrier.src_access = vk::AccessFlagBits::eShaderWrite |
115  vk::AccessFlagBits::eTransferWrite |
116  vk::AccessFlagBits::eColorAttachmentWrite;
117  barrier.src_stage = vk::PipelineStageFlagBits::eFragmentShader |
118  vk::PipelineStageFlagBits::eTransfer |
119  vk::PipelineStageFlagBits::eColorAttachmentOutput;
120  barrier.dst_access = vk::AccessFlagBits::eShaderRead;
121  barrier.dst_stage = vk::PipelineStageFlagBits::eVertexShader |
122  vk::PipelineStageFlagBits::eFragmentShader;
123 
124  const auto& dst = DeviceBufferVK::Cast(*destination);
125 
126  vk::BufferImageCopy image_copy;
127  image_copy.setBufferOffset(destination_offset);
128  image_copy.setBufferRowLength(0);
129  image_copy.setBufferImageHeight(0);
130  image_copy.setImageSubresource(
131  vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
132  image_copy.setImageOffset(
133  vk::Offset3D(source_region.GetX(), source_region.GetY(), 0));
134  image_copy.setImageExtent(
135  vk::Extent3D(source_region.GetWidth(), source_region.GetHeight(), 1));
136 
137  if (!src.SetLayout(barrier)) {
138  VALIDATION_LOG << "Could not encode layout transition.";
139  return false;
140  }
141 
142  cmd_buffer.copyImageToBuffer(src.GetImage(), //
143  barrier.new_layout, //
144  dst.GetBuffer(), //
145  image_copy //
146  );
147 
148  return true;
149 }

References impeller::BackendCast< TextureVK, Texture >::Cast(), impeller::BackendCast< DeviceBufferVK, Buffer >::Cast(), impeller::BarrierVK::cmd_buffer, impeller::BlitCopyTextureToBufferCommand::destination, impeller::BlitCopyTextureToBufferCommand::destination_offset, impeller::BarrierVK::dst_access, impeller::BarrierVK::dst_stage, impeller::CommandEncoderVK::GetCommandBuffer(), impeller::TRect< T >::GetHeight(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::GetX(), impeller::TRect< T >::GetY(), impeller::BarrierVK::new_layout, impeller::BlitCopyTextureToBufferCommand::source, impeller::BlitCopyTextureToBufferCommand::source_region, impeller::BarrierVK::src_access, impeller::BarrierVK::src_stage, impeller::CommandEncoderVK::Track(), and VALIDATION_LOG.

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

◆ GetLabel()

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

Implements impeller::BlitEncodeVK.

Definition at line 97 of file blit_command_vk.cc.

97  {
98  return label;
99 }

References impeller::BlitCommand::label.


The documentation for this struct was generated from the following files:
impeller::TRect::GetX
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition: rect.h:163
impeller::TRect::GetHeight
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition: rect.h:175
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:15
impeller::TRect::GetWidth
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition: rect.h:171
impeller::BlitCopyTextureToBufferCommand::destination_offset
size_t destination_offset
Definition: blit_command.h:29
impeller::BlitCopyTextureToBufferCommand::destination
std::shared_ptr< DeviceBuffer > destination
Definition: blit_command.h:27
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::BlitCopyTextureToBufferCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:26
impeller::TRect::GetY
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:167
impeller::BlitCopyTextureToBufferCommand::source_region
IRect source_region
Definition: blit_command.h:28