|
|
|
|
|
|
Aggressive |
|
|
|
}; |
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class)] |
|
|
|
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Enum)] |
|
|
|
public bool simple; |
|
|
|
public int debugCounterStart; |
|
|
|
public GenerateHLSL(PackingRules rules = PackingRules.Exact, bool simple = false, int debugCounterStart = 1) |
|
|
|
public bool simple; |
|
|
|
public int debugCounterStart; |
|
|
|
public GenerateHLSL(PackingRules rules = PackingRules.Exact, bool simple = false, int debugCounterStart = 1) |
|
|
|
this.simple = simple; |
|
|
|
this.debugCounterStart = debugCounterStart; |
|
|
|
} |
|
|
|
this.simple = simple; |
|
|
|
this.debugCounterStart = debugCounterStart; |
|
|
|
} |
|
|
|
[AttributeUsage(AttributeTargets.Field)] |
|
|
|
public class SurfaceDataAttributes : System.Attribute |
|
|
|
{ |
|
|
|
public string displayName; |
|
|
|
public SurfaceDataAttributes(string displayName = "") |
|
|
|
{ |
|
|
|
this.displayName = displayName; |
|
|
|
} |
|
|
|
} |
|
|
|
[AttributeUsage(AttributeTargets.Field)] |
|
|
|
public class SurfaceDataAttributes : System.Attribute |
|
|
|
{ |
|
|
|
public string displayName; |
|
|
|
public SurfaceDataAttributes(string displayName = "") |
|
|
|
{ |
|
|
|
this.displayName = displayName; |
|
|
|
} |
|
|
|
} |
|
|
|
internal class ShaderTypeGenerator |
|
|
|
internal class ShaderTypeGenerator |
|
|
|
debugCounter = 0; |
|
|
|
} |
|
|
|
debugCounter = 0; |
|
|
|
} |
|
|
|
|
|
|
|
enum PrimitiveType |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
// merge accessors
|
|
|
|
Accessor acc = current.accessor; |
|
|
|
|
|
|
|
|
|
|
|
acc.name = current.name; |
|
|
|
e.Current.accessor = acc; |
|
|
|
e.Current.swizzleOffset += offset; |
|
|
|
|
|
|
|
|
|
|
FieldInfo[] fields = type.GetFields(); |
|
|
|
shaderFields = new List<ShaderFieldInfo>(); |
|
|
|
|
|
|
|
if (type.IsEnum) |
|
|
|
{ |
|
|
|
foreach (var field in fields) |
|
|
|
{ |
|
|
|
if (!field.IsSpecialName) |
|
|
|
{ |
|
|
|
string name = field.Name; |
|
|
|
for (int i = 1; i < name.Length; i++) |
|
|
|
{ |
|
|
|
if (char.IsLower(name[i-1]) && char.IsUpper(name[i])) |
|
|
|
{ |
|
|
|
// case switch, insert underscore
|
|
|
|
name = name.Insert(i, "_"); |
|
|
|
} |
|
|
|
} |
|
|
|
statics[(type.Name + "_" + name).ToUpper()] = field.GetRawConstantValue().ToString(); |
|
|
|
} |
|
|
|
} |
|
|
|
errors = null; |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var field in fields) |
|
|
|
{ |
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (attr.simple) |
|
|
|
{ |
|
|
|
string subNamespace = type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1); |
|
|
|
statics["DEBUGVIEW_" + subNamespace.ToUpper() + "_" + type.Name.ToUpper() + "_" + field.Name.ToUpper()] = Convert.ToString(attr.debugCounterStart + debugCounter++); |
|
|
|
} |
|
|
|
if (attr.simple) |
|
|
|
{ |
|
|
|
string subNamespace = type.Namespace.Substring(type.Namespace.LastIndexOf((".")) + 1); |
|
|
|
statics["DEBUGVIEW_" + subNamespace.ToUpper() + "_" + type.Name.ToUpper() + "_" + field.Name.ToUpper()] = Convert.ToString(attr.debugCounterStart + debugCounter++); |
|
|
|
} |
|
|
|
|
|
|
|
if (field.FieldType.IsPrimitive) |
|
|
|
{ |
|
|
|
|
|
|
else if (field.FieldType == typeof(Vector4)) |
|
|
|
EmitPrimitiveType(PrimitiveType.Float, 4, field.Name, "", shaderFields); |
|
|
|
else if (field.FieldType == typeof(Matrix4x4)) |
|
|
|
EmitMatrixType(PrimitiveType.Float, 4, 4, field.Name, "", shaderFields); |
|
|
|
else if (!ExtractComplex(field, shaderFields)) |
|
|
|
EmitMatrixType(PrimitiveType.Float, 4, 4, field.Name, "", shaderFields); |
|
|
|
else if (!ExtractComplex(field, shaderFields)) |
|
|
|
{ |
|
|
|
// Error reporting done in ExtractComplex()
|
|
|
|
return false; |
|
|
|
|
|
|
get { return statics.Count > 0; } |
|
|
|
} |
|
|
|
|
|
|
|
public bool IsSimple() |
|
|
|
{ |
|
|
|
return attr.simple; |
|
|
|
} |
|
|
|
public bool IsSimple() |
|
|
|
{ |
|
|
|
return attr.simple; |
|
|
|
} |
|
|
|
public int debugCounter; |
|
|
|
public int debugCounter; |
|
|
|
public List<string> errors = null; |
|
|
|
|
|
|
|
Dictionary<string, string> statics; |
|
|
|