Panda3D
computeNode.h
1 // Filename: computeNode.h
2 // Created by: rdb (19Jun14)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef COMPUTENODE_H
16 #define COMPUTENODE_H
17 
18 #include "pandabase.h"
19 #include "pandaNode.h"
20 #include "callbackObject.h"
21 #include "callbackNode.h"
22 #include "pointerTo.h"
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : ComputeNode
26 // Description : A special node, the sole purpose of which is to
27 // invoke a dispatch operation on the assigned
28 // compute shader.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_PANDA_PGRAPHNODES ComputeNode : public PandaNode {
31 PUBLISHED:
32  ComputeNode(const string &name);
33 
34  INLINE void add_dispatch(const LVecBase3i &num_groups);
35  INLINE void add_dispatch(int num_groups_x, int num_groups_y, int num_groups_z);
36 
37  INLINE int get_num_dispatches() const;
38  INLINE const LVecBase3i &get_dispatch(int i) const;
39  INLINE void clear_dispatches();
40 
41  MAKE_SEQ(get_dispatches, get_num_dispatches, get_dispatch);
42 
43 public:
44  ComputeNode(const ComputeNode &copy);
45 
46  virtual PandaNode *make_copy() const;
47  virtual bool safe_to_combine() const;
48 
49  virtual bool is_renderable() const;
50  virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data);
51 
52  virtual void output(ostream &out) const;
53 
54 public:
55  class EXPCL_PANDA_PGRAPHNODES Dispatcher : public CallbackObject {
56  friend class ComputeNode;
57  public:
58  ALLOC_DELETED_CHAIN(Dispatcher);
59  Dispatcher();
60  Dispatcher(const Dispatcher &copy);
61 
62  virtual void do_callback(CallbackData *cbdata);
63 
65 
66  class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
67  public:
68  INLINE CData();
69  INLINE CData(const CData &copy);
70  virtual CycleData *make_copy() const;
71  virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
72  virtual void fillin(DatagramIterator &scan, BamReader *manager);
73  virtual TypeHandle get_parent_type() const {
74  return CallbackNode::get_class_type();
75  }
76 
77  Dispatches _dispatches;
78  };
79 
80  PipelineCycler<CData> _cycler;
83 
84  };
85 
86 private:
87  // One per ComputeNode.
88  PT(Dispatcher) _dispatcher;
89 
90 public:
91  static void register_with_read_factory();
92  virtual void write_datagram(BamWriter *manager, Datagram &dg);
93 
94 protected:
95  static TypedWritable *make_from_bam(const FactoryParams &params);
96  void fillin(DatagramIterator &scan, BamReader *manager);
97 
98 public:
99  static TypeHandle get_class_type() {
100  return _type_handle;
101  }
102  static void init_type() {
103  PandaNode::init_type();
104  register_type(_type_handle, "ComputeNode",
105  PandaNode::get_class_type());
106  }
107  virtual TypeHandle get_type() const {
108  return get_class_type();
109  }
110  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
111 
112 private:
113  static TypeHandle _type_handle;
114 };
115 
116 #include "computeNode.I"
117 
118 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
Definition: bamReader.h:122
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
Base class for objects that can be written to and read from Bam files.
Definition: typedWritable.h:37
This collects together the pieces of data that are accumulated for each node while walking the scene ...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
Definition: bamWriter.h:73
This is a generic data block that is passed along to a CallbackObject when a callback is made...
Definition: callbackData.h:32
virtual bool safe_to_combine() const
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of...
Definition: pandaNode.cxx:281
This template class calls PipelineCycler::read_unlocked(), and then provides a transparent read-only ...
virtual void do_callback(CallbackData *cbdata)
This method called when the callback is triggered; it replaces* the original function.
virtual void write_datagram(BamWriter *, Datagram &) const
Writes the contents of this object to the datagram for shipping out to a Bam file.
Definition: cycleData.cxx:34
An instance of this class is passed to the Factory when requesting it to do its business and construc...
Definition: factoryParams.h:40
virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data)
Adds the node&#39;s contents to the CullResult we are building up during the cull traversal, so that it will be drawn at render time.
Definition: pandaNode.cxx:591
This template class calls PipelineCycler::write() in the constructor and PipelineCycler::release_writ...
A special node, the sole purpose of which is to invoke a dispatch operation on the assigned compute s...
Definition: computeNode.h:30
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
Definition: pandaNode.cxx:604
This is a generic object that can be assigned to a callback at various points in the rendering proces...
virtual void fillin(DatagramIterator &scan, BamReader *manager)
This internal function is intended to be called by each class&#39;s make_from_bam() method to read in all...
Definition: cycleData.cxx:68
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:2788
virtual TypeHandle get_parent_type() const
Returns the type of the container that owns the CycleData.
Definition: computeNode.h:73
A class to retrieve the individual data elements previously stored in a Datagram. ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
Definition: pandaNode.cxx:578
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling...
Definition: cullTraverser.h:48