blob: 14cf9c98641ec0d27ff04ef4973a011ba02d9e5c [file] [log] [blame]
Jamie Madill1f46bc12018-02-20 16:09:43 -05001//
2// Copyright 2017 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6// CommandGraph:
7// Deferred work constructed by GL calls, that will later be flushed to Vulkan.
8//
9
10#ifndef LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_
11#define LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_
12
13#include "libANGLE/renderer/vulkan/vk_cache_utils.h"
14
15namespace rx
16{
17
18namespace vk
19{
Jamie Madill3d61ac22018-08-28 16:58:55 -040020enum class VisitedState
21{
22 Unvisited,
23 Ready,
24 Visited,
25};
26
Jamie Madill0da73fe2018-10-02 09:31:39 -040027enum class CommandGraphResourceType
28{
29 Buffer,
30 Framebuffer,
31 Image,
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -040032 Query,
Shahbaz Youssefi82fddcb2019-01-18 14:27:43 -050033 FenceSync,
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -040034};
35
36// Certain functionality cannot be put in secondary command buffers, so they are special-cased in
37// the node.
38enum class CommandGraphNodeFunction
39{
40 Generic,
41 BeginQuery,
42 EndQuery,
Shahbaz Youssefic2b576d2018-10-12 14:45:34 -040043 WriteTimestamp,
Shahbaz Youssefi82fddcb2019-01-18 14:27:43 -050044 SetFenceSync,
45 WaitFenceSync,
Jamie Madill0da73fe2018-10-02 09:31:39 -040046};
47
Jamie Madill85ca1892019-01-16 13:27:15 -050048// Receives notifications when a command buffer is no longer able to record. Can be used with
49// inheritance. Faster than using an interface class since it has inlined methods. Could be used
50// with composition by adding a getCommandBuffer method.
51class CommandBufferOwner
52{
53 public:
54 CommandBufferOwner() = default;
55 virtual ~CommandBufferOwner() {}
56
57 ANGLE_INLINE void onCommandBufferFinished() { mCommandBuffer = nullptr; }
58
59 protected:
60 vk::CommandBuffer *mCommandBuffer = nullptr;
61};
62
Jamie Madill3d61ac22018-08-28 16:58:55 -040063// Only used internally in the command graph. Kept in the header for better inlining performance.
64class CommandGraphNode final : angle::NonCopyable
65{
66 public:
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -040067 CommandGraphNode(CommandGraphNodeFunction function);
Jamie Madill3d61ac22018-08-28 16:58:55 -040068 ~CommandGraphNode();
69
70 // Immutable queries for when we're walking the commands tree.
71 CommandBuffer *getOutsideRenderPassCommands();
72
73 CommandBuffer *getInsideRenderPassCommands()
74 {
75 ASSERT(!mHasChildren);
76 return &mInsideRenderPassCommands;
77 }
78
79 // For outside the render pass (copies, transitions, etc).
80 angle::Result beginOutsideRenderPassRecording(Context *context,
81 const CommandPool &commandPool,
82 CommandBuffer **commandsOut);
83
84 // For rendering commands (draws).
85 angle::Result beginInsideRenderPassRecording(Context *context, CommandBuffer **commandsOut);
86
87 // storeRenderPassInfo and append*RenderTarget store info relevant to the RenderPass.
88 void storeRenderPassInfo(const Framebuffer &framebuffer,
89 const gl::Rectangle renderArea,
90 const vk::RenderPassDesc &renderPassDesc,
91 const std::vector<VkClearValue> &clearValues);
92
93 // Dependency commands order node execution in the command graph.
94 // Once a node has commands that must happen after it, recording is stopped and the node is
95 // frozen forever.
96 static void SetHappensBeforeDependency(CommandGraphNode *beforeNode,
Jamie Madillc759b8b2019-01-03 15:16:50 -050097 CommandGraphNode *afterNode)
98 {
99 ASSERT(beforeNode != afterNode && !beforeNode->isChildOf(afterNode));
100 afterNode->mParents.emplace_back(beforeNode);
101 beforeNode->setHasChildren();
102 }
103
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400104 static void SetHappensBeforeDependencies(CommandGraphNode **beforeNodes,
105 size_t beforeNodesCount,
Jamie Madill3d61ac22018-08-28 16:58:55 -0400106 CommandGraphNode *afterNode);
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400107 static void SetHappensBeforeDependencies(CommandGraphNode *beforeNode,
108 CommandGraphNode **afterNodes,
109 size_t afterNodesCount);
Jamie Madill3d61ac22018-08-28 16:58:55 -0400110 bool hasParents() const;
111 bool hasChildren() const { return mHasChildren; }
112
113 // Commands for traversing the node on a flush operation.
114 VisitedState visitedState() const;
115 void visitParents(std::vector<CommandGraphNode *> *stack);
116 angle::Result visitAndExecute(Context *context,
117 Serial serial,
118 RenderPassCache *renderPassCache,
119 CommandBuffer *primaryCommandBuffer);
120
Jamie Madill0da73fe2018-10-02 09:31:39 -0400121 // Only used in the command graph diagnostics.
122 const std::vector<CommandGraphNode *> &getParentsForDiagnostics() const;
123 void setDiagnosticInfo(CommandGraphResourceType resourceType, uintptr_t resourceID);
124
125 CommandGraphResourceType getResourceTypeForDiagnostics() const { return mResourceType; }
126 uintptr_t getResourceIDForDiagnostics() const { return mResourceID; }
127
Jamie Madill3d61ac22018-08-28 16:58:55 -0400128 const gl::Rectangle &getRenderPassRenderArea() const;
129
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400130 CommandGraphNodeFunction getFunction() const { return mFunction; }
131
132 void setQueryPool(const QueryPool *queryPool, uint32_t queryIndex);
Shahbaz Youssefi82fddcb2019-01-18 14:27:43 -0500133 void setFenceSync(const vk::Event &event);
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400134
Jamie Madillc759b8b2019-01-03 15:16:50 -0500135 ANGLE_INLINE void addGlobalMemoryBarrier(VkFlags srcAccess, VkFlags dstAccess)
136 {
137 mGlobalMemoryBarrierSrcAccess |= srcAccess;
138 mGlobalMemoryBarrierDstAccess |= dstAccess;
139 }
Jamie Madill03d1a5e2018-11-12 11:34:24 -0500140
Jamie Madill85ca1892019-01-16 13:27:15 -0500141 // This can only be set for RenderPass nodes. Each RenderPass node can have at most one owner.
142 void setCommandBufferOwner(CommandBufferOwner *owner)
143 {
144 ASSERT(mCommandBufferOwner == nullptr);
145 mCommandBufferOwner = owner;
146 }
147
Jamie Madill3d61ac22018-08-28 16:58:55 -0400148 private:
Jamie Madill85ca1892019-01-16 13:27:15 -0500149 ANGLE_INLINE void setHasChildren()
150 {
151 mHasChildren = true;
152 if (mCommandBufferOwner)
153 {
154 mCommandBufferOwner->onCommandBufferFinished();
155 }
156 }
Jamie Madill3d61ac22018-08-28 16:58:55 -0400157
158 // Used for testing only.
159 bool isChildOf(CommandGraphNode *parent);
160
161 // Only used if we need a RenderPass for these commands.
162 RenderPassDesc mRenderPassDesc;
163 Framebuffer mRenderPassFramebuffer;
164 gl::Rectangle mRenderPassRenderArea;
165 gl::AttachmentArray<VkClearValue> mRenderPassClearValues;
166
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400167 CommandGraphNodeFunction mFunction;
168
169 // Keep separate buffers for commands inside and outside a RenderPass.
Jamie Madill3d61ac22018-08-28 16:58:55 -0400170 // TODO(jmadill): We might not need inside and outside RenderPass commands separate.
171 CommandBuffer mOutsideRenderPassCommands;
172 CommandBuffer mInsideRenderPassCommands;
173
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400174 // Special-function additional data:
Shahbaz Youssefi82fddcb2019-01-18 14:27:43 -0500175 // Queries:
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400176 VkQueryPool mQueryPool;
177 uint32_t mQueryIndex;
Shahbaz Youssefi82fddcb2019-01-18 14:27:43 -0500178 // GLsync and EGLSync:
179 VkEvent mFenceSyncEvent;
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400180
Jamie Madill3d61ac22018-08-28 16:58:55 -0400181 // Parents are commands that must be submitted before 'this' CommandNode can be submitted.
182 std::vector<CommandGraphNode *> mParents;
183
184 // If this is true, other commands exist that must be submitted after 'this' command.
185 bool mHasChildren;
186
187 // Used when traversing the dependency graph.
188 VisitedState mVisitedState;
Jamie Madill0da73fe2018-10-02 09:31:39 -0400189
190 // Additional diagnostic information.
191 CommandGraphResourceType mResourceType;
192 uintptr_t mResourceID;
Jamie Madill03d1a5e2018-11-12 11:34:24 -0500193
194 // For global memory barriers.
195 VkFlags mGlobalMemoryBarrierSrcAccess;
196 VkFlags mGlobalMemoryBarrierDstAccess;
Jamie Madill85ca1892019-01-16 13:27:15 -0500197
198 // Command buffer notifications.
199 CommandBufferOwner *mCommandBufferOwner;
Jamie Madill3d61ac22018-08-28 16:58:55 -0400200};
Jamie Madill1f46bc12018-02-20 16:09:43 -0500201
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400202// This is a helper class for back-end objects used in Vk command buffers. It records a serial
203// at command recording times indicating an order in the queue. We use Fences to detect when
204// commands finish, and then release any unreferenced and deleted resources based on the stored
205// queue serial in a special 'garbage' queue. Resources also track current read and write
206// dependencies. Only one command buffer node can be writing to the Resource at a time, but many
207// can be reading from it. Together the dependencies will form a command graph at submission time.
Jamie Madill0da73fe2018-10-02 09:31:39 -0400208class CommandGraphResource : angle::NonCopyable
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400209{
210 public:
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400211 virtual ~CommandGraphResource();
212
Jamie Madillc57ee252018-05-30 19:53:48 -0400213 // Returns true if the resource is in use by the renderer.
214 bool isResourceInUse(RendererVk *renderer) const;
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400215
Jamie Madill193a2842018-10-30 17:28:41 -0400216 // Get the current queue serial for this resource. Used to release resources, and for
217 // queries, to know if the queue they are submitted on has finished execution.
Jamie Madillc759b8b2019-01-03 15:16:50 -0500218 Serial getStoredQueueSerial() const { return mStoredQueueSerial; }
Jamie Madill193a2842018-10-30 17:28:41 -0400219
Jamie Madilld014c9e2018-05-18 15:15:59 -0400220 // Sets up dependency relations. 'this' resource is the resource being written to.
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500221 void addWriteDependency(CommandGraphResource *writingResource);
Jamie Madilld014c9e2018-05-18 15:15:59 -0400222
223 // Sets up dependency relations. 'this' resource is the resource being read.
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500224 void addReadDependency(CommandGraphResource *readingResource);
Jamie Madilld014c9e2018-05-18 15:15:59 -0400225
Shahbaz Youssefi254b32c2018-11-26 11:58:03 -0500226 // Updates the in-use serial tracked for this resource. Will clear dependencies if the resource
227 // was not used in this set of command nodes.
Jamie Madillc759b8b2019-01-03 15:16:50 -0500228 ANGLE_INLINE void updateQueueSerial(Serial queueSerial)
229 {
230 ASSERT(queueSerial >= mStoredQueueSerial);
231
232 if (queueSerial > mStoredQueueSerial)
233 {
234 mCurrentWritingNode = nullptr;
235 mCurrentReadingNodes.clear();
236 mStoredQueueSerial = queueSerial;
237 }
238 }
Shahbaz Youssefi254b32c2018-11-26 11:58:03 -0500239
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400240 // Allocates a write node via getNewWriteNode and returns a started command buffer.
241 // The started command buffer will render outside of a RenderPass.
Jamie Madille2d22702018-09-19 08:11:48 -0400242 // Will append to an existing command buffer/graph node if possible.
243 angle::Result recordCommands(Context *context, CommandBuffer **commandBufferOut);
Jamie Madill316c6062018-05-29 10:49:45 -0400244
245 // Begins a command buffer on the current graph node for in-RenderPass rendering.
Shahbaz Youssefif83a28a2018-12-09 03:48:34 +0100246 // Called from FramebufferVk::startNewRenderPass and UtilsVk functions.
Jamie Madill85ca1892019-01-16 13:27:15 -0500247 angle::Result beginRenderPass(ContextVk *contextVk,
Jamie Madill21061022018-07-12 23:56:30 -0400248 const Framebuffer &framebuffer,
249 const gl::Rectangle &renderArea,
250 const RenderPassDesc &renderPassDesc,
251 const std::vector<VkClearValue> &clearValues,
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400252 CommandBuffer **commandBufferOut);
253
Jamie Madill5dca6512018-05-30 10:53:51 -0400254 // Checks if we're in a RenderPass, returning true if so. Updates serial internally.
255 // Returns the started command buffer in commandBufferOut.
Jamie Madillc759b8b2019-01-03 15:16:50 -0500256 ANGLE_INLINE bool appendToStartedRenderPass(Serial currentQueueSerial,
257 CommandBuffer **commandBufferOut)
258 {
259 updateQueueSerial(currentQueueSerial);
260 if (hasStartedRenderPass())
261 {
262 *commandBufferOut = mCurrentWritingNode->getInsideRenderPassCommands();
263 return true;
264 }
265 else
266 {
267 return false;
268 }
269 }
Jamie Madill316c6062018-05-29 10:49:45 -0400270
271 // Accessor for RenderPass RenderArea.
272 const gl::Rectangle &getRenderPassRenderArea() const;
273
274 // Called when 'this' object changes, but we'd like to start a new command buffer later.
Jamie Madille2d22702018-09-19 08:11:48 -0400275 void finishCurrentCommands(RendererVk *renderer);
Jamie Madill316c6062018-05-29 10:49:45 -0400276
Jamie Madill03d1a5e2018-11-12 11:34:24 -0500277 // Store a deferred memory barrier. Will be recorded into a primary command buffer at submit.
278 void addGlobalMemoryBarrier(VkFlags srcAccess, VkFlags dstAccess)
279 {
280 ASSERT(mCurrentWritingNode);
281 mCurrentWritingNode->addGlobalMemoryBarrier(srcAccess, dstAccess);
282 }
283
Jamie Madill2d03ff42018-09-27 15:04:26 -0400284 protected:
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500285 explicit CommandGraphResource(CommandGraphResourceType resourceType);
Jamie Madill0da73fe2018-10-02 09:31:39 -0400286
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400287 private:
Jamie Madill316c6062018-05-29 10:49:45 -0400288 // Returns true if this node has a current writing node with no children.
Jamie Madillc759b8b2019-01-03 15:16:50 -0500289 ANGLE_INLINE bool hasChildlessWritingNode() const
Jamie Madill3d61ac22018-08-28 16:58:55 -0400290 {
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400291 // Note: currently, we don't have a resource that can issue both generic and special
292 // commands. We don't create read/write dependencies between mixed generic/special
293 // resources either. As such, we expect the function to always be generic here. If such a
294 // resource is added in the future, this can add a check for function == generic and fail if
295 // false.
296 ASSERT(mCurrentWritingNode == nullptr ||
297 mCurrentWritingNode->getFunction() == CommandGraphNodeFunction::Generic);
Jamie Madill3d61ac22018-08-28 16:58:55 -0400298 return (mCurrentWritingNode != nullptr && !mCurrentWritingNode->hasChildren());
299 }
Jamie Madill316c6062018-05-29 10:49:45 -0400300
Jamie Madill5dca6512018-05-30 10:53:51 -0400301 // Checks if we're in a RenderPass without children.
Jamie Madill3d61ac22018-08-28 16:58:55 -0400302 bool hasStartedRenderPass() const
303 {
304 return hasChildlessWritingNode() &&
305 mCurrentWritingNode->getInsideRenderPassCommands()->valid();
306 }
Jamie Madill5dca6512018-05-30 10:53:51 -0400307
Jamie Madill193a2842018-10-30 17:28:41 -0400308 void startNewCommands(RendererVk *renderer);
Jamie Madill0da73fe2018-10-02 09:31:39 -0400309
Jamie Madill193a2842018-10-30 17:28:41 -0400310 void onWriteImpl(CommandGraphNode *writingNode, Serial currentSerial);
311
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500312 Serial mStoredQueueSerial;
313
Jamie Madill193a2842018-10-30 17:28:41 -0400314 std::vector<CommandGraphNode *> mCurrentReadingNodes;
Jamie Madill193a2842018-10-30 17:28:41 -0400315
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500316 // Current command graph writing node.
317 CommandGraphNode *mCurrentWritingNode;
Jamie Madill193a2842018-10-30 17:28:41 -0400318
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500319 // Additional diagnostic information.
320 CommandGraphResourceType mResourceType;
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400321};
322
Jamie Madill1f46bc12018-02-20 16:09:43 -0500323// Translating OpenGL commands into Vulkan and submitting them immediately loses out on some
324// of the powerful flexiblity Vulkan offers in RenderPasses. Load/Store ops can automatically
325// clear RenderPass attachments, or preserve the contents. RenderPass automatic layout transitions
326// can improve certain performance cases. Also, we can remove redundant RenderPass Begin and Ends
327// when processing interleaved draw operations on independent Framebuffers.
328//
329// ANGLE's CommandGraph (and CommandGraphNode) attempt to solve these problems using deferred
330// command submission. We also sometimes call this command re-ordering. A brief summary:
331//
332// During GL command processing, we record Vulkan commands into secondary command buffers, which
333// are stored in CommandGraphNodes, and these nodes are chained together via dependencies to
334// for a directed acyclic CommandGraph. When we need to submit the CommandGraph, say during a
335// SwapBuffers or ReadPixels call, we begin a primary Vulkan CommandBuffer, and walk the
336// CommandGraph, starting at the most senior nodes, recording secondary CommandBuffers inside
Jamie Madill6c7ab7f2018-03-31 14:19:15 -0400337// and outside RenderPasses as necessary, filled with the right load/store operations. Once
Jamie Madill1f46bc12018-02-20 16:09:43 -0500338// the primary CommandBuffer has recorded all of the secondary CommandBuffers from all the open
339// CommandGraphNodes, we submit the primary CommandBuffer to the VkQueue on the device.
Jamie Madilla5e06072018-05-18 14:36:05 -0400340//
Jamie Madill1f46bc12018-02-20 16:09:43 -0500341// The Command Graph consists of an array of open Command Graph Nodes. It supports allocating new
342// nodes for the graph, which are linked via dependency relation calls in CommandGraphNode, and
343// also submitting the whole command graph via submitCommands.
344class CommandGraph final : angle::NonCopyable
345{
346 public:
Jamie Madill0da73fe2018-10-02 09:31:39 -0400347 explicit CommandGraph(bool enableGraphDiagnostics);
Jamie Madill1f46bc12018-02-20 16:09:43 -0500348 ~CommandGraph();
349
350 // Allocates a new CommandGraphNode and adds it to the list of current open nodes. No ordering
351 // relations exist in the node by default. Call CommandGraphNode::SetHappensBeforeDependency
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400352 // to set up dependency relations. If the node is a barrier, it will automatically add
353 // dependencies between the previous barrier, the new barrier and all nodes in between.
Jamie Madill193a2842018-10-30 17:28:41 -0400354 CommandGraphNode *allocateNode(CommandGraphNodeFunction function);
Jamie Madill1f46bc12018-02-20 16:09:43 -0500355
Jamie Madill21061022018-07-12 23:56:30 -0400356 angle::Result submitCommands(Context *context,
357 Serial serial,
358 RenderPassCache *renderPassCache,
359 CommandPool *commandPool,
360 CommandBuffer *primaryCommandBufferOut);
Jamie Madill1f46bc12018-02-20 16:09:43 -0500361 bool empty() const;
Yuly Novikovb56ddbb2018-11-02 16:53:18 -0400362 void clear();
Jamie Madill1f46bc12018-02-20 16:09:43 -0500363
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500364 // The following create special-function nodes that don't require a graph resource.
365 // Queries:
366 void beginQuery(const QueryPool *queryPool, uint32_t queryIndex);
367 void endQuery(const QueryPool *queryPool, uint32_t queryIndex);
368 void writeTimestamp(const QueryPool *queryPool, uint32_t queryIndex);
Shahbaz Youssefi82fddcb2019-01-18 14:27:43 -0500369 // GLsync and EGLSync:
370 void setFenceSync(const vk::Event &event);
371 void waitFenceSync(const vk::Event &event);
Jamie Madill193a2842018-10-30 17:28:41 -0400372
Jamie Madill1f46bc12018-02-20 16:09:43 -0500373 private:
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500374 CommandGraphNode *allocateBarrierNode(CommandGraphResourceType resourceType,
375 CommandGraphNodeFunction function);
376 void setNewBarrier(CommandGraphNode *newBarrier);
377 CommandGraphNode *getLastBarrierNode(size_t *indexOut);
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400378 void addDependenciesToNextBarrier(size_t begin, size_t end, CommandGraphNode *nextBarrier);
379
Shahbaz Youssefic81e7bf2019-01-18 15:35:55 -0500380 void dumpGraphDotFile(std::ostream &out) const;
381
Jamie Madill0da73fe2018-10-02 09:31:39 -0400382 std::vector<CommandGraphNode *> mNodes;
383 bool mEnableGraphDiagnostics;
Shahbaz Youssefi563fbaa2018-10-02 11:22:01 -0400384
385 // A set of nodes (eventually) exist that act as barriers to guarantee submission order. For
386 // example, a glMemoryBarrier() calls would lead to such a barrier or beginning and ending a
387 // query. This is because the graph can reorder operations if it sees fit. Let's call a barrier
388 // node Bi, and the other nodes Ni. The edges between Ni don't interest us. Before a barrier is
389 // inserted, we have:
390 //
391 // N0 N1 ... Na
392 // \___\__/_/ (dependency egdes, which we don't care about so I'll stop drawing them.
393 // \/
394 //
395 // When the first barrier is inserted, we will have:
396 //
397 // ______
398 // / ____\
399 // / / \
400 // / / /\
401 // N0 N1 ... Na B0
402 //
403 // This makes sure all N0..Na are called before B0. From then on, B0 will be the current
404 // "barrier point" which extends an edge to every next node:
405 //
406 // ______
407 // / ____\
408 // / / \
409 // / / /\
410 // N0 N1 ... Na B0 Na+1 ... Nb
411 // \/ /
412 // \______/
413 //
414 //
415 // When the next barrier B1 is met, all nodes between B0 and B1 will add a depenency on B1 as
416 // well, and the "barrier point" is updated.
417 //
418 // ______
419 // / ____\ ______ ______
420 // / / \ / \ / \
421 // / / /\ / /\ / /\
422 // N0 N1 ... Na B0 Na+1 ... Nb B1 Nb+1 ... Nc B2 ...
423 // \/ / / \/ / /
424 // \______/ / \______/ /
425 // \_______/ \_______/
426 //
427 //
428 // When barrier Bi is introduced, all nodes added since Bi-1 need to add a dependency to Bi
429 // (including Bi-1). We therefore keep track of the node index of the last barrier that was
430 // issued.
431 static constexpr size_t kInvalidNodeIndex = std::numeric_limits<std::size_t>::max();
432 size_t mLastBarrierIndex;
Jamie Madill0da73fe2018-10-02 09:31:39 -0400433};
Jamie Madill1f46bc12018-02-20 16:09:43 -0500434} // namespace vk
435} // namespace rx
436
437#endif // LIBANGLE_RENDERER_VULKAN_COMMAND_GRAPH_H_