Changeset 6bac215 in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Jun 9, 2021, 12:38:14 AM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
bb76950
Parents:
8dcbf62
git-author:
Dmitry Portnoy <dportnoy@…> (06/09/21 00:38:09)
git-committer:
Dmitry Portnoy <dportnoy@…> (06/09/21 00:38:14)
Message:

Rewrite a large portion of the VulkanBuffer class, start using it more
to resize buffers, and simplify resizeBufferSet() since the additions to
VulkanBuffer can now do some of what that function used to do

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r8dcbf62 r6bac215  
    616616
    617617   createBufferSet(objects_modelPipeline.capacity * sizeof(SSBO_ModelObject),
    618       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
    619       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    620       storageBuffers_modelPipeline);
     618                   VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
     619                   | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
     620                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     621                   storageBuffers_modelPipeline);
    621622
    622623   shipPipeline = GraphicsPipeline_Vulkan<ModelVertex>(
     
    625626
    626627   createBufferSet(objects_shipPipeline.capacity * sizeof(SSBO_ModelObject),
    627       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
    628       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    629       storageBuffers_shipPipeline);
     628                   VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
     629                   | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
     630                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     631                   storageBuffers_shipPipeline);
    630632
    631633   asteroidPipeline = GraphicsPipeline_Vulkan<ModelVertex>(
     
    634636
    635637   createBufferSet(objects_asteroidPipeline.capacity * sizeof(SSBO_Asteroid),
    636       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
    637       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    638       storageBuffers_asteroidPipeline);
     638                   VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
     639                   | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
     640                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     641                   storageBuffers_asteroidPipeline);
    639642
    640643   laserPipeline = GraphicsPipeline_Vulkan<LaserVertex>(
     
    643646
    644647   createBufferSet(objects_laserPipeline.capacity * sizeof(SSBO_Laser),
    645       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
    646       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    647       storageBuffers_laserPipeline);
     648                   VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
     649                   | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
     650                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     651                   storageBuffers_laserPipeline);
    648652
    649653   explosionPipeline = GraphicsPipeline_Vulkan<ExplosionVertex>(
     
    653657
    654658   createBufferSet(objects_explosionPipeline.capacity * sizeof(SSBO_Explosion),
    655       VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
    656       VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    657       storageBuffers_explosionPipeline);
     659                   VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
     660                   | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
     661                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     662                   storageBuffers_explosionPipeline);
    658663}
    659664
     
    10851090
    10861091   // TODO: Probably move the resizing to the VulkanBuffer class
    1087    if (objects_modelPipeline.numObjects > objects_modelPipeline.capacity) {
     1092   if (objects_modelPipeline.resized) {
    10881093      resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline, modelPipeline, resourceCommandPool,
    10891094                      graphicsQueue);
     1095
     1096      objects_modelPipeline.resize();
    10901097   }
    10911098
     
    10981105
    10991106   // TODO: Probably move the resizing to the VulkanBuffer class
    1100    if (objects_shipPipeline.numObjects > objects_shipPipeline.capacity) {
     1107   if (objects_shipPipeline.resized) {
    11011108      resizeBufferSet(storageBuffers_shipPipeline, objects_shipPipeline, shipPipeline, resourceCommandPool,
    11021109                      graphicsQueue);
     1110
     1111      objects_shipPipeline.resize();
    11031112   }
    11041113
     
    11111120
    11121121   // TODO: Probably move the resizing to the VulkanBuffer class
    1113    if (objects_asteroidPipeline.numObjects > objects_asteroidPipeline.capacity) {
     1122   if (objects_asteroidPipeline.resized) {
    11141123      resizeBufferSet(storageBuffers_asteroidPipeline, objects_asteroidPipeline, asteroidPipeline,
    11151124                      resourceCommandPool, graphicsQueue);
     1125
     1126      objects_asteroidPipeline.resize();
    11161127   }
    11171128
     
    11241135
    11251136   // TODO: Probably move the resizing to the VulkanBuffer class
    1126    if (objects_laserPipeline.numObjects > objects_laserPipeline.capacity) {
     1137   if (objects_laserPipeline.resized) {
    11271138      resizeBufferSet(storageBuffers_laserPipeline, objects_laserPipeline, laserPipeline, resourceCommandPool,
    11281139                      graphicsQueue);
     1140
     1141      objects_laserPipeline.resize();
    11291142   }
    11301143
     
    11371150
    11381151   // TODO: Probably move the resizing to the VulkanBuffer class
    1139    if (objects_explosionPipeline.numObjects > objects_explosionPipeline.capacity) {
     1152   if (objects_explosionPipeline.resized) {
    11401153      resizeBufferSet(storageBuffers_explosionPipeline, objects_explosionPipeline, explosionPipeline,
    11411154                     resourceCommandPool, graphicsQueue);
     1155
     1156      objects_explosionPipeline.resize();
    11421157   }
    11431158
Note: See TracChangeset for help on using the changeset viewer.