Kanzi 4.1.0
kanzi::GPUScene Class Reference

GPUScene tracks scene geometry, materials, and instances on the GPU for use in bindless and ray tracing pipelines. More...

#include <kanzi/core.ui/graphics3d/gpu_scene.hpp>

Public Member Functions

uint32_t getClusterInstanceIdx (const Model3DSharedPtr &model3DPtr, uint32_t clusterIdx, uint32_t instanceIdx) const
 Returns the GPU instance index for a given cluster instance of a model.
 
gfx::GPUSceneHandleGuard getHandle () const
 Returns a handle to the underlying GPU scene resource.
 
uint32_t getMaterialIndex (const MaterialSharedPtr &material) const
 Returns the GPU-side index of a registered material.
 
uint32_t getMeshIndex (const MeshSharedPtr &mesh) const
 Returns the GPU-side index of a registered mesh.
 
uint32_t getTextureIndex (const TextureSharedPtr &texture) const
 Returns the GPU-side index of a registered texture.
 
 GPUScene (const GPUScene &)=delete
 
 GPUScene (Domain *domain, Scene *scene)
 Constructor.
 
 GPUScene (GPUScene &&)=delete
 
bool hadInstanceUpdate () const
 Returns whether the instance buffer was updated during the most recent update() call.
 
void onModelAdded (Model3D &model)
 Notifies the GPU scene that a Model3D node was added to the scene.
 
void onModelRemoved (Model3D &model)
 Notifies the GPU scene that a Model3D node was removed from the scene.
 
GPUSceneoperator= (const GPUScene &)=delete
 
GPUSceneoperator= (GPUScene &&)=delete
 
uint32_t registerMaterial (const MaterialSharedPtr &material)
 Registers a material with the GPU scene, returning its GPU index.
 
uint32_t registerMesh (const MeshSharedPtr &mesh)
 Registers a mesh with the GPU scene, returning its GPU index.
 
uint32_t registerTexture (const TextureSharedPtr &texture)
 Registers a texture with the GPU scene, returning its GPU index.
 
bool setClusterInstanceIdx (const Model3DSharedPtr &model3DPtr, uint32_t clusterIdx, uint32_t instanceIdx, uint32_t value)
 Sets the GPU instance index for a given cluster instance of a model.
 
void unregisterMaterial (const MaterialSharedPtr &material)
 Unregisters a material from the GPU scene.
 
void unregisterMesh (const MeshSharedPtr &mesh)
 Unregisters a mesh from the GPU scene.
 
void unregisterTexture (const TextureSharedPtr &texture)
 Unregisters a texture from the GPU scene.
 
void update (Renderer &renderer)
 Updates the GPU scene state, uploading any dirty mesh, material, or instance data to the GPU.
 
 ~GPUScene ()
 Destructor.
 

Static Public Member Functions

static bool isSupported ()
 Returns whether GPU scene is supported by the active graphics backend.
 

Static Public Attributes

static constexpr uint32_t invalidResourceIndex
 Sentinel value returned when a resource index is not valid.
 

Detailed Description

GPUScene tracks scene geometry, materials, and instances on the GPU for use in bindless and ray tracing pipelines.

Use GPUScene to access GPU-side representations of meshes, materials, and textures by index, and to register or unregister scene objects as they are added or removed from the scene.

Since
Kanzi 4.1.0
Attention
This feature is experimental and is likely to change in future releases.

Constructor & Destructor Documentation

◆ GPUScene() [1/3]

kanzi::GPUScene::GPUScene ( Domain * domain,
Scene * scene )

Constructor.

Parameters
domainThe domain to use.
sceneThe scene that owns this GPU scene.

◆ ~GPUScene()

kanzi::GPUScene::~GPUScene ( )

Destructor.

◆ GPUScene() [2/3]

kanzi::GPUScene::GPUScene ( const GPUScene & )
delete

◆ GPUScene() [3/3]

kanzi::GPUScene::GPUScene ( GPUScene && )
delete

Member Function Documentation

◆ operator=() [1/2]

GPUScene & kanzi::GPUScene::operator= ( const GPUScene & )
delete

◆ operator=() [2/2]

GPUScene & kanzi::GPUScene::operator= ( GPUScene && )
delete

◆ isSupported()

static bool kanzi::GPUScene::isSupported ( )
static

Returns whether GPU scene is supported by the active graphics backend.

Returns
True if supported, false otherwise.

◆ update()

void kanzi::GPUScene::update ( Renderer & renderer)

Updates the GPU scene state, uploading any dirty mesh, material, or instance data to the GPU.

