Commit 558882a1 by Jamie Madill Committed by Commit Bot

Vulkan: Pass vk::Context to BufferHelper::init.

This is necessary so we can initialize a "null" BufferHelper in RendererVk which does not have access to the ContextVk. This in turn will allow us to use a single global "null" Buffer instead of instantiating them all over ANGLE. Also removes a TODO that was sticking in the code. Bug: angleproject:2162 Bug: chromium:1086532 Change-Id: Ica48d5b886e885ebfe0f8e3abfbe8169a8eaa5b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2219139 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent c0c938af
...@@ -3743,11 +3743,6 @@ void ContextVk::insertWaitSemaphore(const vk::Semaphore *waitSemaphore) ...@@ -3743,11 +3743,6 @@ void ContextVk::insertWaitSemaphore(const vk::Semaphore *waitSemaphore)
mWaitSemaphores.push_back(waitSemaphore->getHandle()); mWaitSemaphores.push_back(waitSemaphore->getHandle());
} }
bool ContextVk::shouldFlush()
{
return getRenderer()->shouldCleanupGarbage();
}
bool ContextVk::hasRecordedCommands() bool ContextVk::hasRecordedCommands()
{ {
ASSERT(mOutsideRenderPassCommands && mRenderPassCommands); ASSERT(mOutsideRenderPassCommands && mRenderPassCommands);
......
...@@ -368,7 +368,6 @@ class ContextVk : public ContextImpl, public vk::Context ...@@ -368,7 +368,6 @@ class ContextVk : public ContextImpl, public vk::Context
void insertWaitSemaphore(const vk::Semaphore *waitSemaphore); void insertWaitSemaphore(const vk::Semaphore *waitSemaphore);
bool shouldFlush();
angle::Result flushImpl(const vk::Semaphore *semaphore); angle::Result flushImpl(const vk::Semaphore *semaphore);
angle::Result finishImpl(); angle::Result finishImpl();
......
...@@ -244,11 +244,6 @@ class RendererVk : angle::NonCopyable ...@@ -244,11 +244,6 @@ class RendererVk : angle::NonCopyable
void onCompletedSerial(Serial serial); void onCompletedSerial(Serial serial);
bool shouldCleanupGarbage()
{
return (mSharedGarbage.size() > mGarbageCollectionFlushThreshold);
}
bool enableDebugUtils() const { return mEnableDebugUtils; } bool enableDebugUtils() const { return mEnableDebugUtils; }
SamplerCache &getSamplerCache() { return mSamplerCache; } SamplerCache &getSamplerCache() { return mSamplerCache; }
......
...@@ -2126,19 +2126,11 @@ BufferHelper::BufferHelper() ...@@ -2126,19 +2126,11 @@ BufferHelper::BufferHelper()
BufferHelper::~BufferHelper() = default; BufferHelper::~BufferHelper() = default;
angle::Result BufferHelper::init(ContextVk *contextVk, angle::Result BufferHelper::init(Context *context,
const VkBufferCreateInfo &requestedCreateInfo, const VkBufferCreateInfo &requestedCreateInfo,
VkMemoryPropertyFlags memoryPropertyFlags) VkMemoryPropertyFlags memoryPropertyFlags)
{ {
RendererVk *renderer = contextVk->getRenderer(); RendererVk *renderer = context->getRenderer();
// TODO: Remove with anglebug.com/2162: Vulkan: Implement device memory sub-allocation
// Check if we have too many resources allocated already and need to free some before allocating
// more and (possibly) exceeding the device's limits.
if (contextVk->shouldFlush())
{
ANGLE_TRY(contextVk->flushImpl(nullptr));
}
mSize = requestedCreateInfo.size; mSize = requestedCreateInfo.size;
...@@ -2163,7 +2155,7 @@ angle::Result BufferHelper::init(ContextVk *contextVk, ...@@ -2163,7 +2155,7 @@ angle::Result BufferHelper::init(ContextVk *contextVk,
renderer->getAllocator(), createInfo, requiredFlags, preferredFlags, renderer->getAllocator(), createInfo, requiredFlags, preferredFlags,
renderer->getFeatures().persistentlyMappedBuffers.enabled, &mBuffer, &mMemoryPropertyFlags); renderer->getFeatures().persistentlyMappedBuffers.enabled, &mBuffer, &mMemoryPropertyFlags);
mCurrentQueueFamilyIndex = contextVk->getRenderer()->getQueueFamilyIndex(); mCurrentQueueFamilyIndex = renderer->getQueueFamilyIndex();
if (renderer->getFeatures().allocateNonZeroMemory.enabled) if (renderer->getFeatures().allocateNonZeroMemory.enabled)
{ {
...@@ -2173,7 +2165,7 @@ angle::Result BufferHelper::init(ContextVk *contextVk, ...@@ -2173,7 +2165,7 @@ angle::Result BufferHelper::init(ContextVk *contextVk,
if ((mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0 && if ((mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0 &&
(requestedCreateInfo.usage & VK_BUFFER_USAGE_TRANSFER_DST_BIT) != 0) (requestedCreateInfo.usage & VK_BUFFER_USAGE_TRANSFER_DST_BIT) != 0)
{ {
ANGLE_TRY(initializeNonZeroMemory(contextVk, createInfo->size)); ANGLE_TRY(initializeNonZeroMemory(context, createInfo->size));
} }
else if ((mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0) else if ((mMemoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
{ {
......
...@@ -685,7 +685,7 @@ class BufferHelper final : public Resource ...@@ -685,7 +685,7 @@ class BufferHelper final : public Resource
BufferHelper(); BufferHelper();
~BufferHelper() override; ~BufferHelper() override;
angle::Result init(ContextVk *contextVk, angle::Result init(Context *context,
const VkBufferCreateInfo &createInfo, const VkBufferCreateInfo &createInfo,
VkMemoryPropertyFlags memoryPropertyFlags); VkMemoryPropertyFlags memoryPropertyFlags);
void destroy(RendererVk *renderer); void destroy(RendererVk *renderer);
......
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