Skip to content

Commit

Permalink
Vulkan: Move the interface pipeline library caches to share group
Browse files Browse the repository at this point in the history
When linking libraries into a pipeline, the linked pipeline lives in
ProgramExecutableVk and may be shared between contexts in a share group.
The caches for the vertex input and fragment output libraries thus
cannot live in the context, but should remain alive until all contexts
in the share group are destroyed.

This change moves these caches to the share group.

Bug: angleproject:8629
Change-Id: I2f7edf44d676505cf5e7e24640c6850c67f8b5e3
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5401514
Commit-Queue: Charlie Lao <[email protected]>
Reviewed-by: Charlie Lao <[email protected]>
Auto-Submit: Shahbaz Youssefi <[email protected]>
  • Loading branch information
ShabbyX authored and Angle LUCI CQ committed Mar 28, 2024
1 parent c71a67d commit b4cf07c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
13 changes: 6 additions & 7 deletions src/libANGLE/renderer/vulkan/ContextVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 0 additions & 5 deletions src/libANGLE/renderer/vulkan/ContextVk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion src/libANGLE/renderer/vulkan/ShareGroupVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<vk::BufferPool> &pool : mDefaultBufferPools)
{
Expand All @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions src/libANGLE/renderer/vulkan/ShareGroupVk.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit b4cf07c

Please sign in to comment.