Ejemplo n.º 1
0
        string GetUAVTypeName(ResourceBinding resourceBinding)
        {
            switch (resourceBinding.Dimension)
            {
            case ShaderResourceViewDimension.Buffer:
                return("RWBuffer");

            case ShaderResourceViewDimension.Texture1D:
                return("RWTexture1D");

            case ShaderResourceViewDimension.Texture1DArray:
                return("RWTexture1DArray");

            case ShaderResourceViewDimension.Texture2D:
                return("RWTexture2D");

            case ShaderResourceViewDimension.Texture2DArray:
                return("RWTexture2DArray");

            case ShaderResourceViewDimension.Texture3D:
                return("RWTexture3D");

            default:
                throw new ArgumentException($"Unexpected resource binding dimension type {resourceBinding.Dimension}");
            }
        }
Ejemplo n.º 2
0
 void InitConstantBuffer(ConstantBuffer cb, string registerName, ResourceBinding binding)
 {
     foreach (var variable in cb.Variables)
     {
         InitMember(variable.Member, registerName, binding.BindPoint);
     }
 }
Ejemplo n.º 3
0
        string GetStructuredTypeName(ResourceBinding resourceBinding)
        {
            var buffer = Container.ResourceDefinition.ConstantBuffers.Single(cb =>
                                                                             cb.BufferType == ConstantBufferType.ResourceBindInformation &&
                                                                             cb.Name == resourceBinding.Name);
            var typeName = "";

            if (buffer.Variables[0].ShaderType.VariableClass == ShaderVariableClass.Struct)
            {
                typeName = buffer.Variables[0].ShaderType.BaseTypeName;
                if (string.IsNullOrEmpty(typeName))
                {
                    var index = Container.ResourceDefinition.ConstantBuffers
                                .Where(cb => cb.BufferType == ConstantBufferType.ResourceBindInformation)
                                .ToList()
                                .FindIndex(cb => cb == buffer);
                    typeName = $"struct{index}";
                }
                typeName = $"struct {typeName}";
            }
            else
            {
                typeName = GetShaderTypeName(buffer.Variables[0].ShaderType);
            }
            return(typeName);
        }
Ejemplo n.º 4
0
        static IrResourceClass GetResourceClass(ResourceBinding binding)
        {
            switch (binding.Type)
            {
            case ShaderInputType.CBuffer:
                return(IrResourceClass.CBuffer);

            case ShaderInputType.Sampler:
                return(IrResourceClass.Sampler);

            case ShaderInputType.TBuffer:
            case ShaderInputType.Texture:
            case ShaderInputType.Structured:
            case ShaderInputType.ByteAddress:
                return(IrResourceClass.SRV);

            case ShaderInputType.UavRwTyped:
            case ShaderInputType.UavRwStructured:
            case ShaderInputType.UavRwByteAddress:
            case ShaderInputType.UavAppendStructured:
            case ShaderInputType.UavConsumeStructured:
            case ShaderInputType.UavRwStructuredWithCounter:
                return(IrResourceClass.UAV);

            default:
                throw new ArgumentException($"Unexpected Binding Type {binding.Type}");
            }
        }
Ejemplo n.º 5
0
        private static ResourceBinding CreateResourceBinding(
            ShaderModel model,
            ResourceDefinition resource)
        {
            var resourceBinding = new ResourceBinding
            {
                Name = resource.Name,
                Type = GetResourceKind(resource.ResourceKind)
            };

            var shaderStages = ShaderStages.None;

            if (model.VertexResources.Contains(resource))
            {
                shaderStages |= ShaderStages.Vertex;
            }
            if (model.FragmentResources.Contains(resource))
            {
                shaderStages |= ShaderStages.Fragment;
            }
            resourceBinding.Stages = shaderStages;

            switch (resourceBinding.Type)
            {
            case ResourceKind.StructuredBufferReadOnly:
                resourceBinding.Size = (uint)model.GetTypeSize(resource.ValueType);
                break;

            case ResourceKind.UniformBuffer:
                resourceBinding.Fields = new List <UniformBufferField>();
                resourceBinding.Size   = (uint)model.GetTypeSize(resource.ValueType);
                var structureDefinition = model.GetStructureDefinition(resource.ValueType);
                if (structureDefinition != null)     // Uniform buffers can be of built-in type
                {
                    var offset = 0;
                    foreach (var field in structureDefinition.Fields)
                    {
                        var uniformBufferField = new UniformBufferField();
                        resourceBinding.Fields.Add(uniformBufferField);

                        uniformBufferField.Name   = field.Name;
                        uniformBufferField.Offset = offset;

                        var fieldSize = model.GetTypeSize(field.Type);
                        if (field.IsArray)
                        {
                            fieldSize *= field.ArrayElementCount;
                        }
                        uniformBufferField.Size = fieldSize;

                        offset += uniformBufferField.Size;
                    }
                }
                break;
            }

            return(resourceBinding);
        }
