Changeset a3cefaa in opengl-game for graphics-pipeline_vulkan.hpp
- Timestamp:
- May 17, 2021, 4:06:33 PM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 1abebc1
- Parents:
- 996dd3e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
graphics-pipeline_vulkan.hpp
r996dd3e ra3cefaa 36 36 public: 37 37 string vertShaderFile, fragShaderFile; 38 39 // Both of these are only used for managing the SSBO, so move them out as well40 size_t objectCapacity;41 size_t numObjects;42 38 43 39 GraphicsPipeline_Vulkan(); … … 48 44 GraphicsPipeline_Vulkan(VkPrimitiveTopology topology, VkPhysicalDevice physicalDevice, VkDevice device, 49 45 VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages, 50 size_t vertexCapacity, size_t indexCapacity , size_t objectCapacity);46 size_t vertexCapacity, size_t indexCapacity); 51 47 ~GraphicsPipeline_Vulkan(); 52 48 … … 64 60 void addDescriptorInfo(VkDescriptorType type, VkShaderStageFlags stageFlags, VkDescriptorImageInfo* imageData); 65 61 66 void updateDescriptorInfo(uint32_t index, vector<VkDescriptorBufferInfo>* bufferData); 62 void updateDescriptorInfo(uint32_t index, vector<VkDescriptorBufferInfo>* bufferData, 63 vector<VkImage>& swapChainImages); 67 64 // TODO: Maybe make an analogous one for updating image info 68 65 … … 128 125 // into the constructor. That way, I can also put relevant cleanup code into the destructor 129 126 template<class VertexType> 130 GraphicsPipeline_Vulkan<VertexType>::GraphicsPipeline_Vulkan( 131 VkPrimitiveTopology topology, VkPhysicalDevice physicalDevice, VkDevice device, 132 VkRenderPass renderPass, Viewport viewport, vector<VkImage>& swapChainImages, 133 size_t vertexCapacity, size_t indexCapacity, size_t objectCapacity) { 134 this->topology = topology; 135 this->physicalDevice = physicalDevice; 136 this->device = device; 137 this->renderPass = renderPass; 127 GraphicsPipeline_Vulkan<VertexType>::GraphicsPipeline_Vulkan(VkPrimitiveTopology topology, 128 VkPhysicalDevice physicalDevice, VkDevice device, 129 VkRenderPass renderPass, Viewport viewport, 130 vector<VkImage>& swapChainImages, size_t vertexCapacity, 131 size_t indexCapacity) 132 : topology(topology) 133 , physicalDevice(physicalDevice) 134 , device(device) 135 , renderPass(renderPass) { 136 // This is a member of the base GraphicsPipeline class 137 // It currently is not used for the OpenGL pipeline. Either figure out why (since OpenGL certainly has the concept of 138 // viewports) and use it there too and add viewport the the base class constructor, or create a second base class 139 // constructor which takes the viewport 138 140 this->viewport = viewport; 139 141 … … 158 160 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, 159 161 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, indexBuffer, indexBufferMemory); 160 161 this->numObjects = 0;162 this->objectCapacity = objectCapacity;163 162 } 164 163 … … 204 203 template<class VertexType> 205 204 void GraphicsPipeline_Vulkan<VertexType>::updateDescriptorInfo(uint32_t index, 206 vector<VkDescriptorBufferInfo>* bufferData) { 205 vector<VkDescriptorBufferInfo>* bufferData, 206 vector<VkImage>& swapChainImages) { 207 207 this->descriptorInfoList[index].bufferDataList = bufferData; 208 209 // TODO: This code was mostly copied from createDescriptorSets. I should make some common function they both use 210 // for updating descriptor sets 211 for (size_t i = 0; i < swapChainImages.size(); i++) { 212 VkWriteDescriptorSet descriptorWrite = {}; 213 214 descriptorWrite.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; 215 descriptorWrite.dstSet = this->descriptorSets[i]; 216 descriptorWrite.dstBinding = index; 217 descriptorWrite.dstArrayElement = 0; 218 descriptorWrite.descriptorType = this->descriptorInfoList[index].type; 219 descriptorWrite.descriptorCount = 1; 220 descriptorWrite.pBufferInfo = nullptr; 221 descriptorWrite.pImageInfo = nullptr; 222 descriptorWrite.pTexelBufferView = nullptr; 223 224 // This method is only intended for updated descriptor sets of type VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 225 // but I'm leaving that in here for completeness 226 switch (descriptorWrite.descriptorType) { 227 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: 228 case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: 229 case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: 230 descriptorWrite.pBufferInfo = &(*this->descriptorInfoList[index].bufferDataList)[i]; 231 break; 232 case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: 233 descriptorWrite.pImageInfo = this->descriptorInfoList[index].imageData; 234 break; 235 default: 236 throw runtime_error("Unknown descriptor type: " + to_string(descriptorWrite.descriptorType)); 237 } 238 239 if (bufferData->size() != swapChainImages.size()) { 240 cout << "ALERT ALERT ALERT: SIZE MISMATCH!!!!!!!" << endl; 241 } 242 243 vkUpdateDescriptorSets(this->device, 1, &descriptorWrite, 0, nullptr); 244 } 208 245 } 209 246
Note:
See TracChangeset
for help on using the changeset viewer.