public void AddConstantDefinition(string name, GpuConstantType constType, int arrraySize) { if (this.NamedConstants.Map.ContainsKey(name)) { throw new Exception(string.Format("Constant entry with name '{0}' allready exists.", name)); } var def = new GpuConstantDefinition { ArraySize = arrraySize, ConstantType = constType, // for compatibility we do not pad values to multiples of 4 // when it comes to arrays, user is responsible for creating matching defs ElementSize = GpuConstantDefinition.GetElementSize(constType, false), // not used LogicalIndex = 0, Variability = GpuParamVariability.Global }; if (def.IsFloat) { def.PhysicalIndex = this.FloatConstants.Count; this.FloatConstants.Resize(this.FloatConstants.Count + def.ArraySize * def.ElementSize); } else { def.PhysicalIndex = this.IntConstants.Count; this.IntConstants.Resize(this.IntConstants.Count + def.ArraySize * def.ElementSize); } this.NamedConstants.Map.Add(name, def); ++Version; }
public GpuConstantDefinition() { this.ConstantType = GpuConstantType.Unknown; PhysicalIndex = Int32.MaxValue; this.ElementSize = 0; this.ArraySize = 1; this.Variability = GpuParamVariability.Global; }
public bool IsSamplerConst(GpuConstantType c) { switch (c) { case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.SamplerCube: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: return(true); default: return(false); } }
public static bool IsFloatConst(GpuConstantType c) { switch (c) { case GpuConstantType.Int1: case GpuConstantType.Int2: case GpuConstantType.Int3: case GpuConstantType.Int4: case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.SamplerCube: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: return(false); default: return(true); } ; }
public static int GetElementSize(GpuConstantType ctype, bool padToMultiplesOf4) { if (padToMultiplesOf4) { switch (ctype) { case GpuConstantType.Float1: case GpuConstantType.Float2: case GpuConstantType.Float3: case GpuConstantType.Float4: case GpuConstantType.Int1: case GpuConstantType.Int2: case GpuConstantType.Int3: case GpuConstantType.Int4: case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: case GpuConstantType.SamplerCube: return(4); case GpuConstantType.Matrix_2X2: case GpuConstantType.Matrix_2X3: case GpuConstantType.Matrix_2X4: return(8); // 2 float4s case GpuConstantType.Matrix_3X2: case GpuConstantType.Matrix_3X3: case GpuConstantType.Matrix_3X4: return(12); //3 float4s case GpuConstantType.Matrix_4X2: case GpuConstantType.Matrix_4X3: case GpuConstantType.Matrix_4X4: return(16); //4 float4s default: return(4); } } // else { switch (ctype) { case GpuConstantType.Float1: case GpuConstantType.Int1: case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: case GpuConstantType.SamplerCube: return(1); case GpuConstantType.Float2: case GpuConstantType.Int2: return(2); case GpuConstantType.Float3: case GpuConstantType.Int3: return(3); case GpuConstantType.Float4: case GpuConstantType.Int4: return(4); case GpuConstantType.Matrix_2X2: return(4); case GpuConstantType.Matrix_2X3: case GpuConstantType.Matrix_3X2: return(6); case GpuConstantType.Matrix_2X4: case GpuConstantType.Matrix_4X2: return(8); case GpuConstantType.Matrix_3X3: return(9); case GpuConstantType.Matrix_3X4: case GpuConstantType.Matrix_4X3: return(12); case GpuConstantType.Matrix_4X4: return(16); default: return(4); } } }
public GpuConstantDefinition() { ConstantType = GpuConstantType.Unknown; PhysicalIndex = Int32.MaxValue; ElementSize = 0; ArraySize = 1; Variability = GpuParamVariability.Global; }
public static int GetElementSize(GpuConstantType ctype, bool padToMultiplesOf4) { if (padToMultiplesOf4) { switch (ctype) { case GpuConstantType.Float1: case GpuConstantType.Float2: case GpuConstantType.Float3: case GpuConstantType.Float4: case GpuConstantType.Int1: case GpuConstantType.Int2: case GpuConstantType.Int3: case GpuConstantType.Int4: case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: case GpuConstantType.SamplerCube: return 4; case GpuConstantType.Matrix_2X2: case GpuConstantType.Matrix_2X3: case GpuConstantType.Matrix_2X4: return 8; // 2 float4s case GpuConstantType.Matrix_3X2: case GpuConstantType.Matrix_3X3: case GpuConstantType.Matrix_3X4: return 12; //3 float4s case GpuConstantType.Matrix_4X2: case GpuConstantType.Matrix_4X3: case GpuConstantType.Matrix_4X4: return 16; //4 float4s default: return 4; } } // else { switch (ctype) { case GpuConstantType.Float1: case GpuConstantType.Int1: case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: case GpuConstantType.SamplerCube: return 1; case GpuConstantType.Float2: case GpuConstantType.Int2: return 2; case GpuConstantType.Float3: case GpuConstantType.Int3: return 3; case GpuConstantType.Float4: case GpuConstantType.Int4: return 4; case GpuConstantType.Matrix_2X2: return 4; case GpuConstantType.Matrix_2X3: case GpuConstantType.Matrix_3X2: return 6; case GpuConstantType.Matrix_2X4: case GpuConstantType.Matrix_4X2: return 8; case GpuConstantType.Matrix_3X3: return 9; case GpuConstantType.Matrix_3X4: case GpuConstantType.Matrix_4X3: return 12; case GpuConstantType.Matrix_4X4: return 16; default: return 4; } } }
public bool IsSamplerConst(GpuConstantType c) { switch (c) { case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.SamplerCube: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: return true; default: return false; } }
public static bool IsFloatConst(GpuConstantType c) { switch (c) { case GpuConstantType.Int1: case GpuConstantType.Int2: case GpuConstantType.Int3: case GpuConstantType.Int4: case GpuConstantType.Sampler1D: case GpuConstantType.Sampler2D: case GpuConstantType.Sampler3D: case GpuConstantType.SamplerCube: case GpuConstantType.Sampler1DShadow: case GpuConstantType.Sampler2DShadow: return false; default: return true; } }
public void AddConstantDefinition( string name, GpuConstantType constType, int arrraySize = 1 ) { if ( NamedConstants.Map.ContainsKey( name ) ) { throw new Exception( string.Format("Constant entry with name '{0}' allready exists.", name) ); } var def = new GpuConstantDefinition { ArraySize = arrraySize, ConstantType = constType, // for compatibility we do not pad values to multiples of 4 // when it comes to arrays, user is responsible for creating matching defs ElementSize = GpuConstantDefinition.GetElementSize( constType, false ), // not used LogicalIndex = 0, Variability = GpuParamVariability.Global }; if ( def.IsFloat ) { def.PhysicalIndex = FloatConstants.Count; FloatConstants.Resize(FloatConstants.Count + def.ArraySize * def.ElementSize); } else { def.PhysicalIndex = IntConstants.Count; IntConstants.Resize(IntConstants.Count + def.ArraySize * def.ElementSize); } NamedConstants.Map.Add( name, def ); ++Version; }
public void AddConstantDefinition(string name, GpuConstantType constType) { AddConstantDefinition(name, constType, 1); }
public void AddConstantDefinition( string name, GpuConstantType constType ) { AddConstantDefinition( name, constType, 1 ); }
private static extern void GpuSharedParameters_addConstantDefinition(IntPtr param, String name, GpuConstantType constType, UIntPtr arraySize);
public void addNamedConstant(String name, GpuConstantType constType, uint arraySize = 1) { GpuSharedParameters_addConstantDefinition(ptr, name, constType, new UIntPtr(arraySize)); }