Ion
|
A UniformBlock is a grouping of uniforms that can be easily shared between multiple Nodes; changing a Uniform in a UniformBlock will thus automatically change it for all Nodes that share the block. More...
#include "uniformblock.h"
Public Types | |
enum | Changes { kNumChanges = kNumBaseChanges } |
Changes that affect this resource. More... | |
enum | BaseChanges { kLabelChanged, kResourceChanged, kNumBaseChanges } |
All ResourceHolders derived from this should start their own change enums from kNumBaseChanges. More... | |
Public Member Functions | |
UniformBlock () | |
void | SetResource (size_t index, ResourceKey key, ResourceBase *resource) const |
Sets the resource at the passed index and key. More... | |
ResourceBase * | GetResource (size_t index, ResourceKey key) const |
Returns the Resource at the given index and key, or NULL if no resource was previously set at that location. More... | |
int | GetResourceCount () const |
Returns the number of resources that this holder holds. More... | |
size_t | GetGpuMemoryUsed () const |
Returns the total amount of GPU memory used by this Holder's resource. More... | |
const std::string & | GetLabel () const |
Returns/sets the label of this. More... | |
void | SetLabel (const std::string &label) |
void | AddReceiver (Notifier *receiver) |
Adds a Notifier to be notified. More... | |
void | RemoveReceiver (Notifier *receiver) |
Removes a Notifier to be notified. More... | |
size_t | GetReceiverCount () const |
Returns the number of Notifiers that will be notified. More... | |
const AllocatorPtr & | GetAllocator () const |
Returns the Allocator that was used for the instance. More... | |
const AllocatorPtr & | GetNonNullAllocator () const |
Return our allocator, or the default allocator if the instance was declared on the stack. More... | |
const AllocatorPtr & | GetAllocatorForLifetime (AllocationLifetime lifetime) const |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More... | |
void * | operator new (size_t size) |
The standard no-parameter new operator uses the default Allocator. More... | |
void * | operator new (size_t size, AllocationLifetime lifetime) |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator) |
This overloaded version of the new operator takes the Allocator to use directly as a parameter. More... | |
void * | operator new (size_t size, const AllocatorPtr &allocator, void *ptr) |
Special operator new for using placement new with Allocatables. More... | |
void * | operator new (size_t size, void *ptr) |
The placement new operator is defined conventionally. More... | |
void | operator delete (void *ptr) |
Define the delete operator to use specialized functions dealing with an Allocator. More... | |
void | operator delete (void *ptr, AllocationLifetime lifetime) |
Windows requires these (or it issues C4291 warnings). More... | |
void | operator delete (void *ptr, const AllocatorPtr &allocator) |
void | operator delete (void *ptr, void *ptr2) |
The placement delete operator does nothing, as usual. More... | |
int | GetRefCount () const |
GetRefCount() is part of the interface necessary for SharedPtr. More... | |
size_t | AddUniform (const Uniform &uniform) |
Adds a uniform to this and returns an index that can be used to refer to the uniform. More... | |
bool | ReplaceUniform (size_t index, const Uniform &uniform) |
Replaces the uniform at an index with the passed value, if the index is valid. More... | |
bool | RemoveUniformByName (const std::string &name) |
Removes the uniform with the passed name if it exists. More... | |
void | ClearUniforms () |
Clears the vector of uniforms in this. More... | |
const base::AllocVector < Uniform > & | GetUniforms () const |
Gets the vector of uniforms. More... | |
template<typename T > | |
bool | SetUniformValue (size_t index, const T &value) |
Sets the value of the uniform at an index if the index is valid. More... | |
template<typename T > | |
bool | SetUniformValueAt (size_t index, size_t array_index, const T &value) |
Sets the value of the array uniform at an index if the index is valid. More... | |
size_t | GetUniformIndex (const std::string &name) const |
Returns the index of the uniform this with the given name, if it exists. More... | |
template<typename T > | |
bool | SetUniformByName (const std::string &name, const T &value) |
Convenience function to set the value of a uniform specified by name. More... | |
template<typename T > | |
bool | SetUniformByNameAt (const std::string &name, size_t array_index, const T &value) |
Convenience function to set the value of an element of an array uniform designated by name . More... | |
void | Enable (bool enable) |
Enables or disables the UniformHolder. More... | |
bool | IsEnabled () const |
Protected Types | |
typedef WeakReferentPtr< Notifier > | NotifierPtr |
typedef AllocVector< NotifierPtr > | NotifierPtrVector |
Protected Member Functions | |
~UniformBlock () override | |
The destructor is protected because all base::Referent classes must have protected or private destructors. More... | |
void | OnChanged (int bit) const |
Forwards OnChanged to all resources. More... | |
const NotifierPtrVector & | GetReceivers () const |
Returns the set of Notifiers that will be notified. More... | |
void | Notify () const |
Notifies all contained Notifiers by calling their OnNotify(). More... | |
virtual void | OnNotify (const Notifier *notifier) |
Subclasses can override this to provide custom behavior on notifications. More... | |
A UniformBlock is a grouping of uniforms that can be easily shared between multiple Nodes; changing a Uniform in a UniformBlock will thus automatically change it for all Nodes that share the block.
Note that adding a Uniform adds a copy of the instance; to modify a uniform value use ReplaceUniform() or SetUniformValue[At]().
Definition at line 39 of file uniformblock.h.
|
protectedinherited |
Definition at line 49 of file notifier.h.
|
protectedinherited |
Definition at line 50 of file notifier.h.
|
inherited |
All ResourceHolders derived from this should start their own change enums from kNumBaseChanges.
Enumerator | |
---|---|
kLabelChanged | |
kResourceChanged | |
kNumBaseChanges |
Definition at line 56 of file resourceholder.h.
Changes that affect this resource.
Enumerator | |
---|---|
kNumChanges |
Definition at line 42 of file uniformblock.h.
ion::gfx::UniformBlock::UniformBlock | ( | ) |
Definition at line 23 of file uniformblock.cc.
|
overrideprotected |
The destructor is protected because all base::Referent classes must have protected or private destructors.
Definition at line 25 of file uniformblock.cc.
|
inherited |
Adds a Notifier to be notified.
Does nothing if the receiver is NULL or is already in the receiver vector.
Definition at line 25 of file notifier.cc.
Adds a uniform to this and returns an index that can be used to refer to the uniform.
Note that this index is invalid if ClearUniforms() is ever used, and may refer to a different uniform if the uniform is ever replaced with ReplaceUniform(). Returns base::kInvalidIndex if an attempt is made to add an invalid uniform.
Definition at line 46 of file uniformholder.h.
References ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid(), and ion::base::kInvalidIndex.
Referenced by ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().
|
inlineinherited |
Clears the vector of uniforms in this.
Definition at line 78 of file uniformholder.h.
Referenced by ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().
|
inlineinherited |
Enables or disables the UniformHolder.
Disabled holders are skipped over during rendering; their values are not sent to OpenGL. UniformHolders are enabled by default.
Definition at line 137 of file uniformholder.h.
|
inlineinherited |
Returns the Allocator that was used for the instance.
This will be NULL if the instance was declared on the stack or created with normal placement new.
Definition at line 68 of file allocatable.h.
References allocator_.
Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().
|
inlineinherited |
Convenience function that returns the Allocator to use to allocate an object with a specific lifetime.
Definition at line 78 of file allocatable.h.
References ion::base::Allocator::GetAllocatorForLifetime().
Referenced by ion::text::BasicBuilder::BuildVertexData(), ion::text::OutlineBuilder::BuildVertexData(), ion::gfxutils::ShaderManager::CreateShaderProgram(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), ion::text::DynamicFontImage::FindImageDataIndex(), ion::gfx::Renderer::Renderer(), and ion::gfx::UpdateStateTable().
|
inlineinherited |
Returns the total amount of GPU memory used by this Holder's resource.
Definition at line 78 of file resourceholder.h.
|
inlineinherited |
Returns/sets the label of this.
Definition at line 89 of file resourceholder.h.
|
inlineinherited |
Return our allocator, or the default allocator if the instance was declared on the stack.
Definition at line 72 of file allocatable.h.
References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().
|
inherited |
Returns the number of Notifiers that will be notified.
Definition at line 71 of file notifier.cc.
|
protectedinherited |
Returns the set of Notifiers that will be notified.
Definition at line 77 of file notifier.cc.
|
inlineinherited |
GetRefCount() is part of the interface necessary for SharedPtr.
Definition at line 34 of file shareable.h.
Referenced by ion::base::Notifier::RemoveReceiver().
|
inherited |
Returns the Resource at the given index and key, or NULL if no resource was previously set at that location.
Definition at line 122 of file resourceholder.cc.
|
inlineinherited |
Returns the number of resources that this holder holds.
Note that this is not necessarily the number of indices that have non-NULL resources. This can be used as a fast trivial check to see if the holder has any resources.
Definition at line 73 of file resourceholder.h.
|
inherited |
Returns the index of the uniform this with the given name, if it exists.
The Uniform must have been added with AddUniform() or ReplaceUniform(). If no uniform with the name exists in this then returns ion::base::kInvalidIndex. Note that this is a relatively slow operation and should be used sparingly.
Definition at line 30 of file uniformholder.cc.
References DCHECK, ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::GetIndexInRegistry(), ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::GetRegistry(), ion::gfx::ShaderInputRegistry::GetSpecs(), ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid(), and ion::base::kInvalidIndex.
|
inlineinherited |
Gets the vector of uniforms.
Definition at line 81 of file uniformholder.h.
Referenced by ion::text::Builder::UpdateFontImageTextureUniform(), ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().
|
inlineinherited |
Definition at line 138 of file uniformholder.h.
|
protectedinherited |
Notifies all contained Notifiers by calling their OnNotify().
Any receivers that have been destroyed will be removed from the vector of receivers.
Definition at line 81 of file notifier.cc.
References ion::base::SharedPtr< T >::Get().
|
inlineprotectedinherited |
Forwards OnChanged to all resources.
Definition at line 326 of file resourceholder.h.
|
protectedvirtualinherited |
Subclasses can override this to provide custom behavior on notifications.
Definition at line 96 of file notifier.cc.
|
inlineinherited |
Define the delete operator to use specialized functions dealing with an Allocator.
Definition at line 109 of file allocatable.h.
|
inlineinherited |
Windows requires these (or it issues C4291 warnings).
Definition at line 112 of file allocatable.h.
|
inlineinherited |
Definition at line 113 of file allocatable.h.
|
inlineinherited |
The placement delete operator does nothing, as usual.
Definition at line 118 of file allocatable.h.
|
inlineinherited |
The standard no-parameter new operator uses the default Allocator.
Definition at line 84 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.
Definition at line 88 of file allocatable.h.
|
inlineinherited |
This overloaded version of the new operator takes the Allocator to use directly as a parameter.
If the Allocator pointer is NULL, this uses the default Allocator.
Definition at line 95 of file allocatable.h.
|
inlineinherited |
Special operator new for using placement new with Allocatables.
Definition at line 100 of file allocatable.h.
|
inlineinherited |
The placement new operator is defined conventionally.
Definition at line 105 of file allocatable.h.
|
inherited |
Removes a Notifier to be notified.
Does nothing if the receiver is NULL or not in the set of receivers.
Definition at line 38 of file notifier.cc.
References ion::base::Shareable::GetRefCount().
Referenced by ion::gfx::AttributeArray::~AttributeArray().
|
inlineinherited |
Removes the uniform with the passed name if it exists.
Returns true iff the uniform existed and hence got removed. Note that this will change the indices of other uniforms within the holder.
Definition at line 69 of file uniformholder.h.
References ion::base::kInvalidIndex.
|
inlineinherited |
Replaces the uniform at an index with the passed value, if the index is valid.
Returns if the replacement is successful.
Definition at line 57 of file uniformholder.h.
References ion::gfx::ShaderInput< ValueHolderType, ValueEnumType >::IsValid().
|
inlineinherited |
Definition at line 90 of file resourceholder.h.
|
inherited |
Sets the resource at the passed index and key.
The size of the internal vector is automatically managed so that it has the smallest possible size.
Definition at line 51 of file resourceholder.cc.
References DCHECK, DCHECK_EQ, ion::gfx::ResourceBase::GetKey(), and ion::gfx::ResourceBase::OnChanged().
|
inlineinherited |
Convenience function to set the value of a uniform specified by name.
This returns false if there is no uniform with that name or the value type does not match.
Definition at line 113 of file uniformholder.h.
References ion::base::kInvalidIndex, and value.
|
inlineinherited |
Convenience function to set the value of an element of an array uniform designated by name
.
This returns false if:
name
.array_index
exceeds the size of the uniform array. Definition at line 125 of file uniformholder.h.
References ion::base::kInvalidIndex.
|
inlineinherited |
Sets the value of the uniform at an index if the index is valid.
Returns true if the index is valid and the set was successful (i.e., T is a valid type for the selected uniform), and false otherwise.
Definition at line 86 of file uniformholder.h.
Referenced by ion::text::Builder::UpdateFontImageTextureUniform(), ion::text::BasicBuilder::UpdateUniforms(), and ion::text::OutlineBuilder::UpdateUniforms().
|
inlineinherited |
Sets the value of the array uniform at an index if the index is valid.
Returns true if the index is valid and the set was successful (i.e., T is a valid type for the selected uniform), and false otherwise.
Definition at line 95 of file uniformholder.h.