Hash :
efe061bd
Author :
Date :
2018-11-13T16:44:40
Optimize HLSL zero initializer
Currently we initialize a variable using zero initializer. Take the
below variable for example:
uint var[4];
We translate it to:
uint var[4] = { 0, 0, 0, 0};
If the array size is large, we have to use very long zero initializer.
The problem is that it's very slow for D3D drivers to compile.
This CL uses the 'static' trick below to solve the problem:
static uint _ANGLE_ZEROS_[256];
...
uint var[516] = {_ANGLE_ZEROS_, _ANGLE_ZEROS_, 0, 0, 0, 0};
For 'static', if the declaration does not include an initializer, the
value is set to zero.
https://docs.microsoft.com/en-us/windows/desktop/direct3dhlsl/dx-graphics-hlsl-variable-syntax
Bug: chromium:898030
Change-Id: Ia3f6574b5ddaffa94bf971140eba95835ee105ee
Reviewed-on: https://chromium-review.googlesource.com/c/1332805
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>