WIP possible solution how the operation chunks could be assembled

This commit is contained in:
Fischlurch 2008-07-01 04:53:23 +02:00
parent 5f39f843c3
commit 9389ce2d68
10 changed files with 400 additions and 53 deletions

View file

@ -0,0 +1,22 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class NodeWiring</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class NodeWiring</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass143365"></a>
<p>Declaration :</p><ul><li>C++ : template&lt;class STATE&gt; class NodeWiring : public <a href="class142725.html#refclass142725"><b>WiringDescriptor</b></a> </li></ul><div class="sub">
</div>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class InvocationStateBase</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class InvocationStateBase</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass143493"></a>
<p>Declaration :</p><ul><li>C++ : class InvocationStateBase : public <a href="class132741.html#refclass132741"><b>State</b></a> </li></ul><p>Directly inherited by : <a href="class143621.html#refclass143621"><b>Caching</b></a> </p>
<div class="sub">
</div>
<p>All public operations : <a href="class132741.html#refoperation135941"><b>allocateBuffer</b></a> , <a href="class132741.html#refoperation135813"><b>fetch</b></a> , <a href="class132741.html#refoperation136325"><b>isCalculated</b></a> , <a href="class132741.html#refoperation136197"><b>releaseBuffer</b></a> </p>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Caching</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class Caching</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass143621"></a>
<p>Declaration :</p><ul><li>C++ : class Caching : public <a href="class143493.html#refclass143493"><b>InvocationStateBase</b></a> </li></ul><p>Directly inherited by : <a href="class143749.html#refclass143749"><b>Process</b></a> </p>
<div class="sub">
</div>
<p>All public operations : <a href="class132741.html#refoperation135941"><b>allocateBuffer</b></a> , <a href="class132741.html#refoperation135813"><b>fetch</b></a> , <a href="class132741.html#refoperation136325"><b>isCalculated</b></a> , <a href="class132741.html#refoperation136197"><b>releaseBuffer</b></a> </p>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Process</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class Process</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass143749"></a>
<p>Declaration :</p><ul><li>C++ : class Process : public <a href="class143621.html#refclass143621"><b>Caching</b></a> </li></ul><p>Directly inherited by : <a href="class143877.html#refclass143877"><b>InPlace</b></a> </p>
<div class="sub">
</div>
<p>All public operations : <a href="class132741.html#refoperation135941"><b>allocateBuffer</b></a> , <a href="class132741.html#refoperation135813"><b>fetch</b></a> , <a href="class132741.html#refoperation136325"><b>isCalculated</b></a> , <a href="class132741.html#refoperation136197"><b>releaseBuffer</b></a> </p>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class InPlace</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class InPlace</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass143877"></a>
<p>Declaration :</p><ul><li>C++ : class InPlace : public <a href="class143749.html#refclass143749"><b>Process</b></a> </li></ul><p>Directly inherited by : <a href="class142469.html#refclass142469"><b>StateProxy</b></a> </p>
<div class="sub">
</div>
<p>All public operations : <a href="class132741.html#refoperation135941"><b>allocateBuffer</b></a> , <a href="class132741.html#refoperation135813"><b>fetch</b></a> , <a href="class132741.html#refoperation136325"><b>isCalculated</b></a> , <a href="class132741.html#refoperation136197"><b>releaseBuffer</b></a> </p>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class WiringTable</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class WiringTable</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass144005"></a>
<p>Declaration :</p><ul><li>C++ : template&lt;int SIZ&gt; class WiringTable </li></ul><div class="sub">
<a name="refrelation153861"></a>
<table><tr><td><div class="element">Relation <b>&lt;directional aggregation by value&gt;</b></div></td></tr></table><p>Declaration :</p><ul><li>Uml : # : <a href="class144133.html#refclass144133"><b>BuffHandle</b></a>, multiplicity : SIZ</li><li>C++ : protected: <a href="class144133.html#refclass144133"><b>BuffHandle</b></a> </li></ul><a name="refrelation153989"></a>
<table><tr><td><div class="element">Relation <b>&lt;unidirectional association&gt;</b></div></td></tr></table><p>Declaration :</p><ul><li>Uml : # : <a href="class142725.html#refclass142725"><b>WiringDescriptor</b></a></li><li>C++ : protected: <a href="class142725.html#refclass142725"><b>WiringDescriptor</b></a>* </li></ul></div>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!-- Documentation produced by the Html generator of Bouml (http://bouml.free.fr) -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class BuffHandle</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div class = "title">Class BuffHandle</div>
<p></p>
<!-- ============================================================= -->
<a name="refclass144133"></a>
<p>Declaration :</p><ul><li>C++ : class BuffHandle </li></ul></body>
</html>

View file

