SilverLining
|
This class is the main interface to thread safe rendering with SilverLining. More...
#include <ThreadCameraStreamData.h>
Public Member Functions | |
ThreadCameraStreamData (bool rightHanded, double unitScale, bool deferred) | |
constructor | |
virtual | ~ThreadCameraStreamData () |
destructor | |
const Camera * | GetCamera (void) const |
These are the only public methods you need to use to render multiple views using multiple threads with/without command lists. | |
Camera * | GetCamera (void) |
get the associated camera (non-const) | |
int | Initialize (int rendererType, bool rightHanded, void *environment, bool avoidStalls) |
Initialize the ThreadCameraStreamData (call first) | |
void | Initialize (const Atmosphere &atmosphere) |
Initialize the ThreadCameraStreamData for a given Atmosphere object (call 2nd) | |
bool | IsInitialized (void) const |
Whether initialized. | |
void | ExecuteStream (void) |
Execute the command list for this object. | |
void | SetRandomNumberGenerator (RandomNumberGenerator *rng) |
Some effects (like lightning) need to be synchronized across multiple views. | |
RandomNumberGenerator * | GetRandomNumberGenerator () const |
Get the random number generator. | |
void | SetUserData (const void *userPointer, TcsUserData *userData) |
!!!!Do Not Use!!!! !!!!Internal methods!!!! These should not be used by application developers!! | |
TcsUserData * | GetUserData (const void *userPointer) |
get a user pointer and the user data associated with it, if it exists null otherwise | |
bool | UserDataExists (const void *userPointer) const |
whether user data exists for a user pointer | |
void | EraseUserData (const void *userPointer) |
erase user data associated with this layer (just erases the entry) | |
void | SetCloudLayerTcsUserData (const CloudLayer *cloudLayer, TcsUserData *userData) |
These are named variations of the 3 functions above. | |
TcsUserData * | GetCloudLayerTcsUserData (const CloudLayer *cloudLayer) |
get the name with userDataName as the key | |
bool | CloudLayerTcsUserDataExists (const CloudLayer *cloudLayer) |
exists? | |
void | EraseCloudLayerTcsUserData (const CloudLayer *cloudLayer) |
erase user data associated with this layer (just erases the entry) | |
Renderer * | GetRenderer (void) |
internal. do not use directly | |
const Renderer * | GetRenderer (void) const |
internal. do not use directly | |
const BillboardRenderingParameters * | GetBillboardRenderingParams (void) const |
internal. Do not use directly. Get the parameters, const version | |
BillboardRenderingParameters * | GetBillboardRenderingParams (void) |
internal. Do not use directly. Get the parameters, non-const version | |
const MetaballRenderingParameters * | GetMetaballRenderingParams (void) const |
internal. Do not use directly. Get the parameters, const version | |
MetaballRenderingParameters * | GetMetaballRenderingParams (void) |
internal. Do not use directly. Get the parameters, non-const version | |
const BillboardRenderer * | GetBillboardRenderer (void) const |
internal. Do not use directly. Get the billboard renderer, const version | |
BillboardRenderer * | GetBillboardRenderer (void) |
internal. Do not use directly. Get the billboard renderer, non-const version | |
const CloudRenderingParameters * | GetCloudRenderingParams (void) const |
internal. Do not use directly. Get the parameters, const version | |
CloudRenderingParameters * | GetCloudRenderingParams (void) |
internal. Do not use directly. Get the parameters, non-const version | |
const CumulusCloudRenderingParameters * | GetCumulusCloudRenderingParams (void) const |
internal. Do not use directly. Get the parameters, const version | |
CumulusCloudRenderingParameters * | GetCumulusCloudRenderingParams (void) |
internal. Do not use directly. Get the parameters, non-const version | |
const LuminanceMapper * | GetLuminanceMappper (void) const |
internal. Do not use directly. Get the parameters, const version | |
LuminanceMapper * | GetLuminanceMappper (void) |
internal. Do not use directly. Get the parameters, non-const version | |
bool | GetIsDrawingEnvMap () const |
internal. Do not use directly. Whether drawing env map currently | |
void | SetIsDrawingEnvMap (bool val) |
internal. Do not use directly. Set drawing env map to true/false | |
bool | GetIsDrawingShadowMap () const |
internal. Do not use directly. Whether drawing shadow map currently | |
void | SetIsDrawingShadowMap (bool val) |
internal. Do not use directly. Set drawing shadow map to true/false | |
bool | GetSortByScreenDepth (void) const |
internal. Do not use directly. Get sort screen depth | |
void | SetSortByScreenDepth (bool val) |
internal. Do not use directly. Set sort screen depth | |
const BillboardShader * | GetBillboardShader (void) const |
internal. do not use! | |
const BillboardShader * | GetBillboardShaderInstanced (void) const |
internal. do not use! | |
void | ReloadShaders (void) |
internal. do not use! | |
void | Shutdown (void) |
internal. do not use! | |
void | DeviceLost (void) |
internal. do not use! | |
void | DeviceReset (void) |
internal. do not use! | |
void | FrameStarted () |
internal. do not use! | |
void | SetContext () |
internal. do not use! | |
void | ReloadBillboardShader (void) |
internal. do not use! | |
const SkyShaders * | GetSkyShaders (bool simpleShader) const |
internal. do not use! | |
void | ReloadSkyShaders (void) |
internal. do not use! | |
const StratocumulusShaders * | GetStratocumulusShaders (void) const |
internal. do not use! | |
void | ReloadStratocumulusShaders (void) |
internal. do not use! | |
const FlareShader * | GetFlareShader (void) const |
internal. do not use! | |
const CirrusShader * | GetCirrusShader (void) const |
internal. do not use! | |
void | ReloadCirrusShader (void) |
internal. do not use! | |
const StratusShader * | GetStratusShader (void) const |
internal. do not use! | |
void | ReloadStratusShader (void) |
internal. do not use! | |
const StarShader * | GetStarShader (void) const |
internal. do not use! | |
void | ReloadStarShader (void) |
internal. do not use! | |
const GlareShader * | GetGlareShader (void) const |
internal. do not use! | |
GlareShader * | GetGlareShader (void) |
internal. do not use! | |
const AtmosphereFromSpaceShader * | GetAtmosphereFromSpaceShader (bool doShadow) const |
internal. do not use! | |
bool | GetDeferred (void) const |
get whether internal stream/context is a deferred stream call before initialize! | |
CrepuscularRays * | GetCrepuscularRays (void) |
internal. do not use! | |
const CrepuscularRays * | GetCrepuscularRays (void) const |
internal. do not use! | |
Sky * | GetSky (void) |
internal. do not use! | |
const Sky * | GetSky (void) const |
internal. do not use! | |
LensFlare * | GetLensFlare (void) |
internal. do not use! | |
const LensFlare * | GetLensFlare (void) const |
internal. do not use! | |
bool | GetIsDrawingSky (void) const |
internal. do not use! | |
bool | GetIsDrawingObjects (void) const |
internal. do not use! | |
void | SetIsDrawingSky (bool val) |
internal. do not use! | |
void | SetIsDrawingObjects (bool val) |
internal. do not use! | |
void | SetForceImmediate (bool val) |
internal. do not use! | |
bool | GetForceImmediate (void) const |
internal. do not use! | |
const PrecipitationShaders * | GetPrecipitationShaders (void) const |
internal. do not use! | |
PrecipitationShaders * | GetPrecipitationShaders (void) |
internal. do not use! | |
void | SetUpAndRightVector (const Vector3 &upVector, const Vector3 &rightVector) |
Helper function to set up the up and right vector on the Camera of this tcs data. | |
const PrecipitationManager * | GetPrecipitationManager (void) const |
internal. do not use! | |
PrecipitationManager * | GetPrecipitationManager (void) |
internal. do not use! | |
void | InitializePrecipitationManager (const Atmosphere &atmosphere) |
internal. do not use! | |
bool | GetPrecipitationEnabled (void) const |
internal. do not use! | |
const ShadowMap * | GetOrCreateShadowMap (const Atmosphere &atmosphere) const |
internal. do not use! | |
ShadowMap * | GetOrCreateShadowMap (const Atmosphere &atmosphere) |
internal. do not use! | |
const ShadowMap * | GetShadowMapObject (void) const |
internal. do not use! | |
int | GetShadowMapDim () const |
internal. do not use! | |
void | DeleteShadowMap (void) |
internal. do not use! | |
void | DeleteEnvironmentMaps (void) |
internal. do not use! | |
const MetaballTextureManager * | GetMetaballTextureManager (void) const |
internal. do not use! | |
void | setCreateTextures (bool create) |
internal. do not use! | |
bool | GetEnvironmentMap (EnvironmentMap *&environmentMap, Atmosphere &atmosphere, void *&texture, int facesToRender=6, bool floatingPoint=false, CameraHandle cameraID=0, bool drawClouds=true, bool drawSunAndMoon=true, bool geocentricMode=false) |
internal. do not use! | |
bool | DrawIndirect () const |
internal. do not use! | |
void | SetInfraRedMode (bool bInfraRed) |
set infra red mode | |
bool | GetInfraRedMode () const |
whether infra red model | |
void | SetTime (const LocalTime &pTime, unsigned long timerMilliseconds) |
internal. do not use! | |
const LocalTime & | GetTime (unsigned long timerMilliseconds) |
internal. do not use! | |
void | SetLocation (const Location &_location) |
internal. do not use! | |
const Location & | GetLocation () const |
internal. do not use! | |
Location & | GetLocation () |
internal. do not use! | |
void | SetBaseTimeMS (unsigned long val) |
internal. do not use! | |
unsigned long | GetBaseTimeMS (void) const |
internal. do not use! | |
void | EnableTimePassage (bool enabled, long relightFrequencyMS, unsigned long timerMilliseconds) |
internal. do not use! | |
LocalTime & | GetTime () |
internal. These are used for serialization only | |
bool | GetHDREnabled () const |
internal helper | |
const float * | GetStratusMieLookupPixels (int &width) |
internal. | |
const unsigned char * | GetStratusNoisePixels (int &width, int &height) |
internal. | |
Protected Member Functions | |
void | CreateStratusMieLookupPixels (void) |
internal | |
This class is the main interface to thread safe rendering with SilverLining.
The class represents the concept of thread local storage: https://en.wikipedia.org/wiki/Thread-local_storage
The 'thread' part of the name represents each separate thread (and hence each instance of this class) that we wish to render from in a thread safe fashion.
The 'camera' part of the name represents each view(e.g. window/offscreen view) that you wish to render from in a thread safe fashion in the corresponding thread.
This typically also corresponds to an OpenGL context (you can share OpenGL contexts or not) or an immediate/deferred DirectX context.
The 'stream' part of the name represents the command stream (OpenGL/Vulkan) or the immediate/deferred context commands (DX 11, 11.1) being generated for a given thread, view.
As an example, to render 3 views (one main view, and 2 offscreen views).
Below are then the steps you follow to render everything in a thread safe fashion:
A few notes:
So make sure to pass the pointer to the object of the thread/camera(view)/stream in question in the same order/position/context of which thread/camera(view)/stream is in question.
Multi-Threading:
Deferred Rendering:
!!NOTE!!
SilverLining::ThreadCameraStreamData::ThreadCameraStreamData | ( | bool | rightHanded, |
double | unitScale, | ||
bool | deferred | ||
) |
constructor
rightHanded | Set this the same as the initialized Atmosphere. |
unitScale | Set this the same as the initialized Atmosphere. |
deferred | Set whether this tcsData uses deferred rendering. |
void SilverLining::ThreadCameraStreamData::ExecuteStream | ( | void | ) |
Execute the command list for this object.
See documentation above on 'deferred rendering'.
const Camera * SilverLining::ThreadCameraStreamData::GetCamera | ( | void | ) | const |
These are the only public methods you need to use to render multiple views using multiple threads with/without command lists.
get the associated camera
RandomNumberGenerator * SilverLining::ThreadCameraStreamData::GetRandomNumberGenerator | ( | ) | const |
Get the random number generator.
See SetRandomNumberGenerator
const float * SilverLining::ThreadCameraStreamData::GetStratusMieLookupPixels | ( | int & | width | ) |
internal.
do not use! creates if necessary
const unsigned char * SilverLining::ThreadCameraStreamData::GetStratusNoisePixels | ( | int & | width, |
int & | height | ||
) |
internal.
do not use! creates if necessary
void SilverLining::ThreadCameraStreamData::Initialize | ( | const Atmosphere & | atmosphere | ) |
Initialize the ThreadCameraStreamData for a given Atmosphere object (call 2nd)
environment | The atmosphere against which this tcsData is being initialized |
int SilverLining::ThreadCameraStreamData::Initialize | ( | int | rendererType, |
bool | rightHanded, | ||
void * | environment, | ||
bool | avoidStalls | ||
) |
Initialize the ThreadCameraStreamData (call first)
rendererType | The renderer type. The same as the type passed in to Atmosphere::Initialize |
rightHanded | right handed or left handed system. The same as the type passed in to Atmosphere |
environment | The same value as the one passed in to Atmosphere::Initialize |
avoidStalls | If you with to do any combination of multi-threaded rendering and deferred you need to set this config option on the Atmosphere: atmosphere->SetConfigOption("avoid-opengl-stalls", "yes"); and pass the same value (true) |
void SilverLining::ThreadCameraStreamData::SetCloudLayerTcsUserData | ( | const CloudLayer * | cloudLayer, |
TcsUserData * | userData | ||
) |
These are named variations of the 3 functions above.
set the name with userDataName as the key
void SilverLining::ThreadCameraStreamData::SetRandomNumberGenerator | ( | RandomNumberGenerator * | rng | ) |
Some effects (like lightning) need to be synchronized across multiple views.
Re-seeding the atmosphere random number in these cases per view doesn't quite work right for those. To avoid this, set the value of tcs-data-effects-rng-unique to yes. Then, the tcs datas will use their own internal random generators in this case (which if seeded/reset the same, will synchronize the effects across the views.
If an rng is not set via this call (and the tcs-data-effects-rng-unique is 'yes', the tcs data will use its own internal rng.
void SilverLining::ThreadCameraStreamData::SetSortByScreenDepth | ( | bool | val | ) |
internal. Do not use directly. Set sort screen depth
Set whether objects should be sorted by screen depth or distance from the view
void SilverLining::ThreadCameraStreamData::SetUserData | ( | const void * | userPointer, |
TcsUserData * | userData | ||
) |
!!!!Do Not Use!!!! !!!!Internal methods!!!! These should not be used by application developers!!
set a user pointer and the user data associated with it