Reserve unused std140 uniform block in reflection, and fix uniform block matrix layout (#2041)

According to the spec glsl4.60.7:
4.4.5. Uniform and Shader Storage Block Layout Qualifiers:
"The packed qualifier overrides only std140, std430, and shared; other qualifiers are inherited.
When packed is used, no shareable layout is guaranteed. The compiler and linker can optimize
memory use based on what variables actively get used and on other criteria. Offsets must be
queried, as there is no other way of guaranteeing where (and which) variables reside within the
block"

we should reserve std140 block and shared block in reflection.

According to the spec glsl4.60.7:
4.4.5. Uniform and Shader Storage Block Layout Qualifiers:
"The row_major and column_major qualifiers only affect the layout of matrices, including all
matrices contained in structures and arrays they are applied to, to all depths of nesting. These
qualifiers can be applied to other types, but will have no effect."

We need ensure all matrix block member been effect.

Support EShMsgKeepUncalled in reflection

EShMsgKeepUncalled  is a link message for link program.
We need only one option to control uncalled function optimization.
If we set EShMsgKeepUncalled as false in link time, linker won't be keep the uncall function sequence in AST,  and if we set EShMsgKeepUncalled as true in link time, linker will keep all uncalled function sequence in AST.
So, in reflecte time, we just only travers all function sequence. It make EShMsgKeepUncalled  only work at linker, and can effect reflection.

Recursively layout packing to "block member"

layout packing isn't set recursively, it causes TReflection::getOffsets doesn't work correctly.
This commit is contained in:
Roy.li
2020-05-15 16:26:48 +08:00
committed by GitHub
parent c6874320de
commit 24dcbd1b1f
9 changed files with 315 additions and 101 deletions

View File

@@ -1,5 +1,9 @@
hlsl.reflection.vert
Uniform reflection:
anonDeadMember2: offset 64, type 8b52, size 1, index 0, binding -1, stages 1
ufDead4: offset 28, type 1406, size 1, index 1, binding -1, stages 1
anonMember1: offset 0, type 8b51, size 1, index 0, binding -1, stages 1
uf1: offset 16, type 1406, size 1, index 1, binding -1, stages 1
anonMember3: offset 80, type 8b52, size 1, index 0, binding -1, stages 1
s.a: offset 0, type 1404, size 1, index 1, binding -1, stages 1
m23: offset 16, type 8b67, size 1, index 0, binding -1, stages 1
@@ -54,10 +58,9 @@ deepD[1].d2.d1[2].b: offset 2896, type 8b56, size 1, index 1, binding -1, stages
deepD[1].d2.d1[3].va: offset 2904, type 8b50, size 3, index 1, binding -1, stages 1, arrayStride 8, topLevelArrayStride 304
deepD[1].d2.d1[3].b: offset 2928, type 8b56, size 1, index 1, binding -1, stages 1, topLevelArrayStride 304
deepD[1].v3: offset 2944, type 8b54, size 1, index 1, binding -1, stages 1, topLevelArrayStride 304
ufDead3: offset 24, type 1406, size 1, index 1, binding -1, stages 1
foo1: offset 0, type 1406, size 1, index 4, binding -1, stages 1
foo2: offset 0, type 1406, size 1, index 5, binding -1, stages 1
anonMember1: offset 0, type 8b51, size 1, index 0, binding -1, stages 1
uf1: offset 16, type 1406, size 1, index 1, binding -1, stages 1
Uniform block reflection:
nameless: offset -1, type ffffffff, size 496, index -1, binding -1, stages 1, numMembers 9