Nebula
Loading...
Searching...
No Matches
Materials Namespace Reference

Detailed Description

Material special version of variant.

Classes

struct  [struct].materialLoaderState
struct  MaterialBuffer
struct  MaterialConstant
struct  MaterialId
struct  MaterialInstanceId
class  MaterialLoader
struct  MaterialTexture
struct  MaterialVariant
struct  ShaderConfigBatchTexture

Typedefs

typedef IndexT BatchIndex
typedef Ids::IdAllocator< Util::StringAtom, float, Util::Array< Resources::ResourceId >, Util::FixedArray< CoreGraphics::ResourceTableId >, CoreGraphics::BufferId, Util::FixedArray< Util::FixedArray< CoreGraphics::ResourceTableId > >, Util::FixedArray< Util::Tuple< IndexT, SizeT > >, Util::FixedArray< Util::Array< MaterialTexture > >, Util::FixedArray< Util::Array< MaterialConstant > >, IndexT, const MaterialTemplatesGPULang::Entry *, uint > MaterialAllocator
typedef Ids::IdAllocator< uint > MaterialInstanceAllocator
using LoaderFunc = void(*)(Ptr<IO::BXmlReader>, Materials::MaterialId, Util::StringAtom)

Enumerations

enum  BindlessBufferDirtyBits { Graphics = 0x1 , Compute = 0x2 , All = Graphics | Compute }
enum  {
  Material_Name , Material_MinLOD , Material_LODTextures , Material_Table ,
  Material_Buffer , Material_InstanceTables , Material_InstanceBuffers , Material_Textures ,
  Material_Constants , Material_BufferOffset , Material_Template , Material_Version
}
enum  MaterialInstanceMembers { MaterialInstance_Offsets }

Functions

static void MaterialSetupTemplate (const Ids::Id32 id, const MaterialTemplatesGPULang::Entry *entry)
 Build everything of a material that depends on its template: the constant buffer with the template's defaults, the resource tables of the template's passes and the default textures.
static void MaterialReleaseTemplate (const Ids::Id32 id)
 Release what MaterialSetupTemplate built.
MaterialId CreateMaterial (const MaterialTemplatesGPULang::Entry *entry, const Util::StringAtom &name)
 Create material.
void MaterialReloadTemplate (const MaterialId mat, const MaterialTemplatesGPULang::Entry *entry)
 Rebuild the material for a template under the same id, so everything holding the material keeps working with it.
void DestroyMaterial (const MaterialId id)
 Destroy material.
uint MaterialGetVersion (const MaterialId mat)
 Callbacks that outlive a reload of the material, like those of textures still loading, compare this with the version they were issued for.
void MaterialSetTexture (const MaterialId mat, const ShaderConfigBatchTexture *bind, const Resources::ResourceId tex)
 Set texture.
void MaterialSetTexture (const MaterialId mat, uint name, const Resources::ResourceId tex)
 Set texture.
void MaterialSetTextureBindless (const MaterialId mat, uint name, const uint handle, const uint offset, const Resources::ResourceId tex)
 Set bindless texture.
void MaterialSetConstants (const MaterialId mat, const void *data, const uint size)
 Set all material constants.
void MaterialSetConstant (const MaterialId mat, const void *data, const uint size, const uint offset)
 Set a material constant.
void MaterialSetData (const MaterialId mat, const void *data, const uint size)
 Set the entire material buffer.
void MaterialSetBufferBinding (const MaterialId id, IndexT index)
 Set material GPU buffer binding.
IndexT MaterialGetBufferBinding (const MaterialId id)
 Get material GPU buffer binding.
const Util::StringAtom & MaterialGetName (const MaterialId id)
 Get name of material.
void MaterialAddLODTexture (const MaterialId mat, const Resources::ResourceId tex)
 Add texture to LOD update.
void MaterialSetLowestLod (const MaterialId mat, float lod)
 Update LOD for material.
const MaterialTemplatesGPULang::Entry * MaterialGetTemplate (const MaterialId mat)
 Get material shader config.
const Materials::BatchIndex MaterialGetBatchIndex (const MaterialId mat, const MaterialTemplatesGPULang::BatchGroup batch)
 Get batch index from code.
uint64_t MaterialGetSortCode (const MaterialId mat)
 Get sort code.
void MaterialApply (const MaterialId id, const CoreGraphics::CmdBufferId buf, IndexT index)
 Apply material.
MaterialInstanceId CreateMaterialInstance (const MaterialId material)
 Create material instance.
void DestroyMaterialInstance (const MaterialInstanceId materialInstance)
 Destroy material instance.
CoreGraphics::ConstantBufferOffset MaterialInstanceAllocate (const MaterialInstanceId mat, const BatchIndex batch)
 Allocate instance constants, call per frame when instance constants are needed.
void MaterialInstanceApply (const MaterialInstanceId id, const CoreGraphics::CmdBufferId buf, IndexT index, IndexT bufferIndex)
 Apply material instance.
