public ShaderOp CreateConstant(ConstantOpKey key) { ShaderOp op = new ShaderOp(); mConstantOps.Add(key, op); return(op); }
public ShaderOp CreateConstantOp(ShaderType constantType, ShaderConstantLiteral constantLiteral) { var constantOpKey = new ConstantOpKey(constantLiteral); var constantOp = mCurrentLibrary.FindConstant(constantOpKey); if (constantOp == null) { constantOp = mCurrentLibrary.FindOrCreateConstant(constantOpKey); // Handle bools specially (they're special ops in spirv) if (constantType.mBaseType == OpType.Bool) { var boolVal = (bool)constantLiteral.mValue; if (boolVal == true) { InitializeOp(constantOp, OpInstructionType.OpConstantTrue, constantType, null); } else { InitializeOp(constantOp, OpInstructionType.OpConstantFalse, constantType, null); } } else { InitializeOp(constantOp, OpInstructionType.OpConstant, constantType, new List <IShaderIR> { constantLiteral }); } } return(constantOp); }
public ShaderOp FindConstant(ConstantOpKey key, bool checkDependencies = true) { var result = mConstantOps.GetValueOrDefault(key); if (result == null && checkDependencies && mDependencies != null) { result = mDependencies.FindConstant(key, checkDependencies); } return(result); }
public ShaderOp FindOrCreateConstant(ConstantOpKey key, bool checkDependencies = true) { var result = FindConstant(key, checkDependencies); if (result == null) { result = CreateConstant(key); } return(result); }
public ShaderOp FindConstant(ConstantOpKey key, bool checkDependencies = true) { foreach (var library in this) { var result = library.FindConstant(key, checkDependencies); if (result != null) { return(result); } } return(null); }
//---------------------------------------------------------------Constant Literals public ShaderConstantLiteral GetOrCreateConstantLiteral(ShaderConstantLiteral constantLiteral) { var key = new ConstantOpKey(constantLiteral); var result = mConstantLiterals.GetValueOrDefault(key); if (result == null) { result = constantLiteral; mConstantLiterals.Add(key, result); } return(result); }
public ShaderOp CreateConstantOp(ShaderType constantType, bool constantLiteral) { var constantOpKey = new ConstantOpKey(mCurrentLibrary.FindType(new TypeKey(typeof(bool))), constantLiteral); var constantOp = mCurrentLibrary.FindConstant(constantOpKey); if (constantOp == null) { constantOp = mCurrentLibrary.FindOrCreateConstant(constantOpKey); if (constantLiteral == true) { InitializeOp(constantOp, OpInstructionType.OpConstantTrue, constantType, null); } else { InitializeOp(constantOp, OpInstructionType.OpConstantFalse, constantType, null); } } return(constantOp); }
//---------------------------------------------------------------Constants public bool AddConstant(ConstantOpKey key, ShaderOp shaderOp) { return(mConstantOps.TryAdd(key, shaderOp)); }