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

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

Issue 2318143002: Merge building of program desc in Vulkan into one step (Closed)
Patch Set: more cleanup Created 4 years, 3 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/GrVkPipelineStateBuilder.cpp ('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 "GrVkGpu.h" 10 #include "GrVkGpu.h"
(...skipping 11 matching lines...) Expand all
22 22
23 struct GrVkResourceProvider::PipelineStateCache::Entry { 23 struct GrVkResourceProvider::PipelineStateCache::Entry {
24 24
25 Entry() : fPipelineState(nullptr) {} 25 Entry() : fPipelineState(nullptr) {}
26 26
27 static const GrVkPipelineState::Desc& GetKey(const Entry* entry) { 27 static const GrVkPipelineState::Desc& GetKey(const Entry* entry) {
28 return entry->fPipelineState->getDesc(); 28 return entry->fPipelineState->getDesc();
29 } 29 }
30 30
31 static uint32_t Hash(const GrVkPipelineState::Desc& key) { 31 static uint32_t Hash(const GrVkPipelineState::Desc& key) {
32 return key.fChecksum; 32 return key.getChecksum();
33 } 33 }
34 34
35 sk_sp<GrVkPipelineState> fPipelineState; 35 sk_sp<GrVkPipelineState> fPipelineState;
36 36
37 private: 37 private:
38 SK_DECLARE_INTERNAL_LLIST_INTERFACE(Entry); 38 SK_DECLARE_INTERNAL_LLIST_INTERFACE(Entry);
39 }; 39 };
40 40
41 GrVkResourceProvider::PipelineStateCache::PipelineStateCache(GrVkGpu* gpu) 41 GrVkResourceProvider::PipelineStateCache::PipelineStateCache(GrVkGpu* gpu)
42 : fCount(0) 42 : fCount(0)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt ate( 92 sk_sp<GrVkPipelineState> GrVkResourceProvider::PipelineStateCache::refPipelineSt ate(
93 const GrPipeline& pipeline, 93 const GrPipeline& pipeline,
94 const GrPrimitive Processor& primProc, 94 const GrPrimitive Processor& primProc,
95 GrPrimitiveType p rimitiveType, 95 GrPrimitiveType p rimitiveType,
96 const GrVkRenderP ass& renderPass) { 96 const GrVkRenderP ass& renderPass) {
97 #ifdef GR_PIPELINE_STATE_CACHE_STATS 97 #ifdef GR_PIPELINE_STATE_CACHE_STATS
98 ++fTotalRequests; 98 ++fTotalRequests;
99 #endif 99 #endif
100 // Get GrVkProgramDesc 100 // Get GrVkProgramDesc
101 GrVkPipelineState::Desc desc; 101 GrVkPipelineState::Desc desc;
102 if (!GrProgramDesc::Build(&desc.fProgramDesc, primProc, pipeline, *fGpu->vkC aps().glslCaps())) { 102 if (!GrVkPipelineState::Desc::Build(&desc, primProc, pipeline, primitiveType ,
103 *fGpu->vkCaps().glslCaps())) {
103 GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n"); 104 GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n");
104 return nullptr; 105 return nullptr;
105 } 106 }
106 desc.fProgramDesc.finalize(); 107 desc.finalize();
107
108 // Get vulkan specific descriptor key
109 GrVkPipelineState::BuildStateKey(pipeline, primitiveType, &desc.fStateKey);
110 // Get checksum of entire PipelineDesc
111 int keyLength = desc.fStateKey.count();
112 SkASSERT(0 == (keyLength % 4));
113 // Seed the checksum with the checksum of the programDesc then add the vulka n key to it.
114 desc.fChecksum = SkOpts::hash(desc.fStateKey.begin(), keyLength,
115 desc.fProgramDesc.getChecksum());
116 108
117 Entry* entry = nullptr; 109 Entry* entry = nullptr;
118 if (Entry** entryptr = fHashTable.find(desc)) { 110 if (Entry** entryptr = fHashTable.find(desc)) {
119 SkASSERT(*entryptr); 111 SkASSERT(*entryptr);
120 entry = *entryptr; 112 entry = *entryptr;
121 } 113 }
122 if (!entry) { 114 if (!entry) {
123 #ifdef GR_PIPELINE_STATE_CACHE_STATS 115 #ifdef GR_PIPELINE_STATE_CACHE_STATS
124 ++fCacheMisses; 116 ++fCacheMisses;
125 #endif 117 #endif
(...skipping 20 matching lines...) Expand all
146 entry->fPipelineState = std::move(pipelineState); 138 entry->fPipelineState = std::move(pipelineState);
147 fHashTable.set(entry); 139 fHashTable.set(entry);
148 fLRUList.addToTail(entry); 140 fLRUList.addToTail(entry);
149 return entry->fPipelineState; 141 return entry->fPipelineState;
150 } else { 142 } else {
151 fLRUList.remove(entry); 143 fLRUList.remove(entry);
152 fLRUList.addToTail(entry); 144 fLRUList.addToTail(entry);
153 } 145 }
154 return entry->fPipelineState; 146 return entry->fPipelineState;
155 } 147 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkPipelineStateBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698