When using the bool field type in a struct that is itself used in a buffer, ShaderGen crashes due to a stack overflow. This can be traced to TypeSizeCache.GetCSharpSize not having a known size for System.Boolean, to fix that issue requires reference to the conversation in #14, as the size is different depending on the backend in question.
This bug then causes it to try to determine the size manually, there are only two fields in a bool, and both are static strings (FalseString and TrueString). As they are statics they should be skipped as they don't contribute to the size.
However, this bug causes TypeSizeCahce.GetCSharpAlignment to be called for the symbolSystem.String. This two is not a known type, and also has a single field, which is also a static string (Empty), so TypeSizeCahce.GetCSharpAlignment is called again for the symbolSystem.String. And we get recursion.
The fixes therefore are:
Add a size of 4 bytes for bool, which should be correct for everything but Metal (see #14). May need to add support to specify a size of 1 for Metal.
Skip consideration of static fields in structs when calculating Size.
Change recursive methods to use stack based recursion and detect repeats.
Consider adding support for System.String by treating as a byte[] or similar.
When using the bool field type in a struct that is itself used in a buffer, ShaderGen crashes due to a stack overflow. This can be traced to
TypeSizeCache.GetCSharpSize
not having a known size forSystem.Boolean
, to fix that issue requires reference to the conversation in #14, as the size is different depending on the backend in question.This bug then causes it to try to determine the size manually, there are only two fields in a
bool
, and both are static strings (FalseString
andTrueString
). As they are statics they should be skipped as they don't contribute to the size.However, this bug causes
TypeSizeCahce.GetCSharpAlignment
to be called for thesymbol
System.String
. This two is not a known type, and also has a single field, which is also a static string (Empty
), soTypeSizeCahce.GetCSharpAlignment
is called again for thesymbol
System.String
. And we get recursion.The fixes therefore are:
System.String
by treating as abyte[]
or similar.