MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_texture_pixels()

void MayaFlux::Buffers::DataWriteProcessor::write_texture_pixels ( Kakshya::ImageData  image)

Write pixels straight into the attached TextureBuffer's GPU image.

The image must match the GPU image's format and size, which must be writable (transfer-destination usage). Retained host pixels that are marked dirty re-upload over this write.

Definition at line 175 of file DataWriteProcessor.cpp.

176{
177 auto payload = std::make_shared<Kakshya::ImageData>(std::move(image));
178 enqueue_write([payload](DataWriteProcessor& self, const std::shared_ptr<VKBuffer>& vk) {
179 using Portal::Graphics::TextureLoom;
180
181 const auto texture = std::dynamic_pointer_cast<TextureBuffer>(vk);
182 const auto gpu_image = texture ? resolve_gpu_image(*texture) : nullptr;
183 auto& loom = TextureLoom::instance();
184 const auto format = TextureLoom::writable_format(gpu_image);
185 if (!loom.is_initialized() || !format || payload->format != *format
186 || payload->width != gpu_image->get_width() || payload->height != gpu_image->get_height()
187 || !payload->is_consistent()) {
189 "DataWriteProcessor write_texture_pixels needs a TextureBuffer with a writable GPU image "
190 "and an image of its format and size");
191 return;
192 }
193
194 const size_t size = payload->byte_size();
195 if (!self.m_write_image_staging || self.m_write_image_staging->get_size_bytes() < size) {
196 self.m_write_image_staging = create_image_staging_buffer(size);
197 }
198 if (self.m_write_image_staging) {
199 loom.upload_data(gpu_image, payload->data(), size, self.m_write_image_staging);
200 } else {
201 loom.upload_data(gpu_image, payload->data(), size);
202 }
203 });
204}
#define MF_RT_ERROR(comp, ctx,...)
uint64_t payload
Definition Composite.cpp:18
IO::ImageData image
Definition Decoder.cpp:47
bool format
bool size
std::shared_ptr< VKBuffer > create_image_staging_buffer(size_t size)
Allocate a persistent host-visible staging buffer sized for repeated streaming uploads to an image of...
std::shared_ptr< Core::VKImage > resolve_gpu_image(const T &buffer)
Resolve the GPU-resident image from any GpuImageSource buffer.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Buffers::create_image_staging_buffer(), enqueue_write(), format, image, m_write_image_staging, MF_RT_ERROR, payload, MayaFlux::Buffers::resolve_gpu_image(), and size.

+ Here is the call graph for this function: