示例#1
0
文件: Pipeline.cs 项目: acaly/LightDx
        public unsafe VertexDataProcessorGroup CreateVertexDataProcessors(Type[] types)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("Pipeline");
            }
            var desc           = Enumerable.Empty <InputElementDescription>();
            var processors     = new object[types.Length];
            var deviceTypeList = new[] { typeof(LightDevice) };
            var deviceObject   = new object[] { _device };

            for (int i = 0; i < types.Length; ++i)
            {
                desc = desc.Concat(InputElementDescriptionFactory.Create(types[i], i));
                var processorType = typeof(VertexDataProcessor <>).MakeGenericType(types[i]);
                var ctor          = processorType.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic,
                                                                 null, deviceTypeList, null);
                processors[i] = ctor.Invoke(deviceObject);
            }
            var list = desc.ToArray();

            using (var layout = new ComScopeGuard())
            {
                fixed(InputElementDescription *d = list)
                {
                    Device.CreateInputLayout(_device.DevicePtr, d, (uint)list.Length,
                                             Blob.GetBufferPointer(_signatureBlob), Blob.GetBufferSize(_signatureBlob), out layout.Ptr).Check();
                }

                return(new VertexDataProcessorGroup(_device, types, processors, layout.Move()));
            }
        }
示例#2
0
 internal static InputElementDescription[] CreateLayoutFromType(int slot)
 {
     return(InputElementDescriptionFactory.Create(typeof(T), slot));
 }