protected AcceleratedReactor([NotNull] AccelerationDevice provider) { mProvider = provider; mHardwareQueue = new List <IComputationKernel>(); mContext = new AcceleratedReactorContext(this); mVectorBuffer = new PlaceholderVectorBuffer(); }
internal HardwareBuffer([NotNull] AccelerationDevice provider, long size) : base(provider) { if (size <= 0) { throw new ArgumentOutOfRangeException(nameof(size)); } Size = size; }
public HardwareConstantBuffer([NotNull] AccelerationDevice provider, long size) : base(provider, size) { var bufferSize = Math.Max(16, ((int)size + 15) / 16 * 16); var bufferDescription = new BufferDescription { BindFlags = BindFlags.ConstantBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, SizeInBytes = bufferSize, Usage = ResourceUsage.Dynamic }; mHardwareBuffer = new Buffer(Device, bufferDescription); }
private AcceleratedDynamicBuffer([NotNull] DynamicHardwareConstantBufferContext context, [NotNull] string typeName) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (typeName.NormalizeNull() == null) { throw new ArgumentNullException(nameof(typeName)); } if (context.ContainsBuilder(typeName.Trim())) { throw new ArgumentException(nameof(typeName), $"The type \"{typeName}\" was already defined in the given context."); } var module = context.GetModuleBuilder(); if (module == null) { throw new ObjectDisposedException(nameof(DynamicHardwareConstantBufferContext), $"The {nameof(DynamicHardwareConstantBufferContext)} was already disposed."); } mProvider = context.GetProvider(); mTypeName = typeName; mTypeBuilder = module.DefineType(typeName.Trim(), TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.ExplicitLayout | TypeAttributes.Serializable | TypeAttributes.AnsiClass, typeof(ValueType)); mFieldNames = new List <StringKey>(); mFields = new Dictionary <StringKey, FieldInfo>(); mFieldBuilders = new Dictionary <StringKey, FieldBuilder>(); var structLayoutAttributeConstructor = typeof(StructLayoutAttribute).GetConstructor(new[] { typeof(LayoutKind) }).AssertNotNull(); var structLayoutAttributeBuilder = new CustomAttributeBuilder(structLayoutAttributeConstructor, new object[] { LayoutKind.Sequential }); mContext = context; mTypeName = typeName; mTypeBuilder.SetCustomAttribute(structLayoutAttributeBuilder); mContext.AddBuilder(mTypeName, this); }
public DynamicHardwareConstantBufferContext([NotNull] AccelerationDevice provider, [NotNull] string typeNamespace) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } if (typeNamespace.NormalizeNull() == null) { throw new ArgumentNullException(nameof(typeNamespace)); } var assemblyName = new AssemblyName(typeNamespace.Trim()); var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndCollect); var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name); mProvider = provider; mModuleBuilder = moduleBuilder; mInstances = new Dictionary <StringKey, AcceleratedDynamicBuffer>(); }
protected LinkableHardwareResource([NotNull] AccelerationDevice device) : base(device) { }
internal AcceleratedKernel([NotNull] AccelerationDevice device) : base(device) { }