asynchronous load priorities

This commit is contained in:
David Rose 2008-12-24 22:55:22 +00:00
parent 7fcf84909a
commit 7dc6ea0356
14 changed files with 104 additions and 52 deletions

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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

View File

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

View File

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

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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")
{

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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

View File

@ -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;