Kaynağa Gözat

asynchronous load priorities

David Rose 17 yıl önce
ebeveyn
işleme
7dc6ea0356

+ 3 - 3
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;

+ 0 - 20
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)
-{
-}
-
-  

+ 18 - 0
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

+ 7 - 7
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();

+ 8 - 0
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();

+ 1 - 0
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

+ 1 - 0
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;

+ 34 - 0
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

+ 2 - 0
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")
 {

+ 5 - 0
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;
 

+ 3 - 0
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);
 }

+ 0 - 18
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

+ 18 - 0
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

+ 4 - 4
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;