| OLD | NEW |
| 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" |
| 11 #include "GrProcessor.h" | 11 #include "GrProcessor.h" |
| 12 #include "GrVkPipelineState.h" | 12 #include "GrVkPipelineState.h" |
| 13 #include "GrVkPipelineStateBuilder.h" | 13 #include "GrVkPipelineStateBuilder.h" |
| 14 #include "SkOpts.h" |
| 14 #include "glsl/GrGLSLFragmentProcessor.h" | 15 #include "glsl/GrGLSLFragmentProcessor.h" |
| 15 #include "glsl/GrGLSLProgramDataManager.h" | 16 #include "glsl/GrGLSLProgramDataManager.h" |
| 16 | 17 |
| 17 #ifdef GR_PIPELINE_STATE_CACHE_STATS | 18 #ifdef GR_PIPELINE_STATE_CACHE_STATS |
| 18 // Display pipeline state cache usage | 19 // Display pipeline state cache usage |
| 19 static const bool c_DisplayVkPipelineCache{false}; | 20 static const bool c_DisplayVkPipelineCache{false}; |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 struct GrVkResourceProvider::PipelineStateCache::Entry { | 23 struct GrVkResourceProvider::PipelineStateCache::Entry { |
| 23 | 24 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n"); | 106 GrCapsDebugf(fGpu->caps(), "Failed to build vk program descriptor!\n"); |
| 106 return nullptr; | 107 return nullptr; |
| 107 } | 108 } |
| 108 | 109 |
| 109 // Get vulkan specific descriptor key | 110 // Get vulkan specific descriptor key |
| 110 GrVkPipelineState::BuildStateKey(pipeline, primitiveType, &desc.fStateKey); | 111 GrVkPipelineState::BuildStateKey(pipeline, primitiveType, &desc.fStateKey); |
| 111 // Get checksum of entire PipelineDesc | 112 // Get checksum of entire PipelineDesc |
| 112 int keyLength = desc.fStateKey.count(); | 113 int keyLength = desc.fStateKey.count(); |
| 113 SkASSERT(0 == (keyLength % 4)); | 114 SkASSERT(0 == (keyLength % 4)); |
| 114 // Seed the checksum with the checksum of the programDesc then add the vulka
n key to it. | 115 // Seed the checksum with the checksum of the programDesc then add the vulka
n key to it. |
| 115 desc.fChecksum = SkChecksum::Murmur3(desc.fStateKey.begin(), keyLength, | 116 desc.fChecksum = SkOpts::hash(desc.fStateKey.begin(), keyLength, |
| 116 desc.fProgramDesc.getChecksum()); | 117 desc.fProgramDesc.getChecksum()); |
| 117 | 118 |
| 118 Entry* entry = nullptr; | 119 Entry* entry = nullptr; |
| 119 if (Entry** entryptr = fHashTable.find(desc)) { | 120 if (Entry** entryptr = fHashTable.find(desc)) { |
| 120 SkASSERT(*entryptr); | 121 SkASSERT(*entryptr); |
| 121 entry = *entryptr; | 122 entry = *entryptr; |
| 122 } | 123 } |
| 123 if (!entry) { | 124 if (!entry) { |
| 124 #ifdef GR_PIPELINE_STATE_CACHE_STATS | 125 #ifdef GR_PIPELINE_STATE_CACHE_STATS |
| 125 ++fCacheMisses; | 126 ++fCacheMisses; |
| 126 #endif | 127 #endif |
| (...skipping 20 matching lines...) Expand all Loading... |
| 147 entry->fPipelineState = std::move(pipelineState); | 148 entry->fPipelineState = std::move(pipelineState); |
| 148 fHashTable.set(entry); | 149 fHashTable.set(entry); |
| 149 fLRUList.addToTail(entry); | 150 fLRUList.addToTail(entry); |
| 150 return entry->fPipelineState; | 151 return entry->fPipelineState; |
| 151 } else { | 152 } else { |
| 152 fLRUList.remove(entry); | 153 fLRUList.remove(entry); |
| 153 fLRUList.addToTail(entry); | 154 fLRUList.addToTail(entry); |
| 154 } | 155 } |
| 155 return entry->fPipelineState; | 156 return entry->fPipelineState; |
| 156 } | 157 } |
| OLD | NEW |