Changeset b01b50c in opengl-game for vulkan-game.cpp
- Timestamp:
- Jun 20, 2021, 9:27:27 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 67527a5
- Parents:
- 2f4ff8c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r2f4ff8c rb01b50c 168 168 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 169 169 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 170 storageBuffers_modelPipeline);171 172 objects_modelPipeline.map( storageBuffers_modelPipeline.memory, device);170 objectBuffers_modelPipeline); 171 172 objects_modelPipeline.map(objectBuffers_modelPipeline.memory, device); 173 173 174 174 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 175 175 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_modelPipeline.infoSet); 176 176 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 177 VK_SHADER_STAGE_VERTEX_BIT, & storageBuffers_modelPipeline.infoSet);177 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_modelPipeline.infoSet); 178 178 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 179 179 VK_SHADER_STAGE_FRAGMENT_BIT, &floorTextureImageDescriptor); … … 242 242 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 243 243 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 244 storageBuffers_shipPipeline);245 246 objects_shipPipeline.map( storageBuffers_shipPipeline.memory, device);244 objectBuffers_shipPipeline); 245 246 objects_shipPipeline.map(objectBuffers_shipPipeline.memory, device); 247 247 248 248 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 249 249 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_shipPipeline.infoSet); 250 250 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 251 VK_SHADER_STAGE_VERTEX_BIT, & storageBuffers_shipPipeline.infoSet);251 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_shipPipeline.infoSet); 252 252 253 253 // TODO: With the normals, indexing basically becomes pointless since no vertices will have exactly … … 513 513 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 514 514 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 515 storageBuffers_asteroidPipeline);516 517 objects_asteroidPipeline.map( storageBuffers_asteroidPipeline.memory, device);515 objectBuffers_asteroidPipeline); 516 517 objects_asteroidPipeline.map(objectBuffers_asteroidPipeline.memory, device); 518 518 519 519 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 520 520 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_asteroidPipeline.infoSet); 521 521 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 522 VK_SHADER_STAGE_VERTEX_BIT, & storageBuffers_asteroidPipeline.infoSet);522 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_asteroidPipeline.infoSet); 523 523 524 524 asteroidPipeline.createDescriptorSetLayout(); … … 542 542 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 543 543 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 544 storageBuffers_laserPipeline);545 546 objects_laserPipeline.map( storageBuffers_laserPipeline.memory, device);544 objectBuffers_laserPipeline); 545 546 objects_laserPipeline.map(objectBuffers_laserPipeline.memory, device); 547 547 548 548 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 549 549 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_laserPipeline.infoSet); 550 550 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 551 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, & storageBuffers_laserPipeline.infoSet);551 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, &objectBuffers_laserPipeline.infoSet); 552 552 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 553 553 VK_SHADER_STAGE_FRAGMENT_BIT, &laserTextureImageDescriptor); … … 573 573 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 574 574 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 575 storageBuffers_explosionPipeline);576 577 objects_explosionPipeline.map( storageBuffers_explosionPipeline.memory, device);575 objectBuffers_explosionPipeline); 576 577 objects_explosionPipeline.map(objectBuffers_explosionPipeline.memory, device); 578 578 579 579 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 580 580 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_explosionPipeline.infoSet); 581 581 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 582 VK_SHADER_STAGE_VERTEX_BIT, & storageBuffers_explosionPipeline.infoSet);582 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_explosionPipeline.infoSet); 583 583 584 584 explosionPipeline.createDescriptorSetLayout(); … … 1082 1082 1083 1083 if (objects_modelPipeline.resized) { 1084 objects_modelPipeline.unmap( storageBuffers_modelPipeline.memory, device);1085 1086 resizeBufferSet( storageBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool,1084 objects_modelPipeline.unmap(objectBuffers_modelPipeline.memory, device); 1085 1086 resizeBufferSet(objectBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool, 1087 1087 graphicsQueue, true); 1088 1088 1089 objects_modelPipeline.map( storageBuffers_modelPipeline.memory, device);1089 objects_modelPipeline.map(objectBuffers_modelPipeline.memory, device); 1090 1090 1091 1091 objects_modelPipeline.resize(); 1092 1092 1093 modelPipeline.updateDescriptorInfo(1, & storageBuffers_modelPipeline.infoSet, swapChainImages.size());1093 modelPipeline.updateDescriptorInfo(1, &objectBuffers_modelPipeline.infoSet, swapChainImages.size()); 1094 1094 } 1095 1095 … … 1112 1112 1113 1113 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex), 1114 storageBuffers_modelPipeline.memory[imageIndex],1114 objectBuffers_modelPipeline.memory[imageIndex], 1115 1115 objects_modelPipeline.memorySize(), true); 1116 1116 1117 1117 if (objects_shipPipeline.resized) { 1118 objects_shipPipeline.unmap( storageBuffers_shipPipeline.memory, device);1119 1120 resizeBufferSet( storageBuffers_shipPipeline, objects_shipPipeline.memorySize(), resourceCommandPool,1118 objects_shipPipeline.unmap(objectBuffers_shipPipeline.memory, device); 1119 1120 resizeBufferSet(objectBuffers_shipPipeline, objects_shipPipeline.memorySize(), resourceCommandPool, 1121 1121 graphicsQueue, true); 1122 1122 1123 objects_shipPipeline.map( storageBuffers_shipPipeline.memory, device);1123 objects_shipPipeline.map(objectBuffers_shipPipeline.memory, device); 1124 1124 1125 1125 objects_shipPipeline.resize(); 1126 1126 1127 shipPipeline.updateDescriptorInfo(1, & storageBuffers_shipPipeline.infoSet, swapChainImages.size());1127 shipPipeline.updateDescriptorInfo(1, &objectBuffers_shipPipeline.infoSet, swapChainImages.size()); 1128 1128 } 1129 1129 … … 1142 1142 1143 1143 VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), objects_shipPipeline.mapped(imageIndex), 1144 storageBuffers_shipPipeline.memory[imageIndex],1144 objectBuffers_shipPipeline.memory[imageIndex], 1145 1145 objects_shipPipeline.memorySize(), true); 1146 1146 1147 1147 if (objects_asteroidPipeline.resized) { 1148 objects_asteroidPipeline.unmap( storageBuffers_asteroidPipeline.memory, device);1149 1150 resizeBufferSet( storageBuffers_asteroidPipeline, objects_asteroidPipeline.memorySize(), resourceCommandPool,1148 objects_asteroidPipeline.unmap(objectBuffers_asteroidPipeline.memory, device); 1149 1150 resizeBufferSet(objectBuffers_asteroidPipeline, objects_asteroidPipeline.memorySize(), resourceCommandPool, 1151 1151 graphicsQueue, true); 1152 1152 1153 objects_asteroidPipeline.map( storageBuffers_asteroidPipeline.memory, device);1153 objects_asteroidPipeline.map(objectBuffers_asteroidPipeline.memory, device); 1154 1154 1155 1155 objects_asteroidPipeline.resize(); 1156 1156 1157 asteroidPipeline.updateDescriptorInfo(1, & storageBuffers_asteroidPipeline.infoSet, swapChainImages.size());1157 asteroidPipeline.updateDescriptorInfo(1, &objectBuffers_asteroidPipeline.infoSet, swapChainImages.size()); 1158 1158 } 1159 1159 … … 1195 1195 1196 1196 VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), objects_asteroidPipeline.mapped(imageIndex), 1197 storageBuffers_asteroidPipeline.memory[imageIndex],1197 objectBuffers_asteroidPipeline.memory[imageIndex], 1198 1198 objects_asteroidPipeline.memorySize(), true); 1199 1199 1200 1200 if (objects_laserPipeline.resized) { 1201 objects_laserPipeline.unmap( storageBuffers_laserPipeline.memory, device);1202 1203 resizeBufferSet( storageBuffers_laserPipeline, objects_laserPipeline.memorySize(), resourceCommandPool,1201 objects_laserPipeline.unmap(objectBuffers_laserPipeline.memory, device); 1202 1203 resizeBufferSet(objectBuffers_laserPipeline, objects_laserPipeline.memorySize(), resourceCommandPool, 1204 1204 graphicsQueue, true); 1205 1205 1206 objects_laserPipeline.map( storageBuffers_laserPipeline.memory, device);1206 objects_laserPipeline.map(objectBuffers_laserPipeline.memory, device); 1207 1207 1208 1208 objects_laserPipeline.resize(); 1209 1209 1210 laserPipeline.updateDescriptorInfo(1, & storageBuffers_laserPipeline.infoSet, swapChainImages.size());1210 laserPipeline.updateDescriptorInfo(1, &objectBuffers_laserPipeline.infoSet, swapChainImages.size()); 1211 1211 } 1212 1212 … … 1231 1231 1232 1232 VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), objects_laserPipeline.mapped(imageIndex), 1233 storageBuffers_laserPipeline.memory[imageIndex],1233 objectBuffers_laserPipeline.memory[imageIndex], 1234 1234 objects_laserPipeline.memorySize(), true); 1235 1235 1236 1236 if (objects_explosionPipeline.resized) { 1237 objects_explosionPipeline.unmap( storageBuffers_explosionPipeline.memory, device);1238 1239 resizeBufferSet( storageBuffers_explosionPipeline, objects_explosionPipeline.memorySize(), resourceCommandPool,1237 objects_explosionPipeline.unmap(objectBuffers_explosionPipeline.memory, device); 1238 1239 resizeBufferSet(objectBuffers_explosionPipeline, objects_explosionPipeline.memorySize(), resourceCommandPool, 1240 1240 graphicsQueue, true); 1241 1241 1242 objects_explosionPipeline.map( storageBuffers_explosionPipeline.memory, device);1242 objects_explosionPipeline.map(objectBuffers_explosionPipeline.memory, device); 1243 1243 1244 1244 objects_explosionPipeline.resize(); 1245 1245 1246 explosionPipeline.updateDescriptorInfo(1, & storageBuffers_explosionPipeline.infoSet, swapChainImages.size());1246 explosionPipeline.updateDescriptorInfo(1, &objectBuffers_explosionPipeline.infoSet, swapChainImages.size()); 1247 1247 } 1248 1248 … … 1266 1266 1267 1267 VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), objects_explosionPipeline.mapped(imageIndex), 1268 storageBuffers_explosionPipeline.memory[imageIndex],1268 objectBuffers_explosionPipeline.memory[imageIndex], 1269 1269 objects_explosionPipeline.memorySize(), true); 1270 1270 } … … 2317 2317 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2318 2318 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2319 storageBuffers_modelPipeline);2320 2321 objects_modelPipeline.map( storageBuffers_modelPipeline.memory, device);2319 objectBuffers_modelPipeline); 2320 2321 objects_modelPipeline.map(objectBuffers_modelPipeline.memory, device); 2322 2322 2323 2323 modelPipeline.updateRenderPass(renderPass); … … 2337 2337 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2338 2338 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2339 storageBuffers_shipPipeline);2340 2341 objects_shipPipeline.map( storageBuffers_shipPipeline.memory, device);2339 objectBuffers_shipPipeline); 2340 2341 objects_shipPipeline.map(objectBuffers_shipPipeline.memory, device); 2342 2342 2343 2343 shipPipeline.updateRenderPass(renderPass); … … 2357 2357 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2358 2358 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2359 storageBuffers_asteroidPipeline);2360 2361 objects_asteroidPipeline.map( storageBuffers_asteroidPipeline.memory, device);2359 objectBuffers_asteroidPipeline); 2360 2361 objects_asteroidPipeline.map(objectBuffers_asteroidPipeline.memory, device); 2362 2362 2363 2363 asteroidPipeline.updateRenderPass(renderPass); … … 2377 2377 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2378 2378 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2379 storageBuffers_laserPipeline);2380 2381 objects_laserPipeline.map( storageBuffers_laserPipeline.memory, device);2379 objectBuffers_laserPipeline); 2380 2381 objects_laserPipeline.map(objectBuffers_laserPipeline.memory, device); 2382 2382 2383 2383 laserPipeline.updateRenderPass(renderPass); … … 2397 2397 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2398 2398 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2399 storageBuffers_explosionPipeline);2400 2401 objects_explosionPipeline.map( storageBuffers_explosionPipeline.memory, device);2399 objectBuffers_explosionPipeline); 2400 2401 objects_explosionPipeline.map(objectBuffers_explosionPipeline.memory, device); 2402 2402 2403 2403 explosionPipeline.updateRenderPass(renderPass); … … 2430 2430 } 2431 2431 2432 objects_modelPipeline.unmap( storageBuffers_modelPipeline.memory, device);2433 2434 for (size_t i = 0; i < storageBuffers_modelPipeline.buffers.size(); i++) {2435 vkDestroyBuffer(device, storageBuffers_modelPipeline.buffers[i], nullptr);2436 vkFreeMemory(device, storageBuffers_modelPipeline.memory[i], nullptr);2432 objects_modelPipeline.unmap(objectBuffers_modelPipeline.memory, device); 2433 2434 for (size_t i = 0; i < objectBuffers_modelPipeline.buffers.size(); i++) { 2435 vkDestroyBuffer(device, objectBuffers_modelPipeline.buffers[i], nullptr); 2436 vkFreeMemory(device, objectBuffers_modelPipeline.memory[i], nullptr); 2437 2437 } 2438 2438 … … 2446 2446 } 2447 2447 2448 objects_shipPipeline.unmap( storageBuffers_shipPipeline.memory, device);2449 2450 for (size_t i = 0; i < storageBuffers_shipPipeline.buffers.size(); i++) {2451 vkDestroyBuffer(device, storageBuffers_shipPipeline.buffers[i], nullptr);2452 vkFreeMemory(device, storageBuffers_shipPipeline.memory[i], nullptr);2448 objects_shipPipeline.unmap(objectBuffers_shipPipeline.memory, device); 2449 2450 for (size_t i = 0; i < objectBuffers_shipPipeline.buffers.size(); i++) { 2451 vkDestroyBuffer(device, objectBuffers_shipPipeline.buffers[i], nullptr); 2452 vkFreeMemory(device, objectBuffers_shipPipeline.memory[i], nullptr); 2453 2453 } 2454 2454 … … 2462 2462 } 2463 2463 2464 objects_asteroidPipeline.unmap( storageBuffers_asteroidPipeline.memory, device);2465 2466 for (size_t i = 0; i < storageBuffers_asteroidPipeline.buffers.size(); i++) {2467 vkDestroyBuffer(device, storageBuffers_asteroidPipeline.buffers[i], nullptr);2468 vkFreeMemory(device, storageBuffers_asteroidPipeline.memory[i], nullptr);2464 objects_asteroidPipeline.unmap(objectBuffers_asteroidPipeline.memory, device); 2465 2466 for (size_t i = 0; i < objectBuffers_asteroidPipeline.buffers.size(); i++) { 2467 vkDestroyBuffer(device, objectBuffers_asteroidPipeline.buffers[i], nullptr); 2468 vkFreeMemory(device, objectBuffers_asteroidPipeline.memory[i], nullptr); 2469 2469 } 2470 2470 … … 2478 2478 } 2479 2479 2480 objects_laserPipeline.unmap( storageBuffers_laserPipeline.memory, device);2481 2482 for (size_t i = 0; i < storageBuffers_laserPipeline.buffers.size(); i++) {2483 vkDestroyBuffer(device, storageBuffers_laserPipeline.buffers[i], nullptr);2484 vkFreeMemory(device, storageBuffers_laserPipeline.memory[i], nullptr);2480 objects_laserPipeline.unmap(objectBuffers_laserPipeline.memory, device); 2481 2482 for (size_t i = 0; i < objectBuffers_laserPipeline.buffers.size(); i++) { 2483 vkDestroyBuffer(device, objectBuffers_laserPipeline.buffers[i], nullptr); 2484 vkFreeMemory(device, objectBuffers_laserPipeline.memory[i], nullptr); 2485 2485 } 2486 2486 … … 2494 2494 } 2495 2495 2496 objects_explosionPipeline.unmap( storageBuffers_explosionPipeline.memory, device);2497 2498 for (size_t i = 0; i < storageBuffers_explosionPipeline.buffers.size(); i++) {2499 vkDestroyBuffer(device, storageBuffers_explosionPipeline.buffers[i], nullptr);2500 vkFreeMemory(device, storageBuffers_explosionPipeline.memory[i], nullptr);2496 objects_explosionPipeline.unmap(objectBuffers_explosionPipeline.memory, device); 2497 2498 for (size_t i = 0; i < objectBuffers_explosionPipeline.buffers.size(); i++) { 2499 vkDestroyBuffer(device, objectBuffers_explosionPipeline.buffers[i], nullptr); 2500 vkFreeMemory(device, objectBuffers_explosionPipeline.memory[i], nullptr); 2501 2501 } 2502 2502
Note:
See TracChangeset
for help on using the changeset viewer.