Changeset 5a1ace0 in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Feb 16, 2020, 8:18:50 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
2d87297
Parents:
4ece3bf
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (02/14/20 20:41:35)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (02/16/20 20:18:50)
Message:

In VulkanGame, add objIndex to scene objects, use it in the scene shader to index into the ssbo, and change the code that copies data to the ssbo to do so for each scene object, not just the first one

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r4ece3bf r5a1ace0  
    197197   modelPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::color));
    198198   modelPipeline.addAttribute(VK_FORMAT_R32G32_SFLOAT, offset_of(&ModelVertex::texCoord));
     199   modelPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex));
    199200
    200201   createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
     
    213214
    214215   addObject(modelObjects, modelPipeline,
    215       {
     216      addObjectIndex<ModelVertex>(modelObjects.size(), {
    216217         {{-0.5f, -0.5f, -2.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
    217218         {{ 0.5f, -0.5f, -2.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
    218219         {{ 0.5f,  0.5f, -2.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
    219220         {{-0.5f,  0.5f, -2.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
    220       }, {
     221      }), {
    221222         0, 1, 2, 2, 3, 0
    222223      });
    223224
    224225   addObject(modelObjects, modelPipeline,
    225       {
     226      addObjectIndex<ModelVertex>(modelObjects.size(), {
    226227         {{-0.5f, -0.5f, -1.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
    227228         {{ 0.5f, -0.5f, -1.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
    228229         {{ 0.5f,  0.5f, -1.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
    229230         {{-0.5f,  0.5f, -1.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
    230       }, {
     231      }), {
    231232         0, 1, 2, 2, 3, 0
    232233      });
     
    699700
    700701                  addObject(modelObjects, modelPipeline,
    701                      {
     702                     addObjectIndex<ModelVertex>(modelObjects.size(), {
    702703                        {{-0.5f, -0.5f,  zOffset}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}},
    703704                        {{ 0.5f, -0.5f,  zOffset}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
    704705                        {{ 0.5f,  0.5f,  zOffset}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
    705706                        {{-0.5f,  0.5f,  zOffset}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
    706                      }, {
     707                     }), {
    707708                        0, 1, 2, 2, 3, 0
    708709                     });
     
    774775   so_Asteroid.model = asteroidObjects[0].model_transform * asteroidObjects[0].model_base;
    775776
    776    VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_scenePipeline[currentImage], object_VP_mats);
    777 
    778    VulkanUtils::copyDataToMemory(device, storageBuffersMemory_scenePipeline[currentImage], so_Object);
    779 
    780    VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_shipPipeline[currentImage], ship_VP_mats);
    781 
    782    VulkanUtils::copyDataToMemory(device, storageBuffersMemory_shipPipeline[currentImage], so_Ship);
    783 
    784    VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_asteroidPipeline[currentImage], asteroid_VP_mats);
    785 
    786    VulkanUtils::copyDataToMemory(device, storageBuffersMemory_asteroidPipeline[currentImage], so_Asteroid);
     777   VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_scenePipeline[currentImage], 0, object_VP_mats);
     778
     779   for (size_t i = 0; i < modelObjects.size(); i++) {
     780      VulkanUtils::copyDataToMemory(device, storageBuffersMemory_scenePipeline[currentImage],
     781         i, so_Object);
     782   }
     783
     784   VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_shipPipeline[currentImage], 0, ship_VP_mats);
     785
     786   VulkanUtils::copyDataToMemory(device, storageBuffersMemory_shipPipeline[currentImage], 0, so_Ship);
     787
     788   VulkanUtils::copyDataToMemory(device, uniformBuffersMemory_asteroidPipeline[currentImage], 0, asteroid_VP_mats);
     789
     790   VulkanUtils::copyDataToMemory(device, storageBuffersMemory_asteroidPipeline[currentImage], 0, so_Asteroid);
    787791}
    788792
Note: See TracChangeset for help on using the changeset viewer.