From cd71e8a22409bf7f5c3c2c147d3266507d0c33ef Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 4 Feb 2006 00:27:37 +0000 Subject: [PATCH] more pipeline fixes --- panda/src/display/graphicsEngine.cxx | 3 - .../glstuff/glGraphicsStateGuardian_src.cxx | 2 + panda/src/gobj/geomPrimitive.I | 1 + panda/src/gobj/geomVertexColumn.h | 64 +++++++++++++++++++ panda/src/gobj/geomVertexReader.I | 10 +++ panda/src/gobj/geomVertexReader.cxx | 19 ++++++ panda/src/gobj/geomVertexReader.h | 11 ++++ panda/src/gobj/geomVertexRewriter.cxx | 20 ++++++ panda/src/gobj/geomVertexRewriter.h | 8 +++ panda/src/gobj/geomVertexWriter.I | 10 +++ panda/src/gobj/geomVertexWriter.cxx | 19 ++++++ panda/src/gobj/geomVertexWriter.h | 11 ++++ panda/src/putil/pipelineCyclerTrueImpl.cxx | 17 ++++- panda/src/text/textNode.cxx | 22 +++++++ panda/src/text/textNode.h | 2 + 15 files changed, 215 insertions(+), 4 deletions(-) diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index be1cdc870a..dd3039c1e6 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/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()); } diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 8f6d9a18b6..ee6210b972 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/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); diff --git a/panda/src/gobj/geomPrimitive.I b/panda/src/gobj/geomPrimitive.I index e0ce83f87e..efa5f57154 100644 --- a/panda/src/gobj/geomPrimitive.I +++ b/panda/src/gobj/geomPrimitive.I @@ -388,6 +388,7 @@ CData(const GeomPrimitive::CData ©) : _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) diff --git a/panda/src/gobj/geomVertexColumn.h b/panda/src/gobj/geomVertexColumn.h index d65ce5da47..21cbca5f31 100644 --- a/panda/src/gobj/geomVertexColumn.h +++ b/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; diff --git a/panda/src/gobj/geomVertexReader.I b/panda/src/gobj/geomVertexReader.I index 3ef683ca32..8e0a98d3c4 100644 --- a/panda/src/gobj/geomVertexReader.I +++ b/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 diff --git a/panda/src/gobj/geomVertexReader.cxx b/panda/src/gobj/geomVertexReader.cxx index c4c00653a7..4dcd3a7f45 100644 --- a/panda/src/gobj/geomVertexReader.cxx +++ b/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 diff --git a/panda/src/gobj/geomVertexReader.h b/panda/src/gobj/geomVertexReader.h index fed1d58879..9a2d798055 100644 --- a/panda/src/gobj/geomVertexReader.h +++ b/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 diff --git a/panda/src/gobj/geomVertexRewriter.cxx b/panda/src/gobj/geomVertexRewriter.cxx index 9e3c896b54..7861d04e56 100644 --- a/panda/src/gobj/geomVertexRewriter.cxx +++ b/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(); + } +} diff --git a/panda/src/gobj/geomVertexRewriter.h b/panda/src/gobj/geomVertexRewriter.h index ae8f505b6a..2a3a5dd38b 100644 --- a/panda/src/gobj/geomVertexRewriter.h +++ b/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 diff --git a/panda/src/gobj/geomVertexWriter.I b/panda/src/gobj/geomVertexWriter.I index 57be772cc8..d0d38c33d8 100644 --- a/panda/src/gobj/geomVertexWriter.I +++ b/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 diff --git a/panda/src/gobj/geomVertexWriter.cxx b/panda/src/gobj/geomVertexWriter.cxx index 4c6daa34e5..294a6dddff 100644 --- a/panda/src/gobj/geomVertexWriter.cxx +++ b/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 diff --git a/panda/src/gobj/geomVertexWriter.h b/panda/src/gobj/geomVertexWriter.h index 14c7574bf5..eb4b7d48ee 100644 --- a/panda/src/gobj/geomVertexWriter.h +++ b/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 diff --git a/panda/src/putil/pipelineCyclerTrueImpl.cxx b/panda/src/putil/pipelineCyclerTrueImpl.cxx index 288a7beae8..3b04b344a6 100644 --- a/panda/src/putil/pipelineCyclerTrueImpl.cxx +++ b/panda/src/putil/pipelineCyclerTrueImpl.cxx @@ -61,8 +61,23 @@ PipelineCyclerTrueImpl(const PipelineCyclerTrueImpl ©) : _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 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; } } diff --git a/panda/src/text/textNode.cxx b/panda/src/text/textNode.cxx index aa2115d729..8db2410ae7 100644 --- a/panda/src/text/textNode.cxx +++ b/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 diff --git a/panda/src/text/textNode.h b/panda/src/text/textNode.h index 9652e214ee..0045af28ba 100644 --- a/panda/src/text/textNode.h +++ b/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;