Browse Source

glgsg: make async texture transfer threads configurable

rdb 10 months ago
parent
commit
1a431b3894

+ 3 - 3
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -715,10 +715,10 @@ CLP(GraphicsStateGuardian)(GraphicsEngine *engine, GraphicsPipe *pipe) :
 #endif
 
 #ifdef HAVE_THREADS
-  //XXX having a fixed number of threads is not a great idea.  We ought to have
-  // a common thread pool that is sized based on the available number of CPUs.
   AsyncTaskManager *task_mgr = AsyncTaskManager::get_global_ptr();
-  _async_chain = task_mgr->make_task_chain("texture_copy", 2, TP_normal);
+  _async_chain = task_mgr->make_task_chain("gl_texture_transfer",
+                                           gl_texture_transfer_num_threads,
+                                           gl_texture_transfer_thread_priority);
 #endif
 
 #ifdef DO_PSTATS

+ 13 - 0
panda/src/glstuff/glmisc_src.cxx

@@ -326,6 +326,19 @@ ConfigVariableBool gl_depth_zero_to_one
             "range from 0 to 1, matching other graphics APIs.  This setting "
             "requires OpenGL 4.5, or NVIDIA GeForce 8+ hardware."));
 
+ConfigVariableInt gl_texture_reload_num_threads
+ ("gl-texture-transfer-num-threads", 2,
+  PRC_DESC("The number of threads that will be started to upload and download "
+           "texture data asynchronously, either via the setup_async_transfer "
+           "interface on the the Texture class or via the async screenshot "
+           "interface."));
+
+ConfigVariableEnum<ThreadPriority> gl_texture_transfer_thread_priority
+ ("gl-texture-transfer-thread-priority", TP_normal,
+  PRC_DESC("The default thread priority to assign to the threads created for "
+           "asynchronous texture transfers.  The default is 'normal'; you may "
+           "also specify 'low', 'high', or 'urgent'."));
+
 extern ConfigVariableBool gl_parallel_arrays;
 
 void CLP(init_classes)() {

+ 3 - 0
panda/src/glstuff/glmisc_src.h

@@ -17,6 +17,7 @@
 #include "configVariableEnum.h"
 #include "geomEnums.h"
 #include "coordinateSystem.h"
+#include "threadPriority.h"
 
 // Define some macros to transparently map to the double or float versions of
 // the OpenGL function names.
@@ -76,6 +77,8 @@ extern ConfigVariableBool gl_support_shadow_filter;
 extern ConfigVariableBool gl_support_vertex_array_bgra;
 extern ConfigVariableBool gl_force_image_bindings_writeonly;
 extern ConfigVariableEnum<CoordinateSystem> gl_coordinate_system;
+extern ConfigVariableInt gl_texture_transfer_num_threads;
+extern ConfigVariableEnum<ThreadPriority> gl_texture_transfer_thread_priority;
 
 extern EXPCL_GL void CLP(init_classes)();