25#include "aeongames/AeonEngine.hpp"
26#include "aeongames/Utilities.hpp"
27#include "aeongames/CRC.hpp"
29#include "VulkanRenderer.hpp"
30#include "VulkanMesh.hpp"
31#include "VulkanUtilities.hpp"
36 mVulkanRenderer {aVulkanRenderer}, mMesh{&aMesh}, mMeshBuffer { mVulkanRenderer }
39 const VkBufferUsageFlags buffer_usage {
static_cast<VkBufferUsageFlags
> ( ( aMesh.
GetVertexCount() ? VK_BUFFER_USAGE_VERTEX_BUFFER_BIT : 0 ) | ( aMesh.
GetIndexCount() ? VK_BUFFER_USAGE_INDEX_BUFFER_BIT : 0 ) ) };
41 mMeshBuffer.Initialize ( buffer_size, buffer_usage | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT );
55 std::vector<uint16_t> buffer{};
61 mMeshBuffer.WriteMemory ( aMesh.
GetVertexBuffer().size(), buffer.size() * sizeof ( uint16_t ), buffer.data() );
66 VulkanMesh::~VulkanMesh()
72 mVulkanRenderer{aVulkanMesh.mVulkanRenderer},
73 mMesh{aVulkanMesh.mMesh}, mMeshBuffer{
std::move ( aVulkanMesh.mMeshBuffer ) } {}
75 static VkIndexType GetIndexType (
const Mesh* aMesh )
81 return VK_INDEX_TYPE_UINT16;
83 return VK_INDEX_TYPE_UINT32;
88 throw std::runtime_error (
"Invalid Index Size." );
93 const VkDeviceSize offset = 0;
94 vkCmdBindVertexBuffers ( aVkCommandBuffer, 0, 1, &mMeshBuffer.GetBuffer(), &offset );
95 if ( mMesh->GetIndexCount() )
97 vkCmdBindIndexBuffer ( aVkCommandBuffer,
98 mMeshBuffer.GetBuffer(), mMesh->GetVertexBuffer().size(),
99 GetIndexType ( mMesh ) );
Defines log severity levels and stream output for the AeonGames engine.
Provides the DLL_PROTOBUF export/import macro for protobuf wrapper classes.
Represents a polygon mesh with vertex attributes and index data.
DLL uint32_t GetIndexSize() const
Get the size in bytes of a single index.
DLL uint32_t GetIndexCount() const
Get the total number of indices.
DLL const std::vector< uint8_t > & GetIndexBuffer() const
Get the raw index data buffer.
DLL const std::vector< uint8_t > & GetVertexBuffer() const
Get the raw vertex data buffer.
DLL uint32_t GetVertexCount() const
Get the total number of vertices.
void Finalize()
Release the Vulkan buffer and its device memory.
void Bind(VkCommandBuffer aVkCommandBuffer) const
Bind the mesh vertex and index buffers to a command buffer.
VulkanMesh(const VulkanRenderer &aVulkanRenderer, const Mesh &aMesh)
Construct from a renderer and mesh resource.
Vulkan rendering backend implementing the Renderer interface.
<- This is here just for the literals