Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
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 28 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 62 of file blit_command_vk.cc.

63 {
64 const auto& cmd_buffer = encoder.GetCommandBuffer();
65
66 const auto& src = TextureVK::Cast(*source);
67 const auto& dst = TextureVK::Cast(*destination);
68
69 if (!encoder.Track(source) || !encoder.Track(destination)) {
70 return false;
71 }
72
73 BarrierVK src_barrier;
74 src_barrier.cmd_buffer = cmd_buffer;
75 src_barrier.new_layout = vk::ImageLayout::eTransferSrcOptimal;
76 src_barrier.src_access = vk::AccessFlagBits::eTransferWrite |
77 vk::AccessFlagBits::eShaderWrite |
78 vk::AccessFlagBits::eColorAttachmentWrite;
79 src_barrier.src_stage = vk::PipelineStageFlagBits::eTransfer |
80 vk::PipelineStageFlagBits::eFragmentShader |
81 vk::PipelineStageFlagBits::eColorAttachmentOutput;
82 src_barrier.dst_access = vk::AccessFlagBits::eTransferRead;
83 src_barrier.dst_stage = vk::PipelineStageFlagBits::eTransfer;
84
85 BarrierVK dst_barrier;
86 dst_barrier.cmd_buffer = cmd_buffer;
87 dst_barrier.new_layout = vk::ImageLayout::eTransferDstOptimal;
88 dst_barrier.src_access = {};
89 dst_barrier.src_stage = vk::PipelineStageFlagBits::eTopOfPipe;
90 dst_barrier.dst_access =
91 vk::AccessFlagBits::eShaderRead | vk::AccessFlagBits::eTransferWrite;
92 dst_barrier.dst_stage = vk::PipelineStageFlagBits::eFragmentShader |
93 vk::PipelineStageFlagBits::eTransfer;
94
95 if (!src.SetLayout(src_barrier) || !dst.SetLayout(dst_barrier)) {
96 VALIDATION_LOG << "Could not complete layout transitions.";
97 return false;
98 }
99
100 vk::ImageCopy image_copy;
101
102 image_copy.setSrcSubresource(
103 vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
104 image_copy.setDstSubresource(
105 vk::ImageSubresourceLayers(vk::ImageAspectFlagBits::eColor, 0, 0, 1));
106
107 image_copy.srcOffset =
108 vk::Offset3D(source_region.GetX(), source_region.GetY(), 0);
109 image_copy.dstOffset =
110 vk::Offset3D(destination_origin.x, destination_origin.y, 0);
111 image_copy.extent =
112 vk::Extent3D(source_region.GetWidth(), source_region.GetHeight(), 1);
113
114 // Issue the copy command now that the images are already in the right
115 // layouts.
116 cmd_buffer.copyImage(src.GetImage(), //
117 src_barrier.new_layout, //
118 dst.GetImage(), //
119 dst_barrier.new_layout, //
120 image_copy //
121 );
122
123 // If this is an onscreen texture, do not transition the layout
124 // back to shader read.
125 if (dst.IsSwapchainImage()) {
126 return true;
127 }
128
129 BarrierVK barrier;
130 barrier.cmd_buffer = cmd_buffer;
131 barrier.new_layout = vk::ImageLayout::eShaderReadOnlyOptimal;
132 barrier.src_access = {};
133 barrier.src_stage = vk::PipelineStageFlagBits::eTopOfPipe;
134 barrier.dst_access = vk::AccessFlagBits::eShaderRead;
135 barrier.dst_stage = vk::PipelineStageFlagBits::eFragmentShader;
136
137 return dst.SetLayout(barrier);
138}
static TextureVK & Cast(Texture &base)
dst
Definition cp.py:12
std::shared_ptr< Texture > destination
std::shared_ptr< Texture > source
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
Definition rect.h:304
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
Definition rect.h:314
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
Definition rect.h:300
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.
Definition rect.h:308
#define VALIDATION_LOG
Definition validation.h:73

◆ GetLabel()

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

Implements impeller::BlitEncodeVK.

Definition at line 58 of file blit_command_vk.cc.

58 {
59 return label;
60}

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