Lluvia
ComputeNodeDescriptor.h
Go to the documentation of this file.
1 
8 #ifndef LLUVIA_CORE_NODE_COMPUTE_NODE_DESCRIPTOR_H_
9 #define LLUVIA_CORE_NODE_COMPUTE_NODE_DESCRIPTOR_H_
10 
11 #include "lluvia/core/node/Node.h"
14 
15 #include "lluvia/core/types.h"
16 
17 #include <array>
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <tuple>
22 
23 namespace ll {
24 
25 class ComputeNode;
26 class Program;
27 
34 
35 public:
36  ComputeNodeDescriptor() = default;
37  ComputeNodeDescriptor(const ComputeNodeDescriptor& descriptor) = default;
39 
41 
42  ComputeNodeDescriptor& operator=(const ComputeNodeDescriptor& descriptor) = default;
44 
52  ComputeNodeDescriptor& setProgram(const std::shared_ptr<ll::Program>& tProgram) noexcept;
53 
65  ComputeNodeDescriptor& setProgram(const std::shared_ptr<ll::Program>& tProgram, const std::string& tFunctionName) noexcept;
66 
75  ComputeNodeDescriptor& setParameter(const std::string& name, const ll::Parameter& value);
76 
84  ComputeNodeDescriptor& setFunctionName(const std::string& name) noexcept;
85 
93  ComputeNodeDescriptor& setBuilderName(const std::string& name) noexcept;
94 
103 
111  ComputeNodeDescriptor& addPorts(const std::initializer_list<ll::PortDescriptor>& ports);
112 
127  ComputeNodeDescriptor& setGridX(const uint32_t x) noexcept;
128 
143  ComputeNodeDescriptor& setGridY(const uint32_t y) noexcept;
144 
159  ComputeNodeDescriptor& setGridZ(const uint32_t z) noexcept;
160 
176 
194  ComputeNodeDescriptor& configureGridShape(const ll::vec3ui& globalShape) noexcept;
195 
203  ComputeNodeDescriptor& setLocalX(const uint32_t x) noexcept;
204 
212  ComputeNodeDescriptor& setLocalY(const uint32_t y) noexcept;
213 
221  ComputeNodeDescriptor& setLocalZ(const uint32_t z) noexcept;
222 
231 
241 
247  std::shared_ptr<ll::Program> getProgram() const noexcept;
248 
259  const ll::PortDescriptor& getPort(const std::string& name) const;
260 
271  const ll::Parameter& getParameter(const std::string& name) const;
272 
278  const std::string& getFunctionName() const noexcept;
279 
285  const std::string& getBuilderName() const noexcept;
286 
292  ll::vec3ui getGridShape() const noexcept;
293 
299  ll::vec3ui getLocalShape() const noexcept;
300 
301  uint32_t getGridX() const noexcept;
302  uint32_t getGridY() const noexcept;
303  uint32_t getGridZ() const noexcept;
304 
305  uint32_t getLocalX() const noexcept;
306  uint32_t getLocalY() const noexcept;
307  uint32_t getLocalZ() const noexcept;
308 
309  const ll::PushConstants& getPushConstants() const noexcept;
310 
311  std::vector<vk::DescriptorSetLayoutBinding> getParameterBindings() const;
312 
313 private:
314  std::shared_ptr<ll::Program> m_program;
315  std::string m_functionName;
316  std::string m_builderName;
317 
318  // local and global work group
319  ll::vec3ui m_localShape {1, 1, 1};
320  ll::vec3ui m_gridShape {1, 1, 1};
321 
322  std::map<std::string, ll::PortDescriptor> m_ports;
323  std::map<std::string, ll::Parameter> m_parameters;
324 
325  ll::PushConstants m_pushConstants;
326 };
327 
328 } // namespace ll
329 
330 #endif /* LLUVIA_CORE_NODE_COMPUTE_NODE_DESCRIPTOR_H_ */
Node class and related enums.
Parameter class and related enums.
PushConstants class.
Class for describing a compute node node.
Definition: ComputeNodeDescriptor.h:33
const ll::PortDescriptor & getPort(const std::string &name) const
Gets a port descriptor given its name.
const ll::Parameter & getParameter(const std::string &name) const
Gets a parameter.
ComputeNodeDescriptor & setLocalY(const uint32_t y) noexcept
Sets the local group size in the Y axis.
ComputeNodeDescriptor & setGridShape(const ll::vec3ui &shape) noexcept
Sets the grid shape.
ComputeNodeDescriptor & setFunctionName(const std::string &name) noexcept
Sets the function name within the program object to run in the ll::ComputeNode.
uint32_t getLocalZ() const noexcept
uint32_t getGridX() const noexcept
ComputeNodeDescriptor & setGridX(const uint32_t x) noexcept
Sets the grid size in the X axis.
ComputeNodeDescriptor & setLocalZ(const uint32_t z) noexcept
Sets the local group size in the Z axis.
ll::vec3ui getGridShape() const noexcept
Gets the grid shape.
ComputeNodeDescriptor & operator=(const ComputeNodeDescriptor &descriptor)=default
ComputeNodeDescriptor & setProgram(const std::shared_ptr< ll::Program > &tProgram, const std::string &tFunctionName) noexcept
Sets the program object and function name.
uint32_t getLocalY() const noexcept
const ll::PushConstants & getPushConstants() const noexcept
ComputeNodeDescriptor(ComputeNodeDescriptor &&descriptor)=default
ComputeNodeDescriptor & setPushConstants(const ll::PushConstants &constants) noexcept
Sets the push constants for this compute node.
const std::string & getFunctionName() const noexcept
Gets the function name within the ll::Program object used by this node.
ComputeNodeDescriptor & operator=(ComputeNodeDescriptor &&descriptor)=default
ComputeNodeDescriptor & configureGridShape(const ll::vec3ui &globalShape) noexcept
Calculates the grid shape provided local and global shapes.
ll::vec3ui getLocalShape() const noexcept
Gets the local group shape.
ComputeNodeDescriptor & setLocalX(const uint32_t x) noexcept
Sets the local group size in the X axis.
const std::string & getBuilderName() const noexcept
Gets the builder name within the Lua interpreter.
std::shared_ptr< ll::Program > getProgram() const noexcept
Gets the program associated to this compute node.
uint32_t getGridY() const noexcept
ComputeNodeDescriptor & setLocalShape(const ll::vec3ui &shape) noexcept
Sets the local group shape.
ComputeNodeDescriptor & addPort(const ll::PortDescriptor &port)
Adds a port to the descriptor.
ComputeNodeDescriptor & setGridY(const uint32_t y) noexcept
Sets the grid size in the Y axis.
uint32_t getLocalX() const noexcept
ComputeNodeDescriptor & setGridZ(const uint32_t z) noexcept
Sets the grid size in the Z axis.
ComputeNodeDescriptor & setProgram(const std::shared_ptr< ll::Program > &tProgram) noexcept
Sets the program object.
ComputeNodeDescriptor & addPorts(const std::initializer_list< ll::PortDescriptor > &ports)
Adds a list of ports to the descriptor.
uint32_t getGridZ() const noexcept
std::vector< vk::DescriptorSetLayoutBinding > getParameterBindings() const
ComputeNodeDescriptor(const ComputeNodeDescriptor &descriptor)=default
ComputeNodeDescriptor & setBuilderName(const std::string &name) noexcept
Sets the builder name this descriptor refers to within the Lua interpreter.
ComputeNodeDescriptor & setParameter(const std::string &name, const ll::Parameter &value)
Sets a parameter.
Definition: Parameter.h:23
Definition: PortDescriptor.h:27
Class representing Vulkan shader modules in SPIR-V representation.
Definition: Program.h:37
Definition: PushConstants.h:20
Definition: Buffer.h:28
Common types.