Changeset 2d87297 in opengl-game for graphics-pipeline_vulkan.hpp
- Timestamp:
- Feb 16, 2020, 8:22:40 PM (5 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- d25381b
- Parents:
- 5a1ace0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graphics-pipeline_vulkan.hpp
r5a1ace0 r2d87297 31 31 }; 32 32 33 template<class VertexType >33 template<class VertexType, class SSBOType> 34 34 class GraphicsPipeline_Vulkan : public GraphicsPipeline { 35 35 public: … … 99 99 /*** PUBLIC METHODS ***/ 100 100 101 template<class VertexType >102 GraphicsPipeline_Vulkan<VertexType >::GraphicsPipeline_Vulkan() {101 template<class VertexType, class SSBOType> 102 GraphicsPipeline_Vulkan<VertexType, SSBOType>::GraphicsPipeline_Vulkan() { 103 103 } 104 104 105 105 // TODO: Verify that vertex capacity and index capacity are both > 0 106 template<class VertexType> 107 GraphicsPipeline_Vulkan<VertexType>::GraphicsPipeline_Vulkan(VkPhysicalDevice physicalDevice, VkDevice device, 106 template<class VertexType, class SSBOType> 107 GraphicsPipeline_Vulkan<VertexType, SSBOType>::GraphicsPipeline_Vulkan( 108 VkPhysicalDevice physicalDevice, VkDevice device, 108 109 VkRenderPass renderPass, Viewport viewport, size_t vertexCapacity, size_t indexCapacity) { 109 110 this->physicalDevice = physicalDevice; … … 134 135 } 135 136 136 template<class VertexType >137 GraphicsPipeline_Vulkan<VertexType >::~GraphicsPipeline_Vulkan() {138 } 139 140 template<class VertexType >141 size_t GraphicsPipeline_Vulkan<VertexType >::getNumVertices() {137 template<class VertexType, class SSBOType> 138 GraphicsPipeline_Vulkan<VertexType, SSBOType>::~GraphicsPipeline_Vulkan() { 139 } 140 141 template<class VertexType, class SSBOType> 142 size_t GraphicsPipeline_Vulkan<VertexType, SSBOType>::getNumVertices() { 142 143 return numVertices; 143 144 } 144 145 145 template<class VertexType >146 void GraphicsPipeline_Vulkan<VertexType >::updateRenderPass(VkRenderPass renderPass) {146 template<class VertexType, class SSBOType> 147 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::updateRenderPass(VkRenderPass renderPass) { 147 148 this->renderPass = renderPass; 148 149 } 149 150 150 template<class VertexType >151 void GraphicsPipeline_Vulkan<VertexType >::addAttribute(VkFormat format, size_t offset) {151 template<class VertexType, class SSBOType> 152 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addAttribute(VkFormat format, size_t offset) { 152 153 VkVertexInputAttributeDescription attributeDesc = {}; 153 154 … … 160 161 } 161 162 162 template<class VertexType >163 void GraphicsPipeline_Vulkan<VertexType >::addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData) {163 template<class VertexType, class SSBOType> 164 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, vector<VkDescriptorBufferInfo>* bufferData) { 164 165 this->descriptorInfoList.push_back({ type, stageFlags, bufferData, nullptr }); 165 166 } 166 167 167 template<class VertexType >168 void GraphicsPipeline_Vulkan<VertexType >::addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData) {168 template<class VertexType, class SSBOType> 169 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData) { 169 170 this->descriptorInfoList.push_back({ type, stageFlags, nullptr, imageData }); 170 171 } 171 172 172 template<class VertexType >173 void GraphicsPipeline_Vulkan<VertexType >::createPipeline(string vertShaderFile, string fragShaderFile) {173 template<class VertexType, class SSBOType> 174 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createPipeline(string vertShaderFile, string fragShaderFile) { 174 175 vector<char> vertShaderCode = readFile(vertShaderFile); 175 176 vector<char> fragShaderCode = readFile(fragShaderFile); … … 308 309 } 309 310 310 template<class VertexType >311 void GraphicsPipeline_Vulkan<VertexType >::createDescriptorSetLayout() {311 template<class VertexType, class SSBOType> 312 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createDescriptorSetLayout() { 312 313 vector<VkDescriptorSetLayoutBinding> bindings(this->descriptorInfoList.size()); 313 314 … … 330 331 } 331 332 332 template<class VertexType >333 void GraphicsPipeline_Vulkan<VertexType >::createDescriptorPool(vector<VkImage>& swapChainImages) {333 template<class VertexType, class SSBOType> 334 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createDescriptorPool(vector<VkImage>& swapChainImages) { 334 335 vector<VkDescriptorPoolSize> poolSizes(this->descriptorInfoList.size()); 335 336 … … 350 351 } 351 352 352 template<class VertexType >353 void GraphicsPipeline_Vulkan<VertexType >::createDescriptorSets(vector<VkImage>& swapChainImages) {353 template<class VertexType, class SSBOType> 354 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createDescriptorSets(vector<VkImage>& swapChainImages) { 354 355 vector<VkDescriptorSetLayout> layouts(swapChainImages.size(), this->descriptorSetLayout); 355 356 … … 396 397 } 397 398 398 template<class VertexType >399 void GraphicsPipeline_Vulkan<VertexType >::createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage) {399 template<class VertexType, class SSBOType> 400 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::createRenderCommands(VkCommandBuffer& commandBuffer, uint32_t currentImage) { 400 401 vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); 401 402 vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, … … 411 412 } 412 413 413 template<class VertexType >414 void GraphicsPipeline_Vulkan<VertexType >::addVertices(const vector<VertexType>& vertices, vector<uint16_t> indices,414 template<class VertexType, class SSBOType> 415 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::addVertices(const vector<VertexType>& vertices, vector<uint16_t> indices, 415 416 VkCommandPool commandPool, VkQueue graphicsQueue) { 416 417 … … 431 432 } 432 433 433 template<class VertexType >434 void GraphicsPipeline_Vulkan<VertexType >::cleanup() {434 template<class VertexType, class SSBOType> 435 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::cleanup() { 435 436 vkDestroyPipeline(device, pipeline, nullptr); 436 437 vkDestroyDescriptorPool(device, descriptorPool, nullptr); … … 438 439 } 439 440 440 template<class VertexType >441 void GraphicsPipeline_Vulkan<VertexType >::cleanupBuffers() {441 template<class VertexType, class SSBOType> 442 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::cleanupBuffers() { 442 443 vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr); 443 444 … … 450 451 /*** PRIVATE METHODS ***/ 451 452 452 template<class VertexType >453 VkShaderModule GraphicsPipeline_Vulkan<VertexType >::createShaderModule(const vector<char>& code) {453 template<class VertexType, class SSBOType> 454 VkShaderModule GraphicsPipeline_Vulkan<VertexType, SSBOType>::createShaderModule(const vector<char>& code) { 454 455 VkShaderModuleCreateInfo createInfo = {}; 455 456 createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; … … 465 466 } 466 467 467 template<class VertexType >468 vector<char> GraphicsPipeline_Vulkan<VertexType >::readFile(const string& filename) {468 template<class VertexType, class SSBOType> 469 vector<char> GraphicsPipeline_Vulkan<VertexType, SSBOType>::readFile(const string& filename) { 469 470 ifstream file(filename, ios::ate | ios::binary); 470 471 … … 484 485 } 485 486 486 template<class VertexType >487 void GraphicsPipeline_Vulkan<VertexType >::resizeVertexBuffer(VkCommandPool commandPool, VkQueue graphicsQueue) {487 template<class VertexType, class SSBOType> 488 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::resizeVertexBuffer(VkCommandPool commandPool, VkQueue graphicsQueue) { 488 489 VkBuffer newVertexBuffer; 489 490 VkDeviceMemory newVertexBufferMemory; … … 503 504 } 504 505 505 template<class VertexType >506 void GraphicsPipeline_Vulkan<VertexType >::resizeIndexBuffer(VkCommandPool commandPool, VkQueue graphicsQueue) {506 template<class VertexType, class SSBOType> 507 void GraphicsPipeline_Vulkan<VertexType, SSBOType>::resizeIndexBuffer(VkCommandPool commandPool, VkQueue graphicsQueue) { 507 508 VkBuffer newIndexBuffer; 508 509 VkDeviceMemory newIndexBufferMemory;
Note:
See TracChangeset
for help on using the changeset viewer.