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

Side by Side Diff: src/gpu/vk/GrVkRenderTarget.h

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/GrVkPipelineState.cpp ('k') | src/gpu/vk/GrVkRenderTarget.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 8
9 #ifndef GrVkRenderTarget_DEFINED 9 #ifndef GrVkRenderTarget_DEFINED
10 #define GrVkRenderTarget_DEFINED 10 #define GrVkRenderTarget_DEFINED
11 11
12 #include "GrVkImage.h" 12 #include "GrVkImage.h"
13 #include "GrRenderTarget.h" 13 #include "GrRenderTarget.h"
14 14
15 #include "GrVkRenderPass.h" 15 #include "GrVkRenderPass.h"
16 16
17 class GrVkCommandBuffer; 17 class GrVkCommandBuffer;
18 class GrVkFramebuffer; 18 class GrVkFramebuffer;
19 class GrVkGpu; 19 class GrVkGpu;
20 class GrVkImageView; 20 class GrVkImageView;
21 class GrVkStencilAttachment; 21 class GrVkStencilAttachment;
22 22
23 struct GrVkTextureInfo; 23 struct GrVkImageInfo;
24 24
25 #ifdef SK_BUILD_FOR_WIN 25 #ifdef SK_BUILD_FOR_WIN
26 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via do minance. 26 // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via do minance.
27 #pragma warning(push) 27 #pragma warning(push)
28 #pragma warning(disable: 4250) 28 #pragma warning(disable: 4250)
29 #endif 29 #endif
30 30
31 class GrVkRenderTarget: public GrRenderTarget, public virtual GrVkImage { 31 class GrVkRenderTarget: public GrRenderTarget, public virtual GrVkImage {
32 public: 32 public:
33 static GrVkRenderTarget* CreateNewRenderTarget(GrVkGpu*, SkBudgeted, const G rSurfaceDesc&, 33 static GrVkRenderTarget* CreateNewRenderTarget(GrVkGpu*, SkBudgeted, const G rSurfaceDesc&,
34 const GrVkImage::ImageDesc&); 34 const GrVkImage::ImageDesc&);
35 35
36 static GrVkRenderTarget* CreateWrappedRenderTarget(GrVkGpu*, const GrSurface Desc&, 36 static GrVkRenderTarget* CreateWrappedRenderTarget(GrVkGpu*, const GrSurface Desc&,
37 GrWrapOwnership, 37 GrWrapOwnership,
38 const GrVkTextureInfo*); 38 const GrVkImageInfo*);
39 39
40 ~GrVkRenderTarget() override; 40 ~GrVkRenderTarget() override;
41 41
42 const GrVkFramebuffer* framebuffer() const { return fFramebuffer; } 42 const GrVkFramebuffer* framebuffer() const { return fFramebuffer; }
43 const GrVkImageView* colorAttachmentView() const { return fColorAttachmentVi ew; } 43 const GrVkImageView* colorAttachmentView() const { return fColorAttachmentVi ew; }
44 const GrVkImage::Resource* msaaImageResource() const { return fMSAAImageReso urce; } 44 const GrVkResource* msaaImageResource() const {
45 if (fMSAAImage) {
46 return fMSAAImage->fResource;
47 }
48 return nullptr;
49 }
45 const GrVkImageView* resolveAttachmentView() const { return fResolveAttachme ntView; } 50 const GrVkImageView* resolveAttachmentView() const { return fResolveAttachme ntView; }
46 const GrVkImage::Resource* stencilImageResource() const; 51 const GrVkResource* stencilImageResource() const;
47 const GrVkImageView* stencilAttachmentView() const; 52 const GrVkImageView* stencilAttachmentView() const;
48 53
49 const GrVkRenderPass* simpleRenderPass() const { return fCachedSimpleRenderP ass; } 54 const GrVkRenderPass* simpleRenderPass() const { return fCachedSimpleRenderP ass; }
50 55
51 // override of GrRenderTarget 56 // override of GrRenderTarget
52 ResolveType getResolveType() const override { 57 ResolveType getResolveType() const override {
53 return kCanResolve_ResolveType; 58 return kCanResolve_ResolveType;
54 } 59 }
55 60
56 bool canAttemptStencilAttachment() const override { 61 bool canAttemptStencilAttachment() const override {
57 return true; 62 return true;
58 } 63 }
59 64
60 GrBackendObject getRenderTargetHandle() const override; 65 GrBackendObject getRenderTargetHandle() const override;
61 66
62 // Returns the total number of attachments 67 // Returns the total number of attachments
63 void getAttachmentsDescriptor(GrVkRenderPass::AttachmentsDescriptor* desc, 68 void getAttachmentsDescriptor(GrVkRenderPass::AttachmentsDescriptor* desc,
64 GrVkRenderPass::AttachmentFlags* flags) const; 69 GrVkRenderPass::AttachmentFlags* flags) const;
65 70
66 void addResources(GrVkCommandBuffer& commandBuffer) const; 71 void addResources(GrVkCommandBuffer& commandBuffer) const;
67 72
68 protected: 73 protected:
69 GrVkRenderTarget(GrVkGpu* gpu, 74 GrVkRenderTarget(GrVkGpu* gpu,
70 SkBudgeted,
71 const GrSurfaceDesc& desc, 75 const GrSurfaceDesc& desc,
72 const GrVkImage::Resource* imageResource, 76 const GrVkImageInfo& info,
73 const GrVkImage::Resource* msaaImageResource, 77 const GrVkImageInfo& msaaInfo,
74 const GrVkImageView* colorAttachmentView, 78 const GrVkImageView* colorAttachmentView,
75 const GrVkImageView* resolveAttachmentView); 79 const GrVkImageView* resolveAttachmentView,
80 GrVkImage::Wrapped wrapped);
76 81
77 GrVkRenderTarget(GrVkGpu* gpu, 82 GrVkRenderTarget(GrVkGpu* gpu,
78 const GrSurfaceDesc& desc, 83 const GrSurfaceDesc& desc,
79 const GrVkImage::Resource* imageResource, 84 const GrVkImageInfo& info,
80 const GrVkImage::Resource* msaaImageResource,
81 const GrVkImageView* colorAttachmentView, 85 const GrVkImageView* colorAttachmentView,
82 const GrVkImageView* resolveAttachmentView); 86 GrVkImage::Wrapped wrapped);
83
84 GrVkRenderTarget(GrVkGpu* gpu,
85 SkBudgeted,
86 const GrSurfaceDesc& desc,
87 const GrVkImage::Resource* imageResource,
88 const GrVkImageView* colorAttachmentView);
89
90 GrVkRenderTarget(GrVkGpu* gpu,
91 const GrSurfaceDesc& desc,
92 const GrVkImage::Resource* imageResource,
93 const GrVkImageView* colorAttachmentView);
94
95 static GrVkRenderTarget* Create(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&,
96 const GrVkImage::Resource* imageResource);
97 87
98 GrVkGpu* getVkGpu() const; 88 GrVkGpu* getVkGpu() const;
99 89
100 void onAbandon() override; 90 void onAbandon() override;
101 void onRelease() override; 91 void onRelease() override;
102 92
103 // This accounts for the texture's memory and any MSAA renderbuffer's memory . 93 // This accounts for the texture's memory and any MSAA renderbuffer's memory .
104 size_t onGpuMemorySize() const override { 94 size_t onGpuMemorySize() const override {
105 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig); 95 SkASSERT(kUnknown_GrPixelConfig != fDesc.fConfig);
106 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig)); 96 SkASSERT(!GrPixelConfigIsCompressed(fDesc.fConfig));
107 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig); 97 size_t colorBytes = GrBytesPerPixel(fDesc.fConfig);
108 SkASSERT(colorBytes > 0); 98 SkASSERT(colorBytes > 0);
109 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes; 99 return fColorValuesPerPixel * fDesc.fWidth * fDesc.fHeight * colorBytes;
110 } 100 }
111 101
112 private: 102 private:
103 GrVkRenderTarget(GrVkGpu* gpu,
104 SkBudgeted,
105 const GrSurfaceDesc& desc,
106 const GrVkImageInfo& info,
107 const GrVkImageInfo& msaaInfo,
108 const GrVkImageView* colorAttachmentView,
109 const GrVkImageView* resolveAttachmentView,
110 GrVkImage::Wrapped wrapped);
111
112 GrVkRenderTarget(GrVkGpu* gpu,
113 SkBudgeted,
114 const GrSurfaceDesc& desc,
115 const GrVkImageInfo& info,
116 const GrVkImageView* colorAttachmentView,
117 GrVkImage::Wrapped wrapped);
118
119 static GrVkRenderTarget* Create(GrVkGpu*, SkBudgeted, const GrSurfaceDesc&,
120 const GrVkImageInfo&, GrVkImage::Wrapped wra pped);
121
113 bool completeStencilAttachment() override; 122 bool completeStencilAttachment() override;
114 123
115 void createFramebuffer(GrVkGpu* gpu); 124 void createFramebuffer(GrVkGpu* gpu);
116 125
117 void releaseInternalObjects(); 126 void releaseInternalObjects();
118 void abandonInternalObjects(); 127 void abandonInternalObjects();
119 128
120 const GrVkFramebuffer* fFramebuffer; 129 const GrVkFramebuffer* fFramebuffer;
121 const GrVkImageView* fColorAttachmentView; 130 const GrVkImageView* fColorAttachmentView;
122 const GrVkImage::Resource* fMSAAImageResource; 131 GrVkImage* fMSAAImage;
123 const GrVkImageView* fResolveAttachmentView; 132 const GrVkImageView* fResolveAttachmentView;
124 int fColorValuesPerPixel; 133 int fColorValuesPerPixel;
125 134
126 // This is a cached pointer to a simple render pass. The render target shoul d unref it 135 // This is a cached pointer to a simple render pass. The render target shoul d unref it
127 // once it is done with it. 136 // once it is done with it.
128 const GrVkRenderPass* fCachedSimpleRenderPass; 137 const GrVkRenderPass* fCachedSimpleRenderPass;
129 }; 138 };
130 139
131 #endif 140 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkPipelineState.cpp ('k') | src/gpu/vk/GrVkRenderTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698