Commit 84fce18c by Jamie Madill Committed by Commit Bot

Vulkan: Give CommandQueue an abstract interface.

This gives CommandQueue and CommandProcessor the exact same interface. This also moves the worker thread to be owned by CommandProcessor. Bug: b/172704839 Change-Id: Ife439bcf52d923e01a6a2166e0caaffce14fd086 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2537235 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarTim Van Patten <timvp@google.com>
parent 59bddcfb
......@@ -527,9 +527,6 @@ void ContextVk::onDestroy(const gl::Context *context)
mShaderLibrary.destroy(device);
mGpuEventQueryPool.destroy(device);
mCommandPool.destroy(device);
// This will clean up any outstanding buffer allocations
(void)mRenderer->clearAllGarbage(this);
}
angle::Result ContextVk::getIncompleteTexture(const gl::Context *context,
......@@ -1842,13 +1839,12 @@ void ContextVk::flushGpuEvents(double nextSyncGpuTimestampS, double nextSyncCpuT
void ContextVk::clearAllGarbage()
{
ANGLE_TRACE_EVENT0("gpu.angle", "ContextVk::finishAllWork");
ANGLE_TRACE_EVENT0("gpu.angle", "ContextVk::clearAllGarbage");
for (vk::GarbageObject &garbage : mCurrentGarbage)
{
garbage.destroy(mRenderer);
}
mCurrentGarbage.clear();
mRenderer->clearAllGarbage(this);
}
void ContextVk::handleDeviceLost()
......@@ -3035,7 +3031,7 @@ angle::Result ContextVk::onUnMakeCurrent(const gl::Context *context)
if (mRenderer->getFeatures().asyncCommandQueue.enabled)
{
ANGLE_TRACE_EVENT0("gpu.angle", "ContextVk::onUnMakeCurrent");
mRenderer->finishAllWork(this);
ANGLE_TRY(mRenderer->finishAllWork(this));
}
mCurrentWindowSurface = nullptr;
return angle::Result::Continue;
......
......@@ -260,10 +260,10 @@ void DisplayVk::handleError(VkResult result,
{
ASSERT(result != VK_SUCCESS);
mSavedError.mErrorCode = result;
mSavedError.mFile = file;
mSavedError.mFunction = function;
mSavedError.mLine = line;
mSavedError.errorCode = result;
mSavedError.file = file;
mSavedError.function = function;
mSavedError.line = line;
if (result == VK_ERROR_DEVICE_LOST)
{
......@@ -277,10 +277,9 @@ void DisplayVk::handleError(VkResult result,
egl::Error DisplayVk::getEGLError(EGLint errorCode)
{
std::stringstream errorStream;
errorStream << "Internal Vulkan error (" << mSavedError.mErrorCode
<< "): " << VulkanResultString(mSavedError.mErrorCode) << ", in "
<< mSavedError.mFile << ", " << mSavedError.mFunction << ":" << mSavedError.mLine
<< ".";
errorStream << "Internal Vulkan error (" << mSavedError.errorCode
<< "): " << VulkanResultString(mSavedError.errorCode) << ", in " << mSavedError.file
<< ", " << mSavedError.function << ":" << mSavedError.line << ".";
std::string errorString = errorStream.str();
return egl::Error(errorCode, 0, std::move(errorString));
......
......@@ -190,7 +190,7 @@ angle::Result QueryVk::getResult(const gl::Context *context, bool wait)
if (renderer->getFeatures().asyncCommandQueue.enabled)
{
// TODO: https://issuetracker.google.com/170312581 - For now just stalling here
renderer->waitForCommandProcessorIdle(contextVk);
ANGLE_TRY(renderer->waitForCommandProcessorIdle(contextVk));
}
ASSERT(!mQueryHelperTimeElapsedBegin.hasPendingWork(contextVk));
......
......@@ -281,21 +281,20 @@ class RendererVk : angle::NonCopyable
SamplerYcbcrConversionCache &getYuvConversionCache() { return mYuvConversionCache; }
vk::ActiveHandleCounter &getActiveHandleCounts() { return mActiveHandleCounts; }
// Queue commands to worker thread for processing
void queueCommand(vk::Context *context, vk::CommandProcessorTask *command)
// TODO(jmadill): Remove. b/172704839
angle::Result waitForCommandProcessorIdle(vk::Context *context)
{
mCommandProcessor.queueCommand(context, command);
ASSERT(getFeatures().asyncCommandQueue.enabled);
return mCommandProcessor.waitForWorkComplete(context);
}
bool hasPendingError() const { return mCommandProcessor.hasPendingError(); }
vk::Error getAndClearPendingError() { return mCommandProcessor.getAndClearPendingError(); }
void waitForCommandProcessorIdle(vk::Context *context)
// TODO(jmadill): Remove. b/172704839
angle::Result finishAllWork(vk::Context *context)
{
ASSERT(getFeatures().asyncCommandQueue.enabled);
mCommandProcessor.waitForWorkComplete(context);
return mCommandProcessor.finishAllWork(context);
}
void finishAllWork(vk::Context *context) { mCommandProcessor.finishAllWork(context); }
bool getEnableValidationLayers() const { return mEnableValidationLayers; }
vk::ResourceSerialFactory &getResourceSerialFactory() { return mResourceSerialFactory; }
......@@ -315,7 +314,6 @@ class RendererVk : angle::NonCopyable
vk::GarbageList &&currentGarbage,
vk::CommandPool *commandPool);
void clearAllGarbage(vk::Context *context);
void handleDeviceLost();
angle::Result finishToSerial(vk::Context *context, Serial serial);
angle::Result waitForSerialWithUserTimeout(vk::Context *context,
......@@ -357,12 +355,6 @@ class RendererVk : angle::NonCopyable
template <VkFormatFeatureFlags VkFormatProperties::*features>
bool hasFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits) const;
// Sync any errors from the command processor
void commandProcessorSyncErrors(vk::Context *context);
// Sync any error from worker thread and queue up next command for processing
void commandProcessorSyncErrorsAndQueueCommand(vk::Context *context,
vk::CommandProcessorTask *command);
egl::Display *mDisplay;
mutable bool mCapsInitialized;
......@@ -456,9 +448,8 @@ class RendererVk : angle::NonCopyable
std::mutex mCommandBufferHelperFreeListMutex;
std::vector<vk::CommandBufferHelper *> mCommandBufferHelperFreeList;
// Command Processor Thread
// Async Command Queue
vk::CommandProcessor mCommandProcessor;
std::thread mCommandProcessorThread;
// mNextSubmitFence is the fence that's going to be signaled at the next submission. This is
// used to support SyncVk objects, which may outlive the context (as EGLSync objects).
vk::Shared<vk::Fence> mNextSubmitFence;
......
......@@ -37,7 +37,7 @@ void SyncHelper::releaseToRenderer(RendererVk *renderer)
if (renderer->getFeatures().asyncCommandQueue.enabled)
{
ANGLE_TRACE_EVENT0("gpu.angle", "SyncHelper::releaseToRenderer");
renderer->waitForCommandProcessorIdle(nullptr);
(void)renderer->waitForCommandProcessorIdle(nullptr);
}
}
......@@ -272,7 +272,7 @@ angle::Result SyncHelperNativeFence::clientWait(Context *context,
if (contextVk->getRenderer()->getFeatures().asyncCommandQueue.enabled)
{
ANGLE_TRACE_EVENT0("gpu.angle", "SyncHelperNativeFence::clientWait");
contextVk->getRenderer()->waitForCommandProcessorIdle(contextVk);
ANGLE_TRY(contextVk->getRenderer()->waitForCommandProcessorIdle(contextVk));
}
// Wait for mFenceWithFd to be signaled.
......
......@@ -156,10 +156,10 @@ void AddToPNextChain(VulkanStruct1 *chainStart, VulkanStruct2 *ptr)
struct Error
{
VkResult mErrorCode;
const char *mFile;
const char *mFunction;
unsigned int mLine;
VkResult errorCode;
const char *file;
const char *function;
uint32_t line;
};
// Abstracts error handling. Implemented by both ContextVk for GL and DisplayVk for EGL errors.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment