The Vish Visualization Shell 0.3
Vish
Classes | Public Types | Public Member Functions | Public Attributes | List of all members
Wizt::Seagrass Class Reference

The Anemone Cache, called the Seagrass, is based on Anemone objects. More...

#include <ocean/Anemonia/Seagrass.hpp>

Inheritance diagram for Wizt::Seagrass:
MemCore::ReferenceBase< Seagrass > MemCore::Intercube Wizt::RenderNamespace::Lighting Wizt::UniformBufferRegistry MemCore::ThreadPool MemCore::Ageable

Classes

struct  StorageBufferStatistics
 

Public Types

using Dependencies_t = std::list< Dependency_t >
 Dependencies are given as a list of dependency objects, which are weak pointers to Creature objects.
 
using Dependency_t = MemCore::WeakPtr< MemCore::Creature >
 The dependencies of an Anemone object are Creatures.
 
- Public Types inherited from MemCore::ReferenceBase< Seagrass >
using reference_domain_t = Seagrass
 The type of the base class.
 
using SelfPtr_t = WeakPtr< Seagrass, Seagrass >
 Type for a pointer to this object itself.
 

Public Member Functions

bool addDependencies (const CachedObject_t &theAnemoneCreator, const Dependencies_t &Dependencies)
 Register dependencies for an Anemone Creator.
 
void addDependency (const CachedObject_t &theAnemoneCreator, Intercube &Dependency)
 Add a dependency to the given Anemone Creator: If the intercube object dies, so will the associated Anemone's data released at the next lawn() call.
 
void cleanup ()
 Clear anything that is scheduled for deletion.
 
memsize_t computeAnemonesMemory () const
 Explicitly computing the GPU memory as known from the available Anemones.
 
memsize_t getCachedAnemonesMemory () const
 Get memory size information from cached memory size parameters.
 
size_t getNumberOfAnemones () const
 Get the number of Anemone objects stored here.
 
int lawn ()
 Lawn all the seagrass contained here, i.e.
 
size_t memsize (bool FreeableOnly=true) const
 Get the memory occupied by all the Anemone objects stored here.
 
 Seagrass (MemCore::memsize_t MaxAllowedCost, const std::string &CacheID)
 Constructor.
 
void setMaxCostFromCurrentUsage (memsize_t SafetyBufferMemory=0)
 Set the maximum cost of the cached items from the current usage minus the safety buffer.
 
virtual ~Seagrass ()
 Destructor.
 
- Public Member Functions inherited from MemCore::ReferenceBase< Seagrass >
auto getObjectCountID () const noexcept
 Get a unique ID for this object in the given domain.
 
bool isIdentical (const WeakPtr< Seagrass, Seagrass > &PossibleSelf) const noexcept
 Check if this object is identical to the one used by the given pointer.
 
void mkAutoDestructive ()
 Marks this object as being automatically destructed, e.g.
 
refcount_t refcount () const noexcept
 The strong reference count.
 
 ReferenceBase (Seagrass *that) noexcept
 Constructor, initializes reference counter to zero.
 
const auto & self () const
 Return weak pointer to the object self.
 
refcount_t wrefcount () const noexcept
 The weak reference count.
 
- Public Member Functions inherited from MemCore::Intercube
void addInterface (const RefPtr< InterfaceBase > &I) const
 Add an interface class object.
 
template<class Data >
void addInterfaceData (const Data &D)
 Add data via an interface class object.
 
template<class Data , typename TypeSelector >
void addInterfaceData (const Data &D)
 Add data via an interface class object.
 
void clearInterfaces ()
 Remove all interfaces.
 
bool const_iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP) const
 Constant iterator.
 
virtual RefPtr< InterfaceBasecreateInterface (const type_info &) const
 Virtual function which allows derived objects to create Interface objects on demand.
 
RefPtr< InterfaceBasefindInterface (const type_info &t) const
 Find a certain interface of specified type.
 
RefPtr< InterfaceBasegetInterface (const type_info &t)
 Retrieve an interface object from a certain type.
 
std::string getInterfaceNames (const char delim=';') const
 Debug function retrieving all interfaces as human-readable string.
 
template<class Data >
bool gotNewInterfaceData (const Data &D)
 Check whether data on the given interface have changed, and if so, set new data as interface.
 
template<class Data >
bool gotNewInterfaceData (mutex &M, const Data &D)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data , typename Selector >
bool gotNewInterfaceData (mutex &M, const Data &D)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data , typename Selector >
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector &S)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data , typename Selector >
bool gotNewInterfaceData (mutex &M, const Data &D, const Selector *S)
 Check whether interface data have changed, if so, then set new interface data and return true.
 
template<class Data >
bool hasChangedInterfaceData (const Data &D) const
 Check whether interface data have changed.
 
template<class Data , typename Selector >
bool hasChangedInterfaceData (const Data &D) const
 Check whether interface data have changed.
 
