OLD | NEW |
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 #include "GrVkGpu.h" | 8 #include "GrVkGpu.h" |
9 | 9 |
10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 fCompiler = shaderc_compiler_initialize(); | 120 fCompiler = shaderc_compiler_initialize(); |
121 #endif | 121 #endif |
122 | 122 |
123 fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysic
alDevice, | 123 fVkCaps.reset(new GrVkCaps(options, this->vkInterface(), backendCtx->fPhysic
alDevice, |
124 backendCtx->fFeatures, backendCtx->fExtensions)); | 124 backendCtx->fFeatures, backendCtx->fExtensions)); |
125 fCaps.reset(SkRef(fVkCaps.get())); | 125 fCaps.reset(SkRef(fVkCaps.get())); |
126 | 126 |
127 VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhy
sDevMemProps)); | 127 VK_CALL(GetPhysicalDeviceMemoryProperties(backendCtx->fPhysicalDevice, &fPhy
sDevMemProps)); |
128 | 128 |
129 const VkCommandPoolCreateInfo cmdPoolInfo = { | 129 const VkCommandPoolCreateInfo cmdPoolInfo = { |
130 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType | 130 VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, // sType |
131 nullptr, // pNext | 131 nullptr, // pNext |
132 VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, // CmdPoolCreateFlags | 132 VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | |
133 backendCtx->fGraphicsQueueIndex, // queueFamilyIndex | 133 VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, // CmdPoolCreateFlags |
| 134 backendCtx->fGraphicsQueueIndex, // queueFamilyIndex |
134 }; | 135 }; |
135 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPool
Info, nullptr, | 136 GR_VK_CALL_ERRCHECK(this->vkInterface(), CreateCommandPool(fDevice, &cmdPool
Info, nullptr, |
136 &fCmdPool)); | 137 &fCmdPool)); |
137 | 138 |
138 // must call this after creating the CommandPool | 139 // must call this after creating the CommandPool |
139 fResourceProvider.init(); | 140 fResourceProvider.init(); |
140 fCurrentCmdBuffer = fResourceProvider.createPrimaryCommandBuffer(); | 141 fCurrentCmdBuffer = fResourceProvider.findOrCreatePrimaryCommandBuffer(); |
141 SkASSERT(fCurrentCmdBuffer); | 142 SkASSERT(fCurrentCmdBuffer); |
142 fCurrentCmdBuffer->begin(this); | 143 fCurrentCmdBuffer->begin(this); |
143 | 144 |
144 // set up our heaps | 145 // set up our heaps |
145 fHeaps[kLinearImage_Heap].reset(new GrVkHeap(this, GrVkHeap::kSubAlloc_Strat
egy, 16*1024*1024)); | 146 fHeaps[kLinearImage_Heap].reset(new GrVkHeap(this, GrVkHeap::kSubAlloc_Strat
egy, 16*1024*1024)); |
146 // We want the OptimalImage_Heap to use a SubAlloc_strategy but it occasiona
lly causes the | 147 // We want the OptimalImage_Heap to use a SubAlloc_strategy but it occasiona
lly causes the |
147 // device to run out of memory. Most likely this is caused by fragmentation
in the device heap | 148 // device to run out of memory. Most likely this is caused by fragmentation
in the device heap |
148 // and we can't allocate more. Until we get a fix moving this to SingleAlloc
. | 149 // and we can't allocate more. Until we get a fix moving this to SingleAlloc
. |
149 fHeaps[kOptimalImage_Heap].reset(new GrVkHeap(this, GrVkHeap::kSingleAlloc_S
trategy, 64*1024*1024)); | 150 fHeaps[kOptimalImage_Heap].reset(new GrVkHeap(this, GrVkHeap::kSingleAlloc_S
trategy, 64*1024*1024)); |
150 fHeaps[kSmallOptimalImage_Heap].reset(new GrVkHeap(this, GrVkHeap::kSubAlloc
_Strategy, 2*1024*1024)); | 151 fHeaps[kSmallOptimalImage_Heap].reset(new GrVkHeap(this, GrVkHeap::kSubAlloc
_Strategy, 2*1024*1024)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 211 |
211 void GrVkGpu::submitCommandBuffer(SyncQueue sync) { | 212 void GrVkGpu::submitCommandBuffer(SyncQueue sync) { |
212 SkASSERT(fCurrentCmdBuffer); | 213 SkASSERT(fCurrentCmdBuffer); |
213 fCurrentCmdBuffer->end(this); | 214 fCurrentCmdBuffer->end(this); |
214 | 215 |
215 fCurrentCmdBuffer->submitToQueue(this, fQueue, sync); | 216 fCurrentCmdBuffer->submitToQueue(this, fQueue, sync); |
216 fResourceProvider.checkCommandBuffers(); | 217 fResourceProvider.checkCommandBuffers(); |
217 | 218 |
218 // Release old command buffer and create a new one | 219 // Release old command buffer and create a new one |
219 fCurrentCmdBuffer->unref(this); | 220 fCurrentCmdBuffer->unref(this); |
220 fCurrentCmdBuffer = fResourceProvider.createPrimaryCommandBuffer(); | 221 fCurrentCmdBuffer = fResourceProvider.findOrCreatePrimaryCommandBuffer(); |
221 SkASSERT(fCurrentCmdBuffer); | 222 SkASSERT(fCurrentCmdBuffer); |
222 | 223 |
223 fCurrentCmdBuffer->begin(this); | 224 fCurrentCmdBuffer->begin(this); |
224 } | 225 } |
225 | 226 |
226 /////////////////////////////////////////////////////////////////////////////// | 227 /////////////////////////////////////////////////////////////////////////////// |
227 GrBuffer* GrVkGpu::onCreateBuffer(size_t size, GrBufferType type, GrAccessPatter
n accessPattern, | 228 GrBuffer* GrVkGpu::onCreateBuffer(size_t size, GrBufferType type, GrAccessPatter
n accessPattern, |
228 const void* data) { | 229 const void* data) { |
229 GrBuffer* buff; | 230 GrBuffer* buff; |
230 switch (type) { | 231 switch (type) { |
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 SkRectMemcpy(buffer, rowBytes, mappedMemory, tightRowBytes, tightRow
Bytes, height); | 1488 SkRectMemcpy(buffer, rowBytes, mappedMemory, tightRowBytes, tightRow
Bytes, height); |
1488 } | 1489 } |
1489 } | 1490 } |
1490 | 1491 |
1491 transferBuffer->unmap(); | 1492 transferBuffer->unmap(); |
1492 transferBuffer->unref(); | 1493 transferBuffer->unref(); |
1493 | 1494 |
1494 return true; | 1495 return true; |
1495 } | 1496 } |
1496 | 1497 |
1497 void GrVkGpu::submitSecondaryCommandBuffer(const GrVkSecondaryCommandBuffer* buf
fer, | 1498 void GrVkGpu::submitSecondaryCommandBuffer(GrVkSecondaryCommandBuffer* buffer, |
1498 const GrVkRenderPass* renderPass, | 1499 const GrVkRenderPass* renderPass, |
1499 const VkClearValue* colorClear, | 1500 const VkClearValue* colorClear, |
1500 GrVkRenderTarget* target, | 1501 GrVkRenderTarget* target, |
1501 const SkIRect& bounds) { | 1502 const SkIRect& bounds) { |
1502 const SkIRect* pBounds = &bounds; | 1503 const SkIRect* pBounds = &bounds; |
1503 SkIRect flippedBounds; | 1504 SkIRect flippedBounds; |
1504 if (kBottomLeft_GrSurfaceOrigin == target->origin()) { | 1505 if (kBottomLeft_GrSurfaceOrigin == target->origin()) { |
1505 flippedBounds = bounds; | 1506 flippedBounds = bounds; |
1506 flippedBounds.fTop = target->height() - bounds.fBottom; | 1507 flippedBounds.fTop = target->height() - bounds.fBottom; |
1507 flippedBounds.fBottom = target->height() - bounds.fTop; | 1508 flippedBounds.fBottom = target->height() - bounds.fTop; |
1508 pBounds = &flippedBounds; | 1509 pBounds = &flippedBounds; |
1509 } | 1510 } |
1510 | 1511 |
1511 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment | 1512 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment |
1512 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment | 1513 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment |
1513 // which is always at the first attachment. | 1514 // which is always at the first attachment. |
1514 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); | 1515 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); |
1515 fCurrentCmdBuffer->executeCommands(this, buffer); | 1516 fCurrentCmdBuffer->executeCommands(this, buffer); |
1516 fCurrentCmdBuffer->endRenderPass(this); | 1517 fCurrentCmdBuffer->endRenderPass(this); |
1517 } | 1518 } |
1518 | 1519 |
OLD | NEW |