Ejemplo n.º 6
0
 protected GraphicBuffer(long size, int stride, ResourceUsage usage, CpuAccessFlags access, ResourceBinding binding)
     : base(ResourceType.Buffer)
 {
     _lenght       = size;
     _stride       = stride;
     _usage        = usage;
     _cpuAccesType = access;
     _binding      = binding;
 }
Ejemplo n.º 7
0
        public MainWindow()
        {
            ResourceBinding.Scaling(0.75);
            //Entities DB = new Entities();

            try
            {
                //  var profilesByMME = DB.MME_CODES.Include(m=> m.MME_CODES_TO_PROFILES).Single(m => m.Name == "MME008").MME_CODES_TO_PROFILES.Select(m => m.PROFILE).GroupBy(m => m.PROF_NAME);
//                var highVersionProfiles = profilesByMME.Select(m => m.OrderByDescending(n => n.PROF_VERS).First()).ToList();
            }
            catch (Exception ex)
            {
            }
            InitializeComponent();
        }
Ejemplo n.º 8
0
 private static void CompareResourceBinding(InputBindingDescription expected,
                                            ResourceBinding actual)
 {
     Assert.AreEqual((uint)expected.BindCount, actual.BindCount);
     Assert.AreEqual(expected.BindPoint, actual.BindPoint);
     Assert.AreEqual((int)expected.Dimension, (int)actual.Dimension);
     Assert.AreEqual((int)expected.Flags, (int)actual.Flags);
     Assert.AreEqual(expected.Name, actual.Name);
     if (expected.NumSamples != -1 || actual.NumSamples != uint.MaxValue)
     {
         Assert.AreEqual(expected.NumSamples, actual.NumSamples);
     }
     Assert.AreEqual((int)expected.ReturnType, (int)actual.ReturnType);
     Assert.AreEqual((int)expected.Type, (int)actual.Type);
 }
Ejemplo n.º 9
0
        public MainWindow()
        {
            ResourceBinding.Scaling(0.60);

            InitializeComponent();
            Cache.Main = this;
            Cache.SelectEditModePage = new SelectEditModePage();

            var navigationService = NavigationService.GetNavigationService(MainFrame);

            MainFrame?.Navigate(Cache.SelectEditModePage);

            //MainFrame.Navigate(new ProfilesPage(new MSSQLDbService(new SqlConnection(@"Data Source=IVAN-PC\SQLEXPRESS01;Initial Catalog=SCME_ResultsDBTest;Integrated Security=true;")), "MME005"));
            //MainFrame?.Navigate(new MatchingProfilesCodesPage(new MSSQLDbService(new SqlConnection(@"Data Source=IVAN-PC\SQLEXPRESS01;Initial Catalog=SCME_ResultsDBTest;Integrated Security=true;"))));
        }
Ejemplo n.º 10
0
        static IrResourceBinding ParseBinding(ResourceBinding binding)
        {
            var irBinding = new IrResourceBinding()
            {
                Name      = binding.Name,
                Class     = GetResourceClass(binding),
                Kind      = GetResourceKind(binding),
                Dimension = binding.NumSamples == uint.MaxValue ? 0 : binding.NumSamples,
                BindPoint = binding.BindPoint,
                BindCount = binding.BindCount,
                Debug     = binding.ToString()
            };

            if ((irBinding.Class == IrResourceClass.SRV || irBinding.Class == IrResourceClass.UAV) &&
                irBinding.Kind != IrResourceKind.TBuffer)
            {
                irBinding.ReturnType = ParseShaderReturnType(binding);
            }
            return(irBinding);
        }
Ejemplo n.º 11
0
        string GetBindingName(ResourceBinding resourceBinding)
        {
            switch (resourceBinding.Type)
            {
            case ShaderInputType.Texture:
                return(GetTextureTypeName(resourceBinding));

            case ShaderInputType.Sampler:
                return(resourceBinding.Flags.HasFlag(ShaderInputFlags.ComparisonSampler) ?
                       "SamplerComparisonState" :
                       "SamplerState");

            case ShaderInputType.ByteAddress:
                return("ByteAddressBuffer");

            case ShaderInputType.Structured:
                return("StructuredBuffer");

            case ShaderInputType.UavRwByteAddress:
                return("RWByteAddressBuffer");

            case ShaderInputType.UavRwStructuredWithCounter:
            case ShaderInputType.UavRwStructured:
                return("RWStructuredBuffer");

            case ShaderInputType.UavRwTyped:
                return(GetUAVTypeName(resourceBinding));

            case ShaderInputType.UavAppendStructured:
                return("AppendStructuredBuffer");

            case ShaderInputType.UavConsumeStructured:
                return("ConsumeStructuredBuffer");

            default:
                throw new ArgumentException($"Unexpected resource binding type {resourceBinding.Type}");
            }
        }
