Changeset 5ea0a37 in opengl-game for vulkan-buffer.hpp


Ignore:
Timestamp:
Jun 11, 2021, 10:05:25 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
90880fb
Parents:
6486ba8
Message:

Add a function to VulkanBuffer to return a pointer to the buffer memory, and replace the use of updateBufferSet with copyDataToMemory to update all the data for a single pipeline in one call

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-buffer.hpp

    r6486ba8 r5ea0a37  
    3131      VulkanBuffer<T>& operator=(VulkanBuffer<T>&& other) noexcept;
    3232
    33       void resize();
     33      size_t memorySize();
     34
     35      T* data();  // Not sure I need to expose this
    3436
    3537      T& get(uint32_t index);
    3638      void add(T obj);
    3739
    38       size_t memorySize();
     40      void resize();
    3941
    4042   private:
     
    114116      range = other.range;
    115117
     118      mappedData = other.mappedData;
     119
    116120      if (rawData != nullptr) {
    117121         free(rawData);
     
    124128      other.range = 0;
    125129
     130      other.mappedData.clear();
    126131      other.rawData = nullptr;
    127132   }
     
    131136
    132137template<class T>
    133 void VulkanBuffer<T>::resize() {
    134    resized = false;
     138size_t VulkanBuffer<T>::memorySize() {
     139   return memRequirement(capacity);
     140}
     141
     142template<class T>
     143T* VulkanBuffer<T>::data() {
     144   return rawData;
    135145}
    136146
     
    145155template<class T>
    146156void VulkanBuffer<T>::add(T obj) {
     157   // TODO: Maybe copy this to the resize() function and call that function here
    147158   if (numObjects == capacity) {
    148159      // Once I add Vulkan buffer objects in here, make sure this doesn't overlap with resizeBufferSet
     
    171182
    172183template<class T>
    173 size_t VulkanBuffer<T>::memorySize() {
    174    return memRequirement(capacity);
     184void VulkanBuffer<T>::resize() {
     185   resized = false;
    175186}
    176187
Note: See TracChangeset for help on using the changeset viewer.