23 , m_layers(
std::
max(layers, 1U))
39 std::optional<Portal::Graphics::FitMode> fit)
51 processor->set_streaming_mode(
true);
71 "TextureArrayBuffer::submit_layer needs a layer below {} and {} bytes, got layer {} and {} bytes",
98 "TextureArrayBuffer::submit_layer needs a layer below {} and a consistent image, got layer {}",
106 std::span<const uint8_t>(
static_cast<const uint8_t*
>(
image.data()),
image.byte_size()));
109 if (!same_extent && !
fit_for(layer)) {
119 .height =
image.height,
120 .format =
image.format
125 std::span<const uint8_t>(
static_cast<const uint8_t*
>(
image.data()),
image.byte_size()),
129 "TextureArrayBuffer::submit_layer failed to upload a {}x{} image",
image.width,
image.height);
140 "TextureArrayBuffer::submit_layer needs a layer below {} and an image, got layer {}",
146 const auto fit =
fit_for(layer);
147 if (!same_extent && !fit) {
161 bool stored = !plan.blits.empty();
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
173 for (
auto& blit : plan.blits) {
174 blit.dst_layer = layer;
191 "TextureArrayBuffer: layer data needs a buffer service");
198 VKBuffer::Usage::HOST_STORAGE,
229 std::memcpy(
static_cast<uint8_t*
>(
m_layer_data->get_mapped_ptr()) +
index *
sizeof(glm::vec4),
230 &
values,
sizeof(glm::vec4));
284 if (!data ||
size == 0) {
287 const auto* bytes =
static_cast<const uint8_t*
>(data);
307 "TextureArrayBuffer: failed to create a {} layer array image",
m_layers);
330 "TextureArrayBuffer: failed to allocate staging for {} bytes",
total);
338 const std::vector<uint8_t> blank(
total, 0);
342 std::vector<uint8_t>().swap(
storage);
354 processor->set_push_constant_data(
m_push);
#define MF_ERROR(comp, ctx,...)
#define MF_RT_ERROR(comp, ctx,...)
const std::vector< float > * pixels
std::vector< std::byte > values
std::optional< Portal::Graphics::FitMode > fit_for(uint32_t layer) const
void enable_layer_data()
Create the per-layer buffer the shader reads as layerData.
void set_layer_params(uint32_t layer, const glm::vec4 &values)
Set the params of one layer, layerData[2 * layer].
std::shared_ptr< VKBuffer > m_source_staging
Portal::Graphics::FilterMode m_filter
std::unordered_map< uint32_t, std::optional< Portal::Graphics::FitMode > > m_layer_fit
std::optional< Portal::Graphics::FitMode > m_fit
TextureArrayBuffer(uint32_t width, uint32_t height, Portal::Graphics::ImageFormat format, uint32_t layers)
void set_weight(uint32_t layer, float weight)
Set the weight of one layer.
void set_layer_timing(uint32_t layer, const glm::vec4 &values)
Set the timing of one layer, layerData[2 * layer + 1].
void setup_processors(ProcessingToken token) override
Setup processors with a processing token.
void set_mode(uint32_t mode)
Set the mode number passed to the shader.
void setup_rendering(const RenderConfig &config) override
Setup rendering with RenderProcessor.
std::shared_ptr< VKBuffer > m_layer_staging
std::shared_ptr< VKBuffer > m_layer_data
void set_weights(std::span< const float > weights)
Set the weights of the first layers in order.
bool submit_layer(uint32_t layer, std::span< const uint8_t > pixels)
Replace the frame of one layer with raw pixels.
void set_push_constants(const void *data, size_t size)
Replace the default push constants with the shader's own.
void write_layer_value(size_t index, const glm::vec4 &values)
std::vector< uint8_t > m_blank
Portal::Graphics::ImageCacheEntry m_source_cache
std::vector< glm::vec4 > m_layer_values
void clear_layer(uint32_t layer)
std::vector< uint8_t > m_custom_push
A TextureBuffer whose image is a stack of layers, composed in one draw.
void setup_processors(ProcessingToken token) override
Setup processors with a processing token.
void set_gpu_texture(std::shared_ptr< Core::VKImage > image)
Inject a pre-existing GPU texture, bypassing TextureProcessor allocation.
std::shared_ptr< TextureProcessor > get_texture_processor() const
uint32_t get_width() const
Portal::Graphics::ImageFormat get_format() const
virtual void setup_rendering(const RenderConfig &config)
Setup rendering with RenderProcessor.
void mark_pixels_dirty()
Mark pixel data as changed Use this if you modify pixel data in-place without calling set_pixel_data(...
uint32_t get_height() const
std::shared_ptr< Core::VKImage > get_texture() const
Get GPU texture image Suitable for binding to shaders via RenderProcessor::bind_texture()
std::vector< uint8_t > & get_pixel_data_mutable()
A hybrid buffer managing both a textured quad geometry and its pixel data.
virtual std::shared_ptr< RenderProcessor > get_render_processor() const
Get a RenderProcessor suitable for rendering this buffer.
void set_default_render_config(const RenderConfig &config)
Called by derived classes to set their context-specific defaults.
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.
std::shared_ptr< Core::VKImage > refresh_cached_image(ImageCacheEntry &entry, const ImageKey &key, std::span< const uint8_t > pixels, const std::shared_ptr< Buffers::VKBuffer > &staging={})
Refresh a sampled image in an owner-held cache entry.
bool upload_layer(const std::shared_ptr< Core::VKImage > &image, uint32_t layer, const void *data, size_t size, const std::shared_ptr< Buffers::VKBuffer > &staging=nullptr, bool deferred=false)
Upload pixels into one layer of an array image.
Interface * get_service()
Query for a backend service.
static BackendRegistry & instance()
Get the global registry instance.
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...
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.
ImageFormat
User-friendly image format enum.
@ UNKNOWN
Unknown or undefined modality.
MAYAFLUX_API TextureLoom & get_texture_manager()
Get the global texture manager instance.
@ STRETCH
Whole source onto whole destination, aspect ignored.
static constexpr DomainSpec Graphics
Domain constant for Graphics domain.
std::array< float, WEIGHT_SLOTS > weights
Raw image data loaded from file or read back from a GPU image.
Describes a DynamicVideoStream so it can be built by designated initializer.
Immutable properties that determine whether an image can be reused.
PrimitiveTopology topology
std::string vertex_shader
std::string fragment_shader
std::string default_texture_binding
Unified rendering configuration for graphics buffers.
Backend buffer management service interface.