Flutter Impeller
impeller::BlitCopyTextureToTextureCommandVK Struct Reference

#include <blit_command_vk.h>

Inheritance diagram for impeller::BlitCopyTextureToTextureCommandVK:
impeller::BlitCopyTextureToTextureCommand impeller::BlitEncodeVK impeller::BlitCommand impeller::BackendCast< BlitEncodeVK, BlitCommand >

Public Member Functions

 ~BlitCopyTextureToTextureCommandVK () 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::BlitCopyTextureToTextureCommand
std::shared_ptr< Texturesource
 
std::shared_ptr< Texturedestination
 
IRect source_region
 
IPoint destination_origin
 
- Public Attributes inherited from impeller::BlitCommand
std::string label
 

Detailed Description

Definition at line 27 of file blit_command_vk.h.

Constructor & Destructor Documentation

◆ ~BlitCopyTextureToTextureCommandVK()

impeller::BlitCopyTextureToTextureCommandVK::~BlitCopyTextureToTextureCommandVK ( )
overridedefault

Member Function Documentation

◆ Encode()

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

Implements impeller::BlitEncodeVK.

Definition at line 25 of file blit_command_vk.cc.

26  {
27  const auto& cmd_buffer = encoder.GetCommandBuffer();
28 
29  const auto& src = TextureVK::Cast(*source);
30  const auto& dst = TextureVK::Cast(*destination);
31 
32  if (!encoder.Track(source) || !encoder.Track(destination)) {
33  return false;
34  }
35 
36  BarrierVK src_barrier;
37  src_barrier.cmd_buffer = cmd_buffer;
38  src_barrier.new_layout = vk::ImageLayout::eTransferSrcOptimal;
39  src_barrier.src_access = vk::AccessFlagBits::eTransferWrite |
40  vk::AccessFlagBits::eShaderWrite |
41  vk::AccessFlagBits::eColorAttachmentWrite;
42  src_barrier.src_stage = vk::PipelineStageFlagBits::eTransfer |
43  vk::PipelineStageFlagBits::eFragmentShader |
44  vk::PipelineStageFlagBits::eColorAttachmentOutput;
45  src_barrier.dst_access = vk::AccessFlagBits::eTransferRead;
46  src_barrier.dst_stage = vk::PipelineStageFlagBits::eTransfer;
47 
48  BarrierVK dst_barrier;
49  dst_barrier.cmd_buffer = cmd_buffer;
50  dst_barrier.new_layout = vk::ImageLayout::eTransferDstOptimal;
51  dst_barrier.src_access = {};
52  dst_barrier.src_stage = vk::PipelineStageFlagBits::eTopOfPipe;
53  dst_barrier.dst_access =
54  vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eTransferWrite;
55  dst_barrier.dst_stage = vk::PipelineStageFlagBits::eFragmentShader |
56  vk::PipelineStageFlagBits::eTransfer;
57 
58  if (!src.SetLayout(src_barrier) || !dst.SetLayout(dst_barrier)) {
59  VALIDATION_LOG << "Could not complete layout transitions.";
60  return false;
61  }
62 
63  vk::ImageCopy image_copy;
64 
65  image_copy.setSrcSubresource(
66  vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
67  image_copy.setDstSubresource(
68  vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
69 
70  image_copy.srcOffset =
71  vk::Offset3D(source_region.origin.x, source_region.origin.y, 0);
72  image_copy.dstOffset =
73  vk::Offset3D(destination_origin.x, destination_origin.y, 0);
74  image_copy.extent =
75  vk::Extent3D(source_region.size.width, source_region.size.height, 1);
76 
77  // Issue the copy command now that the images are already in the right
78  // layouts.
79  cmd_buffer.copyImage(src.GetImage(), //
80  src_barrier.new_layout, //
81  dst.GetImage(), //
82  dst_barrier.new_layout, //
83  image_copy //
84  );
85 
86  return true;
87 }

References impeller::BackendCast< TextureVK, Texture >::Cast(), impeller::BarrierVK::cmd_buffer, impeller::BlitCopyTextureToTextureCommand::destination, impeller::BlitCopyTextureToTextureCommand::destination_origin, impeller::BarrierVK::dst_access, impeller::BarrierVK::dst_stage, impeller::CommandEncoderVK::GetCommandBuffer(), impeller::TSize< T >::height, impeller::BarrierVK::new_layout, impeller::TRect< T >::origin, impeller::TRect< T >::size, impeller::BlitCopyTextureToTextureCommand::source, impeller::BlitCopyTextureToTextureCommand::source_region, impeller::BarrierVK::src_access, impeller::BarrierVK::src_stage, impeller::CommandEncoderVK::Track(), VALIDATION_LOG, impeller::TSize< T >::width, impeller::TPoint< T >::x, and impeller::TPoint< T >::y.

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

◆ GetLabel()

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

Implements impeller::BlitEncodeVK.

Definition at line 21 of file blit_command_vk.cc.

21  {
22  return label;
23 }

References impeller::BlitCommand::label.


The documentation for this struct was generated from the following files:
impeller::TRect::size
TSize< Type > size
Definition: rect.h:24
impeller::TPoint::y
Type y
Definition: point.h:24
impeller::BlitCopyTextureToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:19
impeller::BlitCopyTextureToTextureCommand::destination_origin
IPoint destination_origin
Definition: blit_command.h:21
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:14
impeller::TRect::origin
TPoint< Type > origin
Definition: rect.h:23
impeller::BlitCopyTextureToTextureCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:18
impeller::TSize::width
Type width
Definition: size.h:21
impeller::TPoint::x
Type x
Definition: point.h:23
VALIDATION_LOG
#define VALIDATION_LOG
Definition: validation.h:60
impeller::BackendCast< TextureVK, Texture >::Cast
static TextureVK & Cast(Texture &base)
Definition: backend_cast.h:14
impeller::BlitCopyTextureToTextureCommand::source_region
IRect source_region
Definition: blit_command.h:20
impeller::TSize::height
Type height
Definition: size.h:22