Changeset 996dd3e in opengl-game for sdl-game.cpp
- Timestamp:
- May 14, 2021, 1:09:34 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- a3cefaa
- Parents:
- 9d21aac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
r9d21aac r996dd3e 110 110 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_modelPipeline); 111 111 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 112 VK_SHADER_STAGE_VERTEX_BIT, & modelPipeline.storageBufferSet.infoSet);112 VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_modelPipeline.infoSet); 113 113 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 114 114 VK_SHADER_STAGE_FRAGMENT_BIT, &floorTextureImageDescriptor); … … 131 131 }, { 132 132 mat4(1.0f) 133 }, false); 133 }, storageBuffers_modelPipeline, false); 134 135 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo); 134 136 135 137 texturedSquare->model_base = … … 150 152 }, { 151 153 mat4(1.0f) 152 }, false); 154 }, storageBuffers_modelPipeline, false); 155 156 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo); 153 157 154 158 texturedSquare->model_base = … … 264 268 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 265 269 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 266 modelPipeline.storageBufferSet.buffers, modelPipeline.storageBufferSet.memory,267 modelPipeline.storageBufferSet.infoSet);270 storageBuffers_modelPipeline.buffers, storageBuffers_modelPipeline.memory, 271 storageBuffers_modelPipeline.infoSet); 268 272 } 269 273 … … 372 376 }, { 373 377 mat4(1.0f) 374 }, true); 378 }, storageBuffers_modelPipeline, true); 379 380 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare.ssbo); 375 381 376 382 texturedSquare.model_base = … … 439 445 } 440 446 441 // TODO: The only updates that need to happen once per Vulkan image are the SSBO ones,442 // which are already handled by updateObject(). Move this code to a different place,443 // where it will run just once per frame444 447 void VulkanGame::updateScene() { 448 // TODO: These two for loops could probably be combined into one 449 445 450 for (SceneObject<ModelVertex, SSBO_ModelObject>& model : this->modelObjects) { 446 451 model.model_transform = … … 450 455 } 451 456 457 // TODO: Instead, update entire sections (up to 64k) of the dynamic ubo if some objects there have changed 458 // Also, update the objects modelMat and center in the loop above instead of here 452 459 for (size_t i = 0; i < modelObjects.size(); i++) { 453 460 if (modelObjects[i].modified) { 461 // TODO: Think about changing the SSBO-related code to also use a contiguous array 462 // to store the data on the cpu side instead of storing it per-object 463 // Then, I could also copy it to the GPU in one go 464 // Also, double-check if the alignment restrictions also hold for SSBOs 465 454 466 updateObject(modelObjects, modelPipeline, i); 467 updateStorageBuffer(storageBuffers_modelPipeline, i, modelObjects[i].ssbo); 455 468 } 456 469 } … … 475 488 modelPipeline.cleanupBuffers(); 476 489 477 for (size_t i = 0; i < modelPipeline.storageBufferSet.buffers.size(); i++) {478 vkDestroyBuffer(device, modelPipeline.storageBufferSet.buffers[i], nullptr);479 vkFreeMemory(device, modelPipeline.storageBufferSet.memory[i], nullptr);490 for (size_t i = 0; i < storageBuffers_modelPipeline.buffers.size(); i++) { 491 vkDestroyBuffer(device, storageBuffers_modelPipeline.buffers[i], nullptr); 492 vkFreeMemory(device, storageBuffers_modelPipeline.memory[i], nullptr); 480 493 } 481 494
Note:
See TracChangeset
for help on using the changeset viewer.