Changeset 67527a5 in opengl-game


Ignore:
Timestamp:
Jun 21, 2021, 4:12:08 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
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)
Message:

Switch all per-object buffers to be dynamic uniform buffers instead of shader storage buffers

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    rb01b50c r67527a5  
    9696                                                      deviceProperties.limits.minUniformBufferOffsetAlignment);
    9797
    98    objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange,
    99                                                           deviceProperties.limits.minStorageBufferOffsetAlignment);
     98   objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange,
     99                                                          deviceProperties.limits.minUniformBufferOffsetAlignment);
    100100
    101101   initImGuiOverlay();
     
    123123   createBufferSet(objects_modelPipeline.memorySize(),
    124124                   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,
    126126                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    127127                   objectBuffers_modelPipeline);
     
    131131   modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
    132132      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,
    134134      VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_modelPipeline.infoSet);
    135135   modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
     
    482482   }
    483483
    484    VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex),
     484   VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(),
     485                                       uniforms_modelPipeline.mapped(imageIndex),
    485486                                       uniformBuffers_modelPipeline.memory[imageIndex],
    486487                                       uniforms_modelPipeline.memorySize(), true);
    487488
    488    VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex),
     489   VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(),
     490                                       objects_modelPipeline.mapped(imageIndex),
    489491                                       objectBuffers_modelPipeline.memory[imageIndex],
    490492                                       objects_modelPipeline.memorySize(), true);
     
    12131215   // TODO: Find a more elegant, per-screen solution for this
    12141216   if (currentRenderScreenFn == &VulkanGame::renderGameScreen) {
    1215       modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, {});
     1217      modelPipeline.createRenderCommands(commandBuffers[imageIndex], imageIndex, { 0 });
    12161218
    12171219
     
    13011303   createBufferSet(objects_modelPipeline.memorySize(),
    13021304                   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,
    13041306                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    13051307                   objectBuffers_modelPipeline);
  • shaders/asteroid.vert

    rb01b50c r67527a5  
    88};
    99
    10 layout (binding = 0) uniform UniformBufferObject {
     10layout (binding = 0) uniform camera_block {
    1111   mat4 view;
    1212   mat4 proj;
     13} camera;
     14
     15layout(binding = 1) uniform ubo_block {
     16   Object objects[1024];
    1317} ubo;
    14 
    15 layout(binding = 1) readonly buffer StorageBufferObject {
    16    Object objects[];
    17 } sbo;
    1818
    1919layout(location = 0) in vec3 vertex_position;
     
    3535
    3636void 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)));
    3939
    40    float hp_percent = sbo.objects[obj_index].hp / 10.0;
     40   float hp_percent = ubo.objects[obj_index].hp / 10.0;
    4141   vec3 damage_color = vec3(1.0, 0.0, 0.0);
    4242   color = (vertex_color * hp_percent) + (damage_color * (1.0 - hp_percent));
     
    4444   fragTexCoord = inTexCoord;
    4545
    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));
    4848
    49    if (sbo.objects[obj_index].deleted) {
     49   if (ubo.objects[obj_index].deleted) {
    5050      gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
    5151   } else {
    52       gl_Position = ubo.proj * vec4(position_eye, 1.0);
     52      gl_Position = camera.proj * vec4(position_eye, 1.0);
    5353   }
    5454}
  • shaders/explosion.vert

    rb01b50c r67527a5  
    99};
    1010
    11 layout (binding = 0) uniform UniformBufferObject {
     11layout (binding = 0) uniform camera_block {
    1212   mat4 view;
    1313   mat4 proj;
    1414   float cur_time;
     15} camera;
     16
     17layout(binding = 1) uniform ubo_block {
     18   Object objects[1024];
    1519} ubo;
    16 
    17 layout(binding = 1) readonly buffer StorageBufferObject {
    18    Object objects[];
    19 } sbo;
    2020
    2121layout(location = 0) in vec3 particle_start_velocity;
     
    2626
    2727void 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;
    3232
    33    float t = ubo.cur_time - explosion_start_time - particle_start_time;
     33   float t = camera.cur_time - explosion_start_time - particle_start_time;
    3434
    3535   if (t < 0.0) {
     
    5656      p += normalize(particle_start_velocity) * mod(t, explosion_duration) / explosion_duration * 0.3;
    5757
    58       gl_Position = ubo.proj * ubo.view * model * vec4(p, 1.0);
     58      gl_Position = camera.proj * camera.view * model * vec4(p, 1.0);
    5959   }
    6060   gl_PointSize = 10.0; // size in pixels
  • shaders/laser.frag

    rb01b50c r67527a5  
    88};
    99
    10 layout(binding = 1) readonly buffer StorageBufferObject {
    11    Object objects[];
    12 } sbo;
     10layout(binding = 1) uniform ubo_block {
     11   Object objects[1024];
     12} ubo;
    1313
    1414layout(binding = 2) uniform sampler2D laser_texture;
     
    2121void main() {
    2222   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;
    2424
    2525   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  
    88};
    99
    10 layout (binding = 0) uniform UniformBufferObject {
     10layout (binding = 0) uniform camera_block {
    1111   mat4 view;
    1212   mat4 proj;
     13} camera;
     14
     15layout(binding = 1) uniform ubo_block {
     16   Object objects[1024];
    1317} ubo;
    14 
    15 layout(binding = 1) readonly buffer StorageBufferObject {
    16    Object objects[];
    17 } sbo;
    1818
    1919layout(location = 0) in vec3 vertex_position;
     
    2525
    2626void 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));
    2828
    2929   texcoords_fs = texcoords_vs;
    3030   obj_index_fs = obj_index_vs;
    3131
    32    if (sbo.objects[obj_index_vs].deleted) {
     32   if (ubo.objects[obj_index_vs].deleted) {
    3333      gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
    3434   } else {
    35       gl_Position = ubo.proj * vec4(position_eye, 1.0);
     35      gl_Position = camera.proj * vec4(position_eye, 1.0);
    3636   }
    3737}
  • shaders/model.vert

    rb01b50c r67527a5  
    66};
    77
    8 layout (binding = 0) uniform UniformBufferObject {
     8layout (binding = 0) uniform camera_block {
    99   mat4 view;
    1010   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
     14layout (binding = 1) uniform ubo_block {
     15        Object objects[1024];
    1116} 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;
    2017
    2118layout(location = 0) in vec3 inPosition;
     
    3128void main() {
    3229   // 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)));
    3431
    3532   fragColor = inColor;
    3633   fragTexCoord = inTexCoord;
    3734
    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);
    3936}
  • shaders/ship.vert

    rb01b50c r67527a5  
    66};
    77
    8 layout (binding = 0) uniform UniformBufferObject {
     8layout (binding = 0) uniform camera_block {
    99   mat4 view;
    1010   mat4 proj;
     11} camera;
     12
     13layout(binding = 1) uniform ubo_block {
     14   Object objects[1024];
    1115} ubo;
    12 
    13 layout(binding = 1) readonly buffer StorageBufferObject {
    14    Object objects[];
    15 } sbo;
    1616
    1717layout(location = 0) in vec3 vertex_position;
     
    3535// Check Anton's book to see how to fix this
    3636void 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));
    3838
    3939   // 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)));
    4141
    4242   color = vertex_color;
     
    4444   fragTexCoord = inTexCoord;
    4545
    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));
    4848
    49    gl_Position = ubo.proj * vec4(position_eye, 1.0);
     49   gl_Position = camera.proj * vec4(position_eye, 1.0);
    5050}
  • vulkan-game.cpp

    rb01b50c r67527a5  
    113113                                                      deviceProperties.limits.minUniformBufferOffsetAlignment);
    114114
    115    objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange,
    116                                                           deviceProperties.limits.minStorageBufferOffsetAlignment);
     115   objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange,
     116                                                          deviceProperties.limits.minUniformBufferOffsetAlignment);
    117117
    118118   uniforms_shipPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
    119119                                                     deviceProperties.limits.minUniformBufferOffsetAlignment);
    120120
    121    objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange,
    122                                                          deviceProperties.limits.minStorageBufferOffsetAlignment);
     121   objects_shipPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxUniformBufferRange,
     122                                                         deviceProperties.limits.minUniformBufferOffsetAlignment);
    123123
    124124   uniforms_asteroidPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
    125125                                                         deviceProperties.limits.minUniformBufferOffsetAlignment);
    126126
    127    objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxStorageBufferRange,
    128                                                           deviceProperties.limits.minStorageBufferOffsetAlignment);
     127   objects_asteroidPipeline = VulkanBuffer<SSBO_Asteroid>(10, deviceProperties.limits.maxUniformBufferRange,
     128                                                          deviceProperties.limits.minUniformBufferOffsetAlignment);
    129129
    130130   uniforms_laserPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
    131131                                                      deviceProperties.limits.minUniformBufferOffsetAlignment);
    132132
    133    objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxStorageBufferRange,
    134                                                     deviceProperties.limits.minStorageBufferOffsetAlignment);
     133   objects_laserPipeline = VulkanBuffer<SSBO_Laser>(2, deviceProperties.limits.maxUniformBufferRange,
     134                                                    deviceProperties.limits.minUniformBufferOffsetAlignment);
    135135
    136136   uniforms_explosionPipeline = VulkanBuffer<UBO_Explosion>(1, deviceProperties.limits.maxUniformBufferRange,
    137137                                                            deviceProperties.limits.minUniformBufferOffsetAlignment);
    138138
    139    objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.maxStorageBufferRange,
    140                                                             deviceProperties.limits.minStorageBufferOffsetAlignment);
     139   objects_explosionPipeline = VulkanBuffer<SSBO_Explosion>(2, deviceProperties.limits.maxUniformBufferRange,
     140                                                            deviceProperties.limits.minUniformBufferOffsetAlignment);
    141141
    142142   initImGuiOverlay();
     
    166166   createBufferSet(objects_modelPipeline.memorySize(),
    167167                   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,
    169169                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    170170                   objectBuffers_modelPipeline);
     
    174174   modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
    175175      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,
    177177      VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_modelPipeline.infoSet);
    178178   modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
     
    240240   createBufferSet(objects_shipPipeline.memorySize(),
    241241                   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,
    243243                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    244244                   objectBuffers_shipPipeline);
     
    248248   shipPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
    249249      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,
    251251      VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_shipPipeline.infoSet);
    252252
     
    511511   createBufferSet(objects_asteroidPipeline.memorySize(),
    512512                   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,
    514514                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    515515                   objectBuffers_asteroidPipeline);
     
    519519   asteroidPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
    520520      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,
    522522      VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_asteroidPipeline.infoSet);
    523523
     
    540540   createBufferSet(objects_laserPipeline.memorySize(),
    541541                   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,
    543543                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    544544                   objectBuffers_laserPipeline);
     
    548548   laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
    549549      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,
    551551      VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, &objectBuffers_laserPipeline.infoSet);
    552552   laserPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
     
    571571   createBufferSet(objects_explosionPipeline.memorySize(),
    572572                   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,
    574574                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    575575                   objectBuffers_explosionPipeline);
     
    579579   explosionPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
    580580      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,
    582582      VK_SHADER_STAGE_VERTEX_BIT, &objectBuffers_explosionPipeline.infoSet);
    583583
     
    11071107   }
    11081108
    1109    VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(), uniforms_modelPipeline.mapped(imageIndex),
     1109   VulkanUtils::copyDataToMappedMemory(device, uniforms_modelPipeline.data(),
     1110                                       uniforms_modelPipeline.mapped(imageIndex),
    11101111                                       uniformBuffers_modelPipeline.memory[imageIndex],
    11111112                                       uniforms_modelPipeline.memorySize(), true);
    11121113
    1113    VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(), objects_modelPipeline.mapped(imageIndex),
     1114   VulkanUtils::copyDataToMappedMemory(device, objects_modelPipeline.data(),
     1115                                       objects_modelPipeline.mapped(imageIndex),
    11141116                                       objectBuffers_modelPipeline.memory[imageIndex],
    11151117                                       objects_modelPipeline.memorySize(), true);
     
    11371139   }
    11381140
    1139    VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(), uniforms_shipPipeline.mapped(imageIndex),
     1141   VulkanUtils::copyDataToMappedMemory(device, uniforms_shipPipeline.data(),
     1142                                       uniforms_shipPipeline.mapped(imageIndex),
    11401143                                       uniformBuffers_shipPipeline.memory[imageIndex],
    11411144                                       uniforms_shipPipeline.memorySize(), true);
    11421145
    1143    VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(), objects_shipPipeline.mapped(imageIndex),
     1146   VulkanUtils::copyDataToMappedMemory(device, objects_shipPipeline.data(),
     1147                                       objects_shipPipeline.mapped(imageIndex),
    11441148                                       objectBuffers_shipPipeline.memory[imageIndex],
    11451149                                       objects_shipPipeline.memorySize(), true);
     
    11901194   }
    11911195
    1192    VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(), uniforms_asteroidPipeline.mapped(imageIndex),
     1196   VulkanUtils::copyDataToMappedMemory(device, uniforms_asteroidPipeline.data(),
     1197                                       uniforms_asteroidPipeline.mapped(imageIndex),
    11931198                                       uniformBuffers_asteroidPipeline.memory[imageIndex],
    11941199                                       uniforms_asteroidPipeline.memorySize(), true);
    11951200
    1196    VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(), objects_asteroidPipeline.mapped(imageIndex),
     1201   VulkanUtils::copyDataToMappedMemory(device, objects_asteroidPipeline.data(),
     1202                                       objects_asteroidPipeline.mapped(imageIndex),
    11971203                                       objectBuffers_asteroidPipeline.memory[imageIndex],
    11981204                                       objects_asteroidPipeline.memorySize(), true);
     
    12261232   }
    12271233
    1228    VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(), uniforms_laserPipeline.mapped(imageIndex),
     1234   VulkanUtils::copyDataToMappedMemory(device, uniforms_laserPipeline.data(),
     1235                                       uniforms_laserPipeline.mapped(imageIndex),
    12291236                                       uniformBuffers_laserPipeline.memory[imageIndex],
    12301237                                       uniforms_laserPipeline.memorySize(), true);
    12311238
    1232    VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(), objects_laserPipeline.mapped(imageIndex),
     1239   VulkanUtils::copyDataToMappedMemory(device, objects_laserPipeline.data(),
     1240                                       objects_laserPipeline.mapped(imageIndex),
    12331241                                       objectBuffers_laserPipeline.memory[imageIndex],
    12341242                                       objects_laserPipeline.memorySize(), true);
     
    12611269   }
    12621270
    1263    VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(), uniforms_explosionPipeline.mapped(imageIndex),
     1271   VulkanUtils::copyDataToMappedMemory(device, uniforms_explosionPipeline.data(),
     1272                                       uniforms_explosionPipeline.mapped(imageIndex),
    12641273                                       uniformBuffers_explosionPipeline.memory[imageIndex],
    12651274                                       uniforms_explosionPipeline.memorySize(), true);
    12661275
    1267    VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(), objects_explosionPipeline.mapped(imageIndex),
     1276   VulkanUtils::copyDataToMappedMemory(device, objects_explosionPipeline.data(),
     1277                                       objects_explosionPipeline.mapped(imageIndex),
    12681278                                       objectBuffers_explosionPipeline.memory[imageIndex],
    12691279                                       objects_explosionPipeline.memorySize(), true);
     
    18631873   // TODO: Find a more elegant, per-screen solution for this
    18641874   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 });
    18701880   }
    18711881
     
    23152325   createBufferSet(objects_modelPipeline.memorySize(),
    23162326                   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,
    23182328                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    23192329                   objectBuffers_modelPipeline);
     
    23352345   createBufferSet(objects_shipPipeline.memorySize(),
    23362346                   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,
    23382348                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    23392349                   objectBuffers_shipPipeline);
     
    23552365   createBufferSet(objects_asteroidPipeline.memorySize(),
    23562366                   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,
    23582368                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    23592369                   objectBuffers_asteroidPipeline);
     
    23752385   createBufferSet(objects_laserPipeline.memorySize(),
    23762386                   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,
    23782388                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    23792389                   objectBuffers_laserPipeline);
     
    23952405   createBufferSet(objects_explosionPipeline.memorySize(),
    23962406                   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,
    23982408                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
    23992409                   objectBuffers_explosionPipeline);
Note: See TracChangeset for help on using the changeset viewer.