Changeset 67527a5 in opengl-game
- Timestamp:
- Jun 21, 2021, 4:12:08 PM (3 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 27e580e
- Parents:
- b01b50c
- git-author:
- Dmitry Portnoy <dportnoy@…> (06/21/21 15:13:03)
- git-committer:
- Dmitry Portnoy <dportnoy@…> (06/21/21 16:12:08)
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.cpp
rb01b50c r67527a5 96 96 deviceProperties.limits.minUniformBufferOffsetAlignment); 97 97 98 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.max StorageBufferRange,99 deviceProperties.limits.min StorageBufferOffsetAlignment);98 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange, 99 deviceProperties.limits.minUniformBufferOffsetAlignment); 100 100 101 101 initImGuiOverlay(); … … 123 123 createBufferSet(objects_modelPipeline.memorySize(), 124 124 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 125 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,125 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 126 126 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 127 127 objectBuffers_modelPipeline); … … 131 131 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 132 132 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_modelPipeline.infoSet); 133 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,133 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 134 134 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_modelPipeline.infoSet); 135 135 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, … … 482 482 } 483 483 484 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex), 484 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), 485 uniforms_modelPipeline.mapped(imageIndex), 485 486 uniformBuffers_modelPipeline.memory[imageIndex], 486 487 uniforms_modelPipeline.memorySize(), true); 487 488 488 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex), 489 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), 490 objects_modelPipeline.mapped(imageIndex), 489 491 objectBuffers_modelPipeline.memory[imageIndex], 490 492 objects_modelPipeline.memorySize(), true); … … 1213 1215 // TODO: Find a more elegant, per-screen solution for this 1214 1216 if (currentRenderScreenFn == &VulkanGame::renderGameScreen) { 1215 modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1217 modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1216 1218 1217 1219 … … 1301 1303 createBufferSet(objects_modelPipeline.memorySize(), 1302 1304 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 1303 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,1305 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 1304 1306 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 1305 1307 objectBuffers_modelPipeline); -
shaders/asteroid.vert
rb01b50c r67527a5 8 8 }; 9 9 10 layout (binding = 0) uniform UniformBufferObject{10 layout (binding = 0) uniform camera_block { 11 11 mat4 view; 12 12 mat4 proj; 13 } camera; 14 15 layout(binding = 1) uniform ubo_block { 16 Object objects[1024]; 13 17 } ubo; 14 15 layout(binding = 1) readonly buffer StorageBufferObject {16 Object objects[];17 } sbo;18 18 19 19 layout(location = 0) in vec3 vertex_position; … … 35 35 36 36 void main() { 37 position_eye = vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));38 normal_eye = normalize(vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));37 position_eye = vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_position, 1.0)); 38 normal_eye = normalize(vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_normal, 0.0))); 39 39 40 float hp_percent = sbo.objects[obj_index].hp / 10.0;40 float hp_percent = ubo.objects[obj_index].hp / 10.0; 41 41 vec3 damage_color = vec3(1.0, 0.0, 0.0); 42 42 color = (vertex_color * hp_percent) + (damage_color * (1.0 - hp_percent)); … … 44 44 fragTexCoord = inTexCoord; 45 45 46 light_position_eye = vec3( ubo.view * vec4(light_position_world, 1.0));47 light2_position_eye = vec3( ubo.view * vec4(light2_position_world, 1.0));46 light_position_eye = vec3(camera.view * vec4(light_position_world, 1.0)); 47 light2_position_eye = vec3(camera.view * vec4(light2_position_world, 1.0)); 48 48 49 if ( sbo.objects[obj_index].deleted) {49 if (ubo.objects[obj_index].deleted) { 50 50 gl_Position = vec4(0.0, 0.0, 2.0, 1.0); 51 51 } else { 52 gl_Position = ubo.proj * vec4(position_eye, 1.0);52 gl_Position = camera.proj * vec4(position_eye, 1.0); 53 53 } 54 54 } -
shaders/explosion.vert
rb01b50c r67527a5 9 9 }; 10 10 11 layout (binding = 0) uniform UniformBufferObject{11 layout (binding = 0) uniform camera_block { 12 12 mat4 view; 13 13 mat4 proj; 14 14 float cur_time; 15 } camera; 16 17 layout(binding = 1) uniform ubo_block { 18 Object objects[1024]; 15 19 } ubo; 16 17 layout(binding = 1) readonly buffer StorageBufferObject {18 Object objects[];19 } sbo;20 20 21 21 layout(location = 0) in vec3 particle_start_velocity; … … 26 26 27 27 void main() { 28 mat4 model = sbo.objects[obj_index].model;29 float explosion_start_time = sbo.objects[obj_index].explosion_start_time;30 float explosion_duration = sbo.objects[obj_index].explosion_duration;31 bool deleted = sbo.objects[obj_index].deleted;28 mat4 model = ubo.objects[obj_index].model; 29 float explosion_start_time = ubo.objects[obj_index].explosion_start_time; 30 float explosion_duration = ubo.objects[obj_index].explosion_duration; 31 bool deleted = ubo.objects[obj_index].deleted; 32 32 33 float t = ubo.cur_time - explosion_start_time - particle_start_time;33 float t = camera.cur_time - explosion_start_time - particle_start_time; 34 34 35 35 if (t < 0.0) { … … 56 56 p += normalize(particle_start_velocity) * mod(t, explosion_duration) / explosion_duration * 0.3; 57 57 58 gl_Position = ubo.proj * ubo.view * model * vec4(p, 1.0);58 gl_Position = camera.proj * camera.view * model * vec4(p, 1.0); 59 59 } 60 60 gl_PointSize = 10.0; // size in pixels -
shaders/laser.frag
rb01b50c r67527a5 8 8 }; 9 9 10 layout(binding = 1) readonly buffer StorageBufferObject{11 Object objects[ ];12 } sbo;10 layout(binding = 1) uniform ubo_block { 11 Object objects[1024]; 12 } ubo; 13 13 14 14 layout(binding = 2) uniform sampler2D laser_texture; … … 21 21 void main() { 22 22 vec4 texel = texture(laser_texture, texcoords_fs); 23 vec3 laser_color = sbo.objects[obj_index_fs].color;23 vec3 laser_color = ubo.objects[obj_index_fs].color; 24 24 25 25 frag_color = vec4(texel.r * laser_color.r, texel.g * laser_color.g, texel.b * laser_color.b, texel.a); -
shaders/laser.vert
rb01b50c r67527a5 8 8 }; 9 9 10 layout (binding = 0) uniform UniformBufferObject{10 layout (binding = 0) uniform camera_block { 11 11 mat4 view; 12 12 mat4 proj; 13 } camera; 14 15 layout(binding = 1) uniform ubo_block { 16 Object objects[1024]; 13 17 } ubo; 14 15 layout(binding = 1) readonly buffer StorageBufferObject {16 Object objects[];17 } sbo;18 18 19 19 layout(location = 0) in vec3 vertex_position; … … 25 25 26 26 void main() { 27 vec3 position_eye = vec3( ubo.view * sbo.objects[obj_index_vs].model * vec4(vertex_position, 1.0));27 vec3 position_eye = vec3(camera.view * ubo.objects[obj_index_vs].model * vec4(vertex_position, 1.0)); 28 28 29 29 texcoords_fs = texcoords_vs; 30 30 obj_index_fs = obj_index_vs; 31 31 32 if ( sbo.objects[obj_index_vs].deleted) {32 if (ubo.objects[obj_index_vs].deleted) { 33 33 gl_Position = vec4(0.0, 0.0, 2.0, 1.0); 34 34 } else { 35 gl_Position = ubo.proj * vec4(position_eye, 1.0);35 gl_Position = camera.proj * vec4(position_eye, 1.0); 36 36 } 37 37 } -
shaders/model.vert
rb01b50c r67527a5 6 6 }; 7 7 8 layout (binding = 0) uniform UniformBufferObject{8 layout (binding = 0) uniform camera_block { 9 9 mat4 view; 10 10 mat4 proj; 11 } camera; 12 13 // TODO: Verify that I can actually store 1024 values here. They last time I checked, I think I could only store 1016 values 14 layout (binding = 1) uniform ubo_block { 15 Object objects[1024]; 11 16 } ubo; 12 13 layout(binding = 1) readonly buffer StorageBufferObject {14 Object objects[];15 } sbo;16 17 layout (binding = 2) uniform UboInstance {18 mat4 model;19 } uboInstance;20 17 21 18 layout(location = 0) in vec3 inPosition; … … 31 28 void main() { 32 29 // Using 0.0 instead of 1.0 means translations won't effect the normal 33 normal_eye = normalize(vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));30 normal_eye = normalize(vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_normal, 0.0))); 34 31 35 32 fragColor = inColor; 36 33 fragTexCoord = inTexCoord; 37 34 38 gl_Position = ubo.proj * ubo.view * sbo.objects[obj_index].model * vec4(inPosition, 1.0);35 gl_Position = camera.proj * camera.view * ubo.objects[obj_index].model * vec4(inPosition, 1.0); 39 36 } -
shaders/ship.vert
rb01b50c r67527a5 6 6 }; 7 7 8 layout (binding = 0) uniform UniformBufferObject{8 layout (binding = 0) uniform camera_block { 9 9 mat4 view; 10 10 mat4 proj; 11 } camera; 12 13 layout(binding = 1) uniform ubo_block { 14 Object objects[1024]; 11 15 } ubo; 12 13 layout(binding = 1) readonly buffer StorageBufferObject {14 Object objects[];15 } sbo;16 16 17 17 layout(location = 0) in vec3 vertex_position; … … 35 35 // Check Anton's book to see how to fix this 36 36 void main() { 37 position_eye = vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));37 position_eye = vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_position, 1.0)); 38 38 39 39 // Using 0.0 instead of 1.0 means translations won't effect the normal 40 normal_eye = normalize(vec3( ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));40 normal_eye = normalize(vec3(camera.view * ubo.objects[obj_index].model * vec4(vertex_normal, 0.0))); 41 41 42 42 color = vertex_color; … … 44 44 fragTexCoord = inTexCoord; 45 45 46 light_position_eye = vec3( ubo.view * vec4(light_position_world, 1.0));47 light2_position_eye = vec3( ubo.view * vec4(light2_position_world, 1.0));46 light_position_eye = vec3(camera.view * vec4(light_position_world, 1.0)); 47 light2_position_eye = vec3(camera.view * vec4(light2_position_world, 1.0)); 48 48 49 gl_Position = ubo.proj * vec4(position_eye, 1.0);49 gl_Position = camera.proj * vec4(position_eye, 1.0); 50 50 } -
vulkan-game.cpp
rb01b50c r67527a5 113 113 deviceProperties.limits.minUniformBufferOffsetAlignment); 114 114 115 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.max StorageBufferRange,116 deviceProperties.limits.min StorageBufferOffsetAlignment);115 objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange, 116 deviceProperties.limits.minUniformBufferOffsetAlignment); 117 117 118 118 uniforms_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 119 119 deviceProperties.limits.minUniformBufferOffsetAlignment); 120 120 121 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.max StorageBufferRange,122 deviceProperties.limits.min StorageBufferOffsetAlignment);121 objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange, 122 deviceProperties.limits.minUniformBufferOffsetAlignment); 123 123 124 124 uniforms_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 125 125 deviceProperties.limits.minUniformBufferOffsetAlignment); 126 126 127 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.max StorageBufferRange,128 deviceProperties.limits.min StorageBufferOffsetAlignment);127 objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxUniformBufferRange, 128 deviceProperties.limits.minUniformBufferOffsetAlignment); 129 129 130 130 uniforms_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange, 131 131 deviceProperties.limits.minUniformBufferOffsetAlignment); 132 132 133 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.max StorageBufferRange,134 deviceProperties.limits.min StorageBufferOffsetAlignment);133 objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxUniformBufferRange, 134 deviceProperties.limits.minUniformBufferOffsetAlignment); 135 135 136 136 uniforms_explosionPipeline = VulkanBuffer<UBO_Explosion>(1, deviceProperties.limits.maxUniformBufferRange, 137 137 deviceProperties.limits.minUniformBufferOffsetAlignment); 138 138 139 objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.max StorageBufferRange,140 deviceProperties.limits.min StorageBufferOffsetAlignment);139 objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.maxUniformBufferRange, 140 deviceProperties.limits.minUniformBufferOffsetAlignment); 141 141 142 142 initImGuiOverlay(); … … 166 166 createBufferSet(objects_modelPipeline.memorySize(), 167 167 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 168 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,168 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 169 169 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 170 170 objectBuffers_modelPipeline); … … 174 174 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 175 175 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_modelPipeline.infoSet); 176 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,176 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 177 177 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_modelPipeline.infoSet); 178 178 modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, … … 240 240 createBufferSet(objects_shipPipeline.memorySize(), 241 241 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 242 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,242 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 243 243 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 244 244 objectBuffers_shipPipeline); … … 248 248 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 249 249 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_shipPipeline.infoSet); 250 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,250 shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 251 251 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_shipPipeline.infoSet); 252 252 … … 511 511 createBufferSet(objects_asteroidPipeline.memorySize(), 512 512 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 513 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,513 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 514 514 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 515 515 objectBuffers_asteroidPipeline); … … 519 519 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 520 520 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_asteroidPipeline.infoSet); 521 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,521 asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 522 522 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_asteroidPipeline.infoSet); 523 523 … … 540 540 createBufferSet(objects_laserPipeline.memorySize(), 541 541 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 542 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,542 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 543 543 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 544 544 objectBuffers_laserPipeline); … … 548 548 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 549 549 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_laserPipeline.infoSet); 550 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,550 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 551 551 VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, &objectBuffers_laserPipeline.infoSet); 552 552 laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, … … 571 571 createBufferSet(objects_explosionPipeline.memorySize(), 572 572 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 573 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,573 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 574 574 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 575 575 objectBuffers_explosionPipeline); … … 579 579 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 580 580 VK_SHADER_STAGE_VERTEX_BIT, &uniformBuffers_explosionPipeline.infoSet); 581 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_ STORAGE_BUFFER,581 explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 582 582 VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_explosionPipeline.infoSet); 583 583 … … 1107 1107 } 1108 1108 1109 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex), 1109 VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), 1110 uniforms_modelPipeline.mapped(imageIndex), 1110 1111 uniformBuffers_modelPipeline.memory[imageIndex], 1111 1112 uniforms_modelPipeline.memorySize(), true); 1112 1113 1113 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex), 1114 VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), 1115 objects_modelPipeline.mapped(imageIndex), 1114 1116 objectBuffers_modelPipeline.memory[imageIndex], 1115 1117 objects_modelPipeline.memorySize(), true); … … 1137 1139 } 1138 1140 1139 VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), uniforms_shipPipeline.mapped(imageIndex), 1141 VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), 1142 uniforms_shipPipeline.mapped(imageIndex), 1140 1143 uniformBuffers_shipPipeline.memory[imageIndex], 1141 1144 uniforms_shipPipeline.memorySize(), true); 1142 1145 1143 VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), objects_shipPipeline.mapped(imageIndex), 1146 VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), 1147 objects_shipPipeline.mapped(imageIndex), 1144 1148 objectBuffers_shipPipeline.memory[imageIndex], 1145 1149 objects_shipPipeline.memorySize(), true); … … 1190 1194 } 1191 1195 1192 VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), uniforms_asteroidPipeline.mapped(imageIndex), 1196 VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), 1197 uniforms_asteroidPipeline.mapped(imageIndex), 1193 1198 uniformBuffers_asteroidPipeline.memory[imageIndex], 1194 1199 uniforms_asteroidPipeline.memorySize(), true); 1195 1200 1196 VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), objects_asteroidPipeline.mapped(imageIndex), 1201 VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), 1202 objects_asteroidPipeline.mapped(imageIndex), 1197 1203 objectBuffers_asteroidPipeline.memory[imageIndex], 1198 1204 objects_asteroidPipeline.memorySize(), true); … … 1226 1232 } 1227 1233 1228 VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), uniforms_laserPipeline.mapped(imageIndex), 1234 VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), 1235 uniforms_laserPipeline.mapped(imageIndex), 1229 1236 uniformBuffers_laserPipeline.memory[imageIndex], 1230 1237 uniforms_laserPipeline.memorySize(), true); 1231 1238 1232 VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), objects_laserPipeline.mapped(imageIndex), 1239 VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), 1240 objects_laserPipeline.mapped(imageIndex), 1233 1241 objectBuffers_laserPipeline.memory[imageIndex], 1234 1242 objects_laserPipeline.memorySize(), true); … … 1261 1269 } 1262 1270 1263 VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), uniforms_explosionPipeline.mapped(imageIndex), 1271 VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), 1272 uniforms_explosionPipeline.mapped(imageIndex), 1264 1273 uniformBuffers_explosionPipeline.memory[imageIndex], 1265 1274 uniforms_explosionPipeline.memorySize(), true); 1266 1275 1267 VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), objects_explosionPipeline.mapped(imageIndex), 1276 VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), 1277 objects_explosionPipeline.mapped(imageIndex), 1268 1278 objectBuffers_explosionPipeline.memory[imageIndex], 1269 1279 objects_explosionPipeline.memorySize(), true); … … 1863 1873 // TODO: Find a more elegant, per-screen solution for this 1864 1874 if (currentRenderScreenFn == &VulkanGame::renderGameScreen) { 1865 modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1866 shipPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1867 asteroidPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1868 laserPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1869 explosionPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { });1875 modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1876 shipPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1877 asteroidPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1878 laserPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1879 explosionPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 }); 1870 1880 } 1871 1881 … … 2315 2325 createBufferSet(objects_modelPipeline.memorySize(), 2316 2326 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2317 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2327 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2318 2328 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2319 2329 objectBuffers_modelPipeline); … … 2335 2345 createBufferSet(objects_shipPipeline.memorySize(), 2336 2346 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2337 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2347 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2338 2348 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2339 2349 objectBuffers_shipPipeline); … … 2355 2365 createBufferSet(objects_asteroidPipeline.memorySize(), 2356 2366 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2357 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2367 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2358 2368 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2359 2369 objectBuffers_asteroidPipeline); … … 2375 2385 createBufferSet(objects_laserPipeline.memorySize(), 2376 2386 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2377 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2387 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2378 2388 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2379 2389 objectBuffers_laserPipeline); … … 2395 2405 createBufferSet(objects_explosionPipeline.memorySize(), 2396 2406 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT 2397 | VK_BUFFER_USAGE_ STORAGE_BUFFER_BIT,2407 | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 2398 2408 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, 2399 2409 objectBuffers_explosionPipeline);
Note:
See TracChangeset
for help on using the changeset viewer.