Class ReadOnlyDeviceEnvironment

Inheritance Relationships

Derived Type

Class Documentation

class flamegpu::ReadOnlyDeviceEnvironment

Utility for accessing environmental properties These can only be read within agent functions They can be set and updated within host functions

Subclassed by flamegpu::DeviceEnvironment

Public Functions

template<typename T, unsigned int N>
__device__ __forceinline__ T getProperty(const char (&name)[N]) const

Gets an environment property

Getters

Parameters

name – name used for accessing the property, this value should be a string literal e.g. “foobar”

Template Parameters
  • T – Type of the environment property being accessed

  • N – Length of property name, this should always be implicit if passing a string literal

Throws
  • exception::DeviceError – If name is not a valid property within the environment (flamegpu must be built with SEATBELTS enabled for device error checking)

  • exception::DeviceError – If T is not the type of the environment property specified by name (flamegpu must be built with SEATBELTS enabled for device error checking)

template<typename T, unsigned int N>
__device__ __forceinline__ T getProperty(const char (&name)[N], const unsigned int &index) const

Gets an element of an environment property array

Parameters
  • name – name used for accessing the property, this value should be a string literal e.g. “foobar”

  • index – Index of the element within the environment property array to return

Template Parameters
  • T – Type of the environment property being accessed

  • N – Length of property name, this should always be implicit if passing a string literal

Throws
  • exception::DeviceError – If name is not a valid property within the environment (flamegpu must be built with SEATBELTS enabled for device error checking)

  • exception::DeviceError – If T is not the type of the environment property specified by name (flamegpu must be built with SEATBELTS enabled for device error checking)

  • exception::DeviceError – If index is out of bounds for the environment property array specified by name (flamegpu must be built with SEATBELTS enabled for device error checking)

template<unsigned int N>
__device__ __forceinline__ bool containsProperty(const char (&name)[N]) const

Returns whether the named env property exists

Util

Note

Use of this function is not recommended as it should be unnecessary and will impact performance

Parameters

name – name used for accessing the property, this value should be a string literal e.g. “foobar”

Template Parameters

N – Length of variable name, this should always be implicit if passing a string literal

template<typename T, unsigned int I = 1, unsigned int J = 1, unsigned int K = 1, unsigned int W = 1, unsigned int N>
__device__ __forceinline__ ReadOnlyDeviceMacroProperty<T, I, J, K, W> getMacroProperty(const char (&name)[N]) const

Returns a read-only accessor to the named macro property

Parameters

name – name used for accessing the property, this value should be a string literal e.g. “foobar”

Template Parameters
  • I – Length of macro property in the 1st dimension, default 1

  • J – Length of macro property in the 2nd dimension, default 1

  • K – Length of macro property in the 3rd dimension, default 1

  • W – Length of macro property in the 4th dimension, default 1

  • N – Length of variable name, this should always be implicit if passing a string literal

Protected Functions

__device__ __forceinline__ inline ReadOnlyDeviceEnvironment(const detail::curve::Curve::NamespaceHash &_modelname_hash)

Constructor, requires the model name hash to init modelname_hash

Parameters

_modelname_hash – Hash of model name generated by curveGetVariableHash()

Protected Attributes

const detail::curve::Curve::NamespaceHash &modelname_hash

Hash of the model’s name, this is added to CURVE_NAMESPACE_HASH and variable name hash to find curve hash

Protected Static Functions

__host__ __device__ static inline constexpr unsigned int CURVE_NAMESPACE_HASH()

Device accessible copy of curve namespace hash, this is precomputed from EnvironmentManager::CURVE_NAMESPACE_HASH EnvironmentManager::initialiseDevice() validates that this value matches

__host__ __device__ static inline constexpr unsigned int MACRO_NAMESPACE_HASH()

Device accessible copy of macro namespace hash, this is precomputed from CUDAMacroEnvironment::MACRO_NAMESPACE_HASH CUDAMacroEnvironment::CUDAMacroEnvironment() validates that this value matches