Пример #1
0
 public CDomainShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     glShadersToGeometry = new TightConcurrentDictionary<TesselationLayout, TesselationEvaluationShader>(TesselationLayout.Equal);
     glShadersToPixel = new TightConcurrentDictionary<TesselationLayout, TesselationEvaluationShader>(TesselationLayout.Equal);
     domain = Reflection.GetTesselationDomain();
 }
Пример #2
0
 public CGeometryShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     maxVertexCount = Reflection.GetMaxVertexCount();
     inputPrimitiveType = Reflection.GetGeometryInputPrimitiveType();
     outputPrimitiveType = Reflection.GetGeometryOutputPrimitiveType();
 }
Пример #3
0
        private CTextureSurface(ICDevice device, ResourceDimension dimension, Texture2DDescription description, SubresourceData[] initialData, Action<CTextureSurface> onRelease)
            : base(device, dimension, description, t => onRelease((CTextureSurface)t))
        {
            CreateNative();

            if (initialData != null)
                throw new NotSupportedException("Initial newData is not supported for render target and depth-stencil resources by D3D9 implementation of Beholder");
        }
Пример #4
0
 public CHullShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     domain = reflection.GetTesselationDomain();
     partitioning = reflection.GetTesselationPartitioning();
     outputTopology = reflection.GetTesselationOutputTopology();
     outputControlPoints = reflection.GetOutputControlPoints();
     maxTesselationFactor = reflection.GetMaxTesselationFactor();
 }
Пример #5
0
        // IICDeviceBrowserDelegate Interface

        public void DidAddDevice(ICDeviceBrowser browser, ICDevice device, bool moreComing)
        {
            Console.WriteLine($"{nameof (DidAddDevice)}: {device}");

            if (device.Type.HasFlag(ICDeviceType.Scanner))
            {
                WillChangeValue("Scanners");
                Scanners.Add(device);
                DidChangeValue("Scanners");
                device.Delegate = this;
            }
        }
Пример #6
0
        protected CTexture(ICDevice device, ResourceDimension dimension, Texture2DDescription description, Action<CTexture> onDispose)
        {
            this.device = device;
            this.dimension = dimension;
            this.desc = description;
            this.onDispose = onDispose;

            if (desc.BindFlags.HasFlag(BindFlags.RenderTarget))
                rtvs = new List<CRenderTargetView>();
            if (desc.BindFlags.HasFlag(BindFlags.DepthStencil))
                dsvs = new List<CDepthStencilView>();
            if (desc.BindFlags.HasFlag(BindFlags.ShaderResource))
                srvs = new List<CShaderResourceView>();
        }
Пример #7
0
 public CTextureSurface(ICDevice device, Texture1DDescription description, SubresourceData[] initialData, Action<CTextureSurface> onRelease)
     : this(device, ResourceDimension.Texture1D, new Texture2DDescription
     {
         Width = description.Width,
         Height = 1,
         MipLevels = description.MipLevels,
         ArraySize = description.ArraySize,
         FormatID = description.FormatID,
         Sampling = Sampling.NoMultisampling,
         Usage = description.Usage,
         BindFlags = description.BindFlags,
         ExtraFlags = description.ExtraFlags,
         MiscFlags = description.MiscFlags                 
     }, initialData, onRelease)
 {
 }
Пример #8
0
        public CPixelShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            profile = ParseProfile(reflection.Profile);

            var text = GenerateText();
            try
            {
                var bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(profile), ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3);
                d3dShader = new PixelShader(device.D3DDevice, bytecode);
                bytecode.Dispose();
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a pixel shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
        }
