Hash :
e3dc5dd0
Author :
Date :
2018-03-16T07:37:21
Vulkan: Add 2 features to StreamingBuffer This is prerequisite work to dynamic uniform buffer updates. 1- Alignment parameter to be able to allocate by chunks of this alignment. 2- Out boolean to indicate if a new VkBuffer has been assigned on the allocate operation. Bug:angleproject:2392 Change-Id: If346e13200455febbe78045e908ae89c9dc93cdb Reviewed-on: https://chromium-review.googlesource.com/965612 Commit-Queue: Luc Ferron <lucferron@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// StreamingBuffer:
// Create, map and flush buffers as needed to hold data, returning a handle and offset for each
// chunk.
//
#ifndef LIBANGLE_RENDERER_VULKAN_STREAMING_BUFFER_H_
#define LIBANGLE_RENDERER_VULKAN_STREAMING_BUFFER_H_
#include "libANGLE/renderer/vulkan/vk_utils.h"
namespace rx
{
class StreamingBuffer : public ResourceVk
{
public:
StreamingBuffer(VkBufferUsageFlags usage, size_t minSize, size_t minAlignment);
~StreamingBuffer();
gl::Error allocate(ContextVk *context,
size_t sizeInBytes,
uint8_t **ptrOut,
VkBuffer *handleOut,
VkDeviceSize *offsetOut,
bool *outNewBufferAllocated);
gl::Error flush(ContextVk *context);
void destroy(VkDevice device);
private:
VkBufferUsageFlags mUsage;
size_t mMinSize;
vk::Buffer mBuffer;
vk::DeviceMemory mMemory;
size_t mNextWriteOffset;
size_t mLastFlushOffset;
size_t mSize;
size_t mMinAlignment;
uint8_t *mMappedMemory;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_STREAMING_BUFFER_H_