Optimized shader hash to not allocate memory or perform multiple passes of string... 83/28683/5
authorNick Holland <nick.holland@partner.samsung.com>
Tue, 14 Oct 2014 07:17:35 +0000 (08:17 +0100)
committerNick Holland <nick.holland@partner.samsung.com>
Wed, 15 Oct 2014 07:05:23 +0000 (08:05 +0100)
commitd780d8a158700c843a4ee924a599d050e91ca275
tree12b9121c3c9616746a73b9acc95200a21ddcbce4
parentd743f90faaf01704c6bc24840e70acfd6dc99510
Optimized shader hash to not allocate memory or perform multiple passes of string data

Applications like dali-demo end up hashing around 1MB of shader source on startup
due to multiple calls to ShaderFactory::Load ( 340 calls for dali-demo).

The previous code would:
 - Allocate a new string to hold both vertex/ fragment source code
 - Copy vertex / fragment source code in to the new string
 - Pass through the string removing white spaces
 - Pass through the string removing tabs
 - Pass through the string removing new line characters
 - Pass through the string to perform Hash calculation

So if a total of 1MB is passed to the hasher it would end
read/ writing around 5MB of data.

Hence OProfile flagged it up as being a bottleneck for some apps on startup.

New version does no memory allocation and does a single pass of the data.

Todo: Need to look at a better way of comparing shaders

Change-Id: I39c8b351c65c6e91f2c4b32e321f861d634ccca4
dali/internal/common/dali-hash.cpp
dali/internal/common/dali-hash.h
dali/internal/event/effects/shader-factory.cpp
dali/internal/event/effects/shader-factory.h
dali/internal/event/images/image-factory.cpp
dali/internal/event/text/font-factory.cpp