Changeset 5ea0a37 in opengl-game
- Timestamp:
- Jun 11, 2021, 10:05:25 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 90880fb
- Parents:
- 6486ba8
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
r6486ba8 r5ea0a37 465 465 objData.model = obj.model_transform * obj.model_base; 466 466 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 467 468 updateBufferSet(storageBuffers_modelPipeline, i, objData); 469 } 467 } 468 469 VulkanUtils::copyDataToMemory(device, objects_modelPipeline.data(), storageBuffers_modelPipeline.memory[imageIndex], 470 0, objects_modelPipeline.memorySize(), false); 470 471 471 472 VulkanUtils::copyDataToMemory(device, &object_VP_mats, uniformBuffers_modelPipeline.memory[imageIndex], 0, -
sdl-game.hpp
r6486ba8 r5ea0a37 300 300 bool copyData); 301 301 302 template<class SSBOType>303 void updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo);304 305 302 // TODO: Since addObject() returns a reference to the new object now, 306 303 // stop using objects.back() to access the object that was just created … … 338 335 void quitGame(); 339 336 }; 340 341 // TODO: See if it makes sense to pass in the current swapchain index instead of updating all of them342 template<class SSBOType>343 void VulkanGame::updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo) {344 for (size_t i = 0; i < set.memory.size(); i++) {345 VulkanUtils::copyDataToMemory(device, &ssbo, set.memory[i], objIndex * sizeof(SSBOType), sizeof(ssbo), false);346 }347 }348 337 349 338 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model and to change -
vulkan-buffer.hpp
r6486ba8 r5ea0a37 31 31 VulkanBuffer<T>& operator=(VulkanBuffer<T>&& other) noexcept; 32 32 33 void resize(); 33 size_t memorySize(); 34 35 T* data(); // Not sure I need to expose this 34 36 35 37 T& get(uint32_t index); 36 38 void add(T obj); 37 39 38 size_t memorySize();40 void resize(); 39 41 40 42 private: … … 114 116 range = other.range; 115 117 118 mappedData = other.mappedData; 119 116 120 if (rawData != nullptr) { 117 121 free(rawData); … … 124 128 other.range = 0; 125 129 130 other.mappedData.clear(); 126 131 other.rawData = nullptr; 127 132 } … … 131 136 132 137 template<class T> 133 void VulkanBuffer<T>::resize() { 134 resized = false; 138 size_t VulkanBuffer<T>::memorySize() { 139 return memRequirement(capacity); 140 } 141 142 template<class T> 143 T* VulkanBuffer<T>::data() { 144 return rawData; 135 145 } 136 146 … … 145 155 template<class T> 146 156 void VulkanBuffer<T>::add(T obj) { 157 // TODO: Maybe copy this to the resize() function and call that function here 147 158 if (numObjects == capacity) { 148 159 // Once I add Vulkan buffer objects in here, make sure this doesn't overlap with resizeBufferSet … … 171 182 172 183 template<class T> 173 size_t VulkanBuffer<T>::memorySize() {174 re turn memRequirement(capacity);184 void VulkanBuffer<T>::resize() { 185 resized = false; 175 186 } 176 187 -
vulkan-game.cpp
r6486ba8 r5ea0a37 1022 1022 1023 1023 // TODO: Probably move the resizing to the VulkanBuffer class 1024 1025 // TODO: Replace updateBufferSet to one call to copyDataToMemory, using VulkanBuffer to provide the data source1026 1024 // TODO: Figure out a way to make updateDescriptorInfo easier to use, maybe store the binding index in the buffer set 1027 1025 … … 1046 1044 objData.model = obj.model_transform * obj.model_base; 1047 1045 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1048 1049 updateBufferSet(storageBuffers_modelPipeline, i, objData); 1050 } 1046 } 1047 1048 VulkanUtils::copyDataToMemory(device, objects_modelPipeline.data(), storageBuffers_modelPipeline.memory[imageIndex], 1049 0, objects_modelPipeline.memorySize(), false); 1051 1050 1052 1051 if (objects_shipPipeline.resized) { … … 1066 1065 objData.model = obj.model_transform * obj.model_base; 1067 1066 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1068 1069 updateBufferSet(storageBuffers_shipPipeline, i, objData); 1070 } 1067 } 1068 1069 VulkanUtils::copyDataToMemory(device, objects_shipPipeline.data(), storageBuffers_shipPipeline.memory[imageIndex], 1070 0, objects_shipPipeline.memorySize(), false); 1071 1071 1072 1072 if (objects_asteroidPipeline.resized) { … … 1108 1108 objData.model = obj.model_transform * obj.model_base; 1109 1109 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1110 1111 updateBufferSet(storageBuffers_asteroidPipeline, i, objData);1112 1110 } 1113 1111 } 1112 1113 VulkanUtils::copyDataToMemory(device, objects_asteroidPipeline.data(), storageBuffers_asteroidPipeline.memory[imageIndex], 1114 0, objects_asteroidPipeline.memorySize(), false); 1114 1115 1115 1116 if (objects_laserPipeline.resized) { … … 1135 1136 objData.model = obj.model_transform * obj.model_base; 1136 1137 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1137 1138 updateBufferSet(storageBuffers_laserPipeline, i, objData); 1139 } 1138 } 1139 1140 VulkanUtils::copyDataToMemory(device, objects_laserPipeline.data(), storageBuffers_laserPipeline.memory[imageIndex], 1141 0, objects_laserPipeline.memorySize(), false); 1140 1142 1141 1143 if (objects_explosionPipeline.resized) { … … 1160 1162 objData.model = obj.model_transform * obj.model_base; 1161 1163 obj.center = vec3(objData.model * vec4(0.0f, 0.0f, 0.0f, 1.0f)); 1162 1163 updateBufferSet(storageBuffers_explosionPipeline, i, objData); 1164 } 1164 } 1165 1166 VulkanUtils::copyDataToMemory(device, objects_explosionPipeline.data(), storageBuffers_explosionPipeline.memory[imageIndex], 1167 0, objects_explosionPipeline.memorySize(), false); 1165 1168 1166 1169 explosion_UBO.cur_time = curTime; -
vulkan-game.hpp
r6486ba8 r5ea0a37 432 432 bool copyData); 433 433 434 template<class SSBOType>435 void updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo);436 437 434 // TODO: Since addObject() returns a reference to the new object now, 438 435 // stop using objects.back() to access the object that was just created … … 490 487 491 488 // End of specialized no-op functions 492 493 // TODO: See if it makes sense to pass in the current swapchain index instead of updating all of them494 template<class SSBOType>495 void VulkanGame::updateBufferSet(BufferSet& set, size_t objIndex, SSBOType& ssbo) {496 for (size_t i = 0; i < set.memory.size(); i++) {497 VulkanUtils::copyDataToMemory(device, &ssbo, set.memory[i], objIndex * sizeof(SSBOType), sizeof(ssbo), false);498 }499 }500 489 501 490 // TODO: Right now, it's basically necessary to pass the identity matrix in for ssbo.model and to change
Note:
See TracChangeset
for help on using the changeset viewer.