Changeset 2f4ff8c in opengl-game for vulkan-game.cpp
- Timestamp:
- Jun 20, 2021, 7:05:14 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- b01b50c
- Parents:
- 90880fb
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/18/21 16:39:49)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/20/21 19:05:14)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r90880fb r2f4ff8c 77 77 , gui(nullptr) 78 78 , window(nullptr) 79 , vp_mats_modelPipeline()79 , uniforms_modelPipeline() 80 80 , objects_modelPipeline() 81 , vp_mats_shipPipeline()81 , uniforms_shipPipeline() 82 82 , objects_shipPipeline() 83 , vp_mats_asteroidPipeline()83 , uniforms_asteroidPipeline() 84 84 , objects_asteroidPipeline() 85 , vp_mats_laserPipeline()85 , uniforms_laserPipeline() 86 86 , objects_laserPipeline() 87 87 , uniforms_explosionPipeline() … … 110 110 vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties); 111 111 112 vp_mats_modelPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,113 deviceProperties.limits.minUniformBufferOffsetAlignment);112 uniforms_modelPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 113 deviceProperties.limits.minUniformBufferOffsetAlignment); 114 114 115 115 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange, 116 116 deviceProperties.limits.minStorageBufferOffsetAlignment); 117 117 118 vp_mats_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,119 deviceProperties.limits.minUniformBufferOffsetAlignment);118 uniforms_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 119 deviceProperties.limits.minUniformBufferOffsetAlignment); 120 120 121 121 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange, 122 122 deviceProperties.limits.minStorageBufferOffsetAlignment); 123 123 124 vp_mats_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,125 deviceProperties.limits.minUniformBufferOffsetAlignment);124 uniforms_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 125 deviceProperties.limits.minUniformBufferOffsetAlignment); 126 126 127 127 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxStorageBufferRange, 128 128 deviceProperties.limits.minStorageBufferOffsetAlignment); 129 129 130 vp_mats_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,131 deviceProperties.limits.minUniformBufferOffsetAlignment);130 uniforms_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 131 deviceProperties.limits.minUniformBufferOffsetAlignment); 132 132 133 133 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxStorageBufferRange, … … 157 157 modelPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex)); 158 158 159 createBufferSet( vp_mats_modelPipeline.memorySize(),159 createBufferSet(uniforms_modelPipeline.memorySize(), 160 160 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 161 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,161 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 162 162 uniformBuffers_modelPipeline); 163 164 uniforms_modelPipeline.map(uniformBuffers_modelPipeline.memory, device); 163 165 164 166 createBufferSet(objects_modelPipeline.memorySize(), 165 167 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 166 168 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 167 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,169 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 168 170 storageBuffers_modelPipeline); 171 172 objects_modelPipeline.map(storageBuffers_modelPipeline.memory, device); 169 173 170 174 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, … … 227 231 shipPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex)); 228 232 229 createBufferSet( vp_mats_shipPipeline.memorySize(),233 createBufferSet(uniforms_shipPipeline.memorySize(), 230 234 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 231 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,235 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 232 236 uniformBuffers_shipPipeline); 237 238 uniforms_shipPipeline.map(uniformBuffers_shipPipeline.memory, device); 233 239 234 240 createBufferSet(objects_shipPipeline.memorySize(), 235 241 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 236 242 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 237 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,243 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 238 244 storageBuffers_shipPipeline); 245 246 objects_shipPipeline.map(storageBuffers_shipPipeline.memory, device); 239 247 240 248 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, … … 494 502 asteroidPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex)); 495 503 496 createBufferSet( vp_mats_asteroidPipeline.memorySize(),504 createBufferSet(uniforms_asteroidPipeline.memorySize(), 497 505 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 498 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,506 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 499 507 uniformBuffers_asteroidPipeline); 508 509 uniforms_asteroidPipeline.map(uniformBuffers_asteroidPipeline.memory, device); 500 510 501 511 createBufferSet(objects_asteroidPipeline.memorySize(), 502 512 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 503 513 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 504 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,514 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 505 515 storageBuffers_asteroidPipeline); 516 517 objects_asteroidPipeline.map(storageBuffers_asteroidPipeline.memory, device); 506 518 507 519 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, … … 519 531 laserPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&LaserVertex::objIndex)); 520 532 521 createBufferSet( vp_mats_laserPipeline.memorySize(),533 createBufferSet(uniforms_laserPipeline.memorySize(), 522 534 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 523 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,535 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 524 536 uniformBuffers_laserPipeline); 537 538 uniforms_laserPipeline.map(uniformBuffers_laserPipeline.memory, device); 525 539 526 540 createBufferSet(objects_laserPipeline.memorySize(), 527 541 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 528 542 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 529 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,543 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 530 544 storageBuffers_laserPipeline); 545 546 objects_laserPipeline.map(storageBuffers_laserPipeline.memory, device); 531 547 532 548 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, … … 548 564 createBufferSet(uniforms_explosionPipeline.memorySize(), 549 565 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 550 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,566 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 551 567 uniformBuffers_explosionPipeline); 568 569 uniforms_explosionPipeline.map(uniformBuffers_explosionPipeline.memory, device); 552 570 553 571 createBufferSet(objects_explosionPipeline.memorySize(), 554 572 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 555 573 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 556 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,574 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 557 575 storageBuffers_explosionPipeline); 576 577 objects_explosionPipeline.map(storageBuffers_explosionPipeline.memory, device); 558 578 559 579 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, … … 945 965 void VulkanGame::updateScene() { 946 966 947 vp_mats_modelPipeline.data()->view = viewMat; 948 vp_mats_modelPipeline.data()->proj = projMat; 949 950 vp_mats_shipPipeline.data()->view = viewMat; 951 vp_mats_shipPipeline.data()->proj = projMat; 952 953 vp_mats_asteroidPipeline.data()->view = viewMat; 954 vp_mats_asteroidPipeline.data()->proj = projMat; 955 956 vp_mats_laserPipeline.data()->view = viewMat; 957 vp_mats_laserPipeline.data()->proj = projMat; 967 // TODO: I can probably use one buffer to store the view and projection mats 968 // and share it across all the shader pipelines 969 970 uniforms_modelPipeline.data()->view = viewMat; 971 uniforms_modelPipeline.data()->proj = projMat; 972 973 uniforms_shipPipeline.data()->view = viewMat; 974 uniforms_shipPipeline.data()->proj = projMat; 975 976 uniforms_asteroidPipeline.data()->view = viewMat; 977 uniforms_asteroidPipeline.data()->proj = projMat; 978 979 uniforms_laserPipeline.data()->view = viewMat; 980 uniforms_laserPipeline.data()->proj = projMat; 958 981 959 982 uniforms_explosionPipeline.data()->view = viewMat; … … 1059 1082 1060 1083 if (objects_modelPipeline.resized) { 1084 objects_modelPipeline.unmap(storageBuffers_modelPipeline.memory, device); 1085 1061 1086 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool, 1062 1087 graphicsQueue, true); 1088 1089 objects_modelPipeline.map(storageBuffers_modelPipeline.memory, device); 1063 1090 1064 1091 objects_modelPipeline.resize(); … … 1080 1107 } 1081 1108 1082 VulkanUtils::copyDataToMemory(device, vp_mats_modelPipeline.data(), uniformBuffers_modelPipeline.memory[imageIndex], 1083 0, vp_mats_modelPipeline.memorySize(), false); 1084 1085 VulkanUtils::copyDataToMemory(device, objects_modelPipeline.data(), storageBuffers_modelPipeline.memory[imageIndex], 1086 0, objects_modelPipeline.memorySize(), false); 1109 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex), 1110 uniformBuffers_modelPipeline.memory[imageIndex], 1111 uniforms_modelPipeline.memorySize(), true); 1112 1113 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex), 1114 storageBuffers_modelPipeline.memory[imageIndex], 1115 objects_modelPipeline.memorySize(), true); 1087 1116 1088 1117 if (objects_shipPipeline.resized) { 1118 objects_shipPipeline.unmap(storageBuffers_shipPipeline.memory, device); 1119 1089 1120 resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline.memorySize(), resourceCommandPool, 1090 1121 graphicsQueue, true); 1122 1123 objects_shipPipeline.map(storageBuffers_shipPipeline.memory, device); 1091 1124 1092 1125 objects_shipPipeline.resize(); … … 1104 1137 } 1105 1138 1106 VulkanUtils::copyDataToMemory(device, vp_mats_shipPipeline.data(), uniformBuffers_shipPipeline.memory[imageIndex], 1107 0, vp_mats_shipPipeline.memorySize(), false); 1108 1109 VulkanUtils::copyDataToMemory(device, objects_shipPipeline.data(), storageBuffers_shipPipeline.memory[imageIndex], 1110 0, objects_shipPipeline.memorySize(), false); 1139 VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), uniforms_shipPipeline.mapped(imageIndex), 1140 uniformBuffers_shipPipeline.memory[imageIndex], 1141 uniforms_shipPipeline.memorySize(), true); 1142 1143 VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), objects_shipPipeline.mapped(imageIndex), 1144 storageBuffers_shipPipeline.memory[imageIndex], 1145 objects_shipPipeline.memorySize(), true); 1111 1146 1112 1147 if (objects_asteroidPipeline.resized) { 1148 objects_asteroidPipeline.unmap(storageBuffers_asteroidPipeline.memory, device); 1149 1113 1150 resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline.memorySize(), resourceCommandPool, 1114 1151 graphicsQueue, true); 1152 1153 objects_asteroidPipeline.map(storageBuffers_asteroidPipeline.memory, device); 1115 1154 1116 1155 objects_asteroidPipeline.resize(); … … 1151 1190 } 1152 1191 1153 VulkanUtils::copyDataToMemory(device, vp_mats_asteroidPipeline.data(), uniformBuffers_asteroidPipeline.memory[imageIndex], 1154 0, vp_mats_asteroidPipeline.memorySize(), false); 1155 1156 VulkanUtils::copyDataToMemory(device, objects_asteroidPipeline.data(), storageBuffers_asteroidPipeline.memory[imageIndex], 1157 0, objects_asteroidPipeline.memorySize(), false); 1192 VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), uniforms_asteroidPipeline.mapped(imageIndex), 1193 uniformBuffers_asteroidPipeline.memory[imageIndex], 1194 uniforms_asteroidPipeline.memorySize(), true); 1195 1196 VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), objects_asteroidPipeline.mapped(imageIndex), 1197 storageBuffers_asteroidPipeline.memory[imageIndex], 1198 objects_asteroidPipeline.memorySize(), true); 1158 1199 1159 1200 if (objects_laserPipeline.resized) { 1201 objects_laserPipeline.unmap(storageBuffers_laserPipeline.memory, device); 1202 1160 1203 resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline.memorySize(), resourceCommandPool, 1161 1204 graphicsQueue, true); 1205 1206 objects_laserPipeline.map(storageBuffers_laserPipeline.memory, device); 1162 1207 1163 1208 objects_laserPipeline.resize(); … … 1181 1226 } 1182 1227 1183 VulkanUtils::copyDataToMemory(device, vp_mats_laserPipeline.data(), uniformBuffers_laserPipeline.memory[imageIndex], 1184 0, vp_mats_laserPipeline.memorySize(), false); 1185 1186 VulkanUtils::copyDataToMemory(device, objects_laserPipeline.data(), storageBuffers_laserPipeline.memory[imageIndex], 1187 0, objects_laserPipeline.memorySize(), false); 1228 VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), uniforms_laserPipeline.mapped(imageIndex), 1229 uniformBuffers_laserPipeline.memory[imageIndex], 1230 uniforms_laserPipeline.memorySize(), true); 1231 1232 VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), objects_laserPipeline.mapped(imageIndex), 1233 storageBuffers_laserPipeline.memory[imageIndex], 1234 objects_laserPipeline.memorySize(), true); 1188 1235 1189 1236 if (objects_explosionPipeline.resized) { 1237 objects_explosionPipeline.unmap(storageBuffers_explosionPipeline.memory, device); 1238 1190 1239 resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline.memorySize(), resourceCommandPool, 1191 1240 graphicsQueue, true); 1241 1242 objects_explosionPipeline.map(storageBuffers_explosionPipeline.memory, device); 1192 1243 1193 1244 objects_explosionPipeline.resize(); … … 1210 1261 } 1211 1262 1212 VulkanUtils::copyDataToMemory(device, uniforms_explosionPipeline.data(), uniformBuffers_explosionPipeline.memory[imageIndex], 1213 0, uniforms_explosionPipeline.memorySize(), false); 1214 1215 VulkanUtils::copyDataToMemory(device, objects_explosionPipeline.data(), storageBuffers_explosionPipeline.memory[imageIndex], 1216 0, objects_explosionPipeline.memorySize(), false); 1263 VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), uniforms_explosionPipeline.mapped(imageIndex), 1264 uniformBuffers_explosionPipeline.memory[imageIndex], 1265 uniforms_explosionPipeline.memorySize(), true); 1266 1267 VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), objects_explosionPipeline.mapped(imageIndex), 1268 storageBuffers_explosionPipeline.memory[imageIndex], 1269 objects_explosionPipeline.memorySize(), true); 1217 1270 } 1218 1271 … … 2253 2306 createSyncObjects(); 2254 2307 2255 createBufferSet( vp_mats_modelPipeline.memorySize(),2308 createBufferSet(uniforms_modelPipeline.memorySize(), 2256 2309 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2257 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2310 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2258 2311 uniformBuffers_modelPipeline); 2312 2313 uniforms_modelPipeline.map(uniformBuffers_modelPipeline.memory, device); 2259 2314 2260 2315 createBufferSet(objects_modelPipeline.memorySize(), 2261 2316 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2262 2317 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2263 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2318 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2264 2319 storageBuffers_modelPipeline); 2320 2321 objects_modelPipeline.map(storageBuffers_modelPipeline.memory, device); 2265 2322 2266 2323 modelPipeline.updateRenderPass(renderPass); … … 2269 2326 modelPipeline.createDescriptorSets(swapChainImages.size()); 2270 2327 2271 createBufferSet( vp_mats_shipPipeline.memorySize(),2328 createBufferSet(uniforms_shipPipeline.memorySize(), 2272 2329 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2273 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2330 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2274 2331 uniformBuffers_shipPipeline); 2332 2333 uniforms_shipPipeline.map(uniformBuffers_shipPipeline.memory, device); 2275 2334 2276 2335 createBufferSet(objects_shipPipeline.memorySize(), 2277 2336 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2278 2337 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2279 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2338 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2280 2339 storageBuffers_shipPipeline); 2340 2341 objects_shipPipeline.map(storageBuffers_shipPipeline.memory, device); 2281 2342 2282 2343 shipPipeline.updateRenderPass(renderPass); … … 2285 2346 shipPipeline.createDescriptorSets(swapChainImages.size()); 2286 2347 2287 createBufferSet( vp_mats_asteroidPipeline.memorySize(),2348 createBufferSet(uniforms_asteroidPipeline.memorySize(), 2288 2349 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2289 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2350 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2290 2351 uniformBuffers_asteroidPipeline); 2352 2353 uniforms_asteroidPipeline.map(uniformBuffers_asteroidPipeline.memory, device); 2291 2354 2292 2355 createBufferSet(objects_asteroidPipeline.memorySize(), 2293 2356 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2294 2357 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2295 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2358 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2296 2359 storageBuffers_asteroidPipeline); 2360 2361 objects_asteroidPipeline.map(storageBuffers_asteroidPipeline.memory, device); 2297 2362 2298 2363 asteroidPipeline.updateRenderPass(renderPass); … … 2301 2366 asteroidPipeline.createDescriptorSets(swapChainImages.size()); 2302 2367 2303 createBufferSet( vp_mats_laserPipeline.memorySize(),2368 createBufferSet(uniforms_laserPipeline.memorySize(), 2304 2369 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2305 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2370 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2306 2371 uniformBuffers_laserPipeline); 2372 2373 uniforms_laserPipeline.map(uniformBuffers_laserPipeline.memory, device); 2307 2374 2308 2375 createBufferSet(objects_laserPipeline.memorySize(), 2309 2376 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2310 2377 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2311 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2378 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2312 2379 storageBuffers_laserPipeline); 2380 2381 objects_laserPipeline.map(storageBuffers_laserPipeline.memory, device); 2313 2382 2314 2383 laserPipeline.updateRenderPass(renderPass); … … 2319 2388 createBufferSet(uniforms_explosionPipeline.memorySize(), 2320 2389 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2321 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2390 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2322 2391 uniformBuffers_explosionPipeline); 2392 2393 uniforms_explosionPipeline.map(uniformBuffers_explosionPipeline.memory, device); 2323 2394 2324 2395 createBufferSet(objects_explosionPipeline.memorySize(), 2325 2396 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2326 2397 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 2327 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,2398 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2328 2399 storageBuffers_explosionPipeline); 2400 2401 objects_explosionPipeline.map(storageBuffers_explosionPipeline.memory, device); 2329 2402 2330 2403 explosionPipeline.updateRenderPass(renderPass); … … 2349 2422 2350 2423 modelPipeline.cleanup(); 2351 shipPipeline.cleanup(); 2352 asteroidPipeline.cleanup(); 2353 laserPipeline.cleanup(); 2354 explosionPipeline.cleanup(); 2424 2425 uniforms_modelPipeline.unmap(uniformBuffers_modelPipeline.memory, device); 2355 2426 2356 2427 for (size_t i = 0; i < uniformBuffers_modelPipeline.buffers.size(); i++) { … … 2359 2430 } 2360 2431 2432 objects_modelPipeline.unmap(storageBuffers_modelPipeline.memory, device); 2433 2361 2434 for (size_t i = 0; i < storageBuffers_modelPipeline.buffers.size(); i++) { 2362 2435 vkDestroyBuffer(device, storageBuffers_modelPipeline.buffers[i], nullptr); … … 2364 2437 } 2365 2438 2439 shipPipeline.cleanup(); 2440 2441 uniforms_shipPipeline.unmap(uniformBuffers_shipPipeline.memory, device); 2442 2366 2443 for (size_t i = 0; i < uniformBuffers_shipPipeline.buffers.size(); i++) { 2367 2444 vkDestroyBuffer(device, uniformBuffers_shipPipeline.buffers[i], nullptr); … … 2369 2446 } 2370 2447 2448 objects_shipPipeline.unmap(storageBuffers_shipPipeline.memory, device); 2449 2371 2450 for (size_t i = 0; i < storageBuffers_shipPipeline.buffers.size(); i++) { 2372 2451 vkDestroyBuffer(device, storageBuffers_shipPipeline.buffers[i], nullptr); … … 2374 2453 } 2375 2454 2455 asteroidPipeline.cleanup(); 2456 2457 uniforms_asteroidPipeline.unmap(uniformBuffers_asteroidPipeline.memory, device); 2458 2376 2459 for (size_t i = 0; i < uniformBuffers_asteroidPipeline.buffers.size(); i++) { 2377 2460 vkDestroyBuffer(device, uniformBuffers_asteroidPipeline.buffers[i], nullptr); … … 2379 2462 } 2380 2463 2464 objects_asteroidPipeline.unmap(storageBuffers_asteroidPipeline.memory, device); 2465 2381 2466 for (size_t i = 0; i < storageBuffers_asteroidPipeline.buffers.size(); i++) { 2382 2467 vkDestroyBuffer(device, storageBuffers_asteroidPipeline.buffers[i], nullptr); … … 2384 2469 } 2385 2470 2471 laserPipeline.cleanup(); 2472 2473 uniforms_laserPipeline.unmap(uniformBuffers_laserPipeline.memory, device); 2474 2386 2475 for (size_t i = 0; i < uniformBuffers_laserPipeline.buffers.size(); i++) { 2387 2476 vkDestroyBuffer(device, uniformBuffers_laserPipeline.buffers[i], nullptr); … … 2389 2478 } 2390 2479 2480 objects_laserPipeline.unmap(storageBuffers_laserPipeline.memory, device); 2481 2391 2482 for (size_t i = 0; i < storageBuffers_laserPipeline.buffers.size(); i++) { 2392 2483 vkDestroyBuffer(device, storageBuffers_laserPipeline.buffers[i], nullptr); … … 2394 2485 } 2395 2486 2487 explosionPipeline.cleanup(); 2488 2489 uniforms_explosionPipeline.unmap(uniformBuffers_explosionPipeline.memory, device); 2490 2396 2491 for (size_t i = 0; i < uniformBuffers_explosionPipeline.buffers.size(); i++) { 2397 2492 vkDestroyBuffer(device, uniformBuffers_explosionPipeline.buffers[i], nullptr); 2398 2493 vkFreeMemory(device, uniformBuffers_explosionPipeline.memory[i], nullptr); 2399 2494 } 2495 2496 objects_explosionPipeline.unmap(storageBuffers_explosionPipeline.memory, device); 2400 2497 2401 2498 for (size_t i = 0; i < storageBuffers_explosionPipeline.buffers.size(); i++) {
Note:
See TracChangeset
for help on using the changeset viewer.