| Flutter Impeller |

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

`#include <blit_command_vk.h>`

Inheritance diagram for impeller::BlitCopyTextureToBufferCommandVK:

## 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 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::BlitCopyTextureToBufferCommand
std::shared_ptr< Texture > | source
std::shared_ptr< DeviceBuffer > | destination
IRect | source_region
size_t | destination_offset
Public Attributes inherited from impeller::BlitCommand
std::string | label

## Detailed Description

Definition at line 37 of file blit_command_vk.h.

## Constructor & Destructor Documentation

## ◆ ~BlitCopyTextureToBufferCommandVK()

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

BlitCopyTextureToBufferCommandVK

## Member Function Documentation

## ◆ Encode()

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

Implements impeller::BlitEncodeVK.

Definition at line 99 of file blit_command_vk.cc.

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

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::TSize< T >::height, impeller::BarrierVK::new_layout, impeller::TRect< T >::origin, impeller::TRect< T >::size, impeller::BlitCopyTextureToBufferCommand::source, impeller::BlitCopyTextureToBufferCommand::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::BlitCopyTextureToBufferCommandVK::GetLabel | ( |  | ) | const
| override virtual

Implements impeller::BlitEncodeVK.

Definition at line 95 of file blit_command_vk.cc.

95 {
96 return label;
97 }

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::TRect::size
TSize< Type > size
Definition: rect.h:24
impeller::TPoint::y
Type y
Definition: point.h:24
impeller::BlitCommand::label
std::string label
Definition: blit_command.h:14
impeller::BlitCopyTextureToBufferCommand::destination_offset
size_t destination_offset
Definition: blit_command.h:28
impeller::BlitCopyTextureToBufferCommand::destination
std::shared_ptr< DeviceBuffer > destination
Definition: blit_command.h:26
impeller::TRect::origin
TPoint< Type > origin
Definition: rect.h:23
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::BlitCopyTextureToBufferCommand::source
std::shared_ptr< Texture > source
Definition: blit_command.h:25
impeller::TSize::height
Type height
Definition: size.h:22
impeller::BlitCopyTextureToBufferCommand::source_region
IRect source_region
Definition: blit_command.h:27