![]() |
XII Release 0.1.0
|
Resource class for mesh buffers, responsible for managing the GPU resources and data associated with a mesh, including vertex and index buffers, meshlet buffers, and draw command buffers. This resource class handles the loading, unloading, and updating of the mesh data on the GPU, as well as providing access to the mesh data and properties for rendering and other operations. More...
#include <MeshBufferResource.h>
Public Member Functions | |
| const xiiMeshBufferResourceDescriptor & | GetDescriptor () const |
| Returns the mesh buffer resource descriptor for this mesh buffer resource, used to identify the properties and data of this mesh buffer resource for rendering and other operations. The mesh buffer resource descriptor contains information about the vertex stream layout, vertex and index data, meshlet data, and other properties of this mesh buffer resource that are essential for correctly interpreting the mesh data and for configuring the rendering pipeline for this mesh. | |
| const xiiBoundingBoxSphere & | GetBounds () const |
| Returns the bounding box sphere for this mesh buffer resource, used to identify the spatial bounds of this mesh for frustum culling, collision detection, and other spatial queries during rendering. The bounding box sphere is typically calculated based on the vertex positions in the geometry data used to create this mesh buffer resource, and can be used for efficient culling and intersection tests during rendering. | |
| xiiUInt32 | GetVertexCount () const |
| Returns the vertex count for this mesh buffer resource, used to identify the number of vertices in this mesh and to calculate the required memory size for the vertex data based on the vertex stream layout and formats specified in this resource. The vertex count is typically determined by the number of unique vertices in the geometry data used to create this mesh buffer resource. | |
| xiiUInt32 | GetIndexCount () const |
| Returns the index count for this mesh buffer resource, used to identify the number of indices in this mesh and to calculate the required memory size for the index data based on the index format specified in this resource. The index count is typically determined by the number of primitives (triangles, lines, etc.) in the geometry data used to create this mesh buffer resource, multiplied by the number of vertices per primitive (e.g., 3 for triangles). | |
| xiiUInt32 | GetPrimitiveCount () const |
| Returns the primitive count for this mesh buffer resource, used to identify the number of primitives (triangles, lines, etc.) in this mesh and to calculate the required memory size for the index data based on the index format specified in this resource. The primitive count is typically determined by the number of primitives in the geometry data used to create this mesh buffer resource. | |
| xiiUInt32 | GetMeshletCount () const |
| Returns the meshlet count for this mesh buffer resource, used to identify the number of meshlets in this mesh and to calculate the required memory size for the meshlet data based on the maximum vertices and primitives per meshlet specified in the mesh buffer resource descriptor. The meshlet count is typically determined by the number of meshlets generated from the geometry data used to create this mesh buffer resource, based on the specified maximum vertices and primitives per meshlet. | |
| xiiUInt32 | GetVertexStride () const |
| Returns the vertex stride for this mesh buffer resource, used to identify the byte stride between vertices in the vertex data based on the vertex stream layout and formats specified in this resource. The vertex stride is typically calculated as the sum of the sizes of all vertex streams in the vertex layout, taking into account any padding or alignment requirements based on the formats of the vertex streams. | |
| xiiEnum< xiiGALPrimitiveTopology > | GetTopology () const |
| Returns the primitive topology for this mesh buffer resource, used to identify how the primitives in this mesh are defined and rendered (e.g., triangle list, triangle strip, line list, etc.) and may influence how the vertex and index data is organized in memory for optimal rendering performance. | |
| xiiEnum< xiiGALValueType > | GetIndexType () const |
| Returns the index format for this mesh buffer resource, used to identify how the index data is organized and interpreted by the renderer (e.g., 16-bit unsigned integer or 32-bit unsigned integer) and to calculate the expected index data size based on the index count and index stride for this resource. | |
| xiiArrayPtr< const xiiMeshVertexStream > | GetVertexStreams () const |
| Returns the vertex stream layout for this mesh buffer resource, used to identify the semantic meaning, data format, byte offset, and stride for each vertex stream in the vertex data, which is essential for correctly interpreting the vertex data and for configuring the vertex input layout for rendering this mesh. | |
| xiiArrayPtr< const xiiMeshlet > | GetMeshlets () const |
| Returns the meshlet data for this mesh buffer resource, used for GPU-driven rendering techniques such as mesh shaders or compute shader-based rendering to enable more efficient culling and draw call batching. Each meshlet contains information about the primitives and vertices it contains, as well as its bounding sphere and normal cone for culling purposes. The meshlet data will be uploaded to the GPU for use in rendering this mesh with GPU-driven techniques, and can also be retained in CPU memory if m_bKeepCpuMeshData is true for CPU-side processing or other operations that require access to the meshlet data on the CPU. | |
| xiiArrayPtr< const xiiUInt32 > | GetMeshletVertexRemap () const |
| Returns the vertex remapping data for the meshlets in this mesh buffer resource, used to remap the vertex indices for each meshlet to a compact set of unique vertices that are referenced by the primitives in that meshlet. This data is essential for GPU-driven rendering techniques such as mesh shaders or compute shader-based rendering, where each meshlet may reference a different subset of vertices for optimal culling and rendering performance. The vertex remapping data will be uploaded to the GPU for use in rendering this mesh with GPU-driven techniques, and can also be retained in CPU memory if m_bKeepCpuMeshData is true for CPU-side processing or other operations that require access to the vertex remapping data on the CPU. | |
| xiiArrayPtr< const xiiUInt8 > | GetMeshletPrimitiveIndices () const |
| Returns the primitive index data for the meshlets in this mesh buffer resource, used to identify the primitives (triangles, lines, etc.) that belong to each meshlet for rendering and culling purposes in GPU-driven rendering techniques such as mesh shaders or compute shader-based rendering. This data is essential for GPU-driven rendering techniques, where each meshlet may reference a different subset of primitives for optimal culling and rendering performance. The primitive index data will be uploaded to the GPU for use in rendering this mesh with GPU-driven techniques, and can also be retained in CPU memory if m_bKeepCpuMeshData is true for CPU-side processing or other operations that require access to the primitive index data on the CPU. | |
| xiiSharedPtr< xiiGALBuffer > | GetVertexBuffer () const |
| Returns the GPU vertex buffer for this mesh buffer resource, used to identify the GPU resource that contains the vertex data for this mesh and to bind it for rendering. The vertex buffer is typically created from the vertex data in the mesh buffer resource descriptor and uploaded to the GPU for efficient rendering of this mesh. | |
| xiiSharedPtr< xiiGALBuffer > | GetIndexBuffer () const |
| Returns the GPU index buffer for this mesh buffer resource, used to identify the GPU resource that contains the index data for this mesh and to bind it for rendering. The index buffer is typically created from the index data in the mesh buffer resource descriptor and uploaded to the GPU for efficient rendering of this mesh. | |
| xiiSharedPtr< xiiGALBuffer > | GetMeshletBuffer () const |
| Returns the GPU meshlet buffer for this mesh buffer resource, used to identify the GPU resource that contains the meshlet data for this mesh and to bind it for rendering with GPU-driven techniques such as mesh shaders or compute shader-based rendering. The meshlet buffer is typically created from the meshlet data in the mesh buffer resource descriptor and uploaded to the GPU for efficient rendering of this mesh with GPU-driven techniques. | |
| xiiSharedPtr< xiiGALBuffer > | GetMeshletVertexRemapBuffer () const |
| Returns the GPU vertex remapping buffer for the meshlets in this mesh buffer resource, used to identify the GPU resource that contains the vertex remapping data for the meshlets in this mesh and to bind it for rendering with GPU-driven techniques such as mesh shaders or compute shader-based rendering. The vertex remapping buffer is typically created from the vertex remapping data in the mesh buffer resource descriptor and uploaded to the GPU for efficient rendering of this mesh with GPU-driven techniques. | |
| xiiSharedPtr< xiiGALBuffer > | GetMeshletPrimitiveIndexBuffer () const |
| Returns the GPU primitive index buffer for the meshlets in this mesh buffer resource, used to identify the GPU resource that contains the primitive index data for the meshlets in this mesh and to bind it for rendering with GPU-driven techniques such as mesh shaders or compute shader-based rendering. The primitive index buffer is typically created from the primitive index data in the mesh buffer resource descriptor and uploaded to the GPU for efficient rendering of this mesh with GPU-driven techniques. | |
| xiiSharedPtr< xiiGALBuffer > | GetDrawCommandBuffer () const |
| Returns the GPU draw command buffer for this mesh buffer resource, used to identify the GPU resource that contains the draw command data for this mesh and to bind it for rendering with GPU-driven techniques such as mesh shaders or compute shader-based rendering. The draw command buffer is typically created from the draw command data in the mesh buffer resource descriptor and uploaded to the GPU for efficient rendering of this mesh with GPU-driven techniques. | |
| Public Member Functions inherited from xiiResource | |
| XII_ALWAYS_INLINE xiiStringView | GetResourceID () const |
| XII_ALWAYS_INLINE xiiUInt64 | GetResourceIDHash () const |
| Returns the hash of the unique ID. | |
| void | SetResourceDescription (xiiStringView sDescription) |
| const xiiString & | GetResourceDescription () const |
| const xiiString & | GetResourceIdOrDescription () const |
| XII_ALWAYS_INLINE xiiResourceState | GetLoadingState () const |
| Returns the current state in which this resource is in. | |
| XII_ALWAYS_INLINE xiiUInt8 | GetNumQualityLevelsDiscardable () const |
| XII_ALWAYS_INLINE xiiUInt8 | GetNumQualityLevelsLoadable () const |
| Returns how many quality levels the resource may additionally load. | |
| float | GetLoadingPriority (xiiTime now) const |
| Returns the priority that is used by the resource manager to determine which resource to load next. | |
| xiiResourcePriority | GetPriority () const |
| Returns the current resource priority. | |
| void | SetPriority (xiiResourcePriority priority) |
| Changes the current resource priority. | |
| XII_ALWAYS_INLINE const xiiBitflags< xiiResourceFlags > & | GetBaseResourceFlags () const |
| Returns the basic flags for the resource type. Mostly used the resource manager. | |
| XII_ALWAYS_INLINE const MemoryUsage & | GetMemoryUsage () const |
| Returns the information about the current memory usage of the resource. | |
| XII_ALWAYS_INLINE xiiTime | GetLastAcquireTime () const |
| XII_ALWAYS_INLINE xiiInt32 | GetReferenceCount () const |
| Returns the reference count of this resource. | |
| XII_ALWAYS_INLINE const xiiTimestamp & | GetLoadedFileModificationTime () const |
| XII_ALWAYS_INLINE xiiUInt32 | GetCurrentResourceChangeCounter () const |
| XII_ALWAYS_INLINE void | IncResourceChangeCounter () |
| Allows to manually increase the resource change counter to signal that dependent code might need to update. | |
| virtual void | ResetResource () |
| void | PrintHandleStackTraces () |
| Public Member Functions inherited from xiiReflectedClass | |
| virtual const xiiRTTI * | GetDynamicRTTI () const |
| bool | IsInstanceOf (const xiiRTTI *pType) const |
| Returns whether the type of this instance is of the given type or derived from it. | |
| template<typename T> | |
| XII_ALWAYS_INLINE bool | IsInstanceOf () const |
| Returns whether the type of this instance is of the given type or derived from it. | |
Private Member Functions | |
| virtual xiiResourceLoadDescription | UnloadData (Unload whatToUnload) override |
| virtual xiiResourceLoadDescription | UpdateContent (xiiStreamReader *pStream) override |
| virtual void | UpdateMemoryUsage (MemoryUsage &out_NewMemoryUsage) override |
Additional Inherited Members | |
| Public Types inherited from xiiResource | |
| enum class | DoUpdate : xiiUInt8 { OnMainThread = 0U , OnAnyThread } |
| Specifies the thread type on which update operations should be performed. More... | |
| Static Public Member Functions inherited from xiiNoBase | |
| static const xiiRTTI * | GetStaticRTTI () |
| Public Attributes inherited from xiiResource | |
| xiiEvent< const xiiResourceEvent &, xiiMutex > | m_ResourceEvents |
| Protected Types inherited from xiiResource | |
| enum class | Unload : xiiUInt8 { AllQualityLevels = 0U , OneQualityLevel } |
| Protected Member Functions inherited from xiiResource | |
| xiiResource (DoUpdate resourceUpdateThread, xiiUInt8 uiQualityLevelsLoadable) | |
| Default constructor. | |
| virtual | ~xiiResource () |
| virtual destructor. | |
| MemoryUsage & | ModifyMemoryUsage () |
| Non-const version for resources that want to write this variable directly. | |
| void | SetIsReloadable (bool bIsReloadable) |
| void | SetHasLoadingFallback (bool bHasLoadingFallback) |
| Used internally by the code injection macros. | |
Resource class for mesh buffers, responsible for managing the GPU resources and data associated with a mesh, including vertex and index buffers, meshlet buffers, and draw command buffers. This resource class handles the loading, unloading, and updating of the mesh data on the GPU, as well as providing access to the mesh data and properties for rendering and other operations.
|
overrideprivatevirtual |
Requests the resource to unload another quality level. If bFullUnload is true, the resource should unload all data, because it is going to be deleted afterwards.
Implements xiiResource.
|
overrideprivatevirtual |
Called whenever more data for the resource is available. The resource must read the stream to update it's data.
pStream may be nullptr in case the resource data could not be found.
Implements xiiResource.
|
overrideprivatevirtual |
This function must be overridden by all resource types.
It has to compute the memory used by this resource. It is called by the resource manager whenever the resource's data has been loaded or unloaded.
Implements xiiResource.