1 /* 2 * Copyright 2015 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 9 #ifndef GrVkTextureRenderTarget_DEFINED 10 #define GrVkTextureRenderTarget_DEFINED 11 12 #include "include/gpu/vk/GrVkTypes.h" 13 #include "src/gpu/vk/GrVkRenderTarget.h" 14 #include "src/gpu/vk/GrVkTexture.h" 15 16 class GrVkGpu; 17 18 #ifdef SK_BUILD_FOR_WIN 19 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance. 20 #pragma warning(push) 21 #pragma warning(disable: 4250) 22 #endif 23 24 class GrVkImageView; 25 struct GrVkImageInfo; 26 27 class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget { 28 public: 29 static sk_sp<GrVkTextureRenderTarget> MakeNewTextureRenderTarget( 30 GrVkGpu* gpu, 31 SkBudgeted budgeted, 32 SkISize dimensions, 33 VkFormat format, 34 uint32_t mipLevels, 35 int sampleCnt, 36 GrMipmapStatus mipmapStatus, 37 GrProtected isProtected); 38 39 static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget( 40 GrVkGpu*, 41 SkISize dimensions, 42 int sampleCnt, 43 GrWrapOwnership, 44 GrWrapCacheable, 45 const GrVkImageInfo&, 46 sk_sp<GrBackendSurfaceMutableStateImpl>); 47 backendFormat()48 GrBackendFormat backendFormat() const override { return GrVkTexture::backendFormat(); } 49 50 void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override; 51 52 protected: onAbandon()53 void onAbandon() override { 54 // In order to correctly handle calling texture idle procs, GrVkTexture must go first. 55 GrVkTexture::onAbandon(); 56 GrVkRenderTarget::onAbandon(); 57 } 58 onRelease()59 void onRelease() override { 60 // In order to correctly handle calling texture idle procs, GrVkTexture must go first. 61 GrVkTexture::onRelease(); 62 GrVkRenderTarget::onRelease(); 63 } 64 65 private: 66 GrVkTextureRenderTarget(GrVkGpu* gpu, 67 SkBudgeted budgeted, 68 SkISize dimensions, 69 sk_sp<GrVkImage> texture, 70 sk_sp<GrVkImage> colorAttachment, 71 sk_sp<GrVkImage> resolveAttachment, 72 GrMipmapStatus); 73 74 GrVkTextureRenderTarget(GrVkGpu* gpu, 75 SkISize dimensions, 76 sk_sp<GrVkImage> texture, 77 sk_sp<GrVkImage> colorAttachment, 78 sk_sp<GrVkImage> resolveAttachment, 79 GrMipmapStatus, 80 GrWrapCacheable); 81 82 size_t onGpuMemorySize() const override; 83 84 // In Vulkan we call the release proc after we are finished with the underlying 85 // GrVkImage::Resource object (which occurs after the GPU has finished all work on it). onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper)86 void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { 87 // Forward the release proc on to GrVkImage 88 GrVkTexture::onSetRelease(std::move(releaseHelper)); 89 } 90 }; 91 92 #ifdef SK_BUILD_FOR_WIN 93 #pragma warning(pop) 94 #endif 95 96 #endif 97