Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: src/gpu/vk/GrVkCommandBuffer.h

Issue 1813913002: Use dynamic state from vulkan pipelines (Closed) Base URL: https://skia.googlesource.com/skia.git@drawInterface
Patch Set: cache dynamic state updates Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/gpu/vk/GrVkCommandBuffer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrVkCommandBuffer_DEFINED 8 #ifndef GrVkCommandBuffer_DEFINED
9 #define GrVkCommandBuffer_DEFINED 9 #define GrVkCommandBuffer_DEFINED
10 10
11 #include "GrVkGpu.h" 11 #include "GrVkGpu.h"
12 #include "GrVkPipeline.h"
13 #include "GrVkResource.h" 12 #include "GrVkResource.h"
14 #include "GrVkUtil.h" 13 #include "GrVkUtil.h"
15 #include "vulkan/vulkan.h" 14 #include "vulkan/vulkan.h"
16 15
16 class GrVkPipeline;
17 class GrVkRenderPass; 17 class GrVkRenderPass;
18 class GrVkRenderTarget; 18 class GrVkRenderTarget;
19 class GrVkTransferBuffer; 19 class GrVkTransferBuffer;
20 20
21 class GrVkCommandBuffer : public GrVkResource { 21 class GrVkCommandBuffer : public GrVkResource {
22 public: 22 public:
23 static GrVkCommandBuffer* Create(const GrVkGpu* gpu, VkCommandPool cmdPool); 23 static GrVkCommandBuffer* Create(const GrVkGpu* gpu, VkCommandPool cmdPool);
24 ~GrVkCommandBuffer() override; 24 ~GrVkCommandBuffer() override;
25 25
26 void begin(const GrVkGpu* gpu); 26 void begin(const GrVkGpu* gpu);
27 void end(const GrVkGpu* gpu); 27 void end(const GrVkGpu* gpu);
28 28
29 void invalidateState(); 29 void invalidateState();
30 30
31 // Begins render pass on this command buffer. The framebuffer from GrVkRende rTarget will be used 31 // Begins render pass on this command buffer. The framebuffer from GrVkRende rTarget will be used
32 // in the render pass. 32 // in the render pass.
33 void beginRenderPass(const GrVkGpu* gpu, 33 void beginRenderPass(const GrVkGpu* gpu,
34 const GrVkRenderPass* renderPass, 34 const GrVkRenderPass* renderPass,
35 const GrVkRenderTarget& target); 35 const GrVkRenderTarget& target);
36 void endRenderPass(const GrVkGpu* gpu); 36 void endRenderPass(const GrVkGpu* gpu);
37 37
38 void submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu::SyncQueue syn c); 38 void submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu::SyncQueue syn c);
39 bool finished(const GrVkGpu* gpu) const; 39 bool finished(const GrVkGpu* gpu) const;
40 40
41 //////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////
42 // CommandBuffer State/Object bindings
43 ////////////////////////////////////////////////////////////////////////////
44 #if 0
45 void bindPipeline(const GrVkGpu* gpu) const;
46 void bindDynamicState(const GrVkGpu* gpu) const;
47 void bindDescriptorSet(const GrVkGpu* gpu) const;
48 #endif
49
50 ////////////////////////////////////////////////////////////////////////////
51 // CommandBuffer commands 42 // CommandBuffer commands
52 //////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////
53 enum BarrierType { 44 enum BarrierType {
54 kMemory_BarrierType, 45 kMemory_BarrierType,
55 kBufferMemory_BarrierType, 46 kBufferMemory_BarrierType,
56 kImageMemory_BarrierType 47 kImageMemory_BarrierType
57 }; 48 };
58 49
59 void pipelineBarrier(const GrVkGpu* gpu, 50 void pipelineBarrier(const GrVkGpu* gpu,
60 VkPipelineStageFlags srcStageMask, 51 VkPipelineStageFlags srcStageMask,
(...skipping 23 matching lines...) Expand all
84 GR_VK_CALL(gpu->vkInterface(), CmdBindIndexBuffer(fCmdBuffer, 75 GR_VK_CALL(gpu->vkInterface(), CmdBindIndexBuffer(fCmdBuffer,
85 vkBuffer, 76 vkBuffer,
86 0, 77 0,
87 VK_INDEX_TYPE_UINT 16)); 78 VK_INDEX_TYPE_UINT 16));
88 fBoundIndexBufferIsValid = true; 79 fBoundIndexBufferIsValid = true;
89 fBoundIndexBuffer = vkBuffer; 80 fBoundIndexBuffer = vkBuffer;
90 addResource(ibuffer->resource()); 81 addResource(ibuffer->resource());
91 } 82 }
92 } 83 }
93 84
94 void bindPipeline(const GrVkGpu* gpu, const GrVkPipeline* pipeline) {
95 GR_VK_CALL(gpu->vkInterface(), CmdBindPipeline(fCmdBuffer,
96 VK_PIPELINE_BIND_POINT_GR APHICS,
97 pipeline->pipeline()));
98 addResource(pipeline);
99 }
100
101 void bindDescriptorSets(const GrVkGpu* gpu, 85 void bindDescriptorSets(const GrVkGpu* gpu,
102 GrVkProgram*, 86 GrVkProgram*,
103 VkPipelineLayout layout, 87 VkPipelineLayout layout,
104 uint32_t firstSet, 88 uint32_t firstSet,
105 uint32_t setCount, 89 uint32_t setCount,
106 const VkDescriptorSet* descriptorSets, 90 const VkDescriptorSet* descriptorSets,
107 uint32_t dynamicOffsetCount, 91 uint32_t dynamicOffsetCount,
108 const uint32_t* dynamicOffsets); 92 const uint32_t* dynamicOffsets);
109 93
94 void setViewport(const GrVkGpu* gpu,
95 uint32_t firstViewport,
96 uint32_t viewportCount,
97 const VkViewport* viewports);
98
99 void setScissor(const GrVkGpu* gpu,
100 uint32_t firstScissor,
101 uint32_t scissorCount,
102 const VkRect2D* scissors);
103
104 void setBlendConstants(const GrVkGpu* gpu, const float blendConstants[4]);
105
110 // Commands that only work outside of a render pass 106 // Commands that only work outside of a render pass
111 void clearColorImage(const GrVkGpu* gpu, 107 void clearColorImage(const GrVkGpu* gpu,
112 GrVkImage* image, 108 GrVkImage* image,
113 const VkClearColorValue* color, 109 const VkClearColorValue* color,
114 uint32_t subRangeCount, 110 uint32_t subRangeCount,
115 const VkImageSubresourceRange* subRanges); 111 const VkImageSubresourceRange* subRanges);
116 112
117 void clearDepthStencilImage(const GrVkGpu* gpu, 113 void clearDepthStencilImage(const GrVkGpu* gpu,
118 GrVkImage* image, 114 GrVkImage* image,
119 const VkClearDepthStencilValue* color, 115 const VkClearDepthStencilValue* color,
(...skipping 22 matching lines...) Expand all
142 uint32_t copyRegionCount, 138 uint32_t copyRegionCount,
143 const VkBufferImageCopy* copyRegions); 139 const VkBufferImageCopy* copyRegions);
144 140
145 // Commands that only work inside of a render pass 141 // Commands that only work inside of a render pass
146 void clearAttachments(const GrVkGpu* gpu, 142 void clearAttachments(const GrVkGpu* gpu,
147 int numAttachments, 143 int numAttachments,
148 const VkClearAttachment* attachments, 144 const VkClearAttachment* attachments,
149 int numRects, 145 int numRects,
150 const VkClearRect* clearRects) const; 146 const VkClearRect* clearRects) const;
151 147
148 void bindPipeline(const GrVkGpu* gpu, const GrVkPipeline* pipeline);
149
150
152 void drawIndexed(const GrVkGpu* gpu, 151 void drawIndexed(const GrVkGpu* gpu,
153 uint32_t indexCount, 152 uint32_t indexCount,
154 uint32_t instanceCount, 153 uint32_t instanceCount,
155 uint32_t firstIndex, 154 uint32_t firstIndex,
156 int32_t vertexOffset, 155 int32_t vertexOffset,
157 uint32_t firstInstance) const; 156 uint32_t firstInstance) const;
158 157
159 void draw(const GrVkGpu* gpu, 158 void draw(const GrVkGpu* gpu,
160 uint32_t vertexCount, 159 uint32_t vertexCount,
161 uint32_t instanceCount, 160 uint32_t instanceCount,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 bool fBoundIndexBufferIsValid; 197 bool fBoundIndexBufferIsValid;
199 198
200 // Tracks whether we are in the middle of a command buffer begin/end calls a nd thus can add new 199 // Tracks whether we are in the middle of a command buffer begin/end calls a nd thus can add new
201 // commands to the buffer; 200 // commands to the buffer;
202 bool fIsActive; 201 bool fIsActive;
203 202
204 // Stores a pointer to the current active render pass (i.e. begin has been c alled but not end). 203 // Stores a pointer to the current active render pass (i.e. begin has been c alled but not end).
205 // A nullptr means there is no active render pass. The GrVKCommandBuffer doe s not own the render 204 // A nullptr means there is no active render pass. The GrVKCommandBuffer doe s not own the render
206 // pass. 205 // pass.
207 const GrVkRenderPass* fActiveRenderPass; 206 const GrVkRenderPass* fActiveRenderPass;
207
208 // Cached values used for dynamic state updates
209 VkViewport fCachedViewport;
210 VkRect2D fCachedScissor;
211 float fCachedBlendConstant[4];
208 }; 212 };
209 213
210 214
211 #endif 215 #endif
212 216
OLDNEW
« no previous file with comments | « no previous file | src/gpu/vk/GrVkCommandBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698