Пример #9
0
 public CPixelShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     Profile = ParseProfile(Reflection.Profile);
     var text = GenerateText<CPixelShader>(WriteIOAndCode);
     CompilationResult bytecode;
     try
     {
         bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
             ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
     }
     catch (Exception e)
     {
         throw new ArgumentException(string.Format("Failed to compile a pixel shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
     }
     D3DPixelShader = new PixelShader(device.D3DDevice, bytecode);
 }
Пример #10
0
 public CVertexShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     Profile = ParseProfile(Reflection.Profile);
     var text = GenerateText<CVertexShader>(WriteIOAndCode);
     try
     {
         Bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
             ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
     }
     catch (Exception e)
     {
         throw new ArgumentException(string.Format("Failed to compile a vertex shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
     }
     D3DVertexShader = new VertexShader(device.D3DDevice, Bytecode);
     D3DInputElementsDraft = CreateVertexElementsDraft(reflection);
 }
Пример #11
0
        public SwapChainSurfaces(ICDevice device, int width, int height, ref SwapChainDescription implicitSwapChainDescription)
        {
            this.device = device;

            var glContext = device.GetCurrentContext();

            texture2DDescription = new Texture2DDescription
            {
                ArraySize = 1,
                ExtraFlags = ExtraFlags.None,
                Usage = Usage.Default,
                MipLevels = 1,
                MiscFlags = MiscFlags.None
            };

            OnReset(glContext, width, height, ref implicitSwapChainDescription);
        }
Пример #12
0
        public CGeometryShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            Profile = ParseProfile(reflection.Profile);
            MaxVertexCount = reflection.GetMaxVertexCount();
            InputPrimitiveType = reflection.GetGeometryInputPrimitiveType();
            OutputPrimitiveType = reflection.GetGeometryOutputPrimitiveType();

            var text = GenerateText<CGeometryShader>(WriteIOAndCode);
            CompilationResult bytecode;
            try
            {
                bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
                    ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a geometry shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
            D3DGeometryShader = new GeometryShader(device.D3DDevice, bytecode);
        }
Пример #13
0
        public void DidReceiveStatusInformation(ICDevice device, NSDictionary <NSString, NSObject> status)
        {
            Console.WriteLine($"{nameof (DidReceiveStatusInformation)}: {device} Status: {status}");

            var state = status[ICStatusNotificationKeys.NotificationKey] as NSString;

            if (state == ICScannerStatus.WarmingUp)
            {
                ProgressIndicator.IsDisplayedWhenStopped = true;
                ProgressIndicator.Indeterminate          = true;
                ProgressIndicator.StartAnimation(null);
                StatusText.StringValue = status[ICStatusNotificationKeys.LocalizedNotificationKey] as NSString;
            }
            else if (state == ICScannerStatus.WarmUpDone)
            {
                StatusText.StringValue = string.Empty;
                ProgressIndicator.StopAnimation(null);
                ProgressIndicator.Indeterminate          = false;
                ProgressIndicator.IsDisplayedWhenStopped = false;
            }
        }
Пример #14
0
        public CHullShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            Profile = ParseProfile(reflection.Profile);
            Domain = reflection.GetTesselationDomain();
            Partitioning = reflection.GetTesselationPartitioning();
            OutputTopology = reflection.GetTesselationOutputTopology();
            InputControlPoints = reflection.GetInputControlPoints();
            OutputControlPoints = reflection.GetOutputControlPoints();
            MaxTesselationFactor = reflection.GetMaxTesselationFactor();

            var text = GenerateText<CHullShader>(WriteIOAndCode);
            CompilationResult bytecode;
            try
            {
                bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(Profile),
                    ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3, EffectFlags.None, Name);
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a hull shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
            D3DHullShader = new HullShader(device.D3DDevice, bytecode);
        }
Пример #15
0
 public void DeviceDidChangeSharingState(ICDeviceBrowser browser, ICDevice device) => Console.WriteLine($"{nameof (DeviceDidChangeSharingState)}: {device}");
Пример #16
0
 public void RequestsSelectDevice(ICDeviceBrowser browser, ICDevice device) => Console.WriteLine($"{nameof (RequestsSelectDevice)}: {device}");
Пример #17
0
 public CTextureSurface(ICDevice device, Texture2DDescription description, SubresourceData[] initialData, Action<CTextureSurface> onRelease)
     : this(device, ResourceDimension.Texture2D, description, initialData, onRelease)
 {
 }
Пример #18
0
 public void DidRemoveDevice(ICDeviceBrowser browser, ICDevice device, bool moreGoing)
 {
     Console.WriteLine($"{nameof (DidRemoveDevice)}: {device}");
     ScannersController.RemoveObject(device);
 }
Пример #19
0
 public void DidEncounterError(ICDevice device, NSError error) => Console.WriteLine($"{nameof (DidEncounterError)}: {device} Error: {error}");
Пример #20
0
 public void DidReceiveButtonPress(ICDevice device, string buttonType) => Console.WriteLine($"{nameof (DidReceiveButtonPress)}: {device} Button: {buttonType}");
Пример #21
0
 public void DidChangeName(ICDevice device) => Console.WriteLine($"{nameof (DidChangeName)}: {device}");
Пример #22
0
 public CPixelShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
 }
Пример #23
0
 public void DidCloseSession(ICDevice device, NSError error) => Console.WriteLine($"{nameof (DidCloseSession)}: {device} Error: {error}");
Пример #24
0
        public void DidBecomeReady(ICDevice device)
        {
            var scanner        = device as ICScannerDevice;
            var availabeTypes  = scanner.AvailableFunctionalUnitTypes;
            var functionalUnit = scanner.SelectedFunctionalUnit;

            Console.WriteLine($"{nameof (DidBecomeReady)}: {scanner}");

            FunctionalUnitMenu.RemoveAllItems();
            FunctionalUnitMenu.Enabled = false;

            if (availabeTypes.Length > 0)
            {
                var menu = new NSMenu();
                FunctionalUnitMenu.Enabled = true;

                foreach (var item in availabeTypes)
                {
                    NSMenuItem menuItem;
                    switch ((ICScannerFunctionalUnitType)item.Int32Value)
                    {
                    case ICScannerFunctionalUnitType.Flatbed:
                        menuItem = new NSMenuItem("Flatbed", "", SelectFunctionalUnit)
                        {
                            Tag = (nint)(long)ICScannerFunctionalUnitType.Flatbed
                        };
                        menu.AddItem(menuItem);
                        break;

                    case ICScannerFunctionalUnitType.PositiveTransparency:
                        menuItem = new NSMenuItem("PositiveTransparency", "", SelectFunctionalUnit)
                        {
                            Tag = (nint)(long)ICScannerFunctionalUnitType.PositiveTransparency
                        };
                        menu.AddItem(menuItem);
                        break;

                    case ICScannerFunctionalUnitType.NegativeTransparency:
                        menuItem = new NSMenuItem("NegativeTransparency", "", SelectFunctionalUnit)
                        {
                            Tag = (nint)(long)ICScannerFunctionalUnitType.NegativeTransparency
                        };
                        menu.AddItem(menuItem);
                        break;

                    case ICScannerFunctionalUnitType.DocumentFeeder:
                        menuItem = new NSMenuItem("DocumentFeeder", "", SelectFunctionalUnit)
                        {
                            Tag = (nint)(long)ICScannerFunctionalUnitType.DocumentFeeder
                        };
                        menu.AddItem(menuItem);
                        break;
                    }
                }
                FunctionalUnitMenu.Menu = menu;
            }
            Console.WriteLine($"observeValueForKeyPath - functionalUnit: {functionalUnit}");
            if (functionalUnit != null)
            {
                FunctionalUnitMenu.SelectItemWithTag((nint)(long)functionalUnit.Type);
            }
        }
Пример #25
0
        // IICDeviceBrowser Interface

        public void DidRemoveDevice(ICDevice device)
        {
            Console.WriteLine($"{nameof (DidRemoveDevice)}: {device}");
            ScannersController.RemoveObject(device);
        }
Пример #26
0
 public CComputeShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
 }
Пример #27
0
 public CVertexShader(ICDevice device, CShaderReflection reflection)
     : base(device, reflection)
 {
     attributeNames = Reflection.Input.Where(v => v.IsUsed && !v.IsSystem).Select(v => OutputPrefixForStage(ShaderStage.Vertex) + v.Semantic).ToArray();
 }