diff --git a/src/libANGLE/renderer/vulkan/ContextVk.cpp b/src/libANGLE/renderer/vulkan/ContextVk.cpp index 29290743e73..d630dd7d0bc 100644 --- a/src/libANGLE/renderer/vulkan/ContextVk.cpp +++ b/src/libANGLE/renderer/vulkan/ContextVk.cpp @@ -1273,9 +1273,6 @@ void ContextVk::onDestroy(const gl::Context *context) mRenderer->recycleOutsideRenderPassCommandBufferHelper(&mOutsideRenderPassCommands); mRenderer->recycleRenderPassCommandBufferHelper(&mRenderPassCommands); - mVertexInputGraphicsPipelineCache.destroy(this); - mFragmentOutputGraphicsPipelineCache.destroy(this); - mInterfacePipelinesCache.destroy(device); mUtils.destroy(this); @@ -2177,15 +2174,17 @@ angle::Result ContextVk::createGraphicsPipeline() ANGLE_TRY(CreateGraphicsPipelineSubset( this, *mGraphicsPipelineDesc, mGraphicsPipelineLibraryTransition & kVertexInputTransitionBitsMask, - GraphicsPipelineSubsetRenderPass::Unused, &mVertexInputGraphicsPipelineCache, - interfacePipelineCache, &mCurrentGraphicsPipelineVertexInput)); + GraphicsPipelineSubsetRenderPass::Unused, + mShareGroupVk->getVertexInputGraphicsPipelineCache(), interfacePipelineCache, + &mCurrentGraphicsPipelineVertexInput)); // Recreate the fragment output subset if necessary ANGLE_TRY(CreateGraphicsPipelineSubset( this, *mGraphicsPipelineDesc, mGraphicsPipelineLibraryTransition & kFragmentOutputTransitionBitsMask, - GraphicsPipelineSubsetRenderPass::Required, &mFragmentOutputGraphicsPipelineCache, - interfacePipelineCache, &mCurrentGraphicsPipelineFragmentOutput)); + GraphicsPipelineSubsetRenderPass::Required, + mShareGroupVk->getFragmentOutputGraphicsPipelineCache(), interfacePipelineCache, + &mCurrentGraphicsPipelineFragmentOutput)); // Link the three subsets into one pipeline. ANGLE_TRY(executableVk->linkGraphicsPipelineLibraries( diff --git a/src/libANGLE/renderer/vulkan/ContextVk.h b/src/libANGLE/renderer/vulkan/ContextVk.h index 0f530f036a1..c238f771689 100644 --- a/src/libANGLE/renderer/vulkan/ContextVk.h +++ b/src/libANGLE/renderer/vulkan/ContextVk.h @@ -1447,11 +1447,6 @@ class ContextVk : public ContextImpl, public vk::Context, public MultisampleText vk::GraphicsPipelineTransitionBits mGraphicsPipelineTransition; vk::GraphicsPipelineTransitionBits mGraphicsPipelineLibraryTransition; - // Used when VK_EXT_graphics_pipeline_library is available, the vertex input and fragment output - // partial pipelines are created in the following caches. - VertexInputGraphicsPipelineCache mVertexInputGraphicsPipelineCache; - FragmentOutputGraphicsPipelineCache mFragmentOutputGraphicsPipelineCache; - // A pipeline cache specifically used for vertex input and fragment output pipelines, when there // is no blob reuse between libraries and monolithic pipelines. In that case, there's no point // in making monolithic pipelines be stored in the same cache as these partial pipelines. diff --git a/src/libANGLE/renderer/vulkan/ShareGroupVk.cpp b/src/libANGLE/renderer/vulkan/ShareGroupVk.cpp index e96c8176876..26a3c1c1c5a 100644 --- a/src/libANGLE/renderer/vulkan/ShareGroupVk.cpp +++ b/src/libANGLE/renderer/vulkan/ShareGroupVk.cpp @@ -157,7 +157,8 @@ angle::Result ShareGroupVk::updateContextsPriority(ContextVk *contextVk, void ShareGroupVk::onDestroy(const egl::Display *display) { - vk::Renderer *renderer = vk::GetImpl(display)->getRenderer(); + DisplayVk *displayVk = vk::GetImpl(display); + vk::Renderer *renderer = displayVk->getRenderer(); for (std::unique_ptr &pool : mDefaultBufferPools) { @@ -179,6 +180,9 @@ void ShareGroupVk::onDestroy(const egl::Display *display) mFramebufferCache.destroy(renderer); resetPrevTexture(); + + mVertexInputGraphicsPipelineCache.destroy(displayVk); + mFragmentOutputGraphicsPipelineCache.destroy(displayVk); } angle::Result ShareGroupVk::onMutableTextureUpload(ContextVk *contextVk, TextureVk *newTexture) diff --git a/src/libANGLE/renderer/vulkan/ShareGroupVk.h b/src/libANGLE/renderer/vulkan/ShareGroupVk.h index fee113b221c..43bfb42250c 100644 --- a/src/libANGLE/renderer/vulkan/ShareGroupVk.h +++ b/src/libANGLE/renderer/vulkan/ShareGroupVk.h @@ -82,6 +82,15 @@ class ShareGroupVk : public ShareGroupImpl void onTextureRelease(TextureVk *textureVk); + VertexInputGraphicsPipelineCache *getVertexInputGraphicsPipelineCache() + { + return &mVertexInputGraphicsPipelineCache; + } + FragmentOutputGraphicsPipelineCache *getFragmentOutputGraphicsPipelineCache() + { + return &mFragmentOutputGraphicsPipelineCache; + } + angle::Result scheduleMonolithicPipelineCreationTask( ContextVk *contextVk, vk::WaitableMonolithicPipelineCreationTask *taskOut); @@ -117,6 +126,13 @@ class ShareGroupVk : public ShareGroupImpl // The system time when last pruneEmptyBuffer gets called. double mLastPruneTime; + // Used when VK_EXT_graphics_pipeline_library is available, the vertex input and fragment output + // partial pipelines are created in the following caches. These caches are in the share group + // because linked pipelines using these pipeline libraries are referenced from + // ProgramExecutableVk, and as such must stay alive as long as the program may be alive. + VertexInputGraphicsPipelineCache mVertexInputGraphicsPipelineCache; + FragmentOutputGraphicsPipelineCache mFragmentOutputGraphicsPipelineCache; + // The system time when the last monolithic pipeline creation job was launched. This is // rate-limited to avoid hogging all cores and interfering with the application threads. A // single pipeline creation job is currently supported.