From 8231a56b2299b33ce18e77e19e5f8e18f6a2df40 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Thu, 8 Feb 2018 14:19:19 -0800 Subject: [PATCH] pull task out of render and into its own lib --- interface/CMakeLists.txt | 2 +- libraries/avatars-renderer/CMakeLists.txt | 1 + libraries/entities-renderer/CMakeLists.txt | 1 + libraries/render-utils/CMakeLists.txt | 4 +- libraries/render-utils/src/ZoneRenderer.h | 2 +- libraries/render/CMakeLists.txt | 1 + libraries/render/src/render/Engine.h | 5 +- libraries/render/src/render/SortTask.h | 2 +- .../{render => task}/src/task/Config.cpp | 0 libraries/{render => task}/src/task/Config.h | 2 +- libraries/{render => task}/src/task/Task.h | 58 +++++++++---------- libraries/{render => task}/src/task/Varying.h | 0 tests/gpu-test/CMakeLists.txt | 2 +- tests/render-perf/CMakeLists.txt | 2 +- tests/render-texture-load/CMakeLists.txt | 2 +- 15 files changed, 44 insertions(+), 40 deletions(-) rename libraries/{render => task}/src/task/Config.cpp (100%) rename libraries/{render => task}/src/task/Config.h (99%) rename libraries/{render => task}/src/task/Task.h (88%) rename libraries/{render => task}/src/task/Varying.h (100%) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index c5800959f0..85007f5f15 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -204,7 +204,7 @@ endif() # link required hifi libraries link_hifi_libraries( - shared octree ktx gpu gl procedural graphics render + shared task octree ktx gpu gl procedural graphics render pointers recording fbx networking model-networking entities avatars trackers audio audio-client animation script-engine physics diff --git a/libraries/avatars-renderer/CMakeLists.txt b/libraries/avatars-renderer/CMakeLists.txt index 1f740700c5..40e1607b2a 100644 --- a/libraries/avatars-renderer/CMakeLists.txt +++ b/libraries/avatars-renderer/CMakeLists.txt @@ -13,5 +13,6 @@ include_hifi_library_headers(entities-renderer) include_hifi_library_headers(audio) include_hifi_library_headers(entities) include_hifi_library_headers(octree) +include_hifi_library_headers(task) target_bullet() diff --git a/libraries/entities-renderer/CMakeLists.txt b/libraries/entities-renderer/CMakeLists.txt index 4eaa16a107..0f33a73e40 100644 --- a/libraries/entities-renderer/CMakeLists.txt +++ b/libraries/entities-renderer/CMakeLists.txt @@ -13,6 +13,7 @@ include_hifi_library_headers(fbx) include_hifi_library_headers(entities) include_hifi_library_headers(avatars) include_hifi_library_headers(controllers) +include_hifi_library_headers(task) target_bullet() target_polyvox() diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index 57e3572012..3e01fd2643 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -3,10 +3,10 @@ AUTOSCRIBE_SHADER_LIB(gpu graphics render) # pull in the resources.qrc file qt5_add_resources(QT_RESOURCES_FILE "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts/fonts.qrc") setup_hifi_library(Gui Network Qml Quick Script) -link_hifi_libraries(shared ktx gpu graphics model-networking render animation fbx image procedural) +link_hifi_libraries(shared task ktx gpu graphics model-networking render animation fbx image procedural) +include_hifi_library_headers(audio) include_hifi_library_headers(networking) include_hifi_library_headers(octree) -include_hifi_library_headers(audio) if (NOT ANDROID) target_nsight() diff --git a/libraries/render-utils/src/ZoneRenderer.h b/libraries/render-utils/src/ZoneRenderer.h index 5737499270..419db4ebe2 100644 --- a/libraries/render-utils/src/ZoneRenderer.h +++ b/libraries/render-utils/src/ZoneRenderer.h @@ -88,4 +88,4 @@ protected: }; -#endif \ No newline at end of file +#endif diff --git a/libraries/render/CMakeLists.txt b/libraries/render/CMakeLists.txt index 1d88c3e5f5..08f0e07b8f 100644 --- a/libraries/render/CMakeLists.txt +++ b/libraries/render/CMakeLists.txt @@ -4,5 +4,6 @@ setup_hifi_library() # render needs octree only for getAccuracyAngle(float, int) link_hifi_libraries(shared ktx gpu graphics octree) +include_hifi_library_headers(task) target_nsight() diff --git a/libraries/render/src/render/Engine.h b/libraries/render/src/render/Engine.h index 1650d09c5d..94102b4834 100644 --- a/libraries/render/src/render/Engine.h +++ b/libraries/render/src/render/Engine.h @@ -14,9 +14,10 @@ #include -#include "Scene.h" -#include "../task/Task.h" #include +#include + +#include "Scene.h" namespace render { diff --git a/libraries/render/src/render/SortTask.h b/libraries/render/src/render/SortTask.h index de670b1676..8e4c58803e 100644 --- a/libraries/render/src/render/SortTask.h +++ b/libraries/render/src/render/SortTask.h @@ -55,4 +55,4 @@ namespace render { }; } -#endif // hifi_render_SortTask_h; \ No newline at end of file +#endif // hifi_render_SortTask_h; diff --git a/libraries/render/src/task/Config.cpp b/libraries/task/src/task/Config.cpp similarity index 100% rename from libraries/render/src/task/Config.cpp rename to libraries/task/src/task/Config.cpp diff --git a/libraries/render/src/task/Config.h b/libraries/task/src/task/Config.h similarity index 99% rename from libraries/render/src/task/Config.h rename to libraries/task/src/task/Config.h index 7632d4e85d..8f23efe031 100644 --- a/libraries/render/src/task/Config.h +++ b/libraries/task/src/task/Config.h @@ -20,7 +20,7 @@ #include "SettingHandle.h" -#include "Logging.h" +//#include "Logging.h" namespace task { diff --git a/libraries/render/src/task/Task.h b/libraries/task/src/task/Task.h similarity index 88% rename from libraries/render/src/task/Task.h rename to libraries/task/src/task/Task.h index 63bda7bafa..3ac6614a09 100644 --- a/libraries/render/src/task/Task.h +++ b/libraries/task/src/task/Task.h @@ -1,6 +1,6 @@ // // Task.h -// render/src/task +// task/src/task // // Created by Zach Pomerantz on 1/6/2016. // Copyright 2016 High Fidelity, Inc. @@ -17,7 +17,7 @@ #include "SettingHandle.h" -#include "Logging.h" +//#include "Logging.h" #include #include @@ -25,8 +25,8 @@ namespace task { class JobConcept; -template class JobT; -template class TaskT; +template class JobT; +template class TaskT; class JobNoIO {}; class JobContext { @@ -68,23 +68,23 @@ template void jobConfigure(T&, const TaskConfig&) { // nop, as the default TaskConfig was used, so the data does not need a configure method } -template void jobRun(T& data, const RC& renderContext, const JobNoIO& input, JobNoIO& output) { - data.run(renderContext); +template void jobRun(T& data, const JC& jobContext, const JobNoIO& input, JobNoIO& output) { + data.run(jobContext); } -template void jobRun(T& data, const RC& renderContext, const I& input, JobNoIO& output) { - data.run(renderContext, input); +template void jobRun(T& data, const JC& jobContext, const I& input, JobNoIO& output) { + data.run(jobContext, input); } -template void jobRun(T& data, const RC& renderContext, const JobNoIO& input, O& output) { - data.run(renderContext, output); +template void jobRun(T& data, const JC& jobContext, const JobNoIO& input, O& output) { + data.run(jobContext, output); } -template void jobRun(T& data, const RC& renderContext, const I& input, O& output) { - data.run(renderContext, input, output); +template void jobRun(T& data, const JC& jobContext, const I& input, O& output) { + data.run(jobContext, input, output); } -template +template class Job { public: - using Context = RC; + using Context = JC; using ContextPointer = std::shared_ptr; using Config = JobConfig; using None = JobNoIO; @@ -94,7 +94,7 @@ public: Concept(QConfigPointer config) : JobConcept(config) {} virtual ~Concept() = default; - virtual void run(const ContextPointer& renderContext) = 0; + virtual void run(const ContextPointer& jobContext) = 0; }; using ConceptPointer = std::shared_ptr; @@ -130,12 +130,12 @@ public: jobConfigure(_data, *std::static_pointer_cast(Concept::_config)); } - void run(const ContextPointer& renderContext) override { - renderContext->jobConfig = std::static_pointer_cast(Concept::_config); - if (renderContext->jobConfig->alwaysEnabled || renderContext->jobConfig->isEnabled()) { - jobRun(_data, renderContext, _input.get(), _output.edit()); + void run(const ContextPointer& jobContext) override { + jobContext->jobConfig = std::static_pointer_cast(Concept::_config); + if (jobContext->jobConfig->alwaysEnabled || jobContext->jobConfig->isEnabled()) { + jobRun(_data, jobContext, _input.get(), _output.edit()); } - renderContext->jobConfig.reset(); + jobContext->jobConfig.reset(); } }; template using ModelI = Model; @@ -161,12 +161,12 @@ public: return concept->_data; } - virtual void run(const ContextPointer& renderContext) { + virtual void run(const ContextPointer& jobContext) { PerformanceTimer perfTimer(_name.c_str()); - PROFILE_RANGE(render, _name.c_str()); + //PROFILE_RANGE(render, _name.c_str()); auto start = usecTimestampNow(); - _concept->run(renderContext); + _concept->run(jobContext); _concept->setCPURunTime((double)(usecTimestampNow() - start) / 1000.0); } @@ -186,13 +186,13 @@ protected: // The build method is where child Jobs can be added internally to the task // where the input of the task can be setup to feed the child jobs // and where the output of the task is defined -template -class Task : public Job { +template +class Task : public Job { public: - using Context = RC; + using Context = JC; using ContextPointer = std::shared_ptr; using Config = TaskConfig; - using JobType = Job; + using JobType = Job; using None = typename JobType::None; using Concept = typename JobType::Concept; using ConceptPointer = typename JobType::ConceptPointer; @@ -300,11 +300,11 @@ public: } } - void run(const ContextPointer& renderContext) override { + void run(const ContextPointer& jobContext) override { auto config = std::static_pointer_cast(Concept::_config); if (config->alwaysEnabled || config->enabled) { for (auto job : TaskConcept::_jobs) { - job.run(renderContext); + job.run(jobContext); } } } diff --git a/libraries/render/src/task/Varying.h b/libraries/task/src/task/Varying.h similarity index 100% rename from libraries/render/src/task/Varying.h rename to libraries/task/src/task/Varying.h diff --git a/tests/gpu-test/CMakeLists.txt b/tests/gpu-test/CMakeLists.txt index 7bc1349091..336dcf753c 100644 --- a/tests/gpu-test/CMakeLists.txt +++ b/tests/gpu-test/CMakeLists.txt @@ -5,7 +5,7 @@ setup_hifi_project(Quick Gui Script) setup_memory_debugger() set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") link_hifi_libraries( - shared networking gl + shared task networking gl ktx gpu procedural octree image graphics model-networking fbx animation script-engine render render-utils diff --git a/tests/render-perf/CMakeLists.txt b/tests/render-perf/CMakeLists.txt index 57ae7dace7..7ad38c5795 100644 --- a/tests/render-perf/CMakeLists.txt +++ b/tests/render-perf/CMakeLists.txt @@ -13,7 +13,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") # link in the shared libraries link_hifi_libraries( - shared networking animation + shared task networking animation ktx image octree gl gpu gpu-gl render render-utils graphics fbx model-networking diff --git a/tests/render-texture-load/CMakeLists.txt b/tests/render-texture-load/CMakeLists.txt index 2ed905a3ef..b3e49d830b 100644 --- a/tests/render-texture-load/CMakeLists.txt +++ b/tests/render-texture-load/CMakeLists.txt @@ -13,7 +13,7 @@ set_target_properties(${TARGET_NAME} PROPERTIES FOLDER "Tests/manual-tests/") # link in the shared libraries link_hifi_libraries( - shared networking octree + shared task networking octree gl gpu render ktx image animation graphics fbx model-networking render-utils