Sfoglia il codice sorgente

more pipeline fixes

David Rose 20 anni fa
parent
commit
cd71e8a224

+ 0 - 3
panda/src/display/graphicsEngine.cxx

@@ -1186,9 +1186,6 @@ do_cull(CullHandler *cull_handler, SceneSetup *scene_setup,
     }
   }
 
-  static PStatCollector traverse("Cull:Traverse");
-  PStatTimer timer2(traverse);
-  
   trav.traverse(scene_setup->get_scene_root(), get_portal_cull());
 }
 

+ 2 - 0
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -2133,6 +2133,7 @@ prepare_vertex_buffer(GeomVertexArrayData *data) {
 void CLP(GraphicsStateGuardian)::
 apply_vertex_buffer(VertexBufferContext *vbc) {
   nassertv(_supports_buffers);
+  nassertv(vbc->get_data()->get_modified() != UpdateSeq::initial());
 
   CLP(VertexBufferContext) *gvbc = DCAST(CLP(VertexBufferContext), vbc);
 
@@ -2300,6 +2301,7 @@ prepare_index_buffer(GeomPrimitive *data) {
 void CLP(GraphicsStateGuardian)::
 apply_index_buffer(IndexBufferContext *ibc) {
   nassertv(_supports_buffers);
+  nassertv(ibc->get_data()->get_modified() != UpdateSeq::initial());
 
   CLP(IndexBufferContext) *gibc = DCAST(CLP(IndexBufferContext), ibc);
 

+ 1 - 0
panda/src/gobj/geomPrimitive.I

@@ -388,6 +388,7 @@ CData(const GeomPrimitive::CData &copy) :
   _ends(copy._ends),
   _mins(copy._mins),
   _maxs(copy._maxs),
+  _modified(copy._modified),
   _got_minmax(copy._got_minmax),
   _min_vertex(copy._min_vertex),
   _max_vertex(copy._max_vertex)

+ 64 - 0
panda/src/gobj/geomVertexColumn.h

@@ -126,6 +126,10 @@ private:
     virtual void set_data3i(unsigned char *pointer, int a, int b, int c);
     virtual void set_data4i(unsigned char *pointer, int a, int b, int c, int d);
 
+    virtual const char *get_name() const {
+      return "Packer";
+    }
+
     INLINE float maybe_scale_color(unsigned int value);
     INLINE void maybe_scale_color(unsigned int a, unsigned int b);
     INLINE void maybe_scale_color(unsigned int a, unsigned int b,
@@ -162,6 +166,10 @@ private:
     virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
     virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
     virtual void set_data4f(unsigned char *pointer, const LVecBase4f &data);
+
+    virtual const char *get_name() const {
+      return "Packer_point";
+    }
   };
 
   // This is similar to Packer_point, in that the fourth component is
@@ -173,6 +181,10 @@ private:
     virtual void set_data1f(unsigned char *pointer, float data);
     virtual void set_data2f(unsigned char *pointer, const LVecBase2f &data);
     virtual void set_data3f(unsigned char *pointer, const LVecBase3f &data);
+
+    virtual const char *get_name() const {
+      return "Packer_color";
+    }
   };
 
 
@@ -183,73 +195,125 @@ private:
   public:
     virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
     virtual void set_data3f(unsigned char *pointer, const LVecBase3f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_float32_3";
+    }
   };
 
   class Packer_point_float32_2 : public Packer_point {
   public:
     virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
     virtual void set_data2f(unsigned char *pointer, const LVecBase2f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_point_float32_2";
+    }
   };
 
   class Packer_point_float32_3 : public Packer_point {
   public:
     virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
     virtual void set_data3f(unsigned char *pointer, const LVecBase3f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_point_float32_3";
+    }
   };
 
   class Packer_point_float32_4 : public Packer_point {
   public:
     virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
     virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_point_float32_4";
+    }
   };
 
   class Packer_nativefloat_3 : public Packer_float32_3 {
   public:
     virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
+
+    virtual const char *get_name() const {
+      return "Packer_nativefloat_3";
+    }
   };
 
   class Packer_point_nativefloat_2 : public Packer_point_float32_2 {
   public:
     virtual const LVecBase2f &get_data2f(const unsigned char *pointer);
+
+    virtual const char *get_name() const {
+      return "Packer_nativefloat_2";
+    }
   };
 
   class Packer_point_nativefloat_3 : public Packer_point_float32_3 {
   public:
     virtual const LVecBase3f &get_data3f(const unsigned char *pointer);
+
+    virtual const char *get_name() const {
+      return "Packer_point_nativefloat_3";
+    }
   };
 
   class Packer_point_nativefloat_4 : public Packer_point_float32_4 {
   public:
     virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
+
+    virtual const char *get_name() const {
+      return "Packer_point_nativefloat_4";
+    }
   };
 
   class Packer_argb_packed : public Packer_color {
   public:
     virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
     virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_argb_packed";
+    }
   };
 
   class Packer_rgba_uint8_4 : public Packer_color {
   public:
     virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
     virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_rgba_uint8_4";
+    }
   };
 
   class Packer_rgba_float32_4 : public Packer_color {
   public:
     virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
     virtual void set_data4f(unsigned char *pointer, const LVecBase4f &value);
+
+    virtual const char *get_name() const {
+      return "Packer_rgba_float32_4";
+    }
   };
 
   class Packer_rgba_nativefloat_4 : public Packer_rgba_float32_4 {
   public:
     virtual const LVecBase4f &get_data4f(const unsigned char *pointer);
+
+    virtual const char *get_name() const {
+      return "Packer_rgba_nativefloat_4";
+    }
   };
 
   class Packer_uint16_1 : public Packer {
   public:
     virtual int get_data1i(const unsigned char *pointer);
     virtual void set_data1i(unsigned char *pointer, int value);
+
+    virtual const char *get_name() const {
+      return "Packer_uint16_1";
+    }
   };
 
   friend class GeomVertexArrayFormat;

