Class defining mesh object with vulkan specific data and methods.
More...
#include <VulkanMesh.hpp>
|
| struct | SubmeshBuffers |
| | struct used to hold buffers and allocations for each submesh in single object. More...
|
|
| | VulkanMesh (VulkanContext &context) |
| | Constructor for VulkanMesh class.
|
| void | upload (const MeshData &meshData) |
| | Uploads mesh data to the GPU.
|
| void | extractTransparentTriangles (const glm::mat4 &modelMatrix, const glm::vec3 &cameraPos, uint32_t modelIndex, uint32_t frameIndex, vex::Entity entity, std::vector< TransparentTriangle > &outTriangles) |
| void | draw (VkCommandBuffer cmd, VkPipelineLayout pipelineLayout, VulkanResources &resources, uint32_t frameIndex, uint32_t modelIndex, glm::mat4 modelMatrix, const MeshComponent &mc) const |
| | Draws the mesh to the screen.
|
| void | bindAndDrawBatched (VkCommandBuffer cmd, VkPipelineLayout pipelineLayout, VulkanResources &resources, uint32_t frameIndex, uint32_t modelIndex, uint32_t submeshIndex, glm::mat4 modelMatrix, bool modelChanged, bool submeshChanged, const MeshComponent &mc) const |
| | Batch-optimized draw call for sorted transparent triangles.
|
| int | getNumOfInstances () const |
| | Helper function to get number of mesh components using this VulkanMesh instance, needed for mesh manager to know when to unload VulkanMesh.
|
| void | addInstance () |
| | increments number of mesh components using this VulkanMesh instance.
|
| void | removeInstance () |
| | decrements number of mesh components using this VulkanMesh instance.
|
|
| void | StreamToGPU (void *dst, const void *src, size_t sizeBytes) |
| | Helper function to stream data to GPU memory.
|
Class defining mesh object with vulkan specific data and methods.
Definition at line 24 of file VulkanMesh.hpp.
◆ VulkanMesh()
◆ ~VulkanMesh()
| vex::VulkanMesh::~VulkanMesh |
( |
| ) |
|
◆ addInstance()
| void vex::VulkanMesh::addInstance |
( |
| ) |
|
|
inline |
◆ bindAndDrawBatched()
| void vex::VulkanMesh::bindAndDrawBatched |
( |
VkCommandBuffer | cmd, |
|
|
VkPipelineLayout | pipelineLayout, |
|
|
VulkanResources & | resources, |
|
|
uint32_t | frameIndex, |
|
|
uint32_t | modelIndex, |
|
|
uint32_t | submeshIndex, |
|
|
glm::mat4 | modelMatrix, |
|
|
bool | modelChanged, |
|
|
bool | submeshChanged, |
|
|
const MeshComponent & | mc ) const |
Batch-optimized draw call for sorted transparent triangles.
Only re-binds descriptors/buffers if modelChanged or submeshChanged is true. Used in conjunction with issueMultiDrawIndexed.
- Parameters
-
| VkCommandBuffer | cmd - Command buffer. |
| VkPipelineLayout | pipelineLayout - Pipeline layout. |
| VulkanResources& | resources - Resource manager. |
| uint32_t | frameIndex - Frame index. |
| uint32_t | modelIndex - Model index. |
| uint32_t | submeshIndex - Submesh index. |
| glm::mat4 | modelMatrix - Transform matrix. |
| bool | modelChanged - Flag indicating if model-level data (matrix/lights) needs rebinding. |
| bool | submeshChanged - Flag indicating if submesh-level data (buffers/textures) needs rebinding. |
| const | MeshComponent& mc - Component data. |
Definition at line 166 of file VulkanMesh.cpp.
◆ draw()
| void vex::VulkanMesh::draw |
( |
VkCommandBuffer | cmd, |
|
|
VkPipelineLayout | pipelineLayout, |
|
|
VulkanResources & | resources, |
|
|
uint32_t | frameIndex, |
|
|
uint32_t | modelIndex, |
|
|
glm::mat4 | modelMatrix, |
|
|
const MeshComponent & | mc ) const |
Draws the mesh to the screen.
Binds buffers, descriptors, and issues draw calls for each submesh. Resolves texture overrides from MeshComponent.
- Parameters
-
| VkCommandBuffer | cmd - Command buffer to draw the mesh. |
| VkPipelineLayout | pipelineLayout - Pipeline layout for the mesh. |
| VulkanResources& | resources - Vulkan resources for the mesh. |
| uint32_t | frameIndex - Index of the current frame. |
| uint32_t | modelIndex - Index of the current model. |
| float | currentTime - Current time. |
| glm::uvec2 | currentRenderResolution - Current render resolution. |
It is called automatically in Renderer for every mesh component having a VulkanMesh.
Definition at line 246 of file VulkanMesh.cpp.
◆ extractTransparentTriangles()
| void vex::VulkanMesh::extractTransparentTriangles |
( |
const glm::mat4 & | modelMatrix, |
|
|
const glm::vec3 & | cameraPos, |
|
|
uint32_t | modelIndex, |
|
|
uint32_t | frameIndex, |
|
|
vex::Entity | entity, |
|
|
std::vector< TransparentTriangle > & | outTriangles ) |
◆ getNumOfInstances()
| int vex::VulkanMesh::getNumOfInstances |
( |
| ) |
const |
|
inline |
Helper function to get number of mesh components using this VulkanMesh instance, needed for mesh manager to know when to unload VulkanMesh.
- Returns
- int
Definition at line 93 of file VulkanMesh.hpp.
◆ removeInstance()
| void vex::VulkanMesh::removeInstance |
( |
| ) |
|
|
inline |
◆ StreamToGPU()
| void vex::VulkanMesh::StreamToGPU |
( |
void * | dst, |
|
|
const void * | src, |
|
|
size_t | sizeBytes ) |
|
private |
Helper function to stream data to GPU memory.
Copies data to GPU memory using non-temporal stores (bypasses CPU cache)
- Parameters
-
| void* | dst Destination buffer on GPU memory |
| const | void* src Source buffer on CPU memory |
| size_t | sizeBytes Size of data to copy in bytes |
Definition at line 41 of file VulkanMesh.cpp.
◆ upload()
| void vex::VulkanMesh::upload |
( |
const MeshData & | meshData | ) |
|
Uploads mesh data to the GPU.
Creates VMA buffers (VK_BUFFER_USAGE_VERTEX_BUFFER_BIT / INDEX) and uploads data from MeshData. Stores CPU copies of triangle centers for transparency sorting.
- Parameters
-
| const | MeshData& meshData - The source mesh data. |
Definition at line 79 of file VulkanMesh.cpp.
◆ m_cpuSubmeshData
| std::vector<Submesh> vex::VulkanMesh::m_cpuSubmeshData |
|
private |
◆ m_r_context
◆ m_submeshBuffers
◆ m_submeshTextures
| std::vector<std::string> vex::VulkanMesh::m_submeshTextures |
|
private |
◆ numOfInstances
| int vex::VulkanMesh::numOfInstances = 0 |
|
private |
The documentation for this class was generated from the following files: