Fix the preallocated size of string arrays in GrGLSLShaderBuilder
Fragment shaders typically have at least three (?) processors, and from histogramming GMs and SKPs, the largest number is six. Even our vertex shaders (half of all shaders being built) have one, and this code had an off-by-one in the preallocation size: We set aside enough space for kCode (10) elements, then immediately pushed 11 (i <= kCode). This change should cut down on three heap allocations for every shader. Bug: skia: Change-Id: Iaa2a38b9ff82eb5b81935f9f1d1d96a9bc8aad90 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201463 Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
a7181e7c68
commit
389b4b267d
@ -225,12 +225,14 @@ protected:
|
||||
kFunctions,
|
||||
kMain,
|
||||
kCode,
|
||||
|
||||
kPrealloc = kCode + 6, // 6 == Reasonable upper bound on number of processor stages
|
||||
};
|
||||
|
||||
GrGLSLProgramBuilder* fProgramBuilder;
|
||||
SkSTArray<kCode, const char*, true> fCompilerStrings;
|
||||
SkSTArray<kCode, int, true> fCompilerStringLengths;
|
||||
SkSTArray<kCode, SkString> fShaderStrings;
|
||||
SkSTArray<kPrealloc, const char*, true> fCompilerStrings;
|
||||
SkSTArray<kPrealloc, int, true> fCompilerStringLengths;
|
||||
SkSTArray<kPrealloc, SkString> fShaderStrings;
|
||||
SkString fCode;
|
||||
SkString fFunctions;
|
||||
SkString fExtensions;
|
||||
|
Loading…
Reference in New Issue
Block a user