SizeT MaterialInstanceBufferSize (const MaterialInstanceId sur, const BatchIndex batch)
 Get material instance buffer size for batch.
 __ImplementClass (Materials::MaterialLoader, 'MALO', Resources::ResourceLoader)
void LoadTexture (const Ptr< IO::BXmlReader > &reader, CoreGraphics::TextureId def, const char *name, const char *tag, uint &handle, bool &dirtyFlag, void *data, size_t dataSize, const Materials::MaterialId mat)
void LoadVec4 (const Ptr< IO::BXmlReader > &reader, const char *name, float value[4], const Math::vec4 &def)
void LoadVec3 (const Ptr< IO::BXmlReader > &reader, const char *name, float value[3], const Math::vec3 &def)
void LoadFloat (const Ptr< IO::BXmlReader > &reader, const char *name, float &value, const float def)
void LoadMaterialParameter (Ptr< IO::BXmlReader > reader, Util::StringAtom name, const MaterialTemplatesGPULang::Entry *entry, const Materials::MaterialId id, bool immediate)
static void LoadMaterialParams (const Ptr< IO::BXmlReader > &reader, const MaterialId id, const MaterialTemplatesGPULang::Entry *materialTemplate, const Util::StringAtom &tag, const IO::URI &uri)
 Apply the material's values and textures in the Params node, the reader has to be at the surface node.

Variables

MaterialAllocator materialAllocator
MaterialInstanceAllocator materialInstanceAllocator
Threading::CriticalSection materialTextureLoadSection
static uint materialVersionCounter = 0
 material
Util::Dictionary< MaterialTemplatesGPULang::MaterialProperties, LoaderFunc > LoaderMap
struct  materialLoaderState

Typedef Documentation

◆ BatchIndex

◆ LoaderFunc

◆ MaterialAllocator

◆ MaterialInstanceAllocator

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
Material_Name 
Material_MinLOD 
Material_LODTextures 
Material_Table 
Material_Buffer 
Material_InstanceTables 
Material_InstanceBuffers 
Material_Textures 
Material_Constants 
Material_BufferOffset 
Material_Template 
Material_Version 

◆ BindlessBufferDirtyBits

Enumerator
Graphics 
Compute 
All 

◆ MaterialInstanceMembers

Enumerator
MaterialInstance_Offsets 

Function Documentation

◆ __ImplementClass()

Materials::__ImplementClass ( Materials::MaterialLoader ,
'MALO' ,
Resources::ResourceLoader  )

◆ CreateMaterial()

MaterialId Materials::CreateMaterial ( const MaterialTemplatesGPULang::Entry * entry,
const Util::StringAtom & name )

Create material.

◆ CreateMaterialInstance()

MaterialInstanceId Materials::CreateMaterialInstance ( const MaterialId material)

Create material instance.

◆ DestroyMaterial()

void Materials::DestroyMaterial ( const MaterialId id)

Destroy material.

◆ DestroyMaterialInstance()

void Materials::DestroyMaterialInstance ( const MaterialInstanceId materialInstance)

Destroy material instance.

◆ LoadFloat()

void Materials::LoadFloat ( const Ptr< IO::BXmlReader > & reader,
const char * name,
float & value,
const float def )

◆ LoadMaterialParameter()

void Materials::LoadMaterialParameter ( Ptr< IO::BXmlReader > reader,
Util::StringAtom name,
const MaterialTemplatesGPULang::Entry * entry,
const Materials::MaterialId id,
bool immediate )

◆ LoadMaterialParams()

void Materials::LoadMaterialParams ( const Ptr< IO::BXmlReader > & reader,
const MaterialId id,
const MaterialTemplatesGPULang::Entry * materialTemplate,
const Util::StringAtom & tag,
const IO::URI & uri )
static

Apply the material's values and textures in the Params node, the reader has to be at the surface node.

◆ LoadTexture()

void Materials::LoadTexture ( const Ptr< IO::BXmlReader > & reader,
CoreGraphics::TextureId def,
const char * name,
const char * tag,
uint & handle,
bool & dirtyFlag,
void * data,
size_t dataSize,
const Materials::MaterialId mat )

◆ LoadVec3()

void Materials::LoadVec3 ( const Ptr< IO::BXmlReader > & reader,
const char * name,
float value[3],
const Math::vec3 & def )

◆ LoadVec4()

void Materials::LoadVec4 ( const Ptr< IO::BXmlReader > & reader,
const char * name,
float value[4],
const Math::vec4 & def )

◆ MaterialAddLODTexture()

void Materials::MaterialAddLODTexture ( const MaterialId mat,
const Resources::ResourceId tex )

Add texture to LOD update.

◆ MaterialApply()

void Materials::MaterialApply ( const MaterialId id,
const CoreGraphics::CmdBufferId buf,
IndexT index )

