105 {
107 if (!source_mtl) {
108 return false;
109 }
110
112 if (!destination_mtl) {
113 return false;
114 }
115
116 auto destination_origin_mtl =
118
119 auto image_size =
destination->GetTextureDescriptor().size;
120 auto source_size_mtl = MTLSizeMake(image_size.width, image_size.height, 1);
121
122 auto destination_bytes_per_pixel =
124 auto destination_bytes_per_row =
125 source_size_mtl.width * destination_bytes_per_pixel;
126 auto destination_bytes_per_image =
127 source_size_mtl.height * destination_bytes_per_row;
128
129 [
encoder copyFromBuffer:source_mtl
131 sourceBytesPerRow:destination_bytes_per_row
132 sourceBytesPerImage:destination_bytes_per_image
133 sourceSize:source_size_mtl
134 toTexture:destination_mtl
135 destinationSlice:0
136 destinationLevel:0
137 destinationOrigin:destination_origin_mtl];
138
139 return true;
140};
static DeviceBufferMTL & Cast(DeviceBuffer &base)
id< MTLBuffer > GetMTLBuffer() const
id< MTLTexture > GetMTLTexture() const
constexpr size_t BytesPerPixelForPixelFormat(PixelFormat format)
std::shared_ptr< Texture > destination
IPoint destination_origin
std::shared_ptr< const DeviceBuffer > buffer