Skip to content

Commit

Permalink
Selectively wait for post-link tasks in the frontend
Browse files Browse the repository at this point in the history
The frontend waits for post-link tasks only for a relink or in
syncState when `disableProgramCaching` feature is not enabled.

Bug: angleproject:8297
Change-Id: If7a3b8a10a2d01f82fd2bebac5c8f378be56e19e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5427001
Reviewed-by: Charlie Lao <[email protected]>
Commit-Queue: mohan maiya <[email protected]>
Reviewed-by: Shahbaz Youssefi <[email protected]>
  • Loading branch information
Mohan Maiya authored and Angle LUCI CQ committed Apr 6, 2024
1 parent 06472a7 commit 924b40d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/libANGLE/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2073,9 +2073,13 @@ bool Program::linkAttributes(const Caps &caps,
angle::Result Program::syncState(const Context *context)
{
ASSERT(!mLinkingState);
// Wait for the link tasks. This is because these optimization passes are not currently
// thread-safe with draw's usage of the executable.
waitForPostLinkTasks(context);

if (!context->getFrontendFeatures().disableProgramCaching.enabled)
{
// Blob cache tests rely on an implicit caching of the program
waitForPostLinkTasks(context);
}

return angle::Result::Continue;
}

Expand Down Expand Up @@ -2149,10 +2153,6 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
}
}

// Need to wait for post-link tasks because they may be writing to caches that |serialize| would
// read from. In the Vulkan backend, that would be the VkPipelineCache contents.
waitForPostLinkTasks(context);

mProgram->save(context, &stream);
ASSERT(mState.mExecutable->mPostLinkSubTasks.empty());

Expand Down
7 changes: 5 additions & 2 deletions src/libANGLE/renderer/vulkan/ContextVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,6 @@ angle::Result ContextVk::setupDraw(const gl::Context *context,
{
mGraphicsDirtyBits.set(DIRTY_BIT_UNIFORMS);
}
ASSERT(mState.getProgram() == nullptr || !mState.getProgram()->needsSync());

// Update transform feedback offsets on every draw call when emulating transform feedback. This
// relies on the fact that no geometry/tessellation, indirect or indexed calls are supported in
Expand Down Expand Up @@ -1821,7 +1820,6 @@ angle::Result ContextVk::setupDispatch(const gl::Context *context)
mComputeDirtyBits.set(DIRTY_BIT_UNIFORMS);
mComputeDirtyBits.set(DIRTY_BIT_DESCRIPTOR_SETS);
}
ASSERT(mState.getProgram() == nullptr || !mState.getProgram()->needsSync());

DirtyBits dirtyBits = mComputeDirtyBits;

Expand Down Expand Up @@ -2080,6 +2078,9 @@ angle::Result ContextVk::createGraphicsPipeline()
ProgramExecutableVk *executableVk = vk::GetImpl(mState.getProgramExecutable());
ASSERT(executableVk);

// Wait for any warmup task if necessary
executableVk->waitForPostLinkTasksIfNecessary(this, mGraphicsPipelineDesc.get());

vk::PipelineCacheAccess pipelineCache;
ANGLE_TRY(mRenderer->getPipelineCache(this, &pipelineCache));

Expand Down Expand Up @@ -2478,6 +2479,8 @@ angle::Result ContextVk::handleDirtyComputePipelineDesc(DirtyBits::Iterator *dir

ProgramExecutableVk *executableVk = vk::GetImpl(mState.getProgramExecutable());
ASSERT(executableVk);

executableVk->waitForPostLinkTasksIfNecessary(this, nullptr);
ANGLE_TRY(executableVk->getOrCreateComputePipeline(
this, &pipelineCache, PipelineSource::Draw, pipelineRobustness(),
pipelineProtectedAccess(), &mCurrentComputePipeline));
Expand Down
3 changes: 3 additions & 0 deletions src/libANGLE/renderer/vulkan/ProgramExecutableVk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ void ProgramExecutableVk::save(ContextVk *contextVk,
{
angle::MemoryBuffer cacheData;

// Need to wait for warm up tasks to complete.
waitForPostLinkTasksImpl(contextVk);

GetPipelineCacheData(contextVk, mPipelineCache, &cacheData);
stream->writeInt(cacheData.size());
if (cacheData.size() > 0)
Expand Down

0 comments on commit 924b40d

Please sign in to comment.