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

Side by Side Diff: tests/VkWrapTests.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/GrVkTextureRenderTarget.cpp ('k') | tools/viewer/sk_app/VulkanWindowContext.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 2016 Google Inc. 2 * Copyright 2016 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 // This is a GPU-backend specific test. It relies on static intializers to work 8 // This is a GPU-backend specific test. It relies on static intializers to work
9 9
10 #include "SkTypes.h" 10 #include "SkTypes.h"
(...skipping 12 matching lines...) Expand all
23 23
24 const int kW = 1024; 24 const int kW = 1024;
25 const int kH = 1024; 25 const int kH = 1024;
26 const GrPixelConfig kPixelConfig = kRGBA_8888_GrPixelConfig; 26 const GrPixelConfig kPixelConfig = kRGBA_8888_GrPixelConfig;
27 27
28 void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) { 28 void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
29 29
30 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); 30 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
31 31
32 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k W, kH, kPixelConfig); 32 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k W, kH, kPixelConfig);
33 const GrVkTextureInfo* backendTex = reinterpret_cast<const GrVkTextureInfo*> (backendObj); 33 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac kendObj);
34 34
35 // check basic borrowed creation 35 // check basic borrowed creation
36 GrBackendTextureDesc desc; 36 GrBackendTextureDesc desc;
37 desc.fConfig = kPixelConfig; 37 desc.fConfig = kPixelConfig;
38 desc.fWidth = kW; 38 desc.fWidth = kW;
39 desc.fHeight = kH; 39 desc.fHeight = kH;
40 desc.fTextureHandle = backendObj; 40 desc.fTextureHandle = backendObj;
41 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); 41 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
42 REPORTER_ASSERT(reporter, tex); 42 REPORTER_ASSERT(reporter, tex);
43 tex->unref(); 43 tex->unref();
44 44
45 // image is null 45 // image is null
46 GrVkTextureInfo backendCopy = *backendTex; 46 GrVkImageInfo backendCopy = *backendTex;
47 backendCopy.fImage = VK_NULL_HANDLE; 47 backendCopy.fImage = VK_NULL_HANDLE;
48 desc.fTextureHandle = (GrBackendObject) &backendCopy; 48 desc.fTextureHandle = (GrBackendObject) &backendCopy;
49 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); 49 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
50 REPORTER_ASSERT(reporter, !tex); 50 REPORTER_ASSERT(reporter, !tex);
51 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); 51 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership);
52 REPORTER_ASSERT(reporter, !tex); 52 REPORTER_ASSERT(reporter, !tex);
53 53
54 // alloc is null 54 // alloc is null
55 backendCopy.fImage = backendTex->fImage; 55 backendCopy.fImage = backendTex->fImage;
56 backendCopy.fAlloc = VK_NULL_HANDLE; 56 backendCopy.fAlloc = VK_NULL_HANDLE;
57 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); 57 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
58 REPORTER_ASSERT(reporter, !tex); 58 REPORTER_ASSERT(reporter, !tex);
59 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); 59 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership);
60 REPORTER_ASSERT(reporter, !tex); 60 REPORTER_ASSERT(reporter, !tex);
61 61
62 // check adopt creation 62 // check adopt creation
63 backendCopy.fAlloc = backendTex->fAlloc; 63 backendCopy.fAlloc = backendTex->fAlloc;
64 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); 64 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership);
65 REPORTER_ASSERT(reporter, tex); 65 REPORTER_ASSERT(reporter, tex);
66 tex->unref(); 66 tex->unref();
67 67
68 gpu->deleteTestingOnlyBackendTexture(backendObj, true); 68 gpu->deleteTestingOnlyBackendTexture(backendObj, true);
69 } 69 }
70 70
71 void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { 71 void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
72 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); 72 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
73 73
74 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k W, kH, kPixelConfig); 74 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k W, kH, kPixelConfig);
75 const GrVkTextureInfo* backendTex = reinterpret_cast<const GrVkTextureInfo*> (backendObj); 75 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac kendObj);
76 76
77 // check basic borrowed creation 77 // check basic borrowed creation
78 GrBackendRenderTargetDesc desc; 78 GrBackendRenderTargetDesc desc;
79 desc.fWidth = kW; 79 desc.fWidth = kW;
80 desc.fHeight = kH; 80 desc.fHeight = kH;
81 desc.fConfig = kPixelConfig; 81 desc.fConfig = kPixelConfig;
82 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 82 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
83 desc.fSampleCnt = 0; 83 desc.fSampleCnt = 0;
84 desc.fStencilBits = 0; 84 desc.fStencilBits = 0;
85 desc.fRenderTargetHandle = backendObj; 85 desc.fRenderTargetHandle = backendObj;
86 GrRenderTarget* rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwners hip); 86 GrRenderTarget* rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwners hip);
87 REPORTER_ASSERT(reporter, rt); 87 REPORTER_ASSERT(reporter, rt);
88 rt->unref(); 88 rt->unref();
89 89
90 // image is null 90 // image is null
91 GrVkTextureInfo backendCopy = *backendTex; 91 GrVkImageInfo backendCopy = *backendTex;
92 backendCopy.fImage = VK_NULL_HANDLE; 92 backendCopy.fImage = VK_NULL_HANDLE;
93 desc.fRenderTargetHandle = (GrBackendObject)&backendCopy; 93 desc.fRenderTargetHandle = (GrBackendObject)&backendCopy;
94 rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership); 94 rt = gpu->wrapBackendRenderTarget(desc, kBorrow_GrWrapOwnership);
95 REPORTER_ASSERT(reporter, !rt); 95 REPORTER_ASSERT(reporter, !rt);
96 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership); 96 rt = gpu->wrapBackendRenderTarget(desc, kAdopt_GrWrapOwnership);
97 REPORTER_ASSERT(reporter, !rt); 97 REPORTER_ASSERT(reporter, !rt);
98 98
99 // alloc is null 99 // alloc is null
100 backendCopy.fImage = backendTex->fImage; 100 backendCopy.fImage = backendTex->fImage;
101 backendCopy.fAlloc = VK_NULL_HANDLE; 101 backendCopy.fAlloc = VK_NULL_HANDLE;
(...skipping 10 matching lines...) Expand all
112 REPORTER_ASSERT(reporter, rt); 112 REPORTER_ASSERT(reporter, rt);
113 rt->unref(); 113 rt->unref();
114 114
115 gpu->deleteTestingOnlyBackendTexture(backendObj, true); 115 gpu->deleteTestingOnlyBackendTexture(backendObj, true);
116 } 116 }
117 117
118 void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { 118 void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
119 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu()); 119 GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
120 120
121 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k W, kH, kPixelConfig); 121 GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, k W, kH, kPixelConfig);
122 const GrVkTextureInfo* backendTex = reinterpret_cast<const GrVkTextureInfo*> (backendObj); 122 const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(bac kendObj);
123 123
124 // check basic borrowed creation 124 // check basic borrowed creation
125 GrBackendTextureDesc desc; 125 GrBackendTextureDesc desc;
126 desc.fFlags = kRenderTarget_GrBackendTextureFlag; 126 desc.fFlags = kRenderTarget_GrBackendTextureFlag;
127 desc.fConfig = kPixelConfig; 127 desc.fConfig = kPixelConfig;
128 desc.fWidth = kW; 128 desc.fWidth = kW;
129 desc.fHeight = kH; 129 desc.fHeight = kH;
130 desc.fTextureHandle = backendObj; 130 desc.fTextureHandle = backendObj;
131 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); 131 GrTexture* tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
132 REPORTER_ASSERT(reporter, tex); 132 REPORTER_ASSERT(reporter, tex);
133 tex->unref(); 133 tex->unref();
134 134
135 // image is null 135 // image is null
136 GrVkTextureInfo backendCopy = *backendTex; 136 GrVkImageInfo backendCopy = *backendTex;
137 backendCopy.fImage = VK_NULL_HANDLE; 137 backendCopy.fImage = VK_NULL_HANDLE;
138 desc.fTextureHandle = (GrBackendObject)&backendCopy; 138 desc.fTextureHandle = (GrBackendObject)&backendCopy;
139 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership); 139 tex = gpu->wrapBackendTexture(desc, kBorrow_GrWrapOwnership);
140 REPORTER_ASSERT(reporter, !tex); 140 REPORTER_ASSERT(reporter, !tex);
141 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership); 141 tex = gpu->wrapBackendTexture(desc, kAdopt_GrWrapOwnership);
142 REPORTER_ASSERT(reporter, !tex); 142 REPORTER_ASSERT(reporter, !tex);
143 143
144 // alloc is null 144 // alloc is null
145 backendCopy.fImage = backendTex->fImage; 145 backendCopy.fImage = backendTex->fImage;
146 backendCopy.fAlloc = VK_NULL_HANDLE; 146 backendCopy.fAlloc = VK_NULL_HANDLE;
(...skipping 11 matching lines...) Expand all
158 gpu->deleteTestingOnlyBackendTexture(backendObj, true); 158 gpu->deleteTestingOnlyBackendTexture(backendObj, true);
159 } 159 }
160 160
161 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) { 161 DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkWrapTests, reporter, ctxInfo) {
162 wrap_tex_test(reporter, ctxInfo.grContext()); 162 wrap_tex_test(reporter, ctxInfo.grContext());
163 wrap_rt_test(reporter, ctxInfo.grContext()); 163 wrap_rt_test(reporter, ctxInfo.grContext());
164 wrap_trt_test(reporter, ctxInfo.grContext()); 164 wrap_trt_test(reporter, ctxInfo.grContext());
165 } 165 }
166 166
167 #endif 167 #endif
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkTextureRenderTarget.cpp ('k') | tools/viewer/sk_app/VulkanWindowContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698