added buffer naming for stats json

feature/softbody-runtime-control
Benjamin Kraft 3 months ago
parent 2cc08361ac
commit 1c03a0a90c
  1. 1
      include/vulkan/buffer.hpp
  2. 2
      include/vulkan/instance.hpp
  3. 21
      src/application.cpp
  4. 6
      src/vulkan/buffer.cpp
  5. 10
      src/vulkan/instance.cpp

@ -16,6 +16,7 @@ public:
VmaAllocation allocation = VK_NULL_HANDLE;
VmaAllocationInfo allocationInfo {};
VkDeviceSize size;
void setName(const std::string& name);
Buffer(const Buffer& other) = delete;
Buffer& operator =(const Buffer& other) = delete;
private:

@ -11,6 +11,8 @@ using std::optional, std::vector;
class CommandPool;
void printVmaStats();
class Instance {
public:
explicit Instance();

@ -29,8 +29,7 @@ Application::Application() {
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE,
VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT);
descriptorPool->bindBuffer(*cameraUniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, DescriptorSet::WORLD, 0);
cameraUniformBuffer->setName("Camera");
camera = make_unique<Camera>(swapchain->extent);
struct GrabInformation {
@ -42,6 +41,7 @@ Application::Application() {
initialGrabInformation.distanceToFace = 1e20;
grabBuffer = make_unique<Buffer>(sizeof(GrabInformation), &initialGrabInformation, sizeof(GrabInformation),
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, 0);
grabBuffer->setName("Grab");
grabber = make_unique<Grabber>();
createMeshBuffers();
@ -54,6 +54,7 @@ Application::Application() {
sizeof(SizeInformation), &sizeInformation, sizeof(sizeInformation),
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, 0);
sizeInformationBuffer->setName("Sizes");
properties.gravity = {0, -9.81, 0};
properties.k = 10;
@ -63,6 +64,10 @@ Application::Application() {
sizeof(Properties), &properties, sizeof(properties),
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE, 0);
propertiesBuffer->setName("Simulation properties");
descriptorPool->bindBuffer(*cameraUniformBuffer, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, DescriptorSet::WORLD, 0);
descriptorPool->bindBuffer(*vertexBuffers[1 - currentDrawVertexBuffer], VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, DescriptorSet::MESH, 0);
descriptorPool->bindBuffer(*faceBuffer, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, DescriptorSet::MESH, 1);
@ -76,10 +81,7 @@ Application::Application() {
createComputePipelines();
char* stats;
vmaBuildStatsString(Instance::GetAllocator(), &stats, VK_TRUE);
// printf("%s", stats);
vmaFreeStatsString(Instance::GetAllocator(), stats);
printVmaStats();
}
#include <future>
@ -238,6 +240,13 @@ void Application::createMeshBuffers() {
edgeBuffer = make_unique<SimulationBuffer>(constraintData.edges.data(), constraintData.edges.size() * sizeof(Edge));
triangleBuffer = make_unique<SimulationBuffer>(constraintData.triangles.data(), constraintData.triangles.size() * sizeof(Triangle));
tetrahedronBuffer = make_unique<SimulationBuffer>(constraintData.tetrahedra.data(), constraintData.tetrahedra.size() * sizeof(Tetrahedron));
vertexBuffers[0]->setName("Vertices 0");
vertexBuffers[1]->setName("Vertices 1");
faceBuffer->setName("Faces");
edgeBuffer->setName("Edges");
triangleBuffer->setName("Triangles");
tetrahedronBuffer->setName("Tetrahedra");
}
void Application::createComputePipelines() {

@ -18,6 +18,8 @@ Buffer::Buffer(VkDeviceSize size, VkBufferUsageFlags bufferUsage, VmaMemoryUsage
allocationCreateInfo.flags = flags;
vmaCreateBuffer(Instance::GetAllocator(), &bufferCreateInfo, &allocationCreateInfo, &handle, &allocation, &allocationInfo);
vmaSetAllocationName(Instance::GetAllocator(), allocation, "My Custom name");
}
Buffer::Buffer(VkDeviceSize size, void *data, VkDeviceSize dataSize, VkBufferUsageFlags bufferUsage,
@ -69,3 +71,7 @@ void Buffer::copyTo(Buffer *dst) {
vkFreeCommandBuffers(Instance::GetDevice(), Instance::instance->renderingCommandPool->handle, 1, &commandBuffer);
}
void Buffer::setName(const std::string &name) {
vmaSetAllocationName(Instance::GetAllocator(), allocation, name.data());
}

@ -172,6 +172,16 @@ void Instance::createLogicalDevice() {
vkGetDeviceQueue(device, indices.tryComputeAndTransferDedicated(), 0, &computeAndTransferQueue);
}
#include <fstream>
void printVmaStats(){
char* stats;
vmaBuildStatsString(Instance::GetAllocator(), &stats, VK_TRUE);
std::ofstream stream("stats.json");
stream << stats;
stream.close();
vmaFreeStatsString(Instance::GetAllocator(), stats);
}
void Instance::createAllocator() {
VmaVulkanFunctions functions {};
functions.vkGetInstanceProcAddr = &vkGetInstanceProcAddr;

Loading…
Cancel
Save