26 template <
typename Buffer>
27 bool apply_rendering(
const std::shared_ptr<Buffers::VKBuffer>&
buffer,
const Portal::Graphics::RenderConfig& config)
29 if (
const auto typed = std::dynamic_pointer_cast<Buffer>(
buffer)) {
30 typed->setup_rendering(config);
40 if (
const auto texture = std::dynamic_pointer_cast<Buffers::TextureBuffer>(
buffer)) {
41 if (texture->get_pixel_data().empty()) {
49 if (std::dynamic_pointer_cast<Buffers::NodeTextureBuffer>(
buffer)) {
54 if (std::dynamic_pointer_cast<Buffers::MeshBuffer>(
buffer)
55 || std::dynamic_pointer_cast<Buffers::MeshNetworkBuffer>(
buffer)
56 || std::dynamic_pointer_cast<Buffers::ComputeMeshBuffer>(
buffer)
57 || std::dynamic_pointer_cast<Buffers::VolumeGridBuffer>(
buffer)) {
62 if (
const auto geometry = std::dynamic_pointer_cast<Buffers::GeometryBuffer>(
buffer)) {
63 if (std::dynamic_pointer_cast<Nodes::GpuSync::MeshWriterNode>(geometry->get_geometry_node())) {
71 if (std::dynamic_pointer_cast<Buffers::NetworkGeometryBuffer>(
buffer)) {
87 return std::move(mesh->vertex_variant);
95 return std::dynamic_pointer_cast<Buffers::TextureArrayBuffer>(
buffer) !=
nullptr;
99 const std::shared_ptr<Buffers::VKBuffer>& target,
103 const auto array = std::dynamic_pointer_cast<Buffers::TextureArrayBuffer>(target);
105 if (!array || !access || access->byte_count == 0) {
109 array->submit_layer(layer,
110 std::span<const uint8_t>(
static_cast<const uint8_t*
>(access->data_ptr), access->byte_count));
114 const std::shared_ptr<Buffers::VKBuffer>& target,
116 const std::shared_ptr<Core::VKImage>&
image)
118 const auto array = std::dynamic_pointer_cast<Buffers::TextureArrayBuffer>(target);
119 if (array &&
image) {
120 array->submit_layer(layer,
image);
126 const auto texture = std::dynamic_pointer_cast<Buffers::TextureBuffer>(
buffer);
127 return texture && texture->has_texture() ? texture->get_texture() :
nullptr;
136 if (
buffer->get_render_processor()) {
139 "Buffer already renders to another window; keeping its render setup");
144 const bool configured = apply_rendering<Buffers::TextureBuffer>(
buffer, config)
145 || apply_rendering<Buffers::NodeTextureBuffer>(
buffer, config)
146 || apply_rendering<Buffers::RaymarchBuffer>(
buffer, config)
147 || apply_rendering<Buffers::MeshBuffer>(
buffer, config)
148 || apply_rendering<Buffers::GeometryBuffer>(
buffer, config)
149 || apply_rendering<Buffers::CompositeGeometryBuffer>(
buffer, config)
150 || apply_rendering<Buffers::ComputeMeshBuffer>(
buffer, config)
151 || apply_rendering<Buffers::MeshNetworkBuffer>(
buffer, config)
152 || apply_rendering<Buffers::NetworkGeometryBuffer>(
buffer, config)
153 || apply_rendering<Buffers::InstanceNetworkBuffer>(
buffer, config)
154 || apply_rendering<Buffers::VolumeGridBuffer>(
buffer, config)
155 || apply_rendering<Buffers::RelaxationGridBuffer>(
buffer, config)
156 || apply_rendering<Buffers::FormaBuffer>(
buffer, config);
160 "ensure_rendering has no render setup for this buffer type; it was not set up to render");
167 return !(std::dynamic_pointer_cast<Buffers::TextureBuffer>(
buffer)
168 || std::dynamic_pointer_cast<Buffers::NodeTextureBuffer>(
buffer)
169 || std::dynamic_pointer_cast<Buffers::MeshBuffer>(
buffer)
170 || std::dynamic_pointer_cast<Buffers::ComputeMeshBuffer>(
buffer)
171 || std::dynamic_pointer_cast<Buffers::VolumeGridBuffer>(
buffer)
172 || std::dynamic_pointer_cast<Buffers::GeometryBuffer>(
buffer)
173 || std::dynamic_pointer_cast<Buffers::NetworkGeometryBuffer>(
buffer));
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
std::shared_ptr< NetworkGeometryBuffer > buffer
std::optional< Kakshya::DataVariant > resolve_bytes()
Finish the read as raw bytes.
std::optional< Kakshya::ImageData > resolve_pixels()
Finish a pixel read as typed ImageData with its format and dimensions.
void read_bytes(size_t byte_count=0)
Read the attached buffer's primary storage.
void read_texture_pixels()
Download the base level of a TextureBuffer or NodeTextureBuffer image.
std::optional< Kakshya::MeshData > resolve_mesh()
Finish a read_mesh() read as MeshData.
void read_host_pixels()
Read the host pixel data a TextureBuffer retains.
void read_vertices()
Read the attached buffer's declared vertices; the layout count may represent capacity.
void read_mesh()
Read the attached mesh.
Reads selected buffer storage into owned host data, one snapshot per request.
@ Configuration
Configuration and parameter updates.
@ Kriya
Automatable tasks and fluent scheduling api for Nodes and Buffers.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
std::optional< TextureAccess > as_texture_access(const DataVariant &variant)
Extract a TextureAccess from a DataVariant.
void write_layer(const std::shared_ptr< Buffers::VKBuffer > &target, uint32_t layer, const Kakshya::DataVariant &data)
Write a DataVariant into one layer of a layered buffer.
bool accepts_layer_write(const std::shared_ptr< Buffers::VKBuffer > &buffer)
Whether the buffer holds its frames as layers that can be written one at a time.
void arm_graphics_read(Buffers::DataReadProcessor &reader, const std::shared_ptr< Buffers::VKBuffer > &buffer)
Arm the read that suits what the buffer is.
std::shared_ptr< Core::VKImage > source_image(const std::shared_ptr< Buffers::VKBuffer > &buffer)
The GPU image a buffer displays, or null when it has none to copy from.
bool ensure_rendering(const std::shared_ptr< Buffers::VKBuffer > &buffer, const Portal::Graphics::RenderConfig &config)
Make a buffer draw to the window in a render config, unless it already does.
std::optional< Kakshya::DataVariant > resolve_graphics_read(Buffers::DataReadProcessor &reader)
Finish the pending read as one DataVariant.
bool accepts_raw_write(const std::shared_ptr< Buffers::VKBuffer > &buffer)
Whether a DataVariant can be written to the buffer's primary storage.
std::shared_ptr< Core::Window > target_window
Unified rendering configuration for graphics buffers.