You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code does not end up with a reduced array size for arrInOut. The whitepaper (and my recollection of early tests of this feature with @greg-lunarg) seems to suggest that array size should get reduced to arrInOut[2]. Since the resources available for in/out variables between shader stages are very limited, this is an important optimization. arrIn is correctly reduced to arrIn[2] though.
Some input and output arrays are not trimmed by EliminateDead*Components because sometimes it is not safe to do so given the current design.
Input arrays in vertex shaders can always be safely trimmed as with arrIn[] pointed out by @mbechard . Same for output arrays in frag shaders. Any others can potentially break a shader interface given the current design.
EliminateDeadInputComponents (EDIC) and EliminateDeadOutputComponents (EDOC) only operate on one shader at a time. So the workflow has to depend on EDOC and EDIC trimming the same elements on both sides of a shader interface so to not break the interface. In the workflow this can always be guaranteed for structs, but not for arrays. This is because structs can only be indexed with constants, but arrays can be indexed with variables. ED*C cannot trim an array that is indexed with a variable because it has to assume any element might be referenced. So, if on one side of an interface an array is indexed only with constants and on the other side is indexed with a variable, the array may be trimmed differently on either side and break the interface. For this reason EDIC and EDOC do not trim arrays except for the special cases mentioned.
My best idea is to create a new all_array mode in the EDOC and EDOC passes which would trim all arrays with only constant indices. This mode would be controlled with a bool argument. The default would be false.
In order to make sure it is safe to use the all_array mode, I propose new passes called EliminateDeadInputComponentsArraySafe(bool &safe) and EliminateDeadOutputComponentsArraySafe(bool &safe) . These passes would return true if no Input/Output arrays are indexed with variables in the shader. In the workflow, when optimizing shaders A & B, it would be safe to use this new all_array mode if both A & B are ArraySafe. The new all_array mode would need to be used on both shaders.
The control here is fairly coarse-grained (per shader), but since (I believe) it is fairly rare for input/output arrays to be indexed with variables, I don't think this would be too prohibitive. Someone can add more fine-grained control (per array) if it is needed. My design above would be sufficient for this issue.
The following code does not end up with a reduced array size for
arrInOut
. The whitepaper (and my recollection of early tests of this feature with @greg-lunarg) seems to suggest that array size should get reduced to arrInOut[2]. Since the resources available for in/out variables between shader stages are very limited, this is an important optimization.arrIn
is correctly reduced to arrIn[2] though.Vertex:
Fragment
Thanks!
The text was updated successfully, but these errors were encountered: