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

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

Issue 1974983002: Refactor Vulkan image, texture, RTs so that create and getter handles match. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixLayerVersion
Patch Set: nits Created 4 years, 7 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/GrVkCommandBuffer.cpp ('k') | src/gpu/vk/GrVkImage.h » ('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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 VK_IMAGE_ASPECT_COLOR_BIT, 319 VK_IMAGE_ASPECT_COLOR_BIT,
320 0, // mipLevel 320 0, // mipLevel
321 0, // arraySlice 321 0, // arraySlice
322 }; 322 };
323 VkSubresourceLayout layout; 323 VkSubresourceLayout layout;
324 VkResult err; 324 VkResult err;
325 325
326 const GrVkInterface* interface = this->vkInterface(); 326 const GrVkInterface* interface = this->vkInterface();
327 327
328 GR_VK_CALL(interface, GetImageSubresourceLayout(fDevice, 328 GR_VK_CALL(interface, GetImageSubresourceLayout(fDevice,
329 tex->textureImage(), 329 tex->image(),
330 &subres, 330 &subres,
331 &layout)); 331 &layout));
332 332
333 int texTop = kBottomLeft_GrSurfaceOrigin == desc.fOrigin ? tex->height() - t op - height : top; 333 int texTop = kBottomLeft_GrSurfaceOrigin == desc.fOrigin ? tex->height() - t op - height : top;
334 VkDeviceSize offset = texTop*layout.rowPitch + left*bpp; 334 VkDeviceSize offset = texTop*layout.rowPitch + left*bpp;
335 VkDeviceSize size = height*layout.rowPitch; 335 VkDeviceSize size = height*layout.rowPitch;
336 void* mapPtr; 336 void* mapPtr;
337 err = GR_VK_CALL(interface, MapMemory(fDevice, tex->textureMemory(), offset, size, 0, 337 err = GR_VK_CALL(interface, MapMemory(fDevice, tex->memory(), offset, size, 0, &mapPtr));
338 &mapPtr));
339 if (err) { 338 if (err) {
340 return false; 339 return false;
341 } 340 }
342 341
343 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) { 342 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) {
344 // copy into buffer by rows 343 // copy into buffer by rows
345 const char* srcRow = reinterpret_cast<const char*>(data); 344 const char* srcRow = reinterpret_cast<const char*>(data);
346 char* dstRow = reinterpret_cast<char*>(mapPtr)+(height - 1)*layout.rowPi tch; 345 char* dstRow = reinterpret_cast<char*>(mapPtr)+(height - 1)*layout.rowPi tch;
347 for (int y = 0; y < height; y++) { 346 for (int y = 0; y < height; y++) {
348 memcpy(dstRow, srcRow, trimRowBytes); 347 memcpy(dstRow, srcRow, trimRowBytes);
349 srcRow += rowBytes; 348 srcRow += rowBytes;
350 dstRow -= layout.rowPitch; 349 dstRow -= layout.rowPitch;
351 } 350 }
352 } else { 351 } else {
353 // If there is no padding on the src (rowBytes) or dst (layout.rowPitch) we can memcpy 352 // If there is no padding on the src (rowBytes) or dst (layout.rowPitch) we can memcpy
354 if (trimRowBytes == rowBytes && trimRowBytes == layout.rowPitch) { 353 if (trimRowBytes == rowBytes && trimRowBytes == layout.rowPitch) {
355 memcpy(mapPtr, data, trimRowBytes * height); 354 memcpy(mapPtr, data, trimRowBytes * height);
356 } else { 355 } else {
357 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data, row Bytes, 356 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data, row Bytes,
358 trimRowBytes, height); 357 trimRowBytes, height);
359 } 358 }
360 } 359 }
361 360
362 GR_VK_CALL(interface, UnmapMemory(fDevice, tex->textureMemory())); 361 GR_VK_CALL(interface, UnmapMemory(fDevice, tex->memory()));
363 362
364 return true; 363 return true;
365 } 364 }
366 365
367 bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex, 366 bool GrVkGpu::uploadTexDataOptimal(GrVkTexture* tex,
368 int left, int top, int width, int height, 367 int left, int top, int width, int height,
369 GrPixelConfig dataConfig, 368 GrPixelConfig dataConfig,
370 const SkTArray<GrMipLevel>& texels) { 369 const SkTArray<GrMipLevel>& texels) {
371 SkASSERT(!tex->isLinearTiled()); 370 SkASSERT(!tex->isLinearTiled());
372 // The assumption is either that we have no mipmaps, or that our rect is the entire texture 371 // The assumption is either that we have no mipmaps, or that our rect is the entire texture
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 // By default, all textures in Vk use TopLeft 600 // By default, all textures in Vk use TopLeft
602 if (kDefault_GrSurfaceOrigin == origin) { 601 if (kDefault_GrSurfaceOrigin == origin) {
603 return kTopLeft_GrSurfaceOrigin; 602 return kTopLeft_GrSurfaceOrigin;
604 } else { 603 } else {
605 return origin; 604 return origin;
606 } 605 }
607 } 606 }
608 607
609 GrTexture* GrVkGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc, 608 GrTexture* GrVkGpu::onWrapBackendTexture(const GrBackendTextureDesc& desc,
610 GrWrapOwnership ownership) { 609 GrWrapOwnership ownership) {
611 VkFormat format;
612 if (!GrPixelConfigToVkFormat(desc.fConfig, &format)) {
613 return nullptr;
614 }
615
616 if (0 == desc.fTextureHandle) { 610 if (0 == desc.fTextureHandle) {
617 return nullptr; 611 return nullptr;
618 } 612 }
619 613
620 int maxSize = this->caps()->maxTextureSize(); 614 int maxSize = this->caps()->maxTextureSize();
621 if (desc.fWidth > maxSize || desc.fHeight > maxSize) { 615 if (desc.fWidth > maxSize || desc.fHeight > maxSize) {
622 return nullptr; 616 return nullptr;
623 } 617 }
624 618
625 const GrVkTextureInfo* info = reinterpret_cast<const GrVkTextureInfo*>(desc. fTextureHandle); 619 const GrVkImageInfo* info = reinterpret_cast<const GrVkImageInfo*>(desc.fTex tureHandle);
626 if (VK_NULL_HANDLE == info->fImage || VK_NULL_HANDLE == info->fAlloc) { 620 if (VK_NULL_HANDLE == info->fImage || VK_NULL_HANDLE == info->fAlloc) {
627 return nullptr; 621 return nullptr;
628 } 622 }
623 #ifdef SK_DEBUG
624 VkFormat format;
625 if (!GrPixelConfigToVkFormat(desc.fConfig, &format)) {
626 return nullptr;
627 }
628 SkASSERT(format == info->fFormat);
629 #endif
629 630
630 GrSurfaceDesc surfDesc; 631 GrSurfaceDesc surfDesc;
631 // next line relies on GrBackendTextureDesc's flags matching GrTexture's 632 // next line relies on GrBackendTextureDesc's flags matching GrTexture's
632 surfDesc.fFlags = (GrSurfaceFlags)desc.fFlags; 633 surfDesc.fFlags = (GrSurfaceFlags)desc.fFlags;
633 surfDesc.fWidth = desc.fWidth; 634 surfDesc.fWidth = desc.fWidth;
634 surfDesc.fHeight = desc.fHeight; 635 surfDesc.fHeight = desc.fHeight;
635 surfDesc.fConfig = desc.fConfig; 636 surfDesc.fConfig = desc.fConfig;
636 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount() ); 637 surfDesc.fSampleCnt = SkTMin(desc.fSampleCnt, this->caps()->maxSampleCount() );
637 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla g); 638 bool renderTarget = SkToBool(desc.fFlags & kRenderTarget_GrBackendTextureFla g);
638 // In GL, Chrome assumes all textures are BottomLeft 639 // In GL, Chrome assumes all textures are BottomLeft
639 // In VK, we don't have this restriction 640 // In VK, we don't have this restriction
640 surfDesc.fOrigin = resolve_origin(desc.fOrigin); 641 surfDesc.fOrigin = resolve_origin(desc.fOrigin);
641 642
642 GrVkTexture* texture = nullptr; 643 GrVkTexture* texture = nullptr;
643 if (renderTarget) { 644 if (renderTarget) {
644 texture = GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(this , surfDesc, 645 texture = GrVkTextureRenderTarget::CreateWrappedTextureRenderTarget(this , surfDesc,
645 owne rship, format, 646 owne rship, info);
646 info );
647 } else { 647 } else {
648 texture = GrVkTexture::CreateWrappedTexture(this, surfDesc, ownership, f ormat, info); 648 texture = GrVkTexture::CreateWrappedTexture(this, surfDesc, ownership, i nfo);
649 } 649 }
650 if (!texture) { 650 if (!texture) {
651 return nullptr; 651 return nullptr;
652 } 652 }
653 653
654 return texture; 654 return texture;
655 } 655 }
656 656
657 GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc, 657 GrRenderTarget* GrVkGpu::onWrapBackendRenderTarget(const GrBackendRenderTargetDe sc& wrapDesc,
658 GrWrapOwnership ownership) { 658 GrWrapOwnership ownership) {
659 659
660 const GrVkTextureInfo* info = 660 const GrVkImageInfo* info =
661 reinterpret_cast<const GrVkTextureInfo*>(wrapDesc.fRenderTargetHandle); 661 reinterpret_cast<const GrVkImageInfo*>(wrapDesc.fRenderTargetHandle);
662 if (VK_NULL_HANDLE == info->fImage || 662 if (VK_NULL_HANDLE == info->fImage ||
663 (VK_NULL_HANDLE == info->fAlloc && kAdopt_GrWrapOwnership == ownership)) { 663 (VK_NULL_HANDLE == info->fAlloc && kAdopt_GrWrapOwnership == ownership)) {
664 return nullptr; 664 return nullptr;
665 } 665 }
666 666
667 GrSurfaceDesc desc; 667 GrSurfaceDesc desc;
668 desc.fConfig = wrapDesc.fConfig; 668 desc.fConfig = wrapDesc.fConfig;
669 desc.fFlags = kCheckAllocation_GrSurfaceFlag; 669 desc.fFlags = kCheckAllocation_GrSurfaceFlag;
670 desc.fWidth = wrapDesc.fWidth; 670 desc.fWidth = wrapDesc.fWidth;
671 desc.fHeight = wrapDesc.fHeight; 671 desc.fHeight = wrapDesc.fHeight;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 if (!caps.configCanBeDstofBlit(tex->config(), false) || 703 if (!caps.configCanBeDstofBlit(tex->config(), false) ||
704 !caps.configCanBeSrcofBlit(tex->config(), false)) { 704 !caps.configCanBeSrcofBlit(tex->config(), false)) {
705 return; 705 return;
706 } 706 }
707 707
708 // change the original image's layout 708 // change the original image's layout
709 tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 709 tex->setImageLayout(this, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
710 VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_ BIT, false); 710 VK_ACCESS_TRANSFER_READ_BIT, VK_PIPELINE_STAGE_TRANSFER_ BIT, false);
711 711
712 // grab handle to the original image resource 712 // grab handle to the original image resource
713 const GrVkImage::Resource* oldResource = tex->resource(); 713 const GrVkResource* oldResource = tex->resource();
714 oldResource->ref(); 714 oldResource->ref();
715 VkImage oldImage = tex->image();
715 716
716 // SkMipMap doesn't include the base level in the level count so we have to add 1 717 // SkMipMap doesn't include the base level in the level count so we have to add 1
717 uint32_t levelCount = SkMipMap::ComputeLevelCount(tex->width(), tex->height( )) + 1; 718 uint32_t levelCount = SkMipMap::ComputeLevelCount(tex->width(), tex->height( )) + 1;
718 if (!tex->reallocForMipmap(this, levelCount)) { 719 if (!tex->reallocForMipmap(this, levelCount)) {
719 oldResource->unref(this); 720 oldResource->unref(this);
720 return; 721 return;
721 } 722 }
722 723
723 // change the new image's layout 724 // change the new image's layout
724 tex->setImageLayout(this, VK_IMAGE_LAYOUT_GENERAL, 725 tex->setImageLayout(this, VK_IMAGE_LAYOUT_GENERAL,
725 VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER _BIT, false); 726 VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER _BIT, false);
726 727
727 // Blit original image 728 // Blit original image
728 int width = tex->width(); 729 int width = tex->width();
729 int height = tex->height(); 730 int height = tex->height();
730 731
731 VkImageBlit blitRegion; 732 VkImageBlit blitRegion;
732 memset(&blitRegion, 0, sizeof(VkImageBlit)); 733 memset(&blitRegion, 0, sizeof(VkImageBlit));
733 blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; 734 blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
734 blitRegion.srcOffsets[0] = { 0, 0, 0 }; 735 blitRegion.srcOffsets[0] = { 0, 0, 0 };
735 blitRegion.srcOffsets[1] = { width, height, 0 }; 736 blitRegion.srcOffsets[1] = { width, height, 0 };
736 blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; 737 blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
737 blitRegion.dstOffsets[0] = { 0, 0, 0 }; 738 blitRegion.dstOffsets[0] = { 0, 0, 0 };
738 blitRegion.dstOffsets[1] = { width, height, 0 }; 739 blitRegion.dstOffsets[1] = { width, height, 0 };
739 740
740 fCurrentCmdBuffer->blitImage(this, 741 fCurrentCmdBuffer->blitImage(this,
741 oldResource, 742 oldResource,
743 oldImage,
742 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 744 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
743 tex->resource(), 745 tex->resource(),
746 tex->image(),
744 VK_IMAGE_LAYOUT_GENERAL, 747 VK_IMAGE_LAYOUT_GENERAL,
745 1, 748 1,
746 &blitRegion, 749 &blitRegion,
747 VK_FILTER_LINEAR); 750 VK_FILTER_LINEAR);
748 751
749 // setup memory barrier 752 // setup memory barrier
750 SkASSERT(GrVkFormatToPixelConfig(tex->resource()->fFormat, nullptr)); 753 SkASSERT(GrVkFormatToPixelConfig(tex->imageFormat(), nullptr));
751 VkImageAspectFlags aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT; 754 VkImageAspectFlags aspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
752 VkImageMemoryBarrier imageMemoryBarrier = { 755 VkImageMemoryBarrier imageMemoryBarrier = {
753 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType 756 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
754 NULL, // pNext 757 NULL, // pNext
755 VK_ACCESS_TRANSFER_WRITE_BIT, // outputMask 758 VK_ACCESS_TRANSFER_WRITE_BIT, // outputMask
756 VK_ACCESS_TRANSFER_READ_BIT, // inputMask 759 VK_ACCESS_TRANSFER_READ_BIT, // inputMask
757 VK_IMAGE_LAYOUT_GENERAL, // oldLayout 760 VK_IMAGE_LAYOUT_GENERAL, // oldLayout
758 VK_IMAGE_LAYOUT_GENERAL, // newLayout 761 VK_IMAGE_LAYOUT_GENERAL, // newLayout
759 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex 762 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
760 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex 763 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex
761 tex->resource()->fImage, // image 764 tex->image(), // image
762 { aspectFlags, 0, 1, 0, 1 } // subresourceRange 765 { aspectFlags, 0, 1, 0, 1 } // subresourceRange
763 }; 766 };
764 767
765 // Blit the miplevels 768 // Blit the miplevels
766 uint32_t mipLevel = 1; 769 uint32_t mipLevel = 1;
767 while (mipLevel < levelCount) { 770 while (mipLevel < levelCount) {
768 int prevWidth = width; 771 int prevWidth = width;
769 int prevHeight = height; 772 int prevHeight = height;
770 width = SkTMax(1, width / 2); 773 width = SkTMax(1, width / 2);
771 height = SkTMax(1, height / 2); 774 height = SkTMax(1, height / 2);
772 775
773 imageMemoryBarrier.subresourceRange.baseMipLevel = mipLevel - 1; 776 imageMemoryBarrier.subresourceRange.baseMipLevel = mipLevel - 1;
774 this->addImageMemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_ STAGE_TRANSFER_BIT, 777 this->addImageMemoryBarrier(VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_ STAGE_TRANSFER_BIT,
775 false, &imageMemoryBarrier); 778 false, &imageMemoryBarrier);
776 779
777 blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, mipLevel - 1, 0 , 1 }; 780 blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, mipLevel - 1, 0 , 1 };
778 blitRegion.srcOffsets[0] = { 0, 0, 0 }; 781 blitRegion.srcOffsets[0] = { 0, 0, 0 };
779 blitRegion.srcOffsets[1] = { prevWidth, prevHeight, 0 }; 782 blitRegion.srcOffsets[1] = { prevWidth, prevHeight, 0 };
780 blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, mipLevel, 0, 1 }; 783 blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, mipLevel, 0, 1 };
781 blitRegion.dstOffsets[0] = { 0, 0, 0 }; 784 blitRegion.dstOffsets[0] = { 0, 0, 0 };
782 blitRegion.dstOffsets[1] = { width, height, 0 }; 785 blitRegion.dstOffsets[1] = { width, height, 0 };
783 fCurrentCmdBuffer->blitImage(this, 786 fCurrentCmdBuffer->blitImage(this,
784 tex->resource(), 787 *tex,
785 VK_IMAGE_LAYOUT_GENERAL, 788 *tex,
786 tex->resource(),
787 VK_IMAGE_LAYOUT_GENERAL,
788 1, 789 1,
789 &blitRegion, 790 &blitRegion,
790 VK_FILTER_LINEAR); 791 VK_FILTER_LINEAR);
791 ++mipLevel; 792 ++mipLevel;
792 } 793 }
793 794
794 oldResource->unref(this); 795 oldResource->unref(this);
795 } 796 }
796 797
797 798
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), srcDa ta, rowCopyBytes, 941 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), srcDa ta, rowCopyBytes,
941 rowCopyBytes, h); 942 rowCopyBytes, h);
942 } 943 }
943 VK_CALL(UnmapMemory(fDevice, alloc)); 944 VK_CALL(UnmapMemory(fDevice, alloc));
944 } else { 945 } else {
945 // TODO: Add support for copying to optimal tiling 946 // TODO: Add support for copying to optimal tiling
946 SkASSERT(false); 947 SkASSERT(false);
947 } 948 }
948 } 949 }
949 950
950 GrVkTextureInfo* info = new GrVkTextureInfo; 951 GrVkImageInfo* info = new GrVkImageInfo;
951 info->fImage = image; 952 info->fImage = image;
952 info->fAlloc = alloc; 953 info->fAlloc = alloc;
953 info->fImageTiling = imageTiling; 954 info->fImageTiling = imageTiling;
954 info->fImageLayout = initialLayout; 955 info->fImageLayout = initialLayout;
955 info->fFormat = pixelFormat; 956 info->fFormat = pixelFormat;
956 info->fLevelCount = 1; 957 info->fLevelCount = 1;
957 958
958 return (GrBackendObject)info; 959 return (GrBackendObject)info;
959 } 960 }
960 961
961 bool GrVkGpu::isTestingOnlyBackendTexture(GrBackendObject id) const { 962 bool GrVkGpu::isTestingOnlyBackendTexture(GrBackendObject id) const {
962 const GrVkTextureInfo* backend = reinterpret_cast<const GrVkTextureInfo*>(id ); 963 const GrVkImageInfo* backend = reinterpret_cast<const GrVkImageInfo*>(id);
963 964
964 if (backend && backend->fImage && backend->fAlloc) { 965 if (backend && backend->fImage && backend->fAlloc) {
965 VkMemoryRequirements req; 966 VkMemoryRequirements req;
966 memset(&req, 0, sizeof(req)); 967 memset(&req, 0, sizeof(req));
967 GR_VK_CALL(this->vkInterface(), GetImageMemoryRequirements(fDevice, 968 GR_VK_CALL(this->vkInterface(), GetImageMemoryRequirements(fDevice,
968 backend->fIma ge, 969 backend->fIma ge,
969 &req)); 970 &req));
970 // TODO: find a better check 971 // TODO: find a better check
971 // This will probably fail with a different driver 972 // This will probably fail with a different driver
972 return (req.size > 0) && (req.size <= 8192 * 8192); 973 return (req.size > 0) && (req.size <= 8192 * 8192);
973 } 974 }
974 975
975 return false; 976 return false;
976 } 977 }
977 978
978 void GrVkGpu::deleteTestingOnlyBackendTexture(GrBackendObject id, bool abandon) { 979 void GrVkGpu::deleteTestingOnlyBackendTexture(GrBackendObject id, bool abandon) {
979 const GrVkTextureInfo* backend = reinterpret_cast<const GrVkTextureInfo*>(id ); 980 const GrVkImageInfo* backend = reinterpret_cast<const GrVkImageInfo*>(id);
980 981
981 if (backend) { 982 if (backend) {
982 if (!abandon) { 983 if (!abandon) {
983 // something in the command buffer may still be using this, so force submit 984 // something in the command buffer may still be using this, so force submit
984 this->submitCommandBuffer(kForce_SyncQueue); 985 this->submitCommandBuffer(kForce_SyncQueue);
985 986
986 VK_CALL(FreeMemory(this->device(), backend->fAlloc, nullptr)); 987 VK_CALL(FreeMemory(this->device(), backend->fAlloc, nullptr));
987 VK_CALL(DestroyImage(this->device(), backend->fImage, nullptr)); 988 VK_CALL(DestroyImage(this->device(), backend->fImage, nullptr));
988 } 989 }
989 delete backend; 990 delete backend;
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 VkImageBlit blitRegion; 1373 VkImageBlit blitRegion;
1373 memset(&blitRegion, 0, sizeof(VkImageBlit)); 1374 memset(&blitRegion, 0, sizeof(VkImageBlit));
1374 blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; 1375 blitRegion.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
1375 blitRegion.srcOffsets[0] = { srcVkRect.fLeft, srcVkRect.fTop, 0 }; 1376 blitRegion.srcOffsets[0] = { srcVkRect.fLeft, srcVkRect.fTop, 0 };
1376 blitRegion.srcOffsets[1] = { srcVkRect.fRight, srcVkRect.fBottom, 0 }; 1377 blitRegion.srcOffsets[1] = { srcVkRect.fRight, srcVkRect.fBottom, 0 };
1377 blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; 1378 blitRegion.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
1378 blitRegion.dstOffsets[0] = { dstRect.fLeft, dstRect.fTop, 0 }; 1379 blitRegion.dstOffsets[0] = { dstRect.fLeft, dstRect.fTop, 0 };
1379 blitRegion.dstOffsets[1] = { dstRect.fRight, dstRect.fBottom, 0 }; 1380 blitRegion.dstOffsets[1] = { dstRect.fRight, dstRect.fBottom, 0 };
1380 1381
1381 fCurrentCmdBuffer->blitImage(this, 1382 fCurrentCmdBuffer->blitImage(this,
1382 srcImage->resource(), 1383 *srcImage,
1383 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, 1384 *dstImage,
1384 dstImage->resource(),
1385 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1386 1, 1385 1,
1387 &blitRegion, 1386 &blitRegion,
1388 VK_FILTER_NEAREST); // We never scale so any fi lter works here 1387 VK_FILTER_NEAREST); // We never scale so any fi lter works here
1389 1388
1390 this->didWriteToSurface(dst, &dstRect); 1389 this->didWriteToSurface(dst, &dstRect);
1391 } 1390 }
1392 1391
1393 inline bool can_copy_as_draw(const GrSurface* dst, 1392 inline bool can_copy_as_draw(const GrSurface* dst,
1394 const GrSurface* src, 1393 const GrSurface* src,
1395 const GrVkGpu* gpu) { 1394 const GrVkGpu* gpu) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 aglSwapBuffers(aglGetCurrentContext()); 1685 aglSwapBuffers(aglGetCurrentContext());
1687 int set_a_break_pt_here = 9; 1686 int set_a_break_pt_here = 9;
1688 aglSwapBuffers(aglGetCurrentContext()); 1687 aglSwapBuffers(aglGetCurrentContext());
1689 #elif defined(SK_BUILD_FOR_WIN32) 1688 #elif defined(SK_BUILD_FOR_WIN32)
1690 SwapBuf(); 1689 SwapBuf();
1691 int set_a_break_pt_here = 9; 1690 int set_a_break_pt_here = 9;
1692 SwapBuf(); 1691 SwapBuf();
1693 #endif 1692 #endif
1694 #endif 1693 #endif
1695 } 1694 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkCommandBuffer.cpp ('k') | src/gpu/vk/GrVkImage.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698