Parameters
rendererRenderer to use.

◆ getClusterInstanceIdx()

uint32_t kanzi::GPUScene::getClusterInstanceIdx ( const Model3DSharedPtr & model3DPtr,
uint32_t clusterIdx,
uint32_t instanceIdx ) const

Returns the GPU instance index for a given cluster instance of a model.

Parameters
model3DPtrThe model node.
clusterIdxIndex of the mesh cluster.
instanceIdxInstance index within the cluster.
Returns
GPU instance index.

◆ setClusterInstanceIdx()

bool kanzi::GPUScene::setClusterInstanceIdx ( const Model3DSharedPtr & model3DPtr,
uint32_t clusterIdx,
uint32_t instanceIdx,
uint32_t value )

Sets the GPU instance index for a given cluster instance of a model.

Parameters
model3DPtrThe model node.
clusterIdxIndex of the mesh cluster.
instanceIdxInstance index within the cluster.
valueGPU instance index to set.
Returns
True if set was successful.

◆ getMeshIndex()

uint32_t kanzi::GPUScene::getMeshIndex ( const MeshSharedPtr & mesh) const

Returns the GPU-side index of a registered mesh.

Parameters
meshThe mesh to look up.
Returns
Index of the mesh in the GPU scene, or invalidResourceIndex if not registered.

◆ getMaterialIndex()

uint32_t kanzi::GPUScene::getMaterialIndex ( const MaterialSharedPtr & material) const

Returns the GPU-side index of a registered material.

Parameters
materialThe material to look up.
Returns
Index of the material in the GPU scene, or invalidResourceIndex if not registered.

◆ getTextureIndex()

uint32_t kanzi::GPUScene::getTextureIndex ( const TextureSharedPtr & texture) const

Returns the GPU-side index of a registered texture.

Parameters
textureThe texture to look up.
Returns
Index of the texture in the GPU scene, or invalidResourceIndex if not registered.

◆ getHandle()

gfx::GPUSceneHandleGuard kanzi::GPUScene::getHandle ( ) const
inline

Returns a handle to the underlying GPU scene resource.

Returns
GPU scene handle guard.

◆ registerMesh()

uint32_t kanzi::GPUScene::registerMesh ( const MeshSharedPtr & mesh)

Registers a mesh with the GPU scene, returning its GPU index.

Parameters
meshThe mesh to register.
Returns
GPU index assigned to the mesh.

◆ unregisterMesh()

void kanzi::GPUScene::unregisterMesh ( const MeshSharedPtr & mesh)

Unregisters a mesh from the GPU scene.

Parameters
meshThe mesh to unregister.

◆ registerMaterial()

uint32_t kanzi::GPUScene::registerMaterial ( const MaterialSharedPtr & material)

Registers a material with the GPU scene, returning its GPU index.

Parameters
materialThe material to register.
Returns
GPU index assigned to the material.

◆ unregisterMaterial()

void kanzi::GPUScene::unregisterMaterial ( const MaterialSharedPtr & material)

Unregisters a material from the GPU scene.

Parameters
materialThe material to unregister.

◆ registerTexture()

uint32_t kanzi::GPUScene::registerTexture ( const TextureSharedPtr & texture)

Registers a texture with the GPU scene, returning its GPU index.

Parameters
textureThe texture to register.
Returns
GPU index assigned to the texture.

◆ unregisterTexture()

void kanzi::GPUScene::unregisterTexture ( const TextureSharedPtr & texture)

Unregisters a texture from the GPU scene.

Parameters
textureThe texture to unregister.

◆ onModelAdded()

void kanzi::GPUScene::onModelAdded ( Model3D & model)

Notifies the GPU scene that a Model3D node was added to the scene.

Parameters
modelThe model that was added.

◆ onModelRemoved()

void kanzi::GPUScene::onModelRemoved ( Model3D & model)

Notifies the GPU scene that a Model3D node was removed from the scene.

Parameters
modelThe model that was removed.

◆ hadInstanceUpdate()

bool kanzi::GPUScene::hadInstanceUpdate ( ) const
inline

Returns whether the instance buffer was updated during the most recent update() call.

Returns
True if instances were updated in the last frame, false otherwise.

Member Data Documentation

◆ invalidResourceIndex

constexpr uint32_t kanzi::GPUScene::invalidResourceIndex
staticconstexpr

Sentinel value returned when a resource index is not valid.

Clamped to 24 bits on purpose to match accel stuct instance custom index maximum value.


The documentation for this class was generated from the following file: