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

◆ bind_texture_node()

void MayaFlux::Buffers::TextureBindingsProcessor::bind_texture_node ( const std::string &  name,
const std::shared_ptr< Nodes::GpuSync::TextureNode > &  node,
const std::shared_ptr< VKBuffer > &  texture 
)

Bind a texture node to a GPU texture buffer.

Parameters
nameLogical name for this binding
nodeTextureNode to read pixels from
textureGPU texture buffer to upload to

If texture is device-local, a staging buffer is automatically created. If texture is host-visible, no staging is needed.

Definition at line 10 of file TextureBindingsProcessor.cpp.

14{
15 if (!node) {
16 error<std::invalid_argument>(
19 std::source_location::current(),
20 "Cannot bind null texture node '{}'", name);
21 }
22
23 if (!texture) {
24 error<std::invalid_argument>(
27 std::source_location::current(),
28 "Cannot bind texture node '{}' to null texture buffer", name);
29 }
30
31 size_t texture_size = static_cast<size_t>(node->get_width()) * static_cast<size_t>(node->get_height()) * 4 * sizeof(float);
32
33 if (texture->get_size_bytes() < texture_size) {
34 error<std::invalid_argument>(
37 std::source_location::current(),
38 "Texture buffer for '{}' is too small: {} bytes required, {} available",
39 name, texture_size, texture->get_size_bytes());
40 }
41
42 std::shared_ptr<VKBuffer> staging = nullptr;
43 if (!texture->is_host_visible()) {
44 staging = create_staging_buffer(texture_size);
45
47 "Created staging buffer for device-local texture '{}' ({} bytes)",
48 name, texture_size);
49 } else {
51 "No staging needed for host-visible texture '{}'", name);
52 }
53
54 m_bindings[name] = TextureBinding {
55 .node = node,
56 .gpu_texture = texture,
57 .staging_buffer = staging
58 };
59
61 "Bound texture node '{}' ({}x{}, {} bytes)",
62 name, node->get_width(), node->get_height(), texture_size);
63}
#define MF_DEBUG(comp, ctx,...)
std::unordered_map< std::string, TextureBinding > m_bindings
std::shared_ptr< VKBuffer > create_staging_buffer(size_t size)
Create staging buffer for transfers.
@ BufferProcessing
Buffer processing (Buffers::BufferManager, processing chains)
@ Buffers
Buffers, Managers, processors and processing chains.

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, MayaFlux::Buffers::create_staging_buffer(), m_bindings, MF_DEBUG, and MayaFlux::Buffers::TextureBindingsProcessor::TextureBinding::node.

+ Here is the call graph for this function: