Hash :
a56467e0
Author :
Date :
2018-04-11T16:19:41
VertexArray: Use switch macro for faster iteration. Has a small but noticeable impact on performance on a microbenchmark. Seems to improve a synthetic score by about 1%. Should have a very small improvement in real-world performance. Note that the odd formatting is an idiosyncrasy of clang-format. Bug: angleproject:2389 Change-Id: I888bf101c6d8b80a0fbafdb9c5a84205c9c8fee6 Reviewed-on: https://chromium-review.googlesource.com/962963 Reviewed-by: Luc Ferron <lucferron@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// VertexArrayVk.h:
// Defines the class interface for VertexArrayVk, implementing VertexArrayImpl.
//
#ifndef LIBANGLE_RENDERER_VULKAN_VERTEXARRAYVK_H_
#define LIBANGLE_RENDERER_VULKAN_VERTEXARRAYVK_H_
#include "libANGLE/renderer/VertexArrayImpl.h"
#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
#include "libANGLE/renderer/vulkan/vk_helpers.h"
namespace gl
{
class DrawCallParams;
} // namespace gl
namespace rx
{
class BufferVk;
namespace vk
{
class CommandGraphResource;
class DynamicBuffer;
} // namespace vk
class VertexArrayVk : public VertexArrayImpl
{
public:
VertexArrayVk(const gl::VertexArrayState &state);
~VertexArrayVk() override;
void destroy(const gl::Context *context) override;
gl::Error syncState(const gl::Context *context,
const gl::VertexArray::DirtyBits &dirtyBits,
const gl::VertexArray::DirtyAttribBitsArray &attribBits,
const gl::VertexArray::DirtyBindingBitsArray &bindingBits) override;
const gl::AttribArray<VkBuffer> &getCurrentArrayBufferHandles() const;
const gl::AttribArray<VkDeviceSize> &getCurrentArrayBufferOffsets() const;
void updateDrawDependencies(vk::CommandGraphNode *readingNode,
const gl::AttributesMask &activeAttribsMask,
vk::CommandGraphResource *elementArrayBufferOverride,
Serial serial,
bool isDrawElements);
void getPackedInputDescriptions(vk::PipelineDesc *pipelineDesc);
// Draw call handling.
gl::Error drawArrays(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode *drawNode,
bool newCommandBuffer);
gl::Error drawElements(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode *drawNode,
bool newCommandBuffer);
private:
// This will update any dirty packed input descriptions, regardless if they're used by the
// active program. This could lead to slight inefficiencies when the app would repeatedly
// update vertex info for attributes the program doesn't use, (very silly edge case). The
// advantage is the cached state then doesn't depend on the Program, so doesn't have to be
// updated when the active Program changes.
void updatePackedInputDescriptions();
void updatePackedInputInfo(uint32_t attribIndex,
const gl::VertexBinding &binding,
const gl::VertexAttribute &attrib);
void updateArrayBufferReadDependencies(vk::CommandGraphNode *drawNode,
const gl::AttributesMask &activeAttribsMask,
Serial serial);
void updateElementArrayBufferReadDependency(vk::CommandGraphNode *drawNode, Serial serial);
gl::Error streamVertexData(RendererVk *renderer,
const gl::AttributesMask &attribsToStream,
const gl::DrawCallParams &drawCallParams);
gl::Error streamIndexData(RendererVk *renderer, const gl::DrawCallParams &drawCallParams);
gl::Error onDraw(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode *drawNode,
bool newCommandBuffer);
gl::Error onIndexedDraw(const gl::Context *context,
RendererVk *renderer,
const gl::DrawCallParams &drawCallParams,
vk::CommandGraphNode *drawNode,
bool newCommandBuffer);
void syncDirtyAttrib(const gl::VertexAttribute &attrib,
const gl::VertexBinding &binding,
size_t attribIndex);
gl::AttribArray<VkBuffer> mCurrentArrayBufferHandles;
gl::AttribArray<VkDeviceSize> mCurrentArrayBufferOffsets;
gl::AttribArray<vk::CommandGraphResource *> mCurrentArrayBufferResources;
VkBuffer mCurrentElementArrayBufferHandle;
VkDeviceSize mCurrentElementArrayBufferOffset;
vk::CommandGraphResource *mCurrentElementArrayBufferResource;
// Keep a cache of binding and attribute descriptions for easy pipeline updates.
// This is copied out of here into the pipeline description on a Context state change.
gl::AttributesMask mDirtyPackedInputs;
vk::VertexInputBindings mPackedInputBindings;
vk::VertexInputAttributes mPackedInputAttributes;
// Which attributes need to be copied from client memory.
// TODO(jmadill): Move this to VertexArrayState. http://anglebug.com/1391
gl::AttributesMask mClientMemoryAttribs;
vk::DynamicBuffer mDynamicVertexData;
vk::DynamicBuffer mDynamicIndexData;
vk::LineLoopHelper mLineLoopHelper;
Optional<int> mLineLoopBufferFirstIndex;
Optional<int> mLineLoopBufferLastIndex;
bool mDirtyLineLoopTranslation;
// Cache variable for determining whether or not to store new dependencies in the node.
bool mVertexBuffersDirty;
bool mIndexBufferDirty;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_VERTEXARRAYVK_H_