diff --git a/panda/src/chan/animControl.h b/panda/src/chan/animControl.h index e4d7284a2c..b00c765c37 100644 --- a/panda/src/chan/animControl.h +++ b/panda/src/chan/animControl.h @@ -78,14 +78,14 @@ protected: virtual void animation_activated(); private: - // This is a PT(PartGroup) instead of a PT(PartBundle), just because - // we can't include partBundle.h for circular reasons. But it - // actually keeps a pointer to a PartBundle. bool _pending; string _pending_done_event; Mutex _pending_lock; // protects the above two. ConditionVarFull _pending_cvar; // signals when _pending goes true. + // This is a PT(PartGroup) instead of a PT(PartBundle), just because + // we can't include partBundle.h for circular reasons. But it + // actually keeps a pointer to a PartBundle. PT(PartGroup) _part; PT(AnimBundle) _anim; int _channel_index; diff --git a/panda/src/chan/bindAnimRequest.I b/panda/src/chan/bindAnimRequest.I index ed221a11fd..d90807ee43 100644 --- a/panda/src/chan/bindAnimRequest.I +++ b/panda/src/chan/bindAnimRequest.I @@ -12,23 +12,3 @@ // //////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////// -// Function: BindAnimRequest::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -INLINE BindAnimRequest:: -BindAnimRequest(const string &name, - const Filename &filename, const LoaderOptions &options, - Loader *loader, - AnimControl *control, int hierarchy_match_flags, - const PartSubset &subset) : - ModelLoadRequest(name, filename, options, loader), - _control(control), - _hierarchy_match_flags(hierarchy_match_flags), - _subset(subset) -{ -} - - diff --git a/panda/src/chan/bindAnimRequest.cxx b/panda/src/chan/bindAnimRequest.cxx index e69e12886b..7070ea29d0 100644 --- a/panda/src/chan/bindAnimRequest.cxx +++ b/panda/src/chan/bindAnimRequest.cxx @@ -19,6 +19,24 @@ TypeHandle BindAnimRequest::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: BindAnimRequest::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +BindAnimRequest:: +BindAnimRequest(const string &name, + const Filename &filename, const LoaderOptions &options, + Loader *loader, + AnimControl *control, int hierarchy_match_flags, + const PartSubset &subset) : + ModelLoadRequest(name, filename, options, loader), + _control(control), + _hierarchy_match_flags(hierarchy_match_flags), + _subset(subset) +{ +} + //////////////////////////////////////////////////////////////////// // Function: BindAnimRequest::do_task // Access: Protected, Virtual diff --git a/panda/src/chan/bindAnimRequest.h b/panda/src/chan/bindAnimRequest.h index 4292c365cd..9398b6bb86 100644 --- a/panda/src/chan/bindAnimRequest.h +++ b/panda/src/chan/bindAnimRequest.h @@ -33,13 +33,13 @@ public: ALLOC_DELETED_CHAIN(BindAnimRequest); PUBLISHED: - INLINE BindAnimRequest(const string &name, - const Filename &filename, - const LoaderOptions &options, - Loader *loader, - AnimControl *control, - int hierarchy_match_flags, - const PartSubset &subset); + BindAnimRequest(const string &name, + const Filename &filename, + const LoaderOptions &options, + Loader *loader, + AnimControl *control, + int hierarchy_match_flags, + const PartSubset &subset); protected: virtual DoneStatus do_task(); diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 8c698b0d5e..1910ef8fcc 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -95,6 +95,14 @@ PRC_DESC("When this is true, setting all control effects on an Actor to 0 " "false, it retains whatever its last-computed pose was " "(which may or may not be the default pose).")); +ConfigVariableInt async_bind_priority +("async-bind-priority", 100, +PRC_DESC("This specifies the priority assign to an asynchronous bind " + "task when it is requested via PartBundle::load_bind_anim(). " + "This controls the relative order in which asynchronous loads " + "happen (in particular, relative to asynchronous texture or " + "model loads). A higher number here makes the animations " + "load sooner.")); ConfigureFn(config_chan) { AnimBundle::init_type(); diff --git a/panda/src/chan/config_chan.h b/panda/src/chan/config_chan.h index fa7d1b36fb..cf1d2176bb 100644 --- a/panda/src/chan/config_chan.h +++ b/panda/src/chan/config_chan.h @@ -28,5 +28,6 @@ EXPCL_PANDA_CHAN extern ConfigVariableInt compress_chan_quality; EXPCL_PANDA_CHAN extern ConfigVariableBool read_compressed_channels; EXPCL_PANDA_CHAN extern ConfigVariableBool interpolate_frames; EXPCL_PANDA_CHAN extern ConfigVariableBool restore_initial_pose; +EXPCL_PANDA_CHAN extern ConfigVariableInt async_bind_priority; #endif diff --git a/panda/src/chan/partBundle.cxx b/panda/src/chan/partBundle.cxx index b6cf7f9de2..c14e65f90a 100644 --- a/panda/src/chan/partBundle.cxx +++ b/panda/src/chan/partBundle.cxx @@ -369,6 +369,7 @@ load_bind_anim(Loader *loader, const Filename &filename, new BindAnimRequest(string("bind:") + filename.get_basename(), filename, anim_options, loader, control, hierarchy_match_flags, subset); + request->set_priority(async_bind_priority); loader->load_async(request); return control; diff --git a/panda/src/display/displayRegion.I b/panda/src/display/displayRegion.I index a8d6244fb0..a7996987ac 100644 --- a/panda/src/display/displayRegion.I +++ b/panda/src/display/displayRegion.I @@ -186,6 +186,40 @@ get_clear_depth_between_eyes() const { return _clear_depth_between_eyes; } +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::set_texture_reload_priority +// Access: Published +// Description: Specifies an integer priority which is assigned to +// any asynchronous texture reload requests spawned +// while processing this DisplayRegion. This controls +// which textures are loaded first when multiple +// textures need to be reloaded at once; it also +// controls the relative priority between asynchronous +// texture loads and asynchronous model or animation +// loads. +// +// Specifying a larger number here makes the textures +// rendered by this DisplayRegion load up first. This +// may be particularly useful to do, for instance, for +// the DisplayRegion that renders the gui. +//////////////////////////////////////////////////////////////////// +INLINE void DisplayRegion:: +set_texture_reload_priority(int texture_reload_priority) { + _texture_reload_priority = texture_reload_priority; +} + +//////////////////////////////////////////////////////////////////// +// Function: DisplayRegion::get_texture_reload_priority +// Access: Published +// Description: Returns the priority which is assigned to +// asynchronous texture reload requests. See +// set_texture_reload_priority(). +//////////////////////////////////////////////////////////////////// +INLINE int DisplayRegion:: +get_texture_reload_priority() const { + return _texture_reload_priority; +} + //////////////////////////////////////////////////////////////////// // Function: DisplayRegion::set_cull_traverser // Access: Published diff --git a/panda/src/display/displayRegion.cxx b/panda/src/display/displayRegion.cxx index 168413bd69..798db4ef4b 100644 --- a/panda/src/display/displayRegion.cxx +++ b/panda/src/display/displayRegion.cxx @@ -32,6 +32,7 @@ DisplayRegion:: DisplayRegion(GraphicsOutput *window) : _window(window), _clear_depth_between_eyes(true), + _texture_reload_priority(0), _cull_region_pcollector("Cull:Invalid"), _draw_region_pcollector("Draw:Invalid") { @@ -49,6 +50,7 @@ DisplayRegion:: DisplayRegion(GraphicsOutput *window, float l, float r, float b, float t) : _window(window), _clear_depth_between_eyes(true), + _texture_reload_priority(0), _cull_region_pcollector("Cull:Invalid"), _draw_region_pcollector("Draw:Invalid") { diff --git a/panda/src/display/displayRegion.h b/panda/src/display/displayRegion.h index 859e6e0c0f..d25e758eab 100644 --- a/panda/src/display/displayRegion.h +++ b/panda/src/display/displayRegion.h @@ -95,6 +95,9 @@ PUBLISHED: INLINE void set_clear_depth_between_eyes(bool clear_depth_between_eyes); INLINE bool get_clear_depth_between_eyes() const; + INLINE void set_texture_reload_priority(int texture_reload_priority); + INLINE int get_texture_reload_priority() const; + INLINE void set_cull_traverser(CullTraverser *trav); CullTraverser *get_cull_traverser(); @@ -146,6 +149,8 @@ private: GraphicsOutput *_window; bool _clear_depth_between_eyes; + int _texture_reload_priority; + // Ditto for the cull traverser. PT(CullTraverser) _trav; diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index c4195ace92..52645d098e 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -2254,5 +2254,8 @@ async_reload_texture(TextureContext *tc) { new TextureReloadRequest(string("reload:") + tc->get_texture()->get_name(), _prepared_objects, tc->get_texture(), _supports_compressed_texture); + if (_current_display_region != (DisplayRegion *)NULL) { + request->set_priority(_current_display_region->get_texture_reload_priority()); + } _loader->load_async(request); } diff --git a/panda/src/pgraph/modelLoadRequest.I b/panda/src/pgraph/modelLoadRequest.I index 49286ee120..802f158495 100644 --- a/panda/src/pgraph/modelLoadRequest.I +++ b/panda/src/pgraph/modelLoadRequest.I @@ -13,24 +13,6 @@ //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: ModelLoadRequest::Constructor -// Access: Published -// Description: Create a new ModelLoadRequest, and add it to the loader -// via load_async(), to begin an asynchronous load. -//////////////////////////////////////////////////////////////////// -INLINE ModelLoadRequest:: -ModelLoadRequest(const string &name, - const Filename &filename, const LoaderOptions &options, - Loader *loader) : - AsyncTask(name), - _filename(filename), - _options(options), - _loader(loader), - _is_ready(false) -{ -} - //////////////////////////////////////////////////////////////////// // Function: ModelLoadRequest::get_filename // Access: Published diff --git a/panda/src/pgraph/modelLoadRequest.cxx b/panda/src/pgraph/modelLoadRequest.cxx index 0b90aceb45..e66b4e1fb6 100644 --- a/panda/src/pgraph/modelLoadRequest.cxx +++ b/panda/src/pgraph/modelLoadRequest.cxx @@ -18,6 +18,24 @@ TypeHandle ModelLoadRequest::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: ModelLoadRequest::Constructor +// Access: Published +// Description: Create a new ModelLoadRequest, and add it to the loader +// via load_async(), to begin an asynchronous load. +//////////////////////////////////////////////////////////////////// +ModelLoadRequest:: +ModelLoadRequest(const string &name, + const Filename &filename, const LoaderOptions &options, + Loader *loader) : + AsyncTask(name), + _filename(filename), + _options(options), + _loader(loader), + _is_ready(false) +{ +} + //////////////////////////////////////////////////////////////////// // Function: ModelLoadRequest::do_task // Access: Protected, Virtual diff --git a/panda/src/pgraph/modelLoadRequest.h b/panda/src/pgraph/modelLoadRequest.h index 0a4a70e684..06160418d5 100644 --- a/panda/src/pgraph/modelLoadRequest.h +++ b/panda/src/pgraph/modelLoadRequest.h @@ -36,10 +36,10 @@ public: ALLOC_DELETED_CHAIN(ModelLoadRequest); PUBLISHED: - INLINE ModelLoadRequest(const string &name, - const Filename &filename, - const LoaderOptions &options, - Loader *loader); + ModelLoadRequest(const string &name, + const Filename &filename, + const LoaderOptions &options, + Loader *loader); INLINE const Filename &get_filename() const; INLINE const LoaderOptions &get_options() const;