Vulkan: Refix cleanup race condition on Context destroy

This partially reverts commit 905ee08219
due to regression caused on startup time.

Instead of calling finish before destroying the context, the objects in
the Vulkan backend are `release()`ed instead of `destroy()`ed, so they
will be kept alive for the duration of current work.

Bug: 904846
Change-Id: Ia774470666c4c0d4c1ddc348f685d621243de204
Reviewed-on: https://chromium-review.googlesource.com/c/1333969
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Shahbaz Youssefi 2018-11-13 13:55:48 -05:00 коммит произвёл Commit Bot
Родитель 092481ada0
Коммит fca8fd6201
7 изменённых файлов: 17 добавлений и 33 удалений

Просмотреть файл

@ -545,10 +545,6 @@ void Context::initialize()
egl::Error Context::onDestroy(const egl::Display *display)
{
// Trigger a finish() to make sure resources are not in use upon destruction. Particularly
// necessary for Vulkan.
finish();
if (mGLES1Renderer)
{
mGLES1Renderer->onDestroy(this, &mGLState);

Просмотреть файл

@ -1203,12 +1203,6 @@ angle::Result Renderer11::flush(Context11 *context11)
angle::Result Renderer11::finish(Context11 *context11)
{
// If device is lost, there is nothing to finish. This is called on context destroy.
if (!mDevice)
{
return angle::Result::Continue();
}
if (!mSyncQuery.valid())
{
D3D11_QUERY_DESC queryDesc;

Просмотреть файл

@ -648,20 +648,9 @@ angle::Result Renderer9::finish(const gl::Context *context)
}
ANGLE_TRY_HR(context9, result, "Failed to get event query data");
// Loop until the query completes. A bug has been observed where the query result is always
// false, so we loop for a maximum of 100ms.
// Loop until the query completes
unsigned int attempt = 0;
LARGE_INTEGER timerFrequency;
QueryPerformanceFrequency(&timerFrequency);
LARGE_INTEGER startTime;
QueryPerformanceCounter(&startTime);
LARGE_INTEGER currentTime = startTime;
// Note: timerFrequency is ticks in one second
const LONGLONG kMaxWaitTicks = timerFrequency.QuadPart / 10;
while (result == S_FALSE && (currentTime.QuadPart - startTime.QuadPart) < kMaxWaitTicks)
while (result == S_FALSE)
{
// Keep polling, but allow other threads to do something useful first
ScheduleYield();
@ -686,8 +675,6 @@ angle::Result Renderer9::finish(const gl::Context *context)
freeEventQuery(query);
}
ANGLE_TRY_HR(context9, result, "Failed to get event query data");
QueryPerformanceCounter(&currentTime);
}
freeEventQuery(query);

Просмотреть файл

@ -138,8 +138,8 @@ void FramebufferVk::destroy(const gl::Context *context)
RendererVk *renderer = contextVk->getRenderer();
mFramebuffer.release(renderer);
mReadPixelBuffer.destroy(contextVk->getDevice());
mBlitPixelBuffer.destroy(contextVk->getDevice());
mReadPixelBuffer.release(renderer);
mBlitPixelBuffer.release(renderer);
}
angle::Result FramebufferVk::discard(const gl::Context *context,

Просмотреть файл

@ -105,15 +105,16 @@ VertexArrayVk::~VertexArrayVk()
void VertexArrayVk::destroy(const gl::Context *context)
{
VkDevice device = vk::GetImpl(context)->getRenderer()->getDevice();
RendererVk *renderer = vk::GetImpl(context)->getRenderer();
for (vk::DynamicBuffer &buffer : mCurrentArrayBufferConversion)
{
buffer.destroy(device);
buffer.release(renderer);
}
mDynamicVertexData.destroy(device);
mDynamicIndexData.destroy(device);
mTranslatedByteIndexData.destroy(device);
mLineLoopHelper.destroy(device);
mDynamicVertexData.release(renderer);
mDynamicIndexData.release(renderer);
mTranslatedByteIndexData.release(renderer);
mLineLoopHelper.release(renderer);
}
angle::Result VertexArrayVk::streamIndexData(ContextVk *contextVk,

Просмотреть файл

@ -875,6 +875,11 @@ angle::Result LineLoopHelper::streamIndices(ContextVk *contextVk,
return angle::Result::Continue();
}
void LineLoopHelper::release(RendererVk *renderer)
{
mDynamicIndexBuffer.release(renderer);
}
void LineLoopHelper::destroy(VkDevice device)
{
mDynamicIndexBuffer.destroy(device);

Просмотреть файл

@ -361,6 +361,7 @@ class LineLoopHelper final : angle::NonCopyable
VkBuffer *bufferHandleOut,
VkDeviceSize *bufferOffsetOut);
void release(RendererVk *renderer);
void destroy(VkDevice device);
static void Draw(uint32_t count, CommandBuffer *commandBuffer);