Changeset 996dd3e in opengl-game for vulkan-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
-
vulkan-game.cpp
r9d21aac r996dd3e 126 126 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_modelPipeline); 127 127 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 128 VK_SHADER_STAGE_VERTEX_BIT, & modelPipeline.storageBufferSet.infoSet);128 VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_modelPipeline.infoSet); 129 129 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 130 130 VK_SHADER_STAGE_FRAGMENT_BIT, &floorTextureImageDescriptor); … … 145 145 }, { 146 146 mat4(1.0f) 147 }, false); 147 }, storageBuffers_modelPipeline, false); 148 149 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo); 148 150 149 151 texturedSquare->model_base = … … 164 166 }, { 165 167 mat4(1.0f) 166 }, false); 168 }, storageBuffers_modelPipeline, false); 169 170 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare->ssbo); 167 171 168 172 texturedSquare->model_base = … … 189 193 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_shipPipeline); 190 194 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 191 VK_SHADER_STAGE_VERTEX_BIT, &s hipPipeline.storageBufferSet.infoSet);195 VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_shipPipeline.infoSet); 192 196 193 197 // TODO: With the normals, indexing basically becomes pointless since no vertices will have exactly … … 424 428 }, { 425 429 mat4(1.0f) 426 }, false); 430 }, storageBuffers_shipPipeline, false); 431 432 updateStorageBuffer(storageBuffers_shipPipeline, shipPipeline.numObjects - 1, ship.ssbo); 427 433 428 434 ship.model_base = … … 449 455 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_asteroidPipeline); 450 456 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 451 VK_SHADER_STAGE_VERTEX_BIT, & asteroidPipeline.storageBufferSet.infoSet);457 VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_asteroidPipeline.infoSet); 452 458 453 459 asteroidPipeline.createDescriptorSetLayout(); … … 467 473 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_laserPipeline); 468 474 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 469 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, & laserPipeline.storageBufferSet.infoSet);475 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, &storageBuffers_laserPipeline.infoSet); 470 476 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 471 477 VK_SHADER_STAGE_FRAGMENT_BIT, &laserTextureImageDescriptor); … … 487 493 VK_SHADER_STAGE_VERTEX_BIT, &uniformBufferInfoList_explosionPipeline); 488 494 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 489 VK_SHADER_STAGE_VERTEX_BIT, & explosionPipeline.storageBufferSet.infoSet);495 VK_SHADER_STAGE_VERTEX_BIT, &storageBuffers_explosionPipeline.infoSet); 490 496 491 497 explosionPipeline.createDescriptorSetLayout(); … … 599 605 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 600 606 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 601 modelPipeline.storageBufferSet.buffers, modelPipeline.storageBufferSet.memory,602 modelPipeline.storageBufferSet.infoSet);607 storageBuffers_modelPipeline.buffers, storageBuffers_modelPipeline.memory, 608 storageBuffers_modelPipeline.infoSet); 603 609 604 610 shipPipeline = GraphicsPipeline_Vulkan<ModelVertex>( … … 609 615 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 610 616 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 611 s hipPipeline.storageBufferSet.buffers, shipPipeline.storageBufferSet.memory,612 s hipPipeline.storageBufferSet.infoSet);617 storageBuffers_shipPipeline.buffers, storageBuffers_shipPipeline.memory, 618 storageBuffers_shipPipeline.infoSet); 613 619 614 620 asteroidPipeline = GraphicsPipeline_Vulkan<ModelVertex>( … … 619 625 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 620 626 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 621 asteroidPipeline.storageBufferSet.buffers, asteroidPipeline.storageBufferSet.memory,622 asteroidPipeline.storageBufferSet.infoSet);627 storageBuffers_asteroidPipeline.buffers, storageBuffers_asteroidPipeline.memory, 628 storageBuffers_asteroidPipeline.infoSet); 623 629 624 630 laserPipeline = GraphicsPipeline_Vulkan<LaserVertex>( … … 629 635 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 630 636 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 631 laserPipeline.storageBufferSet.buffers, laserPipeline.storageBufferSet.memory,632 laserPipeline.storageBufferSet.infoSet);637 storageBuffers_laserPipeline.buffers, storageBuffers_laserPipeline.memory, 638 storageBuffers_laserPipeline.infoSet); 633 639 634 640 explosionPipeline = GraphicsPipeline_Vulkan<ExplosionVertex>( … … 640 646 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 641 647 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 642 explosionPipeline.storageBufferSet.buffers, explosionPipeline.storageBufferSet.memory,643 explosionPipeline.storageBufferSet.infoSet);648 storageBuffers_explosionPipeline.buffers, storageBuffers_explosionPipeline.memory, 649 storageBuffers_explosionPipeline.infoSet); 644 650 } 645 651 … … 762 768 }, { 763 769 mat4(1.0f) 764 }, true); 770 }, storageBuffers_modelPipeline, true); 771 772 updateStorageBuffer(storageBuffers_modelPipeline, modelPipeline.numObjects - 1, texturedSquare.ssbo); 765 773 766 774 texturedSquare.model_base = … … 1042 1050 10.0f, 1043 1051 false 1044 }, true); 1052 }, storageBuffers_asteroidPipeline, true); 1053 1054 updateStorageBuffer(storageBuffers_asteroidPipeline, asteroidPipeline.numObjects - 1, asteroid.ssbo); 1045 1055 1046 1056 // This accounts for the scaling in model_base. … … 1070 1080 if (shipObjects[i].modified) { 1071 1081 updateObject(shipObjects, shipPipeline, i); 1082 updateStorageBuffer(storageBuffers_shipPipeline, i, shipObjects[i].ssbo); 1072 1083 } 1073 1084 } … … 1076 1087 if (modelObjects[i].modified) { 1077 1088 updateObject(modelObjects, modelPipeline, i); 1089 updateStorageBuffer(storageBuffers_modelPipeline, i, modelObjects[i].ssbo); 1078 1090 } 1079 1091 } … … 1082 1094 if (asteroidObjects[i].modified) { 1083 1095 updateObject(asteroidObjects, asteroidPipeline, i); 1096 updateStorageBuffer(storageBuffers_asteroidPipeline, i, asteroidObjects[i].ssbo); 1084 1097 } 1085 1098 } … … 1088 1101 if (laserObjects[i].modified) { 1089 1102 updateObject(laserObjects, laserPipeline, i); 1103 updateStorageBuffer(storageBuffers_laserPipeline, i, laserObjects[i].ssbo); 1090 1104 } 1091 1105 } … … 1094 1108 if (explosionObjects[i].modified) { 1095 1109 updateObject(explosionObjects, explosionPipeline, i); 1110 updateStorageBuffer(storageBuffers_explosionPipeline, i, explosionObjects[i].ssbo); 1096 1111 } 1097 1112 } … … 1131 1146 explosionPipeline.cleanupBuffers(); 1132 1147 1133 for (size_t i = 0; i < modelPipeline.storageBufferSet.buffers.size(); i++) {1134 vkDestroyBuffer(device, modelPipeline.storageBufferSet.buffers[i], nullptr);1135 vkFreeMemory(device, modelPipeline.storageBufferSet.memory[i], nullptr);1136 } 1137 1138 for (size_t i = 0; i < s hipPipeline.storageBufferSet.buffers.size(); i++) {1139 vkDestroyBuffer(device, s hipPipeline.storageBufferSet.buffers[i], nullptr);1140 vkFreeMemory(device, s hipPipeline.storageBufferSet.memory[i], nullptr);1141 } 1142 1143 for (size_t i = 0; i < asteroidPipeline.storageBufferSet.buffers.size(); i++) {1144 vkDestroyBuffer(device, asteroidPipeline.storageBufferSet.buffers[i], nullptr);1145 vkFreeMemory(device, asteroidPipeline.storageBufferSet.memory[i], nullptr);1146 } 1147 1148 for (size_t i = 0; i < laserPipeline.storageBufferSet.buffers.size(); i++) {1149 vkDestroyBuffer(device, laserPipeline.storageBufferSet.buffers[i], nullptr);1150 vkFreeMemory(device, laserPipeline.storageBufferSet.memory[i], nullptr);1151 } 1152 1153 for (size_t i = 0; i < explosionPipeline.storageBufferSet.buffers.size(); i++) {1154 vkDestroyBuffer(device, explosionPipeline.storageBufferSet.buffers[i], nullptr);1155 vkFreeMemory(device, explosionPipeline.storageBufferSet.memory[i], nullptr);1148 for (size_t i = 0; i < storageBuffers_modelPipeline.buffers.size(); i++) { 1149 vkDestroyBuffer(device, storageBuffers_modelPipeline.buffers[i], nullptr); 1150 vkFreeMemory(device, storageBuffers_modelPipeline.memory[i], nullptr); 1151 } 1152 1153 for (size_t i = 0; i < storageBuffers_shipPipeline.buffers.size(); i++) { 1154 vkDestroyBuffer(device, storageBuffers_shipPipeline.buffers[i], nullptr); 1155 vkFreeMemory(device, storageBuffers_shipPipeline.memory[i], nullptr); 1156 } 1157 1158 for (size_t i = 0; i < storageBuffers_asteroidPipeline.buffers.size(); i++) { 1159 vkDestroyBuffer(device, storageBuffers_asteroidPipeline.buffers[i], nullptr); 1160 vkFreeMemory(device, storageBuffers_asteroidPipeline.memory[i], nullptr); 1161 } 1162 1163 for (size_t i = 0; i < storageBuffers_laserPipeline.buffers.size(); i++) { 1164 vkDestroyBuffer(device, storageBuffers_laserPipeline.buffers[i], nullptr); 1165 vkFreeMemory(device, storageBuffers_laserPipeline.memory[i], nullptr); 1166 } 1167 1168 for (size_t i = 0; i < storageBuffers_explosionPipeline.buffers.size(); i++) { 1169 vkDestroyBuffer(device, storageBuffers_explosionPipeline.buffers[i], nullptr); 1170 vkFreeMemory(device, storageBuffers_explosionPipeline.memory[i], nullptr); 1156 1171 } 1157 1172 … … 1914 1929 color, 1915 1930 false 1916 }, true); 1931 }, storageBuffers_laserPipeline, true); 1932 1933 updateStorageBuffer(storageBuffers_laserPipeline, laserPipeline.numObjects - 1, laser.ssbo); 1917 1934 1918 1935 float xAxisRotation = asin(ray.y / length); … … 2124 2141 duration, 2125 2142 false 2126 }, true); 2143 }, storageBuffers_explosionPipeline, true); 2144 2145 updateStorageBuffer(storageBuffers_explosionPipeline, explosionPipeline.numObjects - 1, explosion.ssbo); 2127 2146 2128 2147 explosion.model_base = model_mat;
Note:
See TracChangeset
for help on using the changeset viewer.