Changeset b8072d3 in opengl-game


Ignore:
Timestamp:
May 1, 2021, 6:10:37 PM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
756162f
Parents:
e8445f0
git-author:
Dmitry Portnoy <dportnoy@…> (04/22/21 02:28:49)
git-committer:
Dmitry Portnoy <dportnoy@…> (05/01/21 18:10:37)
Message:

Add a VkMemoryPropertyFlags parameter to SDLGame::createBufferSet
instead of hard-coding that value

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • compile.sh

    re8445f0 rb8072d3  
    88   VULKAN_SDK_PATH=/Users/dportnoy15/Development/vulkan-sdk-macos-1.1.108.0/macOS
    99fi
     10
     11cd shaders
    1012
    1113shopt -s nullglob
     
    2224   glslangValidator -V $f -o $fOut
    2325done
     26
     27cd ..
  • sdl-game.cpp

    re8445f0 rb8072d3  
    7878
    7979void VulkanGame::run(int width, int height, unsigned char guiFlags) {
     80   cout << "Vulkan Game" << endl;
     81
    8082   cout << "DEBUGGING IS " << (ENABLE_VALIDATION_LAYERS ? "ON" : "OFF") << endl;
    81 
    82    cout << "Vulkan Game" << endl;
    8383
    8484   if (initUI(width, height, guiFlags) == RTWO_ERROR) {
     
    103103   modelPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex));
    104104
    105    createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
    106       uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, uniformBufferInfoList_modelPipeline);
     105   createBufferSet(uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, sizeof(UBO_VP_mats),
     106      VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     107      uniformBufferInfoList_modelPipeline);
    107108
    108109   modelPipeline.addDescriptorInfo(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
     
    113114
    114115   SceneObject<ModelVertex, SSBO_ModelObject>* texturedSquare = nullptr;
     116
     117   // TODO: Ideally, avoid having to make the squares as modified upon creation
    115118
    116119   texturedSquare = &addObject(modelObjects, modelPipeline,
     
    10801083}
    10811084
    1082 void VulkanGame::createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
    1083                                  vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory,
     1085void VulkanGame::createBufferSet(vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory,
     1086                                 VkDeviceSize bufferSize, VkBufferUsageFlags flags, VkMemoryPropertyFlags properties,
    10841087                                 vector<VkDescriptorBufferInfo>& bufferInfoList) {
    10851088   buffers.resize(swapChainImageCount);
     
    10881091
    10891092   for (size_t i = 0; i < swapChainImageCount; i++) {
    1090       VulkanUtils::createBuffer(device, physicalDevice, bufferSize, flags,
    1091          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
    1092          buffers[i], buffersMemory[i]);
     1093      VulkanUtils::createBuffer(device, physicalDevice, bufferSize, flags, properties, buffers[i], buffersMemory[i]);
    10931094
    10941095      bufferInfoList[i].buffer = buffers[i];
     
    12291230   // instead of recreated every time
    12301231
    1231    createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
    1232       uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, uniformBufferInfoList_modelPipeline);
     1232   createBufferSet(uniformBuffers_modelPipeline, uniformBuffersMemory_modelPipeline, sizeof(UBO_VP_mats),
     1233      VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
     1234      uniformBufferInfoList_modelPipeline);
    12331235
    12341236   modelPipeline.updateRenderPass(renderPass);
  • sdl-game.hpp

    re8445f0 rb8072d3  
    276276      void cleanupImGuiOverlay();
    277277
    278       void createBufferSet(VkDeviceSize bufferSize, VkBufferUsageFlags flags,
    279          vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory,
    280          vector<VkDescriptorBufferInfo>& bufferInfoList);
     278      void createBufferSet(vector<VkBuffer>& buffers, vector<VkDeviceMemory>& buffersMemory, VkDeviceSize bufferSize,
     279                           VkBufferUsageFlags flags, VkMemoryPropertyFlags properties,
     280                           vector<VkDescriptorBufferInfo>& bufferInfoList);
    281281
    282282      // TODO: Since addObject() returns a reference to the new object now,
    283283      // stop using objects.back() to access the object that was just created
    284284      template<class VertexType, class SSBOType>
    285       SceneObject<VertexType, SSBOType>& addObject(
    286          vector<SceneObject<VertexType, SSBOType>>& objects,
    287          GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline,
    288          const vector<VertexType>& vertices, vector<uint16_t> indices, SSBOType ssbo,
    289          bool pipelinesCreated);
     285      SceneObject<VertexType, SSBOType>& addObject(vector<SceneObject<VertexType, SSBOType>>& objects,
     286                                                   GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline,
     287                                                   const vector<VertexType>& vertices, vector<uint16_t> indices,
     288                                                   SSBOType ssbo, bool pipelinesCreated);
    290289
    291290      template<class VertexType>
     
    299298
    300299      template<class VertexType, class SSBOType>
    301       void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects,
    302          GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, size_t index);
     300      void updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, GraphicsPipeline_Vulkan<VertexType,
     301                       SSBOType>& pipeline, size_t index);
    303302
    304303      void renderFrame(ImDrawData* draw_data);
     
    458457// TODO: Just pass in the single object instead of a list of all of them
    459458template<class VertexType, class SSBOType>
    460 void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects,
    461    GraphicsPipeline_Vulkan<VertexType, SSBOType>& pipeline, size_t index) {
     459void VulkanGame::updateObject(vector<SceneObject<VertexType, SSBOType>>& objects, GraphicsPipeline_Vulkan<VertexType,
     460                             SSBOType>& pipeline, size_t index) {
    462461   SceneObject<VertexType, SSBOType>& obj = objects[index];
    463462
Note: See TracChangeset for help on using the changeset viewer.