Changeset 90880fb in opengl-game for vulkan-buffer.hpp


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
  • vulkan-buffer.hpp

    r5ea0a37 r90880fb  
    3737      T& get(uint32_t index);
    3838      void add(T obj);
     39
     40      void* mapped(size_t idx);
     41
     42      void map(vector<VkDeviceMemory>& deviceMemory, VkDevice device);
     43      void unmap(vector<VkDeviceMemory>& deviceMemory, VkDevice device);
    3944
    4045      void resize();
     
    182187
    183188template<class T>
     189void* VulkanBuffer<T>::mapped(size_t idx) {
     190   return mappedData[idx];
     191}
     192
     193template<class T>
     194void VulkanBuffer<T>::map(vector<VkDeviceMemory>& deviceMemory, VkDevice device) {
     195   // TODO: Make sure that mappedData initally has size 0. If not, it means the memory is already mapped
     196   // and I should return some kind of error or warning
     197   mappedData.resize(deviceMemory.size());
     198
     199   for (size_t i = 0; i < deviceMemory.size(); i++) {
     200      vkMapMemory(device, deviceMemory[i], 0, memorySize(), 0, &mappedData[i]);
     201   }
     202}
     203
     204template<class T>
     205void VulkanBuffer<T>::unmap(vector<VkDeviceMemory>& deviceMemory, VkDevice device) {
     206   for (size_t i = 0; i < deviceMemory.size(); i++) {
     207      vkUnmapMemory(device, deviceMemory[i]);
     208   }
     209
     210   mappedData.clear();
     211}
     212
     213template<class T>
    184214void VulkanBuffer<T>::resize() {
    185215   resized = false;
Note: See TracChangeset for help on using the changeset viewer.