Changeset 90880fb in opengl-game for sdl-game.cpp


Ignore:
Timestamp:
Jun 17, 2021, 11:59:14 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
2f4ff8c
Parents:
5ea0a37
git-author:
Dmitry Portnoy <dportnoy@…> (06/13/21 23:57:17)
git-committer:
Dmitry Portnoy <dportnoy@…> (06/17/21 23:59:14)
Message:

Start using the VulkanBuffer class for the non-per-object uniforms (this means the view and projection matrices for all pipelines, as well as the current time for the explosion pipeline)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    r5ea0a37 r90880fb  
    7070                     , gui(nullptr)
    7171                     , window(nullptr)
     72                     , vp_mats_modelPipeline()
    7273                     , objects_modelPipeline()
    7374                     , score(0)
     
    9192   VkPhysicalDeviceProperties deviceProperties;
    9293   vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
     94
     95   vp_mats_modelPipeline = VulkanBuffer<UBO_VP_mats>(1, deviceProperties.limits.maxUniformBufferRange,
     96                                                     deviceProperties.limits.minUniformBufferOffsetAlignment);
    9397
    9498   objects_modelPipeline = VulkanBuffer<SSBO_ModelObject>(10, deviceProperties.limits.maxStorageBufferRange,
     
    110114   modelPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex));
    111115
    112    createBufferSet(sizeof(UBO_VP_mats),
     116   createBufferSet(vp_mats_modelPipeline.memorySize(),
    113117                   VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
    114118                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    115119                   uniformBuffers_modelPipeline);
    116120
    117    createBufferSet(objects_modelPipeline.capacity * sizeof(SSBO_ModelObject),
     121   createBufferSet(objects_modelPipeline.memorySize(),
    118122                   VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
    119123                   | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
     
    289293   projMat = perspective(radians(FOV_ANGLE), (float)swapChainExtent.width / (float)swapChainExtent.height, NEAR_CLIP, FAR_CLIP);
    290294   projMat[1][1] *= -1; // flip the y-axis so that +y is up
    291 
    292    object_VP_mats.view = viewMat;
    293    object_VP_mats.proj = projMat;
    294295}
    295296
     
    444445
    445446void VulkanGame::updateScene() {
    446    // TODO: Probably move the resizing to the VulkanBuffer class
     447   vp_mats_modelPipeline.data()->view = viewMat;
     448   vp_mats_modelPipeline.data()->proj = projMat;
     449
     450   // TODO: Probably move the resizing to the VulkanBuffer class's add() method
     451   // Remember that we want to avoid resizing the actuall ssbo or ubo more than once per frame
     452   // TODO: Figure out a way to make updateDescriptorInfo easier to use, maybe store the binding index in the buffer set
     453
    447454   if (objects_modelPipeline.resized) {
    448455      resizeBufferSet(storageBuffers_modelPipeline, objects_modelPipeline.memorySize(), resourceCommandPool,
     
    467474   }
    468475
     476   VulkanUtils::copyDataToMemory(device, vp_mats_modelPipeline.data(), uniformBuffers_modelPipeline.memory[imageIndex],
     477                                 0, vp_mats_modelPipeline.memorySize(), false);
     478
    469479   VulkanUtils::copyDataToMemory(device, objects_modelPipeline.data(), storageBuffers_modelPipeline.memory[imageIndex],
    470480                                 0, objects_modelPipeline.memorySize(), false);
    471 
    472    VulkanUtils::copyDataToMemory(device, &object_VP_mats, uniformBuffers_modelPipeline.memory[imageIndex], 0,
    473                                  sizeof(object_VP_mats), false);
    474481}
    475482
     
    12751282   createSyncObjects();
    12761283
    1277    createBufferSet(sizeof(UBO_VP_mats),
     1284   createBufferSet(vp_mats_modelPipeline.memorySize(),
    12781285                   VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
    12791286                   VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
Note: See TracChangeset for help on using the changeset viewer.