+ 10 - 0
panda/src/gobj/geomVertexReader.I

@@ -435,6 +435,16 @@ get_data4i() {
   return _packer->get_data4i(inc_pointer());
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GeomVertexReader::get_packer
+//       Access: Protected
+//  Description: Returns the reader's Packer object.
+////////////////////////////////////////////////////////////////////
+INLINE GeomVertexColumn::Packer *GeomVertexReader::
+get_packer() const {
+  return _packer;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GeomVertexReader::set_pointer
 //       Access: Private

+ 19 - 0
panda/src/gobj/geomVertexReader.cxx

@@ -77,6 +77,25 @@ set_column(int array, const GeomVertexColumn *column) {
   return true;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GeomVertexReader::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void GeomVertexReader::
+output(ostream &out) const {
+  const GeomVertexColumn *column = get_column();
+  if (column == (GeomVertexColumn *)NULL) {
+    out << "GeomVertexReader()";
+    
+  } else {
+    out << "GeomVertexReader, array = " << get_array_data()
+        << ", column = " << column->get_name()
+        << " (" << get_packer()->get_name()
+        << "), read row " << get_read_row();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GeomVertexReader::initialize
 //       Access: Private

+ 11 - 0
panda/src/gobj/geomVertexReader.h

@@ -100,6 +100,11 @@ PUBLISHED:
   INLINE const int *get_data3i();
   INLINE const int *get_data4i();
 
+  void output(ostream &out) const;
+
+protected:
+  INLINE GeomVertexColumn::Packer *get_packer() const;
+
 private:
   void initialize();
 
@@ -132,6 +137,12 @@ private:
 #endif
 };
 
+INLINE ostream &
+operator << (ostream &out, const GeomVertexReader &reader) {
+  reader.output(out);
+  return out;
+}
+
 #include "geomVertexReader.I"
 
 #endif

+ 20 - 0
panda/src/gobj/geomVertexRewriter.cxx

@@ -17,3 +17,23 @@
 ////////////////////////////////////////////////////////////////////
 
 #include "geomVertexRewriter.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: GeomVertexRewriter::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void GeomVertexRewriter::
+output(ostream &out) const {
+  const GeomVertexColumn *column = get_column();
+  if (column == (GeomVertexColumn *)NULL) {
+    out << "GeomVertexRewriter()";
+    
+  } else {
+    out << "GeomVertexRewriter, array = " << get_array_data()
+        << ", column = " << column->get_name()
+        << " (" << GeomVertexReader::get_packer()->get_name()
+        << "), read row " << get_read_row()
+        << ", write row " << get_write_row();
+  }
+}

+ 8 - 0
panda/src/gobj/geomVertexRewriter.h

@@ -71,8 +71,16 @@ PUBLISHED:
 
   INLINE int get_start_row() const;
   INLINE bool is_at_end() const;
+
+  void output(ostream &out) const;
 };
 
+INLINE ostream &
+operator << (ostream &out, const GeomVertexRewriter &rewriter) {
+  rewriter.output(out);
+  return out;
+}
+
 #include "geomVertexRewriter.I"
 
 #endif

+ 10 - 0
panda/src/gobj/geomVertexWriter.I

@@ -740,6 +740,16 @@ add_data4i(const int data[4]) {
   add_data4i(data[0], data[1], data[2], data[3]);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GeomVertexWriter::get_packer
+//       Access: Protected
+//  Description: Returns the writer's Packer object.
+////////////////////////////////////////////////////////////////////
+INLINE GeomVertexColumn::Packer *GeomVertexWriter::
+get_packer() const {
+  return _packer;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GeomVertexWriter::set_pointer
 //       Access: Private

+ 19 - 0
panda/src/gobj/geomVertexWriter.cxx

@@ -77,6 +77,25 @@ set_column(int array, const GeomVertexColumn *column) {
   return true;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: GeomVertexWriter::output
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+void GeomVertexWriter::
+output(ostream &out) const {
+  const GeomVertexColumn *column = get_column();
+  if (column == (GeomVertexColumn *)NULL) {
+    out << "GeomVertexWriter()";
+    
+  } else {
+    out << "GeomVertexWriter, array = " << get_array_data()
+        << ", column = " << column->get_name()
+        << " (" << get_packer()->get_name()
+        << "), write row " << get_write_row();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: GeomVertexWriter::initialize
 //       Access: Private

+ 11 - 0
panda/src/gobj/geomVertexWriter.h

@@ -135,6 +135,11 @@ PUBLISHED:
   INLINE void add_data4i(int a, int b, int c, int d);
   INLINE void add_data4i(const int data[4]);
 
+  void output(ostream &out) const;
+
+protected:
+  INLINE GeomVertexColumn::Packer *get_packer() const;
+
 private:
   class Writer;
 
@@ -170,6 +175,12 @@ private:
 #endif
 };
 
+INLINE ostream &
+operator << (ostream &out, const GeomVertexWriter &writer) {
+  writer.output(out);
+  return out;
+}
+
 #include "geomVertexWriter.I"
 
 #endif

+ 16 - 1
panda/src/putil/pipelineCyclerTrueImpl.cxx

@@ -61,8 +61,23 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl &copy) :
   _num_stages = _pipeline->get_num_stages();
   nassertv(_num_stages == copy._num_stages);
   _data = new StageData[_num_stages];
+
+  // It's important that we preserve pointerwise equivalence in the
+  // copy: if a and b of the original pipeline are the same pointer,
+  // then a' and b' of the copied pipeline should be the same pointer
+  // (but a' must be a different pointer than a).  This is important
+  // because we rely on pointer equivalence to determine whether an
+  // adjustment at a later stage in the pipeline is automatically
+  // propagated backwards.
+  typedef pmap<CycleData *, PT(CycleData) > Pointers;
+  Pointers pointers;
+
   for (int i = 0; i < _num_stages; ++i) {
-    _data[i]._cycle_data = copy._data[i]._cycle_data->make_copy();
+    PT(CycleData) &new_pt = pointers[copy._data[i]._cycle_data];
+    if (new_pt == NULL) {
+      new_pt = copy._data[i]._cycle_data->make_copy();
+    }
+    _data[i]._cycle_data = new_pt;
   }
 }
 

+ 22 - 0
panda/src/text/textNode.cxx

@@ -367,6 +367,28 @@ generate() {
   return root;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: TextNode::get_internal_geom
+//       Access: Published
+//  Description: Returns the actual node that is used internally to
+//               render the text, if the TextNode is parented within
+//               the scene graph.
+//
+//               In general, you should not call this method.  Call
+//               generate() instead if you want to get a handle to
+//               geometry that represents the text.  This method is
+//               provided as a debugging aid only.
+////////////////////////////////////////////////////////////////////
+PandaNode *TextNode::
+get_internal_geom() const {
+  // Output a nuisance warning to discourage the naive from calling
+  // this method accidentally.
+  text_cat.info()
+    << "TextNode::get_internal_geom() called.\n";
+  check_rebuild();
+  return _internal_geom;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: TextNode::get_unsafe_to_apply_attribs
 //       Access: Public, Virtual

+ 2 - 0
panda/src/text/textNode.h

@@ -221,6 +221,8 @@ PUBLISHED:
   INLINE void update();
   INLINE void force_update();
 
+  PandaNode *get_internal_geom() const;
+
 public:
   // From parent class PandaNode
   virtual int get_unsafe_to_apply_attribs() const;