2011-05-23 04:43:56 +02:00
/*
2011-05-23 05:46:40 +02:00
EngineService - primary service access point for using the renderengine
2011-05-23 04:43:56 +02:00
Copyright ( C ) Lumiera . org
2011-05-23 05:46:40 +02:00
2011 , Hermann Vosseler < Ichthyostega @ web . de >
2011-05-23 04:43:56 +02:00
This program is free software ; you can redistribute it and / or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation ; either version 2 of
the License , or ( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2016-11-03 18:20:10 +01:00
/** @file §§§
* * TODO § § §
*/
2011-05-23 05:46:40 +02:00
# include "proc/engine/engine-service.hpp"
2013-06-03 05:25:13 +02:00
# include "lib/itertools.hpp"
2011-05-23 04:43:56 +02:00
2011-05-23 05:46:40 +02:00
//#include <string>
//#include <memory>
2014-04-03 22:42:48 +02:00
# include <functional>
2011-05-23 05:46:40 +02:00
//#include <boost/scoped_ptr.hpp>
2011-05-23 04:43:56 +02:00
namespace proc {
2011-05-23 05:46:40 +02:00
namespace engine {
2011-05-23 04:43:56 +02:00
2011-05-23 05:46:40 +02:00
// using std::string;
// using lumiera::Subsys;
// using boost::scoped_ptr;
2014-04-03 22:42:48 +02:00
using std : : function ;
using std : : bind ;
using std : : ref ;
2013-06-03 05:25:13 +02:00
using lib : : transform ;
using lib : : append_all ;
2011-08-16 03:02:55 +02:00
2011-08-15 00:52:56 +02:00
namespace { // hidden local details of the service implementation....
2011-05-23 04:43:56 +02:00
2011-08-15 00:52:56 +02:00
} // (End) hidden service impl details
2011-08-16 03:02:55 +02:00
2013-06-03 05:25:13 +02:00
2011-08-16 03:02:55 +02:00
/** storage for the EngineService interface object */
2013-10-20 03:19:36 +02:00
lib : : Depend < EngineService > EngineService : : instance ;
2011-08-16 03:02:55 +02:00
2011-08-15 00:52:56 +02:00
/** */
EngineService : : EngineService ( )
{ }
2011-08-16 03:02:55 +02:00
2011-08-15 00:52:56 +02:00
2011-12-17 04:45:42 +01:00
/** core operation: activate the Lumiera Render Engine.
* Invoking this service effectively hooks up each channel
* of the given model exit point to deliver into the corresponding
* output sink on the given OutputConnection ( which is assumed
* to be already allocated for active use by this connection ) .
* The generated calculation streams represent actively ongoing
* calculations within the engine , started right away , according
* to the given timing constraints and service quality .
*/
CalcStreams
2011-08-15 00:52:56 +02:00
EngineService : : calculate ( ModelPort mPort ,
Timings nominalTimings ,
2011-11-05 16:51:24 +01:00
OutputConnection & output ,
2011-08-15 00:52:56 +02:00
Quality serviceQuality )
{
2013-06-03 05:25:13 +02:00
RenderEnvironmentClosure & renderConfig = configureCalculation ( mPort , nominalTimings , serviceQuality ) ;
2013-06-15 04:02:48 +02:00
function < CalcStream ( play : : DataSink ) > triggerRenderStart = bind ( activateCalculation , _1 , ref ( renderConfig ) ) ;
2013-06-03 05:25:13 +02:00
CalcStreams runningCalculations ;
append_all ( transform ( output . getOpenedSinks ( )
, triggerRenderStart
)
, runningCalculations ) ;
return runningCalculations ;
/////////////////////////////////////////////////////////////////////////////////////////////TICKET #874 : use a pipeline builder to write it as follows:
// treat_all(output.getOpenedSinks())
2013-08-17 03:37:36 +02:00
// .apply (activateCalculation, _1, renderConfig)
2013-06-03 05:25:13 +02:00
// .buildVector();
2011-08-15 00:52:56 +02:00
}
/** */
2011-12-17 04:45:42 +01:00
CalcStreams
2011-08-15 00:52:56 +02:00
EngineService : : calculateBackground ( ModelPort mPort ,
Timings nominalTimings ,
Quality serviceQuality )
{
2011-12-17 04:45:42 +01:00
UNIMPLEMENTED ( " build calculation streams for background rendering " ) ;
2011-08-15 00:52:56 +02:00
}
2013-06-15 04:02:48 +02:00
/** @internal build a representation of a single, ongoing calculation effort.
* This " CalcStream " is tied to the actual engine implementation , but only
* through an opaque link , representing this concrete engine as an
* RenderEnvironmentClosure . This enables the created CalcStream to be
* re - configured and adjusted while running .
*/
CalcStream
EngineService : : activateCalculation ( play : : DataSink sink , RenderEnvironmentClosure & engineCallback )
{
CalcStream calcStream ( engineCallback ) ;
calcStream . sendToOutput ( sink ) ;
return calcStream ;
}
2012-01-21 03:13:33 +01:00
/** @internal extension point
2013-08-17 03:37:36 +02:00
* Create the environment for rendering a connected and related set of output streams .
* Configure and prepare all the internal components , pre - allocate resources and add
* entries to the registration tables necessary to get the related render activities
* into " running " state . The created setup will typically be used to generate all
* the individual channel streams linked together for playback or rendering ;
* they all share the same media type and quality settings .
* @ return an abstracted representation of the specific setup for this render ;
* from this point on , this RenderEnvironmentClosure will be the only way
* for client code to talk to " the engine " . The actual instance of this
* closure is just a handle and can be copied ; any CalcStream created
* off this closure will be linked to the same " environment " and be
* tracked and managed for resource usage automatically .
2012-01-21 03:13:33 +01:00
* @ note variations and especially mock implementations of the render engine
2013-08-17 03:37:36 +02:00
* might choose to configure internals differently . As long as the
2012-01-21 03:13:33 +01:00
* CalcStream and the embedded RenderEnvironmentClosure are consistent ,
* such a specific configuration remains opaque for the user of the
* created render activity
*/
2012-01-23 02:25:12 +01:00
RenderEnvironmentClosure &
2013-06-03 05:25:13 +02:00
EngineService : : configureCalculation ( ModelPort mPort ,
Timings nominalTimings ,
Quality serviceQuality )
2012-01-21 03:13:33 +01:00
{
2013-06-03 05:25:13 +02:00
UNIMPLEMENTED ( " Access and wire to the Scheduler-frontend. "
" Then access the Segmentation and invoke a builder function for a suitable dispatcher table. "
" Package all of this into a suitable RenderEnvironementClosure subclass. " ) ;
2012-01-21 03:13:33 +01:00
RenderEnvironmentClosure * todo_fake ( 0 ) ; ////KABOOOM
2012-01-23 02:25:12 +01:00
return * todo_fake ;
2012-01-21 03:13:33 +01:00
}
2013-09-01 19:48:17 +02:00
/**
* Switch the complete engine into diagnostics mode .
* This activates additional logging and reporting facilities ,
* allowing to verify some specific operations within the engine
* did indeed happen . Activating this mode incurs a performance hit .
*/
void
EngineService : : activateTracing ( )
{
UNIMPLEMENTED ( " tracing/diagnostics mode of the render engine " ) ;
}
void
EngineService : : disableTracing ( )
{
UNIMPLEMENTED ( " tracing/diagnostics mode of the render engine " ) ;
///////////TODO ensure this is EX_FREE
}
2011-08-15 00:52:56 +02:00
/* ===== Quality-of-Service ===== */
enum CalcType {
PLAYBACK ,
RENDER ,
BACKGROUND
} ;
class DefaultQoS
: public EngineService : : Quality
{
CalcType type_ ;
public :
DefaultQoS ( CalcType type )
: type_ ( type )
{ }
} ;
class PriorityQoS
: public DefaultQoS
{
2011-08-18 12:31:26 +02:00
2011-08-15 00:52:56 +02:00
public :
PriorityQoS ( )
: DefaultQoS ( PLAYBACK )
{ }
} ;
class Compromise
: public DefaultQoS
{
public :
Compromise ( CalcType type )
: DefaultQoS ( type )
{ }
} ;
EngineService : : QoS_Definition EngineService : : QoS_DEFAULT = QoS_Definition : : build < DefaultQoS > ( PLAYBACK ) ;
EngineService : : QoS_Definition EngineService : : QoS_BACKGROUND = QoS_Definition : : build < DefaultQoS > ( BACKGROUND ) ;
EngineService : : QoS_Definition EngineService : : QoS_COMPROMISE = QoS_Definition : : build < Compromise > ( PLAYBACK ) ;
EngineService : : QoS_Definition EngineService : : QoS_PERFECT_RESULT = QoS_Definition : : build < DefaultQoS > ( RENDER ) ;
EngineService : : QoS_Definition EngineService : : QoS_SYNC_PRIORITY = QoS_Definition : : build < PriorityQoS > ( ) ;
2011-05-23 04:43:56 +02:00
2011-05-23 05:46:40 +02:00
} } // namespace proc::engine