Vulkan: Store reference to context command buffer.
This frees us from checking the FB every draw. Slightly reduces time
spent in all draw methods. Improvement seen on the draw call overhead
tests. Scores went from 28.17 ns/draw to 26.76 ns/draw on my machine.
In a future improvement we could make this command buffer a dirty bit.
Currently it's a bit slower to call a handler function due to the
dispatch table. Likely we could optimize this by reverting back to a
dirty bit switch and inlining the handler functions. That is left for
future work.
Vulkan is happy enough to run multiple RenderPasses and bind different
Pipelines in the same command buffer. But ANGLE defers RenderPass init
until we submit our work. Thus we can only support one RenderPass per
secondary buffer.
Test: angle_perftests DrawCall*/vulkan_null
Bug: angleproject:3014
Change-Id: I89fd0d9e0822400a5c5a16acb5a9c400a0e71ab5
Reviewed-on: https://chromium-review.googlesource.com/c/1393905
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.cpp b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
index 03f4ff1..979b1e7 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.cpp
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.cpp
@@ -11,6 +11,7 @@
#include <iostream>
+#include "libANGLE/renderer/vulkan/ContextVk.h"
#include "libANGLE/renderer/vulkan/RenderTargetVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
@@ -138,7 +139,7 @@
return mCurrentWritingNode->getRenderPassRenderArea();
}
-angle::Result RecordableGraphResource::beginRenderPass(Context *context,
+angle::Result RecordableGraphResource::beginRenderPass(ContextVk *contextVk,
const Framebuffer &framebuffer,
const gl::Rectangle &renderArea,
const RenderPassDesc &renderPassDesc,
@@ -148,14 +149,16 @@
// If a barrier has been inserted in the meantime, stop the command buffer.
if (!hasChildlessWritingNode())
{
- startNewCommands(context->getRenderer());
+ startNewCommands(contextVk->getRenderer());
}
// Hard-code RenderPass to clear the first render target to the current clear value.
// TODO(jmadill): Proper clear value implementation. http://anglebug.com/2361
mCurrentWritingNode->storeRenderPassInfo(framebuffer, renderArea, renderPassDesc, clearValues);
- return mCurrentWritingNode->beginInsideRenderPassRecording(context, commandBufferOut);
+ mCurrentWritingNode->setCommandBufferOwner(contextVk);
+
+ return mCurrentWritingNode->beginInsideRenderPassRecording(contextVk, commandBufferOut);
}
void RecordableGraphResource::addWriteDependency(RecordableGraphResource *writingResource)
@@ -263,7 +266,8 @@
mHasChildren(false),
mVisitedState(VisitedState::Unvisited),
mGlobalMemoryBarrierSrcAccess(0),
- mGlobalMemoryBarrierDstAccess(0)
+ mGlobalMemoryBarrierDstAccess(0),
+ mCommandBufferOwner(nullptr)
{}
CommandGraphNode::~CommandGraphNode()