Fix subtle copying bug in primeShaderCache
Move the declaration of vectors to the innermost loop that uses them. We loop through a bunch of different LayerSettings to draw content that will prime the shader cache. In several places, we create a vector initialized with multiple LayerSettings, and then inside a loop, we modify the originals. When this code was written, we created a vector<const LayerSettings*>. In I87847d01e2e330ddec88272cd8608f0b78c0a2cd, the RenderEngine API was changed to accept a vector<LayerSettings>. The problem is, when constructing a vector<LayerSettings>, we get a *copy* of the items in the initializer list. So when the loop modifies the originals, the vector stays as it is, and only the first iteraton of the loop caches any shaders. On my test device, we have only cached 6 shaders at the end of primeShaderCache. With this change, we are back up to 93 shaders. Bug: 190487656 Bug: 222355787 Test: manual - logcat + perfetto Change-Id: I9f0e9e8535feee48700f1c896f26833b6095764d
Loading
Please register or sign in to comment