1 /* 2 * Copyright 2020 Google LLC 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 GrD3DTextureRenderTarget_DEFINED 10 #define GrD3DTextureRenderTarget_DEFINED 11 12 #include "include/gpu/d3d/GrD3DTypes.h" 13 #include "src/gpu/d3d/GrD3DRenderTarget.h" 14 #include "src/gpu/d3d/GrD3DTexture.h" 15 16 class GrD3DGpu; 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 struct GrD3DTextureResourceInfo; 25 26 class GrD3DTextureRenderTarget: public GrD3DTexture, public GrD3DRenderTarget { 27 public: 28 static sk_sp<GrD3DTextureRenderTarget> MakeNewTextureRenderTarget(GrD3DGpu*, SkBudgeted, 29 SkISize dimensions, 30 int sampleCnt, 31 const D3D12_RESOURCE_DESC&, 32 GrProtected isProtected, 33 GrMipmapStatus); 34 35 static sk_sp<GrD3DTextureRenderTarget> MakeWrappedTextureRenderTarget( 36 GrD3DGpu*, SkISize dimensions, int sampleCnt, GrWrapCacheable, 37 const GrD3DTextureResourceInfo&, sk_sp<GrD3DResourceState>); 38 backendFormat()39 GrBackendFormat backendFormat() const override { return this->getBackendFormat(); } 40 41 protected: onAbandon()42 void onAbandon() override { 43 // In order to correctly handle calling texture idle procs, GrD3DTexture must go first. 44 GrD3DTexture::onAbandon(); 45 GrD3DRenderTarget::onAbandon(); 46 } 47 onRelease()48 void onRelease() override { 49 // In order to correctly handle calling texture idle procs, GrD3DTexture must go first. 50 GrD3DTexture::onRelease(); 51 GrD3DRenderTarget::onRelease(); 52 } 53 54 private: 55 // MSAA, not-wrapped 56 GrD3DTextureRenderTarget(GrD3DGpu* gpu, 57 SkBudgeted budgeted, 58 SkISize dimensions, 59 const GrD3DTextureResourceInfo& info, 60 sk_sp<GrD3DResourceState> state, 61 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView, 62 const GrD3DTextureResourceInfo& msaaInfo, 63 sk_sp<GrD3DResourceState> msaaState, 64 const GrD3DDescriptorHeap::CPUHandle& colorRenderTargetView, 65 const GrD3DDescriptorHeap::CPUHandle& resolveRenderTargetView, 66 GrMipmapStatus); 67 68 // non-MSAA, not-wrapped 69 GrD3DTextureRenderTarget(GrD3DGpu* gpu, 70 SkBudgeted budgeted, 71 SkISize dimensions, 72 const GrD3DTextureResourceInfo& info, 73 sk_sp<GrD3DResourceState> state, 74 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView, 75 const GrD3DDescriptorHeap::CPUHandle& renderTargetView, 76 GrMipmapStatus); 77 78 // MSAA, wrapped 79 GrD3DTextureRenderTarget(GrD3DGpu* gpu, 80 SkISize dimensions, 81 const GrD3DTextureResourceInfo& info, 82 sk_sp<GrD3DResourceState> state, 83 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView, 84 const GrD3DTextureResourceInfo& msaaInfo, 85 sk_sp<GrD3DResourceState> msaaState, 86 const GrD3DDescriptorHeap::CPUHandle& colorRenderTargetView, 87 const GrD3DDescriptorHeap::CPUHandle& resolveRenderTargetView, 88 GrMipmapStatus, 89 GrWrapCacheable); 90 91 // non-MSAA, wrapped 92 GrD3DTextureRenderTarget(GrD3DGpu* gpu, 93 SkISize dimensions, 94 const GrD3DTextureResourceInfo& info, 95 sk_sp<GrD3DResourceState> state, 96 const GrD3DDescriptorHeap::CPUHandle& shaderResourceView, 97 const GrD3DDescriptorHeap::CPUHandle& renderTargetView, 98 GrMipmapStatus, 99 GrWrapCacheable); 100 101 // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory. 102 size_t onGpuMemorySize() const override; 103 104 // In Vulkan we call the release proc after we are finished with the underlying 105 // GrD3DImage::Resource object (which occurs after the GPU has finished all work on it). onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper)106 void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override { 107 // Forward the release proc on to GrD3DImage 108 this->setResourceRelease(std::move(releaseHelper)); 109 } 110 }; 111 112 #ifdef SK_BUILD_FOR_WIN 113 #pragma warning(pop) 114 #endif 115 116 #endif 117