Ejemplo n.º 1
0
 protected AcceleratedReactor([NotNull] AccelerationDevice provider)
 {
     mProvider      = provider;
     mHardwareQueue = new List <IComputationKernel>();
     mContext       = new AcceleratedReactorContext(this);
     mVectorBuffer  = new PlaceholderVectorBuffer();
 }
Ejemplo n.º 2
0
        internal HardwareBuffer([NotNull] AccelerationDevice provider, long size) : base(provider)
        {
            if (size <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(size));
            }

            Size = size;
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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>();
        }
Ejemplo n.º 6
0
 protected LinkableHardwareResource([NotNull] AccelerationDevice device) : base(device)
 {
 }
Ejemplo n.º 7
0
 internal AcceleratedKernel([NotNull] AccelerationDevice device) : base(device)
 {
 }