浏览代码

Add support of 'bool' to the ShaderGenerator

/main
Evgenii Golubev 8 年前
当前提交
41003740
共有 1 个文件被更改,包括 23 次插入6 次删除
  1. 29
      Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs

29
Assets/ShaderGenerator/Editor/ShaderTypeGeneration.cs


enum PrimitiveType
{
Float, Int, UInt
Float, Int, UInt, Bool
};
static string PrimitiveToString(PrimitiveType type, int rows, int cols)

break;
case PrimitiveType.UInt:
text = "uint";
break;
case PrimitiveType.Bool:
text = "bool";
break;
}

bool ExtractComplex(FieldInfo field, List<ShaderFieldInfo> shaderFields)
{
var floatFields = new List<FieldInfo>();
var intFields = new List<FieldInfo>();
var uintFields = new List<FieldInfo>();
var intFields = new List<FieldInfo>();
var uintFields = new List<FieldInfo>();
var boolFields = new List<FieldInfo>();
var descs = new string[4] { "x: ", "y: ", "z: ", "w: " };
int numFields = 0;

intFields.Add(subField);
else if (subField.FieldType == typeof(uint))
uintFields.Add(subField);
else if (subField.FieldType == typeof(bool))
boolFields.Add(subField);
else
{
Error("'" + fieldName + "' can not be packed into a register, since it contains an unsupported field type '" + subField.FieldType + "'");

if (floatFields.Count > 0)
{
if (intFields.Count + uintFields.Count > 0)
if (intFields.Count + uintFields.Count + boolFields.Count > 0)
{
Error(mismatchErrorMsg);
return false;

else if (intFields.Count > 0)
{
if (floatFields.Count + uintFields.Count > 0)
if (floatFields.Count + uintFields.Count + boolFields.Count > 0)
{
Error(mismatchErrorMsg);
return false;

else if (uintFields.Count > 0)
{
if (floatFields.Count + intFields.Count > 0)
if (floatFields.Count + intFields.Count + boolFields.Count > 0)
}
else if (boolFields.Count > 0)
{
if (floatFields.Count + intFields.Count + uintFields.Count > 0)
{
Error(mismatchErrorMsg);
return false;
}
EmitPrimitiveType(PrimitiveType.Bool, boolFields.Count, field.Name, "", shaderFields);
}
else
{

EmitPrimitiveType(PrimitiveType.Int, 1, field.Name, "", m_ShaderFields);
else if (field.FieldType == typeof(uint))
EmitPrimitiveType(PrimitiveType.UInt, 1, field.Name, "", m_ShaderFields);
else if (field.FieldType == typeof(bool))
EmitPrimitiveType(PrimitiveType.Bool, 1, field.Name, "", m_ShaderFields);
else
{
Error("unsupported field type '" + field.FieldType + "'");

正在加载...
取消
保存