Changeset bb76950 in opengl-game for vulkan-game.cpp
- Timestamp:
- Jun 9, 2021, 6:41:48 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- b7fc3c2
- Parents:
- 6bac215
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/09/21 18:41:20)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/09/21 18:41:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.cpp
r6bac215 rbb76950 1089 1089 } 1090 1090 1091 // TODO: Replace updateBufferSet to one call to copyDataToMemory, using VulkanBuffer to provide the data source 1092 // TODO: Figure out a way to make updateDescriptorInfo easier to use, maybe store the binding index in the buffer set 1091 1093 // TODO: Probably move the resizing to the VulkanBuffer class 1094 1092 1095 if (objects_modelPipeline.resized) { 1093 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline , modelPipeline, resourceCommandPool,1094 graphicsQueue);1096 resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.capacity * sizeof(SSBO_ModelObject), 1097 resourceCommandPool, graphicsQueue, true); 1095 1098 1096 1099 objects_modelPipeline.resize(); 1100 1101 modelPipeline.updateDescriptorInfo(1, &storageBuffers_modelPipeline.infoSet, swapChainImages.size()); 1097 1102 } 1098 1103 … … 1106 1111 // TODO: Probably move the resizing to the VulkanBuffer class 1107 1112 if (objects_shipPipeline.resized) { 1108 resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline , shipPipeline, resourceCommandPool,1109 graphicsQueue);1113 resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline.capacity * sizeof(SSBO_ModelObject), 1114 resourceCommandPool, graphicsQueue, true); 1110 1115 1111 1116 objects_shipPipeline.resize(); 1117 1118 shipPipeline.updateDescriptorInfo(1, &storageBuffers_shipPipeline.infoSet, swapChainImages.size()); 1112 1119 } 1113 1120 … … 1121 1128 // TODO: Probably move the resizing to the VulkanBuffer class 1122 1129 if (objects_asteroidPipeline.resized) { 1123 resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline , asteroidPipeline,1124 resourceCommandPool, graphicsQueue );1130 resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline.capacity * sizeof(SSBO_Asteroid), 1131 resourceCommandPool, graphicsQueue, true); 1125 1132 1126 1133 objects_asteroidPipeline.resize(); 1134 1135 asteroidPipeline.updateDescriptorInfo(1, &storageBuffers_asteroidPipeline.infoSet, swapChainImages.size()); 1127 1136 } 1128 1137 … … 1136 1145 // TODO: Probably move the resizing to the VulkanBuffer class 1137 1146 if (objects_laserPipeline.resized) { 1138 resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline , laserPipeline, resourceCommandPool,1139 graphicsQueue);1147 resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline.capacity * sizeof(SSBO_Laser), 1148 resourceCommandPool, graphicsQueue, true); 1140 1149 1141 1150 objects_laserPipeline.resize(); 1151 1152 laserPipeline.updateDescriptorInfo(1, &storageBuffers_laserPipeline.infoSet, swapChainImages.size()); 1142 1153 } 1143 1154 … … 1151 1162 // TODO: Probably move the resizing to the VulkanBuffer class 1152 1163 if (objects_explosionPipeline.resized) { 1153 resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline , explosionPipeline,1154 resourceCommandPool, graphicsQueue);1164 resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline.capacity * sizeof(SSBO_Explosion), 1165 resourceCommandPool, graphicsQueue, true); 1155 1166 1156 1167 objects_explosionPipeline.resize(); 1168 1169 explosionPipeline.updateDescriptorInfo(1, &storageBuffers_explosionPipeline.infoSet, swapChainImages.size()); 1157 1170 } 1158 1171 … … 1962 1975 set.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now 1963 1976 set.infoSet[i].range = bufferSize; // Size of the update starting from offset, or VK_WHOLE_SIZE 1977 } 1978 } 1979 1980 void VulkanGame::resizeBufferSet(BufferSet& set, VkDeviceSize newSize, VkCommandPool commandPool, 1981 VkQueue graphicsQueue, bool copyData) { 1982 for (size_t i = 0; i < set.buffers.size(); i++) { 1983 VkBuffer newBuffer; 1984 VkDeviceMemory newMemory; 1985 1986 VulkanUtils::createBuffer(device, physicalDevice, newSize, set.usages, set.properties, newBuffer, newMemory); 1987 1988 if (copyData) { 1989 VulkanUtils::copyBuffer(device, commandPool, set.buffers[i], newBuffer, 0, 0, set.infoSet[i].range, 1990 graphicsQueue); 1991 } 1992 1993 vkDestroyBuffer(device, set.buffers[i], nullptr); 1994 vkFreeMemory(device, set.memory[i], nullptr); 1995 1996 set.buffers[i] = newBuffer; 1997 set.memory[i] = newMemory; 1998 1999 set.infoSet[i].buffer = set.buffers[i]; 2000 set.infoSet[i].offset = 0; // This is the offset from the start of the buffer, so always 0 for now 2001 set.infoSet[i].range = newSize; // Size of the update starting from offset, or VK_WHOLE_SIZE 1964 2002 } 1965 2003 }
Note:
See TracChangeset
for help on using the changeset viewer.