61 {
63 if (!source_mtl) {
64 return false;
65 }
66
68 if (!destination_mtl) {
69 return false;
70 }
71
72 auto source_origin_mtl =
74 auto source_size_mtl =
76
77 auto destination_bytes_per_pixel =
79 auto destination_bytes_per_row =
80 source_size_mtl.width * destination_bytes_per_pixel;
81 auto destination_bytes_per_image =
82 source_size_mtl.height * destination_bytes_per_row;
83
84 [
encoder copyFromTexture:source_mtl
85 sourceSlice:0
86 sourceLevel:0
87 sourceOrigin:source_origin_mtl
88 sourceSize:source_size_mtl
89 toBuffer:destination_mtl
91 destinationBytesPerRow:destination_bytes_per_row
92 destinationBytesPerImage:destination_bytes_per_image];
93
94 return true;
95};
static TextureMTL & Cast(Texture &base)
id< MTLBuffer > GetMTLBuffer() const
id< MTLTexture > GetMTLTexture() const
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
std::shared_ptr< Texture > source
size_t destination_offset
constexpr Type GetY() const
Returns the Y coordinate of the upper left corner, equivalent to |GetOrigin().y|.
constexpr Type GetHeight() const
Returns the height of the rectangle, equivalent to |GetSize().height|.
constexpr Type GetX() const
Returns the X coordinate of the upper left corner, equivalent to |GetOrigin().x|.
constexpr Type GetWidth() const
Returns the width of the rectangle, equivalent to |GetSize().width|.