@ -20,6 +20,33 @@
*/
/** @file nodeoperation.hpp
** Chunks of operation for invoking the rendernodes.
** This header defines the "glue" which holds together the render node network
** and enables to pull a result frames from the nodes. Especially, the aspect of
** buffer management is covered here. Each node has been preconfigured by the builder
** with a WiringDescriptor and a concrete type of a StateAdapter. These concrete
** StateAdapter objects are assembled out of the building blocks defined in this header,
** depending on the desired mode of operation. Any node can be built to
** - participate in the Caching or ignore the cache
** - actually process a result or just pull frames from a source
** - employ in-Place calculations or use separate in/out buffers
** Additionally, each node may have a given number of input/output pins, expecting to
** be provided with buffers holding a specific kind of data.
**
** \par composition of the StateAdapter
** For each individual ProcNode#pull() call, the WiringAdapter#callDown() builds an StateAdapter
** instance directly on the stack, holding the actual buffer pointers and state references. Using this
** StateAdapter, the predecessor nodes are pulled. The way these operations are carried out is encoded
** in the actual StateAdapter type known to the NodeWiring (WiringAdapter) instance. All of these actual
** StateAdapter types are built as implementing the engine::State interface, on top of the InvocationStateBase
** and inheriting from a chain of strategy classes (single inheritance, mostly \em no virtual functions).
**
** @see engine::ProcNode
** @see engine::StateProxy
** @see nodewiring.hpp interface for building/wiring the nodes
**
*/
#ifndef ENGINE_NODEOPERATION_H
#define ENGINE_NODEOPERATION_H
@ -33,6 +60,16 @@
namespace engine {
/**
* (abstract) base class of all concrete StateAdapter types.
* Defines the skeleton for the node operation/calculation
*/
class InvocationStateBase
: public State
{
};
/**
* Adapter to shield the ProcNode from the actual buffer management,
@ -70,64 +107,108 @@ namespace engine {
}
};
struct Caching
template<class NEXT>
struct QueryCache : NEXT
{
void retrieveResult (uint requiredOutputNr)
BuffHandle step () // brauche: current state
{
BuffHandle fetched = current_.fetch (genFrameID (requiredOutputNr));
if (fetched)
return fetched;
// Cache miss, need to calculate
BuffHandle calculated[NrO];
calculateResult (&calculated);
// commit result to Cache
current_.isCalculated (NrO, calculated, requiredOutputNr);
return calculated[requiredOutputNr];
else
return NEXT::step();
}
};
struct NoCaching
template<class NEXT>
struct PullInput : NEXT
{
void retrieveResult (BuffHandle requiredOutputNr)
BuffHandle step ()
{
return calculateResult (0);
}
};
struct Process
{
BuffHandle calculateResult(BuffHandle* calculated)
{
uint nrI = this->getNrI();
for (uint i = 0; i<nrI; ++i )
this->createBuffTable();
ASSERT (this->buffTab);
ASSERT (0 < this->buffTabSize());
ASSERT (this->nrO+this->nrI <= this->buffTabSize());
ASSERT (this->buffTab->inHandles = &this->buffTab->handles[this->nrO]);
BuffHandle *inH = this->buffTab->inHandles;
BuffHandle::PBuff *inBuff = this->buffTab->inBuffs;
for (uint i = 0; i < this->nrI; ++i )
{
BuffHandle inID = predNode.pull(inNo); // invoke predecessor
this->inBuff[i] = current_.getBuffer(inID);
inBuff[i] =
*(inH[i] = this->pullPredecessor(i)); // invoke predecessor
// now Input #i is ready...
}
uint nrO = this->getNrO();
for (uint i = 0; i<nrO; ++i )
{
calculated[i] = this->allocateBuffer(this->getBuferType(i)); ///TODO: Null pointer when no caching!!!!!
this->outBuff[i] = current_.getBuffer(calculated[i]);
// now Output buffer for channel #i is available...
}
//
// Invoke our own process() function
this->wiring_.process (this->outBuff);
this->feedCache();
// Inputs no longer needed
for (uint i = 0; i<nrI; ++i)
current_.releaseBuffer(inID); ////TODO.... better release /all/ buffers which are != requiredOutput
return calculated[requiredOutputNr];
return NEXT::step();
}
};
template<class NEXT>
struct AllocOutputFromCache
{
BuffHandle step ()
{
ASSERT (this->buffTab);
ASSERT (this->nrO < this->buffTabSize());
BuffHandle *outH = this->buffTab->handles;
BuffHandle::PBuff *outBuff = this->buffTab->buffers;
for (uint i = 0; i < this->nrO; ++i )
{
outBuff[i] =
*(outH[i] = this->allocateBuffer(i));
// now Output buffer for channel #i is available...
}
return NEXT::step();
}
};
template<class NEXT>
struct ProcessData
{
BuffHandle step ()
{
ASSERT (this->buffTab);
ASSERT (this->nrO+this->nrI <= this->buffTabSize());
ASSERT (this->validateBuffers());
// Invoke our own process() function, providing the buffer array
this->wiring_.processFunction (this->buffTab->buffers);
return NEXT::step();
}
};
template<class NEXT>
struct FeedCache
{
BuffHandle step ()
{
// declare all Outputs as finished
this->current_.isCalculated(this->buffTab->handles,
this->nrO);
return NEXT::step();
}
};
template<class NEXT>
struct ReleaseBuffers
{
BuffHandle step ()
{
// all buffers besides the required Output no longer needed
this->current_.releaseBuffers(this->buffTab->handles,
this->buffTabSize(),
this->requiredOutputNr);
return this->buffTab->outH[this->requiredOutputNr];
}
};
template<class NEXT>
struct NoProcess
{
BuffHandle calculateResult(BuffHandle* calculated)
@ -150,6 +231,35 @@ namespace engine {
};
/* === declare the possible Assembly of these elementary steps === */
template<class Config>
struct Strategy
{
BuffHandle step () { NOTREACHED; }
};
template<>
struct Strategy< Config<CACHE,CALCULATE,IN_OUT> >
: QueryCache <
PullInput<
AllocOutputFromCache<
ProcessData<
FeedCache<
ReleaseBuffers<
InvocationStateBase > > > > > >
{ };
template<>
struct Strategy< Config<NOCACHE,CALCULATE,IN_OUT> >
: PullInput<
AllocOutputFromParent<
ProcessData<
ReleaseBuffers<
InvocationStateBase > > > >
{ };
} // namespace engine