Apply material.

◆ MaterialGetBatchIndex()

const Materials::BatchIndex Materials::MaterialGetBatchIndex ( const MaterialId mat,
const MaterialTemplatesGPULang::BatchGroup batch )

Get batch index from code.

◆ MaterialGetBufferBinding()

IndexT Materials::MaterialGetBufferBinding ( const MaterialId id)

Get material GPU buffer binding.

◆ MaterialGetName()

const Util::StringAtom & Materials::MaterialGetName ( const MaterialId id)

Get name of material.

◆ MaterialGetSortCode()

uint64_t Materials::MaterialGetSortCode ( const MaterialId mat)

Get sort code.

◆ MaterialGetTemplate()

const MaterialTemplatesGPULang::Entry * Materials::MaterialGetTemplate ( const MaterialId mat)

Get material shader config.

◆ MaterialGetVersion()

uint Materials::MaterialGetVersion ( const MaterialId mat)

Callbacks that outlive a reload of the material, like those of textures still loading, compare this with the version they were issued for.

Get the version of the material, it changes every time the material is built for a template.

◆ MaterialInstanceAllocate()

CoreGraphics::ConstantBufferOffset Materials::MaterialInstanceAllocate ( const MaterialInstanceId mat,
const BatchIndex batch )

Allocate instance constants, call per frame when instance constants are needed.

◆ MaterialInstanceApply()

void Materials::MaterialInstanceApply ( const MaterialInstanceId id,
const CoreGraphics::CmdBufferId buf,
IndexT index,
IndexT bufferIndex )

Apply material instance.

◆ MaterialInstanceBufferSize()

SizeT Materials::MaterialInstanceBufferSize ( const MaterialInstanceId mat,
const BatchIndex batch )

Get material instance buffer size for batch.

◆ MaterialReleaseTemplate()

void Materials::MaterialReleaseTemplate ( const Ids::Id32 id)
static

Release what MaterialSetupTemplate built.

The tables and the buffer are deleted once the frames in flight are done with them

◆ MaterialReloadTemplate()

void Materials::MaterialReloadTemplate ( const MaterialId mat,
const MaterialTemplatesGPULang::Entry * entry )

Rebuild the material for a template under the same id, so everything holding the material keeps working with it.

Rebuild a material in place for a template, for reloading, see MaterialLoader::ReinitializeResource.

The values and textures start out as the template's defaults, the caller applies the material's own. The buffer binding and the LOD are kept, they belong to the loader and to the material's distance.

Nodes cache the template of their material, the reload listener in ModelContext::Create updates them

◆ MaterialSetBufferBinding()

void Materials::MaterialSetBufferBinding ( const MaterialId id,
IndexT index )

Set material GPU buffer binding.

◆ MaterialSetConstant()

void Materials::MaterialSetConstant ( const MaterialId mat,
const void * data,
const uint size,
const uint offset )

Set a material constant.

◆ MaterialSetConstants()

void Materials::MaterialSetConstants ( const MaterialId mat,
const void * data,
const uint size )

Set all material constants.

◆ MaterialSetData()

void Materials::MaterialSetData ( const MaterialId mat,
const void * data,
const uint size )

Set the entire material buffer.

◆ MaterialSetLowestLod()

void Materials::MaterialSetLowestLod ( const MaterialId mat,
float lod )

Update LOD for material.

◆ MaterialSetTexture() [1/2]

void Materials::MaterialSetTexture ( const MaterialId mat,
const ShaderConfigBatchTexture * bind,
const Resources::ResourceId tex )

Set texture.

◆ MaterialSetTexture() [2/2]

void Materials::MaterialSetTexture ( const MaterialId mat,
uint name,
const Resources::ResourceId tex )

Set texture.

◆ MaterialSetTextureBindless()

void Materials::MaterialSetTextureBindless ( const MaterialId mat,
uint name,
const uint handle,
const uint offset,
const Resources::ResourceId tex )

Set bindless texture.

◆ MaterialSetupTemplate()

void Materials::MaterialSetupTemplate ( const Ids::Id32 id,
const MaterialTemplatesGPULang::Entry * entry )
static

Build everything of a material that depends on its template: the constant buffer with the template's defaults, the resource tables of the template's passes and the default textures.

Variable Documentation

◆ LoaderMap

Util::Dictionary<MaterialTemplatesGPULang::MaterialProperties, LoaderFunc> Materials::LoaderMap

◆ material

Materials::material

◆ materialAllocator

MaterialAllocator Materials::materialAllocator

◆ materialInstanceAllocator

MaterialInstanceAllocator Materials::materialInstanceAllocator

◆ materialLoaderState

struct Materials::[struct].materialLoaderState Materials::materialLoaderState

◆ materialTextureLoadSection

Threading::CriticalSection Materials::materialTextureLoadSection

◆ materialVersionCounter

uint Materials::materialVersionCounter = 0
static