template<class Data , typename Selector >
bool hasChangedInterfaceData (const Data &D, const Selector &) const
 Check whether interface data have changed.
 
template<class Data , typename Selector >
bool hasChangedInterfaceData (const Data &D, const Selector *) const
 Check whether interface data have changed.
 
bool hasInterface (const type_info &t) const
 Check if some Interface might exist.
 
 Intercube ()
 Constructor.
 
bool iterateInterfaces (const RefPtr< InterfaceIterationParameter > &IIP)
 Modifyable iterator.
 
void printInterfaces () const
 Debug function that prints the names of all interfaces.
 
void registerInterface (const type_info &t)
 Register an interface type; when the interface is actually required, the virtual createInterface() function will be called.
 
template<class InterfaceType >
void removeInterface ()
 Remove an interface.
 
void removeInterfaceBase (const type_info &InterfaceBaseID)
 Remove an interface.
 
virtual ~Intercube ()
 Destructor.
 
- Public Member Functions inherited from Wizt::RenderNamespace::Lighting
unsigned defineLightFunctions (glsl &lightshader) const
 Defines all the light functions as provided by the LightSource shaders managed here, with increasing light source function name.
 
bool isYoungerThan (const MemCore::Ageable &) const
 Check if any light source is younger than the provided argument (which may require re-compilation of the dependent shader code).
 
- Public Member Functions inherited from MemCore::Ageable
 Ageable () noexcept
 Constructor; remembers birth time from current time counter.
 
constexpr Ageable (age_t t) noexcept
 Constructor with explicit time value.
 
constexpr Ageable (const Ageable &A) noexcept
 Copy constructor.
 
 Ageable (const volatile Ageable &A) noexcept
 Copy constructor.
 
constexpr const AgeablegetAge () const
 Return reference to this age, useful for derived classes.
 
bool isNewerThan (const Ageable &a) const noexcept
 Comparison operator.
 
bool isOlderThan (const Ageable &a) const noexcept
 Comparison operator.
 
bool isYoungerThan (const Ageable &a) const noexcept
 Comparison operator (alias to isNewerThan() )
 
bool operator!= (const Ageable &a) const noexcept
 Comparison operator.
 
bool operator< (const Ageable &a) const noexcept
 Comparison operator.
 
bool operator<= (const Ageable &a) const noexcept
 Comparision operator.
 
bool operator<= (const volatile Ageable &a) const volatile noexcept
 Comparision operator.
 
bool operator== (const Ageable &a) const noexcept
 Comparison operator.
 
bool operator> (const Ageable &a) const noexcept
 Comparison operator.
 
bool operator> (const volatile Ageable &a) const volatile throw ()
 Comparision operator.
 
bool operator>= (const Ageable &a) const noexcept
 Comparision operator.
 
bool operator>= (const volatile Ageable &a) const volatile noexcept
 Comparison operator.
 
constexpr void resetAge () noexcept
 Set time value to InfinitelyOld().
 
void setInfinitelyNew () noexcept
 Set time value to InfinitelyOld().
 
age_t time_value () const noexcept
 Return an object's current age.
 
age_t time_value () const volatile noexcept
 Return an object's current age.
 
Ageabletouch () noexcept
 Mark the current object as being modified "now".
 
age_t update (age_t age) noexcept
 Set the age of the current object to a specific age if that is newer than the current one.
 
age_t update (const Ageable &Other) noexcept
 Set the age of the current object to the age of another object if that other one is newer than the current one.
 
age_t update (const volatile Ageable &Other) volatile noexcept
 Set the age of the current object to the age of another object if that other one is newer than the current one.
 
 ~Ageable () noexcept
 Destructor.
 
- Public Member Functions inherited from MemCore::ThreadPool
 ThreadPool (const std::string &ThreadPoolName, unsigned ThreadFactor=2)
 Construct with a set of threads relative to the number of nodes available on the current hardware.
 
 ThreadPool (size_t threads, const std::string &ThreadPoolName)
 Construct with a given number of threads.
 

Public Attributes

MemCore::RefPtr< PixelBuffermyPixelBuffer
 Storage of a possible PixelBuffer object.
 
MemCore::WeakPtr< InteractorSceneInteractor
 Optional interaction parameters.
 

Additional Inherited Members

- Static Public Member Functions inherited from Wizt::RenderNamespace::Lighting
static glsl getEffectiveLightName (glsl &lightshader, unsigned LightNr)
 Convenience function for a text replacement operation:
 
static glsl postfix (unsigned NumberOfLightSources)
 Define a global function.
 
- Static Public Member Functions inherited from MemCore::Ageable
static const AgeableInfinitelyNew () noexcept
 Return a time that is infinitely in the future (well, sort of).
 
static constexpr const AgeableInfinitelyOld () noexcept
 Return a time that is infinitely in the past (well, sort of).
 
