Commit f3614370 by Jamie Madill Committed by Commit Bot

Vulkan: Rename StreamingBuffer to DynamicBuffer.

This makes it consistent with DynamicDescriptorPool, and gives a bit more precise definition. Bug: angleproject:2318 Change-Id: I8953113165ebe2d0dcfc0fc923d94280180442ce Reviewed-on: https://chromium-review.googlesource.com/985199 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent 00af463e
......@@ -57,8 +57,8 @@ VkIndexType GetVkIndexType(GLenum glIndexType)
}
}
constexpr size_t kStreamingVertexDataSize = 1024 * 1024;
constexpr size_t kStreamingIndexDataSize = 1024 * 8;
constexpr size_t kDynamicVertexDataSize = 1024 * 1024;
constexpr size_t kDynamicIndexDataSize = 1024 * 8;
} // anonymous namespace
......@@ -69,13 +69,13 @@ ContextVk::ContextVk(const gl::ContextState &state, RendererVk *renderer)
mDynamicDescriptorPool(),
mVertexArrayDirty(false),
mTexturesDirty(false),
mStreamingVertexData(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, kStreamingVertexDataSize),
mStreamingIndexData(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, kStreamingIndexDataSize)
mDynamicVertexData(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, kDynamicVertexDataSize),
mDynamicIndexData(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, kDynamicIndexDataSize)
{
memset(&mClearColorValue, 0, sizeof(mClearColorValue));
memset(&mClearDepthStencilValue, 0, sizeof(mClearDepthStencilValue));
mStreamingVertexData.init(1);
mStreamingIndexData.init(1);
mDynamicVertexData.init(1);
mDynamicIndexData.init(1);
}
ContextVk::~ContextVk()
......@@ -87,8 +87,8 @@ void ContextVk::onDestroy(const gl::Context *context)
VkDevice device = mRenderer->getDevice();
mDynamicDescriptorPool.destroy(mRenderer);
mStreamingVertexData.destroy(device);
mStreamingIndexData.destroy(device);
mDynamicVertexData.destroy(device);
mDynamicIndexData.destroy(device);
mLineLoopHandler.destroy(device);
}
......@@ -224,7 +224,7 @@ gl::Error ContextVk::setupDraw(const gl::Context *context,
}
commandBuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, mCurrentPipeline->get());
ANGLE_TRY(vkVAO->streamVertexData(context, &mStreamingVertexData, drawCallParams));
ANGLE_TRY(vkVAO->streamVertexData(context, &mDynamicVertexData, drawCallParams));
commandBuffer->bindVertexBuffers(0, maxAttrib, vkVAO->getCurrentArrayBufferHandles().data(),
vkVAO->getCurrentArrayBufferOffsets().data());
......@@ -345,7 +345,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context,
GLubyte *dst = nullptr;
ANGLE_TRY(
mStreamingIndexData.allocate(contextVk, amount, &dst, &buffer, &offset, nullptr));
mDynamicIndexData.allocate(contextVk, amount, &dst, &buffer, &offset, nullptr));
if (type == GL_UNSIGNED_BYTE)
{
// Unsigned bytes don't have direct support in Vulkan so we have to expand the
......@@ -361,7 +361,7 @@ gl::Error ContextVk::drawElements(const gl::Context *context,
{
memcpy(dst, indices, amount);
}
ANGLE_TRY(mStreamingIndexData.flush(contextVk));
ANGLE_TRY(mDynamicIndexData.flush(contextVk));
}
ANGLE_TRY(setupDraw(context, drawCallParams, nullptr, &commandBuffer));
......
......@@ -13,8 +13,8 @@
#include <vulkan/vulkan.h>
#include "libANGLE/renderer/ContextImpl.h"
#include "libANGLE/renderer/vulkan/DynamicBuffer.h"
#include "libANGLE/renderer/vulkan/DynamicDescriptorPool.h"
#include "libANGLE/renderer/vulkan/StreamingBuffer.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
namespace rx
......@@ -190,8 +190,8 @@ class ContextVk : public ContextImpl
VkClearValue mClearColorValue;
VkClearValue mClearDepthStencilValue;
StreamingBuffer mStreamingVertexData;
StreamingBuffer mStreamingIndexData;
DynamicBuffer mDynamicVertexData;
DynamicBuffer mDynamicIndexData;
vk::LineLoopHandler mLineLoopHandler;
};
......
......@@ -3,12 +3,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// StreamingBuffer:
// DynamicBuffer:
// Create, map and flush buffers as needed to hold data, returning a handle and offset for each
// chunk.
//
#include "StreamingBuffer.h"
#include "libANGLE/renderer/vulkan/DynamicBuffer.h"
#include "anglebase/numerics/safe_math.h"
......@@ -17,7 +17,7 @@
namespace rx
{
StreamingBuffer::StreamingBuffer(VkBufferUsageFlags usage, size_t minSize)
DynamicBuffer::DynamicBuffer(VkBufferUsageFlags usage, size_t minSize)
: mUsage(usage),
mMinSize(minSize),
mNextWriteOffset(0),
......@@ -28,28 +28,28 @@ StreamingBuffer::StreamingBuffer(VkBufferUsageFlags usage, size_t minSize)
{
}
void StreamingBuffer::init(size_t alignment)
void DynamicBuffer::init(size_t alignment)
{
ASSERT(alignment > 0);
mAlignment = alignment;
}
StreamingBuffer::~StreamingBuffer()
DynamicBuffer::~DynamicBuffer()
{
ASSERT(mAlignment == 0);
}
bool StreamingBuffer::valid()
bool DynamicBuffer::valid()
{
return mAlignment > 0;
}
vk::Error StreamingBuffer::allocate(ContextVk *context,
size_t sizeInBytes,
uint8_t **ptrOut,
VkBuffer *handleOut,
uint32_t *offsetOut,
bool *outNewBufferAllocated)
vk::Error DynamicBuffer::allocate(ContextVk *context,
size_t sizeInBytes,
uint8_t **ptrOut,
VkBuffer *handleOut,
uint32_t *offsetOut,
bool *outNewBufferAllocated)
{
ASSERT(valid());
RendererVk *renderer = context->getRenderer();
......@@ -121,7 +121,7 @@ vk::Error StreamingBuffer::allocate(ContextVk *context,
return vk::NoError();
}
vk::Error StreamingBuffer::flush(ContextVk *context)
vk::Error DynamicBuffer::flush(ContextVk *context)
{
if (mNextWriteOffset > mLastFlushOffset)
{
......@@ -138,19 +138,19 @@ vk::Error StreamingBuffer::flush(ContextVk *context)
return vk::NoError();
}
void StreamingBuffer::destroy(VkDevice device)
void DynamicBuffer::destroy(VkDevice device)
{
mAlignment = 0;
mBuffer.destroy(device);
mMemory.destroy(device);
}
VkBuffer StreamingBuffer::getCurrentBufferHandle() const
VkBuffer DynamicBuffer::getCurrentBufferHandle() const
{
return mBuffer.getHandle();
}
void StreamingBuffer::setMinimumSize(size_t minSize)
void DynamicBuffer::setMinimumSize(size_t minSize)
{
// This will really only have an effect next time we call allocate.
mMinSize = minSize;
......
......@@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// StreamingBuffer:
// DynamicBuffer:
// Create, map and flush buffers as needed to hold data, returning a handle and offset for each
// chunk.
//
......@@ -16,13 +16,13 @@
namespace rx
{
class StreamingBuffer : public ResourceVk
class DynamicBuffer : public ResourceVk
{
public:
StreamingBuffer(VkBufferUsageFlags usage, size_t minSize);
DynamicBuffer(VkBufferUsageFlags usage, size_t minSize);
void init(size_t alignment);
bool valid();
~StreamingBuffer();
~DynamicBuffer();
vk::Error allocate(ContextVk *context,
size_t sizeInBytes,
uint8_t **ptrOut,
......
......@@ -16,7 +16,6 @@
#include "libANGLE/renderer/vulkan/DynamicDescriptorPool.h"
#include "libANGLE/renderer/vulkan/GlslangWrapper.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/StreamingBuffer.h"
#include "libANGLE/renderer/vulkan/TextureVk.h"
namespace rx
......@@ -25,7 +24,7 @@ namespace rx
namespace
{
constexpr size_t kUniformBlockStreamingBufferMinSize = 256 * 128;
constexpr size_t kUniformBlockDynamicBufferMinSize = 256 * 128;
gl::Error InitDefaultUniformBlock(const gl::Context *context,
gl::Shader *shader,
......@@ -115,7 +114,7 @@ void ReadFromDefaultUniformBlock(int componentCount,
}
vk::Error SyncDefaultUniformBlock(ContextVk *contextVk,
StreamingBuffer &streamingBuffer,
DynamicBuffer &dynamicBuffer,
const angle::MemoryBuffer &bufferData,
uint32_t *outOffset,
bool *outBufferModified)
......@@ -124,11 +123,11 @@ vk::Error SyncDefaultUniformBlock(ContextVk *contextVk,
uint8_t *data = nullptr;
VkBuffer *outBuffer = nullptr;
uint32_t offset;
ANGLE_TRY(streamingBuffer.allocate(contextVk, bufferData.size(), &data, outBuffer, &offset,
outBufferModified));
ANGLE_TRY(dynamicBuffer.allocate(contextVk, bufferData.size(), &data, outBuffer, &offset,
outBufferModified));
*outOffset = offset;
memcpy(data, bufferData.data(), bufferData.size());
ANGLE_TRY(streamingBuffer.flush(contextVk));
ANGLE_TRY(dynamicBuffer.flush(contextVk));
return vk::NoError();
}
......@@ -159,7 +158,7 @@ gl::Shader *GetShader(const gl::ProgramState &programState, uint32_t shaderIndex
ProgramVk::DefaultUniformBlock::DefaultUniformBlock()
: storage(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
kUniformBlockStreamingBufferMinSize),
kUniformBlockDynamicBufferMinSize),
uniformData(),
uniformsDirty(false),
uniformLayout()
......
......@@ -14,8 +14,8 @@
#include "libANGLE/Constants.h"
#include "libANGLE/renderer/ProgramImpl.h"
#include "libANGLE/renderer/vulkan/DynamicBuffer.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/StreamingBuffer.h"
#include "libANGLE/renderer/vulkan/vk_utils.h"
namespace rx
......@@ -153,7 +153,7 @@ class ProgramVk : public ProgramImpl
DefaultUniformBlock();
~DefaultUniformBlock();
StreamingBuffer storage;
DynamicBuffer storage;
// Shadow copies of the shader uniform data.
angle::MemoryBuffer uniformData;
......
......@@ -50,7 +50,7 @@ gl::AttributesMask VertexArrayVk::getAttribsToStream(const gl::Context *context)
}
gl::Error VertexArrayVk::streamVertexData(const gl::Context *context,
StreamingBuffer *stream,
DynamicBuffer *dynamicBuffer,
const gl::DrawCallParams &drawCallParams)
{
ContextVk *contextVk = vk::GetImpl(context);
......@@ -86,14 +86,14 @@ gl::Error VertexArrayVk::streamVertexData(const gl::Context *context,
lastVertex * binding.getStride() + gl::ComputeVertexAttributeTypeSize(attrib);
uint8_t *dst = nullptr;
uint32_t offset = 0;
ANGLE_TRY(stream->allocate(contextVk, lastByte, &dst,
&mCurrentArrayBufferHandles[attribIndex], &offset, nullptr));
ANGLE_TRY(dynamicBuffer->allocate(
contextVk, lastByte, &dst, &mCurrentArrayBufferHandles[attribIndex], &offset, nullptr));
mCurrentArrayBufferOffsets[attribIndex] = static_cast<VkDeviceSize>(offset);
memcpy(dst + firstByte, static_cast<const uint8_t *>(attrib.pointer) + firstByte,
lastByte - firstByte);
}
ANGLE_TRY(stream->flush(contextVk));
ANGLE_TRY(dynamicBuffer->flush(contextVk));
return gl::NoError();
}
......
......@@ -21,7 +21,7 @@ class DrawCallParams;
namespace rx
{
class BufferVk;
class StreamingBuffer;
class DynamicBuffer;
class VertexArrayVk : public VertexArrayImpl
{
......@@ -32,8 +32,9 @@ class VertexArrayVk : public VertexArrayImpl
void destroy(const gl::Context *context) override;
gl::Error streamVertexData(const gl::Context *context,
StreamingBuffer *stream,
DynamicBuffer *dynamicBuffer,
const gl::DrawCallParams &drawCallParams);
gl::Error syncState(const gl::Context *context,
const gl::VertexArray::DirtyBits &dirtyBits,
const gl::VertexArray::DirtyAttribBitsArray &attribBits,
......
......@@ -17,11 +17,9 @@
namespace rx
{
namespace
{
constexpr int kLineLoopStreamingBufferMinSize = 1024 * 1024;
constexpr int kLineLoopDynamicBufferMinSize = 1024 * 1024;
GLenum DefaultGLErrorCode(VkResult result)
{
......@@ -1179,13 +1177,13 @@ void GarbageObject::destroy(VkDevice device)
LineLoopHandler::LineLoopHandler()
: mObserverBinding(this, 0u),
mStreamingLineLoopIndicesData(
new StreamingBuffer(VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
kLineLoopStreamingBufferMinSize)),
mDynamicLineLoopIndicesData(
new DynamicBuffer(VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
kLineLoopDynamicBufferMinSize)),
mLineLoopIndexBuffer(VK_NULL_HANDLE),
mLineLoopIndexBufferOffset(VK_NULL_HANDLE)
{
mStreamingLineLoopIndicesData->init(1);
mDynamicLineLoopIndicesData->init(1);
}
LineLoopHandler::~LineLoopHandler() = default;
......@@ -1204,7 +1202,7 @@ gl::Error LineLoopHandler::createIndexBuffer(ContextVk *contextVk, int firstVert
{
uint32_t *indices = nullptr;
size_t allocateBytes = sizeof(uint32_t) * (count + 1);
ANGLE_TRY(mStreamingLineLoopIndicesData->allocate(
ANGLE_TRY(mDynamicLineLoopIndicesData->allocate(
contextVk, allocateBytes, reinterpret_cast<uint8_t **>(&indices), &mLineLoopIndexBuffer,
&mLineLoopIndexBufferOffset, nullptr));
......@@ -1217,9 +1215,9 @@ gl::Error LineLoopHandler::createIndexBuffer(ContextVk *contextVk, int firstVert
*indices = unsignedFirstVertex;
// Since we are not using the VK_MEMORY_PROPERTY_HOST_COHERENT_BIT flag when creating the
// device memory in the StreamingBuffer, we always need to make sure we flush it after
// device memory in the DynamicBuffer, we always need to make sure we flush it after
// writing.
ANGLE_TRY(mStreamingLineLoopIndicesData->flush(contextVk));
ANGLE_TRY(mDynamicLineLoopIndicesData->flush(contextVk));
mLineLoopBufferFirstIndex = firstVertex;
mLineLoopBufferLastIndex = lastVertex;
......@@ -1248,7 +1246,7 @@ gl::Error LineLoopHandler::createIndexBufferFromElementArrayBuffer(ContextVk *co
auto unitSize = (indexType == VK_INDEX_TYPE_UINT16 ? sizeof(uint16_t) : sizeof(uint32_t));
size_t allocateBytes = unitSize * (count + 1);
ANGLE_TRY(mStreamingLineLoopIndicesData->allocate(
ANGLE_TRY(mDynamicLineLoopIndicesData->allocate(
contextVk, allocateBytes, reinterpret_cast<uint8_t **>(&indices), &mLineLoopIndexBuffer,
&mLineLoopIndexBufferOffset, nullptr));
......@@ -1259,22 +1257,22 @@ gl::Error LineLoopHandler::createIndexBufferFromElementArrayBuffer(ContextVk *co
std::array<VkBufferCopy, 2> copies = {{copy1, copy2}};
vk::CommandBuffer *commandBuffer;
mStreamingLineLoopIndicesData->beginWriteResource(contextVk->getRenderer(), &commandBuffer);
mDynamicLineLoopIndicesData->beginWriteResource(contextVk->getRenderer(), &commandBuffer);
Serial currentSerial = contextVk->getRenderer()->getCurrentQueueSerial();
bufferVk->onReadResource(mStreamingLineLoopIndicesData->getCurrentWritingNode(currentSerial),
bufferVk->onReadResource(mDynamicLineLoopIndicesData->getCurrentWritingNode(currentSerial),
currentSerial);
commandBuffer->copyBuffer(bufferVk->getVkBuffer().getHandle(), mLineLoopIndexBuffer, 2,
copies.data());
ANGLE_TRY(mStreamingLineLoopIndicesData->flush(contextVk));
ANGLE_TRY(mDynamicLineLoopIndicesData->flush(contextVk));
return gl::NoError();
}
void LineLoopHandler::destroy(VkDevice device)
{
mObserverBinding.reset();
mStreamingLineLoopIndicesData->destroy(device);
mDynamicLineLoopIndicesData->destroy(device);
}
gl::Error LineLoopHandler::draw(int count, CommandBuffer *commandBuffer)
......@@ -1288,7 +1286,7 @@ gl::Error LineLoopHandler::draw(int count, CommandBuffer *commandBuffer)
ResourceVk *LineLoopHandler::getLineLoopBufferResource()
{
return mStreamingLineLoopIndicesData.get();
return mDynamicLineLoopIndicesData.get();
}
void LineLoopHandler::onSubjectStateChange(const gl::Context *context,
......
......@@ -53,11 +53,11 @@ ANGLE_GL_OBJECTS_X(ANGLE_PRE_DECLARE_OBJECT);
namespace rx
{
class DisplayVk;
class DynamicBuffer;
class RenderTargetVk;
class RendererVk;
class ResourceVk;
class RenderPassCache;
class StreamingBuffer;
ANGLE_GL_OBJECTS_X(ANGLE_PRE_DECLARE_VK_OBJECT);
......@@ -672,7 +672,7 @@ class LineLoopHandler final : angle::NonCopyable, angle::ObserverInterface
private:
angle::ObserverBinding mObserverBinding;
std::unique_ptr<StreamingBuffer> mStreamingLineLoopIndicesData;
std::unique_ptr<DynamicBuffer> mDynamicLineLoopIndicesData;
VkBuffer mLineLoopIndexBuffer;
uint32_t mLineLoopIndexBufferOffset;
Optional<int> mLineLoopBufferFirstIndex;
......
......@@ -758,6 +758,8 @@
'libANGLE/renderer/vulkan/DeviceVk.h',
'libANGLE/renderer/vulkan/DisplayVk.cpp',
'libANGLE/renderer/vulkan/DisplayVk.h',
'libANGLE/renderer/vulkan/DynamicBuffer.h',
'libANGLE/renderer/vulkan/DynamicBuffer.cpp',
'libANGLE/renderer/vulkan/DynamicDescriptorPool.cpp',
'libANGLE/renderer/vulkan/DynamicDescriptorPool.h',
'libANGLE/renderer/vulkan/FenceNVVk.cpp',
......@@ -784,8 +786,6 @@
'libANGLE/renderer/vulkan/SamplerVk.h',
'libANGLE/renderer/vulkan/ShaderVk.cpp',
'libANGLE/renderer/vulkan/ShaderVk.h',
'libANGLE/renderer/vulkan/StreamingBuffer.h',
'libANGLE/renderer/vulkan/StreamingBuffer.cpp',
'libANGLE/renderer/vulkan/SurfaceVk.cpp',
'libANGLE/renderer/vulkan/SurfaceVk.h',
'libANGLE/renderer/vulkan/SyncVk.cpp',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment