Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 GrVkProgram_DEFINED | 9 #ifndef GrVkProgram_DEFINED |
| 10 #define GrVkProgram_DEFINED | 10 #define GrVkProgram_DEFINED |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 void addUniformResources(GrVkCommandBuffer&); | 40 void addUniformResources(GrVkCommandBuffer&); |
| 41 | 41 |
| 42 void freeGPUResources(const GrVkGpu* gpu); | 42 void freeGPUResources(const GrVkGpu* gpu); |
| 43 | 43 |
| 44 // This releases resources the only a given instance of a GrVkProgram needs to hold onto and do | 44 // This releases resources the only a given instance of a GrVkProgram needs to hold onto and do |
| 45 // don't need to survive across new uses of the program. | 45 // don't need to survive across new uses of the program. |
| 46 void freeTempResources(const GrVkGpu* gpu); | 46 void freeTempResources(const GrVkGpu* gpu); |
| 47 | 47 |
| 48 void abandonGPUResources(); | 48 void abandonGPUResources(); |
| 49 | 49 |
| 50 // The key is composed of two parts: | |
| 51 // 1. uint32_t for total key length | |
| 52 // 2. Vulkan specific data | |
| 53 enum KeyOffsets { | |
| 54 // Part 1. | |
| 55 kLength_KeyOffset = 0, | |
| 56 // Part 2. | |
| 57 kData_KeyOffset = kLength_KeyOffset + sizeof(uint32_t), | |
| 58 }; | |
| 59 | |
| 60 static void BuildVkKey(const GrPipeline&, GrPrimitiveType primitiveType, | |
| 61 SkTArray<unsigned char, true>* key); | |
| 62 | |
| 63 struct PipelineDesc { | |
| 64 uint32_t fChecksum; | |
| 65 GrVkProgramDesc fProgramDesc; | |
| 66 SkTArray<uint8_t, true> fVkKey; | |
|
bsalomon
2016/03/22 14:00:33
Any idea what the typical size is? Wonder if we sh
egdaniel
2016/03/22 20:06:14
Changed this to STArray
| |
| 67 | |
| 68 bool operator== (const PipelineDesc& that) const { | |
| 69 if (fChecksum != that.fChecksum || fProgramDesc != that.fProgramDesc ) { | |
| 70 return false; | |
| 71 } | |
| 72 // We store the keyLength at the start of fVkKey. Thus we don't have to worry about | |
| 73 // different length keys since we will fail on the comparison immedi ately. Therefore we | |
| 74 // just use this PipelineDesc to get the length to iterate over. | |
| 75 int keyLength = fVkKey.count(); | |
| 76 SkASSERT(SkIsAlign4(keyLength)); | |
| 77 int l = keyLength >> 2; | |
| 78 const uint32_t* aKey = reinterpret_cast<const uint32_t*>(fVkKey.begi n()); | |
| 79 const uint32_t* bKey = reinterpret_cast<const uint32_t*>(that.fVkKey .begin());; | |
| 80 for (int i = 0; i < l; ++i) { | |
| 81 if (aKey[i] != bKey[i]) { | |
| 82 return false; | |
| 83 } | |
| 84 } | |
| 85 return true; | |
| 86 } | |
| 87 | |
| 88 static bool Less(const PipelineDesc& a, const PipelineDesc& b) { | |
|
jvanverth1
2016/03/21 21:16:16
Is there a reason you didn't use operator<?
egdaniel
2016/03/21 22:23:52
Mostly just following the template from GL. SkTSea
| |
| 89 if (a.fChecksum != b.fChecksum) { | |
| 90 return a.fChecksum < b.fChecksum ? true : false; | |
| 91 } | |
| 92 bool progDescLess = GrProgramDesc::Less(a.fProgramDesc, b.fProgramDe sc); | |
| 93 if (progDescLess || a.fProgramDesc != b.fProgramDesc) { | |
| 94 return progDescLess; | |
| 95 } | |
| 96 | |
| 97 int keyLength = a.fVkKey.count(); | |
| 98 SkASSERT(SkIsAlign4(keyLength)); | |
| 99 int l = keyLength >> 2; | |
| 100 const uint32_t* aKey = reinterpret_cast<const uint32_t*>(a.fVkKey.be gin()); | |
| 101 const uint32_t* bKey = reinterpret_cast<const uint32_t*>(b.fVkKey.be gin());; | |
| 102 for (int i = 0; i < l; ++i) { | |
| 103 if (aKey[i] != bKey[i]) { | |
| 104 return aKey[i] < bKey[i] ? true : false; | |
| 105 } | |
| 106 } | |
| 107 return false; | |
| 108 } | |
| 109 | |
| 110 }; | |
| 111 | |
| 112 const PipelineDesc& getDesc() { return fPipelineDesc; } | |
| 113 | |
| 50 private: | 114 private: |
| 51 typedef GrVkProgramDataManager::UniformInfoArray UniformInfoArray; | 115 typedef GrVkProgramDataManager::UniformInfoArray UniformInfoArray; |
| 52 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; | 116 typedef GrGLSLProgramDataManager::UniformHandle UniformHandle; |
| 53 | 117 |
| 54 GrVkProgram(GrVkGpu* gpu, | 118 GrVkProgram(GrVkGpu* gpu, |
| 119 const GrVkProgram::PipelineDesc&, | |
| 55 GrVkPipeline* pipeline, | 120 GrVkPipeline* pipeline, |
| 56 VkPipelineLayout layout, | 121 VkPipelineLayout layout, |
| 57 VkDescriptorSetLayout dsLayout[2], | 122 VkDescriptorSetLayout dsLayout[2], |
| 58 const BuiltinUniformHandles& builtinUniformHandles, | 123 const BuiltinUniformHandles& builtinUniformHandles, |
| 59 const UniformInfoArray& uniforms, | 124 const UniformInfoArray& uniforms, |
| 60 uint32_t vertexUniformSize, | 125 uint32_t vertexUniformSize, |
| 61 uint32_t fragmentUniformSize, | 126 uint32_t fragmentUniformSize, |
| 62 uint32_t numSamplers, | 127 uint32_t numSamplers, |
| 63 GrGLSLPrimitiveProcessor* geometryProcessor, | 128 GrGLSLPrimitiveProcessor* geometryProcessor, |
| 64 GrGLSLXferProcessor* xferProcessor, | 129 GrGLSLXferProcessor* xferProcessor, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 235 |
| 171 // Tracks the current render target uniforms stored in the vertex buffer. | 236 // Tracks the current render target uniforms stored in the vertex buffer. |
| 172 RenderTargetState fRenderTargetState; | 237 RenderTargetState fRenderTargetState; |
| 173 BuiltinUniformHandles fBuiltinUniformHandles; | 238 BuiltinUniformHandles fBuiltinUniformHandles; |
| 174 | 239 |
| 175 // Processors in the program | 240 // Processors in the program |
| 176 SkAutoTDelete<GrGLSLPrimitiveProcessor> fGeometryProcessor; | 241 SkAutoTDelete<GrGLSLPrimitiveProcessor> fGeometryProcessor; |
| 177 SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor; | 242 SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor; |
| 178 GrGLSLFragProcs fFragmentProcessors; | 243 GrGLSLFragProcs fFragmentProcessors; |
| 179 | 244 |
| 245 PipelineDesc fPipelineDesc; | |
| 246 | |
| 180 GrVkProgramDataManager fProgramDataManager; | 247 GrVkProgramDataManager fProgramDataManager; |
| 181 | 248 |
| 182 DescriptorPoolManager fSamplerPoolManager; | 249 DescriptorPoolManager fSamplerPoolManager; |
| 183 DescriptorPoolManager fUniformPoolManager; | 250 DescriptorPoolManager fUniformPoolManager; |
| 184 | 251 |
| 185 #ifdef SK_DEBUG | |
| 186 int fNumSamplers; | 252 int fNumSamplers; |
| 187 #endif | |
| 188 | 253 |
| 189 friend class GrVkProgramBuilder; | 254 friend class GrVkProgramBuilder; |
| 190 }; | 255 }; |
| 191 | 256 |
| 192 #endif | 257 #endif |
| OLD | NEW |