| Flutter Impeller |

Public Member Functions | List of all members
impeller::BlitCopyTextureToTextureCommandVK Struct Reference

`#include <blit_command_vk.h>`

Inheritance diagram for impeller::BlitCopyTextureToTextureCommandVK:

## 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 BlitEncodeVK & | Cast (BlitCommand &base)
static const BlitEncodeVK & | Cast (const BlitCommand &base)
static BlitEncodeVK * | Cast (BlitCommand *base)
static const BlitEncodeVK * | Cast (const BlitCommand *base)
Public Attributes inherited from impeller::BlitCopyTextureToTextureCommand
std::shared_ptr< Texture > | source
std::shared_ptr< Texture > | destination
IRect | source_region
IPoint | destination_origin
Public Attributes inherited from impeller::BlitCommand
std::string | label

## Detailed Description

Definition at line 28 of file blit_command_vk.h.

## Constructor & Destructor Documentation

## ◆ ~BlitCopyTextureToTextureCommandVK()

impeller::BlitCopyTextureToTextureCommandVK::~BlitCopyTextureToTextureCommandVK | ( |  | ) |
| override default

BlitCopyTextureToTextureCommandVK

## Member Function Documentation

## ◆ Encode()

bool impeller::BlitCopyTextureToTextureCommandVK::Encode | ( | CommandEncoderVK & | encoder | ) | const
| override virtual

Implements impeller::BlitEncodeVK.

Definition at line 27 of file blit_command_vk.cc.

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

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::TRect< T >::GetHeight(), impeller::TRect< T >::GetWidth(), impeller::TRect< T >::GetX(), impeller::TRect< T >::GetY(), impeller::BarrierVK::new_layout, impeller::BlitCopyTextureToTextureCommand::source, impeller::BlitCopyTextureToTextureCommand::source_region, 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::BlitCopyTextureToTextureCommandVK::GetLabel | ( |  | ) | const
| override virtual

Implements impeller::BlitEncodeVK.

Definition at line 23 of file blit_command_vk.cc.

23 {
24 return label;
25 }

References impeller::BlitCommand::label.

The documentation for this struct was generated from the following files:

- impeller/renderer/backend/vulkan/blit_command_vk.h
- impeller/renderer/backend/vulkan/blit_command_vk.cc

impeller::TPoint::y
Type y
Definition: point.h:26
impeller::BlitCopyTextureToTextureCommand::destination
std::shared_ptr< Texture > destination
Definition: blit_command.h:20
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::BlitCopyTextureToTextureCommand::destination_origin
IPoint destination_origin
Definition: blit_command.h:22
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::BlitCopyTextureToTextureCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:19
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::BlitCopyTextureToTextureCommand::source_region
IRect source_region
Definition: blit_command.h:21
impeller::TRect::GetY
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition: rect.h:167