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

◆ submit_layer() [2/3]

bool MayaFlux::Buffers::TextureArrayBuffer::submit_layer ( uint32_t  layer,
const std::shared_ptr< Core::VKImage > &  image 
)

Replace the frame of one layer with a GPU image, with no host read.

The image is blitted into the layer, converting format and fitting its extent as set_fit says. It must not be this buffer's own image.

Returns
True if the frame was stored.

Definition at line 136 of file TextureArrayBuffer.cpp.

137{
138 if (layer >= m_layers || !image) {
140 "TextureArrayBuffer::submit_layer needs a layer below {} and an image, got layer {}",
141 m_layers, layer);
142 return false;
143 }
144
145 const bool same_extent = image->get_width() == get_width() && image->get_height() == get_height();
146 const auto fit = fit_for(layer);
147 if (!same_extent && !fit) {
148 return false;
149 }
150
152 if (!m_layer_mode) {
153 return false;
154 }
155
157 image->get_width(), image->get_height(), get_width(), get_height(),
158 same_extent ? Portal::Graphics::FitMode::STRETCH : *fit, m_filter);
159
161 bool stored = !plan.blits.empty();
162
163 if (stored) {
164 const vk::Rect2D& first = plan.blits.front().dst;
165 const bool covers = plan.blits.size() == 1
166 && first.offset.x == 0 && first.offset.y == 0
167 && first.extent.width == get_width() && first.extent.height == get_height();
168 if (!covers) {
169 clear_layer(layer);
170 }
171 }
172
173 for (auto& blit : plan.blits) {
174 blit.dst_layer = layer;
175 stored = loom.blit_layer(image, get_texture(), blit) && stored;
176 }
177
178 return stored;
179}
#define MF_RT_ERROR(comp, ctx,...)
IO::ImageData image
Definition Decoder.cpp:47
std::optional< Portal::Graphics::FitMode > fit_for(uint32_t layer) const
std::shared_ptr< Core::VKImage > get_texture() const
Get GPU texture image Suitable for binding to shaders via RenderProcessor::bind_texture()
static FitPlan plan_fit(uint32_t src_width, uint32_t src_height, uint32_t dst_width, uint32_t dst_height, FitMode mode=FitMode::STRETCH, FilterMode filter=FilterMode::LINEAR)
Work out how a source extent maps onto a destination extent.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
MAYAFLUX_API TextureLoom & get_texture_manager()
Get the global texture manager instance.
@ STRETCH
Whole source onto whole destination, aspect ignored.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, clear_layer(), enter_layer_mode(), fit_for(), MayaFlux::Buffers::TextureBuffer::get_height(), MayaFlux::Buffers::TextureBuffer::get_texture(), MayaFlux::Portal::Graphics::get_texture_manager(), MayaFlux::Buffers::TextureBuffer::get_width(), image, m_filter, m_layer_mode, m_layers, MF_RT_ERROR, MayaFlux::Portal::Graphics::SamplerForge::plan_fit(), and MayaFlux::Portal::Graphics::STRETCH.

+ Here is the call graph for this function: