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

Unified Diff: src/gpu/vk/GrVkProgram.h

Issue 1816153002: Set up cache in vulkan to reuse GrVkPrograms (aka VkPipelines) (Closed) Base URL: https://skia.googlesource.com/skia.git@progSamplers
Patch Set: cleanup 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/vk/GrVkProgram.h
diff --git a/src/gpu/vk/GrVkProgram.h b/src/gpu/vk/GrVkProgram.h
index 1a024f2f2a6da81c9cec0f1c82145a4314ad5225..0735f05aa8dabfad64ac0c51d5b313da4da20fc8 100644
--- a/src/gpu/vk/GrVkProgram.h
+++ b/src/gpu/vk/GrVkProgram.h
@@ -47,11 +47,76 @@ public:
void abandonGPUResources();
+ // The key is composed of two parts:
+ // 1. uint32_t for total key length
+ // 2. Vulkan specific data
+ enum KeyOffsets {
+ // Part 1.
+ kLength_KeyOffset = 0,
+ // Part 2.
+ kData_KeyOffset = kLength_KeyOffset + sizeof(uint32_t),
+ };
+
+ static void BuildVkKey(const GrPipeline&, GrPrimitiveType primitiveType,
+ SkTArray<unsigned char, true>* key);
+
+ struct PipelineDesc {
+ uint32_t fChecksum;
+ GrVkProgramDesc fProgramDesc;
+ 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
+
+ bool operator== (const PipelineDesc& that) const {
+ if (fChecksum != that.fChecksum || fProgramDesc != that.fProgramDesc) {
+ return false;
+ }
+ // We store the keyLength at the start of fVkKey. Thus we don't have to worry about
+ // different length keys since we will fail on the comparison immediately. Therefore we
+ // just use this PipelineDesc to get the length to iterate over.
+ int keyLength = fVkKey.count();
+ SkASSERT(SkIsAlign4(keyLength));
+ int l = keyLength >> 2;
+ const uint32_t* aKey = reinterpret_cast<const uint32_t*>(fVkKey.begin());
+ const uint32_t* bKey = reinterpret_cast<const uint32_t*>(that.fVkKey.begin());;
+ for (int i = 0; i < l; ++i) {
+ if (aKey[i] != bKey[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ 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
+ if (a.fChecksum != b.fChecksum) {
+ return a.fChecksum < b.fChecksum ? true : false;
+ }
+ bool progDescLess = GrProgramDesc::Less(a.fProgramDesc, b.fProgramDesc);
+ if (progDescLess || a.fProgramDesc != b.fProgramDesc) {
+ return progDescLess;
+ }
+
+ int keyLength = a.fVkKey.count();
+ SkASSERT(SkIsAlign4(keyLength));
+ int l = keyLength >> 2;
+ const uint32_t* aKey = reinterpret_cast<const uint32_t*>(a.fVkKey.begin());
+ const uint32_t* bKey = reinterpret_cast<const uint32_t*>(b.fVkKey.begin());;
+ for (int i = 0; i < l; ++i) {
+ if (aKey[i] != bKey[i]) {
+ return aKey[i] < bKey[i] ? true : false;
+ }
+ }
+ return false;
+ }
+
+ };
+
+ const PipelineDesc& getDesc() { return fPipelineDesc; }
+
private:
typedef GrVkProgramDataManager::UniformInfoArray UniformInfoArray;
typedef GrGLSLProgramDataManager::UniformHandle UniformHandle;
GrVkProgram(GrVkGpu* gpu,
+ const GrVkProgram::PipelineDesc&,
GrVkPipeline* pipeline,
VkPipelineLayout layout,
VkDescriptorSetLayout dsLayout[2],
@@ -177,14 +242,14 @@ private:
SkAutoTDelete<GrGLSLXferProcessor> fXferProcessor;
GrGLSLFragProcs fFragmentProcessors;
+ PipelineDesc fPipelineDesc;
+
GrVkProgramDataManager fProgramDataManager;
DescriptorPoolManager fSamplerPoolManager;
DescriptorPoolManager fUniformPoolManager;
-#ifdef SK_DEBUG
int fNumSamplers;
-#endif
friend class GrVkProgramBuilder;
};

Powered by Google App Engine
This is Rietveld 408576698