#include "libANGLE/renderer/vulkan/BufferVk.h"
#include "common/FixedVector.h"
#include "common/debug.h"
#include "common/mathutil.h"
#include "common/utilities.h"
#include "libANGLE/Context.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/vk_renderer.h"
namespace rx
{
VkBufferUsageFlags GetDefaultBufferUsageFlags(vk::Renderer *renderer)
{ … }
namespace
{
constexpr VkMemoryPropertyFlags kDeviceLocalFlags = …;
constexpr VkMemoryPropertyFlags kDeviceLocalHostCoherentFlags = …;
constexpr VkMemoryPropertyFlags kHostCachedFlags = …;
constexpr VkMemoryPropertyFlags kHostUncachedFlags = …;
constexpr VkMemoryPropertyFlags kHostCachedNonCoherentFlags = …;
constexpr size_t kBufferSizeGranularity = …;
static_assert …;
constexpr size_t kConvertedArrayBufferInitialSize = …;
VkMemoryPropertyFlags GetPreferredMemoryType(vk::Renderer *renderer,
gl::BufferBinding target,
gl::BufferUsage usage)
{ … }
VkMemoryPropertyFlags GetStorageMemoryType(vk::Renderer *renderer,
GLbitfield storageFlags,
bool externalBuffer)
{ … }
bool ShouldAllocateNewMemoryForUpdate(ContextVk *contextVk, size_t subDataSize, size_t bufferSize)
{ … }
bool ShouldUseCPUToCopyData(ContextVk *contextVk,
const vk::BufferHelper &buffer,
size_t copySize,
size_t bufferSize)
{ … }
bool RenderPassUsesBufferForReadOnly(ContextVk *contextVk, const vk::BufferHelper &buffer)
{ … }
bool ShouldAvoidRenderPassBreakOnUpdate(ContextVk *contextVk,
const vk::BufferHelper &buffer,
size_t bufferSize)
{ … }
BufferUsageType GetBufferUsageType(gl::BufferUsage usage)
{ … }
angle::Result GetMemoryTypeIndex(ContextVk *contextVk,
VkDeviceSize size,
VkMemoryPropertyFlags memoryPropertyFlags,
uint32_t *memoryTypeIndexOut)
{ … }
bool IsSelfCopy(const BufferDataSource &dataSource, const vk::BufferHelper &destination)
{ … }
angle::Result CopyBuffers(ContextVk *contextVk,
vk::BufferHelper *srcBuffer,
vk::BufferHelper *dstBuffer,
uint32_t regionCount,
const VkBufferCopy *copyRegions)
{ … }
}
ConversionBuffer::ConversionBuffer(vk::Renderer *renderer,
VkBufferUsageFlags usageFlags,
size_t initialSize,
size_t alignment,
bool hostVisible)
: … { … }
ConversionBuffer::~ConversionBuffer()
{ … }
ConversionBuffer::ConversionBuffer(ConversionBuffer &&other) = default;
VertexConversionBuffer::VertexConversionBuffer(vk::Renderer *renderer, const CacheKey &cacheKey)
: … { … }
VertexConversionBuffer::VertexConversionBuffer(VertexConversionBuffer &&other) = default;
VertexConversionBuffer::~VertexConversionBuffer() = default;
BufferVk::BufferVk(const gl::BufferState &state)
: … { … }
BufferVk::~BufferVk() { … }
void BufferVk::destroy(const gl::Context *context)
{ … }
void BufferVk::releaseConversionBuffers(vk::Renderer *renderer)
{ … }
angle::Result BufferVk::release(ContextVk *contextVk)
{ … }
angle::Result BufferVk::setExternalBufferData(const gl::Context *context,
gl::BufferBinding target,
GLeglClientBufferEXT clientBuffer,
size_t size,
VkMemoryPropertyFlags memoryPropertyFlags)
{ … }
angle::Result BufferVk::setDataWithUsageFlags(const gl::Context *context,
gl::BufferBinding target,
GLeglClientBufferEXT clientBuffer,
const void *data,
size_t size,
gl::BufferUsage usage,
GLbitfield flags)
{ … }
angle::Result BufferVk::setData(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
gl::BufferUsage usage)
{ … }
angle::Result BufferVk::setDataWithMemoryType(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
VkMemoryPropertyFlags memoryPropertyFlags,
gl::BufferUsage usage)
{ … }
angle::Result BufferVk::setSubData(const gl::Context *context,
gl::BufferBinding target,
const void *data,
size_t size,
size_t offset)
{ … }
angle::Result BufferVk::copySubData(const gl::Context *context,
BufferImpl *source,
GLintptr sourceOffset,
GLintptr destOffset,
GLsizeiptr size)
{ … }
angle::Result BufferVk::allocStagingBuffer(ContextVk *contextVk,
vk::MemoryCoherency coherency,
VkDeviceSize size,
uint8_t **mapPtr)
{ … }
angle::Result BufferVk::flushStagingBuffer(ContextVk *contextVk,
VkDeviceSize offset,
VkDeviceSize size)
{ … }
angle::Result BufferVk::handleDeviceLocalBufferMap(ContextVk *contextVk,
VkDeviceSize offset,
VkDeviceSize size,
uint8_t **mapPtr)
{ … }
angle::Result BufferVk::map(const gl::Context *context, GLenum access, void **mapPtr)
{ … }
angle::Result BufferVk::mapRange(const gl::Context *context,
size_t offset,
size_t length,
GLbitfield access,
void **mapPtr)
{ … }
angle::Result BufferVk::mapImpl(ContextVk *contextVk, GLbitfield access, void **mapPtr)
{ … }
angle::Result BufferVk::ghostMappedBuffer(ContextVk *contextVk,
VkDeviceSize offset,
VkDeviceSize length,
GLbitfield access,
void **mapPtr)
{ … }
angle::Result BufferVk::mapRangeImpl(ContextVk *contextVk,
VkDeviceSize offset,
VkDeviceSize length,
GLbitfield access,
void **mapPtr)
{ … }
angle::Result BufferVk::unmap(const gl::Context *context, GLboolean *result)
{ … }
angle::Result BufferVk::unmapImpl(ContextVk *contextVk)
{ … }
angle::Result BufferVk::getSubData(const gl::Context *context,
GLintptr offset,
GLsizeiptr size,
void *outData)
{ … }
angle::Result BufferVk::getIndexRange(const gl::Context *context,
gl::DrawElementsType type,
size_t offset,
size_t count,
bool primitiveRestartEnabled,
gl::IndexRange *outRange)
{ … }
angle::Result BufferVk::updateBuffer(ContextVk *contextVk,
size_t bufferSize,
const BufferDataSource &dataSource,
size_t updateSize,
size_t updateOffset)
{ … }
angle::Result BufferVk::directUpdate(ContextVk *contextVk,
const BufferDataSource &dataSource,
size_t size,
size_t offset)
{ … }
angle::Result BufferVk::stagedUpdate(ContextVk *contextVk,
const BufferDataSource &dataSource,
size_t size,
size_t offset)
{ … }
angle::Result BufferVk::acquireAndUpdate(ContextVk *contextVk,
size_t bufferSize,
const BufferDataSource &dataSource,
size_t updateSize,
size_t updateOffset,
BufferUpdateType updateType)
{ … }
angle::Result BufferVk::setDataImpl(ContextVk *contextVk,
size_t bufferSize,
const BufferDataSource &dataSource,
size_t updateSize,
size_t updateOffset,
BufferUpdateType updateType)
{ … }
VertexConversionBuffer *BufferVk::getVertexConversionBuffer(
vk::Renderer *renderer,
const VertexConversionBuffer::CacheKey &cacheKey)
{ … }
void BufferVk::dataRangeUpdated(const RangeDeviceSize &range)
{ … }
void BufferVk::dataUpdated()
{ … }
void BufferVk::onDataChanged()
{ … }
angle::Result BufferVk::acquireBufferHelper(ContextVk *contextVk,
size_t sizeInBytes,
BufferUsageType usageType)
{ … }
bool BufferVk::isCurrentlyInUse(vk::Renderer *renderer) const
{ … }
BufferUpdateType BufferVk::calculateBufferUpdateTypeOnFullUpdate(
vk::Renderer *renderer,
size_t size,
VkMemoryPropertyFlags memoryPropertyFlags,
BufferUsageType usageType,
const void *data) const
{ … }
bool BufferVk::shouldRedefineStorage(vk::Renderer *renderer,
BufferUsageType usageType,
VkMemoryPropertyFlags memoryPropertyFlags,
size_t size) const
{ … }
}