static age_t now () noexcept
 Return the current global time.
 
- Static Public Attributes inherited from Wizt::RenderNamespace::Lighting
static const glsl placeholder
 The placeholder text in glsl code provided by lightsources that will be replaced with the number that is assigned to this lightsource for final shader compilation.
 
- Protected Member Functions inherited from MemCore::ReferenceBase< Seagrass >
virtual void extremeUnction ()
 A virtual function that will be called just before the object is destroyed.
 
ReferenceBaseoperator= (const ReferenceBase &R)
 Protected assignment operator (should not be called).
 
void suicide ()
 Delete this.
 
virtual ~ReferenceBase ()
 Virtual destructor.
 

Detailed Description

The Anemone Cache, called the Seagrass, is based on Anemone objects.

The Seagrass class manages Anemone objects, which are referred to from creator objects that are stored in application code. All these creator objects are child classes of the AnemoneCreatorBase.

There two ways of implementing those AnemoneCreators:

  1. Internally, in the virtual function of child class
  2. Externally, in calling code inspecting an Anemone object from within the render() function. The internal method is more elegant, but also slightly more effortsome. For the external method, the AnemoneCreator<> class will serve well the purpose, as this is a Creator that simply forgets the associated Anemone if running out of memory. Such AnemoneCreators<> need to be stored in application memory, wherever they are related to input date. A generic way if only one AnemoneCreator is required per input data set, is storing in an object's state:
    struct MyState : State
    {
    RefPtr<AnemoneCreator<> > myAnemoneCreator;
    };
    RefPtr<State> newState() const override
    {
    return new MyState();
    }
    A reference counting pointer class which keeps objects alive as long as strong pointers to these obje...
    Definition RefPtr.hpp:405
    Note that the AnemoneCreator cannot be constructed in the MyState's constructor because it requires a Seagrass object for initialization. Such is available only in the render() function, and we can create the AnemoneCreator only there:
    void DisplayEdges::environment_render(VRenderContext&Context) const
    {
    RefPtr<MyState> S = myState(Context);
    if (!S->myAnemoneCreator)
    S->myAnemoneCreator = new AnemoneCreator<>( Context.getSeagrass() );
    RefPtr<Anemone> RenderAnemone = S->myAnemoneCreator->create();
    ...
    }
    A set of variable names, with indices associated to each type.
    Definition Context.hpp:18
    Base class for objects that may display something.
    Definition VRenderContext.hpp:77
    The Anemone Cache, called the Seagrass, is based on Anemone objects.
    Definition Seagrass.hpp:282

Sea grass meadows are inhabited or visited by a diverse and abundant fish fauna. Resident fishes are typically small, cryptic, and of little commercial value. [...] Some higher vertebrates can also be found in sea grass meadows. [...] Sea grasses have potential for extremely high primary productivity. [...] Sea grasses are extremely efficient at capturing and utilizing nutrients. [...] (source: http://savefloridareefs.com/page2/Seagrassandmangroves.html )


Class Documentation

◆ Wizt::Seagrass::StorageBufferStatistics

struct Wizt::Seagrass::StorageBufferStatistics

Member Typedef Documentation

◆ Dependency_t

The dependencies of an Anemone object are Creatures.

Their important property is that they are MemCore::Intercubes. Once this Intercube dies, it will schedule all cached Anemone objects for deletion as well. However, the Anemone objects will not be deleted immediately, but only scheduled for deletion. The actual deletion must be done via the Seagrass.

The fact that Creature objects are related to cache management as well is of no relevance here, the Creature's cache is independent from the Seagrass. In particular, the Creature used here may refer to RAM objects, while Anemone objects reside on the GPU.

Member Function Documentation

◆ addDependencies()

bool Wizt::Seagrass::addDependencies ( const CachedObject_t theAnemoneCreator,
const Dependencies_t Dependencies 
)

Register dependencies for an Anemone Creator.

Once those dependencies die, so will their interface die, deferred destructor objects which tell the Seagrass to delete the respective Anemone objects at next occasion.

References addDependency().

◆ lawn()

int Wizt::Seagrass::lawn ( )

Lawn all the seagrass contained here, i.e.

remove all stored entries. Same as purge() (a more conventional naming).

References cleanup(), and myPixelBuffer.

◆ setMaxCostFromCurrentUsage()

void Wizt::Seagrass::setMaxCostFromCurrentUsage ( memsize_t  SafetyBufferMemory = 0)

Set the maximum cost of the cached items from the current usage minus the safety buffer.

This function is useful if some OpenGL command runs out of memory, but the reported GPU RAM would have seemed to be large enough to hold it - in other words, the reported GPU RAM is incorrect and we need to estimate the actually available GPU RAM from issuing commands until the GPU runs out of memory.

References getCachedAnemonesMemory().