View file

@ -36,21 +36,11 @@ namespace engine {
class StateAdapter;
class BuffHandle
struct BuffHandle
{
protected:
typedef float Buff;
typedef Buff* PBuff;//////TODO define the Buffer type(s)
PBuff pBuffer_;
long sourceID_;
BuffHandle (PBuff pb, long id)
: pBuffer_(pb),
sourceID_(id)
{ }
public:
PBuff
operator->() const
{
@ -62,6 +52,10 @@ namespace engine {
ENSURE (pBuffer_);
return *pBuffer_;
}
protected:
PBuff pBuffer_;
long sourceID_;
};

View file

@ -0,0 +1,81 @@
format 40
classcanvas 128005 class_ref 132741 // State
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 78 10 2000
end
classcanvas 128133 class_ref 143493 // InvocationStateBase
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 203 104 2000
end
classcanvas 128261 class_ref 143621 // Caching
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 235 157 2000
end
classcanvas 128389 class_ref 143749 // Process
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 236 212 2000
end
classcanvas 128517 class_ref 143877 // InPlace
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 238 268 2000
end
classcanvas 128645 class_ref 142469 // StateProxy
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 209 332 2004
end
classcanvas 130309 class_ref 144005 // WiringTable
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 101 298 2000
end
classcanvas 130437 class_ref 142725 // WiringDescriptor
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 36 213 2005
end
classcanvas 130565 class_ref 144133 // BuffHandle
draw_all_relations default hide_attributes default hide_operations default show_members_full_definition default show_members_visibility default show_members_stereotype default show_parameter_dir default show_parameter_name default package_name_in_tab default class_drawing_mode default drawing_language default show_context_mode default auto_label_position default show_infonote default shadow default
xyz 36 379 2000
end
textcanvas 131461 "const"
xyzwh 109 257 2010 29 18
relationcanvas 128901 relation_ref 149765 // <generalisation>
from ref 128645 z 1999 to ref 128517
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
relationcanvas 129029 relation_ref 149893 // <generalisation>
from ref 128517 z 1999 to ref 128389
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
relationcanvas 129157 relation_ref 150021 // <generalisation>
from ref 128389 z 1999 to ref 128261
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
relationcanvas 129285 relation_ref 150149 // <generalisation>
from ref 128261 z 1999 to ref 128133
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
relationcanvas 129413 relation_ref 150277 // <generalisation>
from ref 128133 z 1999 to point 260 69
line 129925 z 1999 to point 190 69
line 130181 z 1999 to point 161 176
line 130053 z 1999 to point 118 176
line 129797 z 1999 to ref 128005
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
relationcanvas 130693 relation_ref 150405 // <directional aggregation by value>
geometry VHr
from ref 130309 z 1999 stereotype "<<array>>" xyz 43 309 3000 to point 70 326
line 130821 z 1999 to ref 130565
no_role_a no_role_b
multiplicity_a_pos 45 354 3000 no_multiplicity_b
relationcanvas 130949 relation_ref 150533 // <unidirectional association>
from ref 130309 z 1999 to ref 130437
no_role_a no_role_b
no_multiplicity_a no_multiplicity_b
relationcanvas 131077 relation_ref 150661 // <unidirectional association>
geometry VHr
from ref 128645 z 1999 to point 136 371
line 131333 z 1999 to ref 130309
role_a_pos 148 367 3000 no_role_b
multiplicity_a_pos 122 359 3000 no_multiplicity_b
end