NAP
Classes | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
StructFillPolicy Class Reference

#include <structfillpolicy.h>

Classes

class  BaseEntry
 
class  Entry
 

Public Member Functions

bool fill (StructBufferDescriptor *descriptor, uint8 *data, utility::ErrorState &errorState)
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

std::vector< rtti::ObjectPtr< BaseEntry > > mFillPolicies
 Property 'FillPolicies': List of shader variable fill policy entries. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Member Functions

bool fillFromUniformRecursive (const UniformStruct *uniformStruct, uint8 *data, size_t &outElementSize, utility::ErrorState &errorState)
 
template<typename T >
const FillPolicy< T > * findPolicy (const std::string &name)
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

Fill policy for struct buffers.

Fill policies are initialization utilities that can help fill large blocks of preallocated memory. The fill function assigns a contiguous block of data based on the specified arguments.

StructFillPolicy internally uses TypedFillPolicyNumeric mapped to member names to determine how to fill the struct buffer. The behavior of this fill policy is created in configuration using a set of variable fill policy entries. Each entry maps a struct member name to a fill policy. The fill() function is then able to fill the buffer it is bound to automatically.

Fill policies can be bound to another resource's property (i.e. StructGPUBuffer) in configuration. Typically, an object will first check if a policy is available, and if so, use it to fill an internal buffer. Any object accepting a fill policy is free to implement the way fill() is used in their own way however.

Inheritance diagram for StructFillPolicy:
[legend]
Collaboration diagram for StructFillPolicy:
[legend]

Member Function Documentation

◆ fill()

bool fill ( StructBufferDescriptor descriptor,
uint8 data,
utility::ErrorState errorState 
)

Fills a preallocated buffer using the specified struct buffer descriptor.

Parameters
descriptorbuffer fill description handle
datapointer to the preallocated data
errorStatecontains the error if the buffer cannot be filled

◆ fillFromUniformRecursive()

bool fillFromUniformRecursive ( const UniformStruct uniformStruct,
uint8 data,
size_t &  outElementSize,
utility::ErrorState errorState 
)
protected

Recursively fills the buffer based on the specified uniform struct.

Parameters
uniformStructthe reference uniform used to determine the memory locations to fill
datapointer to the preallocated data
outElementSizethe size of the specified uniform struct in bytes
errorStatecontains the error if the buffer cannot be filled

◆ findPolicy()

const FillPolicy<T>* findPolicy ( const std::string &  name)
protected

Returns a fill policy for the given member name if it is specified in the variable fill policies property, otherwise returns nullptr.

Parameters
namethe name of the member to apply the associated fill policy on
Returns
the buffer fill policy associated with the given member name, otherwise nullptr

Member Data Documentation

◆ mFillPolicies

std::vector<rtti::ObjectPtr<BaseEntry> > mFillPolicies

Property 'FillPolicies': List of shader variable fill policy entries.