#pragma once #include #include // SPDLOG_ACTIVE_LEVEL must be defined before spdlog.h import #if DEBUG #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG #endif #include #include "Tensor.hpp" namespace kp { class Algorithm { public: Algorithm(); Algorithm(std::shared_ptr device, std::shared_ptr commandBuffer); // TODO: Add specialisation data // TODO: Explore other ways of passing shader (ie raw bytes) void init(std::string shaderFilePath, std::vector> tensorParams); ~Algorithm(); // Record commands void recordDispatch(uint32_t x = 1, uint32_t y = 1, uint32_t z = 1); private: // Shared resources std::shared_ptr mDevice; std::shared_ptr mCommandBuffer; // Resources owned by default std::shared_ptr mDescriptorSetLayout; bool mFreeDescriptorSetLayout = false; std::shared_ptr mDescriptorPool; bool mFreeDescriptorPool = false; // TODO: Explore design for multiple descriptor sets std::shared_ptr mDescriptorSet; bool mFreeDescriptorSet = false; std::shared_ptr mShaderModule; bool mFreeShaderModule = false; std::shared_ptr mPipelineLayout; bool mFreePipelineLayout = false; std::shared_ptr mPipelineCache; bool mFreePipelineCache = false; std::shared_ptr mPipeline; bool mFreePipeline = false; // Create util functions void createParameters(std::vector>& tensorParams); void createShaderModule(std::string shaderFilePath); void createPipeline(); }; } // End namespace kp