80 const std::string &texture_path,
81 const std::string &vertex_shader_path,
82 const std::string &fragment_shader_path,
109 void update_mvp(uint32_t image_index,
const glm::mat4 &mvp);
116 void render(VkCommandBuffer cmd, uint32_t image_index);
137 [[nodiscard]]
bool loaded()
const {
return batch_loaded; }
139 [[nodiscard]]
size_t capacity()
const {
return max_vertices; }
147 alignas(16) glm::mat4 mvp{1.0f};
151 void create_vertex_buffer();
153 void destroy_vertex_buffer();
155 void create_swapchain_resources();
157 void cleanup_swapchain_resources();
159 void create_descriptor_set_layout();
161 void create_uniform_buffers();
163 void destroy_uniform_buffers();
165 void create_descriptor_pool();
167 void create_descriptor_sets();
169 void create_pipeline();
171 void destroy_pipeline();
173 [[nodiscard]] std::vector<char> read_shader_file(
const std::string &path)
const;
175 VulkanContext context{};
177 VkPipelineCache pipeline_cache = VK_NULL_HANDLE;
179 VkFormat color_attachment_format = VK_FORMAT_UNDEFINED;
181 VkFormat depth_attachment_format = VK_FORMAT_UNDEFINED;
183 size_t image_count = 0;
186 std::string texture_path{};
188 std::string vertex_shader_path{};
190 std::string fragment_shader_path{};
193 TextureResource texture{};
195 BufferResource vertex_buffer{};
197 size_t max_vertices = 0;
199 size_t active_vertices = 0;
202 VkDescriptorSetLayout descriptor_set_layout = VK_NULL_HANDLE;
204 VkDescriptorPool descriptor_pool = VK_NULL_HANDLE;
206 std::vector<VkDescriptorSet> descriptor_sets{};
208 std::vector<BufferResource> uniform_buffers{};
211 VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
213 VkPipeline pipeline = VK_NULL_HANDLE;
215 bool additive_blending =
true;
217 bool depth_test_enabled =
false;
219 bool depth_write_enabled =
false;
221 bool batch_loaded =
false;
~VK_PointSpriteBatch()
Destroy all owned Vulkan resources.
size_t vertex_count() const
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.
void set_depth_write_enabled(bool enabled)
Enable or disable depth writes in the point-sprite pipeline.
void render(VkCommandBuffer cmd, uint32_t image_index)
Record point-sprite draw commands into an active rendering scope.
void update_mvp(uint32_t image_index, const glm::mat4 &mvp)
Update the MVP uniform for one swapchain image.
void resize(VK_Window *window)
Recreate swapchain-dependent resources after a window resize.
void cleanup()
Destroy all owned resources and reset the batch to an unloaded state.
void set_additive_blending(bool enabled)
Select additive or alpha-over color blending.
void upload_vertices(const PointSpriteVertex *vertices, size_t count)
Copy point vertices into the persistent mapped vertex buffer.
VK_PointSpriteBatch(VK_PointSpriteBatch &&)=delete
void set_depth_test_enabled(bool enabled)
Enable or disable depth testing in the point-sprite pipeline.
VK_PointSpriteBatch & operator=(VK_PointSpriteBatch &&)=delete
VK_PointSpriteBatch(const VK_PointSpriteBatch &)=delete
VK_PointSpriteBatch & operator=(const VK_PointSpriteBatch &)=delete
VK_PointSpriteBatch()=default
Construct an empty point-sprite batch.
Main Vulkan window wrapper for MXVK.
Minimal Vulkan handles shared across MXVK helpers.
Reusable Vulkan buffer, image, upload, and one-shot command helpers.
Utilities for loading and saving PNG images.
Vertex layout consumed by VK_PointSpriteBatch.
float color[4]
RGBA tint color passed to shader location 2.
float size
Rasterized point size in pixels, passed to shader location 1.
float position[3]
Vertex position passed to shader location 0.