diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp index 8cc877424ead1..58a9c8a6f7b9b 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp @@ -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); diff --git a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp index 2277489a706c8..bc72881ff539d 100644 --- a/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp @@ -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; diff --git a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp index 0546a56548331..bbd403622f647 100644 --- a/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp +++ b/src/libANGLE/renderer/d3d/d3d9/Renderer9.cpp @@ -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(¤tTime); } freeEventQuery(query); diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp index b7d373a93b692..e230ad29678b8 100644 --- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp +++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp @@ -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, diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp index e39b3410cadfb..3748816f478f3 100644 --- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp +++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp @@ -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, diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.cpp b/src/libANGLE/renderer/vulkan/vk_helpers.cpp index 0866cede07e4d..fce2f6489e76e 100644 --- a/src/libANGLE/renderer/vulkan/vk_helpers.cpp +++ b/src/libANGLE/renderer/vulkan/vk_helpers.cpp @@ -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); diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.h b/src/libANGLE/renderer/vulkan/vk_helpers.h index 5e2f6c0fb57d9..2950f3bb5cb98 100644 --- a/src/libANGLE/renderer/vulkan/vk_helpers.h +++ b/src/libANGLE/renderer/vulkan/vk_helpers.h @@ -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);