Changeset 2d87297 in opengl-game for vulkan-game.hpp


Ignore:
Timestamp:
Feb 16, 2020, 8:22:40 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
d25381b
Parents:
5a1ace0
Message:

In VulkanGame, add an ssbo field to SceneObject to hold per-object ssbo info, and add a new SSBOType template parameter to SceneObject and GraphicsPipeline_Vulkan

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.hpp

    r5a1ace0 r2d87297  
    5050// TODO: Change the index type to uint32_t and check the Vulkan Tutorial loading model section as a reference
    5151// TODO: Create a typedef for index type so I can easily change uin16_t to something else later
    52 template<class VertexType>
     52template<class VertexType, class SSBOType>
    5353struct SceneObject {
    5454   vector<VertexType> vertices;
    5555   vector<uint16_t> indices;
     56   SSBOType ssbo;
    5657
    5758   mat4 model_base;
     
    6465};
    6566
    66 struct SBO_SceneObject {
     67struct SSBO_ModelObject {
    6768   alignas(16) mat4 model;
    6869};
    6970
    70 struct SBO_Asteroid {
     71struct SSBO_Asteroid {
    7172   alignas(16) mat4 model;
    7273   alignas(4) float hp;
     
    146147      // TODO: Create a struct that holds the buffers, memory, and info objects (Probably in VulkanUtils)
    147148
    148       GraphicsPipeline_Vulkan<OverlayVertex> overlayPipeline;
    149 
    150       vector<SceneObject<OverlayVertex>> overlayObjects;
     149      GraphicsPipeline_Vulkan<OverlayVertex, void*> overlayPipeline;
     150
     151      vector<SceneObject<OverlayVertex, void*>> overlayObjects;
    151152
    152153      // TODO: Rename all the variables related to modelPipeline to use the same pipelie name
    153154
    154       GraphicsPipeline_Vulkan<ModelVertex> modelPipeline;
    155 
    156       vector<SceneObject<ModelVertex>> modelObjects;
     155      GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline;
     156
     157      vector<SceneObject<ModelVertex, SSBO_ModelObject>> modelObjects;
    157158
    158159      vector<VkBuffer> uniformBuffers_scenePipeline;
     
    165166
    166167      UBO_VP_mats object_VP_mats;
    167       SBO_SceneObject so_Object;
    168 
    169       GraphicsPipeline_Vulkan<ShipVertex> shipPipeline;
    170 
    171       vector<SceneObject<ShipVertex>> shipObjects;
     168      SSBO_ModelObject so_Object;
     169
     170      GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject> shipPipeline;
     171
     172      vector<SceneObject<ShipVertex, SSBO_ModelObject>> shipObjects;
    172173
    173174      vector<VkBuffer> uniformBuffers_shipPipeline;
     
    180181
    181182      UBO_VP_mats ship_VP_mats;
    182       SBO_SceneObject so_Ship;
    183 
    184       GraphicsPipeline_Vulkan<AsteroidVertex> asteroidPipeline;
    185 
    186       vector<SceneObject<AsteroidVertex>> asteroidObjects;
     183      SSBO_ModelObject so_Ship;
     184
     185      GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid> asteroidPipeline;
     186
     187      vector<SceneObject<AsteroidVertex, SSBO_Asteroid>> asteroidObjects;
    187188
    188189      vector<VkBuffer> uniformBuffers_asteroidPipeline;
     
    195196
    196197      UBO_VP_mats asteroid_VP_mats;
    197       SBO_Asteroid so_Asteroid;
     198      SSBO_Asteroid so_Asteroid;
    198199
    199200      Uint64 curTime, prevTime;
     
    231232      void createSyncObjects();
    232233
    233       template<class VertexType>
    234       void addObject(vector<SceneObject<VertexType>>& objects, GraphicsPipeline_Vulkan<VertexType>& pipeline,
    235          const vector<VertexType>& vertices, vector<uint16_t> indices);
     234      template<class VertexType, class SSBOType>
     235      void addObject(vector<SceneObject<VertexType, SSBOType>>& objects,
     236         GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline,
     237         const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo);
    236238
    237239      template<class VertexType>
     
    244246      vector<VertexType> centerObject(vector<VertexType> vertices);
    245247
    246       template<class VertexType>
    247       void transformObject(SceneObject<VertexType>& obj, mat4 mat);
     248      template<class VertexType, class SSBOType>
     249      void transformObject(SceneObject<VertexType, SSBOType>& obj, mat4 mat);
    248250
    249251      void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
     
    261263};
    262264
    263 template<class VertexType>
    264 void VulkanGame::addObject(vector<SceneObject<VertexType>>& objects, GraphicsPipeline_Vulkan<VertexType>& pipeline,
    265       const vector<VertexType>& vertices, vector<uint16_t> indices) {
     265template<class VertexType, class SSBOType>
     266void VulkanGame::addObject(vector<SceneObject<VertexType, SSBOType>>& objects,
     267      GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline,
     268      const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo) {
    266269   size_t numVertices = pipeline.getNumVertices();
    267270
     
    270273   }
    271274
    272    objects.push_back({ vertices, indices, mat4(1.0f), mat4(1.0f) });
     275   objects.push_back({ vertices, indices, ssbo, mat4(1.0f), mat4(1.0f) });
    273276
    274277   pipeline.addVertices(vertices, indices, commandPool, graphicsQueue);
     
    341344}
    342345
    343 template<class VertexType>
    344 void VulkanGame::transformObject(SceneObject<VertexType>& obj, mat4 mat) {
     346template<class VertexType, class SSBOType>
     347void VulkanGame::transformObject(SceneObject<VertexType, SSBOType>& obj, mat4 mat) {
    345348   obj.model_transform = mat * obj.model_transform;
    346349}
Note: See TracChangeset for help on using the changeset viewer.