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

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

Issue 1756493002: Use VkPipelineCaches during VkPipeline creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix mipmap issues Created 4 years, 9 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/GrVkResourceProvider.h ('k') | no next file » | 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 #include "GrVkResourceProvider.h" 8 #include "GrVkResourceProvider.h"
9 9
10 #include "GrVkCommandBuffer.h" 10 #include "GrVkCommandBuffer.h"
11 #include "GrVkPipeline.h" 11 #include "GrVkPipeline.h"
12 #include "GrVkRenderPass.h" 12 #include "GrVkRenderPass.h"
13 #include "GrVkUtil.h" 13 #include "GrVkUtil.h"
14 14
15 #ifdef SK_TRACE_VK_RESOURCES 15 #ifdef SK_TRACE_VK_RESOURCES
16 SkTDynamicHash<GrVkResource, uint32_t> GrVkResource::fTrace; 16 SkTDynamicHash<GrVkResource, uint32_t> GrVkResource::fTrace;
17 SkRandom GrVkResource::fRandom; 17 SkRandom GrVkResource::fRandom;
18 #endif 18 #endif
19 19
20 GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) : fGpu(gpu) { 20 GrVkResourceProvider::GrVkResourceProvider(GrVkGpu* gpu) : fGpu(gpu)
21 , fPipelineCache(VK_NUL L_HANDLE) {
21 } 22 }
22 23
23 GrVkResourceProvider::~GrVkResourceProvider() { 24 GrVkResourceProvider::~GrVkResourceProvider() {
24 SkASSERT(0 == fSimpleRenderPasses.count()); 25 SkASSERT(0 == fSimpleRenderPasses.count());
26 SkASSERT(VK_NULL_HANDLE == fPipelineCache);
27 }
28
29 void GrVkResourceProvider::init() {
30 VkPipelineCacheCreateInfo createInfo;
31 memset(&createInfo, 0, sizeof(VkPipelineCacheCreateInfo));
32 createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
33 createInfo.pNext = nullptr;
34 createInfo.flags = 0;
35 createInfo.initialDataSize = 0;
36 createInfo.pInitialData = nullptr;
37 VkResult result = GR_VK_CALL(fGpu->vkInterface(),
38 CreatePipelineCache(fGpu->device(), &createInfo , nullptr,
39 &fPipelineCache));
40 SkASSERT(VK_SUCCESS == result);
41 if (VK_SUCCESS != result) {
42 fPipelineCache = VK_NULL_HANDLE;
43 }
25 } 44 }
26 45
27 GrVkPipeline* GrVkResourceProvider::createPipeline(const GrPipeline& pipeline, 46 GrVkPipeline* GrVkResourceProvider::createPipeline(const GrPipeline& pipeline,
28 const GrPrimitiveProcessor& p rimProc, 47 const GrPrimitiveProcessor& p rimProc,
29 VkPipelineShaderStageCreateIn fo* shaderStageInfo, 48 VkPipelineShaderStageCreateIn fo* shaderStageInfo,
30 int shaderStageCount, 49 int shaderStageCount,
31 GrPrimitiveType primitiveType , 50 GrPrimitiveType primitiveType ,
32 const GrVkRenderPass& renderP ass, 51 const GrVkRenderPass& renderP ass,
33 VkPipelineLayout layout) { 52 VkPipelineLayout layout) {
34 53
35 return GrVkPipeline::Create(fGpu, pipeline, primProc, shaderStageInfo, shade rStageCount, 54 return GrVkPipeline::Create(fGpu, pipeline, primProc, shaderStageInfo, shade rStageCount,
36 primitiveType, renderPass, layout); 55 primitiveType, renderPass, layout, fPipelineCach e);
37 } 56 }
38 57
39 58
40 // To create framebuffers, we first need to create a simple RenderPass that is 59 // To create framebuffers, we first need to create a simple RenderPass that is
41 // only used for framebuffer creation. When we actually render we will create 60 // only used for framebuffer creation. When we actually render we will create
42 // RenderPasses as needed that are compatible with the framebuffer. 61 // RenderPasses as needed that are compatible with the framebuffer.
43 const GrVkRenderPass* 62 const GrVkRenderPass*
44 GrVkResourceProvider::findOrCreateCompatibleRenderPass(const GrVkRenderTarget& t arget) { 63 GrVkResourceProvider::findOrCreateCompatibleRenderPass(const GrVkRenderTarget& t arget) {
45 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { 64 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) {
46 GrVkRenderPass* renderPass = fSimpleRenderPasses[i]; 65 GrVkRenderPass* renderPass = fSimpleRenderPasses[i];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // loop over all render passes to make sure we destroy all the internal VkRe nderPasses 109 // loop over all render passes to make sure we destroy all the internal VkRe nderPasses
91 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { 110 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) {
92 fSimpleRenderPasses[i]->unref(fGpu); 111 fSimpleRenderPasses[i]->unref(fGpu);
93 } 112 }
94 fSimpleRenderPasses.reset(); 113 fSimpleRenderPasses.reset();
95 114
96 #ifdef SK_TRACE_VK_RESOURCES 115 #ifdef SK_TRACE_VK_RESOURCES
97 SkASSERT(0 == GrVkResource::fTrace.count()); 116 SkASSERT(0 == GrVkResource::fTrace.count());
98 #endif 117 #endif
99 118
119 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineCache(fGpu->device(), fPipeli neCache, nullptr));
120 fPipelineCache = VK_NULL_HANDLE;
100 } 121 }
101 122
102 void GrVkResourceProvider::abandonResources() { 123 void GrVkResourceProvider::abandonResources() {
103 // release our current command buffers 124 // release our current command buffers
104 for (int i = 0; i < fActiveCommandBuffers.count(); ++i) { 125 for (int i = 0; i < fActiveCommandBuffers.count(); ++i) {
105 SkASSERT(fActiveCommandBuffers[i]->finished(fGpu)); 126 SkASSERT(fActiveCommandBuffers[i]->finished(fGpu));
106 fActiveCommandBuffers[i]->unrefAndAbandon(); 127 fActiveCommandBuffers[i]->unrefAndAbandon();
107 } 128 }
108 fActiveCommandBuffers.reset(); 129 fActiveCommandBuffers.reset();
109 130
110 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) { 131 for (int i = 0; i < fSimpleRenderPasses.count(); ++i) {
111 fSimpleRenderPasses[i]->unrefAndAbandon(); 132 fSimpleRenderPasses[i]->unrefAndAbandon();
112 } 133 }
113 fSimpleRenderPasses.reset(); 134 fSimpleRenderPasses.reset();
114 135
115 #ifdef SK_TRACE_VK_RESOURCES 136 #ifdef SK_TRACE_VK_RESOURCES
116 SkASSERT(0 == GrVkResource::fTrace.count()); 137 SkASSERT(0 == GrVkResource::fTrace.count());
117 #endif 138 #endif
118 } 139 fPipelineCache = VK_NULL_HANDLE;
140 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkResourceProvider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698