Changeset 67527a5 in opengl-game for vulkan-game.cpp
- Timestamp:
- Jun 21, 2021, 4:12:08 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 27e580e
- Parents:
- b01b50c
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/21/21 15:13:03)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/21/21 16:12:08)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
rb01b50c r67527a5 113 113 deviceProperties.limits.minUniformBufferOffsetAlignment); 114 114 115 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.max StorageBufferRange,116 deviceProperties.limits.min StorageBufferOffsetAlignment);115 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange, 116 deviceProperties.limits.minUniformBufferOffsetAlignment); 117 117 118 118 uniforms_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 119 119 deviceProperties.limits.minUniformBufferOffsetAlignment); 120 120 121 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.max StorageBufferRange,122 deviceProperties.limits.min StorageBufferOffsetAlignment);121 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange, 122 deviceProperties.limits.minUniformBufferOffsetAlignment); 123 123 124 124 uniforms_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 125 125 deviceProperties.limits.minUniformBufferOffsetAlignment); 126 126 127 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.max StorageBufferRange,128 deviceProperties.limits.min StorageBufferOffsetAlignment);127 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxUniformBufferRange, 128 deviceProperties.limits.minUniformBufferOffsetAlignment); 129 129 130 130 uniforms_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 131 131 deviceProperties.limits.minUniformBufferOffsetAlignment); 132 132 133 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.max StorageBufferRange,134 deviceProperties.limits.min StorageBufferOffsetAlignment);133 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxUniformBufferRange, 134 deviceProperties.limits.minUniformBufferOffsetAlignment); 135 135 136 136 uniforms_explosionPipeline = VulkanBuffer<UBO_Explosion>(1, deviceProperties.limits.maxUniformBufferRange, 137 137 deviceProperties.limits.minUniformBufferOffsetAlignment); 138 138 139 objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.max StorageBufferRange,140 deviceProperties.limits.min StorageBufferOffsetAlignment);139 objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.maxUniformBufferRange, 140 deviceProperties.limits.minUniformBufferOffsetAlignment); 141 141 142 142 initImGuiOverlay(); … … 166 166 createBufferSet(objects_modelPipeline.memorySize(), 167 167 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 168 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,168 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 169 169 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 170 170 objectBuffers_modelPipeline); … … 174 174 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 175 175 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_modelPipeline.infoSet); 176 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,176 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 177 177 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_modelPipeline.infoSet); 178 178 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, … … 240 240 createBufferSet(objects_shipPipeline.memorySize(), 241 241 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 242 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,242 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 243 243 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 244 244 objectBuffers_shipPipeline); … … 248 248 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 249 249 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_shipPipeline.infoSet); 250 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,250 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 251 251 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_shipPipeline.infoSet); 252 252 … … 511 511 createBufferSet(objects_asteroidPipeline.memorySize(), 512 512 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 513 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,513 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 514 514 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 515 515 objectBuffers_asteroidPipeline); … … 519 519 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 520 520 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_asteroidPipeline.infoSet); 521 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,521 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 522 522 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_asteroidPipeline.infoSet); 523 523 … … 540 540 createBufferSet(objects_laserPipeline.memorySize(), 541 541 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 542 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,542 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 543 543 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 544 544 objectBuffers_laserPipeline); … … 548 548 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 549 549 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_laserPipeline.infoSet); 550 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,550 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 551 551 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, &objectBuffers_laserPipeline.infoSet); 552 552 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, … … 571 571 createBufferSet(objects_explosionPipeline.memorySize(), 572 572 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 573 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,573 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 574 574 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 575 575 objectBuffers_explosionPipeline); … … 579 579 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 580 580 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_explosionPipeline.infoSet); 581 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,581 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 582 582 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_explosionPipeline.infoSet); 583 583 … … 1107 1107 } 1108 1108 1109 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex), 1109 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), 1110 uniforms_modelPipeline.mapped(imageIndex), 1110 1111 uniformBuffers_modelPipeline.memory[imageIndex], 1111 1112 uniforms_modelPipeline.memorySize(), true); 1112 1113 1113 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex), 1114 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), 1115 objects_modelPipeline.mapped(imageIndex), 1114 1116 objectBuffers_modelPipeline.memory[imageIndex], 1115 1117 objects_modelPipeline.memorySize(), true); … … 1137 1139 } 1138 1140 1139 VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), uniforms_shipPipeline.mapped(imageIndex), 1141 VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), 1142 uniforms_shipPipeline.mapped(imageIndex), 1140 1143 uniformBuffers_shipPipeline.memory[imageIndex], 1141 1144 uniforms_shipPipeline.memorySize(), true); 1142 1145 1143 VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), objects_shipPipeline.mapped(imageIndex), 1146 VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), 1147 objects_shipPipeline.mapped(imageIndex), 1144 1148 objectBuffers_shipPipeline.memory[imageIndex], 1145 1149 objects_shipPipeline.memorySize(), true); … … 1190 1194 } 1191 1195 1192 VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), uniforms_asteroidPipeline.mapped(imageIndex), 1196 VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), 1197 uniforms_asteroidPipeline.mapped(imageIndex), 1193 1198 uniformBuffers_asteroidPipeline.memory[imageIndex], 1194 1199 uniforms_asteroidPipeline.memorySize(), true); 1195 1200 1196 VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), objects_asteroidPipeline.mapped(imageIndex), 1201 VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), 1202 objects_asteroidPipeline.mapped(imageIndex), 1197 1203 objectBuffers_asteroidPipeline.memory[imageIndex], 1198 1204 objects_asteroidPipeline.memorySize(), true); … … 1226 1232 } 1227 1233 1228 VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), uniforms_laserPipeline.mapped(imageIndex), 1234 VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), 1235 uniforms_laserPipeline.mapped(imageIndex), 1229 1236 uniformBuffers_laserPipeline.memory[imageIndex], 1230 1237 uniforms_laserPipeline.memorySize(), true); 1231 1238 1232 VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), objects_laserPipeline.mapped(imageIndex), 1239 VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), 1240 objects_laserPipeline.mapped(imageIndex), 1233 1241 objectBuffers_laserPipeline.memory[imageIndex], 1234 1242 objects_laserPipeline.memorySize(), true); … … 1261 1269 } 1262 1270 1263 VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), uniforms_explosionPipeline.mapped(imageIndex), 1271 VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), 1272 uniforms_explosionPipeline.mapped(imageIndex), 1264 1273 uniformBuffers_explosionPipeline.memory[imageIndex], 1265 1274 uniforms_explosionPipeline.memorySize(), true); 1266 1275 1267 VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), objects_explosionPipeline.mapped(imageIndex), 1276 VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), 1277 objects_explosionPipeline.mapped(imageIndex), 1268 1278 objectBuffers_explosionPipeline.memory[imageIndex], 1269 1279 objects_explosionPipeline.memorySize(), true); … … 1863 1873 // TODO: Find a more elegant, per-screen solution for this 1864 1874 if (currentRenderScreenFn == &VulkanGame::renderGameScreen) { 1865 modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1866 shipPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1867 asteroidPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1868 laserPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1869 explosionPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1875 modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1876 shipPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1877 asteroidPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1878 laserPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1879 explosionPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1870 1880 } 1871 1881 … … 2315 2325 createBufferSet(objects_modelPipeline.memorySize(), 2316 2326 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2317 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2327 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2318 2328 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2319 2329 objectBuffers_modelPipeline); … … 2335 2345 createBufferSet(objects_shipPipeline.memorySize(), 2336 2346 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2337 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2347 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2338 2348 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2339 2349 objectBuffers_shipPipeline); … … 2355 2365 createBufferSet(objects_asteroidPipeline.memorySize(), 2356 2366 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2357 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2367 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2358 2368 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2359 2369 objectBuffers_asteroidPipeline); … … 2375 2385 createBufferSet(objects_laserPipeline.memorySize(), 2376 2386 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2377 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2387 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2378 2388 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2379 2389 objectBuffers_laserPipeline); … … 2395 2405 createBufferSet(objects_explosionPipeline.memorySize(), 2396 2406 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2397 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2407 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2398 2408 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2399 2409 objectBuffers_explosionPipeline);
Note:
See TracChangeset
for help on using the changeset viewer.