Reusable Vulkan point-list renderer for textured particle effects. More...
#include <mxvk/include/mxvk/mxvk_point_sprite_batch.hpp>
Public Member Functions | |
| size_t | capacity () const |
| void | cleanup () |
| Destroy all owned resources and reset the batch to an unloaded state. | |
| void | load (VK_Window *window, const std::string &texture_path, const std::string &vertex_shader_path, const std::string &fragment_shader_path, size_t max_vertices) |
| Create texture, vertex buffer, descriptors, and point-list pipeline. | |
| bool | loaded () const |
| VK_PointSpriteBatch & | operator= (const VK_PointSpriteBatch &)=delete |
| VK_PointSpriteBatch & | operator= (VK_PointSpriteBatch &&)=delete |
| void | render (VkCommandBuffer cmd, uint32_t image_index) |
| Record point-sprite draw commands into an active rendering scope. | |
| void | resize (VK_Window *window) |
| Recreate swapchain-dependent resources after a window resize. | |
| void | set_additive_blending (bool enabled) |
| Select additive or alpha-over color blending. | |
| void | set_depth_test_enabled (bool enabled) |
| Enable or disable depth testing in the point-sprite pipeline. | |
| void | set_depth_write_enabled (bool enabled) |
| Enable or disable depth writes in the point-sprite pipeline. | |
| void | update_mvp (uint32_t image_index, const glm::mat4 &mvp) |
| Update the MVP uniform for one swapchain image. | |
| void | upload_vertices (const PointSpriteVertex *vertices, size_t count) |
| Copy point vertices into the persistent mapped vertex buffer. | |
| size_t | vertex_count () const |
| VK_PointSpriteBatch ()=default | |
| Construct an empty point-sprite batch. | |
| VK_PointSpriteBatch (const VK_PointSpriteBatch &)=delete | |
| VK_PointSpriteBatch (VK_PointSpriteBatch &&)=delete | |
| ~VK_PointSpriteBatch () | |
| Destroy all owned Vulkan resources. | |
Reusable Vulkan point-list renderer for textured particle effects.
VK_PointSpriteBatch owns a host-visible vertex buffer, a sampled point texture, per-swapchain MVP uniform buffers, descriptors, and a point-list graphics pipeline using MXVK's dynamic rendering path. It is intended for starfields, sparks, dust, and similar effects where each vertex becomes one shader-expanded point sprite via gl_PointSize/gl_PointCoord.
The caller owns simulation and fills PointSpriteVertex data each frame via upload_vertices(). The batch must be loaded only after VK_Window has created deferred render resources, usually from onRecordCustomRendering().
Definition at line 53 of file mxvk_point_sprite_batch.hpp.
|
default |
Construct an empty point-sprite batch.
| mxvk::VK_PointSpriteBatch::~VK_PointSpriteBatch | ( | ) |
Destroy all owned Vulkan resources.
Definition at line 14 of file mxvk_point_sprite_batch.cpp.
|
delete |
|
delete |
|
inlinenodiscard |
Definition at line 139 of file mxvk_point_sprite_batch.hpp.
| void mxvk::VK_PointSpriteBatch::cleanup | ( | ) |
Destroy all owned resources and reset the batch to an unloaded state.
Definition at line 78 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::load | ( | VK_Window * | window, |
| const std::string & | texture_path, | ||
| const std::string & | vertex_shader_path, | ||
| const std::string & | fragment_shader_path, | ||
| size_t | max_vertices ) |
Create texture, vertex buffer, descriptors, and point-list pipeline.
| window | Active MXVK window with ready swapchain/render resources. |
| texture_path | PNG texture sampled by the fragment shader. |
| vertex_shader_path | SPIR-V vertex shader path. |
| fragment_shader_path | SPIR-V fragment shader path. |
| max_vertices | Maximum number of point vertices the batch can draw. |
| mxvk::Exception | on invalid input or Vulkan resource failure. |
Definition at line 18 of file mxvk_point_sprite_batch.cpp.
|
inlinenodiscard |
true when load() has completed successfully. Definition at line 137 of file mxvk_point_sprite_batch.hpp.
|
delete |
|
delete |
| void mxvk::VK_PointSpriteBatch::render | ( | VkCommandBuffer | cmd, |
| uint32_t | image_index ) |
Record point-sprite draw commands into an active rendering scope.
| cmd | Command buffer in recording state inside MXVK dynamic rendering. |
| image_index | Current swapchain image index. |
Definition at line 118 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::resize | ( | VK_Window * | window | ) |
Recreate swapchain-dependent resources after a window resize.
| window | Active MXVK window with recreated swapchain resources. |
Definition at line 60 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::set_additive_blending | ( | bool | enabled | ) |
Select additive or alpha-over color blending.
| enabled | true for additive blending, false for alpha blending. |
Definition at line 139 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::set_depth_test_enabled | ( | bool | enabled | ) |
Enable or disable depth testing in the point-sprite pipeline.
| enabled | true to test against the depth attachment. |
Definition at line 150 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::set_depth_write_enabled | ( | bool | enabled | ) |
Enable or disable depth writes in the point-sprite pipeline.
| enabled | true to write point depth values. |
Definition at line 161 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::update_mvp | ( | uint32_t | image_index, |
| const glm::mat4 & | mvp ) |
Update the MVP uniform for one swapchain image.
| image_index | Current swapchain image index. |
| mvp | Model-view-projection transform consumed by the vertex shader. |
Definition at line 108 of file mxvk_point_sprite_batch.cpp.
| void mxvk::VK_PointSpriteBatch::upload_vertices | ( | const PointSpriteVertex * | vertices, |
| size_t | count ) |
Copy point vertices into the persistent mapped vertex buffer.
| vertices | Pointer to count vertices. May be nullptr only when count is zero. |
| count | Number of vertices to upload and draw. |
| mxvk::Exception | if count exceeds capacity(). |
Definition at line 95 of file mxvk_point_sprite_batch.cpp.
|
inlinenodiscard |
Definition at line 141 of file mxvk_point_sprite_batch.hpp.