Ejemplo n.º 12
0
        string GetTextureTypeName(ResourceBinding resourceBinding)
        {
            switch (resourceBinding.Dimension)
            {
            case ShaderResourceViewDimension.Texture1D:
                return("Texture1D");

            case ShaderResourceViewDimension.Texture1DArray:
                return("Texture1DArray");

            case ShaderResourceViewDimension.Texture2D:
                return("Texture2D");

            case ShaderResourceViewDimension.Texture2DArray:
                return("Texture2DArray");

            case ShaderResourceViewDimension.Buffer:
                return("Buffer");

            case ShaderResourceViewDimension.Texture2DMultiSampled:
                return("Texture2DMS");

            case ShaderResourceViewDimension.Texture2DMultiSampledArray:
                return("Texture2DMSArray");

            case ShaderResourceViewDimension.TextureCube:
                return("TextureCube");

            case ShaderResourceViewDimension.TextureCubeArray:
                return("TextureCubeArray");

            case ShaderResourceViewDimension.Texture3D:
                return("Texture3D");

            default:
                throw new ArgumentException($"Unexpected resource binding  dimension type {resourceBinding.Dimension}");
            }
        }
Ejemplo n.º 13
0
        public void Add(DependencyProperty property, ResourceBinding resourceBinding)
        {
            var dict = _bindings.FindOrCreate(property, () => new Dictionary <DependencyPropertyValuePrecedences, ResourceBinding>());

            dict[resourceBinding.Precedence] = resourceBinding;
        }
Ejemplo n.º 14
0
 public IrResourceBinding(ResourceBinding binding)
 {
     Name = binding.Name;
 }
Ejemplo n.º 15
0
 public EffectParameter(
     GraphicsDevice graphicsDevice,
     ResourceBinding resourceBinding,
     in ResourceLayoutElementDescription layoutDescription,
Ejemplo n.º 16
0
        public GraphicBuffer CreateVertexBuffer(int size, int stride, Array data, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAcces = CpuAccessFlags.ReadWrite, ResourceBinding binding = ResourceBinding.VertexBuffer)
        {
            GCHandle      handle = GCHandle.Alloc(data, GCHandleType.Pinned);
            var           pter   = Marshal.UnsafeAddrOfPinnedArrayElement(data, 0);
            GraphicBuffer buffer;

            try
            {
                buffer = CreateVertexBuffer(size, stride, usage, cpuAcces, binding, pter);
            }
            finally
            {
                handle.Free();
            }
            return(buffer);
        }
Ejemplo n.º 17
0
        public GraphicBuffer CreateVertexBuffer <T>(int stride, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAcces = CpuAccessFlags.ReadWrite, ResourceBinding binding = ResourceBinding.VertexBuffer, T[] data = null)
            where T : struct
        {
            int size = data.Length * ClrRuntime.Runtime.SizeOf <T>();

            return(CreateVertexBuffer(size, stride, data, usage, cpuAcces, binding));
        }
Ejemplo n.º 18
0
        void WriteResourceBinding(ResourceBinding resourceBinding)
        {
            Output.AppendLine(resourceBinding.ToString());
            if (resourceBinding.Type == ShaderInputType.CBuffer || resourceBinding.Type == ShaderInputType.TBuffer)
            {
                return;
            }
            if (resourceBinding.Type.IsUav())
            {
                var dcl = Container.Shader.DeclarationTokens
                          .OfType <UnorderedAccessViewDeclarationTokenBase>()
                          .Single(t => t.Operand.Indices[0].Value == resourceBinding.ID);
                if (dcl.Coherency == UnorderedAccessViewCoherency.GloballyCoherent)
                {
                    Output.Append("globallycoherent ");
                }
            }
            var type = GetBindingName(resourceBinding);

            Output.Append(type);
            if (resourceBinding.Type == ShaderInputType.Texture || resourceBinding.Type == ShaderInputType.UavRwTyped)
            {
                if (!(resourceBinding.ReturnType == ResourceReturnType.Float &&
                      resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponents) &&
                      !resourceBinding.Dimension.IsMultiSampled()) || resourceBinding.Type == ShaderInputType.UavRwTyped)
                {
                    string returnType = GetReturnTypeDescription(resourceBinding.ReturnType);
                    if (resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponent0) && !resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponent1))
                    {
                        returnType += "2";
                    }
                    if (!resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponent0) && resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponent1))
                    {
                        returnType += "3";
                    }
                    if (resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponent0) && resourceBinding.Flags.HasFlag(ShaderInputFlags.TextureComponent1))
                    {
                        returnType += "4";
                    }
                    if (resourceBinding.Dimension.IsMultiSampled() && resourceBinding.NumSamples > 0)
                    {
                        Output.AppendFormat("<{0}, {1}>", returnType, resourceBinding.NumSamples);
                    }
                    else
                    {
                        Output.AppendFormat("<{0}>", returnType);
                    }
                }
            }
            if (resourceBinding.Type.IsStructured())
            {
                var typeName = GetStructuredTypeName(resourceBinding);
                Output.AppendFormat("<{0}>", typeName);
            }
            Output.Append($" {resourceBinding.Name}");
            if (EmitRegisterDeclarations)
            {
                Output.Append($" : register({resourceBinding.GetBindPointDescription()})");
            }
            Output.AppendLine($";");
        }
