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

Side by Side Diff: src/gpu/vk/GrVkGpu.cpp

Issue 2274663005: Add GrVkCopyPipeline to handle vulkan copies as draws (Closed) Base URL: https://skia.googlesource.com/skia.git@compatibleCopyDS
Patch Set: indent nits Created 4 years, 2 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 | « src/gpu/vk/GrVkGpu.h ('k') | src/gpu/vk/GrVkGpuCommandBuffer.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 #include "GrVkGpu.h" 8 #include "GrVkGpu.h"
9 9
10 #include "GrContextOptions.h" 10 #include "GrContextOptions.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 #ifdef SK_DEBUG 180 #ifdef SK_DEBUG
181 if (this->vkCaps().allowInitializationErrorOnTearDown()) { 181 if (this->vkCaps().allowInitializationErrorOnTearDown()) {
182 SkASSERT(VK_SUCCESS == res || 182 SkASSERT(VK_SUCCESS == res ||
183 VK_ERROR_DEVICE_LOST == res || 183 VK_ERROR_DEVICE_LOST == res ||
184 VK_ERROR_INITIALIZATION_FAILED == res); 184 VK_ERROR_INITIALIZATION_FAILED == res);
185 } else { 185 } else {
186 SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res); 186 SkASSERT(VK_SUCCESS == res || VK_ERROR_DEVICE_LOST == res);
187 } 187 }
188 #endif 188 #endif
189 189
190 fCopyManager.destroyResources(this);
191
190 // must call this just before we destroy the VkDevice 192 // must call this just before we destroy the VkDevice
191 fResourceProvider.destroyResources(); 193 fResourceProvider.destroyResources();
192 194
193 VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr)); 195 VK_CALL(DestroyCommandPool(fDevice, fCmdPool, nullptr));
194 196
195 #if USE_SKSL 197 #if USE_SKSL
196 delete fCompiler; 198 delete fCompiler;
197 #else 199 #else
198 shaderc_compiler_release(fCompiler); 200 shaderc_compiler_release(fCompiler);
199 #endif 201 #endif
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 1570
1569 bool GrVkGpu::onCopySurface(GrSurface* dst, 1571 bool GrVkGpu::onCopySurface(GrSurface* dst,
1570 GrSurface* src, 1572 GrSurface* src,
1571 const SkIRect& srcRect, 1573 const SkIRect& srcRect,
1572 const SkIPoint& dstPoint) { 1574 const SkIPoint& dstPoint) {
1573 if (can_copy_as_resolve(dst, src, this)) { 1575 if (can_copy_as_resolve(dst, src, this)) {
1574 this->copySurfaceAsResolve(dst, src, srcRect, dstPoint); 1576 this->copySurfaceAsResolve(dst, src, srcRect, dstPoint);
1575 return true; 1577 return true;
1576 } 1578 }
1577 1579
1580 if (fCopyManager.copySurfaceAsDraw(this, dst, src, srcRect, dstPoint)) {
1581 return true;
1582 }
1583
1578 GrVkImage* dstImage; 1584 GrVkImage* dstImage;
1579 GrVkImage* srcImage; 1585 GrVkImage* srcImage;
1580 GrRenderTarget* dstRT = dst->asRenderTarget(); 1586 GrRenderTarget* dstRT = dst->asRenderTarget();
1581 if (dstRT) { 1587 if (dstRT) {
1582 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(dstRT); 1588 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(dstRT);
1583 dstImage = vkRT->numColorSamples() > 1 ? vkRT->msaaImage() : vkRT; 1589 dstImage = vkRT->numColorSamples() > 1 ? vkRT->msaaImage() : vkRT;
1584 } else { 1590 } else {
1585 SkASSERT(dst->asTexture()); 1591 SkASSERT(dst->asTexture());
1586 dstImage = static_cast<GrVkTexture*>(dst->asTexture()); 1592 dstImage = static_cast<GrVkTexture*>(dst->asTexture());
1587 } 1593 }
1588 GrRenderTarget* srcRT = src->asRenderTarget(); 1594 GrRenderTarget* srcRT = src->asRenderTarget();
1589 if (srcRT) { 1595 if (srcRT) {
1590 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(srcRT); 1596 GrVkRenderTarget* vkRT = static_cast<GrVkRenderTarget*>(srcRT);
1591 srcImage = vkRT->numColorSamples() > 1 ? vkRT->msaaImage() : vkRT; 1597 srcImage = vkRT->numColorSamples() > 1 ? vkRT->msaaImage() : vkRT;
1592 } else { 1598 } else {
1593 SkASSERT(src->asTexture()); 1599 SkASSERT(src->asTexture());
1594 srcImage = static_cast<GrVkTexture*>(src->asTexture()); 1600 srcImage = static_cast<GrVkTexture*>(src->asTexture());
1595 } 1601 }
1596 1602
1597 if (can_copy_image(dst, src, this)) { 1603 if (can_copy_image(dst, src, this)) {
1598 this->copySurfaceAsCopyImage(dst, src, dstImage, srcImage, srcRect, dstP oint); 1604 this->copySurfaceAsCopyImage(dst, src, dstImage, srcImage, srcRect, dstP oint);
1599 return true; 1605 return true;
1600 } 1606 }
1601 1607
1602 if (can_copy_as_blit(dst, src, dstImage, srcImage, this)) { 1608 if (can_copy_as_blit(dst, src, dstImage, srcImage, this)) {
1603 this->copySurfaceAsBlit(dst, src, dstImage, srcImage, srcRect, dstPoint) ; 1609 this->copySurfaceAsBlit(dst, src, dstImage, srcImage, srcRect, dstPoint) ;
1604 return true; 1610 return true;
1605 } 1611 }
1606 1612
1607 if (can_copy_as_draw(dst, src, this)) {
1608 this->copySurfaceAsDraw(dst, src, srcRect, dstPoint);
1609 return true;
1610 }
1611
1612 return false; 1613 return false;
1613 } 1614 }
1614 1615
1615 bool GrVkGpu::initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc) const { 1616 bool GrVkGpu::initDescForDstCopy(const GrRenderTarget* src, GrSurfaceDesc* desc) const {
1616 // We can always succeed here with either a CopyImage (none msaa src) or Res olveImage (msaa). 1617 // We can always succeed here with either a CopyImage (none msaa src) or Res olveImage (msaa).
1617 // For CopyImage we can make a simple texture, for ResolveImage we require t he dst to be a 1618 // For CopyImage we can make a simple texture, for ResolveImage we require t he dst to be a
1618 // render target as well. 1619 // render target as well.
1619 desc->fOrigin = src->origin(); 1620 desc->fOrigin = src->origin();
1620 desc->fConfig = src->config(); 1621 desc->fConfig = src->config();
1621 desc->fFlags = src->numColorSamples() > 1 ? kRenderTarget_GrSurfaceFlag : kN one_GrSurfaceFlags; 1622 if (src->numColorSamples() > 1 ||
1623 (src->asTexture() && this->vkCaps().supportsCopiesAsDraws())) {
1624 desc->fFlags = kRenderTarget_GrSurfaceFlag;
1625 } else {
1626 // Just going to use CopyImage here
1627 desc->fFlags = kNone_GrSurfaceFlags;
1628 }
1629
1622 return true; 1630 return true;
1623 } 1631 }
1624 1632
1625 void GrVkGpu::onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings& , 1633 void GrVkGpu::onGetMultisampleSpecs(GrRenderTarget* rt, const GrStencilSettings& ,
1626 int* effectiveSampleCnt, SamplePattern*) { 1634 int* effectiveSampleCnt, SamplePattern*) {
1627 // TODO: stub. 1635 // TODO: stub.
1628 SkASSERT(!this->caps()->sampleLocationsSupport()); 1636 SkASSERT(!this->caps()->sampleLocationsSupport());
1629 *effectiveSampleCnt = rt->desc().fSampleCnt; 1637 *effectiveSampleCnt = rt->desc().fSampleCnt;
1630 } 1638 }
1631 1639
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 // Currently it is fine for us to always pass in 1 for the clear count even if no attachment 1869 // Currently it is fine for us to always pass in 1 for the clear count even if no attachment
1862 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment 1870 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the color attachment
1863 // which is always at the first attachment. 1871 // which is always at the first attachment.
1864 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, *pBounds, true); 1872 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target, *pBounds, true);
1865 fCurrentCmdBuffer->executeCommands(this, buffer); 1873 fCurrentCmdBuffer->executeCommands(this, buffer);
1866 fCurrentCmdBuffer->endRenderPass(this); 1874 fCurrentCmdBuffer->endRenderPass(this);
1867 1875
1868 this->didWriteToSurface(target, &bounds); 1876 this->didWriteToSurface(target, &bounds);
1869 } 1877 }
1870 1878
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | src/gpu/vk/GrVkGpuCommandBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698