public bool FindVariable(string name, out ShaderVariableMapping variable) { foreach (var v in variables) { if (v.name == name) { variable = v; return(true); } } variable = null; return(false); }
internal static void CalculateContantBufferVariableMappings(ShaderVariable[][] constantBufferVariables, out ReadOnlyCollection <ShaderConstantBufferMapping> constantBufferMappings) { int offset = 0, dwordIndex = 0; bool firstVariableProcessed = false; var constantBufferMappingsArray = new ShaderConstantBufferMapping[constantBufferVariables.Length]; for (int i = 0; i != constantBufferVariables.Length; ++i) { var variables = constantBufferVariables[i]; if (variables == null) { throw new ArgumentException("Constant buffers cannot be empty"); } var variablesMapping = new ShaderVariableMapping[variables.Length]; for (int v = 0; v != variables.Length; ++v) { var variable = variables[v]; int stride = VariableTypeToSrcStride(variable.type); int dwordCount = VariableTypeToSrcDWORDCount(variable.type); if (variable.elements >= 1) { stride *= variable.elements; dwordCount *= variable.elements; } if (firstVariableProcessed && dwordCount != 1) { int alignedIndex = dwordIndex % 4; if (dwordCount > alignedIndex) { int remander = 4 - alignedIndex; dwordIndex += remander; offset += remander * sizeof(float); } } variablesMapping[v] = new ShaderVariableMapping(variable.name, variable.type, variable.elements, offset); firstVariableProcessed = true; offset += stride; dwordIndex += dwordCount; } constantBufferMappingsArray[i] = new ShaderConstantBufferMapping(offset, variablesMapping); } constantBufferMappings = new ReadOnlyCollection <ShaderConstantBufferMapping>(constantBufferMappingsArray); }
public abstract void Update <T>(T[] data, ShaderVariableMapping variable) where T : struct;
public abstract void Update <T>(T data, ShaderVariableMapping variable) where T : unmanaged;
/// <summary> /// Writes color as float4 /// </summary> public abstract void Update(Color4[] colors, ShaderVariableMapping variable);
public abstract void Update(Quat[] quaternions, ShaderVariableMapping variable);
public abstract void Update(Mat4[] matrices, ShaderVariableMapping variable);
public abstract void Update(Vec4[] vectors, ShaderVariableMapping variable);
public abstract void Update(float[] values, ShaderVariableMapping variable);
public abstract void Update(Mat4 matrix, ShaderVariableMapping variable);
internal static bool FindVariable(ReadOnlyCollection <ShaderConstantBufferMapping> constantBufferMappings, string name, out ShaderVariableMapping variable) { if (constantBufferMappings == null) { variable = null; return(false); } foreach (var constantBuffer in constantBufferMappings) { if (constantBuffer.FindVariable(name, out variable)) { return(true); } } variable = null; return(false); }
public bool FindVariable(string name, out ShaderVariableMapping variable) { return(ShaderBase.FindVariable(constantBufferMappings, name, out variable)); }