Ejemplo n.º 19
0
 public abstract GraphicBuffer CreateVertexBuffer(int size, int stride, ResourceUsage usage = ResourceUsage.Default, CpuAccessFlags cpuAcces = CpuAccessFlags.ReadWrite, ResourceBinding binding = ResourceBinding.VertexBuffer, IntPtr data = default(IntPtr));
Ejemplo n.º 20
0
        static IrShaderType ParseShaderReturnType(ResourceBinding binding)
        {
            var returnType = new IrShaderType();

            switch (binding.ReturnType)
            {
            case ResourceReturnType.Float:
                returnType.VariableType = IrShaderVariableType.F32;
                break;

            case ResourceReturnType.Double:
                returnType.VariableType = IrShaderVariableType.F64;
                break;

            case ResourceReturnType.SInt:
                returnType.VariableType = IrShaderVariableType.I32;
                break;

            case ResourceReturnType.UInt:
                returnType.VariableType = IrShaderVariableType.U32;
                break;

            case ResourceReturnType.UNorm:
                returnType.VariableType = IrShaderVariableType.UNormF32;
                break;

            case ResourceReturnType.SNorm:
                returnType.VariableType = IrShaderVariableType.SNormF32;
                break;

            case ResourceReturnType.Mixed:
                switch (binding.Type)
                {
                case ShaderInputType.Structured:
                case ShaderInputType.UavRwStructured:
                case ShaderInputType.UavAppendStructured:
                case ShaderInputType.UavConsumeStructured:
                case ShaderInputType.UavRwStructuredWithCounter:
                    break;

                case ShaderInputType.ByteAddress:
                case ShaderInputType.UavRwByteAddress:
                    //TODO: Byte type?
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            default:
                throw new NotImplementedException();
            }
            switch (binding.Type)
            {
            case ShaderInputType.Structured:
            case ShaderInputType.UavRwStructured:
            case ShaderInputType.UavAppendStructured:
            case ShaderInputType.UavConsumeStructured:
            case ShaderInputType.UavRwStructuredWithCounter:
                returnType.VariableClass = ShaderVariableClass.Struct;
                returnType.BaseTypeName  = "TODO";
                break;

            default:
                ushort componentCount = 1;
                if (binding.Flags.HasFlag(ShaderInputFlags.TextureComponent0))
                {
                    componentCount += 1;
                }
                if (binding.Flags.HasFlag(ShaderInputFlags.TextureComponent1))
                {
                    componentCount += 2;
                }
                returnType.Columns       = componentCount;
                returnType.VariableClass = componentCount == 1 ?
                                           ShaderVariableClass.Scalar :
                                           ShaderVariableClass.Vector;
                break;
            }
            return(returnType);
        }
Ejemplo n.º 21
0
        public MainWindow()
        {
            string s = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Application.Current.DispatcherUnhandledException += DispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException       += CurrentDomainOnUnhandledException;

            try
            {
                //Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Localization);
//                CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(Settings.Default.Localization);
//                Thread.CurrentThread.CurrentCulture = new CultureInfo(Settings.Default.Localization);
//                Thread.CurrentThread.CurrentUICulture = new CultureInfo(Settings.Default.Localization);
//                LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
//                    XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
            }
            catch (Exception ex)
            {
                var dw = new DialogWindow("Localization error", ex.Message);
                dw.ButtonConfig(DialogWindow.EbConfig.OK);
                dw.ShowDialog();
            }

            Cache.Keyboards = new KeyboardLayouts(Path.IsPathRooted(Settings.Default.KeyboardsPath) ? Settings.Default.KeyboardsPath : Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), Settings.Default.KeyboardsPath));

            ResourceBinding.Scaling(0.60);

            InitializeComponent();

            m_InitialClampLabelContent = clampLabel.Content;

            m_XRed    = (SolidColorBrush)FindResource("xRed1");
            m_XOrange = (SolidColorBrush)FindResource("xOrange1");

            VM.TechPasswordVisibility = Visibility.Collapsed;

            try
            {
                Cache.Main = this;
                if (Settings.Default.WindowIs1280x1024)
                {
                    Top         = SystemParameters.WorkArea.Top;
                    Left        = SystemParameters.WorkArea.Left;
                    Width       = 1280;
                    Height      = 1024;
                    WindowState = WindowState.Normal;
                }
                else
                {
                    if (Settings.Default.NormalWindow)
                    {
                        WindowStyle           = WindowStyle.SingleBorderWindow;
                        WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        ResizeMode            = ResizeMode.CanResize;
                        WindowState           = WindowState.Maximized;
                    }
                    else
                    {
                        Top    = SystemParameters.WorkArea.Top;
                        Left   = SystemParameters.WorkArea.Left;
                        Width  = SystemParameters.WorkArea.Width;
                        Height = SystemParameters.WorkArea.Height;
                    }
                }

                Cache.Storage = new LocalStorage(Settings.Default.StoragePath);
                Cache.Net     = new ControlLogic();

                VM.IsSafetyBreakIconVisible = false;

                RestartRoutine(null, null);
            }
            catch (Exception ex)
            {
                var dw = new DialogWindow(Properties.Resources.ApplicationStartError, ex.Message);
                dw.ButtonConfig(DialogWindow.EbConfig.OK);
                dw.ShowDialog();

                Application.Current.Shutdown(1);
            }

            mainFrame.Navigated  += MainFrameOnNavigated;
            mainFrame.Navigating += MainFrameOnNavigating;
        }
