Changeset a3cefaa in opengl-game for sdl-game.cpp
- 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
-
sdl-game.cpp
r996dd3e ra3cefaa 70 70 , gui(nullptr) 71 71 , window(nullptr) 72 , objects_modelPipeline() 72 73 , score(0) 73 74 , fps(0.0f) { … … 87 88 88 89 initVulkan(); 90 91 VkPhysicalDeviceProperties deviceProperties; 92 vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties); 93 94 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.minUniformBufferOffsetAlignment); 89 95 90 96 initImGuiOverlay(); … … 131 137 }, { 132 138 mat4(1.0f) 133 }, storageBuffers_modelPipeline , false);134 135 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo);139 }, storageBuffers_modelPipeline); 140 141 objects_modelPipeline.numObjects++; 136 142 137 143 texturedSquare->model_base = … … 152 158 }, { 153 159 mat4(1.0f) 154 }, storageBuffers_modelPipeline , false);155 156 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo);160 }, storageBuffers_modelPipeline); 161 162 objects_modelPipeline.numObjects++; 157 163 158 164 texturedSquare->model_base = … … 263 269 modelPipeline = GraphicsPipeline_Vulkan<ModelVertex>( 264 270 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 265 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24 , 10);266 267 createBufferSet( modelPipeline.objectCapacity * sizeof(SSBO_ModelObject),271 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24); 272 273 createBufferSet(objects_modelPipeline.capacity * sizeof(SSBO_ModelObject), 268 274 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 269 275 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, … … 376 382 }, { 377 383 mat4(1.0f) 378 }, storageBuffers_modelPipeline , true);379 380 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare.ssbo);384 }, storageBuffers_modelPipeline); 385 386 objects_modelPipeline.numObjects++; 381 387 382 388 texturedSquare.model_base = … … 446 452 447 453 void VulkanGame::updateScene() { 448 // TODO: These two for loops could probably be combined into one 449 454 // Rotate the textured squares 450 455 for (SceneObject<ModelVertex, SSBO_ModelObject>& model : this->modelObjects) { 451 456 model.model_transform = … … 455 460 } 456 461 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 462 // TODO: Probably move the resizing to the VulkanBuffer class 463 if (objects_modelPipeline.numObjects > objects_modelPipeline.capacity) { 464 resizeStorageBufferSet(storageBuffers_modelPipeline, objects_modelPipeline, modelPipeline, resourceCommandPool, 465 graphicsQueue); 466 } 467 459 468 for (size_t i = 0; i < modelObjects.size(); i++) { 460 469 if (modelObjects[i].modified) { 461 // TODO: Think about changing the SSBO-related code to also use a contiguous array462 // to store the data on the cpu side instead of storing it per-object463 // Then, I could also copy it to the GPU in one go464 // Also, double-check if the alignment restrictions also hold for SSBOs465 466 470 updateObject(modelObjects, modelPipeline, i); 467 471 updateStorageBuffer(storageBuffers_modelPipeline, i, modelObjects[i].ssbo); … … 845 849 return VulkanUtils::findSupportedFormat( 846 850 physicalDevice, 847 { VK_FORMAT_D32_SFLOAT , VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT },851 { VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D32_SFLOAT, VK_FORMAT_D24_UNORM_S8_UINT }, 848 852 VK_IMAGE_TILING_OPTIMAL, 849 853 VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
Note:
See TracChangeset
for help on using the changeset viewer.