mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Let's do away with Geom-wide usage hints, it's not very useful
This commit is contained in:
parent
7bef96e71d
commit
7259425b7c
@ -3956,7 +3956,7 @@ begin_draw_primitives(const GeomPipelineReader *geom_reader,
|
||||
#endif
|
||||
|
||||
#if !defined(OPENGLES) && defined(SUPPORT_FIXED_FUNCTION) // Display lists not supported by OpenGL ES.
|
||||
if (geom_reader->get_usage_hint() == Geom::UH_static &&
|
||||
if (/*geom_reader->get_usage_hint() == Geom::UH_static &&*/
|
||||
_data_reader->get_usage_hint() == Geom::UH_static &&
|
||||
display_lists) {
|
||||
// If the geom claims to be totally static, try to build it into a display
|
||||
|
@ -44,21 +44,6 @@ get_geom_rendering() const {
|
||||
return cdata->_geom_rendering;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum (i.e. most dynamic) usage_hint among all of the
|
||||
* individual GeomPrimitives that have been added to the geom.
|
||||
*/
|
||||
INLINE Geom::UsageHint Geom::
|
||||
get_usage_hint() const {
|
||||
CDLockedReader cdata(_cycler);
|
||||
if (!cdata->_got_usage_hint) {
|
||||
CDWriter cdataw(((Geom *)this)->_cycler, cdata, false);
|
||||
((Geom *)this)->reset_usage_hint(cdataw);
|
||||
return cdataw->_usage_hint;
|
||||
}
|
||||
return cdata->_usage_hint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a const pointer to the GeomVertexData, for application code to
|
||||
* directly examine (but not modify) the geom's underlying data.
|
||||
@ -114,7 +99,6 @@ modify_primitive(int i) {
|
||||
Thread *current_thread = Thread::get_current_thread();
|
||||
CDWriter cdata(_cycler, true, current_thread);
|
||||
nassertr(i >= 0 && i < (int)cdata->_primitives.size(), NULL);
|
||||
cdata->_got_usage_hint = false;
|
||||
cdata->_modified = Geom::get_next_modified();
|
||||
clear_cache_stage(current_thread);
|
||||
return cdata->_primitives[i].get_write_pointer();
|
||||
@ -505,8 +489,6 @@ CData() :
|
||||
_primitive_type(PT_none),
|
||||
_shade_model(SM_uniform),
|
||||
_geom_rendering(0),
|
||||
_usage_hint(UH_unspecified),
|
||||
_got_usage_hint(false),
|
||||
_nested_vertices(0),
|
||||
_internal_bounds_stale(true),
|
||||
_bounds_type(BoundingVolume::BT_default)
|
||||
@ -523,8 +505,6 @@ CData(const Geom::CData ©) :
|
||||
_primitive_type(copy._primitive_type),
|
||||
_shade_model(copy._shade_model),
|
||||
_geom_rendering(copy._geom_rendering),
|
||||
_usage_hint(copy._usage_hint),
|
||||
_got_usage_hint(copy._got_usage_hint),
|
||||
_modified(copy._modified),
|
||||
_internal_bounds(copy._internal_bounds),
|
||||
_nested_vertices(copy._nested_vertices),
|
||||
@ -627,15 +607,6 @@ get_geom_rendering() const {
|
||||
return _cdata->_geom_rendering;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
INLINE GeomPipelineReader::UsageHint GeomPipelineReader::
|
||||
get_usage_hint() const {
|
||||
nassertr(_cdata->_got_usage_hint, UH_static);
|
||||
return _cdata->_usage_hint;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -104,6 +104,24 @@ make_copy() const {
|
||||
return new Geom(*this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum (i.e. most dynamic) usage_hint among all of the
|
||||
* individual GeomPrimitives that have been added to the geom.
|
||||
* @deprecated This is no longer very useful.
|
||||
*/
|
||||
Geom::UsageHint Geom::
|
||||
get_usage_hint() const {
|
||||
CDReader cdata(_cycler);
|
||||
GeomEnums::UsageHint hint = UH_unspecified;
|
||||
Primitives::const_iterator pi;
|
||||
for (pi = cdata->_primitives.begin();
|
||||
pi != cdata->_primitives.end();
|
||||
++pi) {
|
||||
hint = min(hint, (*pi).get_read_pointer()->get_usage_hint());
|
||||
}
|
||||
return hint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the UsageHint hint for all of the primitives on this Geom to the
|
||||
* same value. See get_usage_hint().
|
||||
@ -115,7 +133,6 @@ void Geom::
|
||||
set_usage_hint(Geom::UsageHint usage_hint) {
|
||||
Thread *current_thread = Thread::get_current_thread();
|
||||
CDWriter cdata(_cycler, true, current_thread);
|
||||
cdata->_usage_hint = usage_hint;
|
||||
|
||||
Primitives::iterator pi;
|
||||
for (pi = cdata->_primitives.begin(); pi != cdata->_primitives.end(); ++pi) {
|
||||
@ -304,7 +321,6 @@ set_primitive(int i, const GeomPrimitive *primitive) {
|
||||
}
|
||||
|
||||
reset_geom_rendering(cdata);
|
||||
cdata->_got_usage_hint = false;
|
||||
cdata->_modified = Geom::get_next_modified();
|
||||
clear_cache_stage(current_thread);
|
||||
mark_internal_bounds_stale(cdata);
|
||||
@ -346,7 +362,6 @@ add_primitive(const GeomPrimitive *primitive) {
|
||||
}
|
||||
|
||||
reset_geom_rendering(cdata);
|
||||
cdata->_got_usage_hint = false;
|
||||
cdata->_modified = Geom::get_next_modified();
|
||||
clear_cache_stage(current_thread);
|
||||
mark_internal_bounds_stale(cdata);
|
||||
@ -369,7 +384,6 @@ remove_primitive(int i) {
|
||||
cdata->_shade_model = SM_uniform;
|
||||
}
|
||||
reset_geom_rendering(cdata);
|
||||
cdata->_got_usage_hint = false;
|
||||
cdata->_modified = Geom::get_next_modified();
|
||||
clear_cache_stage(current_thread);
|
||||
mark_internal_bounds_stale(cdata);
|
||||
@ -1154,8 +1168,6 @@ draw(GraphicsStateGuardianBase *gsg, const GeomMunger *munger,
|
||||
const GeomVertexData *vertex_data, bool force,
|
||||
Thread *current_thread) const {
|
||||
GeomPipelineReader geom_reader(this, current_thread);
|
||||
geom_reader.check_usage_hint();
|
||||
|
||||
GeomVertexDataPipelineReader data_reader(vertex_data, current_thread);
|
||||
data_reader.check_array_readers();
|
||||
|
||||
@ -1380,22 +1392,6 @@ check_will_be_valid(const GeomVertexData *vertex_data) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recomputes the minimum usage_hint.
|
||||
*/
|
||||
void Geom::
|
||||
reset_usage_hint(Geom::CData *cdata) {
|
||||
cdata->_usage_hint = UH_unspecified;
|
||||
Primitives::const_iterator pi;
|
||||
for (pi = cdata->_primitives.begin();
|
||||
pi != cdata->_primitives.end();
|
||||
++pi) {
|
||||
cdata->_usage_hint = min(cdata->_usage_hint,
|
||||
(*pi).get_read_pointer()->get_usage_hint());
|
||||
}
|
||||
cdata->_got_usage_hint = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rederives the _geom_rendering member.
|
||||
*/
|
||||
@ -1670,7 +1666,6 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
// instead, we rederive it in finalize().
|
||||
scan.get_uint16();
|
||||
|
||||
_got_usage_hint = false;
|
||||
_modified = Geom::get_next_modified();
|
||||
|
||||
_bounds_type = BoundingVolume::BT_default;
|
||||
@ -1679,39 +1674,6 @@ fillin(DatagramIterator &scan, BamReader *manager) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the Geom's usage_hint cache has been computed.
|
||||
*/
|
||||
void GeomPipelineReader::
|
||||
check_usage_hint() const {
|
||||
if (!_cdata->_got_usage_hint) {
|
||||
// We'll need to get a fresh pointer, since another thread might already
|
||||
// have modified the pointer on the object since we queried it.
|
||||
{
|
||||
#ifdef DO_PIPELINING
|
||||
unref_delete((CycleData *)_cdata);
|
||||
#endif
|
||||
Geom::CDWriter fresh_cdata(((Geom *)_object)->_cycler,
|
||||
false, _current_thread);
|
||||
((GeomPipelineReader *)this)->_cdata = fresh_cdata;
|
||||
#ifdef DO_PIPELINING
|
||||
_cdata->ref();
|
||||
#endif
|
||||
if (!fresh_cdata->_got_usage_hint) {
|
||||
// The cache is still stale. We have to do the work of freshening it.
|
||||
((Geom *)_object)->reset_usage_hint(fresh_cdata);
|
||||
nassertv(fresh_cdata->_got_usage_hint);
|
||||
}
|
||||
|
||||
// When fresh_cdata goes out of scope, its write lock is released, and
|
||||
// _cdata reverts to our usual convention of an unlocked copy of the
|
||||
// data.
|
||||
}
|
||||
}
|
||||
|
||||
nassertv(_cdata->_got_usage_hint);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -75,9 +75,9 @@ PUBLISHED:
|
||||
MAKE_PROPERTY(shade_model, get_shade_model);
|
||||
MAKE_PROPERTY(geom_rendering, get_geom_rendering);
|
||||
|
||||
INLINE UsageHint get_usage_hint() const;
|
||||
UsageHint get_usage_hint() const;
|
||||
void set_usage_hint(UsageHint usage_hint);
|
||||
MAKE_PROPERTY(usage_hint, get_usage_hint, set_usage_hint);
|
||||
//MAKE_PROPERTY(usage_hint, get_usage_hint, set_usage_hint);
|
||||
|
||||
INLINE CPT(GeomVertexData) get_vertex_data(Thread *current_thread = Thread::get_current_thread()) const;
|
||||
PT(GeomVertexData) modify_vertex_data();
|
||||
@ -194,7 +194,6 @@ private:
|
||||
void clear_prepared(PreparedGraphicsObjects *prepared_objects);
|
||||
bool check_will_be_valid(const GeomVertexData *vertex_data) const;
|
||||
|
||||
void reset_usage_hint(CData *cdata);
|
||||
void reset_geom_rendering(CData *cdata);
|
||||
|
||||
void combine_primitives(GeomPrimitive *a_prim, const GeomPrimitive *b_prim,
|
||||
@ -318,8 +317,6 @@ private:
|
||||
PrimitiveType _primitive_type;
|
||||
ShadeModel _shade_model;
|
||||
int _geom_rendering;
|
||||
UsageHint _usage_hint;
|
||||
bool _got_usage_hint;
|
||||
UpdateSeq _modified;
|
||||
|
||||
CPT(BoundingVolume) _internal_bounds;
|
||||
@ -416,12 +413,9 @@ public:
|
||||
INLINE const Geom *get_object() const;
|
||||
INLINE Thread *get_current_thread() const;
|
||||
|
||||
void check_usage_hint() const;
|
||||
|
||||
INLINE PrimitiveType get_primitive_type() const;
|
||||
INLINE ShadeModel get_shade_model() const;
|
||||
INLINE int get_geom_rendering() const;
|
||||
INLINE UsageHint get_usage_hint() const;
|
||||
INLINE CPT(GeomVertexData) get_vertex_data() const;
|
||||
INLINE int get_num_primitives() const;
|
||||
INLINE CPT(GeomPrimitive) get_primitive(int i) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user