Vulkan: Optimize Attribute Change Perf (3/5)

This patch series optimizes programs that use the pattern:

for (;;) {
  glVertexAttribPointer(...)
  glDraw(...)
}

Change 3: Use FastUnorderedSet for RP XFB buffers.

Most of the time this list is empty. This speeds up the count check for
empty and non-empty sets considerably.

In total the patch series reduces test iteration time by 25%.

Test: DrawCallPerfBenchmark.Run/vulkan_attrib_change
Bug: angleproject:5045
Bug: b/168493024
Change-Id: Ia43eb11bdd62aa3bf425069b591f9318f519fd4c
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2409175
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Tim Van Patten <timvp@google.com>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Jamie Madill 2020-09-13 23:15:40 -04:00 коммит произвёл Commit Bot
Родитель d6806d732d
Коммит d79db25910
2 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -3460,7 +3460,7 @@ angle::Result ContextVk::onBeginTransformFeedback(
for (size_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex)
{
const vk::BufferHelper *buffer = buffers[bufferIndex];
if (mCurrentTransformFeedbackBuffers.count(buffer) != 0 ||
if (mCurrentTransformFeedbackBuffers.contains(buffer) ||
mRenderPassCommands->usesBuffer(*buffer))
{
ANGLE_TRY(flushCommandsAndEndRenderPass());
@ -3484,7 +3484,11 @@ void ContextVk::populateTransformFeedbackBufferSet(
{
for (size_t bufferIndex = 0; bufferIndex < bufferCount; ++bufferIndex)
{
mCurrentTransformFeedbackBuffers.insert(buffers[bufferIndex]);
vk::BufferHelper *buffer = buffers[bufferIndex];
if (!mCurrentTransformFeedbackBuffers.contains(buffer))
{
mCurrentTransformFeedbackBuffers.insert(buffer);
}
}
}

Просмотреть файл

@ -1063,7 +1063,9 @@ class ContextVk : public ContextImpl, public vk::Context
bool mHasPrimaryCommands;
// Transform feedback buffers.
std::unordered_set<const vk::BufferHelper *> mCurrentTransformFeedbackBuffers;
angle::FastUnorderedSet<const vk::BufferHelper *,
gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS>
mCurrentTransformFeedbackBuffers;
// Internal shader library.
vk::ShaderLibrary mShaderLibrary;
@ -1131,7 +1133,7 @@ class ContextVk : public ContextImpl, public vk::Context
ANGLE_INLINE angle::Result ContextVk::endRenderPassIfTransformFeedbackBuffer(
const vk::BufferHelper *buffer)
{
if (!buffer || mCurrentTransformFeedbackBuffers.count(buffer) == 0)
if (!buffer || !mCurrentTransformFeedbackBuffers.contains(buffer))
{
return angle::Result::Continue;
}