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

◆ bind_push_constants()

template<typename T , typename Receiver >
Influence< T >::Target MayaFlux::Nexus::bind_push_constants ( const Receiver &  target,
size_t  offset = 0 
)

Target that pushes an influence's value to a GPU executor as push constants.

Template Parameters
TTrivially copyable struct matching the shader's push constant layout.
Parameters
targetAn operator with push_constants (MeshFieldOperator, InstanceFieldOperator) or a shader processor with set_push_constant_data; raw pointer or shared_ptr, retained by the target.

For an operator this arms the next dispatch of its executor. This is how an Agent's state reaches a slot-transform kernel, for example one assembled from a DualField of mat4 through ShaderSpec::Assemble::function(). For a shader processor the push block is grown to hold T at offset here, so a shader that already declares it is not drawn before the block exists. A shader that keeps push constants of its own passes the byte offset after them and declares both in one block.

Definition at line 154 of file FieldTargets.hpp.

155{
156 if constexpr (requires { target->get_push_constant_data(); }) {
157 if (target->get_push_constant_data().size() < offset + sizeof(T)) {
158 target->set_push_constant_size(offset + sizeof(T));
159 }
160 }
161
162 return [target, offset](const T& data) {
163 if constexpr (requires { target->push_constants(data); }) {
164 target->push_constants(data);
165 } else {
166 if (target->get_push_constant_data().size() < offset + sizeof(T)) {
167 target->set_push_constant_size(offset + sizeof(T));
168 }
169 std::memcpy(target->get_push_constant_data().data() + offset, &data, sizeof(T));
170 }
171 };
172}
uint64_t offset
Definition Composite.cpp:10

References offset.