mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-30 08:34:59 +00:00
- Added detailed logging to the ScriptEngineService to trace initialization status. - Improved logging in SdlAudioService to track audio operations including initialization, shutdown, and playback functions. - Enhanced SdlInputService with logging for key and mouse events, as well as state retrieval. - Updated SdlWindowService to log window creation, destruction, and event polling. - Added logging to ShaderScriptService for shader path loading and Lua state retrieval. - Implemented logging in SwapchainService for swapchain operations, including creation, cleanup, and querying support details. - Enhanced VulkanDeviceService with logging for device creation, shutdown, and memory type queries. - Improved VulkanGuiService with logging for GUI initialization, frame preparation, and rendering operations.
69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include "../interfaces/i_buffer_service.hpp"
|
|
#include "../interfaces/i_vulkan_device_service.hpp"
|
|
#include "../interfaces/i_logger.hpp"
|
|
#include "../../di/lifecycle.hpp"
|
|
#include <memory>
|
|
|
|
namespace sdl3cpp::services::impl {
|
|
|
|
/**
|
|
* @brief Buffer service implementation.
|
|
*
|
|
* Small, focused service (~150 lines) for Vulkan buffer management.
|
|
* Handles vertex and index buffer creation and memory management.
|
|
*/
|
|
class BufferService : public IBufferService,
|
|
public di::IShutdownable {
|
|
public:
|
|
explicit BufferService(std::shared_ptr<IVulkanDeviceService> deviceService, std::shared_ptr<ILogger> logger);
|
|
~BufferService() override;
|
|
|
|
// IBufferService interface
|
|
void UploadVertexData(const std::vector<core::Vertex>& vertices) override;
|
|
void UploadIndexData(const std::vector<uint16_t>& indices) override;
|
|
void Cleanup() override;
|
|
|
|
VkBuffer GetVertexBuffer() const override {
|
|
logger_->Trace("BufferService", "GetVertexBuffer");
|
|
return vertexBuffer_;
|
|
}
|
|
VkBuffer GetIndexBuffer() const override {
|
|
logger_->Trace("BufferService", "GetIndexBuffer");
|
|
return indexBuffer_;
|
|
}
|
|
size_t GetVertexCount() const override {
|
|
logger_->Trace("BufferService", "GetVertexCount");
|
|
return vertexCount_;
|
|
}
|
|
size_t GetIndexCount() const override {
|
|
logger_->Trace("BufferService", "GetIndexCount");
|
|
return indexCount_;
|
|
}
|
|
|
|
// Public buffer creation utility
|
|
void CreateBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties,
|
|
VkBuffer& buffer, VkDeviceMemory& bufferMemory) override;
|
|
|
|
// IShutdownable interface
|
|
void Shutdown() noexcept override;
|
|
|
|
private:
|
|
std::shared_ptr<IVulkanDeviceService> deviceService_;
|
|
std::shared_ptr<ILogger> logger_;
|
|
|
|
VkBuffer vertexBuffer_ = VK_NULL_HANDLE;
|
|
VkDeviceMemory vertexBufferMemory_ = VK_NULL_HANDLE;
|
|
VkBuffer indexBuffer_ = VK_NULL_HANDLE;
|
|
VkDeviceMemory indexBufferMemory_ = VK_NULL_HANDLE;
|
|
|
|
size_t vertexCount_ = 0;
|
|
size_t indexCount_ = 0;
|
|
|
|
// Helper methods
|
|
void CleanupBuffers();
|
|
};
|
|
|
|
} // namespace sdl3cpp::services::impl
|