Ejemplo n.º 22
0
        static IrResourceKind GetResourceKind(ResourceBinding binding)
        {
            switch (binding.Type)
            {
            case ShaderInputType.CBuffer:
                return(IrResourceKind.CBuffer);

            case ShaderInputType.TBuffer:
                return(IrResourceKind.TBuffer);

            case ShaderInputType.Texture:
            case ShaderInputType.UavRwTyped:
                switch (binding.Dimension)
                {
                case ShaderResourceViewDimension.Texture1D:
                    return(IrResourceKind.Texture1D);

                case ShaderResourceViewDimension.Texture1DArray:
                    return(IrResourceKind.Texture1DArray);

                case ShaderResourceViewDimension.Texture2D:
                    return(IrResourceKind.Texture2D);

                case ShaderResourceViewDimension.Texture2DArray:
                    return(IrResourceKind.Texture2DArray);

                case ShaderResourceViewDimension.Texture2DMultiSampled:
                    return(IrResourceKind.Texture2DMS);

                case ShaderResourceViewDimension.Texture2DMultiSampledArray:
                    return(IrResourceKind.Texture2DMSArray);

                case ShaderResourceViewDimension.Texture3D:
                    return(IrResourceKind.Texture3D);

                case ShaderResourceViewDimension.TextureCube:
                    return(IrResourceKind.TextureCube);

                case ShaderResourceViewDimension.TextureCubeArray:
                    return(IrResourceKind.TextureCubeArray);

                case ShaderResourceViewDimension.Buffer:
                    return(IrResourceKind.TypedBuffer);

                default:
                    throw new ArgumentException($"Unexpected Binding Dimension: {binding.Dimension}");
                }

            case ShaderInputType.ByteAddress:
            case ShaderInputType.UavRwByteAddress:
                return(IrResourceKind.RawBuffer);

            case ShaderInputType.Structured:
            case ShaderInputType.UavRwStructured:
            case ShaderInputType.UavAppendStructured:
            case ShaderInputType.UavConsumeStructured:
            case ShaderInputType.UavRwStructuredWithCounter:
                return(IrResourceKind.StructuredBuffer);

            case ShaderInputType.Sampler:
                return(IrResourceKind.Sampler);

            default:
                throw new ArgumentException($"Unexpected Binding Type: {binding.Type}");
            }
        }