Files
Destrum/destrum/include/destrum/Graphics/Pipelines/SkinningPipeline.h

59 lines
1.5 KiB
C++

#ifndef SKINNINGPIPELINE_H
#define SKINNINGPIPELINE_H
#include <vulkan/vulkan.h>
#include <array>
#include <span>
#include <glm/glm.hpp>
#include <destrum/Graphics/ComputePipeline.h>
#include <destrum/Graphics/Resources/AppendableBuffer.h>
#include "destrum/Graphics/Resources/NBuffer.h"
struct MeshDrawCommand;
class MeshCache;
class GfxDevice;
class SkinningPipeline final {
public:
void init(GfxDevice& gfxDevice);
void cleanup(GfxDevice& gfxDevice);
void doSkinning(
VkCommandBuffer cmd,
std::size_t frameIndex,
const MeshCache& meshCache,
const MeshDrawCommand& dc);
void beginDrawing(std::size_t frameIndex);
std::size_t appendJointMatrices(
std::span<const glm::mat4> jointMatrices,
std::size_t frameIndex);
private:
VkPipelineLayout m_pipelineLayout;
std::unique_ptr<ComputePipeline> skinningPipeline;
struct PushConstants {
VkDeviceAddress jointMatricesBuffer;
std::uint32_t jointMatricesStartIndex;
std::uint32_t numVertices;
VkDeviceAddress inputBuffer;
VkDeviceAddress skinningData;
VkDeviceAddress outputBuffer;
};
static constexpr std::size_t MAX_JOINT_MATRICES = 5000;
struct PerFrameData {
AppendableBuffer<glm::mat4> jointMatricesBuffer;
};
std::array<PerFrameData, FRAMES_IN_FLIGHT> framesData;
// NBuffer framesData;
PerFrameData& getCurrentFrameData(std::size_t frameIndex);
};
#endif //SKINNINGPIPELINE_H